Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Display Hexadecimal Value in Cobol Program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Kelly Kilpatrick

New User


Joined: 19 Sep 2006
Posts: 2

PostPosted: Wed Jan 09, 2008 8:35 pm    Post subject: Display Hexadecimal Value in Cobol Program
Reply with quote

For debugging purposes I would like to display the hex value for a field.
Back to top
View user's profile Send private message

mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Jan 09, 2008 10:06 pm    Post subject:
Reply with quote

Hi Kelly,

The easiest way is to redefine the field as a PIC X field and DISPLAY that.
For eg.:
Code:

05  pd-field        PIC S99999V99.
05  funky-data REDEFINES pd-field PIC XXXX.

Then via SDSF look at your sysout with "hex on". You'll see the data between the >< mentioned below.

When DISPLAYing fields that have funky data, I usually do this:
Code:

DISPLAY '>' FUNKY-DATA '<'

The data between the >< is what you displayed.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Jan 15, 2008 8:30 am    Post subject: Display Hexadecimal Value in Cobol Program
Reply with quote

Kelly,

Here's a tried and true method -

Code:

03  WS-PACKED       PIC  9(17)   PACKED-DECIMAL.
03  WS-PACKED-V9    REDEFINES WS-PACKED
                    PIC  9(16)V9 PACKED-DECIMAL.
03  WS-PACKED-X     REDEFINES WS-PACKED
                    PIC  X(09).
03  WS-DISPLAY      PIC  9(17).
03  WS-DISPLAY-V9   REDEFINES WS-DISPLAY
                    PIC  9(16)V9.
03  WS-DISPLAY-X    REDEFINES WS-DISPLAY
                    PIC  X(17).

MOVE X'0F'               TO WS-PACKED-X (LENGTH OF WS-PACKED-X:)
MOVE X'0123456789ABCDEF' TO WS-PACKED-X (1:LENGTH OF WS-PACKED-X - 1).
MOVE WS-PACKED-V9        TO WS-DISPLAY-V9.

INSPECT WS-DISPLAY-X     CONVERTING X'FAFBFCFDFEFF'
                         TO 'ABCDEF'.

DISPLAY WS-DISPLAY-X (1:LENGTH OF WS-DISPLAY-X - 1).


After the INSPECT, field WS-DISPLAY-X (1:LENGTH OF WS-DISPLAY-X - 1) will equal '0123456789ABCDEF'.

Note that these fields must be defined as UNSIGNED.

HTH....

Regards,

Bill
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Tue Jan 15, 2008 11:59 am    Post subject:
Reply with quote

Kelly,

Quote:
For debugging purposes I would like to display the hex value for a field.

Are you using any debugging tool (like expediter)?
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Jan 15, 2008 7:46 pm    Post subject:
Reply with quote

WOW,

DBz, CICS Guy, and now, Bill O'Boyle.

You guys must be getting desperate. icon_smile.gif
Not much going on over there.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
No new posts Display ZEDLMSG without Pressing F1 &... anandgbe CLIST & REXX 8 Thu Dec 15, 2016 4:20 pm
No new posts I can not compile my program PL1 V3.R... Miguel Fernandez PL/I & Assembler 13 Tue Dec 06, 2016 8:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us