Converting from hexadecimal or bit data (HEX-TO-CHAR, BIT-TO-CHAR)

You can use the HEX-TO-CHAR or BIT-TO-CHAR intrinsic functions to convert hexadecimal character strings (consisting of characters "0" through "9", "A" through "F", and "a" through "f") or bit character strings (consisting of characters "0" and "1") to alphanumeric data items.

About this task

HEX-TO-CHAR

The HEX-TO-CHAR intrinsic function can be used to convert a character string consisting of hexadecimal digits ("0" through "9", "A" through "F", and "a" through "f") to an alphanumeric character string consisting of bytes that correspond to the hexadecimal digits in the input character string.

For example,
MOVE 'FFAABB' TO MY-HEX-DATA
FUNCTION HEX-TO-CHAR(MY-HEX-DATA) returns a character string with value x'FFAABB'.

The argument to the HEX-TO-CHAR intrinsic function can be an alphanumeric literal, alphanumeric data item, or alphanumeric group item. The length of the argument must be a multiple of 2 bytes.

BIT-TO-CHAR

The BIT-TO-CHAR intrinsic function can be used to convert a character string consisting of characters "0" and "1" to an alphanumeric character string consisting of bytes that correspond to the bit pattern indicated by the sequence of "0" and "1" characters in the input character string.

For example,
MOVE '1111001000000110' TO MY-BIT-DATA
FUNCTION BIT-TO-CHAR(MY-BIT-DATA) returns a character string with value x'F206'.

The argument to the BIT-TO-CHAR intrinsic function can be an alphanumeric literal, alphanumeric data item or alphanumeric group item. The length of the argument must be a multiple of 8 bytes.

Related references  
BIT-TO-CHAR (Enterprise COBOL for z/OS® Language Reference)
HEX-TO-CHAR (Enterprise COBOL for z/OS Language Reference)