Simple PERFORM


  • A simple PERFORM statement executes a block of COBOL statements, typically grouped into paragraphs or sections.
  • It executes a given paragraph or section once, and control is passed to the following statement in the flow.
  • It is both inline and outline.

Syntax -

Inline PERFORMOutline PERFORM
PERFORM 
   statements-block
END-PERFORM.
PERFORM paragraph-name|section-name

Parameters -

  • paragraph-name - The name of the paragraph we want to execute.
  • section-name - The name of the section we want to execute. Remember that a section can contain multiple paragraphs.

Practical Example -


Scenario - Simple Outline PERFORM coding in COBOL program.

Code -

----+----1----+----2----+----3----+----4----+----5----+
       ...
       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