以编程方式取消AX中的SalesOrders

时间:2017-12-21 09:21:33

标签: axapta x++ dynamics-ax-2009

我想以编程方式取消AX2009中状态为BackOrder且小于特定日期的所有SalesOrders。

1 个答案:

答案 0 :(得分:2)

我设法通过运行以下作业

来完成此操作
static void SalesOrderUpdate(Args _args)
{
    SalesTable          salesTable;
    SalesLine           salesLine;
    int i;
    ;
    changecompany ('10')
    {
        ttsBegin;    
        while select forUpdate salesTable 
            where salesTable.SalesStatus == SalesStatus::Backorder
            &&    salesTable.ReceiptDateRequested  <= 31\12\2016
            &&    salesTable.ShippingDateRequested <= 31\12\2016
            join forUpdate salesLine
            where salesLine.SalesId == salesTable.SalesId
        {
            i++;    
            salesLine.RemainSalesPhysical = 0;
            salesLine.RemainInventPhysical = 0;
            salesLine.update();    
        }
        ttsCommit;    
    }
    info(int2Str(i));    
}