1.6 Transfer of Control
In the Procedure Division, unless there is an explicit control transfer or
there is no next executable statement, program flow transfers control from
statement to statement in the order in which the statements are written.
(See Note below.) This normal program flow is an implicit transfer of
control.
In addition to the implicit transfers of control between consecutive
statements, implicit transfer of control also occurs when the normal flow
is altered without the execution of a procedure branching statement. The
following examples show implicit transfers of control, overriding
statement-to-statement transfer of control:
- After execution of the last statement of a procedure being executed
under control of another COBOL statement, control implicitly
transfers. (COBOL statements that control procedure execution are,
for example: MERGE, PERFORM, SORT, and USE.) Further, if a paragraph
is being executed under the control of a PERFORM statement which
causes iterative execution, and that paragraph is the first paragraph
in the range of that PERFORM statement, an implicit transfer of
control occurs between the control mechanism associated with that
PERFORM statement and the first statement in that paragraph for each
iterative execution of the paragraph.
- During SORT or MERGE statement execution, control is implicitly
transferred to an input or output procedure.
- During execution of any COBOL statement that causes execution of a
declarative procedure, control is implicitly transferred to that
procedure.
- At the end of execution of any declarative procedure, control is
implicitly transferred back to the control mechanism associated with
the statement that caused its execution.
COBOL also provides explicit control transfers through the execution of
any procedure branching, program call, or conditional statement. (Lists
of procedure branching and conditional statements are contained in
"Statement Categories" in topic 6.1.7.)
Note: The term "next executable statement" refers to the next COBOL
statement to which control is transferred, according to the rules given
above. There is no next executable statement under these circumstances:
- When the program contains no Procedure Division
- Following the last statement in a declarative section when the
paragraph in which it appears is not being executed under the control
of some other COBOL statement
- Following the last statement in a program or method when the paragraph
in which it appears is not being executed under the control of some
other COBOL statement in that program
- Following the last statement in a declarative section when the
statement is in the range of an active PERFORM statement executed in a
different section and this last statement of the declarative section
is not also the last statement of the procedure that is the exit of
the active PERFORM statement
- Following a STOP RUN statement or EXIT PROGRAM statement that
transfers control outside the COBOL program
- X Following a GOBACK statement that transfers control outside the COBOL
X program
- X Following an EXIT METHOD statement that transfers control outside the
X COBOL method
- X The end program or end method header
When there is no next executable statement and control is not transferred
outside the COBOL program, the program flow of control is undefined unless
the program execution is in the nondeclarative procedures portion of a
program under control of a CALL statement, in which case an implicit EXIT
PROGRAM statement is executed.
X Similarly, if control reaches the end of the Procedure Division of a
X method, and there is no next executable statement, an implicit EXIT METHOD
X statement is executed.
© Copyright IBM Corp. 1991, 1998
IBM Library Server Copyright 1989, 2005 IBM Corporation. All rights reserved.
Return to library:
z/OS |
z/OS.e |
TPF |
z/VSE |
z/VM |
IBM Hardware |
IBM System z Redbooks
Glossary:
IBM terminology
Publications:
How to order publications
Readers:
Download IBM Library Reader |
Download IBM Softcopy Reader |
Download Adobe® Acrobat® Reader®
Library management:
Download IBM Softcopy Librarian
Contacts:
Contact z/OS
Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks
of Adobe Systems incorporated.