COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
apply to a key unless it also applies to the table. As a consequence, a key cannot be or belong
to a table that is subordinate to the table of which it is a key. An OCCURS statement can have
a maximum of 31 keys. The representation of the reference to the key in this context does not
include subscripts.
The KEY phrase indicates that within the table occurrences, the values referenced by the keys
are arranged in a consistent order.
When the key appears in an ASCENDING phrase, the values are arranged in ascending
order of occurrence numbers (that is, the value associated with an occurrence is never less
than the value associated with any preceding occurrence).
When the key appears in a DESCENDING phrase, the values are arranged in descending
order (that is, the value associated with an occurrence is never greater than the value associated
with any preceding occurrence).
This characteristic is relevant only during the execution of a SEARCH ALL statement that
references the table. All of the KEY phrases taken together define a single list, within which
the keys appear in decreasing order of search significance.
• Subscripts
Each appearance of a table’s data-name must include an appropriate subscript, except when
the entire table is desired (this only occurs in the SEARCH statement and some intrinsic
functions). References appearing in a REDEFINES clause or a KEY phrase of the OCCURS
clause are not considered operands and must not include subscripts.
• References to Subordinates Must be Subscripted
If the data-name is a data structure, then all items belonging to the group must also be
subscripted whenever they are used as operands; however, subordinate data-names used in
the KEY phrase, or as objects of a REDEFINES clause, are not considered operands and must
not be subscripted or indexed.
• OCCURS Limited to Certain Level Numbers
The OCCURS clause must not be specified for a data description entry having a level number
of 01, 66, 77, or 88.
• OCCURS Forbidden for Redefined Data Elements
The OCCURS clause cannot appear in a data description entry whose data-name is specified
in a REDEFINES clause of some subsequent data description entry; therefore, an entire table
cannot be redefined. It is possible, however, to redefine subordinate data items of table
elements. (See REDEFINES Clause.)
• Multidimensional Tables
Data items subordinate to the subject of an entry described with an OCCURS clause can
themselves contain an OCCURS clause; therefore, tables can consist of multiple occurrences
of subordinate tables for a maximum of seven levels. A data description entry containing either
type of OCCURS clause can be followed by subordinate entries containing the OCCURS
clause for fixed-size tables; however, a data description entry with an OCCURS DEPENDING
clause (discussed in the next topic) cannot be subordinate to a group entry described with
either type of OCCURS clause.
• Order of Subscripts in References
Up to seven subscripts can be used with one data item. When more than one subscript is
used, they are written to the right of the table name, in the order of more inclusive to less
inclusive dimensions of the data organization (that is, the first subscript matches the table
having the lowest level number).
All qualification must precede any subscripts (see VEHICLE in Example 50).
Descriptions of Records (Levels 01-49) 213










