In a COBOL program, data organization can be
+-------------------------------IBM Extension--------------------------------+
+----------------------------End of IBM Extension----------------------------+
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.
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.
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:
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--------------------------------+
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----------------------------+
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.