Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

return a variable from one subReport to another subReport in Jaspersoft Ireport

I have a main Report in jaspersoft. Inside the main Report I have used two SubReports. Inside one of the subreport i have a variable Total Cash. I have to use this variable Total Cash in my next subReport. Is it possible to pass a variable from one SubReport to another SubReport. If not then how can i pass the variable from the SubReport to the main Report.

Thanks.

like image 450
Kiran Avatar asked Nov 13 '22 13:11

Kiran


1 Answers

You can get a return value from a sub-report to the main-report using the returnValue element. The following code sets the $V{result} value in the main-report to the value of $V{total} in the sub-report. This is much more obvious in iReport instead of jrxml code. Take a look at Subreports for more information.

<subreport isUsingCache="true">
  <reportElement x="18" y="11" width="189" height="77" key="subreport-1" />
  <connectionExpression>
    <![CDATA[$P{REPORT_CONNECTION}]]>
</connectionExpression>
  <returnValue subreportVariable="total" toVariable="result" />
  <subreportExpression class="java.lang.String">
    <![CDATA["C:/Program Files/JasperSoft/iReport-3.0.0/compile/Untitled_report_2.jasper"]]>
</subreportExpression>
</subreport>
like image 83
user845279 Avatar answered Dec 14 '22 23:12

user845279