A subroutine is a series of instructions that a program calls to perform a specific task. The instruction that calls the subroutine is the CALL instruction. You can use the CALL instruction several times in a program to call the same subroutine.
When the subroutine ends, it can return control to the instruction that directly follows the subroutine call. The instruction that returns control is the RETURN instruction.
function(argument1, argument2,…)
or
function()
z = function(arguments1, argument2,…)
When the function ends, it can use the RETURN instruction to send back a value to replace the function call.
Both subroutines and functions can be internal (designated by a label) or external (designated by the subroutine or function in the REXX File System/VSE Librarian sublibrary member name). The two preceding examples illustrate an internal subroutine named sub1 and an internal function named func1.
The following illustrates an external subroutine named sub2.
The following illustrates an external function named func2.