Vendor Ledger entries in last 2 years?

nverma
Member Posts: 396
I have to create a report, that should print a list of all the vendors that do not have any vendor ledger entries in the last two years. Any suggestions How I can do this.
So far, I have a two dataitems: Vendors and Vendor Ledger entries (indented under it).
I am just not sure how to check if a vendor has any ledger entries in the last two years.
So far, I have a two dataitems: Vendors and Vendor Ledger entries (indented under it).
I am just not sure how to check if a vendor has any ledger entries in the last two years.
0
Answers
-
-
Right now its showing me all vendor ledger entries that have a posting date between today and two years ago...
How can I make it show the vendor information if there were no vendor ledger entries in the last two years...I am not sure which item to set the filter on...
Vendor Ledger Entry - OnPreDateItemTodaysDate := TODAY; CalculateDate := '<CD-2Y>'; TwoYearsAgo := CALCDATE(CalculateDate,TodaysDate); "Vendor Ledger Entry".SETFILTER("Posting Date",'%1..%2',TwoYearsAgo,TODAY);
0 -
You really need to start thinking about these things yourself. Go through the steps, analyze the need.
If you need to create a list report that shows the vendors that do not have any vendor ledger entries for the past 2 years, does it make sense to have a dataitem that shows vendor ledger entries? In my opinion no. Why would you have a dataitem for a table from which you are not going to show any data? You have to think about this.
Instead of a dataitem, add some code to the OnAfterGetRecord trigger of the Vendor, and use the CurrReport.SKIP method to skip over vendors that DO have ledger entries. Since you are not showing any details, you don't need to actually retrieve and records, so you can use the ISEMPTY command.0 -
SOLVED!
// Filter the Vendor Ledger Entries, "Posting Date" to be between today and two years ago. TodaysDate := TODAY; CalculateDate := '<CD-2Y>'; TwoYearsAgo := CALCDATE(CalculateDate,TodaysDate); VendorLedgerEntries.SETFILTER("Posting Date", '%1..%2', TwoYearsAgo,TodaysDate); // - ADD End Vendor - OnAfterGetRecord() // - ADD Start // Filters the Vendor No. that are found in the Vendor Ledger Entries to the Vendor No found in Vendor Table. // If a match a found, then skip that record. VendorLedgerEntries.SETRANGE("Vendor No.", Vendor."No."); IF VendorLedgerEntries.FINDSET THEN REPEAT CurrReport.SKIP; UNTIL VendorLedgerEntries.NEXT=0; // - ADD End
0 -
Again, a good start but no....
You are looping where you don't need to loop. All you need to do is know whether records exist, like this:VendorLedgerEntries.SETRANGE("Vendor No.", Vendor."No."); IF NOT VendorLedgerEntries.ISEMPTY THEN CurrReport.SKIP;
Also, your date filtering can be done better:VendorLedgerEntries.SETRANGE("Posting Date",CALCDATE('<-2Y>',TODAY),TODAY);
No need for 4 different variables, and it's easier to use SETRANGE. Also, I don't know where 'CD' comes from0 -
.David Singleton0
-
DenSter wrote:Again, a good start but no....
You are looping where you don't need to loop. All you need to do is know whether records exist, like this:VendorLedgerEntries.SETRANGE("Vendor No.", Vendor."No."); IF NOT VendorLedgerEntries.ISEMPTY THEN CurrReport.SKIP;
Also, your date filtering can be done better:VendorLedgerEntries.SETRANGE("Posting Date",CALCDATE('<-2Y>',TODAY),TODAY);
No need for 4 different variables, and it's easier to use SETRANGE. Also, I don't know where 'CD' comes from
CD was ment to be "Current Date". I wasnt sure how to tell the system to calculate the 2 year difference. Thats why I used CD (current day) - 2y.
your way makes a bit more sense. :thumbsup: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