This is an example of transferring control to improve performance.
In the following illustration, if Program A is specified with
USRPRF(*OWNER), the owner's authorities are in effect for all of the programs
shown. If Program B is specified with USRPRF(*OWNER), the owner's authorities
are in effect only while Programs B and C are active. When Program B transfers
control to Program D, Program B is no longer in the call stack and the owner
of Program B is no longer considered for authorization during the running
of Program D. When the programs complete processing (by returning or transferring
control), the owner's authorities are no longer in effect. Any overrides
issued by Program B remain in effect while Program D is running and are lost
when Program D does a return.
The Transfer Control (TFRCTL) command has the following format:
TFRCTL PGM(library-name/program-name) PARM(CL-variable)
The program (and library qualifier) may be a variable.
It is important to note that only variables may be used as parameter arguments on this command, and that those variables must have been received as a parameter in the argument list from the program that called the transferring program. That is, the Transfer Control (TFRCTL) command cannot pass a variable that was not passed to the program running the Transfer Control (TFRCTL) command.
In the following example, the first Transfer Control (TFRCTL) is valid. The second Transfer Control (TFRCTL) command is not valid because &B was not passed to this program. The third TFRCTL command is not valid because a constant cannot be specified as an argument.
PGM PARM(&A) DCL &A *DEC 3 DCL &B *CHAR 10 IF (&A *GT 100) THEN (TFRCTL PGM(PGMA) PARM(&A)) /* valid */ IF (&A *GT 50) THEN (TFRCTL PGM(PGMB) PARM(&B)) /* not valid */ ELSE (TFRCTL PGM(PGMC) PARM('1')) /* not valid */ ENDPGM