Skip to main content

How to rebuild with a comp variable index

  • February 15, 2013
  • 0 replies
  • 0 views

Problem:

I have a line sequential file, with the following file structure:

01 lsfile

      05 ACCOUNT    PIC 9(9) COMP.

      05 MOREINFO   PIC X(20).

I want to rebuild this file to IDX8 format, using ACCOUNT as the key.  Can I use a COMP field as an index, if so, how can I do this?

Resolution:

The size of a PIC 9(9) COMP is 4 bytes so, in this case, the total record size is 24 bytes.

For the lsfile example:

01   a  pic 9(9) comp.

01   b  pic x(20).

$ rebuild lsfile, ifile -r:f24 -o:lseq,ind -t:mf8 -k:1 4

$ rebuild ifile -n

        File                             :   ifile

        Organization                     :   Indexed

        Format                           :   IDX-8

        Recording Mode                   :   Fixed

        Compression                      :   N

        Maximum Record Length            :                24

        Minimum Record Length            :                24

        Index Node Size                  :              1024

        Number of data records           :               200

        Data  Created With Extfh Version :             14521

        Last  Updated With Extfh Version :             14521

        Key Description (where 'Start' is measured from offset 1):

          Key       Start     Length     Dupl     Key Comp   Sparse Char

            0           1          4        N

More information on data storage, and character representation, can be found in the online documentation at:

COBOL Language > Part 1. Concepts > Class and Category of Data > Selection of Character Representation.

Full instructions on the use of Rebuild can be found in the File Handling manual.

Old KB# 2018

#RMCOBOL
#COBOL
#ServerExpress
#netexpress
#AcuCobol

0 replies

Be the first to reply!