Simple Perform Example


Scenario - Simple Outline PERFORM.

Code -

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

       PROCEDURE DIVISION.
       MAIN-PARA.

           DISPLAY 'Start of Main Paragraph'.  
           PERFORM 1000-DISPLAY1
           DISPLAY 'End of Main Paragraph'.

           STOP RUN.

       1000-DISPLAY1.
           DISPLAY 'Inside DISPLAY1 Paragraph'.

Output -

Start of Main Paragraph  
Inside DISPLAY1 Paragraph
End of Main Paragraph

Explaining Example -

In the above example:

  • It displays message before first and continue with PERFORM loop.
  • As it is outline PERFORM loop with a paragraph 1000-DISPLAY1 and executes the statements in the paragraph.
  • Later, it displays message after the PERFORM loop.