I am trying to pass a variable from sub report to main report. I have already declared variable in subreport. But it's not showing when I'm trying to use this at the main report. Can anyone please help me out? Thanks in advance.
3 Answers
Add the folowing parameters in Properties of your Subreport
Parameters Map Expression : $P{REPORT_PARAMETERS_MAP} : This is used to pass a map containing report parameters to the subreport. The map is usually obtained from a parameter in the master report, or by using the built-in REPORTS_PARAMETERS_MAP parameter to pass the parent report's parameters to the subreport. This expression should always return a java.util.Map object in which the keys are the parameter names.
Subreport Expression Class : java.lang.String
Subreport Expression : $P{SUBREPORT_DIR} + "yourPage.jasper"
Connection/Data source Expression, select Use connection expression, and put : $P{REPORT_CONNECTION}
See also:
While returning any value from subReport you have to just type the variable name you declared at the subReport in "subReport variable" field. And at the "Local Destination Variable" you will find the variable you declared in main report. Like this:
Don't forget to set the variable expression you declared at the main report. It has to be that variable itself.
report_connection
parameter is added or not. if not In propertise of SUbreport , For "Connection/Datasource Expression " select "Use Connection Expression" and add Built in parameter "$P{REPORT_CONNECTION}" – Saif$P{REPORT_CONNECTION}
is already added in the properties of sub Report. – Ayon