Program Structure of COBOL
COBOL is a programming language that was developed to solve business problems. COBOL stands for Common Business Oriented Language. Being a High-Level Structured Language, COBOL is very similar to English-like language, which is used to develop major business applications. Due to its easier maintenance, ability to work with any database (DB2, VSAM), and ability to handle huge volumes of data, COBOL is used for handling a wide range of traditional business scenarios like retail sales tracking, inventory control, contact management, commissions, and payroll systems.
COBOL programs are made up of similar constructs such as paragraphs, sentences, statements, and clauses. The hierarchy of a COBOL program is shown in the following diagram. The Division is a block of code, usually containing one or more sections. It starts where the division name is encountered and ends with the beginning of the next division or with the end of the program text.
COBOL Program Divisions:
- IDENTIFICATION Division
- ENVIRONMENT Division
- DATA Division
- PROCEDURE Division
- Lines 1,2 IDENTIFICATION DIVISION (Mandatory): This division is used to identify basic information about the program. In this example, the IDENTIFICATION DIVISION contains only the PROGRAM-ID, GFG.
- Line 3 ENVIRONMENT DIVISION (Optional): It is used to identify the environment in which the program is running
- Line 4 DATA DIVISION (Optional): It contains any data that the program operates on. As the program has no data, So the DATA DIVISION is empty.
- Line 7 DISPLAY statement used to transfer the data to the output device/screen.
- Line 9 STOP RUN (Mandatory): This is the final executable statement that marks the end of the program after which the control returns back to the Operating System.