Wednesday 18 December 2013

Axapta collection classes in ax 2012

Axapta collection classes 
Axapta has several collection classess:
  • List
  • Container
  • Array
  • Map
List
declare as class member variable
public class AdjustVendTables
{
    List list;
}
Iniitalize in the new method
void new()
{
    ;
    list = new List(Types::Integer);
}
Loop with the ListIterator
ListIterator:- The ListIterator loop through the Complete List.
ListEnumerator:- List Enumerator class is like list iterator class ,but allows the deletion of element during Enumeration and list itereator does not.
    ListIterator  literator;
    literator = new ListIterator (list);
    while (literator.more())
    {
        print literator.value();
        literator.next();
    }
Container
A container is not a reference type but a value type ( keep in mind). A container contains an ordered sequence of primitive values or other containers. A container is helpful when you must pass a variety of value types between the client and server tiers. A container is a poor choice when you intend to repeatedly add to a list in a loop.
Example:
    container con2;
    int int4;
    str str7;
    ;
    con2 = ["11", 222];
    [int4, str7] = con2;
  • There are several function for working with containers:
  • conDel
  • conIns
  • conPoke
  • conPeek
Array
Arrays can be used for all types but Tables and Classes
// A dynamic array of integers
int i[];

// A fixed-length real array with 100 elements
real r[100];

// A dynamic array of dates with only 10 elements in memory
date d[,10];

// A fixed length array of NoYes variables with 100 elements
// and 10 in memory
noYes e[100,10];
Map
Map is a key-value collection, the x++ equivalent of a dictionairy:
example:


No comments:

Post a Comment