Summary -

In this topic, we described about the below sections -

Iterative programming construction involves making the set of statements runs in repetitive/iterative/looping manner. In iterative programming construction, the statements execute repeatedly until the specified condition is true. The PERFORM statement is the part of the iterative programming construction.

PERFORM Statement -

PERFORM statement executes the set of statements/block of statements repetitively. The repetitive execution can be conditional or unconditional. If any condition specified, the statements block gets executed until the specified condition is true.

END-PERFORM phrase

The END-PERFORM used to end the scope of the in-line PERFORM statement. Execution of an in-line PERFORM statement is completed after executing the END-PERFORM statement.

END-PERFORM statement is optional if the statements under PERFORM is ended with period. The period considers as a logical end of PERFORM statement.

PERFORM Types -

PERFORM statement is mainly two types –

  • In-line PERFORM
  • Out-of-line PERFORM

The below table describes the differences between in-line an out-of-line PERFORM statements –

In-line PERFORMOut-of-line PERFORM
The PERFORM statement executes the implicit statement that coded in between PERFORM and END-PERFORM The PERFORM statement transfers control explicitly to one or more procedures
Not required to transfer the control explicitly Control explicitly transfers to the procedures
Not required to specify any procedure Procedures must specify in PERFORM statement
Mainly used to perform a set of statements/ block of statements that executed in between the PERFORM and END-PERFORM Mainly used to perform set of statements/ block of statements coded in separate section or separate paragraph or procedure
Scope terminator END-PERFORM is mandatory that represents the end of PERFORM statements Scope terminator END-PERFORM is not required
Note! A PERFORM statement must not cause itself to be executed. A recursive PERFORM statement can cause unpredictable results.

The in-line and out-of-line PERFORM formats can’t be combined. If procedure-name-1 is specified, imperative statements and the END-PERFORM phrase must not be specified. If procedure-name-1 is not specified, imperative statements and END-PERFORM phrase must be specified.

Different PERFORMs -

The PERFORM statement formats are -

PERFORM FormatDescription
Simple PERFORM Used to execute the statements-block/procedures
THROUGH PERFORM Used to execute the statements-block that are coded with procedure
TIMES phrase PERFORM Used to execute statements-block/procedures number of times specified
UNTIL phrase PERFORM Used to execute the statements-block/paragraph until the specified condition true
VARYING phrase PERFORM Used to execute the statements-block/procedures by increasing or decreasing the values of one or more identifiers for the iterations