COBOL - Divisions
There are four divisions in COBOL:
The Identification division is the beginning of the COBOL program, and this is the mandatory section in every COBOL program. This division is used by the compiler and programmer to identify the program.
In this section, we can define the other optional details. Like Author name, Date of writing the code, date of last compiled code, and other security details as per your requirements.
You must define the PROGRAM-ID (a keyword) immediately after the Identification division.
When you compile and execute the above program, it will display the following output:
In the Environment division section of the program, we can define the input and output files. This section is optional. This division is usually used to describe the system's environment in which the program will run.
It consists of two sections:
1. Configuration Section
The configuration section contains the information about your system on which your program is written and executed. This section must be specified in Area A.
It consists of two paragraphs:
This Input-Output section contains information about all the files to be used in your COBOL program.
Let's see one simple example for Environment section:
Data division contains information about the variables and data items used in the program. It defines the variable names, their lengths, decimal locations, and the information about the storage formats.
File Section: The file section specifies the details of the records used in the file. It will show the whole record structure of the file.
Let's see one simple example for Data Division:
Let's see the example for Procedure Division: