When initializing large arrays with default values, most programmers will perform a paragraph or internal loop, moving the default values to each field of each occurs until all of the occurrences are populated. This is not necessarily the most efficient way to perform this task.
One way to perform this task more efficiently is to move your default values to the fields of the first occurrence. Then move that first group of occurs to the second group (as a block, not as individual fields). Then move the first two group of occurs to the third and fourth. Then move the first four group of occurs to the next four, and so on and so on. Be careful when you get to the end of your occurs that you do not move data beyond the end of your array, or you will likely clobber code.
Here is a quick example:
One way to perform this task more efficiently is to move your default values to the fields of the first occurrence. Then move that first group of occurs to the second group (as a block, not as individual fields). Then move the first two group of occurs to the third and fourth. Then move the first four group of occurs to the next four, and so on and so on. Be careful when you get to the end of your occurs that you do not move data beyond the end of your array, or you will likely clobber code.
Here is a quick example:
01 EXAMPLE-TABLE.
05 MY-TABLE.
10 TABLE-ENTRY OCCURS 999 TIMES.
15 FIRST-NAME PIC X(15).
15 LAST-NAME PIC X(15).
15 SEX-CODE PIC X.
15 DOB.
20 DOB-YYYY PIC 9(4).
20 DOB-MM PIC 99.
20 DOB-DD PIC 99.
15 SSN PIC 9(9).
15 SALARY PIC S9(9)V99 COMP-3.
...
MOVE SPACES TO MY-TABLE.
MOVE ZEROS TO DOB
SSN
SALARY.
MOVE MY-TABLE (1:54)
TO MY-TABLE (55:54).
MOVE MY-TABLE (1:108)
TO MY-TABLE (109:108).
MOVE MY-TABLE (1:216)
TO MY-TABLE (217:216).
05 MY-TABLE.
10 TABLE-ENTRY OCCURS 999 TIMES.
15 FIRST-NAME PIC X(15).
15 LAST-NAME PIC X(15).
15 SEX-CODE PIC X.
15 DOB.
20 DOB-YYYY PIC 9(4).
20 DOB-MM PIC 99.
20 DOB-DD PIC 99.
15 SSN PIC 9(9).
15 SALARY PIC S9(9)V99 COMP-3.
...
MOVE SPACES TO MY-TABLE.
MOVE ZEROS TO DOB
SSN
SALARY.
MOVE MY-TABLE (1:54)
TO MY-TABLE (55:54).
MOVE MY-TABLE (1:108)
TO MY-TABLE (109:108).
MOVE MY-TABLE (1:216)
TO MY-TABLE (217:216).
You obviously do not want to hard code like in the example above, but this shows the concept in a simple form. You would want to make your start position and length variable fields and perform this in a loop. How you code it is up to you.
The routine I am familiar with became more efficient than the typical performed loop at about 15 occurs. Yours may differ. You may have to look at the assembler code generated to make that determination.
If anyone has other techniques to populate large arrays, please share them in a comment or email the concept to me and I'll post it on this blog.