(DEV) Where to clear total variables on a report

redhotmustang
Member Posts: 91
Hi there,
I'm correcting a report that lists student's expenses.
The report first shows the list of expenses student by student.
Like:
This code is on the body section
The TotalStudent is on the group footer section.
The issue is that when I proccess the following sudent the TotalStudent brings the info (the total) of the previous student.
I'm trying to clear this variable. But I don't know where to do it.
In which section?
Thank you in advance.
Regards.
I'm correcting a report that lists student's expenses.
The report first shows the list of expenses student by student.
Like:
Student - Description - Quantity - Amount Student 1 - Lunch - 2 - $25 Student 1 - Gym - 1 - $50 TotalStudent = $100 Student - Description - Quantity - Amount Student 2 - Lunch - 3 - $25 Student 1 - Gym - 2 - $50 TotalStudent = $175 Grand Total (All students) - $275I use a variable to multiply the amount by the quantity, and then a new var that adds the student's total.
This code is on the body section
QtdAmount := Quantity * Amount; TotalStudent := TotalStudent + QtdAmount;
The TotalStudent is on the group footer section.
The issue is that when I proccess the following sudent the TotalStudent brings the info (the total) of the previous student.
I'm trying to clear this variable. But I don't know where to do it.
In which section?
Thank you in advance.
Regards.
Redcodestudio: Web Development, FLASH & Webdesign (and a little NAV, in the future)
0
Answers
-
Add one more group footer down the one you are talking about.
there in OnPreSection() OR OnPostSection() clear the variable
(TotalStudent = 0;)
And how about adding (TotalStudent = 0;) in the OnPostSection() of the Group Footer you are talking about......??Sandeep Prajapati
Technical Consultant, MS Dynamics NAV0 -
Hello,
I understand you group by student code probably. You can have a structure withCurrreport.CREATETOTALS(QtdAmount);
in OnPreDataItem of your DataItem. then show QtdAmount variable in Group Footer section.
In the end you can add a Footer section for the dataitem and show again QtdAmount variable for grand totals.//Bogdan0 -
Sandeep Prajapati wrote:And how about adding (TotalStudent = 0;) in the OnPostSection() of the Group Footer you are talking about......??
That makes the TotalStudent appears as 0. That is, it calculates the total and then clears it. And in the report the total appears as 0.Redcodestudio: Web Development, FLASH & Webdesign (and a little NAV, in the future)0 -
And what about the 1st one..Add one more group footer down the one you are talking about.
there in OnPreSection() OR OnPostSection() clear the variable
(TotalStudent = 0;)Sandeep Prajapati
Technical Consultant, MS Dynamics NAV0 -
Problem solved.
I cleared the variable in Student Group Header. That is, every time a student is processed the variable is cleared.
We have to clear before every student is processed.
Thanks!Redcodestudio: Web Development, FLASH & Webdesign (and a little NAV, in the future)0 -
Second part of the report:
Now I need to add the expenses from all the students per service (like lunches, classes, books).
Like this:
Service TotalQuantity TotalAmount
Lunch 5 $100
Books 3 $300
Classes 1 $50
GrantTotal $450
The TotalAmount is the Quantity * Amount (that is, the TotalAmount has already this value calculated).
There is a field Description with the name of the service adquired, and the TotalAmount for that service that totals all the Students expenses for that service.
The GrandTotal is the total of all services.
I'm trying to code it, like this:TotalAmount := Quantity * Amount
But this will only calculate the last quantity found * last amount found.
I mean if student A has bougth 2 lunches, and student B 3 lunches, it will multiply the quantity of last student times the amount of the last student.
I need to multiply the quantity per amount, student by student, because some students have discounts. And not the total of quantities times the total of amounts.
I tried lots of things, but I can't find the answer.
Hope you can help me, thanks.Redcodestudio: Web Development, FLASH & Webdesign (and a little NAV, in the future)0 -
Problem solved.
I had to code it on the dataitem OnAfterGetRecord() trigger.
I cleared the variable, and add the amount * quantity for every service.
I was trying to code it on the group footer section.
Regards.Redcodestudio: Web Development, FLASH & Webdesign (and a little NAV, in the future)0 -
As I was reading your post I was preparing to tell you never to write any data manipulation code in any of the section triggers. Everything data related should be in dataitem triggers. Section triggers should really only be for layout, formatting, and whether the section is printed or not.
That is by far THE most important lesson to be learned in NAV report writing, and you seemed to have picked up on that yourself. Well done0 -
Thank you very much. Lesson learned.
Experimenting is the most important part of the learning process! But I only wish I add more time to study in order to get things done easier and faster when my teammates ask me.
Regards.Redcodestudio: Web Development, FLASH & Webdesign (and a little NAV, in the future)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