最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

DAX 2012 Remove reservations and markings from a sales order

网络文摘 William 5724浏览 0评论

Some friends of me have asked how to remove reservations and markings on a sales order. Going through line by line can be time consuming and they wanted to know how this could be solved by a single “click”.

 

static void Tutorial_UnreserveSalesTable(Args _args)
{
    InventTrans             inventTrans;
    InventTransOrigin       inventTransOrigin;
    SalesLine               salesLine;
    InventMovement          inventMovement;
    InventUpd_Reservation   inventUpd_Reservation ;
    SalesId                 SalesId = "001260";//<--- Send/get sales id here

    // Remove reservations and markings on a reserved salesorder
    while select inventTrans
        where inventTrans.StatusReceipt                == StatusReceipt::None
           && (inventTrans.StatusIssue                 == StatusIssue::ReservPhysical 
           ||  inventTrans.StatusIssue                 == StatusIssue::ReservOrdered)
        exists join inventTransOrigin 
            where   inventTransOrigin.RecId            == inventTrans.InventTransOrigin
        exists join salesLine 
            where   salesLine.InventTransId            == inventTransOrigin.InventTransId                    
                &&  SalesLine.SalesId                  == SalesId    
    {
            if (inventTrans.MarkingRefInventTransOrigin)
            {
                InventTransOrigin::deleteMarking(inventTrans.MarkingRefInventTransOrigin, inventTrans.InventTransOrigin, -inventTrans.Qty, true);
                InventTransOrigin::deleteMarking(inventTrans.InventTransOrigin, inventTrans.MarkingRefInventTransOrigin, inventTrans.Qty, true);
            }

            if (inventTrans.StatusIssue == StatusIssue::ReservPhysical || inventTrans.StatusIssue == StatusIssue::ReservOrdered)
            {                
                Inventmovement = inventTrans.inventmovement(true); 
                inventUpd_Reservation = InventUpd_Reservation::newInventDim(inventmovement,inventTrans.inventDim(), -1 * inventTrans.Qty, false); 
                inventUpd_Reservation.updatenow(); 
            }
    }
}

The next step would be to create a class, so that it can be performed in CIL, and some code that refreshes the sales order for the end-user.


发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址