Use the CALL command

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 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:
The sequence of CALL commands in a set of programs calling each other is the call stack example.
In this series, the call stack is as follows:


Call stack example.

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.

Related tasks
Pass parameters
CALL command
Related information
Call (CALL) command