Definition Attributes
Data Definition Language (DDL) Reference Manual — 426798-002
6- 23
OCCURS Clause
OCCURS Clause Examples
The following statements declare storage for 52 paycheck values, one for each week
of the year:
DEF salary.
02 paycheck PIC 9999V99
OCCURS 52 TIMES.
END
TAL programs with TALBOUND 1 or with no TALBOUND clause access individual
paycheck values like this:
TAL programs with TALBOUND 0 access individual paycheck values like this:
A group can be repeated with an OCCURS clause; for example:
DEF paydate.
02 dates OCCURS 12 TIMES.
03 month PIC 99.
03 day PIC 99.
03 year PIC 99.
END
To refer to an individual field within a group, follow the field name with a subscript. For
example, a COBOL program uses a subscript to refer to a month within the
DATES group:
You could also specify a constant as the OCCURS value:
CONSTANT pay-period VALUE IS 24.
DEF bi-monthly-paydate.
02 paydate OCCURS pay-period TIMES.
03 bi-month PIC 99.
03 day PIC 99.
PAYCHECK [1]
PAYCHECK [52]
Paycheck value for the first week
Paycheck value for the last week
VST601.vsd
PAYCHECK [0]
PAYCHECK [51]
Paycheck value for the first week
Paycheck value for the last week
VST602.vsd
MONTH (10)
Refers to the 10th month
VST603.vsd