IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Display Hexadecimal Value in Cobol Program


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Jan 15, 2008 8:30 am
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: 1436
Location: Bangalore,India

PostPosted: Tue Jan 15, 2008 11:59 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top