How it works...

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. 

If you are going to make an enum extensible, make sure that you handle this in your source code by raising events where necessary in order to handle any additional enum values that might be added.

You can use enums variable types to define the following:

  • Table field
  • Variables
  • Function parameters
You can reuse enum objects across multiple entities, meaning you can create a single enum object and use it for a table field and a variable.

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';
}
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.168.16