Delete physical reservation from x++

hi,

I use AX 2009. I would like to delete physical reservation from SalesLine. I use below code but it doesn’t remove transaction. After executed it transaction with physical reservation still exist. Why?

salesLine = SalesLine::find(“ZS/BOK/2013/007553”, 0, true);
movement = InventMovement::construct(salesLine);
upd = InventUpd_Reservation::newMovement(movement, 0, true);
upd.updateNow();

To un reserve

InventUpd_Reservation::updateReserveBuffer(salesLine, salesLine.QtyOrdered);

To reserve

InventUpd_Reservation::updateReserveBuffer(salesLine, -salesLine.QtyOrdered);

Still nothing :confused:

In my opinion yout method do the same thing like my method.

Your method:

inventMovement = InventMovement::constructNoThrow(_buffer,_inventMovSubType);

if (inventMovement)
{
reservation = InventUpd_Reservation::newMovement(inventMovement,_reserveQty,true);
reservation.updateNow();
}

Yes, i used an existing API, InventUpd_Reservation::updateReserveBuffer

It is working in my case.

Hi Jacek,

I also faced the same issue. All i missed is the trans id is not updated in the sales line and unreserve is not happening. just use the below code and check the conditions given below :

inveMovement = InventTrans::findTransId(salesLine.InventTransId).inventMovement(true);

InventUpd_Reservation = InventUpd_Reservation::newInventDim(inveMovement,inventDim,InventSum::find(SalesLine.ItemId,inventDim.inventDimId).PhysicalInvent,true);

inventUpd_Reservation.updatenow();

Here, if it was not still unreserving, just debug and see whether qty is in -ve or +ve . also kindly check that the trans id is matching with the respective sales line with the Invent trans dimid and sales line dim id…

Thanks and Regards,

Kevin

Is it work for Dynamics Ax 2012 R2

what is the code for ax 2012 R2 to unreserved the qty??

what is the code for ax 2012 R2 to unreserved the qty??