web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Under review by Community Managers

Under review

Thank you for your post! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

How to resolve Lot Line on PickingRegistration in D365 X++

Posted on by 321

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

Image

02

Image

03

Image

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

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
Basit Profile Picture

Basit 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans