Invoking EXECs synchronously with IMFEXEC SELECT(EXEC) WAIT(YES)
Passing control of an EXEC
By specifying the WAIT(YES) parameter on an IMFEXEC SELECT statement, an EXEC can schedule another EXEC, wait for its completion, and then resume execution.
When an EXEC schedules another EXEC by using the WAIT(YES) parameter, control is passed immediately to the called EXEC. The called EXEC can use the IMFEXEC statements VDCL, VGET, and VPUT to access all the LOCAL, GLOBAL, and SHARED variables created by the first EXEC, but it does not have access to any of the TSO variables created by the first EXEC.
The execution of the calling EXEC is suspended when the called EXEC is being processed. When the called EXEC terminates, the first EXEC receives control at the first statement immediately after the IMFEXEC SELECT statement.
BBI variables IMFCC and IMFRC are used to report the success of the scheduled WAIT(YES) EXEC. See Understanding-completion-codes-for-EXEC-Initiated-EXECs-with-WAIT-YES-and-User-Written-programs for more information.
For EXECs scheduled with the IMFEXEC SELECT EXEC( ) WAIT(yes) statement, the two ways to pass back results are using
- IMFEXEC EXIT CODE(x)
- A local, shared, or profile variable
Using RETURN will give control back to the calling EXEC but the passed back value (RESULT) is not supported.