ILE COBOL Language Reference

Data Organization

In a COBOL program, data organization can be

Sequential Organization

The physical order in which the records are placed in the file determines the sequence of records. The relationships among records in the file do not change, except that the file can be extended. There are no keys. Both database files and device files can have sequential organization.

Each record in the file, except the first, has a unique predecessor record, and each record, except the last, also has a unique successor record.

Relative Organization

Think of the file as a string of record areas, each of which contains a single record. Each record area is identified by a relative record number; the access method stores and retrieves a record, based on its relative record number. For example, the first record area is addressed by relative record number 1, and the 10th is addressed by relative record number 10. Relative files must be assigned to DISK or DATABASE.

Table 8 summarizes conditions affecting relative output files.


Table 8. Initialization of Relative Output Files

File Access and CL Specifications Conditions at Opening Time Conditions at Closing Time   File Boundary
Sequential *INZDLT   Records not written are initialized All increments
Sequential *INZDLT *NOMAX size   CLOSE succeeds File status is 0Q Up to boundary of records written
Sequential *NOINZDLT     Up to boundary of records written
Random or dynamic Records are initialized File is open   All increments
Random or dynamic *NOMAX size OPEN fails File status is 9Q   File is empty

To recover from a file status of 9Q, use the CHGPF (Change Physical File) command as described in the associated run-time message text.

Relative record number processing can be used for a physical file or for a logical file that is based on only one physical file.

Extending the file boundary

After file creation time, the size of a file can be extended. If a file status 0Q is received for a file, you may need to add more records to the file before processing it. You can use the INZPFM (Initialize Physical File Member) command to add deleted records to the file.

For example, suppose you create a file of 10 000 records with 3 increments of 1 000 records each:

  1. You initialize the (first 10 000) records.
  2. You realize you need to store more data. So, you run the INZPFM command with the RECORDS(*DLT) option again, until you have all 13 000 records initialized.
  3. You receive a requirement to store even more data - but you have already used up all 13 000 records! If you run the INZPFM command again, you will receive an interactive error message (of severity 99) prompting you either to
    1. Cancel the INZPFM request
    2. Go ahead with the request (say, initialize another 1 000 records).
  4. If you choose the second option in the previous step, you now have 14 000 initialized records. You have thus increased the size of the file past the previously defined maximum.

Indexed Organization

Each record in the file has an embedded key (called a key data item) that is associated with an index. An index provides a logical path to the data records, according to the contents of the associated embedded record key data items. Only database and DISK files can have indexed organization.

When records are inserted, updated, or deleted, they are identified solely by the values of their prime keys. Specify the name of the prime key data item on the RECORD KEY clause of the FILE-CONTROL paragraph.

+-------------------------------IBM Extension--------------------------------+

A logical file that is opened for OUTPUT does not remove all records in the physical file on which it is based. Instead, the file is opened to allow only write operations, and the records are added to the file.

+----------------------------End of IBM Extension----------------------------+

+-------------------------------IBM Extension--------------------------------+

TRANSACTION Organization

Workstation and data communication files can have TRANSACTION organization. See the Transaction Files chapter in the ILE COBOL for AS/400 Programmer's Guide.

+----------------------------End of IBM Extension----------------------------+


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]