A COBOL source program is a syntactically correct set of COBOL statements.
A COBOL source program may contain other COBOL source programs. These contained programs may reference some of the resources of the programs within which they are contained.
This concept of contained programs is known as nesting and the contained program is known as a nested program. A nested program may be directly or indirectly contained in another program. For example, if program B is contained in Program A, it is directly contained if there is no program in program A that also contains program B. Program B is indirectly contained in program A if there exists a program contained in Program A that also contains program B.
For more information on contained and containing programs, refer to the section on nested programs in the IBM Rational Development Studio for i: ILE COBOL Programmer's Guide.
The end of a COBOL source program is indicated by either the END PROGRAM header, if specified, or by the absence of additional source program lines.
The following figure briefly illustrates the general structure of a COBOL program.
COBOL Source Program—Format >>-+-IDENTIFICATION-+--DIVISION.--PROGRAM-ID.-------------------> | (1) | '-ID-------------' >--+-program-name-1-+--+------------------------------------+---> | (1) | '-+----+--+-INITIAL---+--+---------+-' '-literal-1------' '-IS-' '-RECURSIVE-' '-PROGRAM-' >--.--+---------------------------------+-----------------------> '-identification-division-content-' >--+-----------------------------------------------------+------> '-ENVIRONMENT DIVISION.--environment-division-content-' >--+---------------------------------------+--------------------> '-DATA DIVISION.--data-division-content-' >--+-------------------------------------------------+----------> '-PROCEDURE DIVISION.--procedure-division-content-' >--+----------------------------------------------------------------+->< '-+------------------------+--END PROGRAM--+-program-name-1-+--.-' | .--------------------. | | (1) | | V | | '-literal-1------' '---| nested program |-+-' nested program |--+-IDENTIFICATION-+--DIVISION.--PROGRAM-ID.-------------------> | (1) | '-ID-------------' >--+-program-name-2-+-------------------------------------------> | (1) | '-literal-2------' >--+----------------------------------------------------+-------> '-+----+--+-COMMON--+-----------+-----+--+---------+-' '-IS-' | +-INITIAL---+ | '-PROGRAM-' | '-RECURSIVE-' | '-+-INITIAL---+--+--------+-' '-RECURSIVE-' '-COMMON-' >--.--+---------------------------------+-----------------------> '-identification-division-content-' >--+-----------------------------------------------------+------> '-ENVIRONMENT DIVISION.--environment-division-content-' >--+---------------------------------------+--------------------> '-DATA DIVISION.--data-division-content-' >--+-------------------------------------------------+----------> '-PROCEDURE DIVISION.--procedure-division-content-' >--+------------------------+--END PROGRAM----------------------> | .--------------------. | | V | | '---| nested program |-+-' >--+-program-name-2-+--.----------------------------------------| | (1) | '-literal-2------'