List Object Type
Views (8)
A new AL data type that caught my attention was the List data type: it is a kind of array with lot of handling methods and no need to set the dimensions in the declaration. The dimensions are dynamic as you add new entries in the List. Its main limitation is you only can store simple types in its structure.
If you read the list of methods you can notice that is more than an array is a table with dynamic searchs and advanced methods to insert and delete.
Use case: asking for the end of the (hello) world
The title is about the value of good examples and use cases. It is as important to show good applications and uses as show new techs.
My use case is into one of my apps, in a method I use a list to the do this operation:
- We get and option field with a generic type “fieldref”. This generic types are also very interesting and are widely used in my app: JalmarazMartn/BCDataSuport (github.com)
- We load a str menu with option caption. As you know, the different options of the field are separated with “,” char, so a str menu suites without problems, splitting the option automatically :
local procedure LookupOptionValue(FieldRef: FieldRef)
var
OptionList: List of [Text];
OptionSelection: Integer;
begin
OptionSelection := StrMenu(FieldRef.OptionCaption);
if OptionSelection = 0 then
exit;
- We save all the field option caption string in a list applying “split” in the string:
OptionList := FieldRef.OptionCaption.Split(',');
- we get the value of selection index with List method “get(index)”. FieldValue is a text variable:
FieldValue := OptionList.get(OptionSelection);
And all together:
local procedure LookupOptionValue(FieldRef: FieldRef)
var
OptionList: List of [Text];
OptionSelection: Integer;
begin
OptionSelection := StrMenu(FieldRef.OptionCaption);
if OptionSelection = 0 then
exit;
OptionList := FieldRef.OptionCaption.Split(',');
FieldValue := OptionList.get(OptionSelection);

Like
Report
*This post is locked for comments