ILE COBOL Programmer's Guide

Describing Files Stored on Tape Devices

Once you have named the sequential file in the Environment Division, you must then describe the file through a file description entry in the Data Division. See the WebSphere Development Studio: ILE COBOL Reference for a full description of the File Description Entry. Use the Format 3 File Description Entry to describe a sequential file that is accessed through a tape file.

Tape files have no data description specifications (DDS). A sequential file that is stored on a tape device must be a program-described file. Your ILE COBOL program must describe the fields in the record format so the program can arrange the data received from or sent to the tape device in the manner specified by the tape file description.

A simple file description entry in the Data Division that describes a sequential file that is accessed through a tape file looks as follows:

FD  sequential-file-name.
01  sequential-file-record.
    05  record-element-1   PIC ... .
    05  record-element-2   PIC ... .
    05  record-element-3   PIC ... .
.
.
.

Describing Tape Files with Variable Length Records

You can store files that have variable length records on a tape device. You specify the Format 3 RECORD clause with the FD entry of the file to define the maximum and minimum record lengths for the file.

A simple file description entry in the Data Division that describes a sequential file with variable length records looks as follows:

FILE SECTION.
FD  sequential-file-name
    RECORD IS VARYING IN SIZE
              FROM integer-6 TO integer-7
              DEPENDING ON data-name-1.
01  minimum-sized-record.
    05  minimum-sized-element     PIC X(integer-6).
01  maximum-sized-record.
    05  maximum-sized-element     PIC X(integer-7).

·
·
·
WORKING-STORAGE SECTION. 77 data-name-1 PIC 9(5).
·
·
·

The minimum record size of any record in the file is defined by integer-6. The maximum record size of any record in the file is defined by integer-7. Do not create records descriptions for the file which contain a record length that is less than that specified by integer-6 nor a record length that is greater than that specified by integer-7. If any record descriptions break this rule, then a compile time error message is issued by the ILE COBOL compiler. The ILE COBOL compiler will then use the limits implied by the record description. The ILE COBOL compiler also issues a compile time error message when none of the record descriptions imply a record length that is as long as integer-7.

When a READ or WRITE statement is performed on a variable length record, the size of that record is defined by the contents of data-name-1.

Refer to the Format 3 RECORD clause in the WebSphere Development Studio: ILE COBOL Reference for a further description of how variable length records are handled.


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