fwhorton Posted August 10, 2007 Share Posted August 10, 2007 Hello All, Just wanted to post my experiences with subreport return values since I see so many posts. What I usually do is create the subreport and make sure the output is correct and anything that I do not want show in the report I just set the band or field's Print When Expression to Boolean.FALSE so I can always go back and verify output without having to create everything over. Also, many times I do not want anything of the subreport to show so I just set the subreport height to 1 and stick it at the top of a group. Groupings are important. Let's say the subreport is in the header of group A. Then I find the subreport return values can be used in any sub-group (i.e. group B's) or within the footer the subreport is in (i.e. group A's footer). Scenario subreport: variable name = "temp" calculation type = "sum"Scenario main report: Group A contains subreport variable name = "temp" (name them the same) calculation type = "System" (only one worked) Reset Type = "Group" Reset Group= = "Group A" Text Field (Eval. Time) = "Now" (left defaulted)Scenario main report subreport return values: Subreport Variable = "temp" (manually typed) Local Destination Variable = "temp" Calculation Type = "Nothing" **If subreport is not located in a group then set Reset Type = "Report" (i.e. when subreport located in header). The subreport's variable (variable name = "temp") can be set in any way (i.e. calculation type, reset type, or variable expression). Create a variable in the main report (variable name = "temp") with calculation type = "System" and set Reset Group to grouping where subreport is located. Create subreport return values and type in the subreport variable name that needs to be returned (i.e. name = "temp") and then set the destination to the variable just created (i.e. name = "temp"). To use the subreport return value in another variable's Variable Expression (i.e. calculating a subreport return value with a field). I set the new variable's calculation type = "Nothing", Reset Type = "None" and left the field's evaluation time = "Now". Then I find the new variable can be used in any sub-group (i.e. group B's) or within the footer the subreport is in (i.e. group A's footer). Hope this works for you. And please add any comments.Post edited by: fwhorton, at: 2007/08/15 21:29 Link to comment Share on other sites More sharing options...
joepmo Posted February 28, 2010 Share Posted February 28, 2010 Oh my goodness - thank you! This worked perfectly.The detailed settings were exactly what I needed to solve my problem. Link to comment Share on other sites More sharing options...
georve Posted March 3, 2010 Share Posted March 3, 2010 in my case it doesn't work, i`m trying to take variables from subreport to make calculus if i put the values like you describes in your post, the result values are null.. if i put my values like this i got the calculus except the last valueVariables: Calculus tipe: nothing reset type: report Evaluation Time: Report.to receive the value is the same as your post Link to comment Share on other sites More sharing options...
mattmattb Posted August 2, 2010 Share Posted August 2, 2010 I too could not get a value other than null on my initial pages of the report, however setting the evaluation time to report makes the value work on the last page of the report(obviously). So instead I changed my calculations that use the main report variable to just say new Boolean($V{mainReptVariable} == null) do something. I don't know how to get the value to not be null, but was able to use the null value as my if condition that I needed. Link to comment Share on other sites More sharing options...
hunta007 Posted January 30, 2012 Share Posted January 30, 2012 Thank you for this post. I am trying to use the return value of the subreport variable in a filter expression in my main report (or even in the subreport) but can't seem to get any Groovy expressions to acknowledge the integer value of the variable as an integer. Is there something special about the return value that needs to be taken into consideration? Thank you. Link to comment Share on other sites More sharing options...
groxli Posted September 24, 2014 Share Posted September 24, 2014 I'm using Jaspersoft Studio CE 5.6.0 and was seeing the same odd sort of behavior where the return values from a subreport were not showing up--even though the variable mappings in the main report were correctly pointing to the source variables in the subreport. I switched the "Evaluation Time" from "Now" to "Auto" as you described, and it fixed the issue. Thank you!! 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