Jump to content

BIRT Developer Center
Download


Photo
- - - - -

Fetching dataset value in Master Page footer


  • Please log in to reply
2 replies to this topic

#1 gruel

gruel

    Junior Member

  • Members
  • Pip
  • 2 posts

Posted 26 November 2009 - 12:00 PM

Hi,

I am just starting with BIRT and I need to convert reports done with eReport Designer 8 to BIRT.

For the Body part on the report, it goes well.

But, in our reports done with eReport Designer, we fetched information from the database to show in the Header and the Footer.

First, in the header, we fetch a logo from the database (stored as text) and depending on the company's division, if we found a specific logo, we would display it, otherwise it would be blank.

Second, in the footer, as we use only Oracle Stored Procedures for the retrieval of data, each report has an Oracle Package (named based on the report name) and each Package has a version that we retrieve using the GetPackageVersion function in the package.

Finally, my question is...
How can I retrieve information from the database, using BIRT datasets, in the Header and Footer of the MasterPage ? It is possible ?

I have tried a many things, but with the little BIRT experience I have, I have not yet found a way to do this. I have read a few pages of threads in this forum but have not found what I was looking for.

Can anybody help me ? I would really appreciate your help.

Kind Regards
Guy

#2 mwilliams

mwilliams

    BIRT Guru

  • Administrators
  • 13684 posts

Posted 30 November 2009 - 07:41 AM

Hi Guy,

Master pages in BIRT are created just once, so switching images probably won't work. You could use multiple master pages and switch those out for different report elements, but you're probably wanting to make changes even within one table. The using a data element in the master page footer will run into a similar issue. If you're using 2.5.x, you could use a report variable that can be updated within the master page because it works within the auto text items which are the only items updated in a master page. Let me know if you have questions.
Regards,

Michael Williams

Actuate Corporation – The BIRT Company™

If you need help with deploying BIRT and didn't find your answer here, check out the new Deployment Center.
 
Find me on:
Twitter
Facebook
Blog

LinkedIn
 
Email me:
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com

#3 gruel

gruel

    Junior Member

  • Members
  • Pip
  • 2 posts

Posted 01 December 2009 - 09:43 AM

Hello Michael,

thank you for your reply. I kept searching for a while and came up with this.

As mentionned, we use Oracle PLSQL packages with Ref Cursor to store the Selection logic in the Oracle database. We have 1 package per report and one common package for procedures and functions that can be reused.

In a typical report package, we would have:
create or replace package REPORT0001
AS

vPackageVersion VARCHAR2(20) := '1.0.0';

FUNCTION GetPackageVersion RETURN VARCHAR2;

PROCEDURE MAIN (p_criteria1 IN VARCHAR2,
p_criteria2 IN VARCHAR2,
p_cur OUT REPORTCOMMON.CURSOR_TYPE);
END REPORT0001;

create or replace package body REPORT0001 is

FUNCTION GetPackageVersion RETURN VARCHAR2
IS
BEGIN
RETURN vPackageVersion;
END GetPackageVersion;

PROCEDURE MAIN (p_criteria1 IN VARCHAR2,
p_criteria2 IN VARCHAR2,
p_cur OUT REPORTCOMMON.CURSOR_TYPE)
IS
BEGIN
OPEN p_cur FOR SELECT * FROM DUAL;
END MAIN;
end REPORT0001;

And the common package header would look like:
create or replace package REPORTCOMMON
AS
TYPE CURSOR_TYPE IS REF CURSOR;
END REPORTCOMMON;

I added a procedure to retrieve the package version based on a parameter.

so the common package now looks like:
create or replace package REPORTCOMMON
AS
TYPE CURSOR_TYPE IS REF CURSOR;

PROCEDURE GetPackageVersion(p_reportname IN VARCHAR2, p_cur out cursor_type);
END REPORTCOMMON;

create or replace package body REPORTCOMMON is
PROCEDURE GetPackageVersionCur(p_reportname IN VARCHAR2, p_cur out cursor_type))
IS
vSelectStatement VARCHAR(500);
BEGIN
vSelectStatement := 'SELECT ' || P_REPORT_NAME || '.GetPackageVersion() AS PackageVersion from dual';
OPEN P_CUR FOR vSelectStatement;

END GetPackageVersionCur;
END REPORTCOMMON;

For the report design , I use a library which contains the master pages (used by the report and containing the field PackageVersion in the footer) and a dataset. This dataset fetches the version from the Oracle database. The parameter is set in the beforeOpen event and it uses the display name in the report design (not the library)


MyClass


p_report_name
string
1
'BTRAMR0001'
true
false





1
PACKAGEVERSION
string



this.setInputParameterValue("p_report_name", reportContext.getDesignHandle().displayName);

actuateDataSource


1
PACKAGEVERSION
PACKAGEVERSION
string





So now, at run-time, the parameter is updated with the right reportname and the dataset fetches the information for the package version, by going through the REPORTCOMMON package.

I had tried many other things previously and only that way worked for me.

I haven't had time to look for the solution for the dynamic logo issue yet. I have 14 reports to convert from eReportDesigner to BIRT until December 18th and I have more important issues to resolve (i.e. MaximumHeight of textbox,etc...)

Hoping the explanation is clear and could help someone else.

Kind Regards
Guy