COBOL Manual for TNS and TNS/R Programs
Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs—522555-006
9-181
READ for Sequential or Dynamic Access
The file identified by file-name must be open in the INPUT or I-O mode; if it is
not, the read operation is unsuccessful with I-O status code “47.” If the file is
described with fixed-length records and a smaller record is read, the read
operation is successful with I-O status code “04.”
In addition to the specific I-O status codes described later, the general codes “00,”
“30,” and “90” can occur. For more information, see I-O Status Code.
°
Retrieval of a logical record
The read operation retrieves a logical record from the file identified by file-
name and places it into the record area associated with that file.
°
Alignment within record area
If the size of the retrieved record is greater than the maximum record size
defined for the file (as specified in the explicit or implicit RECORD clause in the
file description entry for file name), the run-time routines truncate the retrieved
record on the right before placing it in the record area.
If the size of the retrieved record is less than the maximum record size defined
for the file, the run-time routines left justify the record content within the record
area. All character positions in the record area that are to the right of the last
character in the retrieved record have undefined values—that is, they can
contain any characters. If you want to verify that they are spaces, use the INTO
phrase.
When the read operation is attempted on a file with fixed-length records and
the size of the retrieved record is greater than the maximum record size
defined for the file or less than the minimum record size defined for the file (as
specified in the explicit or implicit RECORD clause in the file description entry
for the file), the read operation is unsuccessful with I-O status code “30” and
the GUARDIAN-ERR register has the value 21.
°
Unsuccessful read operation
Whenever the read operation terminates with an I-O status code greater than
or equal to “30” (except “97”), execution of the READ statement is not
successful. In this case the applicable USE procedure, if one exists, is
executed.
If the execution of a READ statement is unsuccessful for any reason, the key
of reference and the contents of the record area associated with the file are
undefined and the value of the depending item, if one is defined for the file, is
not altered.
°
PROMPT phrase
When the PROMPT phrase appears, and the device with which the file is
associated is either a terminal or a process (typically, a server), and the file’s
open mode is I-O, the value of prompt-item is sent to the file as part of the
read operation.