Examples of Returning from an ILE COBOL Program

The following examples illustrate the behavior of EXIT PROGRAM, STOP RUN, and GOBACK in various combinations of Named, *NEW, and *DFTACTGP activation groups.

Figure 1shows an activation group containing programs A, B, C, D, and E. A calls B and C; C calls D and E.

Figure 1. Example of EXIT PROGRAM, STOP RUN, and GOBACK behavior in a Single Named Activation Group
A calls B and C; C calls D and E.
Statement Program A Program B Program C Program D Program E
EXIT PROGRAM  1   4   4   2   2 
STOP RUN  3   3   3   3   3 
GOBACK  3   4   4   2   2 
 1 
No operation is processed if an EXIT PROGRAM without the CONTINUE phrase is coded because the statement is in a main program. Processing continues with the next statement in the program. An EXIT PROGRAM with the CONTINUE phrase returns control to the caller of Program A, and leaves the activation group active. All files and resources used in the activation group are left in their last used state.
 2 
The activation group remains active and control is returned to Program C. All files and resources used in the activation group are left in their last used state.
 3 
The activation group is ended and control is returned to the caller of the main program. The activation group will close all files scoped to the activation group. Any pending commit operations scoped to the activation group will be implicitly committed. All resources allocated to the activation group will be returned back to the system. As a result of the activation group ending, all programs that were active in the activation group are placed in their initial state.
 4 
The activation group remains active and control is returned to Program A. All files and resources used in the activation group are left in their last used state.

Figure 2 shows two activation groups. Activation group 1 contains programs A and B. Activation group 2 contains programs C, D, and E. A calls B and C. C calls D and E.

Figure 2. Example of EXIT PROGRAM, STOP RUN, and GOBACK behavior in Two Named Activation Groups
Calls across two activation groups.
Statement Program A Program B Program C Program D Program E
EXIT PROGRAM  1   5   1   2   2 
STOP RUN  3   3   4   4   4 
GOBACK  3   5   4   2   2 
 1 
If an EXIT PROGRAM statement without the CONTINUE phrase was used, no operation is processed because the statement is in a main program. Processing continues with the next statement in the program. If an EXIT PROGRAM statement with the CONTINUE phrase was used, the activation group remains active and control is returned to the calling program or command. All files and resources used in the activation group are left in their last used state.
 2 
The activation group remains active and control is returned to Program C. All files and resources used in the activation group are left in their last used state.
 3 
The activation group is ended and control is returned to the caller of the main program. The activation group will close all files scoped to the activation group. Any pending commit operations scoped to the activation group will be implicitly committed. All resources allocated to the activation group will be returned back to the system. As a result of the activation group ending, all programs that were active in the activation group are placed in their initial state.
 4 
The activation group is ended and control is returned to Program A. The activation group will close all files scoped to the activation group. Any pending commit operations scoped to the activation group will be implicitly committed. All resources allocated to the activation group will be returned back to the system. As a result of the activation group ending, all programs that were active in the activation group are placed in their initial state.
 5 
The activation group remains active and control is returned to Program A. All files and resources used in the activation group are left in their last used state.

Figure 3 shows two named activation groups and a *NEW activation group. Activation group 1 contains programs A and D. Activation group 2 contains programs C and E. *NEW activation group contains program B. A calls B and C. C calls D and E.

Figure 3. Example of EXIT PROGRAM, STOP RUN, and GOBACK behavior in multiple *NEW and Named Activation Groups
Two named and one *NEW activation groups.
Statement Program A Program B Program C Program D Program E
EXIT PROGRAM  1   5   1   2   2 
STOP RUN  3   4   4   2   4 
GOBACK  3   4   4   2   2 
 1 
If an EXIT PROGRAM statement without the CONTINUE phrase was used, no operation is processed because the statement is in a main program. Processing continues with the next statement in the program. If an EXIT PROGRAM statement with the CONTINUE phrase was used, the activation group remains active and control is returned to the calling program or command. All files and resources used in the activation group are left in their last used state.
 2 
The activation group remains active and control is returned to Program C. All files and resources used in the activation group are left in their last used state.
 3 
The activation group is ended and control is returned to the caller of the main program. The activation group will close all files scoped to the activation group. Any pending commit operations scoped to the activation group will be implicitly committed. All resources allocated to the activation group will be returned back to the system. As a result of the activation group ending, all programs that were active in the activation group are placed in their initial state.
 4 
The activation group is ended and control is returned to Program A. The activation group will close all files scoped to the activation group. Any pending commit operations scoped to the activation group will be implicitly committed. All resources allocated to the activation group will be returned back to the system. As a result of the activation group ending, all programs that were active in the activation group are placed in their initial state.
 5 
If an EXIT PROGRAM statement without the CONTINUE phrase was used, no operation is processed because the statement is in a main program. Processing continues with the next statement in the program.

If an EXIT PROGRAM statement with the CONTINUE phrase was used, control is returned to the calling program or command. In a *NEW activation group, when a main program returns control to the caller, the activation group is ended. The activation group will close all files scoped to the activation group. Any pending commit operation scoped to the activation group will be implicitly committed.

All resources allocated to the activation group will be returned back to the system. As a result of the activation group ending, all programs that were active in the activation group are placed in their initial state.

Figure 4 shows interaction between a named activation group, the default activation group and a *NEW activation group. Activation group 1 contains programs A and D. *DFTACTGP activation group contains OPM COBOL/400 programs C and E. *NEW activation group contains program B. A calls B and C. C calls D and E.

Figure 4. Example of EXIT PROGRAM, STOP RUN, and GOBACK behavior in *NEW, Named, and *DFTACTGP Activation Groups
Named, default, and *NEW activation groups.
Statement Program A Program B Program C Program D Program E
EXIT PROGRAM  1   6   7   2   2 
STOP RUN  3   4   5   2   5 
GOBACK  3   4   5   2   2 
 1 
If an EXIT PROGRAM statement without the CONTINUE phrase was used, no operation is processed because the statement is in a main program. Processing continues with the next statement in the program. If an EXIT PROGRAM statement with the CONTINUE phrase was used, the activation group remains active and control is returned to the calling program or command. All files and resources used in the activation group are left in their last used state.
 2 
The activation group remains active and control is returned to Program C. All files and resources used in the activation group are left in their last used state.
 3 
The activation group is ended and control is returned to the caller of the main program. The activation group will close all files scoped to the activation group. Any pending commit operations scoped to the activation group will be implicitly committed. All resources allocated to the activation group will be returned back to the system. As a result of the activation group ending, all programs that were active in the activation group are placed in their initial state.
 4 
The activation group is ended and control is returned to Program A. The activation group will close all files scoped to the activation group. Any pending commit operations scoped to the activation group will be implicitly committed. All resources allocated to the activation group will be returned back to the system. As a result of the activation group ending, all programs that were active in the activation group are placed in their initial state.
 5 
The activation group remains active and control is returned to Program A. All files that were opened by Program C or Program E are closed. Any pending commit operations for files opened by Program C or Program E will be implicitly committed. Storage is freed for Program C and Program E.
 6 
If an EXIT PROGRAM statement without the CONTINUE phrase was used, no operation is processed because the statement is in a main program. Processing continues with the next statement in the program.

If an EXIT PROGRAM statement with the CONTINUE phrase was used, control is returned to the calling program or command.

In a *NEW activation group, when a main program returns control to the caller, the activation group is ended. The activation group will close all files scoped to the activation group. Any pending commit operation scoped to the activation group will be implicitly committed.

All resources allocated to the activation group will be returned back to the system. As a result of the activation group ending, all programs that were active in the activation group are placed in their initial state.

 7 
No operation is processed because the statement is in a main program. Processing continues with the next statement in the program.