Chapter 6. Report Parameters

Up until now, the reports that we have worked with have had one thing in common—they all have been static reports. That means they do not accept any sort of input from the user. Their output depends solely on the data present in a database. While we have demonstrated that a filter can be applied to the data coming back from a data source, we haven't discussed how a report user can specify what details they want to see.

In this chapter, we will look at the different types of parameters that BIRT offers. We will distinguish between parameters that can filter datasets and parameters that can change the look and feel of reports.When we finish reading through this chapter, we will be able to take our reports one step further than the canned reports that we have developed so far, and be able to offer our users the ability to filter down large amounts of data to just the information that is important to them.

Why parameterize reports?

This is a very important question to ask ourselves, and while the answer might seem obvious, it goes a little deeper. Imagine that we are a report developer for a large organization with several different departments. Now we create a report for a department that shows their costs for the fiscal quarter—that's great. Now a second department asks us to create the same report for them. Then a third department asks for a similar report, but they want to be able to see data for both last quarter and this quarter. By this time, we have created three similar reports, each representing the same set of data and running the same queries, only that we have hard coded the department information. Now we have to maintain all three of those reports, and any changes or mistakes we or an analyst find in any of the reports, ultimately we will ultimately have to fix in all three reports.

The solution to this problem is to parameterize our report. In a simple scenario such as this, it becomes obvious that if we created a few parameters such as one for department and a few to handle date ranges, we would then have to maintain only a single report for all the departments and time frames that would be requested. By parameterizing, we are taking a larger number of reports needed to be maintained and verified and reducing it to a more manageable number. This becomes useful as more often than not, report requests remain very similar.

Now, take a step back and let's look at something we haven't addressed up until now. Let's say for each department that runs the report, they want their header to be displayed in the report or their department logo. Now we are looking at something other than data-centric issues and moving into the realm of layout-specific issues. With BIRT, we also have the ability to address these kinds of visual requirements. For example, if the manager from the accounting department wanted alternating row colors, but the other managers did not, we could easily create a report parameter that would ask the report user if they wanted to add alternating row colors. With the logo issue, we can easily create some basic logic that is driven by report parameters to meet these requests. We will look at some examples in this chapter, and explore this more in depth in the chapter on Scripting.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset