ILE COBOL Programmer's Guide

Processing Sequential Files

An ILE COBOL sequential file is a file in which records are processed in the order in which they were placed in the file, that is, in arrival sequence. For example, the tenth record placed in the file occupies the tenth record position and is the tenth record to be processed. To process a file as a sequential file, you must specify ORGANIZATION IS SEQUENTIAL in the SELECT clause, or omit the ORGANIZATION clause. A sequential file can only be accessed sequentially.

To write Standard COBOL programs that access a sequential file, you must create the file with certain characteristics. Table 23 lists these characteristics and what controls them.

Table 23. Characteristics of Sequential Files that are Accessible to Standard COBOL Programs

Characteristic Control
The file must be a physical file. Create the file using the CRTPF CL command.
The file cannot be a shared file. Specify SHARE(*NO) on the CRTPF CL command.
No key can be specified for the file. Do not include any line with K in position 17 in the Data Description Specifications (DDS) of the file.
The file must have a file type of DATA. Specify FILETYPE(*DATA) on the CRTPF CL command.
Field editing cannot be used. Do not specify the EDTCDE and EDTWRD keywords in the file DDS.
Line and position information cannot be specified. Leave blanks in positions 39 to 44 of all field descriptions in the file DDS.
Spacing and skipping keywords cannot be speicifed. Do not specify the SPACEA, SPACEB, SKIPA, or SKIPB keywords in the file DDS.
Indicators cannot be used. Leave blanks in positions 9 to 16 of all lines in the file DDS.
System-supplied functions such as date, time, and page number cannot be used. Do not specify the DATE, TIME, or PAGNBR keywords in the file DDS.
Select/omit level keywords cannot be used for the file. Do not include any line with S or O in position 17 in the file DDS. Do not specify the COMP, RANGE, VALUES, or ALL keywords.
Records in the file cannot be reused. Specify REUSEDLT(*NO) on the CRTPF CL command.
Records in the file cannot contain NULL fields Do not specify the ALWNULL keyword in the file DDS.

The OPEN, READ, WRITE, REWRITE, and CLOSE statements are used to access data that is stored in a sequential file. Refer to the WebSphere Development Studio: ILE COBOL Reference for a description of each of these statements.

All physical database files with SEQUENTIAL organization, that are opened for OUTPUT are cleared.

To preserve the sequence of records in a file that you open in I-O (update) mode, do not create or change the file so that you can reuse the records in it. That is, do not use a Change Physical File (CHGPF) CL command bearing the REUSEDLT option.

Note:
The ILE COBOL compiler does not check that the device associated with the external file is of the type specified in the device portion of assignment-name. The device specified in the assignment-name must match the actual device to which the file is assigned. See the "ASSIGN Clause" section of the WebSphere Development Studio: ILE COBOL Reference for more information.


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