RETRIEVE retrieves data that is stored by expired START commands. It is the only method that is available for accessing such data.
A task that is not associated with a terminal can access only the single data record that is associated with the original START command; it does so by issuing a RETRIEVE command. The storage that is occupied by the data that is associated with the task is released on execution of the RETRIEVE command, or at termination of the task if no RETRIEVE command is executed before termination.
A task that is associated with a terminal can access all data records that are associated with all expired START commands that have the same transaction identifier and terminal identifier as does the START command that started the task; it does so by issuing consecutive RETRIEVE commands. Expired data records are presented to the task on request in expiration time sequence, starting with any data that is stored by the command that started the task, and including data from any commands that have expired since the task started. Each data record is retrieved from temporary storage by using the REQID of the original START command as the identification of the record in temporary storage.
If the task that is issuing the retrieve is long running, and the data that it retrieves was created with a PROTECTed START, the retrieving task should syncpoint after retrieving that data (or at regular intervals while issuing multiple RETRIEVEs).
When all expired data records have been retrieved, the ENDDATA condition occurs. The storage that is occupied by the single data record that is associated with a START command is released after the data has been retrieved by a RETRIEVE command.
The following example shows how to retrieve data that is stored by a START command for the task, and store it in the user-supplied data area called DATAFLD.