Hello Martin,
Firstly I send you here because it is not possible to add a post on the community site!
Secondly, Can you help in my iusse
on WMSPickingRegistration form to set Reslove Lot Easly for my company user as Donky work and Wasted a lot of time,
As we all know Reslove lot for Selected Line in D365 as be as shown in the attached pictures as well,
01
02
03
So that Iwant to add Customize on above form WMSPickingRegistration on No. 5 in above image also to Reslove Lot for all Lines to consume Donky work and Wasted a lot of time.
So that I Emplement Attched Code Class to invole that but ihave iusse and Idont 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/
My tried 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);
}
}
//////////////////////////////////////////////////////
}
Can Help me Please;
H.R
