Subreport repetido muitas vezes [RESOLVIDO]

Caros,

Estou com um pequeno problema em gerar relatórios.

Fiz um relatório genérico onde coloco diversos sub-relatórios (por enquanto apenas 1 para ver como funciona!). O resultado é que o sub-relatório se repete pelo número de linhas na tabela (o primeiro subrelatório).

Alguém pode me dar uma idéia?

Obrigado desde já,

Gustavo

O relatório “pai” está assim:

[code]<?xml version="1.0" encoding="UTF-8" ?>






<parameter name="nome_regional" isForPrompting="false" class="java.lang.String">
	<parameterDescription><![CDATA[Nome do Município Sede da Regional velha]]></parameterDescription>
	<defaultValueExpression ><![CDATA["Nome_da_Regional"]]></defaultValueExpression>
</parameter>
<parameter name="mes_relatorio" isForPrompting="false" class="java.lang.String">
	<parameterDescription><![CDATA[Mês do Relatório por Extenso]]></parameterDescription>
	<defaultValueExpression ><![CDATA["Mes_Do_Relatorio"]]></defaultValueExpression>
</parameter>
<parameter name="SUBREPORT_DIR" isForPrompting="false" class="java.lang.String">
	<defaultValueExpression ><![CDATA["C:\\Performer\\FWWeb\\Tomcat 5.0\\webapps\\vigilantos_2x\\WEB-INF\\relatorios\\compiled\\"]]></defaultValueExpression>
</parameter>
<queryString><![CDATA[SELECT
 *

FROM
escala_sa]]>

<field name="idsobreaviso" class="java.lang.Long"/>
<field name="dataInicio" class="java.sql.Date"/>
<field name="dataFim" class="java.sql.Date"/>
<field name="matricula" class="java.lang.Long"/>
<field name="nome" class="java.lang.String"/>
<field name="cargo" class="java.lang.String"/>
<field name="celular" class="java.lang.String"/>
<field name="telefone" class="java.lang.String"/>
<field name="idregionalvelho" class="java.lang.Integer"/>
<field name="isMotorista" class="java.lang.Boolean"/>

	<background>
		<band height="0"  isSplitAllowed="true" >
		</band>
	</background>
	<title>
		<band height="19"  isSplitAllowed="true" >
		</band>
	</title>
	<pageHeader>
		<band height="172"  isSplitAllowed="true" >
			<image  evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
				<reportElement
					x="7"
					y="7"
					width="69"
					height="69"
					key="image-1"/>
				<box></box>
				<graphicElement stretchType="NoStretch"/>
				<imageExpression class="java.lang.String"><![CDATA["C:\\Performer\\FWWeb\\Tomcat 5.0\\webapps\\vigilantos_2x\\images\\brasaoSC.gif"]]></imageExpression>
			</image>
			<staticText>
				<reportElement
					x="23"
					y="18"
					width="0"
					height="0"
					key="staticText-13"/>
				<box></box>
				<textElement>
					<font/>
				</textElement>
			<text><![CDATA[Texto Estático]]></text>
			</staticText>
			<staticText>
				<reportElement
					x="85"
					y="11"
					width="247"
					height="66"
					key="staticText-14"/>
				<box></box>
				<textElement>
					<font fontName="Arial" pdfFontName="Helvetica-Bold" size="11" isBold="true"/>
				</textElement>
			<text><![CDATA[ESTADO DE SANTA CATARINA

SECRETARIA DE ESTADO DA SAÚDE
SISTEMA ÚNICO DE SAÚDE
SUPERINTENDÊNCIA DE SAÚDE PÚBLICA
DIRETORIA DE VIGILÂNCIA EPIDEMIOLÓGICA]]>







































































































[/code]

e o relatório “filho”:

[code]<?xml version="1.0" encoding="UTF-8" ?>






<queryString><![CDATA[SELECT
 *

FROM
escala_sa
WHERE
isMotorista=false
]]>

<field name="idsobreaviso" class="java.lang.Long"/>
<field name="dataInicio" class="java.sql.Date"/>
<field name="dataFim" class="java.sql.Date"/>
<field name="matricula" class="java.lang.Long"/>
<field name="nome" class="java.lang.String"/>
<field name="cargo" class="java.lang.String"/>
<field name="celular" class="java.lang.String"/>
<field name="telefone" class="java.lang.String"/>
<field name="idregionalvelho" class="java.lang.Integer"/>
<field name="isMotorista" class="java.lang.Boolean"/>

	<background>
		<band height="0"  isSplitAllowed="true" >
		</band>
	</background>
	<title>
		<band height="0"  isSplitAllowed="true" >
		</band>
	</title>
	<pageHeader>
		<band height="20"  isSplitAllowed="true" >
			<staticText>
				<reportElement
					x="200"
					y="0"
					width="135"
					height="20"
					key="staticText-6"/>
				<box></box>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font pdfFontName="Helvetica-Bold" isBold="true"/>
				</textElement>
			<text><![CDATA[ESCALA DE TÉCNICOS]]></text>
			</staticText>
		</band>
	</pageHeader>
	<columnHeader>
		<band height="30"  isSplitAllowed="true" >
			<rectangle>
				<reportElement
					x="5"
					y="10"
					width="525"
					height="20"
					backcolor="#CCCCFF"
					key="rectangle-1"/>
				<graphicElement stretchType="NoStretch"/>
			</rectangle>
			<staticText>
				<reportElement
					x="6"
					y="11"
					width="58"
					height="18"
					forecolor="#000000"
					key="staticText-1"
					isRemoveLineWhenBlank="true"/>
				<box></box>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font pdfFontName="Helvetica-Bold" isBold="true"/>
				</textElement>
			<text><![CDATA[Período]]></text>
			</staticText>
			<line direction="TopDown">
				<reportElement
					x="65"
					y="10"
					width="0"
					height="20"
					key="line-2"/>
				<graphicElement stretchType="NoStretch"/>
			</line>
			<line direction="TopDown">
				<reportElement
					x="337"
					y="10"
					width="0"
					height="20"
					key="line-4"/>
				<graphicElement stretchType="NoStretch"/>
			</line>
			<staticText>
				<reportElement
					x="66"
					y="11"
					width="160"
					height="18"
					forecolor="#000000"
					key="staticText-2"
					isRemoveLineWhenBlank="true"/>
				<box></box>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font pdfFontName="Helvetica-Bold" isBold="true"/>
				</textElement>
			<text><![CDATA[Nome do Servidor]]></text>
			</staticText>
			<staticText>
				<reportElement
					x="228"
					y="11"
					width="108"
					height="18"
					forecolor="#000000"
					key="staticText-3"
					isRemoveLineWhenBlank="true"/>
				<box></box>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font pdfFontName="Helvetica-Bold" isBold="true"/>
				</textElement>
			<text><![CDATA[Cargo]]></text>
			</staticText>
			<staticText>
				<reportElement
					x="338"
					y="11"
					width="93"
					height="18"
					forecolor="#000000"
					key="staticText-4"
					isRemoveLineWhenBlank="true"/>
				<box></box>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font pdfFontName="Helvetica-Bold" isBold="true"/>
				</textElement>
			<text><![CDATA[Celular]]></text>
			</staticText>
			<staticText>
				<reportElement
					x="433"
					y="11"
					width="96"
					height="18"
					forecolor="#000000"
					key="staticText-5"
					isRemoveLineWhenBlank="true"/>
				<box></box>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font pdfFontName="Helvetica-Bold" isBold="true"/>
				</textElement>
			<text><![CDATA[Telefone]]></text>
			</staticText>
			<line direction="TopDown">
				<reportElement
					x="432"
					y="10"
					width="0"
					height="20"
					key="line-7"/>
				<graphicElement stretchType="NoStretch"/>
			</line>
			<line direction="TopDown">
				<reportElement
					x="227"
					y="11"
					width="0"
					height="19"
					key="line-9"/>
				<graphicElement stretchType="NoStretch"/>
			</line>
		</band>
	</columnHeader>
	<detail>
		<band height="20"  isSplitAllowed="true" >
			<rectangle>
				<reportElement
					x="5"
					y="0"
					width="525"
					height="20"
					key="rectangle-2"/>
				<graphicElement stretchType="NoStretch"/>
			</rectangle>
			<line direction="TopDown">
				<reportElement
					x="227"
					y="1"
					width="0"
					height="19"
					key="line-3"/>
				<graphicElement stretchType="NoStretch"/>
			</line>
			<line direction="TopDown">
				<reportElement
					x="432"
					y="0"
					width="0"
					height="20"
					key="line-5"/>
				<graphicElement stretchType="NoStretch"/>
			</line>
			<line direction="TopDown">
				<reportElement
					x="65"
					y="0"
					width="0"
					height="20"
					key="line-6"/>
				<graphicElement stretchType="NoStretch"/>
			</line>
			<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
				<reportElement
					x="6"
					y="1"
					width="58"
					height="18"
					key="textField-1"/>
				<box></box>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font/>
				</textElement>
			<textFieldExpression   class="java.lang.String"><![CDATA[$F{dataInicio}.getDate()+" a "+$F{dataFim}.getDate()]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
				<reportElement
					x="70"
					y="1"
					width="156"
					height="18"
					key="textField-2"/>
				<box></box>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font/>
				</textElement>
			<textFieldExpression   class="java.lang.String"><![CDATA[$F{nome}]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
				<reportElement
					x="232"
					y="1"
					width="104"
					height="18"
					key="textField-3"/>
				<box></box>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font/>
				</textElement>
			<textFieldExpression   class="java.lang.String"><![CDATA[br.gov.sc.dive.util.ReportClass.getFuncaoSobreaviso($F{isMotorista}.booleanValue(),$F{cargo})]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
				<reportElement
					x="342"
					y="1"
					width="89"
					height="18"
					key="textField-4"/>
				<box></box>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font/>
				</textElement>
			<textFieldExpression   class="java.lang.String"><![CDATA[br.gov.sc.dive.util.ReportClass.getPhoneFormat($F{celular})]]></textFieldExpression>
			</textField>
			<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
				<reportElement
					x="437"
					y="1"
					width="92"
					height="18"
					key="textField-5"/>
				<box></box>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font/>
				</textElement>
			<textFieldExpression   class="java.lang.String"><![CDATA[br.gov.sc.dive.util.ReportClass.getPhoneFormat($F{telefone})]]></textFieldExpression>
			</textField>
			<line direction="TopDown">
				<reportElement
					x="337"
					y="0"
					width="0"
					height="20"
					key="line-8"/>
				<graphicElement stretchType="NoStretch"/>
			</line>
		</band>
	</detail>
	<columnFooter>
		<band height="0"  isSplitAllowed="true" >
		</band>
	</columnFooter>
	<pageFooter>
		<band height="0"  isSplitAllowed="true" >
		</band>
	</pageFooter>
	<summary>
		<band height="0"  isSplitAllowed="true" >
		</band>
	</summary>
[/code]

… voce colocou o subrelatório na banda Detail, tente mudá-lo para outra banda…

Realmente era isso!

Coloquei o primeiro subreport na banda pageHeader e o outro na banda columnHeader. Funcionou, mas achei confusa a formatação… Acho que trabalhar melhor os subrelatorios.

Obrigado

o problema esta na consulta que vc faz no report principal, o subreport vai repetir o numero de linhas que essa consulta retornar.