COBOL Level Numbers

COBOL Data Item Declaration COBOL Data Classification

Advertisements


Level Number plays most important role in the declaration of the variables in the application programming of COBOL.

Level number describes the hierarchy of the data items/variable declared.

The level numbers includes 01 to 49 and special purpose level numbers 66, 77 and 88.

The level number describes the properties of data declared such as general purpose or special purpose and etc..

Level Number plays most important role in the declaration of the variables in the application programming of COBOL.

Level numbers are two types based on their usage.


  • General purpose level numbers.
  • Special purpose level numbers.

General purpose level numbers:


General purpose level numbers are mostly used to declare the variables that are used during the program execution.

In this, Level Number hierarchy should start with low number(01) and max number for the level number is 49.

Based on the level numbers, the data items/variables will be divided into two categories.


  • Individual data item
  • Group data item
  • Elementary data item

Individual data item:

Individual data item is a data-item which will be the only one variable declared.

Individual data item will always have a picture clause and no sub items.

Individual data item name should be unique in a program or in all communicating programs(calling/called).

Individual data item level numbers are from 01 to 49.

In the below example, LEVEL-1 is the Individual data item which has no elementary data items under it.


Group data item:

Group data item is a data-item which will be the first variable declared.

Group data item didn’t have a picture clause. Group data item name should be unique in a program or in all communicating programs(calling/called).

Group data item level numbers are from 01 to 48.

In the below example, LEVEL-GROUP is the group data item which has elementary data items under it.


Elementary data item:

Elementary data item is a data item which will be under the group data item. Elementary data item will have a picture clause.

Elementary data item not unique and will be same under different group items and those will refer with OF keyword followed with Group item name.

Elementary data item level numbers will be 02 to 49.

In the below example, LEVEL-21, LEVEL-22 is the group data item which has elementary data items under it.


General purpose level numbers - Practicle Example:


Code:



Output:



Special purpose level numbers:


These level numbers which will be used for special purpose like RENAMES, individual data items and conditional names.

These special purpose level numbers will come with combination other level numbers.

The brief details of the special purpose level number are below.


  • 66 level number - used for RENAMES clause
  • 77 level number - used for Individual elementary variables/data items
  • 88 level number - used for Conditional names

Let’s discuss special purpose level numbers one by one.


66 Level number/RENAMES:

66 level number/RENAMES used to regrouping the elementary items in a group item.

66 level number/RENAMES will create a logical group from the group of elementary items.

The 66 level number/RENAMES topic explained in detail here


77 Level number:

Non-contiguous data items are not subdivided and have no hierarchical relationship to another data items.

These data items are only defined in the WORKING-STORAGE and LINKAGE SECTIONs.

The 77 level number topic explained in detail here


88 Level number/Conditional names:

A conditional variable is always subordinate to another data item.

Level number 88 used for conditional names.

Conditional name identifies the particular value associated to verify during the flow.

The 88 level number topic explained in detail here


COBOL Data Item Declaration COBOL Data Classification

Advertisements