In the Procedure Division, a program can call another program (generally called a subprogram in COBOL terms), and this called program may itself call another program. The program that calls another program is referred to as the calling program, and the program it calls is referred to as the called program.
The called ILE COBOL program starts running at the top of the non-declarative part of the Procedure Division. If a called ILE COBOL program does not have a Procedure Division or does not have a non-declarative part in the Procedure Division, it will simply return to the calling ILE COBOL program.
When the called program processing is completed, the program can either transfer control back to the calling program or end the run unit. The run unit is ended after STOP RUN is issued and the nearest control boundary is a hard control boundary. If the nearest control boundary is a soft control boundary, then control returns to the caller of the control boundary but the run unit remains active.
A called program must not directly or indirectly call its caller (such as program X calling program Y; program Y calling program Z; and program Z then calling program X). This is called a recursive call. ILE COBOL does not allow recursion in non-recursive main programs or subprograms. Recursive calls are only allowed if you code the RECURSIVE clause on the recursively invoked program's PROGRAM-ID paragraph. If you try to recursively call a COBOL program that does not have the RECURSIVE clause coded on its PROGRAM-ID paragraph, a run time error message is generated.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.