web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Odd Behavior in Report Lines (Wrong Debit & Credit calculation)

(2) ShareShare
ReportReport
Posted on by 458
in below loop  code inside bracket not working as expected(if Amt > 0 then Temp_Dimension_Ledger_Table.Debit := Amt else Temp_Dimension_Ledger_Table.Credit := Abs(Amt);)
I have also attached Output Amount Colum is correct however Debit Credit are not correct.(Yellow Highlighted values are what i am talking about).
Can someone please tell me the reason for this behavior. 
 
 
 
 
Amt := 0;
                                    Qry_GL_Entries.SetFilter(Qry_GL_Entries.Posting_Date, '<%1', From_Date);
                                    Qry_GL_Entries.SetRange(Qry_GL_Entries.Dimension_Code, Dimension_Filter);
                                    Qry_GL_Entries.SetRange(Qry_GL_Entries.Dimension_Value_Code, Dim_Val.Code);
                                    Qry_GL_Entries.SetRange(Qry_GL_Entries.G_L_Account_No_, GL_acc."No.");
                                    if Qry_GL_Entries.Open() then begin
                                        while Qry_GL_Entries.Read() do begin
                                            Amt := Amt + Qry_GL_Entries.Amount;
                                        end;
                                        Qry_GL_Entries.Close();
                                    end;
                                    Temp_Dimension_Ledger_Table.Amount := Amt; // this is working fine
                                    if Amt > 0 then Temp_Dimension_Ledger_Table.Debit := Amt else Temp_Dimension_Ledger_Table.Credit := Abs(Amt); //this line causing me that odd issue.
                                    Temp_Dimension_Ledger_Table.Insert();
                                until GL_acc.Next() = 0;
 
I have the same question (0)
  • Verified answer
    Khushbu Rajvi. Profile Picture
    20,441 Super User 2025 Season 2 on at
    Ensure fields are reset before assigning values
    Temp_Dimension_Ledger_Table.Debit := 0;
    Temp_Dimension_Ledger_Table.Credit := 0;
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    26,428 Super User 2025 Season 2 on at
     
    I think you need to reset the variable "Amt"
    Amt := 0;
    before this line :
    if Qry_GL_Entries.Open() then begin
     
    Best regards,
    Mohamed Amine MAHMOUDI
     
  • Suggested answer
    YUN ZHU Profile Picture
    95,729 Super User 2025 Season 2 on at
    Since you are already using Query, why not sum it directly in Query? In this way, you can directly get Amt.
     
    Thanks
    ZHU
  • One And Only Naveen Profile Picture
    458 on at
    Thank You All,
    Your suggested answer worked.
     
    bat is there any way i can reset all fields that i am trying to insert in a table before entering next line in my loop.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,468

#2
YUN ZHU Profile Picture

YUN ZHU 923 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 607

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans