The END READ statement indicates the end of a BEG READ Read Next Record loop.
(1) (2) (3)
When using this statement in conjunction with an RDBMS table, you can specify a field name instead of a file name to limit the volume of data being passed between APPX and the RDBMS. See the Partial-Record I/O section in Chapter 4-3: Specifying Statements for more information.
The END READ statement acts as a GOTO and a placeholder; the END READ goes to the statement after the corresponding BEG READ. The END READ statement is also used by the BEG READ statement as a placeholder, to know where to continue execution when the loop is finished.
The application ID and file name must match those specified in a previous BEG READ statement.
The END READ statement cannot be used with one-record files.
A non-recoverable file processing error occurs if an END READ statement executes without, or before, the corresponding BEG READ statement. A non-recoverable error also occurs if, once loop termination has taken place, the END READ is re-executed without or before another corresponding BEG READ statement. All loops are considered terminated when an event point ends.
BEG AT, BEG READ, END AT, READNEXT
The following example demonstrates a common use of the END READ statement where a range is specified:
In this example, the system reads the TRANFILE file, beginning with the first record where the TRANFILE CUSTOMER ID is equal to or greater than the first one found in the TRANFILE (TRANFILE CUSTOMER ID must be the first part of TRANFILE KEY). The BEG READ Read Next Record loop terminates when the key in TRANFILE exceeds the one specified in the END AT statement. If no BEG AT is present, the read begins with the first record in the file.