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 COBOL procedure being executed under control of another COBOL statement, control implicitly transfers. (COBOL statements that control COBOL procedure execution are, for example: MERGE, PERFORM, SORT, and USE.)
  • During SORT or MERGE statement execution, when 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.
  • When a program that has no procedure division or any nondeclarative sections is called, the calling program issues an implicit EXIT PROGRAM.

COBOL provides explicit control transfers through the execution of any procedure branching or conditional statement.