AL: Lists and Dictionaries

TallyHoTallyHo Member Posts: 416
I've been looking for a good way to use the new variable types List and Dictionary to replace the use of temporary tables.
If anyone here has code snippets to share on how to implement those new buffering tools in more complex ways it would be very welcome! So far I came up with this:


// Welcome to your new AL extension.
// Remember that object names and IDs should be unique across all extensions.
// AL snippets start with t*, like tpageext - give them a try and happy coding!

pageextension 50100 CustomerListExt extends "Customer List"
{
trigger OnOpenPage();
var
myDictionary: Dictionary of [code[20], Decimal];
myListOfLists: List of [List of [code[20]]];
myListOfDictionaries: List of [Dictionary of [code[20], Decimal]];
i: Integer;
j: Integer;
begin
myDictionary.Add('A', 2.432);
myDictionary.Add('B', 0.037);
myDictionary.Add('C', 1.234);
myListOfDictionaries.Add(myDictionary);
clear(myDictionary);
myDictionary.Add('A', 1.425);
myDictionary.Add('B', 9.333);
myDictionary.Add('C', 0.123);
myListOfDictionaries.Add(myDictionary);
clear(myDictionary);
myDictionary.Add('A', 0.134);
myDictionary.Add('B', 3.234);
myDictionary.Add('C', 7.334);
myListOfDictionaries.Add(myDictionary);
for i := 1 to myListOfDictionaries.count do begin
myDictionary := myListOfDictionaries.get(i);
for j := 1 to myDictionary.Count do begin
message('%1', myDictionary.get('A'));
end;
end;
end;
}
Sign In or Register to comment.