Perform Through Example


Scenario - Executing paragraphs using PERFORM...THRU.

Code -

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

       PROCEDURE DIVISION.
           PERFORM 1000-DISPLAY1 
              THRU 2000-DISPLAY2.
           STOP RUN.

       1000-DISPLAY1.
           DISPLAY "PARAGRAPH1". 
       2000-DISPLAY2.
           DISPLAY "PARAGRAPH2".
       3000-DISPLAY3.
           DISPLAY "PARAGRAPH3".
       4000-DISPLAY3.
           DISPLAY "PARAGRAPH4".

Output -

Paragraph1
Paragraph2
Paragraph3

Explaining Example -

In the above example:

  • It has four paragraphs coded. PERFORM statement only executes 1000-DISPLAY1 THRU 3000-DISPLAY3. After 3000-DISPLAY3 execution, control returns back to PROCEDURE DIVISION.