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:
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.
<group name='Sales' sql="SELECT ID,Customer,Num,SalesRep,SaleDate FROM ZENApp_Report.Invoice WHERE (Month(SaleDate) = ?) OR (? IS NULL) ORDER BY SalesRep,SaleDate">
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)) } K ^||ztemp("ADMTYPE") quit stream }
Hello Guilherme
XData ReportDefinition [ XMLNamespace = "http://www.intersystems.com/zen/report/definition" ]
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:
{
<report xmlns="http://www.intersystems.com/zen/report/definition" name="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
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/definition" name='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/definition" name='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))
}
K ^||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