Can you define an ENUM with some keywords included?

Posted by jquerijero on 23-Jul-2019 19:16

I'm trying to create an ENUM with No and Yes as part of the list, but it is not letting me. Can you at least do a named member with specific string value? 

Posted by Simon L. Prinsloo on 03-Sep-2019 09:49

The inability to use No and Yes appears to be a defect, as the documentation states:

The rules for member names follow the same rules that are in place for variable and property names. Member names are case insensitive and can be reserved keywords.


It fails in both OE11.7.4 and OE12.0, so you should report it as a defect.

All Replies

Posted by Torben on 24-Jul-2019 09:35

Sounds like a bug!?

Posted by Mike Fechner on 24-Jul-2019 09:46

It's probably more an intended limitation. You cannot use all ABL keywords as identifiers anywhere. This might be due to syntax ambiguity or just complexity in the compiler implementation.

"Can you at least do a named member with specific string value?"

No, the string value is always the Enum member name. You need to live with that. Enums are not made to provide anything "human readable". Emums are there to produce a type with a defined set of values. Enums are to make API's and Interfaces more clear and generally help to avoid programming mistakes.

What we typically to, is to use the enum type name and member name as keys to retrieve a human readable value from our translation service. That way we maintain a localizable version of the human readable representation.

Posted by Fernando Souza on 24-Jul-2019 10:43

This is a limitation. The constants yes/no/true/false are not allowed as member names in classes or enums.

Posted by mircea.alexandru on 25-Jul-2019 08:25

If you really really want a string enum, you can use the type-safe-enum pattern and create some static class exposing things quite similar to a standard oe enum from a syntax perspective.

Posted by mircea.alexandru on 25-Jul-2019 08:25

If you really really want a string enum, you can use the type-safe-enum pattern and create some static class exposing things quite similar to a standard oe enum from a syntax perspective.

Posted by Simon L. Prinsloo on 03-Sep-2019 09:49

The inability to use No and Yes appears to be a defect, as the documentation states:

The rules for member names follow the same rules that are in place for variable and property names. Member names are case insensitive and can be reserved keywords.


It fails in both OE11.7.4 and OE12.0, so you should report it as a defect.

This thread is closed