ILE COBOL Language Reference

Levels of Data

After a record has been defined, it can be subdivided to provide more detailed data references.

For example, in a customer file for a department store, one complete record could contain all data pertaining to one customer. Subdivisions within that record could be: customer name, customer address, account number, department number of sale, unit amount of sale, dollar amount of sale, previous balance, plus other pertinent information.

The basic subdivisions of a record (that is, those fields not further subdivided) are called elementary items.

Thus, a record can be made up of a series of elementary items, or it may itself be an elementary item.

It may be necessary to refer to a set of elementary items; thus, elementary items can be combined into group items. Groups themselves can be combined into a more inclusive group that contains one or more subgroups. Thus, within one hierarchy of data items, an elementary item can belong to more than one group item.

A system of level-numbers specifies the organization of elementary and group items into records.

Special level-numbers are also used; they identify data items used for special purposes.

Related Information:

Levels of Data in a Record Description Entry

Each group and elementary item in a record requires a separate entry, and each must be assigned a level-number.

A level-number is a 1- or 2-digit integer between 01 and 49, or one of three special level-numbers: 66, 77, or 88.

The following level-numbers are used to structure records:

 01 
This level-number specifies the record itself, and is the most inclusive level-number possible. A level-01 entry may be either a group item or an elementary item. It must begin in Area A. Type-names (defined using the TYPEDEF clause) must be level-01 items.
 02-49 
These level-numbers specify group and elementary items within a record. They may begin in Area A or Area B. Less inclusive data items are assigned higher (not necessarily consecutive) level-numbers in this series.

A group item includes all group and elementary items following it, until a level-number less than or equal to the level-number of this group is encountered.

All elementary or group items immediately subordinate to one group item must be assigned identical level-numbers higher than the level-number of this group item.

If a type-name is a group item, and it is used in a TYPE clause to define a new data item, then the new data item will have subordinate items of the same name, description, and hierarchy as those of the type-name. There is no limit to the number of levels that can result because:

Related Information:

+-------------------------------IBM Extension--------------------------------+

Coding Example

The ILE COBOL compiler accepts nonstandard level-numbers that are not identical to others at the same level. For example, the following two data description entries are equivalent:

01   EMPLOYEE-RECORD.
     05  EMPLOYEE-NAME.
         10  FIRST     PICTURE  X(10).
         10  LAST      PICTURE  X(10).
     05  EMPLOYEE-ADDRESS.
         10  STREET    PICTURE  X(10).
         10  CITY      PICTURE  X(10).
01   EMPLOYEE-RECORD.
         05  EMPLOYEE-NAME.
             10  FIRST     PICTURE  X(10).
             10  LAST      PICTURE  X(10).
         04  EMPLOYEE-ADDRESS.
             08  STREET    PICTURE  X(10).
             08  CITY      PICTURE  X(10).

Because 04 is less than 05, it is not subordinate to EMPLOYEE-NAME, yet because it is greater than 01 it is subordinate to EMPLOYEE-RECORD. If 07 was used in place of 04, EMPLOYEE-ADDRESS would be subordinate to EMPLOYEE-NAME (which in this example would be undesirable).

Such coding practices are not recommended, and this extension is provided only for compatibility.

+----------------------------End of IBM Extension----------------------------+

Conceptual Example

Figure 4 illustrates the concept. Note that all groups immediately subordinate to the level-01 entry have the same level-number. Note also that elementary items from different subgroups do not necessarily have the same level numbers, and that elementary items can be specified at any level within the hierarchy.

Figure 4. Levels in a Record Description

REQTEXT

Special Level-Numbers

Special level-numbers identify items that do not structure a record. The special level-numbers are:

 66 
Identifies items that must contain only a RENAMES clause; such items regroup previously defined data items. (For details, see RENAMES Clause.)
 77 
Identifies data item description entries -- independent Working-Storage, Local-Storage or Linkage Section items that are not subdivisions of other items, and are not subdivided themselves. Level-77 items must begin in Area A.
 88 
Identifies any condition-name entry that is associated with a particular value of a conditional variable. The condition-name entry must contain only a VALUE clause. (For details, see VALUE Clause.)
Note:
Level-77 and level-01 entries in the Working-Storage, Local-Storage and Linkage Sections that are referenced in the program must be given unique data-names, because neither can be qualified. Subordinate data-names that are referenced in the program must be either uniquely defined, or made unique through qualification. Unreferenced data-names need not be uniquely defined.

Indentation

Successive data description entries may begin in the same column as preceding entries, or may be indented. Indentation is useful for documentation, but does not affect the action of the compiler.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]