Wednesday, December 9, 2015

Dynamics NAV 2013 R2 - How to resolve CONSISTENCY error

  • Import this codeunit (save as text and import and compile)
---------------------------------------------------------------------------------------------


OBJECT Codeunit 50089 Single Instance CU-GL Consist
{
  OBJECT-PROPERTIES
  {
    Date=10/29/15;
    Time=[ 1:15:17 PM];
    Modified=Yes;
    Version List=MOD01;
  }
  PROPERTIES
  {
    Permissions=TableData 17=rimd;
    SingleInstance=Yes;
    OnRun=BEGIN
            IF NOT StoreToTemp THEN BEGIN
              StoreToTemp := TRUE;
            END ELSE
              PAGE.RUN(0,TempGLEntry);
          END;
  }
  CODE
  {
    VAR
      TempGLEntry@1000000000 : TEMPORARY Record 17;
      StoreToTemp@1000000001 : Boolean;
    PROCEDURE InsertGL@1000000000(GLEntry@1000000000 : Record 17);
    BEGIN
      IF StoreToTemp THEN BEGIN
        TempGLEntry := GLEntry;
        IF NOT TempGLEntry.INSERT THEN BEGIN
           TempGLEntry.DELETEALL;
           TempGLEntry.INSERT;
       END;
      END;
    END;
    BEGIN
    {
      Used for debugging GL Consistency errors.
      See CU 12
      Steps:
      1. Run CU and it will start in memory
      2. Run any posting that generates a consistency error
      3. Run CU again and the GL that would have posted will be shown
    }
    END.
  }
}


----------------------------------------------------------------------------------------------
  • Modify C12 - FinishPosting
    • Look for these lines 
    • Insert the code between //MOD

    • GlobalGLEntry.INSERT;
      //MOD
      SingleCU.InsertGL(GlobalGLEntry);
      //MOD
        UNTIL TempGLEntryBuf.NEXT = 0;
       
  • Add Global Variable SingleCU = Codeunit, Single Instance CU-GL Consist
  • Run CU and it will start in memory
  • Run any posting that generates a consistency error
  • Run CU again and the GL that would have posted will be shown
  • Copy and paste the results to Excel
  • Sort by account
  • Subtotal by account
  • Manually Sum totals for all Sales
  • Manually Sum totals for all Receipts
  • Compare the totals and work through the figures to find where the numbers do not match
  • General problem areas
    • Rounding causes minor differences and no rounding account is setup, so rounding differences are lost, causing inconsistencies
    • VAT causes rounding and above problem
    • Discounts cause rounding and above problem
    • Currency Exchange rates cause the above problem
    • Records are missing from the Sales_Trans_Entry table if dealing with statements
    • Total Payments do not match Total receipts
  • To resolve the issue
    • Determine the root cause of the differences to prevent future errors
    • Cancel, reverse, void or redo the transaction if possible
    • LAST RESORT: You may need to modify the Sales_Trans_Entry table record values to force a match to allow the current transaction to post if dealing with statements

No comments:

Post a Comment