时点现有量JOB
qty availQty(ItemId _PitemId,InventLocationId _InventLocationId,TransDate pointDate)
{
Query _Query;
QueryRun _QueryRun;
InventSum inventsum;
InventDim InventDim;
inventDim inventDimCriteria;
inventdimparm inventDimparmCriteria;
inventDimParm inventDimparmGroupby;
InventSumDatePhysicalDim inventSumDateDim;
Qty availQty ;
;
inventDimCriteria.clear();
inventDimCriteria.InventLocationId = _InventLocationId;
inventDimparmCriteria.clear();
inventDimparmCriteria.ItemIdFlag = Noyes::Yes;
inventDimparmCriteria.InventLocationIdFlag = Noyes::Yes;
inventDimparmGroupby.clear();
inventDimparmGroupby.ItemIdFlag =Noyes::Yes;
inventDimparmGroupby.InventLocationIdFlag =Noyes::Yes;
_Query = new Query();
Inventsum::newQuery(_Query,_PitemId,inventDimCriteria,inventDimparmCriteria,inventDimparmGroupby);
_queryRun = new QueryRun(_query);
while(_queryrun.next())
{
inventsum = _Queryrun.get(tablenum(InventSum));
inventDim = _QueryRun.get(tablenum(InventDim));
inventSumDateDim=InventSumDatePhysicalDim::newParameters(pointDate,
InventSum.ItemId,
inventdim,
inventDimparmCriteria);
availQty = inventSumDateDim.postedQty()+ inventSumDateDim.receivedQty() -
InventSumDateDim.deductedQty() + InventSumDateDim.registeredQty() -InventSumDateDim.pickedQty();
}
return availQty;
}