Should sql datasource subreports work?

I am building a 'multi-month statement' - we have customers who are tardy payers and for whom we want to generate a statement going back to the time prior to when they last paid up to.

This is the first sql data source report that I have tried to build that uses a subreport. (The subreport is used to output the line items of the invoice and is invoked with the act_id of the invoice as the only parameter.)  I proceeded by cloning my statement (type 'Customer Statement') and its subreport.

I can run the subreport happily as preview in iReports and it outputs what is expected - ie

(I have cut the prices off)

However, I cannot run the whole thing successfully.

If I run a preview in iReports with the following subreport invocation

             <subreport isUsingCache="true" runToBottom="false">
                <reportElement key="subreport-1" stretchType="RelativeToBandHeight" x="0" y="14" width="535" height="44" isPrintWhenDetailOverflows="true"/>
                <subreportParameter name="act_id">
                    <subreportParameterExpression><![CDATA[$F{actId}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression class="java.lang.String"><![CDATA["C:\\OpenVPMS\\Current-release\\HKG\\reports\\RPT ExtStatementItems-BE.jrxml"]]></subreportExpression>
            </subreport> 

There are no errors but no output at all. [I can happily preview other sql reports that don't use a subreport.]

If I adjust the subreport invocation as follows:

             <subreport isUsingCache="true" runToBottom="false">
                <reportElement key="subreport-1" stretchType="RelativeToBandHeight" x="0" y="14" width="535" height="44" isPrintWhenDetailOverflows="true"/>
                <subreportParameter name="act_id">
                    <subreportParameterExpression><![CDATA[$F{actId}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA["RPT ExtStatementItems-BE.jrxml"]]></subreportExpression>
            </subreport>

and then run it from the Reporting|Reports screen, there are no errors, the main report works but what should be the invoice item data is blank - as shown below: (The 1123413 & 1124016 are the act_id  dumped for diagnostic purposes)

I have looked through the user contributed reports but can find none that use a subreport.

What I am I doing wrong or do we have a problem that the Reporting|Reports engine cannot handle a subreport in an sql data source report?

Note that the subreport is set as type 'Sub Report' in Admin|Templates.

Regards, Tim G

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Should sql datasource subreports work?

I haven't tried this. If you like, send me your report off list and I'll take a look.

-Tim A

Re: Should sql datasource subreports work?

Re: Should sql datasource subreports work?

Tim - I have 5717 running on the laptop and the report now runs ( though I am still removing my errors). Thanks for the fix. Will put into production tomorrow morning.

For the sake of others, herewith what the XML should look like to invoke an SQL subreport:

 <subreport isUsingCache="true" runToBottom="false">
   <reportElement key="subreport-1" stretchType="RelativeToBandHeight" x="0" y="14" width="535" height="44" isPrintWhenDetailOverflows="true"/>
      <subreportParameter name="act_id">
          <subreportParameterExpression><![CDATA[$F{actId}]]></subreportParameterExpression>
      </subreportParameter>
      <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
      <subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA["RPT ExtStatementItems-BE.jrxml"]]></subreportExpression>
</subreport> 

and here is the iReports version

Regards, Tim G

Re: Should sql datasource subreports work?

Sorry for necroing this thread - but has anyone had any success burying  a sql sub report on a report that would typical use an OpenVPMS.datasource. 

IE Main Report - Patient Letter - uses a `org.openvpms.report.jasper.IMObjectCollectionDataSource` then a subreport that is passed parameters from the main and runs a sql query...I am assuming it doesnt work because no report connection is made available for these types of reports.

 

 

Regards
 
Ben 
OpenVPMS Installer and Helper 
Ph: +61423044823 
Email: info[at]charltonit.com[dot]au

Re: Should sql datasource subreports work?

This isn't supported. Reports using an OpenVPMS data source don't get supplied any SQL connection. What data are you trying to access?

Re: Should sql datasource subreports work?

Full patient history embedded in a patient letter.

Regards
 
Ben 
OpenVPMS Installer and Helper 
Ph: +61423044823 
Email: info[at]charltonit.com[dot]au

Re: Should sql datasource subreports work?

It would be hard to generate a history listing in a patient letter using SQL.

At the moment, there's no support to include history within a document.

You can email history as an attachment, so you could:

  • attach an existing patient letter to the email; or
  • use an Email Template to generate the email body

 

Re: Should sql datasource subreports work?

Yep No probs I'll do it another way!

Regards
 
Ben 
OpenVPMS Installer and Helper 
Ph: +61423044823 
Email: info[at]charltonit.com[dot]au
Syndicate content