How to Use COBOL 66 Level Field

In COBOL, 66 level is a special level and every programmer must know. Since this is a special level in COBOL.


COBOL 66 level example
Stocksnap.io

What you need to know

COBOL 66 assigns a new name to a field or group. It just assigns an alternative name to a field.

COBOL 66 Level Example

66 dataname_1 RENAMES dataname_2
...
...
01 WW-VAR1.
   05 WW-V1     PIC XX.
   05 WW-V2     PIC XXX.
   05 WW-V3.
     10 WW-V3-1 PIC X.
     10 WW-V3-2 PIC XX.
     10 WW-V3-3 PIC X.
     10 WW-V3-4 PIC XX.
   05 WW-V4     PIC X(06).
   05 WW-V5     PIC X(10).
   05 WW-V6     pic x(04).
   66 WW-RNM1 RENAMES WW-V2 THRU WW-V3-2.
   66 WW-RNM2 RENAMES WW-V2 THRU WW-V3-4.

So physically it does not add any field to copy book. It is just a logical name. You cannot rename 01, 88, 77, 66 level numbers.

You can do RENAMES to regroup the data elements.

Recently my friend has been asked the same question in an interview.

Related Posts

Author: Srini

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