The class inventOnhand is very useful when retrieving inventory information for a specific item.
If we want to get the sum of an item for all warehouses and all configurations:
static void FO_InventOnhand(Args _args)
{
InventOnhand onhand;
;
onhand = InventOnhand::newItemId("0001");
// Physical inventory
print onhand.physicalInvent();
// Physical reserved
print onhand.reservPhysical();
// Total available
print onhand.availOrdered();
// Ordered reserved
print onhand.reservOrdered();
// Available physical
print onhand.availPhysical();
pause;
}
Maybe we want the sum of an item in a certain warehouse, in our case the warehouse “GW”:
static void FO_InventOnhand(Args _args)
{
InventOnhand onhand;
;
onhand = InventOnhand::newItemId("0001");
onhand.parmInventLocationId("GW");
// Physical inventory
print onhand.physicalInvent();
// Physical reserved
print onhand.reservPhysical();
// Total available
print onhand.availOrdered();
// Ordered reserved
print onhand.reservOrdered();
// Available physical
print onhand.availPhysical();
pause;
}
If the item has different configurations, let’s say that item “0001” is a lamp that comes in the different colors red, green and black. But we only want to see the sum of the black(Has the configId “Black”) lamps:
static void FO_InventOnhand(Args _args)
{
InventOnhand onhand;
;
onhand = InventOnhand::newItemId("0001");
onhand.parmInventLocationId("GW");
onhand.parmConfigId("Black");
// Physical inventory
print onhand.physicalInvent();
// Physical reserved
print onhand.reservPhysical();
// Total available
print onhand.availOrdered();
// Ordered reserved
print onhand.reservOrdered();
// Available physical
print onhand.availPhysical();
pause;
}
If we have some SalesLine data we can narrow this calculations even further, this is because in the SalesLine we have access to the InventDimId. With the InventDimId we can get the specific inventory data for this specific salesLine. This can look something like this if the method is created on the salesLine table:
inventDimParm.initDimActive(InventTable::find(this.ItemId)
.DimGroupId);
onHand = InventOnHand::newItemDim(this.ItemId,
inventDim::find(this.InventDimId),
inventDimParm);
The static method newItemDim() does just what we have done before with the parameters methods, but behind the scenes in the InventOnhand class. This is what happens:
static InventOnhand newItemDim(
ItemId _itemId,
InventDim _inventDim,
InventDimParm _inventDimParm
)
{
InventOnhand inventOnhand = new InventOnhand();
;
inventOnhand.parmInventDim(_inventDim);
inventOnhand.parmInventDimParm(_inventDimParm);
inventOnhand.parmItemId(_itemId);
return inventOnhand;
}
No comments:
Post a Comment