Skip to main content

Problem:

How can I rebuild a Sequential File into an Index File with multiple 01 levels?

Resolution:

The reindex sample program does not cover multiple 01 levels. If the program has multiple 01 levels with varying length records, and each record has a unique length, it is possible to write the record to the correct 01 based on the length.

To do this, change the sample reindex code in the following manner:

  1) Create a data name in WS , such as, WS-SIZE PIC 9(4)

  2) Change the FD for the binary sequential file to read:

          RECORD IS VARYING FROM 1 TO ### DEPENDING ON WS-SIZE.

      where ### is the maximum length for the record and the "depending

      on" clause will store the length of the record in ws-size.

  3) Change GET-REC to have

          03 FILLER PIC X(###).

       where ### is the maximum length for the record.

  4) Write PUT-REC from the 01 DATANAME that matches the RECORD

       LENGTH.

    

Old KB# 6119