Progressive SUM Flowfield

Alx
Member Posts: 38
Hi everyone,
What I want is a column on e.g. Cust. Ledger Entries that will display the progressive SUM of Amount for a specific Customer, up to that Entry No.
I tried to do it but couldn't implement the "Up to Entry No.", so I wrote the following code to display those totals on a customer Invoice report:
It works allright but I need 2 loops over Cust.LedgEntry, Which could become very slow. In addition, the results are limited to within the report. Is there ANY way to implement the loopy part of my code using a flowfield?
Thanks in advance,
Alx
What I want is a column on e.g. Cust. Ledger Entries that will display the progressive SUM of Amount for a specific Customer, up to that Entry No.
I tried to do it but couldn't implement the "Up to Entry No.", so I wrote the following code to display those totals on a customer Invoice report:
CustLedgEntry.SETRANGE("Customer No.", "Sales Invoice Header"."Sell-to Customer No."); CustLedgEntry.SETRANGE("Document No.", "Sales Invoice Header"."No."); IF CustLedgEntry.FIND('+') THEN BEGIN LastEntryNo := CustLedgEntry."Entry No."; CustLedgEntry.RESET; CustLedgEntry.SETRANGE("Customer No.", "Sales Invoice Header"."Sell-to Customer No."); CustLedgEntry.SETFILTER("Document No.", '<> %1', "Sales Invoice Header"."No."); CustLedgEntry.SETFILTER("Entry No.", '< %1', LastEntryNo); IF CustLedgEntry.FIND('+') THEN PrevEntryNo := CustLedgEntry."Entry No."; END; CustLedgEntry.RESET; CustLedgEntry.SETRANGE("Customer No.", "Sales Invoice Header"."Sell-to Customer No."); IF CustLedgEntry.GET(LastEntryNo) THEN REPEAT CustLedgEntry.CALCFIELDS(Amount); NewBalanceAmount := NewBalanceAmount + CustLedgEntry.Amount; UNTIL CustLedgEntry.NEXT(-1) = 0; IF CustLedgEntry.GET(PrevEntryNo) THEN REPEAT CustLedgEntry.CALCFIELDS(Amount); OldBalanceAmount := OldBalanceAmount + CustLedgEntry.Amount; UNTIL CustLedgEntry.NEXT(-1) = 0;
It works allright but I need 2 loops over Cust.LedgEntry, Which could become very slow. In addition, the results are limited to within the report. Is there ANY way to implement the loopy part of my code using a flowfield?
Thanks in advance,
Alx
0
Comments
-
I think you should use cust. detail ledger entry. Once you find your entries, set the filters and do a calcsum. You will need to do create a key and sumindex the amount field.0
-
I tried to create a FlowField on Cust. Ledger Entry as the SUM of DetCustLedgEntry.Amount, with a Table Filter of :
Entry Type=FILTER(Initial Entry|Unrealized Loss|Unrealized Gain|Realized Loss|Realized Gain|Payment Discount|'Payment Discount (VAT Excl.)'|'Payment Discount (VAT Adjustment)'|Payment Tolerance|Payment Discount Tolerance|'Payment Tolerance (VAT Excl.)'|'Payment Tolerance (VAT Adjustment)'|'Payment Discount Tolerance (VAT Excl.)'|'Payment Discount Tolerance (VAT Adjustment)'),
Customer No.=FIELD(Customer No.),
Posting Date=FIELD(Date Filter)
But the result I get is the same on all Customer Ledger Entries, and is probably equal to the SUM of Amount. What I want is a FlowField that displays the SUM of Amount up to the Date of the current Ledger Entry or, more correctly, up to the current Cust. Ledger Entry... :x0 -
you need to create a flowfilter on cust. ledger entry. Called "Entry No. Flowfilter" and in your flowfield set cust. ledger entry no. = Field(Entry No. Flowfilter);0
-
Thanks a lot!!!!
It took me a while but it works, and now I understand FlowFields and FlowFilters better!
Merry Christmas0
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