zoukankan      html  css  js  c++  java
  • AX 2012 CopySO_CreditNote

    static void JobCopySO()
    {
        SalesTable  salesTable = SalesTable::find('SO1-900104');
        SalesLine   salesLine;
        SalesTable  salesTableNew;
        SalesOrderCopyingContract contract = SalesOrderCopyingContract::newIsCreditNote(false);
       
        SalesCopying            salesCopying;
        TmpFrmVirtual           tmpFrmVirtualLines;
        TmpFrmVirtual           tmpFrmVirtualHeader;
       
        void writeTmpFrmVirtual(TmpFrmVirtual _tmpFrmVirtual, TableId _tableId, RecId _recId, Num _id, LineNum _lineNum = 0, TransDate _transDate = systemDateGet(), Qty _qty = 0)
        {
            _tmpFrmVirtual.clear();
            _tmpFrmVirtual.TableNum     = _tableId;
            _tmpFrmVirtual.RecordNo     = _recId;
            _tmpFrmVirtual.Id           = _id;
            _tmpFrmVirtual.LineNum      = _lineNum;
            _tmpFrmVirtual.TransDate    = _transDate;
            _tmpFrmVirtual.Qty          = _qty;

            _tmpFrmVirtual.write();
        }
       
        // Create your new sales header
        salesTableNew.SalesId = NumberSeq::newGetNum(SalesParameters::numRefSalesId()).num();
        salesTableNew.initValue();
        salesTableNew.CustAccount = salesTable.CustAccount;
        salesTableNew.initFromCustTable();
        salesTableNew.insert();
       
        // Build header virtual
        writeTmpFrmVirtual(tmpFrmVirtualHeader, salesTable.TableId, salesTable.RecId, salesTable.SalesId);
       
        while select salesLine
            where salesLine.SalesId == salesTable.SalesId
        {
            writeTmpFrmVirtual(tmpFrmVirtualLines, salesLine.TableId, salesLine.RecId, salesLine.SalesId, salesLine.LineNum, systemDateGet(), salesLine.SalesQty);
        }
       
        contract.parmSalesPurchCopy(SalesPurchCopy::CopyAllHeader);
        contract.parmCallingTableSalesId(salesTableNew.SalesId);
        contract.parmTmpFrmVirtualLines(tmpFrmVirtualLines);
        contract.parmTmpFrmVirtualHeader(tmpFrmVirtualHeader);
        contract.parmQtyFactor(1);
        contract.parmRecalculateAmount(NoYes::No);
        contract.parmReverseSign(NoYes::No);
        contract.parmCopyMarkup(NoYes::No);
        contract.parmCopyPrecisely(NoYes::No);
        contract.parmDeleteLines(NoYes::Yes);   
       
        SalesCopying::copyServer(contract.pack(), false);
          
        info(strFmt("Created %1", salesTableNew.SalesId));
    }

  • 相关阅读:
    Linux下shell
    分享微博@功能jquery代码及全面解析
    使用C#处理WebBrowser控件中的跨域问题
    Sqler 工具
    ASP.NET Web API批处理器
    Microsoft Academic Search
    C#中delegate对象Equals方法简析
    写一个编译器
    使用.NET中的Action及Func泛型委托
    电子政务数据库管理系统及应用软件系统安全分享(一)
  • 原文地址:https://www.cnblogs.com/fogfog/p/6135141.html
Copyright © 2011-2022 走看看