CL Command Reference - ENDSUBR
CL Command List > ENDSUBR Reference
Description:
The End Subroutine (ENDSUBR) command specifies the end of a subroutine, and must be paired with a previous Subroutine (SUBR) command. When the ENDSUBR command is processed, control is returned to the command immediately following the Call Subroutine (CALLSUBR) command that called the subroutine. If a value is to be returned, such as an error code, the returned value must be able to be stored into a 4-byte signed integer CL variable. The Return value (RTNVAL) parameter can be a variable or constant. If no RTNVAL parameter is defined, the value will default to zero.
Restrictions:
. This command is valid only within a CL procedure.
. The subroutine must be defined within a procedure, and must be located at the end of the procedure.
Examples:
PGM
:
SUBR SUBR1
:
ENDSUBR
ENDPGM
This CL subroutine is identified by a SUBR command that contains the subroutine name, SUBR1, and is ended by the ENDSUBR command.
PGM
:
SUBR SUBR1
:
ENDSUBR RTNVAL(-1)
ENDPGM
This CL subroutine has an ENDSUBR command that returns a -1.