Inine Perform Example


Scenario - Simple inline PERFORM.

Code -

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

       PROCEDURE DIVISION.

           DISPLAY 'Start of Main Paragraph'.
           PERFORM
               DISPLAY 'Inside DISPLAY1 Paragraph'
           END-PERFORM.
           DISPLAY 'End of Main Paragraph'.

           STOP RUN.

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 inline PERFORM loop and it executes only one time and displays the message.
  • Later, it displays message after the PERFORM loop.