Assigning values to a variable-length table
You can code a VALUE
clause for
an alphanumeric or national group item that has a subordinate data
item that contains the OCCURS
clause with the DEPENDING
ON
phrase. Each subordinate structure that contains the DEPENDING
ON
phrase is initialized using the maximum number of occurrences.
About this task
If you define the
entire table by using the DEPENDING ON
phrase, all
the elements are initialized using the maximum defined value of the
ODO (OCCURS DEPENDING ON
) object.
If the ODO
object is initialized by a VALUE
clause, it is logically
initialized after the ODO subject has been initialized.
01 TABLE-THREE VALUE "3ABCDE".
05 X PIC 9.
05 Y OCCURS 5 TIMES
DEPENDING ON X PIC X.
For example, in the code above, the ODO subject Y(1)
is
initialized to 'A', Y(2)
to 'B', . . ., Y(5)
to
'E', and finally the ODO object X
is initialized
to 3. Any subsequent reference to TABLE-THREE
(such
as in a DISPLAY
statement) refers to X
and the
first three elements, Y(1)
through Y(3)
, of the table.