2005 IR Help Posted August 26, 2006 Share Posted August 26, 2006 By: LL - lovelyliatroim Scriplet 2004-08-06 08:28 Kinda relates back to my original problem http://sourceforge.net/forum/forum.php?thread_id=1123115&forum_id=113530 Trying to get the grand total of 3 sub-reports which each subreport returns back a value of there sub-total and i want to show the grand total in master report!! Couldnt get a variable to add for me , i.e ($V{Total} = new Double($V{Total}.doubleValue() + new Double($P{ReturnedValuesMap}.get("RunningTotal").toString()).doubleValue())) compiler didnt like it, think its because i had it as a textfield expression, can one add a variable and parameter together?? if so where should it be?? anyways, as a work around, cause i couldnt get variable + parameter to work i came up with a scriptlet to do it for me!! The plan being that every time a group had finished i would add the sub-total to the grand-total, but what i think is happening is this, each group contains a subreport ,when the afterGroupInit() is called i hoped that i would be able to get the value of the returned parameter and it to grand total before i moved off to next group(subreport), but when afterGroupInit() is called i think that the subreport hasnt even being run yet, and it moves off to the next group!! when afterGroupInit() is encountered, should the subreport in that group be called?? i think it doesnt!! running out of ideas on this, how does one go about getting the grand total of 3 subreports which return there sub-totals?? cheers, LL By: Emmanuel Okyere - eokyere RE: Scriplet [LONG RESPONSE] 2004-08-06 11:10 i have a problem that is related to this; what i'm trying to do is print a summary item for every item in the group... let's say i'm grouping according to $F{customerid}, i want to give a summary for each customer... the results per customer can span X number of pages (depending on how many records, which varies) I can't use a group footer because I cannot control exact positioning with that, so I resulted to using a page footer, with a printWhenExpreesion as (Boolean.class, $V{printFooter}) -- use variable "printFooter" -- and pritFooter's variable expression is defined as (Boolean.class, new Boolean($V{printFooter}.booleanValue()) My intention was to use a scriplet to control the boolean value of printFooter, however, I've noticed the same thing you've noticed... which is the event callbacks (afterReportInit, beforePageInit etc) seem to be a bit off... i created a simple method in my scriplet which prints out if the group has changed (i have only one group) private String yes() { return ((JRFillGroup)groups[0]).hasChanged() ? " [yes] " : " [no] "; } I am calling this in all the events with a println on standard output and this is what the trace looks like: call beforeReportInit [yes] call beforePageInit : PAGE_NUMBER = null [yes] call beforeColumnInit : printFooter = null [yes] call beforeGroupInit [yes] call afterGroupInit [yes] call afterColumnInit [yes] call afterPageInit : PAGE_NUMBER = 1 [yes] call afterReportInit [no] -> detail [no] <- detail [no] -> detail [no] <- detail [no] call beforePageInit : PAGE_NUMBER = 1 [no] call beforeColumnInit : printFooter = false [no] call afterColumnInit [no] call afterPageInit : PAGE_NUMBER = 1 [no] -> detail [no] <- detail [no] -> detail [no] <- detail [no] call beforePageInit : PAGE_NUMBER = 2 [no] call beforeColumnInit : printFooter = false [no] call afterColumnInit [no] call afterPageInit : PAGE_NUMBER = 2 [no] -> detail [no] <- detail [no] -> detail [no] <- detail [no] call beforePageInit : PAGE_NUMBER = 3 [no] call beforeColumnInit : printFooter = false [no] call afterColumnInit [no] call afterPageInit : PAGE_NUMBER = 3 [no] -> detail [no] <- detail [no] call beforeGroupInit [yes] call afterGroupInit [yes] call beforePageInit : PAGE_NUMBER = 4 [yes] call beforeColumnInit : printFooter = true [yes] call afterColumnInit [yes] call afterPageInit : PAGE_NUMBER = 4 [yes] -> detail [yes] <- detail [yes] call beforeGroupInit [yes] call afterGroupInit [yes] call beforePageInit : PAGE_NUMBER = 1 [yes] call beforeColumnInit : printFooter = true [yes] call afterColumnInit [yes] call afterPageInit : PAGE_NUMBER = 1 [yes] -> detail [yes] <- detail [yes] call beforeGroupInit [yes] call afterGroupInit [yes] call beforePageInit : PAGE_NUMBER = 1 [yes] call beforeColumnInit : printFooter = true [yes] call afterColumnInit [yes] call afterPageInit : PAGE_NUMBER = 1 [yes] -> detail [yes] <- detail [yes] (-> detail is beforeDetailEval, and <- is after) Interpretation: As you can see, from the detail, I have 10 records coming in; the first 7 belong to the first customer id; the last 3 are spread across the last 3 customers (should result in hasChanged() returning "yes" 3 times, which is what happens) I have made the detail bands large enough to only print 2 records per page (so I can spread a case like that of the first customer to make it print on the last page it appears on); I also start a new page when the group breaks. The problem is, though I am resetting "printFooter" in the beforeGroupInit to Boolean.TRUE whenever I have a yes, the printWhen for the textFields I have in my report do not conform... ... I'm at the point where I could tear my hair out ;) maybe (adding my voice to LL's) somebody has an idea out there? thanks, eokyere Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now