Rational Developer for System z
COBOL for Windows, Version 7.5, Programming Guide


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.

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.

related references
OCCURS clause (COBOL for Windows Language Reference)
GROUP-USAGE clause (COBOL for Windows Language Reference)


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)