Data Item
Data Item Example
Scenario - Explaining about different types of data items declaration in COBOL program.
Code -
----+----1----+----2----+----3----+----4----+----5----+
IDENTIFICATION DIVISION.
PROGRAM-ID. WORDEX.
AUTHOR. MTH.
DATA DIVISION.
WORKING-STORAGE SECTION.
* Individual data item
01 LEVEL-1 PIC 9(03) VALUE 256.
* Group data item
01 LEVEL-GROUP.
* Elementary data items
05 LEVEL-21 PIC 9(03) VALUE 256.
05 LEVEL-22 PIC 9(03) VALUE 128.
PROCEDURE DIVISION.
DISPLAY 'INDIVIDUAL DATA ITEM : ' LEVEL-1.
DISPLAY 'GROUP DATA ITEM : ' LEVEL-GROUP.
DISPLAY 'ELEMENTARY DATA ITEM-1 : ' LEVEL-21.
DISPLAY 'ELEMENTARY DATA ITEM-2 : ' LEVEL-22.
STOP RUN.
Output -
INDIVIDUAL DATA ITEM : 256 GROUP DATA ITEM : 256128 ELEMENTARY DATA ITEM-1 : 256 ELEMENTARY DATA ITEM-2 : 128
Explaining Example -
In the above example:
- The LEVEL-1 individual data item is declared and initialized with the value 256. LEVEL-GROUP is declared as a group data item with two elementary data items - LEVEL-21 and LEVEL-22.
- LEVEL-GROUP displays the data of both elementary data items LEVEL-21 and LEVEL-22.