Main programs, subprograms, and calls

If a COBOL program is the first program in a run unit, that COBOL program is the main program. Otherwise, it and all other COBOL programs in the run unit are subprograms. No specific source-code statements or options identify a COBOL program as a main program or subprogram.

Whether a COBOL program is a main program or subprogram can be significant for either of two reasons:

  • Effect of program termination statements
  • State of the program when it is reentered after returning

In the PROCEDURE DIVISION, a program can call another program (generally called a subprogram), and this called program can itself call other programs. 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. When the processing of the called program is completed, the called program can either transfer control back to the calling program or end the run unit.

The called COBOL program starts running at the top of the PROCEDURE DIVISION.

Related references  
Language Environment® Programming Guide