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
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts Need help in REXX CALL program Raje1002 CLIST & REXX 5 Wed Apr 19, 2017 11:18 pm


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