Absent Member.
Absent Member.

Initializing or moving values to COMP-5 fields

Hello folks,

I am dealing with quite a lot of fields in the CALL "PC_PRINTER_DEFAULT_FONT" and in the CALL "PC_PRINT_FILE" but I have never worked 

with COMP-5 format. Would please send a couple of examples or explanations to me. I did not succeed in the first seaches throgh the Internet.

Thanks a lot, in advance,


Rui Natal  

1 Reply
Micro Focus Expert
Micro Focus Expert

RE: Initializing or moving values to COMP-5 fields

COMP-5 fields are used to represent either signed or unsigned integer data stored as binary fields in the byte order of the computer on which the program is running.

The picture for a COMP-5 field can contain either 9's or X's.

In the case of 9's each 9 represents a decimal digit into which the value can be placed.

In the case of X's each X represents a single byte of storage so a PIC X(2) COMP-5 field represents a 16-bit fields while a PIC X(4) COMP-5 represents a 32-bit field.

You can move numeric values to a COMP-5 field in the same manner as other numeric fields which define an integer.

01 field1     pic 9(9) comp-5.       *> internally the same as pic x(4) or 32-bits.
01 field2     pic x(4) comp-5.

  move 500 to field1
  move 9999 to field2

For more information on the storage of fields including COMP-5, please see the Visual COBOL Documentation here:



The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.