Summary -
In this topic, we described about the below sections -
PERFORM UNTIL used to execute the statements-block/paragraph until the specified condition true. Control is then passed to the next executable statement following the PERFORM statement. PERFORM UNTIL statement is both in-line and out-of-line.
Syntax -

In-line perform | Out-of-line perform |
---|---|
UNTIL -PERFORM UNTIL condition-1 imperative-statement-1 END-PERFORM. |
UNTIL -PERFORM procedure-name-1 THROGH/THRU procedure-name-2 UNTIL condition-1 |
WITH TEST BEFORE -PERFORM WITH TEST BEFORE UNTIL condition-1 imperative-statement-1 END-PERFORM. | WITH TEST BEFORE -PERFORM procedure-name-1 THROGH/THRU procedure-name-2 WITH TEST BEFORE UNTIL condition-1 |
WITH TEST AFTER -PERFORM WITH TEST AFTER UNTIL condition-1 imperative-statement-1 END-PERFORM. |
WITH TEST AFTER -PERFORM procedure-name-1 THROGH/THRU procedure-name-2 WITH TEST AFTER UNTIL condition-1 |
If procedure-name-1 is specified, imperative-statement-1 and the END-PERFORM phrase must not be specified. If procedure-name-1 is omitted, imperative-statement-1 and the END-PERFORM phrase must be specified.
procedure-name-1, procedure-name-2 -
Must name a section or paragraph in the procedure division. If one of the procedures is in a declarative procedure and both procedures are specified, the other procedure also must be procedure-names in the same declarative procedure.
If procedure-name-1 is specified, imperative-statement-1 and the END-PERFORM phrase must not be specified. If procedure-name-1 is omitted, imperative-statement-1 and the END-PERFORM phrase must be specified.
imperative-statement-1 -
The statements-block to be executed for an in-line PERFORM.
condition-1 -
Can be any logical expression with a combination of operands and operators. The loop iterated until the condition is false and once the condition is true, the loops gets terminated and control is passed to the next executable statement following the PERFORM statement. The operands in the condition-1 can be subscripted.
WITH TEST BEFORE -
WITH TEST BEFORE is used to test the condition before executing the statements block. If the condition is true, then simply terminate the loop and control transfers to the next executable statements. WITH TEST BEFORE is default phase with PERFORM if not specified any.
WITH TEST AFTER -
WITH TEST AFTER is used to test the condition after executing the statements block. It simply executes the statements block without checking the condition.
After one iteration completed, it validates the condition. i.e. The statements-block gets executed one time at least even though the condition is true for first time itself.
Practical Example - Inline PERFORM UNTIL
Code -

Jcl -

Output -

Practical Example - Inline PERFROM UNTIL WITH TEST BEFORE:
Code -

Jcl -

Output -

Practical Example - Inline PERFORM UNTIL WITH TEST AFTER:
Code -

Jcl -

Output -
