77 Level Number Example


Scenario - Declaring a variable using 77-level number.

Code -

----+----1----+----2----+----3----+----4----+----5----+----6
       IDENTIFICATION DIVISION.
       PROGRAM-ID. LEVEL77.
       AUTHOR. MTH.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
      * Declaring Individual Variable
       01 WS-VAR1       PIC X(10) VALUE "MAINFRAMES".
       77 WS-VAR2       PIC X(10) VALUE "MAINFRAMES".

       PROCEDURE DIVISION.

           DISPLAY "WS-VAR1: " WS-VAR1.
           DISPLAY "WS-VAR2: " WS-VAR2.

           STOP RUN.

Explaining Example -

In the above example:

  • WS-VAR1 is declared using level-01, and WS-VAR2 is declared with level-77.
  • We can't extend WS-VAR2 because it is an individual variable. We can extend WS-VAR1 if required, like below -
    01 WS-VAR1.
       05 WS-VAR11      PIC X(10).
       05 WS-VAR12      PIC X(10).
       05 WS-VAR13      PIC X(10).
       ...
       ...
       ...