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 XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm
No new posts pre-compiler for program in an HFS Pedro DB2 0 Fri Jun 23, 2017 11:13 pm
No new posts Display upon console bipinpeter COBOL Programming 1 Thu Jun 22, 2017 12:35 am
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm


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