Jump to content

Subreport-variable "bug" in JasperReports 3.0!?


mikij

Recommended Posts

 Hi,

I have in my main report three Double variables: var1, var2 and var3, and a subreport. var1 and var2 are define in "Subreport return values" of my subreport properties (with sum as Calculaction type). I've set those var1 and var2 as following: Calculation type = System, Reset Type = None, and Report for Evaluation time. I show these two variables in the summary band of my main report. They are shown OK, but when I define another variable, var3 (with Nothing as Calculaction type), whose expression is: var1 + var2, var3 is always null!! I tried ALL Evaluation Times for var3, from Now to Auto and it doesn't work!! 

 

What can I do, please help because I'm stuck with this stupid problem for days now :-(((((!

 

I asked the same thing here but nobody answered: http://jasperforge.org/plugins/espforum/view.php?group_id=83&forumid=101&topicid=47773

 

--

Thank you VERY MUCH in advance, Miki

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

You can do two things:

1. Don't use a third variable, and directly display $V{var1} + $V{var2} in a text field.
 

2. Use subreport return values to compute var3.  I.e. something like this:

    <returnValue subreportVariable="subreportVar1" toVariable="var1" calculation="Sum"/>    <returnValue subreportVariable="subreportVar2" toVariable="var2" calculation="Sum"/>    <returnValue subreportVariable="subreportVar1" toVariable="var3" calculation="Sum"/>    <returnValue subreportVariable="subreportVar2" toVariable="var3" calculation="Sum"/>

HTH,

Lucian



Post Edited by Lucian Chiriţă at 11/05/08 17:16
Link to comment
Share on other sites

 Dear Lucian, thank you very much on such a fast answer! 

O.K. But, the problem is that my actually var3 need to divide these two variables var1 and var2 and show it in my main report ? I cannot just show var1 / var2 in textfield, because I need var3 to use it with some other (also returned from subreport - var4) variable to compute new value, i.e., when var3 is computed in main report (as var1 / var2) and var4 also returned from subreport I need to show following expression: var3/var4 * 1000 ?

 

--

Thank you, Miki

 

 

Link to comment
Share on other sites

 Is it possible that JasperReports doesn't have solution to such a common thing, like a summary for multiple groups in a subreport ?! I sum some variables from my subreport, and now I want to make final calculaction in summary of my main report, it is simple like that and my EVERY report have this. 

Link to comment
Share on other sites

Variables that have their values returned from subreports cannot be used (in the general case) in the expressions of other variables due to the way the JasperReports engine works.  The problem is that variable expressions are evaluated at the beginning of a band fill, while subreport values are only returned during the band fill.  Please log a bug if you think we need to address this.

In many cases, a workaround is to use subreport return variables directly in text field expressions.  E.g. you would use a text field expression that shows (var1 / var2) / var4 * 1000.

Regards,

Lucian

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...