Simple PERFORM
Simple PERFORM
The PERFORM statement is used to execute a block of COBOL statements, which are typically grouped into a paragraph or section.
The simple PERFORM is a way to execute a given paragraph or section once, and control is passed to the next statement in the flow. It is both inline and outline.
Syntax -
Inline PERFORM | Outline PERFORM |
---|---|
|
|
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----+
IDENTIFICATION DIVISION.
PROGRAM-ID. SIMPPERF.
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