BIRT Report - Tivoli Automation Engine
BIRT Report - Tivoli Automation Engine
Implementation Guidelines
By Bradley K. Downing, MBA
Version 1.5
Copyright Notice
Copyright IBM Corporation 2010. All rights reserved. May only be used pursuant
to a Tivoli Systems Software License Agreement, an IBM Software License
Agreement, or Addendum for Tivoli Products to IBM Customer or License
Agreement. No part of this publication may be reproduced, transmitted,
transcribed, stored in a retrieval system, or translated into any computer
language, in any form or by any means, electronic, mechanical, magnetic,
optical, chemical, manual, or otherwise, without prior written permission of
IBM Corporation. IBM Corporation grants you limited permission to make hardcopy
or other reproductions of any m achine-readable documentation for your own use,
provided that each such reproduction shall carry the IBM Corporation copyright
notice. No other rights under copyright are granted without prior written
permission of IBM Corporation. The document is not inte nded for production and
is furnished “as is” without warranty of any kind. All warranties on this
document are hereby disclaimed, including the warranties of merchantability and
fitness for a particular purpose.
U.S. Government Users Restricted Rights -- Use, duplication or disclosure
restricted by GSA ADP Schedule Contract with IBM Corporation.
Trademarks
IBM, the IBM logo, Tivoli, the Tivoli logo, AIX, Cross -Site, NetView, OS/2,
Planet Tivoli, RS/6000, Tivoli Certified, Tivoli Enterprise, Tivoli Enterpri se
Console, Tivoli Ready, and TME are trademarks or registered trademarks of
International Business Machines Corporation or Tivoli Systems Inc. in the
United States, other countries, or both.
Lotus is a registered trademark of Lotus Development Corporation .
Microsoft, Windows, Windows NT, and the Windows logo are trademarks of
Microsoft Corporation in the United States, other countries, or both.
UNIX is a registered trademark of The Open Group in the United States and other
countries.
C-bus is a trademark o f Corollary, Inc. in the United States, other countries,
or both.
PC Direct is a trademark of Ziff Communications Company in the United States,
other countries, or both and is used by IBM Corporation under license.
ActionMedia, LANDesk, MMX, Pentium, and P roShare are trademarks of Intel
Corporation in the United States, other countries, or both. For a complete list
of Intel trademarks, see http://www.intel.com/sites/corporate/trademarx.htm.
SET and the SET Logo are trademarks owned by SET Secure Electronic Transaction
LLC. For further information, see http://www.setco.org/aboutmark.html.
Java and all Java-based trademarks and logos are trademarks or registered
trademarks of Sun Microsystems, Inc. in the United States and other countries.
Other company, product, and service names may be trademarks or service marks of
others.
Notices
References in this publication to Tivoli Systems or IBM products, programs, or
services do not imply that they will be available in all countries in which
Tivoli Systems or IBM op erates. Any reference to these products, programs, or
services is not intended to imply that only Tivoli Systems or IBM products,
programs, or services can be used. Subject to valid intellectual property or
other legally protectable right of Tivoli Systems or IBM, any functionally
equivalent product, program, or service can be used instead of the referenced
product, program, or service. The evaluation and verification of operation in
conjunction with other products, except those expressly designated by Tivo li
Systems or IBM, are the responsibility of the user. Tivoli Systems or IBM may
have patents or pending patent applications covering subject matter in this
document. The furnishing of this document does not give you any license to
these patents. You can s end license inquiries, in writing, to the IBM Director
of Licensing, IBM Corporation, North Castle Drive, Armonk, New York 10504 -1785,
iii
U.S.A.
iv
Acknowledgements
Pam Denny – for providing the bulk of the material and answers to seemingly endless question s
by the editor.
v
About the Tivoli Field Guides
Sponsor
Tivoli Customer Support sponsors the Tivoli Field Guide program.
Authors
Those who write field guides belong to one of these three groups:
Audience
The field guides are written for all customers, both new and existing. They are ap plicable to
external audiences including executives, project leads, technical leads, team members, and to
internal audiences as well.
Field Guides for technical issues are designed to address specific technical scenarios or
concepts that are often complex to implement or difficult to understand, for example:
endpoint mobility, migration, and heartbeat monitoring.
Field Guides for business issues are designed to address specific business practices that
have a high impact on the success or failure of an ESM project, for example: change
management, asset Management, and deployment phases.
Purposes
The Field Guide program has tw o major purposes:
Availability
All completed field guides are available free to registered customers and internal IBM employees
at the following Web site:
http://www.ibm.com/software/sysmgmt/products/support/Field_Guides.html
vii
mailto:[email protected]
viii
Table of Contents
ix
The ROP Fetch Method ................................ ................................ ..........39
LOCALIZATION SETUP .................................................................................................... 41
How Localization is Enabled ................................ ................................ ........42
How Report Labels get Localized ................................ ................................ 43
Request Pages ................................ ................................ ............................ 45
Static Content ................................ ................................ ......................... 46
Dynamic Content ................................ ................................ .................... 46
Common Customer Scenarios ................................ ................................ .....47
x
Fetch Method ................................ ................................ ............................... 59
beforeClose Method ................................ ................................ .................... 61
OTHER METHODS ........................................................................................................... 63
Initialize Method ................................ ................................ ........................... 63
afterFactory................................ ................................ ................................ ..64
User Functions (in any method) ................................ ................................ ...64
xi
BIRT for Tivoli Process Automation Engine (Maximo)
7.x
Implementation Guidelines
The purpose of this guide is to enable the Maximo develope r to install and modify existing report source code
using the BIRT tool in the Eclipse framework. This guide is not intended to replace any existing documentation.
Rather, it is intended to supplement that documentation and re -enforce critical points in that documentation.
Further, this guide is not intended as educational material per -se, but rather as insight into the implementation
and practice of using the BIRT tool in the Maximo framework only.
The author strongly suggests that the practitioner obtain formal training from IBM (IBM Tivoli Reporting for
Enterprise IT and Asset Management 7.1) before using this guide in depth.
1
Installing BIRT into IBM’s Tivoli Process Automation
Engine v7 framework
Installing BIRT in and of itself is not a difficult task. However, there are considerations that the implementation
team MUST take into account in order to mitigate risk to the installation of the software.
1. Maximo V7 (7.1.1.1 through 7.1.1.4) uses Eclipse 3.2 with BIRT Designer 2.1.2 . The following
components require installation:
b. GEF SDK
e. JDK 1.5
2. Maximo V7.1.1.5 uses Eclipse 3.4.2 with BIRT Designer 2.3.2 with the same components.
13
http://www-01.ibm.com/software/brandcatalog/portal/opal/details?NavCode=1TW10OT07
c. In order to upgrade rather than install please navigate to this support document for complete
instructions:
http://www-01.ibm.com/software/sysmgmt/products/support/IBMMaximoAssetManagement.html
3. In order to obtain the software , use the following steps. IBM Employees must downloa d these
components from the IES Website.
a. Create a local directory to store Eclipse and BIRT. The example shown here uses a local
directory of ‘eclipse_download’. NOTE: The local folder should NOT have any spaces in its
path.
b. Access http://ies.ottawa.ibm.com/iss/ies/downloads/index.php
c. Click on 3.2.2 Build, Win 32. Under the Eclipse Full Structure, locate the Eclipse Full SDK and
save the file to your directory.
14
d. On the same page, locate the Business Intelligence and Reporting Tools SDK and save the
file to your local directory.
e. Locate the EMF (Core) SDK and save the file to your local directory.
f. Locate the GEF SDK and save the file to your local directory.
g. Extract the Eclipse Zip File first to your local directory. Once complete, extract
15
the remaining three zip files to your local folder. If you receive prompts to replace existing fi les,
only replace if the date is greater than the existing file. Once complete, your directory should look
like the following:
h. If JDK 1.5 (5.0) is not already installed, then an IBM -authorized version is available from “jim”:
http://w3.hursley.ibm.com/java/jim/jim/index.html
Non-IBM Employees
a. Navigate to the following website: http://www-01.ibm.com/software/brandcatalog/portal/opal
Login with your IBM ID and then search for BIRT .
b. Click on the icon and then click on the BIRT ReportDesigner v2.1.2 link.
16
c. When the following page appears, click on the button.
17
e. Enter your IBM credentials again.
The next page will show your IBM login credentials and prompt you to answer some questions . You will also be
required to check a License agreement checkbox.
18
f. Now Click on “I confirm”
19
Once the download process is complete, move the zip file to the location of the machine that has a local copy
of Maximo V7, with the report source.
\\eclipse\plugins\org.eclipse.birt.report.viewer_2.1.2.v20070205-1728\birt\WEB-INF
\\eclipse\plugins\org.eclipse.birt.report.viewer_2.1.2.v20070205-1728\birt\WEB-INF\classes
3. Copy mxdatasources.properties using the same source and destination folders from steps 1 and 2.
20
4. Open the copied mxdatasources.properties file and edit it for the local configuration
a. Set the URL, driver, username, password, and schemaowner properties for the local
environment following the sample formats provided.
5. Finally, in order to view reports in a PDF forma t within the BIRT Designer, the practitioner will need to
copy the iText.Jar file from the Maximo build folder to the local installation folder of Eclipse.
NOTES
1. The mxdatasources.properties file is only required by the report designer at runtime ; the connection
information will be set from Maximo.
#<DataSourceName>.<propertyName>=valu e
# driver for ORACLE
# oracle.jdbc.driver.OracleDrive r
# sample url for ORACLE
# jdbc:oracle:thin:@<HOST>:<PORT>:<SID >
# driver for SQLServer
# com.inet.tds.TdsDriver
# sample url for SQLServer
#
jdbc:inetdae7a:hostname:port?database=dbname&langu age=us_english&nowar n
ings=true
# driver for DB2
# com.ibm.db2.jcc.DB2Drive r
# sample url for DB2
# jdbc:db2://localhost:50000/dbalia s
maximoDataSource .url=jdbc:db2://MAXIMODB2:50000/MAXIMO
maximoDataSource .driver=com.ibm.db2.jcc.DB2Drive r
maximoDataSource .username=maximo
21
maximoDataSource .password=maximo
The values in red point to a sample local database. You can check yours and other s that are available for you
to choose from Start Menu \Programs\IBM DB2\Set-up Tools\Configuration Assistant.
The key name in blue is the default set for all reports; this text must be used exactly in order for the reports to
work properly.
3. Copy the JDBC driver(s) from the fol der: \\<Maximo>\applications\maximo\lib into
\\eclipse\plugins\org.eclipse.birt.report.viewer_2.1.1.v20070205-1728\birt\WEB-INF\lib
Further, if the practitioner experiences any “NoClassDef Found” errors, experiment with extracting the jar files
into the “classes” folder, which was created in step 2.b (above).
22
2. Select a workspace location. Check “Use this as default” field and OK.
23
4. From the menu, select File – New – Project. Scroll down to the Business Intelligence and Reporting
Tools Location, and select Report Project. Click Next.
24
5. Type in a project name and click Finish.
25
6. The BIRT Report designer within Eclipse SDK Displays.
26
Configuring BIRT Report Designer to Work with V7
Configuration Files
NOTE: Use forward slashes or the Select button when specifying the folder paths in Eclipse.
//<maximo>/reports/birt/libraries
a. If the dialog box is not already o pen (below), then select from the menu, “Window |
Preferences.”
27
c. Browse to your local report template location and select Apply.
<maximo>/reports/birt/templates
a. If the dialog box is not already open (below), then select from the menu, “Windows |
Preferences.”
c. Remove the flag from the “Generate comment when creating a report design” field if it is set.
28
4. Next, import the report project. This will import the V7 Reports into the project workspace.
b. Expand the General folder and select Existing Projects into Workspace.
c. Click Next.
\\<maximo>\reports\birt\reports
5. Click OK.
29
6. Click Finish.
2
Working with Maximo Reports
Maximo reports are unique in their setup and configuration within the Eclipse/BIRT toolset. This section
describes common report features and discusses the most commonly used methods for business logic
implementation. This is not intended to be an exhaustive study but rather a primer on where to find common
and reusable code that the practitioner can modify to meet unique requirements.
30
This report is based on the WORKORDER table and works with the Work Order Tracking ap plications (i.e.
WOTRACK, QUICKREP, CHANGE, ACTIVITY, and RELEASE). This report has several methods overridden.
The first two methods to study are located on the Data Set component. Focus on the data set that requires
attention:
1. Click on the desired data set in either the Data Ex plorer tab or the Outline View t ab. By default, both are
located on the left-hand side of the screen.
31
2. Click on the Script Tab in the Layout pane.
This method defines the interrogative that BIRT passes to the database in order to define the report’s initial
selection.
32
The Fetch Method
This method allows the developer to define the various row elements to display. It is critical to note t he correct
data type. The Database Data Type and the BIRT Data Type are often different, which means that the
definition of the correct “get” method is highly prone to errors in report generation. To get the correct mapping
of the types to one another, please refer to the Report Developer Guide. This information is available on the
following website:
http://publib.boulder.ibm.com/infocenter/tivihelp/v3r1/index.jsp?topic=/com.ibm.itmaxam.doc/welcome.htm
Ensure that the Script tab is in Focus and that the initialize method is available for editing.
33
Developers use this method for many purposes, but the most common is for debugging. Using the above code
enables the developer to view a log file tha t delivers significant information , such that the practitioner may
identify and fix errors easily.
Note:The initial line performs an import package. This package enables the report to access and use the
various custom Maximo methods developed by IBM. Witho ut this package, the reports will not perform
according to expected standards within the Maximo framework.
Every report built for the TPAE (Maximo) framework will have these methods overridden.
WOPRINT
The next report that has interesting meth ods to study is the Work Order Details R eport. In the Fetch method,
the Long description is fetched using a data set open method.
This series of JavaScript snippets allows the user to obtain the long description for each work order retrieved in
the main data set “open” method. Since this dataset open method is embedded on the Fetch method of the
main data set, it will retrieve the long description for each record in the data set.
34
With this approach, the long description for each task on the work order (or job plan) ca n be retrieved simply by
copying the function to the fetch method of the task data set.
//mxReportScriptContext.setDefaultLogLevel("DEBUG" );
//mxReportScriptContext.setDefaultLogFile("C:/temp /inventory_rop.log") ;
scriptLogger = mxReportScriptContext.getReportScri ptLogger();
importPackage(Packages.com.ibm.tivoli.maximo.report.script);
mxReportScriptContext = MXReportScriptContext.initialize(r eportContext);
//mxReportScriptContext.setDefaultLogLevel("DEBUG");
//mxReportScriptContext.setDefaultLogFile("C:/temp/inventory_rop_update.log");
scriptLogger = mxReportScriptContext.getReportScriptLogger();
var paramlist=params["paramstring"].split(params["paramdelimiter"]);
if (scriptLogger.isDebugEnabled()) {
scriptLogger.debug(" >>> paramlist array : " + paramlist.join());
}
if(paramlist.length == 2) {
var attkey=paramlist[0];
var dskey=paramlist[1];
try{
if (scriptLogger.isDebugEnabled()) {
scriptLogger.debug(" >>> updStmtList : " + updStmtList.length);
}
35
if(updStmtList!=null){
var updTxn = MXReportTxnProvider.create(dsName);
for(var i=0; i < updStmtList.length; i++) {
updStmtList.length); var updStmt = updTxn.createStatement();
updStmt.setQuery(updStmtList[i]);
if (scriptLogger.isDebugEnabled()) {
scriptLogger.debug(" >>> updStmt #" + (i+1) + " of " +
}
36
}
if (scriptLogger.isInfoEnabled()) {
scriptLogger.info(" >>> updTxn ready to be saved" );
}
updTxn.save();
status = "update_success";
if (scriptLogger.isInfoEnabled()) {
scriptLogger.info(" >>> updTxn success");
}
}
}
catch( e ){
status = "update_error";
if (scriptLogger.isInfoEnabled()) {
scriptLogger.info(" >>> updTxn failed");
}
}
finally{
updTxn = null;
mxReportScriptContext.removeH ttpSessionAttribute(params[ "paramstring"]);
}
}
}
Additionally, when debugging is turned on, the code displays the update statements being processed.
params["paramdelimiter"] = "||";
params["paramstring"] = attkey + params["paramdelimiter"] + dskey;
37
if(maximoDataSet.isDB2() )
totalItemsClause = "( select max(a) from (select count(*) as a from
matrectrans "
+ " where issuetype='TRANSFER ' union select count(*) as a from matusetrans
where "
+ " issuetype='ISSUE') as b) "
+ " as totalitems, ";
else
totalItemsClause = " ((select count(*) from matrectrans where
38
issuetype='TRANSFER')+( "
+ " select count(*) from matusetrans where issuetype='ISSUE')) as
totalitems, "
maximoDataSet.setQuery(sqlText) ;
if (!maximoDataSet.fetch() )
return (false);
39
row["sstock"] = maximoDataSet.getFloat( "sstock");
var leadtime = 0;
var sstock = 0;
var newlevel = 0;
row["newrop"] = newlevel;
row["newsstock"] = sstock;
if(conversion==null)
conversion=0;
40
row["cfactor"] = conversion;
if(updStmtList==null){
updStmtList = new Array;
}
updStmtList.push(updateQuery) ;
session.setAttribute(attkey , updStmtList);
}
return (true);
Localization Setup
Two specific actions are required to enable localization of V7 reports.
1. Both the Language and Locale for the user must be set.
2. The request pages for each of the languages required by a client need to be generated in the report
admin app for each of these different language s. This can best be described by the use case below.
41
a. A client needs to enable V7 in English, Spanish, and Italian.
b. The report administrator’s locale is set to English. First, he would access Report Admin, and
generate the request pages xml in English.
c. Next, he would sign out. He would then sign back in and change his locale to Spanish. He
would then access Report Admin, and would generate the report request pages in Spanish.
d. Finally, he would sign out again. He would sign back in, change his locale to Italian, and
generate the report request pages in Italian.
The request pages would then be available in all three languages – English, Spanish, and Italian.
When a user signs in to V7, his language is known. It is then compar ed to the V7 MAXVAR of
BASELANGUAGE.
If the user’s language is the same as the MAXVAR’s base language setting, then V7 and reporting
will retrieve data from the standard Database Tables (e.g. Report labels come form REPORTLABEL).
If the user’s language is different from the MAXVAR’s base language setting, then V7 and Reporting
will retrieve data from the corresponding localized tables (e.g. Report labels come from
L_REPORTLABEL where Language Code is equal to the Language Code of the End User).
42
How Report Labels get Localized
All report labels and titles are referenced in their design file by key values. The key value s are simply unique
text values of the control. These key values will be stored in the REPOR TLABEL table in the Database.
For example, in the Report Usage Report, reportusage.rptdesign, two of its labels are circled – User and
Success.
These two label values are stored in the REPORTLABLE Table as shown below.
For clients using a language othe r then English, or for clients enabl ing multiple languages in a V7
environment, corresponding database tables identified by L_REPORTLABEL will be used. These tables will
hold the translated value(s) of the label values.
Multiple instances of a label value can be stored in the L_REPORTLABEL table for multiple languages. The
combination of the Label Value and Language Code will make the label value unique.
Labelkey and Labelvalues for each control in each report have to be defined by the Report Developer. This
occurs when the reports are being developed in BIRT’s report designer.
To do this, after the developed has completed the code for the report, but before it is ready for importing, the
developer needs to enable the labels for localization. To do this, the practitioner performs the following steps:
43
2. Select the Localization Property.
3. If no values are displayed, click on the Browse button to locate the Resource (properties) file.
4. Select the correct text value from the list of existing values.
5. If a new value is needed, type in the text for the new value and it will be saved to the PropertyFile.
This is shown below. The Work Order Label is highlighted in the Layou t Pane. Only values for ‘page’ and ‘of’
are defined, so a new value for Work Order must be a dded.
The Value of Work Order, with a key of work order , is added. This is added to the resource file.
The next report needing a Work Order Value can re -use the same key value.
44
As the values are added, the properties file is updated. A sample o f the wotrack.properties file is shown
below. The first value on the left is the label key, and the second value on the right is the label value. The
label value is the value that will be translated.
NOTES
A. Property files are application -specific. This means that all reports stored in the SLA Application, for
example, will use the same resource file. This enables common labels to be used by multiple reports.
B. Not every V7 App has reports. Prope rty files are only available “OOB” for those applications that have
reports.
C. If one report design file is stored in multiple applications, it only need s to use one resource file.
Request Pages
Request pages contain both static and dynamic content. Static c ontent includes text on subheaders like
Parameters and Schedule Choices. Dynamic Content includes the variable parameter text.
45
Static Content
When the dialog is generated during the Generate XML process, the MAXMESSAGE table contents are used.
Once the dialog is generated, when the dialog is shown, the MAXLABEL table is used.
NOTE: During the Generate XML process, the MAXLABEL table is populated based on the dialog XML.
For localized database, the Generate XML process would take the localized messages fro m the
L_MAXMESSAGE table and the dialog loader would populate the L_MAXLABEL with the same localized
content as in L_MAXMESSAGE table.
This means that the dialogs need to be generated from every language that we support in order to populate
the L_MAXLABEL table. When the dialog is shown, the L_MAXLABEL values are used.
NOTE: The MAXLABAL and L_MAXLABEL values are overwritten each time the Generate XML operation is
invoked.
Dynamic Content
When the dialog is generated using the Generate XML process, the REPO RTLOOKUP table contents are
used. Once the dialog is generated, when the dialog is shown, the MAXLABEL table is used.
NOTE: During the Generate XML process, the MAXLABEL table is populated based on the dialog XML.
For localized database, the Generate XML process would take the localized messages from the
L_REPORTSLOOKUP table and the dialog loader would populate the L_MAXLABEL with the same localized
content as in the L_REPORTLOOKUP table. This means that the dialogs need to be generated for every
language that we support in order to populate the L_MAXLABEL table. When the dialog is shown, the
L_MAXLABEL values are used.
46
NOTE: the MAXLABEL and L_MAXLABEL values are overwritten every time the Generate XML operation is
invoked.
The chart below shows the process that each setup will go through to ena ble the specified languages in each
client setup.
Yes. Retain Original, create new for Yes. Retain Original, create new for
Create Properties Create report properties No French French, Spanish
jobplan.properties jobplan.properties jobplan.properties
jobplan_FR.properties jobplan_FR.properties
jobplan_SP.properties
A. “Out of the Box” V7 Reports will use the following formatting for consistency:
BIRT offers custom date formattin g. However, due to localization issues, clients are encouraged to use only
Short, Medium, or Long Date/Time formatting for their custom reports.
B. Hyperlinks
47
If a user hyperlinks from one BIRT r eport to another, no additional code is required for localizatio n. The
language code is passed through internal report context and is not passed as part of the hyerlink.
Whether the report is a regular report or a hyperlink report, the report has to go through a single servlet that
knows about the already logged in use r and the user’s locale/languagecode/timezone information. This
information is automatically passed to the BIRT engine or to our scripting code through a framework provided
report context.
C. Fonts
Within the Labels Tab of Report Administration, there is a se ction where the Administrator can specify the
Font Name and Font Size. This functi onality does not apply to BIRT r eports.
If a client wants to change the font of the BIRT r eports to a Unicode or other format, he would change the
Style Sheet used in the Rep ort Library.
The default fonts used in the OOB reports are Arial, Helvetica, Sans -serif.
The font used will depend on what is available on the user’s browser. It will start with Arial ; if that is not
available, it will use Helvetica.
3
Report Modification
Modification of Out-of-the-Box (OOTB) reports is a common practice, and knowledge of how to make these
modifications without breaking the report is critical. Understanding how the reports are structured is critical to
the successful modification effort. F urther knowledge of specialized areas of the report, such as business
logic, plays a key role in successful modification of the report, as well. This section will cover the most
common aspects to modification. The following section will cover advanced conc epts that will aid the
practitioner in the further development and modification of BIRT reports in Maximo.
Report Types
List
The list report is the simplest form of report , and modification of this type of report usually encompasses
adding or deleting columns of data. The sample below is the WOTRACK report:
48
This list of work orders displays several columns of data for each work order. To add columns to this, you
must follow four simple steps. (Details of these steps begin on the next page).
Beginning with the layout view, one can see that there are many columns with components in each of those
columns.
This is a table format for this specific report. The template for the list report starts with a simple table. The
following steps can be used to modify t his report:
49
1. Modify the SQL in the Open Method t o add the new attribute.
Take care to ensure that the Java Script syntax is adhered to in order to avoid introducing an error into the
report.
It is important to review the table on page 16 of the Tivoli Report Developer Guide to ensure that the correct
method is used for the correct data type. The following URL will allow the practioner to access this guide.
http://publib.boulder.ibm.com/infocenter/tivihelp/v3r1/index.jsp?topic=/com.ibm.itmaxam.doc/welcome.htm
50
Focus on the Data set either in the Data Sets tab or in the Outline view. D ouble click on the dataset or choose
Edit from the Right Click menu. The following dialog box will appear:
Go to the last row and type in (or copy from a text editor) the name of the tab. It must match the name as
defined in the fetch method. In addition, the correct data type is required in the last row.
4. Insert a new column to the table and add the new attribute.
Focus on the column that is immediately to the right or left of the area on the report you wish to display the
new data. Right Click and then choose Insert.
If the column is in the middle of the report, there is now problem with choosing either “Column to the Right” or
“Column to the Left”. However, if the data is to be placed at the extreme right of the report (either last or next
to last), please try to use only “Column to the Left.” When the practitioner chooses “Column to the Right,” it
may cause the table to go off the end of the page.
After the column is placed on the report, then the developer can simply drag and drop the newly -created
attribute from the data set onto the desired location in the report.
Sub-Report
Examples of a sub-report type are the Detail reports, such as JOBPLAN, WOPRINT, PO, or PR. These
reports have complex data structures that form the total Job Plan or Work Order, etc.
51
In this example, the Job Plan details report displays the various sub -
components, such as Labor, Materials, Tasks, Service, to the Job Plan.
As shown here, the various tables in the report appear in the detail row.
Notice that this is a single row for all of the sub -reports. Each sub-report relates to a particular data set. This
is called Table Binding.
When the developer focuses on the Table in the Outline view, the layout pane displays the associated
components. When the developer move s the focus to the Binding Tab on the Property Editor, the specifics of
the table binding are displayed. For each table, the developer establishes which data set is bound to that
52
table. The tables are executed in descending order, from top to bottom. This is more readily displayed in the
layout view, as shown on the previous page.
NOTE: The developer uses this tab to create specific table bindings that are not in the data set. Click on ADD,
then create the desired binding.
In this case, the binding jpke y was added to the table binding.
The New Data Binding Column allows the practitioner to enter a Name, Data Type, and Expression.
53
The ellipsis button launches the Expression builder.
Here, the developer enters the desired expression. This value entered will be discussed in the next section on
Grouped Reports.
Grouped
Using the same report to demonstrate grouping, when the practitioner reviews the Groups section of the
outline, the details are displayed in the Group’s diaglog box.
54
In the Group On drop down box, available elements from the table binding allow the developer to select how
the data will be grouped. Page Breaks for Befor e and After are determined in this dialog box, as well.
The use of internals allows the grouping to use additional characteristics of the value chosen. For example, if
the group on key was a date attribute, then the interval could be by Day, Week, Month, Q uarter, etc.
The TOC Item Expression for the Table of Contents feature in the Web Viewer and the Filtering and sorting
within the group may also be set by the developer in this dialog box.
4
Summary of Custom Report Functions
IBM created the following fu nctions (methods) in order to integrate BIRT fully into the TPAE framework. By
carefully reading this section, and referring to it as needed, the practitioner will successfully deploy these
methods in customer reports and report modification to existing bu siness logic. A short synopsis for each
method helps the practitioner understand the usage and context of each method.
55
MXReportSqlFormat.class Methods
The following methods aid the practitioner in manipulating the SQL that is passed t o the database when the
report is executed.
The myStatus parameter is populated by the user through a request page parameter set up in Maximo.
getCurrentDateFunction()
This function returns the current system date from the server
Usage: getCurrentDateFunction()
Result: Friday July 24, 2009
getCurrentTimestampFunction()
This function returns the current system time from the server
Usage: getCurrentTimestampFunction()
Result: 4:12 PM
56
getDouble(string)
This is used in the fetch method to populate the row variable with the data from the data set open method.
getEndDayTimestamp(Date d)
This function takes the value from the output to the above function and when used in the SQL Text portion of
a data set method formats the value to be used in the SQL call to the database
getEndDayTimestampFunction(Date d)
getStartDayTimestamp(Date d)
This function is used in a method where the developer wants to format a variable into a meaningful format to
be used later in the SQLof a data set call.
getTimestampFunction(Date d)
This function takes the value from the output to the above function and when used in the SQL Text portion of
a data set method formats the value to be used in the SQL call to the database
57
MXReportTxnProvider.create(“maximoDataSource”);
This method is used to create a data set that will receive an update statement. This is a typical way of
doing this.
Usage: myTxn = MXReportTxnProvider.create("maximoDataSource");
Result: A NEW data source artifact is created in memory. It is available for later processing.
5
Sample Usage of Methods
This section gives the practitioner a few samples (taken from existing reports) on how to implement the
methods outlined in the previous se ction.
if(params["paramstring"] == "update"){
request = reportContext.getHttpServletRequest();
if(request != null){
session = request.getSession();
updated = session.getAttribute("costrollup_update_status");
}
}
The initial report will have calculations (usually) in the Fetch method and will then create update statements
that are stored in the session. The actual update report is then called from a push button located on the initial
report, which then calls the stored session i nformation and processes it.
Open Method
Conditional logic used in the open method determines which database syntax to use. Below is a useful syntax
for conditional logic example:
maximoDataSet = MXReportDataSetProvider.create(this.getDataSource().getName( ),
this.getName());
maximoDataSet.open();
if(maximoDataSet.isSQLServer()){
assetDescription = " asset.assetnum + char(10) + asset.description ast, ";
}else assetDescription = " asset.assetnum || chr(10) || asset.description ast, ";
Create the various needed data sources for the update statements.
58
myTxn = MXReportTxnProvider.create("maximoDataSource");
matTxn = MXReportTxnProvider.create("maximoDataSource");
labTxn = MXReportTxnProvider.create("maximoDataSource");
servTxn = MXReportTxnProvider.create("maximoDataSource");
toolTxn = MXReportTxnProvider.create("maximoDataSource");
maximoDataSet.setQuery(sqlText);
Fetch Method
Typically, the Fetch method is used to process business logic on a row -by-row basis. In the Asset Cost Roll -up
report, various components of each asset’s cost is calculated, totaled, and displayed.
if (!maximoDataSet.fetch())
return (false);
validatedRecord = false;
while (!(validatedRecord)) {
labcost = 0;
matcost
= 0;
servcos
t = 0;
toolcos
t = 0;
// Lab Cost
labcostDataSet = MXReportDataSetProvider.create(this.getDataSource().getName(),
"labcostDataSet");
labcostDataSet.open();
if(labcostDataSet.fetch()) {
labcost = labcost + labcostDataSet.getDouble("linecost");
}
// End Lab Cost
if(childlabcostDataSet.fetch()) {
labcost = labcost + childlabcostDataSet.getDoubl e("linecost");
}
// End Child Lab Cost
59
Total Cost calculated.
if (temptotalcost > 0) {
row["ast"] = maximoDataSet.getString("ast");
row["totalcost"] = maximoDataSet.getDouble("totalcost");
.....
validatedRecord = true;
myStmt = myTxn.createStatement();
myStmt.setQuery("update asset set totalcost = " + row["newtotalcost"] + ", ytdcost =
" + row["newytdcost"] + " "
+ " where assetuid=" + maximoDataSet.getInteger("assetuid"));
Using the various data sources created in the open Method, set the update SQL here:
matUpdtStmt = matTxn.createStatement();
sqlStmt = "update matusetrans set matusetrans.linecost = 0 where "
.....set your SQL statement here.....
matUpdtStmt.setQuery(sqlStmt);
session.setAttribute("TxnMatUpdate", matTxn);
labUpdtStmt = labTxn.createStatement();
sqlStmt = "update labtrans set labtrans.linecost = 0 where "
.....set your SQL statement here.....
labUpdtStmt.setQuery(sqlStmt);
session.setAttribute("TxnLabUpdate", labTxn);
servUpdtStmt = servTxn.createStatement();
sqlStmt = "update servrectrans set servrectrans.linecost = 0 where "
.....set your SQL statement here.....
servUpdtStmt.setQuery(sqlStmt);
session.setAttribute("TxnServUpdate", ser vTxn);
toolUpdtStmt = toolTxn.createStatement();
sqlStmt = "update tooltrans set tooltrans.linecost = 0 where "
.....set your SQL statement here.....
toolUpdtStmt.setQuery(sqlStmt);
session.setAttribute("TxnToolUpdate", toolTxn);
}
else {
if (!maximoDataSet.fetch())
return (false);
}
} //end while
60
// Compare YTD Current with YTD Dynamic (if same do nothing, otherwise display record)
return (true);
beforeClose Method
This method properly closes all of the temporary data sets opened in the processing of the report.
if(params["paramstring"] != "update"){
request = reportContext.getHttpServletRequest();
if(request != null){
session = request.getSession();
myTxn = session.getAttribute("TxnUpdate");
matTxn = session.getAttribute("TxnMatUpdate");
labTxn = session.getAttribute("TxnLabUpdate");
servTxn = session.getAttribute("TxnServUpdate");
toolTxn = session.getAttribute("TxnToolUpdate");
if(myTxn != null && matTxn != null && labTxn != null && servTxn != null && toolTxn != null){
myTxn.save();
matTxn.save();
labTxn.save();
servTxn.save();
toolTxn.save();
updated = true;
session.setAttribute("costrollup_update_status", true);
myTxn = null;
matTxn = null;
labTxn = null;
toolTxn = null;
servTxn = null;
session.setAttribute("TxnUpdate", null);
session.setAttribute("TxnMatUpdate", null);
session.setAttribute("TxnLabUpdate", null);
session.setAttribute("TxnServUpdate", null);
session.setAttribute("TxnToolUpdate", null);
}else{
session.setAttribute("costrollup_update_status", false);
}
}
}
61
Other Methods
Initialize Method
The templates override the initialize method to introduce the script context classes.
importPackage(Packages.com.ibm.tivoli.maximo.repor t.script);
Using the Job Plan Report (jobplan.rptdesign) the practitioner sees that a good example of code is as follows:
importPackage(Packages.com.ibm.tivoli.maximo.repor t.script);
return hlink;
}
Notice that a function is cr eated here and is referenced through out the report. A key thing to note here is how
the debugging is set up. The blue text indicates the debug level, as well as the target for the report.
importPackage(Packages.com.ibm.tivoli.maximo.repor t.script);
mxReportScriptContext.setDefaultLogLevel( "DEBUG");
mxReportScriptContext.setDefaultLogFile( "C:/temp/cah_ar2_case_resolution_type.l o
g");
In this example, a global variable is created. This allows the practitioner to set and access a variable that has
global scope but is NOT a parameter. This is important in that a report parameter will be imported into the
Maximo framework during the “Report Import” process, whereas the global variable will not.
63
afterFactory
The afterFactory method has this standard code in the template:
MXReportScriptContext .close();
The process automation engine passes the logged -in user’s credentials to the report engine at runtime as a
part of a number of different parameters. The user’s ID (username) can then be used in the following method
to get the PERSON record’s DISPLAYNAME attribute.
userDispNameDataSet = MXReportDataSetProvider.create(this.getDataSource().getName(),
"userDispNameDataSet");
userDispNameDataSet.open();
userDispNameDataSet.setQuery(userDispNameSQL);
if(userDispNameDataSet.fetch()) {
params["displayname"] = userDispNameDataSet.getString("displayname");
}
userDispNameDataSet.close();
The parameter “username” must be added to the report along with the parameter “displayname” (as indicated
below) in order for this to work.
64
6
Reporting Best Practices
This section describes what practitioners should consider as standards and techniques that define the most
appropriate manner in which custom r eports should be developed to best integrate th em with the standard
OOTB reports from IBM.
Practice and care is required in order to ensure that custom and modified reports properly reference the
objects stored and/pr modified in the updated library. When changes are made in the library file, any logos
used in the updated library must be re-imported. Otherwise, the images do not render correctly.
Standardized Functionality
Common Methods and Techniques
The code that is delivered with several reports enables consistency across similar applications. For example,
the WORINT.RPTDESIGN file is used in “clone” applications (i.e. QUICK, WOACTIVITY, and WOCHANGE
are all clones of WOTRACK). As such, the common report amongst those applications is a single report that
uses the appName parameter that is established in the Maximo Templates.
Similarly, the SR, INCIDENT, and PROBLEM applications’ reports all rely on the und erlying TICKET object
rather than each applications’ view. The standardized code in these reports enables any report developed for
the TICKET object to be used in any application whose main object is based on the TICKET object.
With the above statements made, the practitioner is strongly advised to create reports for the above
applications using the standards as set forth in the code in these reports.
For example: The TICKET.RPTDESIGN report uses a global variable defined in the initialize method to allow
the report to look to the application ’s “MAINTABLE” value in the MAXAPPS object. A function in the main data
set “open” method then obtains this information and re places the Application’s value with “ticket;” thereby,
modifying the SQL where clause to work against the TICKET object instead of SP, PROBLEM, or INCIDENT.
2. Allow the clients to use the existing code as t emplates for further report development
As such, the well-informed practitioner will use the existing reports as a model for further report development.
Examining existing reports for code examples is not only suggested, but also strongly recommended.
65
The following reports have code s that are great samples for practitioners to use:
jobplan.rptdesign
o hyperlink function
ticket.rptdesign
ticketprint.rptdesign
woprint.rptdesign
wotrack.rptdesign
o hyperlink function
inventory_rop.rptdesign
inventory_eog_tbl.rptdesign
asset_costrollup.rptdesign
The designers of these reports took different approa ches in some of these techniques such that some of the
samples do the same thing but with a different style. These samples will enable the practitioner to develop his
or her own style but still have the reports work effectively within the TPA E
66
1