An Oracle blog about BI Publisher

  • RTF
    May 11, 2011

Dynamic Report Titles

Couple of mails recently on being able to externalise the header and footer for a set of templates in 10g. 11g has the whole new style templates that include not only externalised headers and footers but also the look and feel for your templates.

In 10g, you can get the headers and footers with a little effort and I have written about them in the past. The recent mails had a small wrinkle in the requirement - they wanted dynamic report titles (or content) passed to the header template. So I could have a template looking like this:

Dynamic Header

With a place holder for the report title, this could be passed at runtime, either as a runtime report parameter or embedded inside the XML data for the report. The Report Name field holds a reference to the passed parameter <?$ReportName?>. The Template Header field contains a reference to the expected inbound report name as a parameter.

<?template:Header?> <?param:ReportName;string('')?>

The 'param' command declares the name of the parameter and sets a default value i.e. in this case an empty string.

We can two approaches to getting the dynamic value into the output.

XML Data Source

Firstly, we can pull a value from the report's XML data and pass it to the report header sub-template.

We have a standard Import Template command to bring in the sub template. The clear text in the header is a standard call-template command with the added with-param command to pass the report title. You need the @inlines if you want to pass a parameter value.

<?call@inlines:Header?><?with-param:ReportName;.//DEPARTMENT_NAME?> <?end call?>

In this case we are passing the department name from the XML data. I have added a bit more to this template by using the @section in the main grouping statement (group ROW by DEPARTMENT_NAME) This has the effect of re-setting the header each time the DEPARTMENT_NAME changes and thus the 'report title' changes to the new department name.

Report Parameter Source

This is a similar approach.

We just need to declare the report parameter in the main template. The 'Report Param' field contains the parameter declaration.

<?param@begin:val1;'"Employee Report"'?>

That's double quotes surrounding the inner string with single quotes.  The header then contains:

<?call@inlines:Header?><?with-param:ReportName;$val1?> <?end call?>

'with-param' now passes the val1 parameter value to the sub template as $val1. This time the report title will be 'Employee Report' in spite of the @section command i.e, its a fixed constant value that will show on all pages.

You can find the sample templates, data and outputs here.

Join the discussion

Comments ( 2 )
  • Vetri Thursday, May 12, 2011
    Hi Tim,
    i think, i used this n one of the client location in 2008.
    Glad, you had it here.
  • guest Thursday, July 28, 2011

    Hi Tim,

    It's a cool approach. I was Wondering if i can use the same apporach to change the whole header information dynamically. I have a very intresting requirement for a Invoice report where the header in first page should be unique and if the data exceeds next page the header should be different and the footer should be displayed only at the last page. Added to this i have two other templates which will print once the first one is printed. So i coded all three in one RTF. For the rest of two templates no header and footer is required. Header should change only from second page of first template. I achieved footer part by using section breaks and <?start@last-page:body?><?end body?> , but unable to achieve change in header for second page onwards. I tried above given method but it doesn't seem to work in my case.

    I would really appreciate you advice and feed back on this issue.



Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.