Sign in

docs RPG Reference

ENDyy (End a Structured Group)

ENDyy (End a Structured Group)

Free-Form SyntaxENDDO ENDFOR ENDIF ENDMON ENDSL (END and ENDCS not allowed)
CodeFactor 1Factor 2Result FieldIndicators
ENDincrement-value
ENDCS
ENDDOincrement-value
ENDFOR
ENDIF
ENDMON
ENDSL

The ENDyy operation ends a CASxx, DO, DOU, DOW, DOUxx, DOWxx, FOR, IF, IFxx, MONITOR, or SELECT group of operations.

The ENDyy operations are listed below:

END : End a CASxx, DO, DOU, DOUxx, DOW, DOWxx, FOR, IF, IFxx, or SELECT group

ENDCS : End a CASxx group

ENDDO : End a DO, DOU, DOUxx, DOW, or DOWxx group

ENDFOR : End a FOR or FOR-EACH group

ENDIF : End an IF or IFxx group

ENDMON : End a MONITOR group

ENDSL : End a SELECT group

The increment-value operand is allowed only on an ENDyy operation that delimits a DO group. It contains the incrementing value of the DO group. It can be positive or negative, must have zero decimal positions, and can be one of: an array element, table name, data structure, field, named constant, or numeric literal. If increment-value is not specified on the ENDDO, the increment defaults to 1. If increment-value is negative, the DO group will never end.

Conditioning indicators are optional for ENDDO or ENDFOR and not allowed for ENDCS, ENDIF, ENDMON, and ENDSL.

Resulting indicators are not allowed. No operands are allowed for ENDCS, ENDIF, ENDMON, and ENDSL.

If one ENDyy form is used with a different operation group (for example, ENDIF with a structured group), an error results at compilation time.

See the CASxx, DO, DOUxx, DOWxx, FOR, FOR-EACH, IFxx, and DOU, DOW, IF, MONITOR, and SELECT operations for examples that use the ENDyy operation.

For more information, see Error-Handling Operations or Structured Programming Operations.