General Structure

162 Views


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.

With the exception of compiler-directing statements and the END PROGRAM header, the statements, entries, paragraphs, and sections of a COBOL source program are grouped into the following four divisions:

  • Identification Division
  • Environment Division
  • Data Division
  • Procedure Division

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.

 

A division is the first level (highest) construct in a COBOL program.
COBOL programs are partitioned into the following four divisions, which appear in the order listed:

   *   IDENTIFICATION DIVISION: Specifies the program name and other  items used to uniquely identify the program.  This division is
       required in every COBOL program.
   *   ENVIRONMENT DIVISION: Describes the computer and peripheral devices used to compile and execute the program, and the data
       files used by the program. This division is optional.
   *   DATA DIVISION: Describes and defines the data items referenced by the program, including their names, lengths, decimal point
       locations (if applicable), and storage formats.  This division is optional.
   *   PROCEDURE DIVISION: Specifies the operations that the program must perform, describing how the data defined in the DATA DIVISION should be processed.   This division is optional. 

END PROGRAM Header

The END PROGRAM header indicates the end of a named COBOL source program. It also separates each program in a sequence of source programs. An END PROGRAM header is optional for the last program in a sequence of source programs only if that program does not contain any nested programs.

 

 

 

 

 

Post Comments