Otherwise (OTHERWISE)

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

Specifies the command or group of commands (in an If or Do group) that are processed if none of the conditions on any of the When commands within a Select command group were evaluated to be true. After the command or Do group is processed, control is passed to the next command after the End Select command associated with this Otherwise command. If the command specified in this parameter is a DO, DOWHILE, DOUNTIL, or DOFOR command, all commands within the Do group are considered to be the command specified by the parameter.

Restrictions:

Top

Parameters

Keyword Description Choices Notes
CMD Command Command string Optional, Positional 1
Top

Command (CMD)

Specifies the command or commands (in a If or Do group) to be processed if no When commands had an expression that evaluated to true.

If the command specified in this parameter is a DO, DOWHILE, DOUNTIL, or DOFOR command, all of the commands specified within the Do group are considered to be part of the command specified by the parameter.

If no command is specified on the CMD parameter (a null OTHERWISE) control is passed to the next command after the ENDSELECT command associated with this WHEN command.

Any CL command can be specified on the CMD parameter, except the following commands:

Top

Examples

DCL   VAR(&NAME)  TYPE(*CHAR)  LEN(10)
 :
SELECT
  WHEN   COND(&NAME *EQ *CMD)  THEN(DO)
    :   (group of CL commands)
  ENDDO
  WHEN   COND(&NAME *EQ *PGM)  THEN(DO)
    :   (group of CL commands)
  ENDDO
  OTHERWISE   CMD(CHGVAR &NAME *PGM)
ENDSELECT

The OTHERWISE specifies the command to run if none of conditions on any of the WHEN commands in a SELECT command group command group were matched. In this example the CHGVAR will be run when the value of &NAME is not *CMD and not *PGM.

Top

Error messages

None

Top