ktrinad Posted August 31, 2006 Share Posted August 31, 2006 By: abangkisp - abangkisp Subreport Return Value? 2003-05-29 00:29 Hai.. sorry to bother all of you again. I want to know if a subreport can return a value? I have a report that use 3 subreport and i want to add the value of all the result i got in the subreport. can anyone help me? TIA Abangkis P By: Giulio Toffoli - gt78 RE: Subreport Return Value? 2003-05-29 03:31 I'm not sure that you can, but try to assign to a subreport parameter a report variable, try to set in the subreport the parameter to a variable and change the variable value. If all values are assigned by reference your master variable is now changed. Giulio By: abangkisp - abangkisp RE: Subreport Return Value? 2003-06-02 23:58 i've found the solution in the jasperreport forum. here's the link if anyone interested https://sourceforge.net/forum/message.php?msg_id=1746736 By: Giulio Toffoli - gt78 RE: Subreport Return Value? 2003-06-03 03:06 For details about the solution try to contact evguen ( Evguen Rosada ) that has discovered this solution. Regards Giulio By: abangkisp - abangkisp RE: Subreport Return Value? 2003-06-03 02:54 When i try the example. i've encountered some problems. It seems that IReport dont support java.util.HashMap (I assumed this because there's no HashMap in the dropdown list, please correct me if i'm wrong) the thing that confused me even more is that when i write it manually it work in the master report. but not in the child report. Can You Tell me whats wrong? TIA Abangkis P // =========== Master Report Code ======= <?xml version="1.0" encoding="UTF-8" ?> <!-- Created with iReport - A designer for JasperReports --> <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="SOE_REPORT" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="595" pageHeight="842" columnWidth="535" columnSpacing="0" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <parameter name="CompanyName" isForPrompting="true" class="java.lang.String"/> <parameter name="Date" isForPrompting="true" class="java.lang.String"/> <parameter name="SUB_REPORT_CAPITAL" isForPrompting="true" class="java.lang.String"> <parameterDescription><![CDATA[complete .jasper subreport name]]></parameterDescription> <defaultValueExpression><![CDATA["C:\ReportTools\AccountingReport\OwnerCapSubreport.jasper"]]></defaultValueExpression> </parameter> <parameter name="SUB_REPORT_INV" isForPrompting="true" class="java.lang.String"> <parameterDescription><![CDATA[complete .jasper subreport name]]></parameterDescription> <defaultValueExpression><![CDATA["C:\ReportTools\AccountingReport\InvestmentSubreport.jasper"]]></defaultValueExpression> </parameter> <parameter name="SUB_REPORT_NET_INCOME" isForPrompting="true" class="java.lang.String"> <defaultValueExpression><![CDATA["C:\ReportTools\AccountingReport\NetIncomeSubreport.jasper"]]></defaultValueExpression> </parameter> <parameter name="SUB_REPORT_WITHDRAWAL" isForPrompting="true" class="java.lang.String"> <defaultValueExpression><![CDATA["C:\ReportTools\AccountingReport\WithdrawalSubreport.jasper"]]></defaultValueExpression> </parameter> <parameter name="InvReturnedValuesMap" isForPrompting="true" class="java.util.HashMap"> <defaultValueExpression><![CDATA[new java.util.HashMap()]]></defaultValueExpression> </parameter> <queryString><![CDATA[select A.accountgroup, debet, credit from Account A inner join Balance B on A.accountno=B.accountno inner join JournalDetail JD on B.accountno=JD.accountno]]></queryString> <field name="accountgroup" class="java.lang.String"/> <field name="debet" class="java.lang.Double"/> <field name="credit" class="java.lang.Double"/> <group name="DetailGroup" isStartNewColumn="false" isStartNewPage="false" isResetPageNumber="false" isReprintHeaderOnEachPage="false" minHeightToStartNewPage="0" > <groupExpression></groupExpression> <groupHeader> <band height="0"> </band> </groupHeader> <groupFooter> <band height="0"> </band> </groupFooter> </group> <title> <band height="100"> <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement mode="Transparent" x="150" y="6" width="250" height="21" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Center" verticalAlignment="Middle" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica" size="20" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String">$P{CompanyName}</textFieldExpression> </textField> <staticText> <reportElement mode="Transparent" x="125" y="40" width="300" height="30" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Center" verticalAlignment="Top" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica-Bold" size="20" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> </textElement> <text><![CDATA[statement Of Owner's Equity]]></text> </staticText> <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement mode="Transparent" x="150" y="80" width="250" height="15" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Center" verticalAlignment="Middle" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String">$P{Date}</textFieldExpression> </textField> </band> </title> <pageHeader> <band height="25"> <rectangle radius="5" > <reportElement mode="Opaque" x="5" y="2" width="525" height="20" forecolor="#808080" backcolor="#808080" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" /> </rectangle> <staticText> <reportElement mode="Transparent" x="320" y="5" width="80" height="14" forecolor="#FFFFFF" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Center" verticalAlignment="Middle" lineSpacing="Single"> <font fontName="sansserif" pdfFontName="Helvetica-Bold" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <text>Debet</text> </staticText> <staticText> <reportElement mode="Transparent" x="18" y="5" width="117" height="14" forecolor="#FFFFFF" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="sansserif" pdfFontName="Helvetica-Bold" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <text>Account</text> </staticText> <staticText> <reportElement mode="Transparent" x="420" y="5" width="80" height="14" forecolor="#FFFFFF" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Center" verticalAlignment="Middle" lineSpacing="Single"> <font fontName="sansserif" pdfFontName="Helvetica-Bold" size="12" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <text>Credit</text> </staticText> </band> </pageHeader> <columnHeader> <band height="120"> <line direction="TopDown"> <reportElement mode="Opaque" x="310" y="0" width="0" height="104" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" /> </line> <line direction="TopDown"> <reportElement mode="Opaque" x="410" y="0" width="0" height="104" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" /> </line> <line direction="TopDown"> <reportElement mode="Opaque" x="510" y="0" width="0" height="104" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" /> </line> <staticText> <reportElement mode="Transparent" x="18" y="1" width="96" height="14" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Middle" lineSpacing="Single"> <font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <text><![CDATA[Owners, Capital On]]></text> </staticText> <staticText> <reportElement mode="Transparent" x="18" y="18" width="73" height="14" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Middle" lineSpacing="Single"> <font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <text><![CDATA[investmen On, ]]></text> </staticText> <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement mode="Transparent" x="90" y="18" width="80" height="14" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Middle" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String">$P{Date}</textFieldExpression> </textField> <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement mode="Transparent" x="113" y="1" width="80" height="14" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Middle" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String">$P{Date}</textFieldExpression> </textField> <staticText> <reportElement mode="Transparent" x="18" y="36" width="75" height="14" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Middle" lineSpacing="Single"> <font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <text>Net Income For</text> </staticText> <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement mode="Transparent" x="95" y="36" width="80" height="14" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Middle" lineSpacing="Single"> <font fontName="" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.String">$P{Date}</textFieldExpression> </textField> <subreport isUsingCache="false"> <reportElement mode="Opaque" x="420" y="1" width="82" height="16" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <connectionExpression>$P{REPORT_CONNECTION}</connectionExpression> <subreportExpression class="java.lang.String">$P{SUB_REPORT_CAPITAL}</subreportExpression> </subreport> <subreport isUsingCache="false"> <reportElement mode="Opaque" x="320" y="17" width="82" height="16" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <subreportParameter name="InvReturnedValuesMap"> <subreportParameterExpression>$P{InvReturnedValuesMap}</subreportParameterExpression> </subreportParameter> <connectionExpression>$P{REPORT_CONNECTION}</connectionExpression> <subreportExpression class="java.lang.String">$P{SUB_REPORT_INV}</subreportExpression> </subreport> <subreport isUsingCache="false"> <reportElement mode="Opaque" x="320" y="36" width="82" height="16" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <connectionExpression>$P{REPORT_CONNECTION}</connectionExpression> <subreportExpression class="java.lang.String">$P{SUB_REPORT_NET_INCOME}</subreportExpression> </subreport> <subreport isUsingCache="false"> <reportElement mode="Opaque" x="320" y="72" width="82" height="16" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <connectionExpression>$P{REPORT_CONNECTION}</connectionExpression> <subreportExpression class="java.lang.String">$P{SUB_REPORT_WITHDRAWAL}</subreportExpression> </subreport> <line direction="TopDown"> <reportElement mode="Opaque" x="320" y="100" width="82" height="0" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" /> </line> <rectangle> <reportElement mode="Transparent" x="420" y="80" width="82" height="16" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="RelativeToTallestObject" pen="1Point" fill="Solid" /> </rectangle> <textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="false" evaluationTime="Group" evaluationGroup="DetailGroup" hyperlinkType="None" > <reportElement mode="Transparent" x="320" y="56" width="80" height="16" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="false" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.Double"><![CDATA[($P{InvReturnedValuesMap}.get("INV_RETURNED_VALUE"))]]></textFieldExpression> </textField> </band> </columnHeader> <detail> <band height="0"> </band> </detail> <columnFooter> <band height="0"> <line direction="TopDown"> <reportElement mode="Opaque" x="320" y="-66" width="82" height="0" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" /> </line> </band> </columnFooter> <pageFooter> <band height="0"> </band> </pageFooter> <summary> <band height="0"> </band> </summary> </jasperReport> // ============ child report code ========= <?xml version="1.0" encoding="UTF-8" ?> <!-- Created with iReport - A designer for JasperReports --> <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> <jasperReport name="InvestmentSubreport" columnCount="1" printOrder="Vertical" orientation="Portrait" pageWidth="80" pageHeight="14" columnWidth="80" columnSpacing="0" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" whenNoDataType="NoPages" isTitleNewPage="false" isSummaryNewPage="false"> <parameter name="InvReturnedValuesMap" isForPrompting="false" class="java.util.HashMap"> <defaultValueExpression><![CDATA[new java.util.HashMap()]]></defaultValueExpression> </parameter> <queryString><![CDATA[select sum(credit-debet) from Account A inner join JournalDetail JD on A.accountno=JD.accountno and (A.accountgroup=2) and periodno=200305 where normalsaldo=1]]></queryString> <field name="sum" class="java.lang.Double"/> <title> <band height="0"> </band> </title> <pageHeader> <band height="0"> </band> </pageHeader> <columnHeader> <band height="0"> </band> </columnHeader> <detail> <band height="14"> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement mode="Transparent" x="0" y="0" width="80" height="14" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"/> <textElement textAlignment="Right" verticalAlignment="Middle" lineSpacing="Single"> <font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.lang.Double">$F{sum}</textFieldExpression> </textField> </band> </detail> <columnFooter> <band height="0"> </band> </columnFooter> <pageFooter> <band height="0"> </band> </pageFooter> <summary> <band height="0"> <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement mode="Transparent" x="0" y="0" width="0" height="0" forecolor="#000000" backcolor="#FFFFFF" positionType="FixRelativeToTop" isPrintRepeatedValues="true" isRemoveLineWhenBlank="false" isPrintInFirstWholeBand="false" isPrintWhenDetailOverflows="false"> <printWhenExpression><![CDATA[($P{InvReturnedValuesMap} .put("INV_RETURNED_VALUE", $F{sum}) == null)?Boolean.FALSE:Boolean.FALSE]]></printWhenExpression> </reportElement> <textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single"> <font fontName="sansserif" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" /> </textElement> <textFieldExpression class="java.util.HashMap">$P{InvReturnedValuesMap}</textFieldExpression> </textField> </band> </summary> </jasperReport> By: Hopoz - hopoz RE: Subreport Return Value? 2004-03-28 14:39 you can use iReport to return values from a subreport using the hashmap method described in teodords "Returning values from a subreport" post in the jasper forums here: https://sourceforge.net/forum/message.php?msg_id=1746736 You will need to manually type in the Paramater type of java.util.Map over the top of the drop down box in iReport. Scott Link to comment Share on other sites More sharing options...
eagle101 Posted November 13, 2006 Share Posted November 13, 2006 the provided link for solution cannot be accessed for some reason. Could anybody provide an answer for this question? I am facing the exact issue described in the thead. I am trying to sum up the value returned from various sub reports and assign it to the master variable. However, the value seems to be reset on each group for some reason even though i didn't specify the reset for this variable. Could someone please help? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now