CALL and RETURN instructions

The CALL instruction interrupts the flow of a program by passing control to an internal or external subroutine. An internal subroutine is part of the calling program. An external subroutine is another program. The RETURN instruction returns control from a subroutine back to the calling program and optionally returns a value.

When calling an internal subroutine, CALL passes control to a label specified after the CALL keyword. When the subroutine ends with the RETURN instruction, the instructions following CALL are processed.
dfhrx006
When calling an external subroutine, CALL passes control to the program name that is specified after the CALL keyword. When the external subroutine completes, you can use the RETURN instruction to return to where you left off in the calling program.
dfhrx007

For more information about calling subroutines, see Subroutines and functions.

You can use the CALL instruction with the ON parameter to implement a routine that receives control when REXX detects an exception condition, for example an error or failure condition. See Conditions and condition traps.

For more details about the CALL and RETURN instructions, see CALL and RETURN.