Sign in

docs RPG Reference

WHEN (When True Then Select)

WHEN (When True Then Select)

Free-Form SyntaxWHEN{(MR)} indicator-expression
CodeFactor 1Extended Factor 2
WHEN (M/R)indicator-expression

The WHEN operation code is similar to the WHENxx operation code in that it controls the processing of lines in a SELECT operation. It differs in that the condition is specified by a logical expression in the indicator-expression operand. The operations controlled by the WHEN operation are performed when the expression in the indicator-expression operand is true. See Expressions for details on expressions. For information on how operation extenders M and R are used, see Precision Rules for Numeric Operations.

For more information, see Compare Operations or Structured Programming Operations.

Figure 1. WHEN Operation

CL0N01Factor1+++++++Opcode(E)+Extended-factor2+++++++++++++++++++++++++++..
 *
C                   SELECT
C                   WHEN    *INKA
C                   :
C                   :
C                   :
C                   WHEN    NOT(*IN01) AND (DAY = 'FRIDAY')
C                   :
C                   :
C                   :
C                   WHEN    %SUBST(A:(X+4):3) = 'ABC'
C                   :
C                   :
C                   :
C                   OTHER
C                   :
C                   :
C                   :
C                   ENDSL