Initializing each table item individually
If a table is small, you can set the value of each item
individually by using a VALUE
clause.
About this task
Use the following technique, which is shown in the example code below:
Procedure
- Define a record (such as
Error-Flag-Table
below) that contains the items that are to be in the table. - Set the initial value of each item in a
VALUE
clause. - Code a
REDEFINES
entry to make the record into a table.
Results
***********************************************************
*** E R R O R F L A G T A B L E ***
***********************************************************
01 Error-Flag-Table Value Spaces.
88 No-Errors Value Spaces.
05 Type-Error Pic X.
05 Shift-Error Pic X.
05 Home-Code-Error Pic X.
05 Work-Code-Error Pic X.
05 Name-Error Pic X.
05 Initials-Error Pic X.
05 Duplicate-Error Pic X.
05 Not-Found-Error Pic X.
01 Filler Redefines Error-Flag-Table.
05 Error-Flag Occurs 8 Times
Indexed By Flag-Index Pic X.
In the example above, the VALUE
clause
at the 01 level initializes each of the table items to the same value.
Each table item could instead be described with its own VALUE
clause
to initialize that item to a distinct value.
To initialize
larger tables, use MOVE
, PERFORM
,
or INITIALIZE
statements.
Related references
REDEFINES clause (Enterprise COBOL for z/OS® Language Reference)
OCCURS clause (Enterprise COBOL for z/OS Language Reference)
REDEFINES clause (Enterprise COBOL for z/OS® Language Reference)
OCCURS clause (Enterprise COBOL for z/OS Language Reference)