Skip to main content

This article provides a sample COBOL routine to display the HEXA value of COBOL variables.

Problem:

How can you retrieve and display the HEXA value of COBOL variables?

Resolution:

The routine named HEXAutil.cbl attached to this article will sh you how to retrieve and display the HEXA value of COBOL variables.

Following is a sample COBOL program:
 

...
linkage section.
01 aCobolVar pic x ANY LENGTH.
procedure division using aCobolVar.
...
The test program callHEXAutil calls the routine HEXAutil:
  working-storage section.
78 HEXAUTIL value "hexautil".
01 anInt pic s9(9) comp-5 value 123456789.
01 aStr pic x(40) value "0123456789abcdefghijklmopqrtsuvwxyz".
01 aComp-2 comp-2 value 123456789.01.
01 aComp-3 pic 9(9) comp-3 value 123456789.
procedure division.
working-storage section.
78 HEXAUTIL value "hexautil".
01 anInt pic s9(9) comp-5 value 123456789.
01 aStr pic x(40) value "0123456789abcdefghijklmopqrtsuvwxyz".
01 aComp-2 comp-2 value 123456789.01.
01 aComp-3 pic 9(9) comp-3 value 123456789.
01 aComp-x pic 9(9) comp-x value 123456789.
01 aComp pic 9(9) comp value 123456789.
procedure division.
call HEXAUTIL using anint(1 : length of anInt)
call HEXAUTIL using aStr
call HEXAUTIL using aComp-2(1 : length of aComp-2)
call HEXAUTIL using aComp-3(1 : length of aComp-3)
call HEXAUTIL using aComp-x(1 : length of aComp-x)
call HEXAUTIL using aComp(1 : length of aComp)

Ensure that you can retrieve the HEXA value of alphanumeric like COMP variables.

Incident Number: 2280696

Old KB# 14622