To reviewAX 2009

AX 2009: update the quantity of a purchase order line from code

The AX 2009 calls needed to change PurchQty on a purchase line from X++ so that related quantities and inventory stay consistent.

Written for AX 2009; whether PurchLine::modifyPurchQty and InventMovement::bufferSetRemainQty still exist and behave the same in D365FO is not checked.

First written
Re-read
Versions
AX 2009

Setting PurchQty on a purchase line and calling update() is not enough: the derived quantities and the remaining inventory quantity must follow. In AX 2009 these were the calls to make.

The original note

Use this script to update the purchase quantity of a purchase line:

ttsbegin;
_pLine.PurchQty = q;
PurchLine::modifyPurchQty(_pLine, InventDim::find(_pLine.InventDimId), avoidBox);
InventMovement::bufferSetRemainQty(_pLine);
_pLine.update();
ttscommit;

References

  • No current Microsoft Learn page applies to this AX 2009 code.