Novice Coding Question, Please Help

adamEthan
Member Posts: 104
Thanks for looking!
Nav 4.0 SP3
I have a very basic report that I created to detail the past shipping/invoice history of a customer, sorted by customer, then sales order no. then line items. I wanted to do this filtered on just a specific range of item numbers, so lines that were to GL or a different range were omitted.
This is what my Report Designer looks like:
Customer
__Sales Invoice Header
___Sales Invoice Line
_____ Integer ( Amounts )
And my code for each section looks like this:
( SIL = Sales Invoice Line Temp table )
Since I have to wipe the "TotalAmount" Global each time a new customer is pulled, I'm having a hard time adding up all of the customers totals.
Can someone help so that I'd have a grand total?
Thanks a million..
-Adam
Nav 4.0 SP3
I have a very basic report that I created to detail the past shipping/invoice history of a customer, sorted by customer, then sales order no. then line items. I wanted to do this filtered on just a specific range of item numbers, so lines that were to GL or a different range were omitted.
This is what my Report Designer looks like:
Customer
__Sales Invoice Header
___Sales Invoice Line
_____ Integer ( Amounts )
And my code for each section looks like this:
( SIL = Sales Invoice Line Temp table )
Customer - OnAfterGetRecord() TotalAmount := 0;
Sales Invoice Line - OnAfterGetRecord() SIL.SETRANGE("Document No.","Document No."); SIL.SETRANGE("Line No.","Line No."); IF NOT SIL.FINDFIRST THEN BEGIN SIL := "Sales Invoice Line"; SIL.INSERT; END ELSE BEGIN SIL.Amount := SIL.Amount + Amount; SIL.MODIFY; END;
Amounts - OnPreDataItem() Amounts.SETRANGE(Number,1,SIL.COUNT); Amounts - OnAfterGetRecord() IF Amounts.Number = 1 THEN SIL.FINDFIRST ELSE SIL.NEXT; TotalAmount := TotalAmount + SIL.Amount;
Since I have to wipe the "TotalAmount" Global each time a new customer is pulled, I'm having a hard time adding up all of the customers totals.
Can someone help so that I'd have a grand total?
Thanks a million..
-Adam
0
Answers
-
Hi Adam,
Two ways to solve this - create a new variable for OverallTotal and add into it when you total TotalAmont or use the currreport.createtotals - this command is very usefull and will maintain total per group and an overall total even if the value is zero'd in the middle. Look at report 105 for a easy example
Hope this helps.0 -
Thank you for the reply, and while I am home over the weekend I will certainly try this out on Monday and post my results.
I'm familiar with the create totals aspect of the program, however I didn't know it would work when calculating variables etc.
Thanks!
-Adam0 -
If you created a new key ("Sell-to Customer No.", SumIndexField Amount), it would be easier.
Customer - OnAfterGetRecord:SalesInvoiceLine.SetRange("Sell-to Customer No.","No."); SalesInvoiceLine.calcsums(Amount); TotalAmount+=SalesInvoiceLine.Amount;
If you dont´t want to create the key, you´ll have to add the Amounts line by line (if SalesInvoiceLine.find('-') then repeat .. until).
All the other DataItems are not necessary.0 -
Thanks for all the help! I got the report to function properly because of your assistance.
Just one simple question though.
How do I remove the tabs from the "report filter" screen? Currently it has all the tabs at the top for the different filtering, but I want to remove a few.
Thanks!
-Adam0 -
set the DataItemTableView property for the dataItem corresponding to the tab O:)Sandeep Prajapati
Technical Consultant, MS Dynamics NAV0 -
Set a sort order in the DataItemTableView property and make sure there are no fields specified in the ReqFilterFields property.0
-
Thanks for the quick replies. I think I must have mistyped.
I know how to remove the fields that could recieve filters, what I meant to type was that I don't know how to remove the tab altogether, like the "integer" tabs are completely unnecessary, etc.
haha, sorry about that
-adam0 -
Maybe you didn't read my post:DenSter wrote:Set a sort order in the DataItemTableView property and make sure there are no fields specified in the ReqFilterFields property.DenSter wrote:Set a sort order in the DataItemTableView0
-
Detailed instructions:
1 - Check the ReqFilterFields property. If this is already blank: good. If this has any value, remove it.
2 - Set a sort order in the DataItemTableView property
Now you should not have a tab for the dataitem any longer.0 -
Thanks for the replies, I'm uncertain if you were being punchy or frank.
I'm unfamiliar with the phrase that you so eloquently repeated, "set a sort order." Nothing is glaringly obvious when I view the properties of each table in the field you mentioned, as Integer tables have no viewable capabilities in these realms, but I'd rather avoid the confrontation and frustration and be on my way, report finished and all.
Perhaps I should become a site supporter again.
Thanks,
-Adam0 -
adamEthan wrote:I'm unfamiliar with the phrase that you so eloquently repeated, "set a sort order."
Since you wrote that you are familiar with these properties, I assumed that you would know where to find it. You obviously did not find where you can select the sort order for the Integer dataitem.adamEthan wrote:Nothing is glaringly obvious when I view the properties of each table in the field you mentioned, as Integer tables have no viewable capabilities in these realms
Open your report in design, put the cursor on the integer dataitem, and open the properties page. Scroll down to the DataItemTableView property and click the ellipsis button (that's the little button with the 3 dots on it, and you can also press Shift+F2), which opens the 'table view' dialog box. In the 'Key' field, click the lookup button (that's the one with the arrow pointing upward), and you will see the Integer Key List, from which you can select the Number field as the key, which sets the sort order of the dataitem to the number field of the virtual Integer table.
I've told you the same thing in three different ways, and you keep telling me that it is not what you need. If this still confuses you, please tell me what it is exactly that you don't understand, and I will try to help you.0 -
DenSter,
My coworkers and I got a laugh out of your comical response when you needed to slow it down for me, yet the information you provided did indeed help in finally "finishing" this report. Best of all, everyone at my company is very pleased with the effort, as they found the report to be very useful and extremely beneficial to their daily activities. I couldn't have done it without you! Thanks!
All the best
-Adam0 -
adamEthan wrote:your comical response
Good to hear you got that to work, well done.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