Transfer of control across programs
EGL provides several ways to switch control from one program to another:
- The call statement gives control to another program and optionally passes a series of values. Control returns to the caller when the called program ends. If the called program changes any data that was passed as a variable, the content of the variable is changed in the caller.
The call does not commit databases or other recoverable resources, although an automatic server-side commit may occur.
You may specify characteristics of the call by setting a callLink element of the linkage options part. For details, see call and callLink element. For details on the automatic server-side commit, see luwControl in callLink element.
- The transfer statement gives control from one main program to another, ends the transferring program, and optionally passes a record whose data is accepted into the receiving program's input record. You cannot use a transfer statement in a called program.
Your program can transfer control by a statement of the form transfer to a transaction or by a statement of the form transfer to a program:
- A transfer to a transaction acts as follows--
- In a program that runs as a Java main text or main batch program, the behavior depends on the setting of build descriptor option synchOnTrxTransfer--
- If the value of synchOnTrxTransfer is YES, the transfer statement commits recoverable resources, closes files, closes cursors, and starts a program in the same run unit.
- If the value of synchOnTrxTransfer is NO (the default), the transfer statement also starts a program in the same run unit, but does not close or commit resources, which are available to the invoked program.
- In a Web program or page handler, a transfer to a transaction is not valid.
- A transfer to a program does not commit or rollback recoverable resources, but closes files, releases locks, and starts a program in the same run unit.
The linkage options part does not affect the characteristics of either kind of transfer.
For details, see transfer.
- The system function sysLib.startTransaction starts a run unit asynchronously. The operation does not end the transferring program and does not affect the databases, files, and locks in the transferring program. You have the option to pass data into the input record, which is an area in the receiving program.
If your program invokes sysLib.startTransaction, generate the program with a linkage options part, asynchLink element. For details, see sysLib.startTransaction and asynchLink element.
- The EGL show statement ends the current main program in a text application and shows data to the user by way of a form. After the user submits the form, the show statement optionally forwards control to a second main program, which receives data received from the user as well as data that was passed without change from the originating program.
The show statement is affected by the settings in the linkage options part, transferLink element.
For details, see show.
- Finally, the forward statement is invoked from a page handler or from a program that runs in the context of a Web application. The statement acts as follows:
- Commits recoverable resources, closes files, and releases locks
- Forwards control
- Ends the code
The target in this case is another program or a Web page. For details, see forward.
Related reference
asynchLink element
call
callLink element
forward
luwControl in callLink element
show
sysLib.startTransaction
transfer