Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » how to know the value of parameter pass from report to subreport
how to know the value of parameter pass from report to subreport [message #667715] Sun, 01 May 2011 15:45 Go to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 81
Registered: April 2011
Member
any method to know what parameter's value is passed to the subreport?

I have a table and in a column of detail band, I add one more table as subreport.
the main report dataset is SingleServerOverload and the subreport dataset is HelpdeskTicket.
In the HelpdeskTicket, the query has three parameter like following:
select 
TICKETID,
CREATIONDATE,
DESCRIPTION,
STATUS
from SR 
where 
(LOCATE(?, classificationid) > 0 )
and CREATIONDATE > ?
and CREATIONDATE < ?



and in the subreport table, Dataset parameter Binding, I define the following
param_1:row["DATE"]
PARAM_2:ROW["helpdeskStartdate"]
PARAM_3:ROW["helpdeskEnddate"]



then in the subreport dataset HelpDeskTicket beforeOpen event, I want to know
what value is passed to the subreport parameter, so I write
Packages.java.lang.System.out.println(row["classificationID"].value);
Packages.java.lang.System.out.println(row["helpdeskStartdate"].value);
Packages.java.lang.System.out.println(row["helpdeskEnddate"].value);
try {
Packages.java.lang.System.out.println(param_1);
}catch(ex){Packages.java.lang.System.out.println("catch println(param_1)");}
try{
Packages.java.lang.System.out.println(params["param_1"]);
}catch(ex1){
        Packages.java.lang.System.out.println("catch println(params[\"param_1\"])");


but the first three println cannot show the value of parameter, and the later
two println show exception and go to catch statement.
I try to modify to
Packages.java.lang.System.out.println(row["classificationID");
Packages.java.lang.System.out.println(row["helpdeskStartdate"]);
Packages.java.lang.System.out.println(row["helpdeskEnddate"]);

but still cannot show the value, in eclipsec.exe, it show the address instead of the value of parameter.

So any method to know what parameter's value is passed to the subreport?
(because my subreport seems cannot run properly)

thanks in advance.
Re: how to know the value of parameter pass from report to subreport [message #667931 is a reply to message #667715] Mon, 02 May 2011 19:14 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Yes use the inputParams["parameter"] syntax. Look at the attached
example. Specifically the beforeOpen of the inner scripted dataset.

<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.21"
id="1">
<property name="comments">Copyright (c) 2006 &lt;&lt;Your Company
Name here>></property>
<property name="createdBy">Eclipse BIRT Designer Version
2.5.2.v20100208 Build &lt;2.5.2.v20100210-0630></property>
<property name="units">in</property>
<method name="beforeFactory"><![CDATA[myArray = [];
ctr=0;
rctr=0;]]></method>
<property name="layoutPreference">auto layout</property>
<data-sources>
<script-data-source name="Data Source" id="4"/>
</data-sources>
<data-sets>
<script-data-set name="outer" id="5">
<list-property name="resultSetHints">
<structure>
<property name="position">1</property>
<property name="name">c1</property>
<property name="dataType">integer</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">c1</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">c1</property>
<property name="dataType">integer</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<method name="open"><![CDATA[i=0;]]></method>
<method name="fetch"><![CDATA[if (i++ >10)
return false;
else {
row.c1=i;
return true;
}]]></method>
</script-data-set>
<script-data-set name="inner" id="6">
<list-property name="resultSetHints">
<structure>
<property name="position">1</property>
<property name="name">c2</property>
<property name="dataType">integer</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">c2</property>
</structure>
</list-property>
<list-property name="parameters">
<structure>
<property name="name">startval</property>
<property name="dataType">integer</property>
<property name="position">1</property>
<expression name="defaultValue">1</expression>
<property name="isInput">true</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">c2</property>
<property name="dataType">integer</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<method name="open"><![CDATA[j =
inputParams["startval"];]]></method>
<method name="fetch"><![CDATA[if (j ++ >=6)
return false;
else {
row.c2=j;
return true;
}]]></method>
</script-data-set>
</data-sets>
<styles>
<style name="table-header" id="37">
<property name="backgroundColor">#6078BF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="table-footer" id="38">
<property name="backgroundColor">#6078BF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="table-detail" id="39">
<property name="backgroundColor">#E6ECFF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">x-small</property>
<property name="fontWeight">bold</property>
<property name="color">#000080</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="table-group-header-1" id="40">
<property name="backgroundColor">#809FFF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="table-group-footer-1" id="41">
<property name="backgroundColor">#809FFF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="special-header" id="42">
<property name="backgroundColor">#6078BF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">medium</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="crosstab-detail" id="43">
<property name="backgroundColor">#E6ECFF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">x-small</property>
<property name="fontWeight">bold</property>
<property name="color">#000080</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="crosstab-header" id="44">
<property name="backgroundColor">#6078BF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<property name="topMargin">1in</property>
<property name="leftMargin">1.25in</property>
<property name="bottomMargin">1in</property>
<property name="rightMargin">1.25in</property>
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property
name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<table id="55">
<property name="width">100%</property>
<property name="dataSet">outer</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">c1</property>
<expression
name="expression">dataSetRow["c1"]</expression>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">Column Binding</property>
<expression name="expression">var rtn =myArray[rctr];
rctr++;
rtn;</expression>
<property name="dataType">integer</property>
</structure>
</list-property>
<property name="pageBreakInterval">50</property>
<column id="77"/>
<column id="78"/>
<column id="82"/>
<header>
<row id="56">
<cell id="57">
<label id="58">
<text-property name="text">c1</text-property>
</label>
</cell>
<cell id="59"/>
<cell id="79">
<label id="83">
<text-property
name="text">combination</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="60">
<cell id="61">
<data id="62">
<property name="resultSetColumn">c1</property>
</data>
</cell>
<cell id="63">
<table id="64">
<property name="width">100%</property>
<property name="dataSet">inner</property>
<list-property name="paramBindings">
<structure>
<property
name="paramName">startval</property>
<expression
name="expression">row["c1"]</expression>
</structure>
</list-property>
<list-property name="boundDataColumns">
<structure>
<property name="name">c2</property>
<expression
name="expression">myArray[ctr] = dataSetRow["c2"]*row._outer["c1"];
ctr++;
dataSetRow["c2"];</expression>
<property
name="dataType">integer</property>
</structure>
<structure>
<property name="name">Column
Binding</property>
<expression
name="expression">row._outer[row.__rownum]</expression>
<property
name="dataType">string</property>
</structure>
</list-property>
<property
name="pageBreakInterval">50</property>
<column id="73"/>
<header>
<row id="65">
<cell id="66">
<label id="67">
<text-property
name="text">c2</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="68">
<cell id="69">
<data id="70">
<property
name="resultSetColumn">c2</property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="71">
<cell id="72"/>
</row>
</footer>
</table>
</cell>
<cell id="80">
<data id="84">
<property name="resultSetColumn">Column
Binding</property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="74">
<cell id="75"/>
<cell id="76"/>
<cell id="81"/>
</row>
</footer>
</table>
</body>
</report>



Jason

On 5/1/2011 11:45 AM, tong123123@yahoo.com.hk wrote:
> any method to know what parameter's value is passed to the subreport?
>
> I have a table and in a column of detail band, I add one more table as
> subreport.
> the main report dataset is SingleServerOverload and the subreport
> dataset is HelpdeskTicket.
> In the HelpdeskTicket, the query has three parameter like following:
>
> select TICKETID,
> CREATIONDATE,
> DESCRIPTION,
> STATUS
> from SR where (LOCATE(?, classificationid) > 0 )
> and CREATIONDATE > ?
> and CREATIONDATE < ?
>
>
>
> and in the subreport table, Dataset parameter Binding, I define the
> following
>
> param_1:row["DATE"]
> PARAM_2:ROW["helpdeskStartdate"]
> PARAM_3:ROW["helpdeskEnddate"]
>
>
>
> then in the subreport dataset HelpDeskTicket beforeOpen event, I want to
> know
> what value is passed to the subreport parameter, so I write
>
> Packages.java.lang.System.out.println(row["classificationID "].value);
> Packages.java.lang.System.out.println(row["helpdeskStartdate "].value);
> Packages.java.lang.System.out.println(row["helpdeskEnddate"].value);
> try {
> Packages.java.lang.System.out.println(param_1);
> }catch(ex){Packages.java.lang.System.out.println("catch
> println(param_1)");}
> try{
> Packages.java.lang.System.out.println(params["param_1"]);
> }catch(ex1){
> Packages.java.lang.System.out.println("catch
> println(params[\"param_1\"])");
>
>
> but the first three println cannot show the value of parameter, and the
> later
> two println show exception and go to catch statement.
> I try to modify to
> Packages.java.lang.System.out.println(row["classificationID ");
> Packages.java.lang.System.out.println(row["helpdeskStartdate "]);
> Packages.java.lang.System.out.println(row["helpdeskEnddate"]);
>
> but still cannot show the value, in eclipsec.exe, it show the address
> instead of the value of parameter.
>
> So any method to know what parameter's value is passed to the subreport?
> (because my subreport seems cannot run properly)
>
> thanks in advance.
Re: how to know the value of parameter pass from report to subreport [message #667967 is a reply to message #667715] Tue, 03 May 2011 06:52 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 81
Registered: April 2011
Member
thanks for the reply, but my birt version is 2.2.1, and so cannot open the attachment xml, could you upload a older version sample, thanks.

My birt designer version
Quote:

<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.15" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 2.2.1.r221_v20070924 Build &lt;2.2.0.v20070924-1550></property>
Re: how to know the value of parameter pass from report to subreport [message #668096 is a reply to message #667967] Tue, 03 May 2011 17:42 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

You can reference it with inputParams["innerdatasetparametername"]
Here is an example with 2.2.1

Jason

<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.15"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.2.1.r221_v20070924 Build &lt;2.2.0.v20070924-1550></property>
<property name="units">in</property>
<property name="comments">Copyright (c) 2006 &lt;&lt;Your Company
Name here>></property>
<method name="initialize"><![CDATA[importPackage( Packages.java.util );
importPackage( Packages.java.lang );

var outerMap = new Hashtable();
var innerMap = new Hashtable();

for ( i=0; i<10; i++ ){
var mystring = "Outerrow_" + i;
var myinnerstring = "Innerrow_" + i;
outerMap.put(i, mystring);
innerMap.put( mystring, myinnerstring );
}
reportContext.setPersistentGlobalVariable("outerMap", outerMap);
reportContext.setPersistentGlobalVariable("innerMap", innerMap);]]></method>
<data-sources>
<script-data-source name="Data Source" id="4"/>
</data-sources>
<data-sets>
<script-data-set name="outer" id="5">
<list-property name="resultSetHints">
<structure>
<property name="position">0</property>
<property name="name">outtercol</property>
<property name="dataType">string</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">outtercol</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">outtercol</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<method name="open"><![CDATA[hMap =
reportContext.getPersistentGlobalVariable("outerMap");
iter = hMap.entrySet().iterator();]]></method>
<method name="fetch"><![CDATA[if( iter.hasNext() ){
myObject = iter.next();
row["outtercol"] = myObject.getValue().toString();
return true;

}else{

return false;

}]]></method>
</script-data-set>
<script-data-set name="inner" id="6">
<list-property name="resultSetHints">
<structure>
<property name="position">0</property>
<property name="name">innercol</property>
<property name="dataType">string</property>
</structure>
</list-property>
<list-property name="columnHints">
<structure>
<property name="columnName">innercol</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">innercol</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<list-property name="parameters">
<structure>
<property name="name">innerparm</property>
<property name="dataType">string</property>
<property name="position">1</property>
<expression name="defaultValue">testkey</expression>
<property name="isInput">true</property>
<property name="isOutput">true</property>
</structure>
</list-property>
<method name="open"><![CDATA[i = 0;
jj = inputParams["innerparm"];]]></method>
<method name="fetch"><![CDATA[iMap =
reportContext.getPersistentGlobalVariable("innerMap");
inObj = iMap.get(jj);
if( i > 0 )return false;

if( inObj != null ){
row["innercol"] = inObj.toString();

}
i++
return true;]]></method>
</script-data-set>
</data-sets>
<styles>
<style name="detail" id="54">
<property name="backgroundColor">#BACAE2</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="paddingTop">0px</property>
<property name="paddingLeft">0px</property>
<property name="paddingBottom">0px</property>
<property name="paddingRight">0px</property>
</style>
<style name="headerfooter" id="55">
<property name="backgroundColor">#004080</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
</style>
<style name="groupheader" id="56">
<property name="backgroundColor">#0080FF</property>
<property name="fontFamily">"Arial"</property>
<property name="fontSize">small</property>
<property name="fontWeight">bold</property>
<property name="color">#FFFFFF</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property
name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<table name="myoutertable" id="7">
<property name="width">100%</property>
<property name="dataSet">outer</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">outtercol</property>
<expression
name="expression">dataSetRow["outtercol"]</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<column id="16"/>
<column id="20"/>
<header>
<row id="8">
<property name="style">headerfooter</property>
<cell id="9">
<label id="10">
<text-property
name="text">OuterDSCol</text-property>
</label>
</cell>
<cell id="17"/>
</row>
</header>
<detail>
<row id="11">
<property name="style">detail</property>
<cell id="12">
<data id="13">
<property
name="resultSetColumn">outtercol</property>
</data>
</cell>
<cell id="18">
<table name="innertable" id="21">
<property name="width">100%</property>
<property name="dataSet">inner</property>
<list-property name="paramBindings">
<structure>
<property
name="paramName">innerparm</property>
<expression
name="expression">row["outtercol"]</expression>
</structure>
</list-property>
<list-property name="boundDataColumns">
<structure>
<property
name="name">innercol</property>
<expression
name="expression">dataSetRow["innercol"]</expression>
<property
name="dataType">string</property>
</structure>
<structure>
<property name="name">Column
Binding</property>
<expression
name="expression">row._outer[row.__rownum]</expression>
<property
name="dataType">any</property>
</structure>
</list-property>
<expression
name="bookmark">"innertableforrow"+row._outer[row.__rownum] </expression>
<column id="59"/>
<column id="30"/>
<header>
<row id="22">
<cell id="57"/>
<cell id="23">
<label id="24">
<text-property
name="text">InnerDataSetCol</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="25">
<property
name="style">groupheader</property>
<cell id="58">
<data id="60">
<property
name="resultSetColumn">Column Binding</property>
</data>
</cell>
<cell id="26">
<data id="27">
<property
name="resultSetColumn">innercol</property>
</data>
</cell>
</row>
</detail>
</table>
</cell>
</row>
</detail>
<footer>
<row id="14">
<property name="style">headerfooter</property>
<cell id="15"/>
<cell id="19"/>
</row>
</footer>
</table>
</body>
</report>


On 5/3/2011 2:52 AM, tong123123@yahoo.com.hk wrote:
> thanks for the reply, but my birt version is 2.2.1, and so cannot open
> the attachment xml, could you upload a older version sample, thanks.
>
> My birt designer version
> Quote:
>> <report xmlns="http://www.eclipse.org/birt/2005/design"
>> version="3.2.15" id="1">
>> <property name="createdBy">Eclipse BIRT Designer Version
>> 2.2.1.r221_v20070924 Build <2.2.0.v20070924-1550></property>
>
Previous Topic:Supress Table Group Headers
Next Topic:Crosstab memory limitation
Goto Forum:
  


Current Time: Fri Apr 19 23:48:52 GMT 2024

Powered by FUDForum. Page generated in 0.03363 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top