Subroutine (SUBR)

Where allowed to run:
  • Batch program (*BPGM)
  • Interactive program (*IPGM)
Threadsafe: Yes
Parameters
Examples
Error messages

The Subroutine (SUBR) command is used in a CL procedure, along with the End Subroutine (ENDSUBR) command, to delimit the group of commands that define a subroutine. The SUBR command defines the start of a subroutine. Subroutines may not be nested; therefore, an ENDSUBR command must end the current subroutine before the next SUBR command starts a new subroutine. A label specified on a SUBR command, or on a null command preceding the SUBR command, can be used as a target for a Go To (GOTO) command defined in the same subroutine. This GOTO command, when run, will pass control to the first executable statement in the subroutine.

Restrictions:

Top

Parameters

Keyword Description Choices Notes
SUBR Subroutine Simple name Required, Positional 1
Top

Subroutine (SUBR)

Specifies the subroutine name. This is the name that must be specified on a Call Subroutine (CALLSUBR) command.

This is a required parameter.

simple-name
Specify the name of the subroutine. A CL variable name cannot be used to specify the subroutine name.
Top

Examples

PGM
 :
SUBR SUBR1
 :
ENDSUBR
ENDPGM

This SUBR command defines the start of a subroutine named SUBR1.

Top

Error messages

None

Top