COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-180
READ for Sequential or Dynamic Access
imperative-stmt-1
is an imperative statement to be performed when the end of the file is encountered
at the beginning of the read operation. This phrase is required if no USE statement
is applicable for the file. If both a USE statement and an AT END phrase are
present, only the AT END phrase is used.
imperative-stmt-2
is an imperative statement to be performed when the end of the file is not
encountered at the beginning of the read operation.
END-READ
ends the scope of the READ statement, causing the READ to be a delimited-scope
statement. If the READ statement does not end with an END-READ phrase, the
presence of the AT END or the NOT AT END phrase causes the READ statement
to be a conditional statement, which ends at the next period separator.
Usage Considerations:
•
Restrictions on REVERSED
REVERSED can be specified for a file only if all of these conditions are true:
°
The file is a structured disk file.
°
The file’s file-control entry does not have a RESERVE clause with number
greater than one in the non-CRE environment or greater than two in the CRE.
°
The file’s access is not RANDOM.
°
Prereading is not active for the file.
If REVERSED is specified, then:
°
Neither LOCK nor PROMPT prompt-item can be specified.
°
REVERSED cancels the effect of GENERIC (a positioning mode that the
START statement can specify).
REVERSED is not recommended if these conditions are true, because it is very
inefficient:
°
File organization is RELATIVE.
°
The relative key is the key of reference.
°
Records are not contiguous.
•
Action of the READ Statement (Sequential Read)
Any READ statement that has a NEXT or REVERSED phrase, or is associated
with a file for which the ACCESS MODE SEQUENTIAL clause is specified or
implied, is a sequential READ statement. Any other READ statement is a random
READ statement.