COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
Usage Considerations
• See the usage considerations for OCCURS Clause for Fixed-Size Tables.
• Depending Item
The depending item (depend in the syntax diagram) must reference an integer numeric data
item that is capable of containing the value of max. The storage space associated with the
depending item cannot be contained within or overlap the storage space associated with the
table whose occurrences it controls; therefore, the depending item cannot be described as a
subordinate of the variable-occurrence data item. If the table is external, the depending item
must also be external.
At any point during execution of the object program-unit, the current value of the depending
item represents the number of occurrences in the table; therefore, its value must never be less
than min or greater than max during execution of a statement that references the table, any
of its subordinate items, or any data structure that contains the table.
You can use the CHECK compiler directive to verify that the depending item has an acceptable
value.
• Concept of a Variable-Size Item
Any data structure containing a variable-occurrence table has a variable size. When such an
item is referenced as an operand, its value normally includes only those table elements whose
occurrence numbers are less than or equal to the value of the depending item at the start of
the operation; however, when the data structure is used as a receiving operand and the
depending item is itself a subordinate of the data structure (so that the operation changes its
value), the size of the receiving operand is the maximum size of the data structure; that is, the
operation proceeds as if the depending item contained the value of max.
• Changing the Depending Item Affects Table Values
Whenever the value of the depending item is increased, occurrences of the table are
dynamically appended to each affected variable-size data structure; however, the portion of
the item’s value contained in these new occurrences has an unpredictable content unless the
same or a subsequent operation assigns a known value to that portion.
Whenever the value of the depending item is reduced, the values of table members whose
occurrence numbers exceed the new limit are lost. Even after a subsequent increase in the
value of the depending item restores these occurrences to the table, their values are not
predictable and they must not be used as operands until known values are assigned.
• OCCURS DEPENDING Incompatible with REDEFINES
A variable-occurrence data item cannot be specified as a redefinition or as part of a
redefinition; that is, an OCCURS DEPENDING clause cannot appear in a data description
entry that includes a REDEFINES clause or that is subordinate to a data description entry that
includes a REDEFINES clause.
• OCCURS DEPENDING Cannot Be Nested and Must Be Last
A data description entry with an OCCURS DEPENDING clause can only be followed, within
its record description, by descriptions of subordinate items; that is, only one table with a
variable number of occurrences can appear in a single record description entry, and the data
items it contains must be the last data items in the record. Note, however, that a
fixed-occurrence data item can be subordinate to a variable-occurrence data item.
216 Data Division










