READ statement notes

This topic provides notes on the READ statement.

  • If the FILE-STATUS clause is specified in the file-control entry, the associated file status key is updated when the READ statement is executed.
  • After unsuccessful READ statement execution, the contents of the associated record area and the value of the file position indicator are undefined. Attempts to access or move data into the record area after an unsuccessful read can result in a protection exception.
  • If the number of character positions in a record is less than the minimum size specified by the record description entries for file-name-1, after a READ statement is executed, the portion of the record area that is to the right of the last valid character read is undefined. If the number of character positions in a record exceed the maximum size specified by the record description entries for file-name-1, after a READ statement is executed, the record is truncated on the right to the maximum size.

    In either of these cases, the READ statement is successful and the I-O status is set to either 00 (hiding the record length conflict condition) or 04 (indicating that a record length conflict has occurred), depending on the VLR compiler option setting.

    • When the VLR(COMPAT) compiler option is in effect, the status value of 00 is set.
    • When the VLR(STANDARD) compiler option is in effect, the status value of 04 is set.
    For more information about the VLR compiler option, see VLR in the Enterprise COBOL Programming Guide.