X++ to update sales line reserve physical qty

Hi

I have create a button and when user click on the button in sales order i want to update the reserve physical qty == deliver now qty

by default reserve physical qty == sales qty but i want to update the reserve physical qty == deliver now qty

does any on have x++ code on how to update the reserve physical qty base on sales order

Thank you

You can use \Classes\InventUpd_Reservation\updateNow to reserve the physical quantity. Look at the cross reference of that method on how to use it.

thank you i am using below code but its not updating

static void Job16(Args _args)
{
InventTrans inventTrans;
InventTransOrigin inventTransOrigin;
InventMovement inventMovement;
InventUpd_Reservation inventUpd_Reservation ;

// Reserve an item
SalesLine SalesLine = SalesLine::findRecId(5640934326);
select inventTrans
where inventTrans.ItemId == SalesLine.ItemId
&& inventTrans.StatusReceipt == StatusReceipt::None
&& inventTrans.StatusIssue == StatusIssue::OnOrder
exists join inventTransOrigin
where inventTransOrigin.RecId == inventTrans.InventTransOrigin;

if(inventTrans.RecId)

{
Inventmovement = inventTrans.inventmovement(true);
inventUpd_Reservation = InventUpd_Reservation::newInventDim(inventmovement,SalesLine.inventDim(),-120, false);
inventUpd_Reservation.updatenow();
}

info(strFmt("%1",salesLine.reservedPhysicalSalesUnit()));

}

Do you have onhand for that dimensions? Also try using, inventTrans.inventDim()

thank you i am debugging it

If there is no onhand with that dimension and there ordered quantity, then it will put the status of inventory transaction to ReserveOrdered.

info(strFmt("%1",salesLine.reservedPhysicalSalesUnit())); → this will return zero, as there is no physical reserved quantity and you only have ordered reserved.

thank you now my code is working good . below is the code if any one need it

/*
this methos is used for update the reserve Physical qty
take 3 paramater
RecId = this is sales line recid
reservePhysical = this is the qty we get from deliver now
reservedPhysical = this is the qty we get from previously reserved qty
*/

public static void updateReservedPhysical(RecId _recId,Qty reservePhysical,Qty reservedPhysical)
{
InventTrans inventTrans;
InventTransOrigin inventTransOrigin;
InventMovement inventMovement;
InventUpd_Reservation reservation ;
SalesLine salesLine;
Qty qty;

/*
here we check the condetion
and set the qty to add or deduct for physical reserver qty
*/
if (reservePhysical < reservedPhysical)
{
qty = reservedPhysical - reservePhysical;
}
else if(reservePhysical > reservedPhysical)
{
qty = reservedPhysical - reservePhysical;
}

// find the record on sales line base on recid
salesLine = SalesLine::findRecId(_recId);
select inventTransOrigin
where inventTransOrigin.InventTransId == salesLine.InventTransId
join inventTrans
where inventTrans.InventTransOrigin == inventTransOrigin.RecId
&& inventTrans.StatusReceipt == StatusReceipt::None;

//if inventTrans.RecId is not 0 then we continue
if(inventTrans.RecId)
{
inventMovement = inventTrans.inventmovement(true);
// here we set the paramater for InventUpd_Reservation check class InventUpd_Reservation for more info
reservation = InventUpd_Reservation::newInventDim(inventmovement,inventTrans.inventDim(),qty, false);
reservation.updatenow();

}

//info(strFmt("%1",salesLine.reservedPhysicalSalesUnit()));

}

I have a task in d365 . can anyone please share the code in x++ for the same??
I am a beginner and have 0 idea. Please help.

Task: Sales order line reservation

Create a new column in sales order line – “Reserved quantity” and “Backorder quantity” (Non-editable field)

Create a button on sales order line action pane – “Reserve quantity”.

After saving the quantity on sales line, and pressing your button, system should reserve quantity of selected lines, multi select of line should be allowed:

For example,

Item A – 10 quantities (Sales line) [But only 4 is available physical].Then,

Reserve quantity should show 4 quantity and backorder quantity should show (Quantity – Reserved quantity) = 10 – 4 = 6.