Initializing a table at the group level
Code an alphanumeric or national group
data item and assign to it, through the VALUE clause,
the contents of the whole table. Then, in a subordinate data item,
use an OCCURS clause to define the individual table
items.
About this task
In the following example, the alphanumeric
group data item TABLE-ONE uses a VALUE clause
that initializes each of the four elements of TABLE-TWO:
01 TABLE-ONE VALUE "1234".
05 TABLE-TWO OCCURS 4 TIMES PIC X.
In the following example, the national group data item Table-OneN uses
a VALUE clause that initializes each of the three
elements of the subordinate data item Table-TwoN (each
of which is implicitly USAGE NATIONAL). Note that
you can initialize a national group data item with a VALUE clause
that uses an alphanumeric literal, as shown below, or a national literal.
01 Table-OneN Group-Usage National Value "AB12CD34EF56".
05 Table-TwoN Occurs 3 Times Indexed By MyI.
10 ElementOneN Pic nn.
10 ElementTwoN Pic 99.
After Table-OneN is initialized, ElementOneN(1)
contains NX"00410042" (the UTF-16 representation
of 'AB'), the national decimal item ElementTwoN(1)
contains NX"00310032" (the UTF-16 representation
of '12'), and so forth.
OCCURS clause (Enterprise COBOL for z/OS® Language Reference)
GROUP-USAGE clause (Enterprise COBOL for z/OS Language Reference)