Jump to content

Using subreport return values in master report var


seboss

Recommended Posts

Hello,

I'm trying to generate a report which use some subreport to get calculated values, but I can't use this values in the master report.

So I have two subreport which return 2 values ($V{A}, $V{B} for exemple), I put this in master report as the same name.

In the master report, I have $F{C} and I wan't to generate $V{INTER_VALUE} (for exemple, expression value : "$V{A}*$F{C}+$V{B}").

If I display $V{INTER_VALUE}, I have "null" value.
If I display a text field with "$V{A}*$F{C}+$V{B}" expression, I have the correct value.

Subreports are in the detail band whereas $V{INTER_VALUE} is in the summary band.

Is there a solution to do this ? Or should I write all in the expression of the text field ?

Thanks for help and sorry if my english isn't very good...

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

seboss wrote:

Is there a solution to do this ? Or should I write all in the expression of the text field ?

 

Currently, the only solution is to use the return variables in the text field expression. Returning values from subreports and evaluating "normal" variable expressions happen at different moments, and using a subreport return value in a variable expression will not work as expected.

 

Regards,

Lucian

Link to comment
Share on other sites

  • 1 month later...

Hello,

 

is there a plan to resolve this problem?

In my case, I need to sum up the subreport variables and to return them to the next higher subreport (I have 3-4 nested subreports). And as you describe there doesn't exist any solution...

 

Regards.

Link to comment
Share on other sites

johahe wrote:

In my case, I need to sum up the subreport variables and to return them to the next higher subreport (I have 3-4 nested subreports). And as you describe there doesn't exist any solution...

Doesn't returning the values with calculation="Sum" work?

Code:

Regards,
Lucian

Link to comment
Share on other sites

Unfortunately, it doesn't because my subreports are because of some reasons in the summary band.
Therefore I sum them up like

Code:

in a textfield.

If I use system for calculation type, I get the count of (parallel) subreports.

In the parent report (not in the image), I want to sum up the values like sumOfCostOfCategory241. Therefore, I need to sum up these variables and return their sum to the parent report.

Now, I try to write the "return" values into a file and read this file later by jasperreports. It could be a workaround but not really a solution in my opinion.

[file name=subreport-f9c4bd21b0f694d98b7ffa25d20a0d07.jrxml size=47028]
PS: Please note that not all variables and parameters are needed...
Post edited by: johahe, at: 2008/07/03 09:39

Link to comment
Share on other sites

johahe wrote:

Unfortunately, it doesn't because my subreports are because of some reasons in the summary band.

 

This doesn't mean that you can't use calculation="Sum" when returning values from subreports:

Code:

<variable name="SubreportsTotal" .../>

<!-- first subreport -->
<returnValue subreportVariable="subreportSumOfCostOfAll" toVariable="SubreportsTotal" calculation="Sum"/>

<!-- second subreport -->
<returnValue subreportVariable="subreportSumOfCostOfAll" toVariable="SubreportsTotal" calculation="Sum"/>

<!-- third subreport -->
<returnValue subreportVariable="subreportSumOfCostOfAll" toVariable="SubreportsTotal" calculation="Sum"/>

<!-- and so on -->

 

In the parent report (not in the image), I want to sum up the values like sumOfCostOfCategory241. Therefore, I need to sum up these variables and return their sum to the parent report.

 

You kind of lost me here. What is the problem again? Why can't you sum values returned from sumOfCostOfCategory241 in the master report?

 

Regards,

Lucian

Link to comment
Share on other sites

Thanks a lot!

 

Obviously, I didn't try to set the calculation type of the return value to sum - I only tried to change the calculation type of the variable in the main report (which does not work properly).

 

With your hint, everything works fine. Thanks!

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...