Arrays can be defined using the "OCCURS" clause.
01 ARRAYS. 05 ARRAY1 PIC X(9) OCCURS 10 TIMES. 05 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX.
Initializing an array(INITIALIZE):
You can load a table by coding one or more INITIALIZE statements.
For example, to move the value 3 into each of the elementary numeric data items in a table called TABLE-ONE, shown below, you can code the following statement:
INITIALIZE TABLE-ONE REPLACING NUMERIC DATA BY 3.
To move the character 'X' into each of the elementary alphanumeric data items in TABLE-ONE, you can code the following statement:
INITIALIZE TABLE-ONE REPLACING ALPHANUMERIC DATA BY "X".
When you use the INITIALIZE statement to initialize a table, the table is processed as a group item; that is, elementary data items within the group are recognized and processed. For example, suppose that TABLE-ONE is an alphanumeric group that is defined like this:
01 TABLE-ONE. 02 Trans-out Occurs 20. 05 Trans-code Pic X Value "R". 05 Part-number Pic XX Value "13". 05 Trans-quan Pic 99 Value 10. 05 Price-fields. 10 Unit-price Pic 99V Value 50. 10 Discount Pic 99V Value 25. 10 Sales-Price Pic 999 Value 375. . . . Initialize TABLE-ONE Replacing Numeric Data By 3 Initialize TABLE-ONE Replacing Alphanumeric Data By "X"
Some times,initialization itself may cause some performance issue if the table is huge.Every time initializing a table causes all the items(subscripts) to get initializes which can take considerable time.
Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!