Containers are dynamic and have no limits. They can contain elements of
almost all data types: boolean, integer, real, date, string, container,
arrays, tables, and extended data types. However, objects may not be stored
in containers.
almost all data types: boolean, integer, real, date, string, container,
arrays, tables, and extended data types. However, objects may not be stored
in containers.
Containers in AX are used very often. It’s easy to work with them. But…
data in containers are stored sequentially, and thus retrieved sequentially.
This means that containers provide slower data access if you are working with
_large numbers_ of records. In case of large numbers of records use temporary
tables.
data in containers are stored sequentially, and thus retrieved sequentially.
This means that containers provide slower data access if you are working with
_large numbers_ of records. In case of large numbers of records use temporary
tables.
Containers vs Temporary Tables
There is question arises why we use temporary tables when we have containers . These containers which can store almost every data type values and also while there are lot of functions available for containers. Answer is that on temporary temple we can set indexes on fields and by this way we can fetch data much faster. Although data is stored in container sequentially but on insertion a new copy is generated which is performance over head. When data is increases in container, container starts to be heavy. Similar when you passed temporary table to any method it passed by reference. But when we passed container to method, a new copy is generated and used in method. Container will used only when fewer values will be manipulated. In the case of larger set of data, we have to use temporary tables.
Declaration of containers.
container firstContainer; container secondContainer = [3,"Ali","RAza"];
Insert value:
There are two functions used for insert a value in container, conPoke and conIns
ConIns
secondContainer=conIns(secondContainer,2,"Zaidi");
conPoke:
secondContainer=conpoke(secondContainer,2,”test");
There difference between conPoke and conIns is that conIns, insert a new value at location, and rest of value is shifted to one next Index. conPoke replace the value at insert location.
Read value from container.
The value from container can be read with conPeek function, this method take two parameter, first one is container and second parameter is for getting index. The conPeek function read value of any type so and read for any type.
_value = conPeek(secondContainer,1);
//Read 3
Removing the value from Container:
Condel function is used to remove the value from container.
secondContainer =conDel(secondContainer,2,1);
conDel Function Overview:
container conDel(container container, int start, int number)
Parameter
|
Description
|
---|---|
container
|
The container from which to remove elements.
|
start
|
The one-based position at which to start removing elements.
|
number
| The number of elements to delete. |
conNull function is used to clear all the value from container as
secondContainer=conNull() ;
confind:
This method find the index of the value which is required to be searched , if value is not found zero will be return
_found =conFind(secondContainer,"RAza"); info(int2str(_found)); _found =conFind(secondContainer,"Abc");
Loop through container:
Usually we have to loop through the container.
_lenght = conLen(secondContainer); for (counter =1; counter <=_lenght; count++) { info(strfmt("%1",conPeek(firstcontainer,counter))); }
Happy Daxing:)
Your new valuable key points imply much a person like me and extremely more to my office workers. With thanks; from every one of us.
ReplyDeleteMS Dynamics Online Training