Concept of Levels [ COBOL/HP-UX Language Reference for the Series 700 and 800 ] MPE/iX 5.0 Documentation
COBOL/HP-UX Language Reference for the Series 700 and 800
Concept of Levels
A level concept or hierarchy is inherent in the structure of a logical
data record. This concept arises from the need to specify subdivisions
of a record for the purpose of data reference. Once a subdivision has
been specified, it can be further subdivided to permit more detailed data
referral.
The most basic subdivisions of a record, that is, those not further
subdivided, are called elementary items; consequently, a record is said
to consist of a sequence of elementary items, or the record itself can be
an elementary item.
In order to refer to a set of elementary items, the elementary items are
combined into groups. Each group consists of a named sequence of one or
more elementary items. Groups, in turn, can be combined into groups of
two or more groups, and so on. Thus, an elementary item can belong to
more than one group.
Level-Numbers
A system of level-numbers shows the organization of elementary items and
group items. Since records are the most inclusive data items,
level-numbers for records start at 01. Less inclusive data items are
assigned higher (not necessarily successive) level-numbers not greater in
value than 49. A maximum of 49 levels in a record is allowed. There are
special level-numbers, 66, 77 ,78 (MF) and 88 which are exceptions to
this rule (see below). Separate entries are written in the source
program for each level-number used.
A group includes all group and elementary items following it until a
level-number less than or equal to the level-number of that group is
encountered. All items which are immediately subordinate to a given
group item should be described using identical level-numbers greater than
the level-number used to describe that group item; this rule is not
insisted upon. (OSVS) (VSC2)
Example:
+--------------------------+
Correct | Incorrect but Permitted |
| |
01 A. | 01 A. |(OSVS)
05 C-1. | 05 C-1. |(VSC2)
10 D PICTURE X. | 10 D PICTURE X. |(MF)
10 E PICTURE X. | 10 E PICTURE X. |
05 C-2. | 04 B-1. |
+--------------------------+
Four types of entries exist for which there is no true concept of level.
These are:
1. Entries that specify elementary items or groups introduced by a
RENAMES clause.
2. Entries that specify noncontiguous working storage and linkage
data items.
3. Entries that specify condition-names.
________________________________________________________________________
|(MF) |
| |
| |
| |
|4. Entries that specify constant-names. |
| |
________________________________________________________________________
Entries describing items by means of RENAMES clauses for the purpose of
regrouping data items have been assigned the special level-number 66.
Entries that specify noncontiguous data items, which are not subdivisions
of other items, and are not themselves subdivided, have been assigned the
special level-number 77.
Entries that specify condition-names, to be associated with particular
values of a conditional variable, have been assigned the special
level-number 88.
________________________________________________________________________
|(MF) |
|Entries that specify constant-names, to be associated with the value |
|of a particular literal, have been assigned the special level-number |
|78. |
________________________________________________________________________
Figure 2-1. Example of Level-Numbers Representing a Data Hierarchy
Note that indentation of COBOL source code is only a readability
convention and is not part of the language.
Elementary items are by definition those items without any subordinate
entries (entries without numerically greater level-numbers) following,
and must have a storage definition associated with them (see "The PICTURE
Clause" and "The USAGE Clause" in the chapter The Nucleus).
Note that only elementary items (marked with an asterisk, "*", above) and
FILLER items (marked with a "#" sign above) will have storage explicitly
reserved for them (in accordance with the associated PICTURE clause);
non-elementary items have implicit storage associated with them of size
determined by their subordinate items plus any FILLER bytes needed for
synchronization (see "The SYNCHRONIZED Clause" in the chapter The
Nucleus).
Level-numbers need not be consecutively ascending or descending as shown
above for clarity; thus, the next subordinate level after 01 could be 05,
and the next level 10, and so on.
The above data record would produce storage allocation in the following
manner:
MPE/iX 5.0 Documentation