HP 3000 Manuals

Concept of Levels [ Micro Focus COBOL Language Reference ] MPE/iX 5.0 Documentation


Micro Focus COBOL Language Reference

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-numbersnot greater in
value than 49.  A maximum of 49 levels in a record is allowed.  There are
special level-numbers, 66, 77, 78 (MF only) 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 groupand 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 and VSC2 only)

Example.   

[]
Four types of entries exist for which there is no true concept of level. These are: 1. Entries that specify elementary itemsor groups introduced by a RENAMES clause. 2. Entries that specify noncontiguous working storage and linkage data items. 3. Entries that specify condition-names. 4. For MF only: 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. For MF only: 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 a readability convention only 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 sections The PICTURE Clause and The USAGE Clause in the chapter Program Definition). 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 section The SYNCHRONIZED Clause in the chapter Program Definition). 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:
[]
Figure 2-2: Data Record Storage Allocation where: R-E-I is Record-Entry-Item M-G-I is Major-Group-Item R-G-I is Regular-Group-Item S-G is Sub-Group EI is Elementary-Item NEI is noncongtiquous Elementary-Item


MPE/iX 5.0 Documentation