Jump to content
Changes to the Jaspersoft community edition download ×

Subreport did not display data


Recommended Posts

By: Michael Mai - mmai

Subreport did not display data

2003-06-13 10:36

I am trying to display some master/detail report. I can not get subreport to display any data. When I paste the sql from subreport and plug in parameter value, the query returns several rows. Can any one help me on this?

Here is my master/detail reports and java codes.

###Master

<parameter name="ReportTitle" class="java.lang.String"/>

<parameter name="BaseDir" class="java.io.File"/>

<parameter name="logo" class="java.lang.String"/>

<parameter name="ReportToSubreport" class="dori.jasper.engine.JasperReport"/>

<parameter name="ReportDate" class="java.lang.String"/>

<parameter name="SubreportDataConnection" class="java.sql.Connection"/>

<queryString><![CDATA[

select distinct reports_to, tcs_name_lookup, tcs_id, payroll_id

from ncntv.tblmanagementheirarchy a, ncntv.tblemployees b

where a.datetime = $P{ReportDate} and a.reports_to = 146271 and a.reports_to = b.eid (+)

order by reports_to

]]></queryString>

<field name="reports_to" class="java.lang.String"/>

<field name="tcs_name_lookup" class="java.lang.String"/>

<field name="tcs_id" class="java.lang.String"/>

<field name="payroll_id" class="java.lang.String"/>

 

 

<detail>

<subreport isUsingCache="true">

<reportElement x="5" y="25" width="325" height="15" backcolor="#FFCC99" isPrintRepeatedValues="false" isPrintWhenDetailOverflows="false" isRemoveLineWhenBlank="true"/>

<subreportParameter name="reports_to">

<subreportParameterExpression>

$F{reports_to}

</subreportParameterExpression>

</subreportParameter>

<connectionExpression>

$P{SubreportDataConnection}

</connectionExpression>

 

<!-- <dataSourceExpression class="dori.jasper.engine.JRDataSource">

$P{SubreportDataSource}

</dataSourceExpression> -->

<subreportExpression class="dori.jasper.engine.JasperReport">

$P{ReportToSubreport}

</subreportExpression>

</subreport>

</detail>

 

####Subreport

<parameter name="reports_to" class="java.lang.String"/>

<queryString><![CDATA[

select distinct a.eid as eid, tcs_name_lookup as name

from ncntv.tblmanagementheirarchy a, ncntv.tblemployees b

where a.reports_to = $P{reports_to} and a.eid = b.eid

order by a.eid

]]></queryString>

<field name="name" class="java.lang.String"/>

<field name="eid" class="java.lang.Integer"/>

<variable name="ReportToCount" class="java.lang.Integer" resetType="Group" resetGroup="ReportToGroup" calculation="System">

<initialValueExpression>($V{ReportToCount} != null)?(new Integer($V{ReportToCount}.intValue() + 1)):(new Integer(1))</initialValueExpression>

</variable>

<group name="ReportToGroup">

<groupExpression>

$F{eid}

</groupExpression>

<groupHeader>

<band height="50">

<textField>

<reportElement x="0" y="2" width="50" height="10"/>

<textElement textAlignment="Right"/>

<textFieldExpression class="java.lang.Integer">

$F{eid}

</textFieldExpression>

</textField>

<textField isStretchWithOverflow="true">

<reportElement x="60" y="2" width="150" height="10" positionType="Float"/>

<textFieldExpression class="java.lang.String">

$F{name}

</textFieldExpression>

</textField>

</band>

</groupHeader>

<groupFooter>

<band height="0"/>

</groupFooter>

</group>

 

 

####JAVA Code:

//Preparing parameters

JasperReport subreport = (JasperReport)JRLoader.loadObject("ReportToReport.jasper");

Map parameters = new HashMap();

parameters.put("ReportToSubreport", subreport);

parameters.put("ReportTitle", "Heirarchy Report");

parameters.put("ReportDate", "01-Jun-2002");

parameters.put("logo", "/bea/wlserver6.1/reports/logo.gif");

parameters.put("SubreportDataConnection", getConnection());

 

JasperRunManager.runReportToPdfFile(

fileName,

parameters,

getConnection());

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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