≡ Menu




Data manipulation tip 1 In Dynamics ax 2012 and D365 Of Operations Data copy method.

 

Currently I am doing Report development project, I got some tips for Data manipulation , these tips I recently learned.

 

Copy data from one table buffer to other of same type.

 

 

During report development, We usually populate  temp table with result of Query execution. Usually we need copy of same data for aggregate functions.

 

Instead map each field of buffer with each other. We can copy the whole data by using .data method.

 

 

Suppose we have custom temp table CustSaleQtyTmp which we need to copy from one buffer to other.

class DataManipulationJob
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{

CustSaleQtytmp _temp1,_temp2;
_temp1.IntQty=100;
_temp1.CustAccount =”Cust00001″;
_temp1.insert();
_temp1.IntQty=200;
_temp1.CustAccount =”Cust00002″;
_temp1.insert();

_temp1.IntQty=300;
_temp1.CustAccount =”Cust00003″;
_temp1.insert();
while select * from _temp1
{
// Instead copy like this we can use Data method
// _temp1.CustAccount = _temp2.CustAccount;
// _temp1.IntQty = _temp2.IntQty;

_temp2.data(_temp1);
_temp2.insert();

}

while select * from _temp2
{
info( ” _temp2 with ” + _temp2.CustAccount + ” ” + int2Str(_temp2.IntQty));

}
}

}

output like

{ 0 comments… add one }

Leave a Comment