Command reference / CL

RTNSUBR

Return from Subroutine

Returns control to the command immediately following the CALLSUBR command that called the subroutine. RTNSUBR must be used within a subroutine, and a subroutine may contain multiple RTNSUBR commands. A returned value, such as an error code, must be storable in a 4-byte signed integer CL variable. If no RTNVAL is given, the value defaults to zero.

Allowed environments: *BPGM, *IPGM. Use within a CL program. Positional parameters: 0.

Restrictions

Parameters

RTNVAL Return value

Specifies the value returned from the subroutine. It can be a variable or constant that can be stored in a 4-byte signed integer CL variable. If the calling CALLSUBR specified a CL variable for the returned value, that variable is set to this value.

Type
*INT4
Required
No
Default
0
Case
Uppercase

Examples

IF (&A *LT 30) THEN(RTNSUBR RTNVAL(-1))

Exits the CL subroutine with a return value of -1 when &A is less than 30.

IBM command documentation

Generated from os/cl/catalog/RTNSUBR.json and os/cl/help/RTNSUBR.json.