Hi Experts,
on WMSPickingRegistration form to set Resolve Lot Easly for my company user as Donky work and Wasted a lot of time,
As we all know Resolve lot for Selected Line in D365 as be as shown in the attached pictures as well,
01
02
03
So that I want to add Customize on the above form WMSPickingRegistration on No. 5 in the above image also to Resolve Lot for all Lines to consume Donky work and Wasted a lot of time.
So I Implemented the Attached Code Class to involve that but I have iusse and I don't understand where?
Some links to help:
community.dynamics.com/.../reserve-salesline-throughcode
www.schweda.net/blog_ax.php
sangeethwiki.blogspot.com/.../reserve-and-unreserve-sales-order-line.html
www.instructorbrandon.com/.../
www.dynamicsuser.net/.../7
community.dynamics.com/.../x-to-update-sales-line-reserve-physical-qty
gfeaxblog.wordpress.com/.../
eurom.be/.../storage-dimension-group-in-d365.html
axfactory.wordpress.com/.../
https://timsaxblog.wordpress.com/2015/08/31/the-reserved-ordered-items-inventory-parameter/
Code:
public class GOWMSPickingRegistrationReserveLot
{
WMSOrderTrans _WMSOrderTrans , _WMSOrderTransInsert;
InventMovement _InventMovement;
InventUpd_Reservation _InventUpd_Reservation;
InventSum _InventSum;
InventBatch inventBatch;
InventDim inventDim;
Qty totalReservedQty,mainQty ,availableQty, RemainQty;
public void ReserveLotLine(RecId _wmsOrderTransRecId)
{
select forUpdate _WMSOrderTrans
where _WMSOrderTrans.RecId == _wmsOrderTransRecId;
//select _InventSum
//where _InventSum.InventDimId == _WMSOrderTrans.inventDimId &&
// _InventSum.ItemId == _WMSOrderTrans.itemId
select _InventSum
where _InventSum.ItemId == _WMSOrderTrans.itemId &&//'F000442' &&
_InventSum.AvailPhysical != 0
join inventBatch
order by inventBatch.expDate desc
where inventBatch.inventBatchId == _InventSum.inventBatchId
join inventDim
where inventDim.inventDimId == _InventSum.inventDimId;
availableQty = _InventSum.AvailPhysical;// physicalInventCalculated(); //345+48 = 393
//confirm -QTYs
if (availableQty >= _WMSOrderTrans.qty)
{
this.UpdateLineNow(_WMSOrderTrans);
}
else
{
mainQty = _WMSOrderTrans.qty; // 102
RemainQty = availableQty - mainQty; //393 - 102 = 291
select _InventSum
where _InventSum.PostedQty + _InventSum.Received - _InventSum.Deducted + _InventSum.Registered - _InventSum.Picked >= RemainQty
&& _InventSum.ItemId == _WMSOrderTrans.itemId;
//Order by InventBatch Expired date && Big on-Hand
if(_InventSum)
{
ttsBegin;
_WMSOrderTrans.qty = availableQty;
_WMSOrderTrans.update();
ttsCommit;
this.UpdateLineNow(_WMSOrderTrans);
//insert New Row///
_WMSOrderTransInsert.data(_WMSOrderTrans);
_WMSOrderTransInsert.inventDimId = _InventSum.InventDimId;
_WMSOrderTransInsert.qty = RemainQty;
_WMSOrderTransInsert.IsReserved = NoYes::Yes;
_WMSOrderTransInsert.expeditionStatus = WMSExpeditionStatus::Complete;
_WMSOrderTransInsert.insert();
this.UpdateLineNow(_WMSOrderTransInsert);
}
else
{
//info("there is no onhand for all Qty")
ttsBegin;
_WMSOrderTrans.qty = availableQty;
_WMSOrderTrans.update();
ttsCommit;
this.UpdateLineNow(_WMSOrderTrans);
totalReservedQty += availableQty;
if(mainQty > totalReservedQty)
this.UpdateLineRecursiveNow(mainQty-totalReservedQty);
}
}
}
//////////////////////////////////////////////////////
private void UpdateLineNow(WMSOrderTrans currWMSOrderLine)
{
if(_WMSOrderTrans)
{
_InventMovement = _WMSOrderTrans.inventMovement(true);
_InventUpd_Reservation = InventUpd_Reservation::newInventDim(_InventMovement,currWMSOrderLine.inventDim(),currWMSOrderLine.qty * -1,false);
_InventUpd_Reservation.updateNow();
}
}
//////////////////////////////////////////////////////
private void UpdateLineRecursiveNow(Qty _RQty)
{
select _InventSum
where _InventSum.PostedQty + _InventSum.Received - _InventSum.Deducted + _InventSum.Registered - _InventSum.Picked >= 0
&& _InventSum.ItemId == _WMSOrderTrans.itemId;
//Order by InventBatch Expired date && Big on-Hand
if(_RQty < _InventSum.physicalInventCalculated())
{
_WMSOrderTransInsert.data(_WMSOrderTrans);
_WMSOrderTransInsert.inventDimId = _InventSum.InventDimId;
_WMSOrderTransInsert.qty = _RQty;
_WMSOrderTransInsert.IsReserved = NoYes::Yes;
_WMSOrderTransInsert.insert();
this.UpdateLineNow(_WMSOrderTransInsert);
totalReservedQty += availableQty;
}
else
{
_WMSOrderTransInsert.data(_WMSOrderTrans);
_WMSOrderTransInsert.inventDimId = _InventSum.InventDimId;
_WMSOrderTransInsert.qty = _InventSum.physicalInventCalculated();
_WMSOrderTransInsert.IsReserved = NoYes::Yes;
_WMSOrderTransInsert.insert();
this.UpdateLineNow(_WMSOrderTransInsert);
totalReservedQty += _InventSum.physicalInventCalculated();
if(mainQty > totalReservedQty)
this.UpdateLineRecursiveNow(mainQty-totalReservedQty);
}
}
//////////////////////////////////////////////////////
}
H.R
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... 290,902 Super User 2024 Season 2
Martin Dráb 229,297 Most Valuable Professional
nmaenpaa 101,156