End of Process
End of Process statements execute once, immediately before the data files close and the process ends. All processes, with the exception of subroutine and status processes, include this event point. If a process is cancelled for any reason, APPX executes End of Process before canceling. The predefined field OPTION can be interrogated to determine if the process is ending normally or if it was cancelled.
For a query process, this event point executes as a part of query setup. Query processes are unique in that the End of Process ends before the process completes execution; the query itself has not yet executed. This means that End of Process executes before the query event points Start of Query Execution, Establish PCF Range, Pre-User Selection, Post User Selection, and End of Query Execution. Immediately following End of Process for a query process (completion of query setup), APPX automatically saves a copy of the contents of all record areas in memory. Query execution restores the copy of memory immediately before the Start of Query Execution event point.
End of Process is often used to:
· Determine how a process ends (END, CANCEL, or PREV IMAGE) by interrogating the predefined field OPTION, and then perform any required action.
· Perform processing that is dependent upon process completion, such as storing a control or hash total, setting a report printed flag for an output process, or checking for errors or warnings to advise the user of an error log.
· Perform any final updating of files.
· Write data to a file that is read in the Start of Process event point of the next process in the family.