COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
If the file position indicator was established by an earlier READ statement, and its setting does
not reflect an alternate record key for which duplicates are allowed, then the record selected
for retrieval is one of:
◦ If NEXT is specified or implied, the first existing record in the file whose record number
or key value is greater than the file position indicator
◦ If REVERSED is specified, the first existing record in the file whose record number or key
value is less than the file position indicator
If the file position indicator was established by an earlier READ statement, and the setting of
the file position indicator reflects an alternate record key for which duplicates are not allowed,
then the record selected for retrieval is one of:
◦ If NEXT is specified or implied, the first record in the file whose key value is either equal
to the file position indicator and whose logical position within the set of duplicates is
immediately after the record that was made available by that previous READ statement,
or whose key value is greater than the file position indicator
◦ If REVERSED is specified, the first record in the file whose key value is either equal to the
file position indicator and whose logical position within the set of duplicates is immediately
prior to the record that was made available by that previous READ statement, or whose
key value is less than the file position indicator
The execution of a START statement establishes a subset of the file’s records that can be
retrieved by subsequent sequential or dynamic READ statements. If the current statement is
one in a sequence of such READ statements executed after a START statement for the same
file (without the execution of an OPEN, START, or Random READ having intervened), then the
record (if any) selected for retrieval by the preceding rules is tested to determine whether it is
a member of the file subset established by the START statement. If it is not, then the record is
disqualified and the effect is the same as if no record had been selected.
If the read operation is successful, the record selected by the file position indicator is retrieved
and placed into the record area associated with the file.
If the file is a multiple-reel tape file, and the end-of-reel condition occurs during the retrieval
operation, the run-time routines perform a reel-swap sequence, and the first record of the next
reel is retrieved. (For information on the reel-swap sequence, see OPEN.) If there is no next
reel, the at-end condition exists. In this case, the read operation terminates, and execution of
the READ statement is unsuccessful.
The at-end condition exists because one of these conditions is true:
◦ The file is present but there is no record at the position specified by the file position
indicator (such as the position immediately beyond the last record in the file).
◦ The file has an OPTIONAL phrase in its SELECT clause and, although open, is not actually
present.
◦ The START GENERIC reached the end of a set of duplicates.
If the at-end condition exists, the read operation terminates, and execution of the READ
statement is unsuccessful.
When the at-end condition exists, the I-O status code of the read operation is set to “10.” If
the AT END phrase is specified, control passes to the imperative statement in that phrase, and
no USE procedure is executed. If neither the AT END nor the NOT AT END phrase is specified,
and an applicable USE procedure exists, that procedure is executed.
READ 411










