Define a hex constant in the value clause of a PIC X element
search cancel

Define a hex constant in the value clause of a PIC X element

book

Article ID: 44042

calendar_today

Updated On:

Products

IDMS

Issue/Introduction

Is there a way to define a hex constant in the value clause of a PIC X element in the dictionary, similar to the following COBOL statement?

FIELD-NAME PIC X(01) VALUE X'C0'.

Environment

Release: All supported releases.

Resolution

To get a similar result, a PIC 9(1) USAGE COMP field could be defined with a value clause for a decimal value that is the hexadecimal equivalent of X'C0' or whatever hexadecimal is required. For this specific example, FIELD-NAME PIC 9(1) USAGE COMP VALUE 192. A PIC 9(1) USAGE COMP field is two bytes in length therefore the result will be x'00C0'. To access just the x'C0' byte refine the FIELD-NAME with another field that has two subordinate PIC X fields. Example:

02 FIELD-NAME PIC 9(1) USAGE COMP VALUE 192.
02 FIELD-NAME-R  REDEFINES FIELD-NAME.
   04 FIELD-NAME1 PIC X.
   04 FIELD-NAME2 PIC X.

In this example FIELD-NAME2 will have a hexadecimal value of X'C0'.

Additional Information