
I have reserved items of the sales order through x++.
Suppose the ordered quantities are 10 and 10 quantities got reserved.
But now if I edit the sales order quantity from 10 to 8, then how can I update the reserved quantities? As 2 quantities should be unreserved and total reserved should be changed from 10 to 8.
How can I achieve this through X++?
You can give this a try, some of the parameters are optional so you can tailor it to your requirements.
Find reference on InventUpd_Reservation class to see more examples
// Reserve quantity
Qty reserveQty = 2
// Inventory dimensions for 'On order' transactions
InventDim inventDimFrom = InventDim::find(saleLine.InventDimId);
// Create movement for the reservation
InventMovement movement = InventMovement::construct(saleLine);
// Match on all fields
InventDimParm inventDimParm;
inventDimParm.initFromInventDim(movement.inventdim());
// Create reservation class
InventUpd_Reservation reservation = InventUpd_Reservation::newParameters(movement,
inventDimFrom,
inventDimParm,
InventDimFixedClass::inventDimParm2InventDimFixed(inventDimParm),
-reserveQty,
false);
// Set inventory dimension criteria to reserve against at the input location
reservation.parmInventDimOnHandSelectionCriteria(inventDimTo);
reservation.updateNow();