Pages

Sunday, November 14, 2010

COBOL Performance Tuning - INITIALIZE Statement And Large Arrays

We have covered the INITIALIZE statement and initializing large arrays, so now let's put them together.

Say you have a large copybook with a large array in it.

01  LARGE-RECORD.
(several 05 levels)
    05  MY-TABLE.
        10  TABLE-ENTRY OCCURS 999 TIMES.
(multiple fields here)
(more 05 levels)

Using the above copybook, you would have to modify it so that you can initialize parts of the copybook, but not the array, as you want to use a separate routine to do that.  Here is what I would do:

01  LARGE-RECORD.
  03  LARGE-RECORD-PART-1.
(several 05 levels)
  03  LARGE-RECORD-PART-2.
    05  MY-TABLE.
        10  TABLE-ENTRY OCCURS 999 TIMES.
(multiple fields here)
  03  LARGE-RECORD-PART-3
(more 05 levels)

Now you can initialize LARGE-RECORD like this:

MOVE SPACES TO LARGE-RECORD.
INITIALIZE LARGE-RECORD-PART-1
    REPLACING NUMERIC DATA BY ZEROS.
INITIALIZE LARGE-RECORD-PART-3
    REPLACING NUMERIC DATA BY ZEROS.

You would then initialize MY-TABLE as discussed in COBOL Performance Tuning - Large Arrays.

Contact me if you know of other ways (especially better ones) of accomplishing this objective.

No comments:

Post a Comment