Short Table Names in the BIRT report

Short Table Names in the BIRT report

If you like to shorten your table names for whatever reason (for example select * from inventory inv) and you are creating a report which absolutely must use the standard Maximo parameter (params["where"]) you will notice problems, as the standard Maximo parameter addresses all tables by their full name.

The solution is to tweak the parameter using a nifty little replace function, along with a small regexp statement. In the example below, I am replacing all INVENTORY, ITEM and LOCATIONS references with their respective shortened versions:

In the initialize method of your report:


// report will use the where clause, and since we have shortened the names of objects, we need to tweak the params["where"] clause
scriptLogger.debug(">>>>>> current params[where]: " + params["where"]);

params["where"] = params["where"].replace(/inventory\./g, "inv.");
params["where"] = params["where"].replace(/item\./g, "i.");
params["where"] = params["where"].replace(/locations\./g, "loc.");

scriptLogger.debug(">>>>>> tweaked params[where]: " + params["where"]);

We must use regular expression here since the replace method in Javascript only replaces the first occurrence of the string to be replaced.