COBOL Manual for TNS and TNS/R Programs
Data Division
HP COBOL Manual for TNS and TNS/R Programs—522555-006
7-81
OCCURS Clause for Fixed-Size Tables
•
KEY Phrase
Each key (key in the syntax diagram) must reference a data item that is
subordinate to the table, except that the first key in a list can reference the table
itself. No OCCURS clause can 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.)