Microsoft Dynamics AX 2012 的 Microsoft Management Reporter 2012 中發生「物件參考未設定為對象的實例」錯誤

本文提供 對象參考未設定 為 Microsoft Dynamics AX 2012 的 Microsoft Management Reporter 2012 中所發生之物件錯誤實例的解析。

適用於: Microsoft Management Reporter 2012、Microsoft Dynamics AX 2012 R3
原始 KB 編號: 2967363

徵狀

您在 Microsoft Management Reporter 2012 for Microsoft Dynamics AX 2012 中 Management Reporter 組態控制台的整合記錄中收到下列錯誤:

[AX 2012 帳戶對帳戶] 發生錯誤。 處理將會中止。 錯誤文字:對象參考未設定為 對象的實例。

此外,下列錯誤也可能出現在 事件檢視器 中:

攔截到的例外狀況:[System.NullReferenceException] 對象參考未設定為 對象的實例。堆疊追蹤:at
Microsoft.Dynamics.Integration.Adapters.AX2012GL.DataAccessHelper.GetEnumLabelId (EnumMetadata enumList, Nullable'1 值)
Microsoft.Dynamics.Integration.Adapters.AX2012GL.DataAccessHelper.GetEnumLabelId (EnumMetadata enumList, Nullable'1 值)
Microsoft.Dynamics.Integration.Adapters.AX2012GL.AX2012GLAdapter.GetEnumValueLabelString (String enumName, Nullable'1 value)
Microsoft.Dynamics.Integration.Adapters.AX2012GL.AccountObjectProvider.PopulateAccountAttributes (SqlDataReader accountReader)
Microsoft.Dynamics.Integration.Adapters.AX2012GL.AccountObjectProvider.CreateAccount (SqlDataReader reader, Dimension mainAccountDimension, Int64 mainAccountRecId) 在 Microsoft.Dynamics.Integration.Adapters.AX2012GL.AccountObjectProvider.QueryAccountValues ()
Microsoft.Dynamics.Integration.Adapters.AX2012GL.AccountObjectProvider.ReadObjectKeys (DateTime modifiedDate)
Microsoft.Dynamics.Integration.Service.Tasks.MapWork.ReadObjectKeyList (DbMap map、 DateTime queryDate、 Int32& count)
Microsoft.Dynamics.Integration.Service.Tasks.MapWork.ProcessRecordsImplementation (OperationType operationType)

原因

之所以會發生此問題,是因為 AX 資料庫的 MainAccount 資料表中存在但不存在於 AOT) (應用程式物件樹狀結構中的 post 類型。

解決方案

若要解決此問題,請遵循下列步驟:

  1. 針對 AX 資料庫執行下列 SQL 語句,以檢查帳戶的張貼類型:

    select distinct (postingtype) from MainAccount
    
  2. 登入 AX 並檢查 AOT。 若要流覽至 AOT,請選取 [數據字典],選取 [ 基底列舉],然後選取 [LedgerPostingType]。 檢查每個項目的屬性,並記下 EnumValues 數據表。

  3. 如果在MainAccount資料表和AOT中的EnumValues資料表之間找到差異,則包含無效張貼類型的帳戶必須設定有效的張貼類型。

    例如,使用下列語句來更新 MainAccount 數據表,其中無效的張貼類型 255 不存在於 AOT 中。 此語句會將張貼類型設定為有效的類型 0。

    update MainAccount set postingtype = 0 where postingtype = 255
    
  4. 當您更新 MainAccount 數據表時,必須重建 Management Reporter Data Mart。 如果要執行這項操作,請依照下列步驟執行:

    1. 取 [開始],開啟伺服器上的組態控制台。
    2. 在左側瀏覽窗格中,選取 [ ERP 整合]
    3. 選取正在使用的整合,然後選取 [停用整合] 來停 用整合
    4. 取 [移除 ] 以移除 ERP 整合。
    5. 選取左側導覽中的 [ 管理報告者服務 ],然後停止兩個管理報告服務。
    6. 在 Microsoft SQL Management Studio 中備份和刪除 DDB 資料庫。
    7. 啟動管理報表服務。
    8. 取 [檔案 ], 然後選取 [設定] 以再次設定 ERP 整合。
    9. 設定整合時,請從組態控制台左側選取整合,然後選取 [ 啟用整合]