Friday, October 21, 2016

How to create AOT Map

Map can be created from AOT > Data Dictionary > Maps.

Using Map, we can access a single field from different tables with referencing single map field. So we can simplify the code.
Example, fields named PurchId in PurchTable and SalesId in SalesTable can be accessed by the name SalesPurchId.

For Map methods, we can override tables / xRecord methods, or add our own. To access the methods that only occurs in the Map (not in the table) we have to include the segment "varMap.JJK_Map::" because of the uniqueness of the method name.

public static str dTestMap()
{
//jjk_map is a map for purchTable and salesTable
JJK_Map map;
PurchTable purchTable;
SalesTable salesTable;
;
//mapMethod only exist in JJK_Map
map.mapMethod(); //no error will be thrown if no table buffer had been assigned to the map.
purchTable = PurchTable::find("PO0001");
map = purchTable;
map.mapMethod(); //error will be thrown because the buffer had been assigned to the map.
map.JJK_Map::mapMethod(); //we need to call the method with the segment
}

No comments:

Post a Comment