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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Hex Command Format

Status
Not open for further replies.

martha3

MIS
Mar 25, 2003
1
US
Does anyone know what the format of the "Display" command that would allow me to display a numeric value in hex in my output? I thought it was Display Hex fieldname but it's not working. thanks.
 
There may be some other commands, but od has a hex option.
There may be some extraneous display characters you will want to cut out. Example:
echo "1" | od -x
 
Sorry about my previous post, I thought I was in the unix forum.
 
Hi,

If you're running on a mainframe, this should work. The redefines are a bit overdone for your purposes but it should work.

Regards, Jack.

Code:
           05  WS-WORK-PACKED          PIC 9(009)             COMP-3.
           05  REDEFINES WS-WORK-PACKED.
           10  WS-WORK-X5.
               20  WS-WORK-X1          PIC         X(001).
               20  WS-WORK-X3          PIC         X(003).
           05  REDEFINES WS-WORK-PACKED.
           10  WS-WORK-BIN4            PIC         9(009)     COMP.

           05  WS-WORK-UNPACKED        PIC 9(009).
           05  REDEFINES WS-WORK-UNPACKED.
           10  WS-WORK-UNPACKED-8      PIC         9(008).


       100-CONVERT-HEX-DATA.
      *-----------------------------------------------------      *===>  CONVERTS HEX DATA FOR DISPLAY PURPOSES
      *      E.G. X"04FB" ====> X"F0F4C6C2" OR 04FB CHARACTER
      *-----------------------------------------------------           MOVE    WS-WORK-PACKED TO WS-WORK-UNPACKED
           INSPECT WS-WORK-UNPACKED CONVERTING
                   X"FAFBFCFDFEFF"  TO  "ABCDEF"
           .
 
Sorry about the format. This should look better, I hope.
Code:
05  WS-WORK-PACKED           PIC 9(009) COMP-3.
05  REDEFINES WS-WORK-PACKED.
    10  WS-WORK-X5.
        20  WS-WORK-X1       PIC X(001).
        20  WS-WORK-X3       PIC X(003).
05  REDEFINES WS-WORK-PACKED.
    10  WS-WORK-BIN4         PIC 9(009) COMP.
        05  WS-WORK-UNPACKED PIC 9(009).
        05  REDEFINES WS-WORK-UNPACKED.
    10  WS-WORK-UNPACKED-8   PIC 9(008).


 100-CONVERT-HEX-DATA.
*--------------------------------------------------      
*  CONVERTS HEX DATA FOR DISPLAY PURPOSES
*  E.G. X"04FB" => X"F0F4C6C2" OR 04FB CHARACTER
*--------------------------------------------------      MOVE    WS-WORK-PACKED TO WS-WORK-UNPACKED
INSPECT WS-WORK-UNPACKED CONVERTING
        X"FAFBFCFDFEFF"  TO  "ABCDEF"
DISPLAY WS-WORK-UNPACKED-8
.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top