ltannous
10th September 2002, 23:33
I have created a report and a report script. In the script, I have a varaivble (val4) which is used in the detail lines of this report. I want to get the totoal of val4 in another layout to use with another variable. How do I get the totals for val4 without settitng the function within the report field to Total
lbencic
10th September 2002, 23:58
Those are just variables that are accessable in the events of the report. So...
before.program:
tot.field = 0.0
detail.1:
before.layout:
tot.field = tot.field + variable.to.be.totalled
|* calculate here using the tot.field as a running total
after.breakfield.10:
before.layout:
|* calculate here using the tot.field
after.layout:
tot.field = 0.0
You can see an example in the Sales Invoice standard report script (tdsls440401000) - watch what they do with the 'tot.invoiced' variable - same basic logic.
You can find and example of almost anything you need to do in reports in the Invoice Report
morpheus
11th September 2002, 08:09
Hello,
You can write code in the report script (after.field -> before.layout). Also, you can use the aggregate function in the report layout.
rupertb
11th September 2002, 11:46
Why don't you use the Baan report field total option, if you need to access that value you can - it's stored in a variable called total..0 if you have multiple totals they'll be in total..0, total..1, total..2 and so on.
Do a debug, you'll soon see ...
Regards,
Rupert
lbencic
11th September 2002, 16:54
You guys are right - the total...0 fields are absolutely the best way to go. This code would only be useful if you needed to do something different than the report can calculate, like conditions that will not fit in the on the report field total 'where' box.
mark_h
11th September 2002, 17:04
You were correct the first time that was the better solution. If you use total..# variables then everytime you change the report you have to figure out which total..# number to use again. I do not recommend using the total..# variables. Too much headache in updating them.
Mark
ltannous
11th September 2002, 18:56
Thanks, that worked great (lbencic)
rupertb
11th September 2002, 21:26
lol mark, I knew that - I'd been bitten in the bum too many times with the total..# functionality, especially on sum of our *huge* planning reports the ones with 255 input fields :)
Just thought I'd mention it anyway,
Regards
lbencic
11th September 2002, 21:34
ok - I should know with so many ways to do things, there is no 'absolutely'. The method I gave is standard. While the other method is DARN handy for pre-written reports that you aren't messing with, that already have the totals you want, it has large drawbacks in the areas Mark and Rupert were mentioning. I guess that's where all those upgrade dollars go - when someone adds a field on the report, and all of a sudden the totals don't work. :eek: