Question
· Sep 30, 2021

Zen Reports

Is there a way to create anything like this?

Multiples result sets.

Product version: Caché 2018.1
Discussion (3)2
Log in or sign up to continue

Hello Guilherme

I have already done something like this yes. To work it is necessary to place a select that returns only 1 result in the <report> tag. And in my case I also needed to place a <group> below the <group> where the CreateResultSet is. Stays like this:

XData ReportDefinition [ XMLNamespace = "http://www.intersystems.com/zen/report/definition]
{
<report xmlns="http://www.intersystems.com/zen/report/definitionname="rReport" sql="Select TOP 1 ID FROM anytable">
 
<group name="gTest1" OnCreateResultSet="CreateRS1">
     <group name="gTest1A">
        <attribute name="name"  field='name'/>
   
 </group>
 </group>
 
 <group name="gTest2" OnCreateResultSet="CreateRS2">
     <group name="gTest2B">
        <attribute name="name"  field='name'/>
   
 </group>
 </group>

Hello Guilherme,

I'm not sure about what your goal is, but alternatively, you can use Stored Procedure attached to each group

<report xmlns="http://www.intersystems.com/zen/report/definition" name="MyName" runonce="true">
    <attribute name='attribute1' expression='..GetXXXXX(..P1)'/>
    <attribute name='attribute2' expression='..GetXXXXX(..P2)'/>
    <group name="GroupQuery1" queryClass='Custom.Reports.ZEN.StoredProc.StoredProc1' queryName='Query1'>
      <parameter field="attribute1"/>
      <parameter expression="..GetYYYY()"/>
      ...
      <group name="GroupResponse1">
        ...
      </group>
    </group>
    <group name="GroupQuery2" queryClass='Custom.Reports.ZEN.StoredProc.StoredProc2' queryName='Query2'>
      <parameter field="attribute2"/>
      <parameter expression="..GetZZZZZZ()"/>
      ...
      <group name="GroupResponse2">
        ...
      </group>
    </group>
</report>

Hope this help

Regards,

Jacques

So there are a couple of ways to accomplish what you would like

(1) option is to use the runonce='true' property at the report level and then define each group underneath it individually with its own query option (stored procedure, sql or result set) BUT in order for each individual value to be returned, you would need another group level defined.

So it would look like this:

<report xmlns="http://www.intersystems.com/zen/report/definitionname='myReport' runonce="true">

<group name='Sales' sql="SELECT ID,Customer,Num,SalesRep,SaleDate 
FROM ZENApp_Report.Invoice 
WHERE (Month(SaleDate) = ?) OR (IS NULL)
ORDER BY SalesRep,SaleDate">

<group name="SalesRep" >
<attribute name='name' field='SalesRep' />

</group>
</group>

This produces XML output like this

<myReport>

<Sales>

<SalesRep name='Jack'/>

<SalesRep name='Jen'/>

</Sales>

</myReport>

BUT you have another option

(2) You could use the CALL method within the report to come up with your own XML structure

<report xmlns="http://www.intersystems.com/zen/report/definitionname='myReport' runonce="true">

<call method="FindADMType"/>

And then have the method defined in the report class

Method FindADMType(ByRef pParms) As %GlobalCharacterStream
{
set stream=##class(%GlobalCharacterStream).%New()
set x=""
set x=$O(^||ztemp("ADMTYPE",x))
while (x'="") set rec="<Type typename='"_x_"' />"
do stream.Write(rec)
set x=$O(^||ztemp("ADMTYPE",x))
}
^||ztemp("ADMTYPE")
quit stream
}

So this would produce the following XML output

<myReport>

<Type typename='Inpatient'/>

<Type typename='Outpatient'/>

</myReport>

I hope this helps

Thanks Julie