×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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  

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

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.

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

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).

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

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.

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

And if you want to show more than one byte - add the loop wink

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

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close