Command reference / CL
LEAVE
Leave
Ends processing of the commands in the associated DOWHILE, DOUNTIL, or DOFOR loop and passes control to the first command following the associated ENDDO.
Allowed environments: *BPGM, *IPGM.
Use within a CL program.
Positional parameters: 1.
Restrictions
- Valid only in a CL program or ILE CL procedure.
- Valid only inside a DOWHILE, DOUNTIL, or DOFOR command group.
Parameters
CMDLBL
Command label
The label must be within the same program as the LEAVE command and must label an active DOWHILE, DOUNTIL, or DOFOR group. A CL variable name cannot be used for the label.
Suggested / special values:
*CURRENT
*CURRENT- Leaves the innermost loop surrounding this LEAVE command.
Examples
IF COND(&NAME *EQ *NONE) THEN(LEAVE)
Interrupts the active DOFOR group; processing continues with the command following the ENDDO.
IF COND(&NAME *EQ *NONE) THEN(LEAVE CMDLBL(LOOP1))
Interrupts both the active DOUNTIL and DOFOR groups; processing continues after the ENDDO matching the DOFOR.
Generated from os/cl/catalog/LEAVE.json and os/cl/help/LEAVE.json.