A COBOL source program is a syntactically correct set of COBOL statements.
With the exception of the COPY and REPLACE statements and the end program marker, the statements, entries, paragraphs, and sections of a COBOL source program are grouped into the following four divisions:
The end of a COBOL source program is indicated by the END PROGRAM marker. If there are no nested programs, the absence of additional source program lines also indicates the end of a COBOL program.
Following is the format for the entries and statements that constitute a separately compiled COBOL source program.
Format: COBOL source program >>-+-IDENTIFICATION-+--DIVISION.--PROGRAM-ID--+---+-------------> '-ID-------------' '-.-' >--program-name-1--+------------------------------------+-------> '-+----+--+-RECURSIVE-+--+---------+-' '-IS-' '-INITIAL---' '-PROGRAM-' >--+---+--+---------------------------------+-------------------> '-.-' '-identification-division-content-' >--+-----------------------------------------------------+------> '-ENVIRONMENT DIVISION.--environment-division-content-' >--+---------------------------------------+--------------------> '-DATA DIVISION.--data-division-content-' >--+-------------------------------------------------+----------> '-PROCEDURE DIVISION.--procedure-division-content-' >--+-----------------------------------------------------------------+->< '-+-------------------------------+--END PROGRAM--program-name-1.-' | .---------------------------. | | V | | '---| Nested source program |-+-' nested source program |--+-IDENTIFICATION-+--DIVISION.--PROGRAM-ID--+---+-------------> '-ID-------------' '-.-' >--program-name-2-----------------------------------------------> >--+----------------------------------------------+--+---+------> '-+----+--+-COMMON--+---------+-+--+---------+-' '-.-' '-IS-' | '-INITIAL-' | '-PROGRAM-' '-INITIAL--+--------+-' '-COMMON-' >--+---------------------------------+--------------------------> '-identification-division-content-' >--+-----------------------------------------------------+------> '-ENVIRONMENT DIVISION.--environment-division-content-' >--+---------------------------------------+--------------------> '-DATA DIVISION.--data-division-content-' >--+-------------------------------------------------+----------> '-PROCEDURE DIVISION.--procedure-division-content-' >--+-------------------------------+--END PROGRAM---------------> | .---------------------------. | | V | | '---| nested source program |-+-' >--program-name-2.----------------------------------------------|
A sequence of separate COBOL programs can also be input to the compiler. The following is the format for the entries and statements that constitute a sequence of source programs (batch compile).
Format: sequence of COBOL source programs .----------------------. V | >>---COBOL-source-program-+------------------------------------><
program-name can be specified either as a user-defined word or in an alphanumeric literal. Either way, program-name must follow the rules for forming program-names. program-name cannot be a figurative constant. Any lowercase letters in the literal are folded to uppercase.
An end program marker is optional for the last program in the sequence only if that program does not contain any nested source programs.