I want to simply return a value from sub report to main report, but always shows null
when the report is executed. Using iReport 5.1.0.
Main report
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report4" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="ce028d85-f7e8-4abd-ad6b-e3b2ba04d14e">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["C:\\Users\\DellXFR\\"]]></defaultValueExpression>
</parameter>
<variable name="z" class="java.lang.Integer" calculation="System">
<variableExpression><![CDATA[8]]></variableExpression>
</variable>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<detail>
<band height="125" splitType="Stretch">
<subreport>
<reportElement uuid="0c501730-d98a-4982-9953-2939f127ad9e" x="40" y="10" width="200" height="100"/>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<returnValue subreportVariable="x" toVariable="z"/>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "report4_subreport1.jasper"]]></subreportExpression>
</subreport>
<textField evaluationTime="Band">
<reportElement uuid="9020a8d9-5799-4907-b8a3-704f41ffdcc0" x="399" y="73" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$V{z}]]></textFieldExpression>
</textField>
</band>
</detail>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>
Subreport
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report4_subreport1" language="groovy" pageWidth="555" pageHeight="802" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="78290b3a-34c2-496e-86ff-e213ca2c1039">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<queryString language="SQL">
<![CDATA[select * from ot;]]>
</queryString>
<field name="salscheme_id" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<field name="ot_amount" class="java.lang.Double">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
<variable name="x" class="java.lang.Integer">
<variableExpression><![CDATA[1]]></variableExpression>
</variable>
<group name="salscheme_id">
<groupExpression><![CDATA[$F{salscheme_id}]]></groupExpression>
</group>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="125" splitType="Stretch"/>
</detail>
</jasperReport>