Guys, sometime it’s required to do a counting of inventory and in some case if you want to do it technically, I've created a static method which will be helpful to create a counting history and related voucher posting (Inventory count).
Front end navigation: Inventory On-Hand >> Quantity adjustment
Code:
publicstaticvoid adjustInventoryCount( ItemId _item, InventLocationId _inventLocation, WMSLocationId _wmsLocation, Qty _qtyCounted ) { WMSOnlineCountingServer wmsOnlineCountingServer; TmpWMSOnlineCounting tmpWMSOnlineCounting; void initOnHandItem( ItemId _itemId, InventLocationId _inventLocationId, WMSLocationId _wmsLocationId, Qty _counted ) { InventSum inventSum; InventDim inventDim; if (!_itemId) { return; } whileselect ItemId, PhysicalInvent, PdsCWPhysicalInvent, InventDimId from inventSum where inventSum.ItemId == _itemId && inventSum.ClosedQty == NoYes::No && inventSum.PhysicalInvent != 0 existsjoin InventDimId, InventLocationId, wmsLocationId from inventDim where inventDim.InventDimId == inventSum.InventDimId && (!_inventLocationId || inventDim.InventLocationId == _inventLocationId) && (!_wmsLocationId || inventDim.wmsLocationId == _wmsLocationId) { tmpWMSOnlineCounting.ItemId = inventSum.ItemId; tmpWMSOnlineCounting.InventDimId = inventSum.InventDimId; tmpWMSOnlineCounting.QtyOnHand = inventSum.PhysicalInvent; tmpWMSOnlineCounting.QtyCounted = _counted; tmpWMSOnlineCounting.PdsCWQtyOnHand = inventSum.PdsCWPhysicalInvent; tmpWMSOnlineCounting.PdsCWQtyCounted = _counted; tmpWMSOnlineCounting.insert(); wmsOnlineCountingServer.parmSBStmpWMSOnlineCounting(tmpWMSOnlineCounting); } } wmsOnlineCountingServer = WMSOnlineCountingServer::construct(); initOnHandItem(_item, _inventLocation, _wmsLocation, _qtyCounted); wmsOnlineCountingServer.run(); } |