Sum of Amount for the same document no

sankar
Member Posts: 79
Hi Experts,
If same document number exist more than one time, how can i get the sum of Amount. Say in Vendor Ledger entry it consist of same documents may be twice or thrice how can i find the total amounts of the document..
Thanks in advance.
If same document number exist more than one time, how can i get the sum of Amount. Say in Vendor Ledger entry it consist of same documents may be twice or thrice how can i find the total amounts of the document..
Thanks in advance.
Everything is Possible
0
Comments
-
You must loop the entries, calculate the total per entry (with CALCFIELDS) and add them up.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Thanks Kriki,
Can you give some example for it..Everything is Possible0 -
decTotalAmount := 0; recVendorLedgerEntry.RESET; recVendorLedgerEntry.SETCURRENTKEY("Document No."); recVendorLedgerEntry.SETRANGE("Document No.",'Your Document'); IF recVendorLedgerEntry.findset THEN REPEAT recVendorLedgerEntry.CALCFIELDS(Amount); decTotalAmount := decTotalAmount + recVendorLedgerEntry.Amount; UNTIL recVendorLedgerEntry.NEXT = 0; MESSAGE('Total Amount : %1',decTotalAmount);
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Thanks Kriki.
i have tried your code in on after get record of Vendor Ledger Entry, but only one document number is displaying even though lot of documents with same document number is there in table..
can you please tell me why kriki.Everything is Possible0 -
Code looks correct - maybe your just messing up your filters.. Just use a report for testing this. You wouldnt put this code on a form. If you really need it on the form put in a new text box and make the source expression a function on the table, which returns the result.0
-
Hi,
i am trying this in report. Vendor Ledger entry as a dataitem. in that only one record is displaying but if i remove the above code it's giving whole Vendor ledger entries in Report. i have inserted the code in on after get record....
Any help is appreciated...Everything is Possible0 -
decTotalAmount := 0; recVendorLedgerEntry.RESET; recVendorLedgerEntry.SETCURRENTKEY("Document No."); recVendorLedgerEntry.SETRANGE("Document No.","document no."); IF recVendorLedgerEntry.findset THEN REPEAT recVendorLedgerEntry.CALCFIELDS(Amount); decTotalAmount := decTotalAmount + recVendorLedgerEntry.Amount; UNTIL recVendorLedgerEntry.NEXT = 0;
For your report. Use this and make sure your dataitem isnt called recVendorLedgerEntry. In body section of your report just print dectotalamount. Can make recvendorledgerentry a local variable and ditch the reset while your at it.0 -
sankar wrote:Hi Experts,
If same document number exist more than one time, how can i get the sum of Amount. Say in Vendor Ledger entry it consist of same documents may be twice or thrice how can i find the total amounts of the document..
Thanks in advance.
If you sure that the document number is used for only one Vendor??
Why not just use a Document Number Group Total section, and supress the body sections, no code required.
Create a report with the wizard use the key "Document No.","Document Type","Vendor No." group on the 1st level only "Document No." and have totals for the fields you need, then run and have a look at the group totals, delete sections you do not need and set Body to SHOWOUTPUT(FALSE).Analyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com0 -
[solved] Thanks Experts the purpose is solved...Everything is Possible0
-
RecCLE.RESET;
RecCLE.SETRANGE("Document No.","Document No.");
RecCLE.SETRANGE("Global Dimension 2 Code","Vendor Ledger Entry"."Global Dimension 2 Code");
IF Docno <> "Vendor Ledger Entry"."Document No." THEN BEGIN//add this line in your code
IF RecCLE.FINDFIRST THEN BEGIN
REPEAT
RecCLE.CALCFIELDS("Amount (LCY)","Debit Amount","Credit Amount");
TotalBalance +=RecCLE."Amount (LCY)";
CreditBalance1 += RecCLE."Credit Amount";
DebitBalance1 += RecCLE."Debit Amount";
TotalCreditBalance += RecCLE."Credit Amount";
TotalDebitBalance += RecCLE."Debit Amount";
UNTIL RecCLE.NEXT = 0;
Docno := "Vendor Ledger Entry"."Document No.";//add this line in your code
END;
END;
Hope it will help you0 -
PS: NEVER use FINDFIRST - REPEAT - UNTIL!
PS2:Instead of CALCFIELDS in every loop, use SETAUTOCALCFIELDS.
use FINDFIRST or FIND('-') depending on your needs (see https://mibuso.com/howtos/how-to-work-with-record-variables-version-3)Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions