Data Definition Language (DDL) Reference Manual

Definition Attributes
Data Definition Language (DDL) Reference Manual529431-004
6-24
OCCURS DEPENDING ON
The OCCURS DEPENDING ON clause differs from OCCURS on page 6-20 in that:
For Pascal (on D-series systems), C, FORTRAN, pTAL, TACL, and TAL, the DDL
compiler generates source code identical to the code it generates for OCCURS
max TIMES.
Only one OCCURS DEPENDING ON clause can be in a DEFINITION or RECORD
statement, and the clause’s subordinate fields or groups must be the last fields or
groups in that statement.
OCCURS DEPENDING ON clauses cannot be nested; however, a subordinate
field or group can have an OCCURS clause.
COBOL output for the INDEXED BY attribute is the direct translation of the
attribute.
If you specify an index name in the OCCURS clause, do not specify USAGE IS
INDEX for the field of that name, because COBOL requires that all index names be
unique throughout a program. The DDL compiler checks for the uniqueness of an
index name you specify in the INDEXED BY attribute.
In Example 6-20 on page 6-24, the number of occurrences of DEP-NAME depends on
the value of NUM-DEP. NUM-DEP must contain a positive integer value.
Example 6-20. OCCURS DEPENDING ON Clause (page 1 of 2)
DEF name.
02 last-name PIC X(12).
02 first-name PIC X(8).
02 midinit PIC X(2).
END
DEF addr.
02 address PIC X(22).
02 city PIC X(14).
02 state PIC X(2).
02 zip PIC 9(5).
END
DEF employee.
02 emp-name TYPE name.
02 emp-addr TYPE addr.
02 num-dep TYPE BINARY 16 MUST BE 0 THRU 12.
02 dep-name TYPE name
OCCURS 0 TO 12 TIMES
DEPENDING ON num-dep.
END