Wednesday, April 12, 2017

Passing Parameters to a Scripted DataSet;or any DataSet for that matter

The first time I heard the phrase "parameter binding to a data set" cold chills shot down my spine. I was thrust right back into my first OO Programming Class, where concepts like "pointers", "polymorphism" and others were thrown around like we were all just born to understand these abstract descriptions. Why not call it something simpler... like Parameter "place-holder" or "access point" ? Using the word "parameter binding" just makes it sound more complicated than it has to be. ...Maybe that's the idea? We are talking about nerdy techie types after all.

That said, I will try to make sure I don't needlessly try to impress with my cryptic verbage. So, here it goes. If you are both new to BIRT and have to use a scripted source the way IBM’s Maximo implementations do, you might not know where to begin right off the bat. I will break it down into smaller pieces, so that it is easier to follow and less complicated.

Start with a report that is easy for you to understand from a conceptual perspective if nothing else. In this case person_details.rptdesign should do just fine. What you see here is the 7.5 Maximo Server. In the spirit of keeping it easy, the report chosen has a single user prompt, PersonID.

The purpose of the report is to display all Assets, Contracts, Tickets or Work Orders that the selected person is assigned to. This is shown by utilizing multiple sub-tables within the primary summary table listing information coming from the Maximo person table. Looking at the report layout perspective you see each sub-table maps to a DataSet.

The first thing you do is add the Parameter, this can be done under the Data Explorer or Outline view (I find it easier to do it in the Outline). Here is where you define the parameter prompt for the user as well as consider the type of data you are expecting to work with in the dataset. This parameter was defined as a String value that will be provided via a Text Box.

Once you have a parameter you have increased the usability and functionality of the report significantly. But the most effective, or rather most efficient one is utilized in this report, it is applied at each DataSet level. Let’s take a look at a portion of the open event of the first DataSet, assetdetail:

You can see where BIRT is going to replace the ? with the provided Person ID in the where clause. But it can be used against multiple fields. For example, here is the workorders DataSet open, in this DataSet it will compare against 3 fields; the owner of the workorder, who it was reported by or on behalf of:

The best way to tackle handling anything new, and in particular anything new with BIRT or even troubleshooting complicated reports or queries is to break the system down into simpler and simpler terms until you begin with something which is easy for you to understand. This report is a good example of creating a highly functional report using small manageable pieces. Using a default parameter values you not only makes unit testing quicker for you, you also have the ability to run each DataSet individually to troubleshoot any potential scripting issues.

Like I often mention to my clients, and any of my BIRT classes, if you are confused by the BIRT report development process, you are not breaking it down into it's three simple parts....
  1. Data 
  2. Layout 
  3. Formatting & Features 

If you would like to take a class from us, or would like to get some help with your BIRT Project(s), please visit our Website or give us a call (888)234-DATA.