Thursday, 2 July 2015

cancel sales order code with updating the inventory qty for the item in ax 2012

public static void closeSalesOrders(Guid _transId)
{
    #AviFiles
    SysOperationProgress        progress  = new SysOperationProgress();
   
    SalesTable                      salesTable;
    SalesLine                       salesLine;
    ;

    progress.setCaption("Sales order closing ....");
    progress.setAnimation(#AviSearch);
    try
    {
        ttsbegin;
     
            while select firstonly forupdate salesTable
                where salesTable.SalesId            == salesOrderClosing.SalesId
            {
                while select forupdate salesline
                    where salesLine.SalesId         == salesTable.SalesId
                    && salesLine.SalesStatus        == salesStatus::Backorder
                {
                    salesLine.RemainInventPhysical  = 0;
                    salesLine.RemainSalesPhysical   = 0;
                    salesLine.Complete              = noYes::Yes;
                    salesLine.Blocked               = noYes::Yes;
                    salesLine.update();
                    progress.setText('Processing item ' + salesLine.ItemId + ' with sales id ' + salesLine.SalesId + '.');
                }
             
                    }
               

        ttscommit;

    }
    catch(Exception::Error)
    {
        ttsabort;
    }
}

No comments:

Post a Comment

intercompany PO multiple product receipt by x++

public void processStampICPO(PackingSlipId _deliveryNote,                             Transdate _deliverydate,                             ...