Note that this can become a more complex problem IF your team happens to create more than one shipping line, or more than one packslip for a specific order on a specific day… in other words… if you have an order for 10 pieces… and you create two packslips, you can ship 8 on one packslip, and 8 more on another packslip… both packslips are “valid” because they are under the order quantity, but you still are overshipping them.
To do this “properly” you need to look at both the current packslip, AND any other open/unshipped packslips.
The BO CustShip.GetQtyInfo includes a field for the qty already shipped. So doing the check in there should work, even if multiple packers or multiple lines on a single packer are employed.
Below which I have created in E9 on CustShip.UpdateMaster Pre-Processing when ReadyToInvoice is checked.
define var lShippedQty like ShipDtl.OurInventoryShipQty no-undo.
for each ttShipHead where ttShipHead.Company = cur-comp and (ttShipHead.RowMod = “A” or ttShipHead.RowMod = “U”) and ttShipHead.ReadyToInvoice = true :
for each ShipDtl no-lock where ShipDtl.Company = ttShipHead.Company and ShipDtl.PackNum = ttShipHead.PackNum :
lShippedQty = 0 .
for each BuffShipDtl no-lock where BuffShipDtl.Company = ShipDtl.Company and BuffShipDtl.OrderNum = ShipDtl.OrderNum and
BuffShipDtl.OrderLine = ShipDtl.OrderLine and BuffShipDtl.OrderRelNum = ShipDtl.OrderRelNum and
BuffShipDtl.PackNum = ShipDtl.PackNum and BuffShipDtl.PackLine <> ShipDtl.PackLine :
lShippedQty = lShippedQty + (BuffShipDtl.OurInventoryShipQty + BuffShipDtl.OurJobShipQty ) .
end.
lShippedQty = lShippedQty + (ShipDtl.OurInventoryShipQty + ShipDtl.OurJobShipQty ) .
find first OrderRel where OrderRel.Company = ShipDtl.Company and OrderRel.OrderNum = ShipDtl.OrderNum and
OrderRel.OrderLine = ShipDtl.OrderLine and OrderRel.OrderRelNum = ShipDtl.OrderRelNum no-lock no-error.
if avail OrderRel then
do:
lShippedQty = lShippedQty + OrderRel.OurJobShippedQty + OrderRel.OurStockShippedQty.
if lShippedQty > OrderRel.OurReqQty then
do:
lQtyMessage = "Total shipped qty " + string(lShippedQty) + " is more than the order qty " + string(OrderRel.OurReqQty) +
" for pack line " + string(ShipDtl.PackLine) + " related to Order/Line/Rel Num : " + string(ShipDtl.OrderNum) + “/” +
string(ShipDtl.OrderLine) + “/” + string(ShipDtl.OrderRelNum) + ". Please check the shipped qty. ".
{lib/PublishEx.i &ExMsg = lQtyMessage }
end.
end.
end.