A division is a block of code, which contains one or more sections or set of Sections or set of Sentences or a block of Statements.
Division begins with division name and ends at the beginning of the next division or at the end of the program.
The divisions are known as system defined words.
All Divisions should code in the AREA A.
There are actually four divisions in COBOL.
- IDENTIFICATION DIVISION
- ENVIRONMENT DIVISION
- DATA DIVISION
- PROCEDURE DIVISION
Let’s discuss one by one.
The IDENTIFICATION DIVISION provides the program name and other items used to uniquely identify the program. This division is required in every COBOL program.
In other words, the identification is used to identify the programmer who has write program and it may contain optional entries like Author, Installation, Date-written, Date-compiled and security depending on the requirement.
PROGRAM-ID is a keyword and it must be specified immediately after the IDENTIFICATION DIVISION and it is mandatory in COBOL program.
Program name can be up to 8 characters max.
IDENTIFICATION DIVISION can be explained more detailed here .
ENVIRONMENT DIVISION describes the computer and other devices used to compile, execute the program and the data files used in the program.
ENVIRONMENT DIVISION is optional.
The ENVIRONMENT DIVISION describes the environment to the system in which the program will run.
The ENVIRONMENT DIVISION describes the input and output sources required to run the program and to whom with the program interacting like printers, files etc.
ENIVIRONMENT DIVISION has two sections. i.e. The CONFIGURATION and INPUT-OUTPUT SECTIONs and those are optional.
ENIVIRONMENT DIVISION can be explained more detailed here .
DATA DIVISION describes and defines the data items referenced by the program, including their names, lengths, decimal point locations, and storage formats.
DATA DIVISION is optional.
DATA DIVISION has divided into three sections.
- File Section
- Working Storage Section
- Linkage Section
Each Section has its own identity in the DATA DIVISION.
File section describes about the data input or output received from and their layouts to receive/send the data from outside sources.
Working-storage section describes about the variables used in the program to manipulate data.
Linkage section describes about the data passing between the programs.
DATA DIVISION can be explained more detailed here .
The PROCEDURE DIVISION is used specify the operations to be performed by the program. It may contain declarative as well as non-declarative procedures.
The PROCEDURE DIVISION contains all the statements which will execute by the compiler in which the order written by the programmer.
PROCEDURE DIVISION may contain the DECLARATIVES and it is coupled with the END DECLARATIVES.
PROCEDURE DIVISION is the starting point for the program execution.
PROCEDURE DIVISION used to receive the data which is passed from other program which is in the concept of call.
PROCEDURE DIVISION can be explained more detailed here .
These 4 divisions divide the program into distinct structural elements.
A simple program with all divisions can be like below.
If any questions on the above, post your queries on Cobol Discussion forum
COBOL program Structure COBOL Identification Division