Wednesday 3 December 2014

Table inheritance in Ax 2012


Step-1 Create a table called 'BaseTable'
Step-2 Set table property 'supportInheritance' to 'Yes'
Step-3 Create a filed name called 'InstanceRelationType' extends 'RelationType'
Step-4 Set table property 'InstanceRelationType' to 'InstanceRelationType'
Step-5 Create two filed called Id and Name as shown below screen
Step-6 Create another table called 'ChildTable'
Step-7 Set table property 'supportInheritance' to 'Yes'
Step-8 Set table property 'Extends' to 'BaseTable'
Step-9 Write a job to access the base table fields given below

static void dataInsert_BaseTable(Args _args)
{
BaseTable bt;
ChildTable ct;

ct.Id = '1000';
ct.Name = 'Test';
ct.insert();
}

Tuesday 2 December 2014

Collection Classes in Ax 2012

Array 
     Array's can hold values of any single data type and allows duplicate values and insertion of data is based on the location Specific. 


Static void Array_example(Args _args)

{
Int I;
Array arr=new Array(Types::String);
arr.value(1,”ABC”);
arr.value(2,”ABCD”);
arr.value(3,”ABCDE”);
for(i=1;i<=arr.lastindex();i++)
{
Info(strfmt(“Value is: %1”,arr.value(i)));
}
}



List   
 List Contains elements that are accessed sequentially. Unlike the Array class, the List class provides an addStart() method. As with the Set class, the List class provides methods getEnumerator() and getIterator(). You can use an iterator to insert and delete items from a List object. It allows duplicate values.


Static void List_example(Args _args)
{
List l=new List (Types::Integer);
ListEnumerator lenum;
l.addEnd (20);
l.addEnd (24);
l.addStart (30);
l.addStart (25);
lenum= l.getEnumerator();
lenum.reset();
  While (lenum.movenext())
    {
             Info (strfmt(“Value is: %1”,lenum.current()));
     }


Map

 Map Associates a key value with another value. It doesn't allow duplicate Key values in Maps.

Static void Map_example(Args _args)
{
Map m=new Map (Types::String,Types::Integer);
MapEnumerator menum;
m.insert(“Vlaue1”, 20);
m.insert(“Vlaue2”, 30);
m.insert(“Vlaue3”, 60);
menum= m.getEnumerator();
While (menum.movenext())
{
Info (strfmt(“Value is: %1 || Key is: %2 ”,menum.currentValue(),menum.currentKey()));
}
}

Set
Holds values of any single type. Values are not stored in the sequence they are added. Instead, the Set object stores them in a manner that optimizes performance for the in() method. When you add a value to a Set object which is already storing that same value, the add attempt is ignored by the Set object.Unlike the Array class, the Set class provides the methods in() and remove().
Static void Set_example(Args _args)
{
Set s=new Map (Types::Integer);
SetEnumerator senum;
s.add( 20);
s.add( 25);
s.add( 60);
senum= s.getEnumerator();
While (senum.movenext())
  {
     Info (strfmt(“Value is: %1 “,senum.current()));
  }
}

Struct
Can contain values of more than one type. Used to group information about a specific entity.

Static void Struct_example(Args _args)
{
Int i;
Struct s=new Struct ();
s.add(“Name”,”ABC”);
s.add( “Age”, 34);
s.add( “Salary”,23000.00);
for(i=1;i<=s.fields();i++)
  {
    Info (strfmt(“Field Type: %1 || Field Name: %2 || Value      is:%3“,s.fieldType(i),s.fieldName(i),s.value(s.fieldName(i))));
  }
}