Thursday 12 April 2012

Map & MapEnumerator Objects in Ax 2009

Hi friends, Today we are going to see about map and map enumerator . Maps are used to store the data just like temporary tables. It is much quicker than temporary tables. The critical difference is that even though Map resembles a table at first glance, it does not contain data but functions rather as a library of methods intended to be shared by several tables. Maps can be used in different locations , and you need to act on those values. Map Example:: Map M; ; M = new map(type::integer,type::integer); M.insert(custTable.RecId,custTable.custGroup); M.valueSet(); // Retrieving the values from the map M.exist(custTable.RecId); M.lookUp(CustTable.RecId); This is a wonderful way to look up the value because you have the exact key. What if you wanted to transverse or enumrate through a given map to act on each value. This would be similar to moving through a resultset, etc: MapEnumerator ME; ; ME = new MapEnumerator(M); while(ME.moveNext()) { // .. preform some logic .. } With this you can now walk through or enumrate through a given map and act upon each value stored in it. Like I said, Maps are very cool, easy to use, and much faster and preferred than using a temp table. Check back soon for more posting on code examples, how to's, etc. Vivek Chirumamilla

No comments:

Post a Comment