Showing posts with label Container. Show all posts
Showing posts with label Container. Show all posts

Definition of List, Set, Container, and Map

 

Difference between List, Set, Container, and Map


Containers:

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.

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.

List:

Lists are structures that may contain any number of elements that are
accessed sequentially. Lists may contain values of any X++ type. All the
values in the list must be of __the same__(this is the main difference
between lists and containers) type, given in the creation of the list. The
implementation of lists is such that the traversal of the list elements is __very
fast.

Take a look for example at the class Dialog addControl() method.
Their controls are stored in ctrls List.

Map:

A map is a data type that associates one (key) value with another value [An
analog – a small table in memory with two fields: Keys, Values]. Both the key
and value values may be of any valid X++ type, including objects. The types
of the key and the value are given in the declaration of the map. The
implementation of maps is such that access to the values is _very fast_.

Don’t confuse map X++ types with Map objects in AOT, which are used for
mapping tables with similar structures of fields

Set:

The functionality of Sets is similar to the list.  A Set is just an unordered list of items, while a list of items held by a Map
are indexed via a key.
Take look at
\Classes\sysLabel\LabelModuleId().

Support Faryal's Cusine


Container Functions D365FO-AX 2012

Container Functions D365FO-AX 2012


Today, I am Sharing the functions of container, I have explored during in my career.


Container View

conView


Parameters

cconView(container,Caption,false);


reference screenshot



Insert in container



conIns


Parameters

conIns(container,position,anytype of value);

Example

   container   objContainer;
    int     position=1;
    // insert in container
   objContainer =conIns(objContainer,position,"Sohail Sheikh");

reference screenshot




Length of container 


conLen


Parameters

conLen(containerobject); // will return int

 Example

 container   objContainer=["Sohail Sheikh"];
    int     position=1,len=0;
    

 // container length   
   len=conLen(objContainer);
    info(strFmt("%1",len));

reference screenshot

Pull Data from container


conpeek


Parameters


conpeek(container,position)// will return anytype

Example
  container   objContainer=["Sohail Sheikh"];
    int     position=1;
    str objValue;

        
    // pull data from container   
    objValue=conPeek(objContainer,position);
        info(strFmt("%1",objValue));
 
reference screenshot




Replace Data of container

conpoke

Parameters

conPoke(container,position,anyvalue)// will return container

Example
   container   objContainer=["Sohail Sheikh"];
    int     position=1;
    str objValue;

        
    
     objContainer=conPoke(objContainer,position,"Sheikh Sohail Hussain");
    objValue=conPeek(objContainer,position);    
    info(strFmt("%1",objValue));

reference screenshot



Container Insert Operator 



Parameters


Example
    container   objContainer=["Sohail Sheikh"];
    int     position=1;
    str objValue;

        // insert using operator 
    objContainer+="Inserted";
       
    

    info(strFmt("%1,%2",conPeek(objContainer,1),conPeek(objContainer,2)));

reference screenshot




Find value in Container  

conFind


Parameters

conFind(container,anytype)// will return true or false


Example
 container   objContainer=["Sohail Sheikh"];
    int     position=1;
    str objValue;

        // insert using operator 
    objContainer+="Inserted";
    
      if(conFind(objContainer,"Inserted"))
    {
        info("Value found");
    }

   
reference screenshot





Delete value in Container  

conDel


Parameters

conDel(container,startPosition,EndPosition)// will return container

Example
container   objContainer=["Sohail Sheikh"];
    int     position=1;
    str objValue;

        // insert using operator 
    objContainer+="Inserted";
    
    info(strFmt("Container length Before delete %1",conLen(objContainer)));
    objContainer=conDel(objContainer,2,2);
  
   
   info(strFmt("Container length After delete %1",conLen(objContainer)));

    
reference screenshot





Container  to Str

con2Str


Parameters

conStr(container)// string

Example

  container   objContainer=["Sohail Sheikh"];
    int     position=1;
    str objValue;

        // insert using operator 
    objContainer+="Inserted";
    
    info(con2Str(objContainer));

reference screenshot




Container  Null

conNull


Parameters
conNull()// set the container null

Example
 container   objContainer=["Sohail Sheikh"];
    int     position=1;
    str objValue;

        // insert using operator 
    objContainer+="Inserted";
    
    info(strFmt("Container length Before set null %1",conLen(objContainer)));

 objContainer=conNull(); 
   

   info(strFmt("Container length After set null %1",conLen(objContainer)));


reference screenshot



Str to container

str2con


Parameters

str2Con(stringValues,separator);// will return container

 str objValue;
    container   objContainer;
    objContainer=str2con("Sheikh,Sohail",",");
    
    info(strFmt("%1",con2Str(objContainer)));



reference screenshot



Support Faryal's Cusine


Virtual Fields Vs Computed Fields

  Virtual Field: A virtual field in D365FO is a field that doesn't have a direct representation in the database. It's a field that y...