Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IBM MF COBOL: How to display read data in hex format?

Status
Not open for further replies.

RICHINMINN

Programmer
Dec 31, 2001
138
I'm having some issues with the data which is being read by a COBOL program on an IBM MVS mainframe. Is it possible to display the data (text and numeric, that has been read from an input file) in hex format? Is it simply a matter of moving the data to a 'USAGE NATIONAL' field and displaying that?

Does anyone have an example of this?

Thanks in advance.

RichinMinn
 
You mean what your program is getting or what the data are on the disk file? For the latter, there are different utilities which do this task (hex dump of file data by record size), or even the OS editor will do this with the right settings. This is what is typically done to see/troubleshoot what you should see from a disk file.

For the former, you'll have to be a little more specific as to what you are looking to get out of it.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
One way to do what you want id to define an array of 256 2-byte entries containing the values from x'00' to x'FF. Also define 2 other arrays to receive the "hex values"

Inside a loop, use an individual "hex" byte as the displacement into this array to retrieve/display the hex values for that byte.

When doing this i find it helpful to show the "fields" or the record as:

Code:
Input value: ABCDEF
Hex Over     CCCCCC
Hex Under    123456
in the output (similar to HEX ON in an edit/browse session).
 
A simpler and faster way is to avoid the search altogether.
1) Define a table of 2-byte hex values as suggested by papadba.
2) Define a subscript as follows:
Code:
01  SUB-G.
    05  SUB-1  PIC S9(4) COMP.
01  SUB-H REDEFINES SUB-G.
    05  FILLER PIC X.
    05  SUB-X  PIC X.
Then do the following:
Code:
    MOVE ZERO TO SUB-1.
    MOVE 1_byte_of_data TO SUB-X.
    ADD 1 TO SUM-1.
    MOVE hex_code(SUB-1) TO target.
 
Thanks, guys!
The conversion table seems to be the way to go. I won't, however, be able to get to it within the next few days, but I will let you know how it works out when I do have the time to pursue it.

RichinMinn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top