Thursday, 2 January 2014

Difference between temporary table and container in ax 2012

Pack and unpack in ax 2009

Pack
this method is a standard method inherited from RunBase. It is used to save
the values that the user selects and store them until the next time the user executes
the class.
Public container pack ()
 
{
return [#CurrentVersion, #CurrentList];
}

===
unpack
Standard method inherited from RunBase and used to fetch the values that the user
selected the previous time he executed the class.
public boolean unpack(container packed Class)
{
Version version = RunBase::getVersion(packedClass);
;
switch (version)
{
case #CurrentVersion:
[version, #CurrentList] = packedClass;
break;
default:
return false;
}
return true;
}

Display & Edit methods in ax 2012

Display Method:
         Indicates that the methods return value is to be displayed on a forms (or) Reports .The value cannot be altered in the form or report

Take the new method in a table, and then drag that method into the grid and set data source properties. In that field is non-editable.

We can create display method on the
1. Table methods
2. Form methods
3. Form data source methods
4. Report methods
5. Report design methods

Display Name names ()
{
    CustTable   custTable;
    ;
    return  CustTable::find(this.CustAccount).Name;
}

Edit Method:

        Indicates that the methods return type is to be use to provide information for a field that is used in a form only

 We can create edit method on the

1. Table methods
2. Form methods
3. Form datasoruce methods

        Take the new method in the table, and then drag that method into the grid and set data source properties. In that field is user can edit it and accept the values to the user and save it CustTable.

 Edit Name name(boolean _set , Name _name)
{
    Name    name    = _name;
    CustTable   custTable;
    ;
    if(_set)
    {
        if(name)
        {
            ttsbegin;
            custTable   = CustTable::find(this.CustAccount,true);
            custTable.Name  = name;
            custTable.update();
            ttscommit;
        }
    }
    else
    {
        name    = CustTable::find(this.CustAccount).Name;
    }
    return name;
}

Link Type and Join Types in ax 2012


Link Type:-

1.      Active: - Parent and child- data source is updated immediately when a new record in the parent data source is selected. Continuous updates consume lots of resources consuming.

2. Delayed: - Parent and child - A pause is inserted before linked child data sources are updated. This     enables faster navigation in the parent data source because the records from child data sources are not updated immediately. For example, you can scroll a list of orders where you do not want to review the lines associated with the order until you stop scrolling.

3. Passive: - Parent and child - Linked child data sources are not updated automatically. Updates of the child data source must be programmed on the active method of the master data source.

Join Types:-

1. InnerJoin: - Combined data source – select the record from the main table that matches records in the joined table and vice versa.
There is one record for each match. Records without related records in the other data source are eliminated from the result.

2. Outer Join: - Combined data source – select the records from the main table. The records are retrieved whether they have matching records in the joined table

3. Exist Join: - Combined data source -The data source retrieves a record from the main table for each matching record in the joined table.
The differences between InnerJoin and ExistJoin are as follows:
·         When the join type is ExistJoin, the search ends after the first match has been found.
·         When the join type is InnerJoin, all matching records are searched for.

4. NotExistJoin: - Combined data source -Select records from the main table that do not have a match in the joined table.


 For more information:-


Container And its Functions Use in ax 2012

condel :- Use condel to delete one or more items from a container.

EX:-  container conDel(container container, int start, int number)
 
static void conDelExample(Args _args)
{
    container c = ["Hello world", 1, 3.14];
    ;
    // Deletes the first two items from the container.
    c = conDel(c, 1, 2);
}
 
confind:- Use confind to locate a sequence of items in a container.

EX:-  int conFind (container container, anytype element,... )

static void conFindExample(Args _args)
{
    container c = ["item1", "item2", "item3"];
    int i;
    int j;
    ;
 
    i = conFind(c, "item2");
    j = conFind(c, "item4");
    print "Position of 'item2' in container is " + int2Str(i);
    print "Position of 'item4' in container is " + int2Str(j);
    pause;
}

conins :-  Use conins to insert some items into a container.
EX:- container conIns (container container ,int start ,anytype element,... )
 
static void conInsExample(Args _arg)
{
    container c;
    int i;
    ;
    c = conIns(c,1,"item1");  
    c = conIns(c,2,"item2");
    for (i = 1 ; i <= conLen(c) ; i++)  
    {
    // Prints the content of a container.
        print conPeek(c, i);
    }
    pause;
}
 

conlen :- Use conlen to find out how many items there are in a container.
EX:- int conLen(container container)
 
static void conLenExample(Args _arg)
{
    container c;
    int i;
    ;
 
    c = conins(["item1", "item2"], 1);  
    for (i = 1 ; i <= conLen(c) ; i++)
    {
        print conPeek(c, i);
     }
    pause;
}

connull :- Use connull to explicitly dispose of the contents of a container.
EX:- container conNull()
 
static void conNullExample(Args _arg)
{
    container c = ["item1", "item2", "item3"];
    ;
 
    print "Size of container is " + int2str(conLen(c));
    // Set the container to null.
    c = conNull();  
    print "Size of container after conNull() is " + int2Str(conLen(c));
    pause;
}

conpeek:- Use conpeek to extract an item from a container, and to convert it into another data type, if necessary.
EX:- anytype conPeek(container container, int number)
 
static void main(Args _args)
{
    container cnI, cnJ;
    int i, j;
    anytype aty;
    
    
    info("container cnI ...");
    cnI = ["itemBlue", "itemYellow"];
    
    for (i=1; i <= conLen(cnI); i++)  
    {
        aty = conPeek(cnI, i);
        info(int2str(i) + " :  " + aty);
    }
 
    //
    
    info("container cnJ ...");
    cnJ = conIns(cnI, 2, "ItemInserted");
    
    for (j=1; j <= conLen(cnJ); j++)  
    {
        aty = conPeek(cnJ, j);
        info(int2str(j) + " :  " + aty);
    }
}

conpoke :- Use conpoke to replace (poke) an item in a container.

EX:- container conPoke(container container,int start,anytype element,...)
 
static void conPokeExample(Args _arg)
{
    container c1 = ["item1", "item2", "item3"];
    container c2;
    int i;
 
    void conPrint(container c)
    {
        for (i = 1 ; i <= conLen(c) ; i++)
        {
            print conPeek(c, i);
        }
    }
    ;
    conPrint(c1);
    c2 = conPoke(c1, 2, "PokedItem");
    print "";
    conPrint(c2);
    pause;
}