{
List l = new List(Types::String);
ListIterator li;
;
// limitation of list - it will give in the order u add - ascending or descending order
// it all also allow duplicates
l.addStart("Tendulkar");
l.addEnd("sehwag");
l.addEnd("gambhir");
l.addEnd("yuvraj");
l.addStart("haribhajan");
l.addend("haribhajan");
info(int2str(l.elements()));
li = new ListIterator(l);
while (li.more()) // this will return true or false -
{
info (li.value());
li.next();
}
}
{
CustTable custTable;
Set set = new Set(Types::Record);
SetEnumerator setEnumerator;
;
while select custTable
{
if (custTable && !set.in(custTable))
{
set.add(custTable);
}
}
if (!set.empty())
{setEnumerator = set.getEnumerator();
setEnumerator.reset();
while (setEnumerator.moveNext())
{
custTable = setEnumerator.current();
info(strfmt("Customer: %1",custTable.AccountNum));
}
}
}
*--*
static Set dimensionCodesSet2DimensionTopicsSet(Set _dimensionCodesSet) { Set topicsSet; SetEnumerator setEnumerator; DimensionTopic dimensionTopic; ; topicsSet = new Set(Types::Class); setEnumerator = _dimensionCodesSet.getEnumerator(); while (setEnumerator.moveNext()) { dimensionTopic = DimensionTopic::construct( DimensionTopicType::Dimension, Dimensions::code2ArrayIdx(setEnumerator.current())); topicsSet.add(dimensionTopic); } return topicsSet; }
static void TDS_SetExample(Args _args)
{
Set s1 = new Set(Types::String);
SetIterator si;
Set s2 = new Set(Types::String);
Set resultSet;
// set will always result in ascending order and it will not allow duplicates
// set can perform additional operations - union , intersection and difference
s1.add("A");
S1.add("z");
s1.add("B");
s1.add("F");
s1.add("F");
// To find any value in a set use "in" method
if (s1.in("b") == true)
{
info ("b exists");
}
else
{
error ("b doesnt exists");
}
s2.add("A");
s2.add("k");
S2.add("g");
info(int2str(s1.elements()));
si = new SetIterator(s1);
while (si.more())
{
info(si.value());
si.next();
}
resultSet = Set::intersection(s1, s2);
si = null;
info ("Intersection");
si = new SetIterator(resultSet);
while (si.more())
{
info(si.value());
si.next();
}
}
Map :
- Map can hold a key and associated value
- Imp methods : elements, Key, insert
static void TDS_MapExample(Args _args)
{
// Maps are used to hold the key and correspondiong value
Map m = new Map(Types::Integer, Types::String);
MapIterator mi;
;
m.insert(100, "Nick");
m.insert(200, "Leo");
m.insert(400, "Eve");
mi = new MapIterator(m);
while (mi.more())
{
info(mi.key());
info(mi.value());
mi.next();
}
}
static void MAP_LoadTableTable(Args _args)
{
Map m = new Map(Types::String, Types::Real);
MEE_CustTable k;
MapIterator mi;
;
while select k
{
m.insert(k.CustomerId, k.Creditlimit);
}
info(int2str(m.elements()));
info ("_______________________");
mi = new MapIterator(m);
while (mi.more())
{
info(mi.key());
info(mi.value());
mi.next();
}
}
Containers :
- Containers are used to store different datatypes
- Max columns in a container - 50
>> some important functions :
conlen - gives the length of the container
conpeek - gives the value of an element based on the index
conpoke - used for replacing any element with new element value
condel - willl delete the elements in cotnainer based on the start postion and number of elements to be deleted
connull - will empty the container
conins - will help to insert new elements to container
conview - to viuew the elements in the container - onyl for unit testing
confind - to find a particular element exists in container - it will give u the postiion/index
>> Just look at the following example to undestand how these methods can be applied :
static void TDS_Containers(Args _args)
{
Container con = [1000, "Rahul", 5000.00, 56];
container resultCon;
int i;
int position;
// container limit is 50 columns
;
// container index starts with 1
// to get the length of the container
info(int2str(conlen(con)));
// to get any value based on the index use conpeek() function
info(conpeek(con, 3));
// to get all the values in one shot
info("__________________________________");
for ( i = 1; i <= conlen(con); i++)
{
info(conpeek(con,i));
}
info("__________________________");
resultcon = condel(con, 2,2);
conview(resultcon); // this should be only used for testing purpose
// to nullify to empty the container
//con = connull();
//info(int2str(conlen(con)));
//
// To insert any new valuezs into container - use conins()
// To replace any value in the container - use conpoke()
// to find any value in container- use confind
position= confind(con, "sreedhar");
info(strfmt("sreedhar is found at %1 position", position));
}
Macros in Microsoft dynamics Ax
- Macros are reusable components
- Macros are mostly used to remove hardcoding and for constant values
- Macros are pre-compiled/FASTER
- In AX, we have a macro processor
- Macros cannot be debugged
- Macros reduces line of code/optimizes the lines of code
- Macros will not end with semicolon
3) Macro library
{
#define.pi(3.142)
#define.name('Tony')
#define.address('SR Nagar, Hyd')
;
info(strfmt('%1',#pi));
info(#name);
info(#name + "is a bad person");
info(#address);
}
>>Go to AOT >> Macros >> Right click on the Macros node >> New Macro >> rename it to TDSAdd 4 functions inside the macros by doubling clicking it
#define.age(30)
#define.inst('Vertex soft')
#define.cl(4000.00)
>>Create a new job as shown below
{
#TDS
;
info(#college);
info(int2str#age));
}
Go to TDS_CustTable >> Methods >> Override initvalue() method and paste the following code
{
#TDS
;
super();
this.Creditlimit = #cl;
this.JoinedDate = systemdateget();
}
Microsoft has already given many macros in AOT >> Macros node
[sys] layer
we can go ahead and add any function to already existing macros [sys layer]
How to call Macro library macro
{
#aotexport //#macrolib.aotexport
;
info(int2str(#marks));
}
{
int c;
#localmacro.sum
c = %1 + %2;
#endmacro
;
#sum(10,20)
info(int2str(C));
#sum(1000,5466)
info(int2str(c));
}
{
int c;
#localmacro.sum
c = %1 + %2;
c = c - 4;
c = c * 4/100;
#endmacro
;
#sum(10,20)
info(int2str(C));
#sum(1000,5466)
info(int2str(c));
}
Hiç yorum yok:
Yorum Gönder