COBOL Divisions

COBOL program Structure COBOL Identification Division

Advertisements


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.


  1. IDENTIFICATION DIVISION
  2. ENVIRONMENT DIVISION
  3. DATA DIVISION
  4. PROCEDURE DIVISION

IDENTIFICATION DIVISION:


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:


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:


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.


  1. File Section
  2. Working Storage Section
  3. 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 .


PROCEDURE DIVISION:


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.


Practical Example:


A simple program with all divisions can be like below.


Code:



Output:



COBOL program Structure COBOL Identification Division

Advertisements