Reading records from line-sequential files
To read from a line-sequential file, open the file and
use the READ
statement. Your program reads one record
after another in the same order in which the records were entered
when the file was created.
About this task
Characters in the file record are read one at a time into the record area until one of the following conditions occurs:
- The record delimiter (the EBCDIC newline character) is encountered.
The delimiter is discarded and the remainder of the record area is filled with spaces. (Record area is longer than the file record.)
- The
entire record area is filled with characters.
If the next unread character is the record delimiter, it is discarded. The next
READ
reads from the first character of the next record. (Record area is the same length as the file record.)Otherwise the next unread character is the first character to be read by the next
READ
. (Record area is shorter than the file record.) - End-of-file is encountered.
The remainder of the record area is filled with spaces. (Record area is longer than the file record.)
Opening line-sequential files
Adding records to line-sequential files
Closing line-sequential files
Allocating line-sequential files
OPEN statement (Enterprise COBOL for z/OS Language Reference)
WRITE statement (Enterprise COBOL for z/OS Language Reference)