How to calculate On Hand Stock of an item given the InventLocationId that shown on the on hand form D365O (AX7)
Hi,
OR
InventIAvailability inventAvailability = InventAvailabilityProvider::findBySumDim(_inventSum, _inventDim).parmInventAvailability();
inventOnhandTmp.ItemId = _inventSum.ItemId;
inventOnhandTmp.Deducted = _inventSum.Deducted;
inventOnhandTmp.Ordered = _inventSum.Ordered;
inventOnhandTmp.PostedQty = _inventSum.PostedQty;
inventOnhandTmp.Received = _inventSum.Received;
inventOnhandTmp.AvailOrdered = inventAvailability.availTotal();
inventOnhandTmp.AvailPhysical = inventAvailability.availPhysical();
inventOnhandTmp.ReservOrdered = inventAvailability.reservOrdered();
inventOnhandTmp.ReservPhysical = inventAvailability.reservPhysical();
if(inventSum.isItemWHSEnabled())
{
WHSInventReserveQty ret = null;
InventDimParm inventDimParm;
InventDim inventDimCriteria=inventDim::find(inventDim.inventDimId);
inventDimCriteria.data(inventSum.relatedTable(tableStr(InventDim)));
inventTable = InventTable::find(inventSum.ItemId);
inventDimCriteria = InventDim::findOrCreate(inventDimCriteria);
inventDimParm.initFromInventDim(inventDimCriteria);
ret = WHSInventReserveQty::newFromParms(
inventTable,
inventDimCriteria,
inventDimParm,
inventSum);
inventOnhandTmp.availPhysical=ret.availPhysical();
inventOnhandTmp.reservPhysical=ret.reservPhysical ();
}
else
{
inventOnhandTmp.availPhysical=inventSum.AvailPhysical ;
inventOnhandTmp.reservPhysical=inventSum.ReservPhysical ;
}
How to calculate On Hand Stock of an item given the InventLocationId that shown on the on hand form D365O (AX7)
InventDimParm invDimParm; InventDim invDim; Qty availPhys; ; invDim.InventLocationId = 'INVENTLOCATIONID'; invDim = InventDim::findOrCreate(invDim); invDimParm.initFromInventDim(InventDim::find(invDim.inventDimId)); availPhys = InventSum::findSum("ITEMID",invDim,invDimParm).availPhysical(); info(strfmt("availPhys:%1 ",availPhys));
OR
InventDim inventDim;
InventDimParm inventDimParm;
InventOnhand inventOnhand;
;
inventDim.InventLocationId = 'Yourwarehouse';
inventDimParm.initFromInventDim(inventDim);
inventOnhand = InventOnhand::newParameters('Youritem', inventDim, inventDimParm);
info(strfmt("Available Physical: %1", inventOnhand.availPhysical()));
OR
inventOnhandTmp.ItemId = _inventSum.ItemId;
inventOnhandTmp.Deducted = _inventSum.Deducted;
inventOnhandTmp.Ordered = _inventSum.Ordered;
inventOnhandTmp.PostedQty = _inventSum.PostedQty;
inventOnhandTmp.Received = _inventSum.Received;
inventOnhandTmp.AvailOrdered = inventAvailability.availTotal();
inventOnhandTmp.AvailPhysical = inventAvailability.availPhysical();
inventOnhandTmp.ReservOrdered = inventAvailability.reservOrdered();
inventOnhandTmp.ReservPhysical = inventAvailability.reservPhysical();
OR
For WHS Enabled Items (Warehouse Enabled Items) On Hand Stock
{
WHSInventReserveQty ret = null;
InventDimParm inventDimParm;
InventDim inventDimCriteria=inventDim::find(inventDim.inventDimId);
inventDimCriteria.data(inventSum.relatedTable(tableStr(InventDim)));
inventTable = InventTable::find(inventSum.ItemId);
inventDimCriteria = InventDim::findOrCreate(inventDimCriteria);
inventDimParm.initFromInventDim(inventDimCriteria);
ret = WHSInventReserveQty::newFromParms(
inventTable,
inventDimCriteria,
inventDimParm,
inventSum);
inventOnhandTmp.availPhysical=ret.availPhysical();
inventOnhandTmp.reservPhysical=ret.reservPhysical ();
}
else
{
inventOnhandTmp.availPhysical=inventSum.AvailPhysical ;
inventOnhandTmp.reservPhysical=inventSum.ReservPhysical ;
}
Comments
Post a Comment