The Call Program (CALL) command calls a program named on the command, and passes control to it.
The CALL command has the following format:
CALL PGM(library-name/program-name) PARM(parameter-values)
The program name or library name may be a variable. If the called program is in a library that is not on the library list, you must specify the qualified name of the program on the PGM parameter. When the called program finishes running, control returns to the next command in the calling program.
The sequence of CALL commands
in a set of programs calling each other is the call stack. For example, look
at this series:
In this series, the call stack
is as follows:
When PROGC finishes processing, control returns to PROGB at the command after the call to PROGC. Control is thus returned up the call stack. This occurs whether or not PROGC ends with a RETURN or an ENDPGM command.
A CL program can call itself.