Jump to content
We've recently updated our Privacy Statement, available here ×

Using returned value from subreport.


Apolo

Recommended Posts

Hi

Maybe anybody know, how returned value from subreport use in variable in main report?

I have:

1. <returnValue subreportVariable="icount" toVariable="icount"/>,

2. Text field in main report with “Textfield expression†= “$V{icount}†and “Evaluation time†= “Bandâ€

3. Variable “var†in main report with “Variable expressionâ€=“$V{icount}â€

4. Text field in main report with “Textfield expression†= “$V{var}†and “Evaluation time†= “Bandâ€

 

When I generate report value of text field (icount) is correct, however value of test field (var) is null.

 

How solve this problem?

 

Thanks.

 

P.S.

Sorry for bad English.

Link to comment
Share on other sites

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

You can't use variables with values returned from subreports in other variables' expressions, because variable expressions are evaluated at the beginning of the band rendering, and subreport return values while the band gets rendered.

 

You should try to find a way to avoid this. How are you using the value returned from the subreport in your other variable?

 

Regards,

Lucian

Link to comment
Share on other sites

How are you using the value returned from the subreport in your other variable?

 

I need find sum of returned values. + In the future more complex data processing from subreport can be necessary.

 

 

I solved this problem by using very simple scriptlet:

 

Code:

+ 2 text fields:

1. field1:

a. textfield expression: "" + $P{REPORT_SCRIPTLET}.addcount($V{icount}.intValue())

b. evaluation time: “Bandâ€

c. band: “Detailâ€

2. field2:

a. textfield expression: "" + $P{REPORT_SCRIPTLET}.getcount()

b. evaluation time: “Nowâ€

c. band: “Summaryâ€

 

result:

Value, which is returned from subreport, processed in the scriptlet.

Link to comment
Share on other sites

I have added one more returnable value with calculation type: “Sumâ€

Code:


Property of variable var:

Code:

Text field with variable var is in “Summaryâ€
Property of text field:
Evaluation time: “Bandâ€

Result: variable var contain last value from subreport instead of sum of returned values.

Maybe you have a sample how calculate sum of values returned from subreport?

Link to comment
Share on other sites

  • 2 months later...

Hi all. I'm new to this forum. In the last days we have been evaluating JasperReports as our report generation system.

 

We are trying to move from JInfonet Jreports to JasperReports. But we are experiencing problems with working with return values from subreports.

 

As I understand from last posts, we can't use returned values in the definition of other expressions... And here is the problem. With the other product, we've been using this technique to generate intermediate values to reach final results.

 

Could we do this same process with JasperReports? Do we need to use scriptlets to evaluate returned values from subreports?

 

Thanks in advance,

 

Greetings.

 

Juan Fuentes

Link to comment
Share on other sites

Thanks for your interest Lucian. We have already solve this problem... well by now: We have created a group that corresponds to every line of the detail. Then set the subreport in the group header. In this way, expressions in the detail band are evaluated after running the subreports, and the values from the subreports are already set.

 

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