Definition Attributes
Data Definition Language (DDL) Reference Manual — 426798-002
6- 25
OCCURS DEPENDING ON Clause
OCCURS DEPENDING ON Clause Guidelines
The guidelines for using an OCCURS clause also apply to OCCURS DEPENDING
ON, with the following exceptions:
•
For C, FORTRAN, Pascal, 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, you should not specify
USAGE IS INDEX for the field of that name, because COBOL requires that all
index names be unique throughout a program. DDL checks for the uniqueness of
an index name you specify in the INDEXED BY attribute.
OCCURS DEPENDING ON Clause Example
In the following example, the number of occurrences of DEP-NAME depends on the
value of NUM-DEP:
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
NUM-DEP must contain a positive integer value.