Supported RPG Features

DCL-ENUM declares a group of named constants sharing a common type. It is free-format-only syntax.

DCL-ENUM Colors INT(5) QUALIFIED;
  Red   CONST(5);
  Green CONST(9);
  Blue  CONST(2);
END-ENUM;

A QUALIFIED enumeration's constants are read by their dotted name, and the reference evaluates to that enumerator's declared value - not its position in the declaration:

DCL-S n INT(5);
n = Colors.Green;                    // 9, not 2
IF Colors.Blue < Colors.Red;         // 2 < 5 - compares by value

Like a DCL-C constant, an enumerator has no storage: its value is inlined at each reference. It can therefore be used anywhere a literal of that type can - in an expression, as an assignment source, in a comparison, or as an argument.

CONST is optional on the value; DFT marks at most one enumerator as the default (a second DFT is rejected with TRN1531). LIKE may reference an enumeration to inherit its type, and %HIVAL / %LOVAL over a numeric enumeration group return the largest and smallest enumerator values (see Supported Built-In Functions).