When you specify the NEXT MODIFIED phrase, the record made available is the first record in the subfile that has been modified.
The search for the next modified record begins:
The value of the RELATIVE KEY data item is updated to reflect the relative record number of the record made available to the program.
If you specify NEXT MODIFIED and there is no user-modified record in the subfile with a relative record number greater than the relative record number contained in the RELATIVE KEY data item, the AT END condition exists, the file status is set to 12, and the value of the RELATIVE KEY data item is set to the key of the last record in the subfile. Imperative-statement-2, or any applicable USE AFTER ERROR/EXCEPTION procedure, if any, is then executed.
If you do not specify the NEXT MODIFIED phrase, the data record made available is the record in the subfile with a relative record number that corresponds to the value of the RELATIVE KEY data item; and if the RELATIVE KEY data item contains a value other than the relative record number of a record in the subfile, the INVALID KEY condition exists and the execution of the READ statement is unsuccessful.
Random Access of Subfile Records: The NEXT MODIFIED phrase must not be used to randomly access records in a subfile. The INVALID KEY phrase can only be used for random access of subfile records.
Sequential Access of Subfile Records: The NEXT MODIFIED phrase must be specified to access subfile records sequentially. The AT END phrase can only be specified with the NEXT MODIFIED phrase.
If you specify the FORMAT phrase, literal-1 or the contents of identifier-2 must specify a format which is active for the appropriate program device. The READ statement reads a data record of the specified format.
When a format-name is not specified, the format used is the last record format written to the display device that contains input fields, input/output fields, or hidden fields. If no such format exists for the display file, the format used is the record format of the last WRITE operation to the display device.
To ensure correct results, always specify the FORMAT phrase for multiple format files.
The TERMINAL phrase specifies the program device from which the data record is made available. The program device must have been acquired before the READ operation. For a single device file, the TERMINAL phrase can be omitted. The program device is assumed to be that single device. If the TERMINAL phrase is omitted for a READ of a TRANSACTION file that has acquired multiple program devices, the default program device is used.
If the TERMINAL phrase is omitted for a file that has multiple devices acquired for it, a record is read from the subfile associated with the default program device.
The INVALID KEY phrase should be specified if the NEXT MODIFIED phrase is not specified and there is no applicable USE procedure specified for the file name.
If the RELATIVE KEY data item contains a value that does not correspond to a relative record number for the subfile at the time of the execution of the READ statement, the INVALID KEY condition exists and the execution of the READ statement is unsuccessful.
Click here for further information about the invalid key condition.
The AT END phrase serves to explicitly delimit the scope of the READ statement. Specify the AT END phrase when you use the NEXT MODIFIED phrase and no applicable USE procedure is specified for the file name. If the AT END phrase and a USE procedure are both specified for a file, and the AT END condition arises, control transfers to the AT END imperative statement and the USE procedure is not executed.
If you specify NEXT MODIFIED and there is no user-modified record in the subfile, the AT END condition exists, and the READ operation is unsuccessful.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.