Hi Experts,
Does anyone know how to get the reservation of sales line through X++, like inventory location, batch and quantity?
Thanks.
Hi Experts,
Does anyone know how to get the reservation of sales line through X++, like inventory location, batch and quantity?
Thanks.
hi,
this code can work in AX3.0 for your reference.
public static server void Svc_SalesLineReservation(RecId _recId
, InventDimId _dimId
, Qty _qty ,date _date = systemdateget())
{
InventTrans l_invTrans;
SalesLine l_salesLine;
InventMovement l_inventMovement;
InventUpd_Reservation l_inventUpd_Reservation ;
InventDim l_invDim;
SalesLine l_line;
InventSum l_sum;
;
systemdateset(_date);
try
{
l_invDim = InventDim::find(_dimId);
ttsbegin;
l_line = SalesLine::findRecId(_recId,true);
if(!l_line.RecId)
{
throw error(strFmt("Can not find the line recID : %1",_recId));
}
l_sum = InventSum::find(l_line.ItemId,_dimId);
if(l_sum.AvailPhysical < _qty)
{
throw error(strFmt("There is not enough inventory onhand quantity (%8) for delivery (%9). SalesOrder : %1 ; LineNum : %2 ; Warehouse: %3 ; Location: %4 ; Batch: %5 ; Pallet: %6; Serial: %7 ;"
,l_line.SalesId,l_line.LineNum,l_invDim.InventLocationId,l_invDim.wMSLocationId,l_invDim.inventBatchId,l_invDim.wMSPalletId,l_invDim.inventSerialId
,l_sum.AvailPhysical,_qty));
}
l_line.RemainInventPhysical = UnitConvert::qty(l_line.RemainSalesPhysical,
l_line.salesUnit,
l_line.inventTable().inventUnitId(),
l_line.itemId);
if(l_line.RemainInventPhysical < l_line.InventDeliverNow + _qty)
{
l_line.RemainInventPhysical = l_line.InventDeliverNow + _qty;
l_line.RemainSalesPhysical = UnitConvert::qty(l_line.RemainInventPhysical,
l_line.inventTable().inventUnitId(),
l_line.salesUnit,
l_line.itemId);
}
l_line.InventDeliverNow = l_line.InventDeliverNow + _qty;
l_line.SalesDeliverNow = UnitConvert::qty(l_line.InventDeliverNow,
l_line.inventTable().inventUnitId(),
l_line.salesUnit,
l_line.itemId);
l_line.update();
ttscommit;
l_inventMovement = InventMovement::construct(l_line);
l_inventUpd_Reservation =
InventUpd_Reservation::newInventDim(
l_inventMovement
,l_invDim
,_qty * -1
);
l_inventUpd_Reservation.updatenow();
}
catch (Exception::Deadlock)
{
retry;
}
}
Hi Bernardqin,
This is not something we have to use daily. So I can't help you directly. You can have a look at the reservation form what logic is used to show the reservations. So, with some reverse engineering, you should be able to find out what x++ logic needs to be used to achieve your requirement.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156