tenho um relatorio mestre com 3 subreports, cada um tem um valor total acumulativo, preciso somar esse valores e mostrar no relatorio mestre.
A minha dúvida é: como passar os valores do subreport para o relatorio mestre…
Alguem pode me ajudar?
tenho um relatorio mestre com 3 subreports, cada um tem um valor total acumulativo, preciso somar esse valores e mostrar no relatorio mestre.
A minha dúvida é: como passar os valores do subreport para o relatorio mestre…
Alguem pode me ajudar?
Achei uma trick que nao sei se eh de muita utilidade.
Ela permite retornar valores de subreport para o master.
Antes que pergute, nao, ainda nao usei nem testei, mas ta ai. Se conseguir alguma coisa me avisa, pois seria interessante funcionar.
[quote]
Returning values from subreport top
You can return values from subreports using special parameters as containers.
HereÂ’s an example:
Problem:
I want to pass to my master report the total number of records that the subreport had.
Solution:
In the master report, I define a special container parameter that will hold the values that I want to return from the subreport.
<parameter name="ReturnedValuesMap" class="java.util.Map">
<defaultValueExpression>
new java.util.HashMap()
</defaultValueExpression>
</parameter>
I pass this container parameter to my subreport, so that it can store the returned values in it.
<subreportParameter name="ReturnedValuesMap">
<subreportParameterExpression>
$P{ReturnedValuesMap}
</subreportParameterExpression>
</subreportParameter>
In the subreport template, I declare the container parameter. Even they both have the same name, the master report parameter and the subreport parameter are in fact totally different entities.
<parameter name="ReturnedValuesMap" class="java.util.Map"/>
In the subreport, I use the dummy <printWhenExpression> of an invisible line element placed on the summary section to put in the container parameter the value that I want to return to my master report:
<line>
<reportElement x="0" y="0" width="0" height="0">
<printWhenExpression>
($P{ReturnedValuesMap}.put(
"MY_RETURNED_VALUE", $V{REPORT_COUNT}) == null
)?Boolean.FALSE:Boolean.FALSE
</printWhenExpression>
</reportElement>
</line>
Remember that the returned value can be placed in the container parameter also using scriptlets. I chose this trick for simplicity reasons.
Back in the master report, if I want to display the returned value, I just extract it from the container parameter:
<textField evaluationTime="Group" evaluationGroup="DetailGroup">
<reportElement x="335" y="50" width="175" height="15"/>
<textFieldExpression class="java.lang.Integer">
$P{ReturnedValuesMap}.get("MY_RETURNED_VALUE")
</textFieldExpression>
</textField>
You might ask why is it that the text field uses evaluationTime=“Group”.
This is because one of the problems with the returned values from subreports is that these values are returned after the content of the band elements has already been evaluated.
If you want to display subreport returned values in the same band as the subreport itself, you’ll end up seeing that they were returned too late for that.
So, in order to be able to display the returned values in the same master report band that contains the subreport itself, I had to delay the text field evaluation. This was done by introducing a dummy group in the master report and let my text field be evaluated when this dummy group ends.
This dummy group breaks with every record in the data source and has no header and footer of its own.
<group name="DetailGroup">
<groupExpression>$V{REPORT_COUNT}</groupExpression>
</group>
This dummy group served my purpose because my subreport and the text field were placed in the detail section of the master report and it had to break with every detail. If the subreport is placed in a different report section, the dummy group expression should be adapted to fit the given situation.
The use of a dummy group is not necessary if you do not need to display the returned values in the same report section that contains the subreport itself.
[/code]
Como é que eu modifico essa expressão:
($P{ReturnedValuesMap}.put( "MY_RETURNED_VALUE", $V{REPORT_COUNT}) == null )?Boolean.FALSE:Boolean.FALSEpra retonar um valor Double, que não precisa ser avaliado, o valor ja esta armazenado em uma variável $V{VALOR}