COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

END-PERFORM
ends the scope of the PERFORM statement, causing the PERFORM to be a delimited-scope
statement. If the PERFORM statement does not end with an END-PERFORM phrase, it is an
out-of-line PERFORM. If the PERFORM statement ends with an END-PERFORM phrase, it is an
in-line PERFORM.
Usage Considerations:
Execution Cycle of a PERFORM Statement (PERFORM Cycle)
Each execution of the range of a PERFORM statement is called a “PERFORM cycle.” It begins
with the implicit transfer of control to the first statement of the range of the PERFORM and ends
with an implicit transfer of control back to the internal decision logic of the PERFORM statement.
The point at which the return occurs depends upon the proc-1 THROUGH proc-2 phrase:
When proc-2 does not appear and proc-1 is a paragraph-name, the return occurs
after the execution of the last statement in the specified paragraph.
When proc-2 does not appear and proc-1 is a section-name, the return occurs after
the execution of the last statement of the last paragraph of that section.
When proc-2 does appear and is a paragraph-name, the return occurs after the
execution of the last statement in that paragraph.
When proc-2 does appear and is a section-name, the return occurs after the execution
of the last statement of the last paragraph of that section.
The preceding conditions for the return of control might be unsatisfied when the range includes
a GO TO statement. If the flow of control does not pass through the last statement indicated
above, the condition for return cannot be satisfied. Such a PERFORM cycle ends only when
the program terminates, which it can do by executing one of these statements:
A STOP RUN statement
An EXIT PROGRAM statement (from within in a called program)
The last statement in the program
Avoid including a GOTO statement in the range of a PERFORM statement. A GOTO statement
can cause a run-time diagnostic indicating that the PERFORM stack is full.
Procedure Relationships and the Ends of PERFORM Cycles
There is no necessary relationship between proc-1 and proc-2, except that a PERFORM
cycle begun at the procedure named by proc-1 ends when control reaches the return point
following the last statement of the procedure named by proc-2. GO TO statements, PERFORM
statements, CALL or ENTER statements, and so forth, can occur in the logical sequence of
statements executed during a PERFORM cycle. If there are two or more logical points at which
a cycle could end, then proc-2 can name a paragraph consisting solely of the EXIT statement,
and all execution paths can terminate cleanly by transferring control to that paragraph.
The existence of a return point following the end of an execution range is a dynamic
characteristic of an executing program. If control reaches the return point defined for a
PERFORM statement that is not in the process of execution (that is, is not currently performing
a cycle), then control passes through to the next paragraph in accordance with the normal
rules for implicit transfer of control from one statement to the next.
In-line and Out-of-Line PERFORM Statements
The PERFORM imperative-statement END-PERFORM form of the statement is an “in-line
PERFORM statement. The PERFORM procedure-group form of the statement is an out-of-line
PERFORM statement.
390 Procedure Division Verbs