Variable-length tables

You can specify variable-length tables by using the OCCURS DEPENDING ON clause.

Format 2: variable-length tables

Read syntax diagramSkip visual syntax diagramOCCURSinteger-1TO integer-2UNBOUNDED TIMESDEPENDINGONdata-name-1ASCENDINGDESCENDINGKEYISdata-name-2INDEXEDBYindex-name-1
integer-1
The minimum number of occurrences.

The value of integer-1 must be greater than or equal to zero, and it must also be less than the value of integer-2.

If integer-1 is omitted, a value of 1 is assumed and the keyword TO must also be omitted.

integer-2
The maximum number of occurrences.

integer-2 must be greater than integer-1.

The length of the subject item is fixed. Only the number of repetitions of the subject item is variable.

UNBOUNDED
Unbounded maximum number of occurrences.
Unbounded table
A table with an OCCURS clause that specifies UNBOUNDED.

You can reference unbounded tables in COBOL syntax anywhere a table can be referenced.

Unbounded group
A group that contains at least one unbounded table.

You can define unbounded groups only in the LINKAGE SECTION. Either alphanumeric groups or national groups can be unbounded.

You can reference unbounded groups in COBOL syntax anywhere an alphanumeric or national group can be referenced, with the following exceptions:
  • You cannot specify unbounded groups as a BY CONTENT argument in a CALL statement.
  • You cannot specify unbounded groups as data-name-2 on the PROCEDURE DIVISION RETURNING phrase.
  • You cannot specify unbounded groups as arguments to intrinsic functions, except as an argument to the LENGTH intrinsic function.

The total size of an unbounded group at run time must be less than 999,999,999 bytes.

For unbounded tables and groups, the effect of the SSRANGE compiler option is limited. For more information, see SSRANGE in the Enterprise COBOL Programming Guide.

For references about working with unbounded tables and groups, see Working with unbounded tables and groups in the Enterprise COBOL Programming Guide.