2017-04-12 63 views
-1

我是X ++開發新手。我正在嘗試在供應商老化報告中添加一個字段。這是作爲例外。如何在運行時更新臨時表數據AX 2012

我的問題是在運行時更新字段值。

情景, 我們有一個發票字段包含「AA_BBBBBB」。我需要做的是我需要將值分爲AA,BBBBBB和更新BBBBBB發票字段和AA到新字段(發票類型)。

問題, 一旦我得到的值不是Temptable VendAgingReportTmp的方法VendAgingReportDP \ insertVendAgingReportTmp,我嘗試更新上面的場景,但code is not selecting the records from VendAgingReportTmp。有人可以幫助我完成這件事。

+1

你可以發佈你的工作是不工作的代碼? –

+0

另外看看如何創建[mcve]。 –

回答

0

我由下面添加了一個解決方案,

  • 新增InvoiceType場to temptable VendTmpAccountSum因爲這被聲明爲全局變量。
  • 將我們的自定義發票類型更新爲InvoiceType字段VendTmpAccountSum
  • 然後,整個數據從VendTmpAccountSum表通過使用insert_recordset以增加性能插入到VendAgingReportTmp

感謝,

1

VendAgingReportDPinsertVendAgingReportTmp的標準代碼的最後一行是vendAgingReportTmp.insert();

如果你的代碼是vendAgingReportTmp.insert();之前,您不需要進行更新。如果您在vendAgingReportTmp.insert();之前放入vendAgingReportTmp.update();,則會出現該錯誤。

把你的代碼中//YourCode//YourCode END withhout vendAgingReportTmp.update();

例子:

/// <summary> 
/// Inserts records into the temporary <c>VendAgingReportTmp</c> table. 
/// </summary> 
/// <param name="_reverseAmountsAndHeadings"> 
/// A boolean value which indicates whether the column values should be  reversed. 
/// </param> 
private void insertVendAgingReportTmp(boolean _reverseAmountsAndHeadings) 
{ 
    vendAgingReportTmp.AsOfDate = strFmt("@SYS84682",  date2StrUsr(contract.parmZeroDate(), DateFlags::FormatAll),  contract.parmDateTransactionDuedate()); 
    vendAgingReportTmp.HeadingAccount = strFmt("@SYS24500"); 
    vendAgingReportTmp.HeadingName = strFmt("@SYS7399"); 

    switch (contract.parmDateTransactionDuedate()) 
    { 
     case DateTransactionDuedate::DocumentDate : vendAgingReportTmp.HeadingDate = "@SYS2587"; 
               break; 
     case DateTransactionDuedate::TransactionDate : vendAgingReportTmp.HeadingDate = "@SYS67"; 
               break; 
     case DateTransactionDuedate::DueDate : vendAgingReportTmp.HeadingDate =  "@SYS14588"; 
                break; 
     default : vendAgingReportTmp.HeadingDate = "@SYS14588"; 
                break; 
    } 

    if (_reverseAmountsAndHeadings) 
    { 
     this.setVendAgingReportTmpInReverse(); 
    } 
    else 
    { 
     this.setVendAgingReportTmp(); 
    } 

    vendAgingReportTmp.TransDate = tmpAccountSum.TransDate; 
    vendAgingReportTmp.InvoiceId = tmpAccountSum.InvoiceId; 
    vendAgingReportTmp.Voucher = tmpAccountSum.Voucher; 
    vendAgingReportTmp.AccountNum = tmpAccountSum.AccountNum; 
    vendAgingReportTmp.Name = vendTable.name(); 
    vendAgingReportTmp.VendAccount = tmpAccountSum.AccountNum; 
    vendAgingReportTmp.Txt = tmpAccountSum.Txt; 
    vendAgingReportTmp.Balance = 100; 
    vendAgingReportTmp.CurrencyCode = tmpAccountSum.CurrencyCode; 
    vendAgingReportTmp.VendGroup = vendTable.VendGroup; 

    //YourCode 
    //... 
    //... 
    //... 
    //YourCode END 

    vendAgingReportTmp.insert(); 
} 
+0

其實我們正在使用insert_recordset –

+1

@SankarR:請將這些信息加入您的問題中,以增加您回答的機會。 –

+0

@SankarR請加上你的代碼,給你一個正確的答案。 –