The procedure(s) referenced in the basic PERFORM statement are executed once, and control then passes to the next executable statement following the PERFORM statement.
PERFORM Statement - Format 1 >>-PERFORM------------------------------------------------------> >--+-procedure-name-1--+-------------------------------+-+----->< | '-+-THROUGH-+--procedure-name-2-' | | '-THRU----' | '-imperative-statement--END-PERFORM-------------------'
When both procedure-name-1 and procedure-name-2 are specified, if either is a procedure-name in a declarative procedure, both must be procedure-names in the same declarative procedure.
If the PERFORM statement is in a declarative section, procedure-name-1 and procedure-name-2 must also be in a declarative section.
If procedure-name-1 is specified, imperative-statement and the END-PERFORM phrase must not be specified.
If procedure-name-1 is omitted, imperative-statement and the END-PERFORM phrase must be specified.
An in-line PERFORM statement functions according to the
same general rules as an otherwise identical out-of-line PERFORM statement, except that statements contained within the in-line PERFORM are executed in place of the statements contained within the range of procedure-name-1 (through procedure-name-2, if specified). Unless specifically qualified by the word in-line or out-of-line, all the rules that apply to the out-of-line PERFORM statement also apply to the in-line PERFORM.
Whenever an out-of-line PERFORM statement is executed, control is transferred to the first statement of the procedure named procedure-name-1. Control is always returned to the statement following the PERFORM statement. The point from which this control is returned is determined as follows:
The only necessary relationship between procedure-name-1 and procedure-name-2 is that a consecutive sequence of operations is executed, beginning at the procedure named by procedure-name-1 and ending with the execution of the procedure named by procedure-name-2.
PERFORM statements may be specified within the performed procedure. If there are two or more logical paths to the return point, then procedure-name-2 may name a paragraph that consists only of an EXIT statement; all the paths to the return point must then lead to this paragraph.
When both procedure-name-1 and procedure-name-2 are specified, GO TO and PERFORM statements can appear within the sequence of statements contained in these paragraphs or sections. A GO TO statement should not refer to a procedure-name outside the range of procedure-name-1 through procedure-name-2. If this is done, results are unpredictable and are not diagnosed.
When only procedure-name-1 is specified, PERFORM and GO TO statements can appear within the procedure. A GO TO statement should not refer to a procedure-name outside the range of procedure-name-1. If this is done, results are unpredictable and are not diagnosed.
When the performed procedures include another PERFORM statement, the sequence of procedures associated with the embedded PERFORM statement must be totally included in or totally excluded from the performed procedures of the first PERFORM statement. That is, an active PERFORM statement whose execution point begins within the range of performed procedures of another active PERFORM statement must not allow control to pass through the exit point of the other active PERFORM statement. In addition, two or more such active PERFORM statements must not have a common exit.
+-------------------------------IBM Extension--------------------------------+
Two or more active PERFORM statements can have a common exit point.
+----------------------------End of IBM Extension----------------------------+
When control passes to the sequence of procedures by means other than a PERFORM statement, control passes through the exit point to the next executable statement, as if no PERFORM statement referred to these procedures.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.