The OCCURS DEPENDING ON clause specifies variable-length tables.
The object of the OCCURS DEPENDING ON clause (data-name-1) must describe an integer data item. The object cannot be a windowed date field.
The object of the OCCURS DEPENDING ON clause must not occupy any storage position within the range of the table (that is, any storage position from the first character position in the table through the last character position in the table).
The object of the OCCURS DEPENDING ON clause cannot be variably located; the object cannot follow an item that contains an OCCURS DEPENDING ON clause.
If the OCCURS clause is specified in a data description entry included in a record description entry that contains the EXTERNAL clause, data-name-1, if specified, must reference a data item that possesses the external attribute. data-name-1 must be described in the same data division as the subject of the entry.
If the OCCURS clause is specified in a data description entry subordinate to one that contains the GLOBAL clause, data-name-1, if specified, must be a global name. data-name-1 must be described in the same data division as the subject of the entry.
All data-names used in the OCCURS clause can be qualified; they cannot be subscripted or indexed.
At the time that the group item, or any data item that contains a subordinate OCCURS DEPENDING ON item or that follows but is not subordinate to the OCCURS DEPENDING ON item, is referenced, the value of the object of the OCCURS DEPENDING ON clause must fall within the range integer-1 through integer-2.
When a group item that contains a subordinate OCCURS DEPENDING ON item is referred to, the part of the table area used in the operation is determined as follows:
The following statements are affected by the maximum length rule:
If a variable-length group item is not followed by a nonsubordinate item, the maximum length of the group is used when it appears as the identifier in CALL ... USING BY REFERENCE identifier. Therefore, the object of the OCCURS DEPENDING ON clause does not need to be set unless the group is variably located.
If the group item is followed by a nonsubordinate item, the actual length, rather than the maximum length, is used. At the time the subject of entry is referenced, or any data item subordinate or superordinate to the subject of entry is referenced, the object of the OCCURS DEPENDING ON clause must fall within the range integer-1 through integer-2.
Certain uses of the OCCURS DEPENDING ON clause result in complex OCCURS DEPENDING ON (ODO) items. The following constitute complex ODO items:
The object of an OCCURS DEPENDING ON clause cannot be a nonsubordinate item that follows a complex ODO item.
Any nonsubordinate item that follows an item described with an OCCURS DEPENDING ON clause is a variably located item. That is, its location is affected by the value of the OCCURS DEPENDING ON object.
When implicit redefinition is used in a File Description (FD) entry, subordinate level items can contain OCCURS DEPENDING ON clauses.
The INDEXED BY phrase can be specified for a table that has a subordinate item that contains an OCCURS DEPENDING ON clause.
For more information about complex OCCURS DEPENDING ON, see the Enterprise COBOL Programming Guide.
The ASCENDING KEY phrase, the DESCENDING KEY phrase, and the INDEXED BY clause are described under Fixed-length tables.