Level Numbers in COBOL

Level Numbers:

COBOL makes use of the level number concept to describe the hierarchical data structure. A level number is a 2-digit number. The allowed level numbers are 01 – 49, 66, 77 and 88. All variables are declared in the working-storage section using appropriate level numbers.

An elementary data item can take either 01 or 77 as its level number. In COBOL a distinction is made between elementary and group data items. A few elementary data may be combined to form a group.

The most inclusive group must have level number 01. The first subdivisions can have any level number between 02 and 49. Further subdivisions should follow the same range with the restriction that an item cannot have a level number less than or equal to the level numbers of the group that may include it. Thus a group includes all elementary data or smaller groups beneath it until a level number equal to or less than the level number of the said group is encountered. The following examples reveal the concept of level numbers.

Example:
01 DATE
05 DAY
05 MONTH
05 YEAR