An enum is a new object type in the AL development language. It provides developers with a way to define a list of named values. Using an enum extension object, the list of values in an enum can be extended by other developers without making modifications to your source code.
You can control whether or not an enum can be extended by using the Extensible attribute in the enum object.
You can use enums variable types to define the following:
- Table field
- Variables
- Function parameters
Both entities will share the same set of enum values, so if the enum is changed or extended, both entities will inherit the change. This could be good or bad, so take care when reusing enum object types.
To reiterate, the reason you should use an enum instead of a standard option field is that the enum values can be extended. The list of option values is static and cannot be changed without altering the original source code. In order to add new enum values, a developer creates an enumextension object, which then allows them to append new values to the enum values, as follows:
enumextension 50000 MyEnumExtension extends "Transaction Status"
{
value(50000; MyNewValue)
{
Caption = 'My New Value';
}
}