Processing files with variable-length records or multiple record descriptions
If more than one record description entry is associated with file-name-1, those records automatically share the same storage area; that is, they are implicitly redefined. After a READ statement is executed, only those data items within the range of the current record are replaced; data items stored beyond that range are undefined. The following example illustrates this concept.
If the length of the current record that is read is less than the minimum size specified by the record description entries for file-name-1, the portion of the record area which is to the right of the last valid character read is undefined. If the length of the current record exceeds the record description entries for file-name-1, the record is truncated on the right to the maximum record definition size.
In either of the previous 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. If compiler option VLR(COMPAT) is in effect, the I-O status would be set to 00.
For more information about the VLR compiler option, see VLR in the Enterprise COBOL Programming Guide.
The following example shows two record areas of different sizes in an FD. When a shorter record is read, the content of the remaining record area is undefined.
FD INPUT-FILE LABEL RECORD OMITTED.
01 RECORD-1 PICTURE X(30).
01 RECORD-2 PICTURE X(20).
Content of input area when READ statement is executed:
ABCDEFGHIJKLMNOPQRSTUVWXYZ1234
Content of record being read in (RECORD-2
):
01234567890123456789
Content of input area after READ statement is executed:
01234567890123456789??????????
The "?" characters are undefined characters in input area.