Monday, July 23, 2012

X++ code to find the Stock of Item by Date

static void findOnHand_ByDate(Args _args)
{
InventDim inventDim;
InventDimParm inventDimParm;
Itemid itemid;
InventOnHand inventOnHand = new InventOnHand();
InventSumDateDim inventSumDateDim;
TransDate transDate;
;
// take a sample item for testing
itemid = "20 MM RMC";
transDate = 13\01\2010;
// take a combination of dimension , against which you want to find the stock
inventDim.InventLocationId = "GW";
//Set the flag for the selected dimensions as active.
inventDimParm.initFromInventDim(inventDim);
//initialize the inventSumDateDim with Date,item,dimension and dim paramter
inventSumDateDim = InventSumDateDim::newParameters(transDate,
itemid,
inventDim,
inventDimParm);
// Retrieve the onhand info
info(strfmt("PostedQty: %1",inventSumDateDim.postedQty()));
info(strfmt("DeductedQty: %1",inventSumDateDim.deductedQty()));
info(strfmt("ReceivedQty: %1",inventSumDateDim.receivedQty()));
}

No comments: