Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 2504
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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts display the sign only if the value is... useit DFSORT/ICETOOL 3 Wed Oct 04, 2017 5:53 pm
No new posts Accessing CICS tran with map from JCL... navdeepaggarwal CICS 5 Tue Oct 03, 2017 6:15 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us