Cobol – ‘PIC’ Clause Not Needed For Comp-1 and Comp-2

Comp variables have prominent importance in all mainframe technologies COBOL/IMSDB/IMSDC/CICS.

The advantage is, at word boundaries it is more efficient than comp-3, means takes less space.

The popular range:

PIC 9(1) — PIC 9(4)      2 bytes

PIC 9(5) — PIC 9(9)      4 bytes

PIC 9(10) — PIC 9(18)      8 bytes

As we aware the above values only for “COMP” data type. Let us take on “COMP-1” , so the data will store internally as 1 word. It takes 4 bytes of space.

Then, for Comp-2, the data will store internally as 2  words. So it takes 8 bytes. This is the reason Comp-2 is more precession than Comp-1.

The other great point is, we should not specify PIC for Comp-1 and Comp-2, the reason is, the data type(numeric) and sizes (4 or 8 bytes) are pre-determined. So PIC is not required.

PIC clause determined relation between data name and data type.

Bottom Line: Comp-1 take 4 bytes(1 word) is single precession & Comp-2 takes 8-bytes(2 words) is double precession.

05 DATA-ONE           USAGE IS COMP-1

05 DATA-TWO          USAGE IS COMP-2


Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.