COBOL General Levels

GENERAL LEVEL NUMBERS IN COBOL​

COBOL defines data items in Levels 

01 level – Topmost level.

  • We can use this for an Individual data item or a group item. There cannot be another 01 levels within a 01 level.

  Example:   01 EMP-ID PIC 9(5). Here this an is individual variable and no sub-items are present below this.

  • This can also use for Group data item. Group data item does not have a picture clause. It has elementary items below it.

    Example: 01 EMP-RECORD.  —- This is a group item

           05 EMP-ID PIC 9(5). —Elementary items

           05 EMP-NAME. — This is also a group item

  10 FIRST-NAME PIC A(15).

  10 LAST-NAME PIC A(15).

Level numbers with the same numeric value are considered at the same level.

As we move down, the level number must increase.

Level 01-49 is for general purpose

SPECIAL LEVEL NUMBERS IN COBOL​

Special purpose Level: 66, 77, 88

66 level – Used for RENAMES clause. and 66 levels should not have a picture clause.

  Example – 01 EMP-REC.

  05 EMP-ID PIC 9(5).

  05 EMP-NAME PIC A(10).

  05 EMP-BIRTH-DATE PIC  X(10).

66    EMP-DETAIL RENAMES EMP-ID THRU EMP-NAME.

77 – Normally we should avoid using 77 levels. we need use for an Individual data item or elementary data item. And we can’t subdivide it further.

88 level– This is used for conditional processing. 88 level must be coded under a group item. It works on the principle of true or false.

  Example: 01 CHECK-DAY.

  05 DAY PIC X(3).

  88 MONDAY  VALUE ‘MON’.

  88 TUESDAY      VALUE ‘TUE’.

  88 WEDNESDAY   VALUE ‘WED’.

  88 THURSDAY   VALUE ‘THU’.

  88 FRIDAY   VALUE  ‘FRI’.

  88 SATURDAY   VALUE ‘SAT’.

  88 SUNDAY   VALUE ‘SUN’.

Tutorials for all brains!