Open In App

COBOL Divisions

Last Updated : 24 Aug, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

COBOL stands for Common Business-Oriented Programming Language, which is one of the oldest and first high-level programming languages. It is mostly used for the defense and insurance domains which require huge data processing.

Features of COBOL:

  • It is a business-oriented and robust language
  • Provide good file handling methods
  • Excellent self-documenting capabilities
  • Structured Programming language
Structure of COBOL Divisions

 

A COBOL program basically divided into the following four divisions:

  1. Identification division
  2. Environment division
  3. Data division
  4. Procedure division

Identification Division:

  • This is the first and the compulsory division of every COBOL program.
  •  In this division, the details like author name, date of execution, date of writing the code, installation, etc. can be mentioned. 

Syntax:

  IDENTIFICATION DIVISION.                                                                           

  PROGRAM-ID.  PGM-NAME.

  [AUTHOR.                               Comment Entry]

  [INSTALLATION.                     Comment Entry]

  [DATE-COMPILED.                  Comment Entry]

 [DATE-COMPILED.                  Comment Entry]

Environment division:

  • Using this environment division we can specify the program features which are dependent on the system running it. 
  • Environment division is used to specify, the computer environment in which the program is written and executed. 
  • Environment division is further divided into two types:
    • Configuration Section: Identifies the computer used for compiling programs.
    • Input- Output Section: Identifies the files and the input-output resources used by the program.

Syntax:

 ENVIRONMENT DIVISION.                                                 

 CONFIGURATION SECTION.

   INPUT-OUTPUT  SECTION.

   [FILE-CONTROL. ]

   [ File control entries ] 

   [ I – O  CONTROL. ]

  [ I- O  Control entries ]  

Data Division: 

  • The data division is used to declare variables and parameters in the COBOL program.
  • In Data division we declare the variables, their data type, size, usage type, etc. 
  • Data division is optional unless the program manipulates any constant and user-defined data.
  • DATA DIVISION has three different sections, which is mentioned below:
    • FILE SECTION: describe most of the data that is sent to, or coming from, the computer’s peripherals.
    • WORKING-STORAGE SECTION: Describes the general variables used in the program
    • LINKAGE SECTION: Establishes a link between two programs

Procedure Division: 

  • This is the main division in the COBOL programming language, where business logic has to be written.
  • Procedure Division contains user-defined Sections, Paragraphs, Sentences, Statements, Clauses, and Verbs.
  • Statements and sentences are necessary for reading input, processing it, and writing the output.
  • All the data described in the DATA DIVISION are processed here and desired results are produced.
  • Should contain at least one paragraph, sentence, and statement
  • only the Section is an option.

Example 1:

Cobol




IDENTIFICATION DIVISION.
PROGRAM-ID. DIVISION-REPRESENTATION.
AUTHOR. RUPA KUMARI.
INSTALLATION. MF.
DATE-WRITTEN. 18 AUG 2022.
DATE-COMPILED. 18 AUG 2022.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. 
OBJECT-COMPUTER. 
INPUT-OUTPUT SECTION.
FILE-CONTROL
DATA DIVISION.
    WORKING-STORAGE SECTION.
    01 WS-VAR                 PIC X(50).
PROCEDURE DIVISION.
MAIN-PARA.
    DISPLAY 'ROW 1-6 COMES UNDER IDENTIFICATION DIVISION'.
    DISPLAY 'ROW 7-12 COMES UNDER ENVIRONMENT DIVISION'.
    DISPLAY 'ROW 13-15 COMES UNDER DATA DIVISION'.
    DISPLAY 'ROW AFTER 16 WILL COMES UNDER PROCEDURE DIVISION'.
STOP RUN.


Output:

 

Explanation:

  • In this program, we are displaying the uses and performance of the 4 different kinds of COBOL division. Which we discussed in this article. 
  • Identification division is used to display author details.
  • Environment division is used to display, source computer details, and object computer details. As well as input-output files details we have to mention under this division only.
  • Data division is used to introduce all the variables before using them in the procedure division
  • Procedure division is used to write the main part of the program and its functionality.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads