February 26, 2012

Best way to loop through an MboSet

This entry is part of the Maximo Java Development series.

In this article I will describe some common ways of iterating through an MboSet and what is the best approach.
In the following examples mboSet is the already holding the MboSetRemote that you need to traverse.

Example 1 (worst solution)

for(int i=0; i<mboSet.count(); i++;)
{
    MboRemote currMbo=mboSet.getMbo(i);
    ...
}

The MboSet.count() method will issue a SELECT COUNT(*) query to the database for each loop. This will seriously affect the looping performances with an unnecessary workload on the database server too.

Example 2 (good solution)

MboRemote currMbo=null;
for(int i=0; (currMbo=mboSet.getMbo(i))!=null; i++)
{
    ...
}

This is a good approach from a performance point of view. However, I'm a Java-purist so I'm still not fully satisfied in terms of code style.

Example 3 (best solution)

for(MboRemote currMbo=mboSet.moveFirst(); currMbo!=null; currMbo=mboSet.moveNext())
{
    ...
}

Very concise syntax. Inline declaration of MboRemote object. Iterator style. Index variable i no longer needed. Perfect :-)

February 19, 2012

Formatting and converting data in Java

This entry is part of the Maximo Java Development series.

If you need to format dates and numbers into a locale-sensitive string or if you just need to convert data between different types then take a look at psdi.util.MaxType class.
For example, the following piece of code shows how to correctly format a currency amount into a string.
MaxType mt = new MaxType(MaxType.AMOUNT);
mt.setValue(10.1234);
String s = mt.asLocaleString();

February 17, 2012

Automatic login to Maximo UI

As a Maximo consultant I spend many hours on test and development systems developing customizations and testing business processes. This means I frequently login on Maximo Web UI with several users and passwords.
I typically store the passwords in my web browser to speedup the annoying step but today I have found a better trick to directly jump into a Maximo application skipping the login page. This can be done providing the username and password in the URL used to connect to the web UI. Lets make some examples.
  • Connect to the Start Center as wilson
    http://mxhost/maximo/ui/login?login=url&username=wilson&password=wilson
  • Connect to the Work Order Tracking application as wilson
    http://mxhost/maximo/ui/login?login=url&username=wilson&password=wilson&event=loadapp&value=wotrack
Just replace the tags in the previous URLs with your hostname, application, username and password.

There is only one drawback with this solution... security. Your admin password will be stored in plain text in your browser's bookmarks and will remain visible in the address bar throughout the session.
See Maximo URLs for more Maximo http shortcuts.

February 15, 2012

How to migrate Maximo Administrative Workstation

This article explains a procedure that can be used to migrate the Maximo 7.1 Administrative Workstation from one physical system to another.

Installation of products based on Maximo/TPAE infractructure (MAM, TAMIT, CCMDB, etc.), industry specific extension (Nuclear, Transportation, etc.) or fixpacks use the IBM Autonomic Deployment Engine. This is installed at the beginning of the installation of any Maximo product and is a core part of the Maximo Administrative Workstation component.

The official procedure to migrate the Administrative Workstation requires that target system must host the same operating system and major version as the original administrative system. I haven't tested this procedure but it seems to lack some important steps.

In my opinion a better approach is the following:
  1. Start any Maximo installer on the new server than install ADE and stop before performing the installation. Check under C:\Program Files\ibm\common\acsi to see when ADE is deployed.
  2. Check the version of ADE against the existing installation.
    1. From command prompt change to C:\Program Files\ibm\common\acsi directory.
    2. Run setenv command.
    3. Run de_version to check ADEs version.
  3. Copy the SMP folder (typically C:\IBM\SMP) to the new server.
  4. Run de_backupdb on the old server.
  5. Copy the backup file to the new server.
  6. Run a de_restoredb on the new server.
  7. Update the configuration of the new server setting the new hostname with de_chghostname command.
ADEs documentation links:

NOTE: This is non an official IBM technote. Use at your own risk.

February 14, 2012

February 12, 2012

Set an attribute as required with no default value

This post describes how to set an object attribute as mandatory without providing a default value. This is to circumvent what it seems to be a TPAE limitation that prevents to do this from the standard Database Configuration application.
Lets make an example. The out-of-the-box attribute PO.VENDOR (Purchase Order - Vendor) is not mandatory. Unfortunately if you try to set as required using the Database Configuration application you will get the following error.


However, if you look into other PO attributes you will find many of these (CHANGEBY, ORGID, etc.) that are defined as required but have no default value. This means that Maximo is internally capable of handling this case.
To circumvent this restriction I use the procedure described hereafter.

Ensure there are no null values in the desired field. This is important because otherwise the configdb will fail with the error: Assignment of a NULL value to a NOT NULL column "VENDOR" is not allowed.
These are two sample SQL statements that can be used to check null values and to set a dummy value in these rows.
select * from PO where VENDOR is null;
update PO set VENDOR='...' where VENDOR is null;

Set the attribute and provide a dummy default value using the Database Configuration. Save your changes without applying the configuration. Do not run configdb!
Locate the PO.VENDOR row in the MAXATTRIBUTECFG table and clean the DEFAULTVALUE field.
Refresh the Database Configuration list view and check the definition of the PO.VENDOR attribute. It should now be listed as 'To be changed' and defined as required but without a default value.
Run configdb script of apply the configuration changes using the action menu.
Now open the Purchase Orders application and you will see the Company field marked with an asterisk.


NOTE: I have used this procedure many times but I do not guarantee it always works on every possible database server. Never do this in a production environment without testing it on your development environment!

February 11, 2012

How to configure data import in Maximo 7.5

In version 7.5 of Maximo/TPAE products, you can import and export data from applications. Learn how to enable this feature in this unofficial guide.
There is also a nice TechNote from IBM.

February 10, 2012

Troubleshooting Birt report performances

Sometimes I had the hard task to debug performance issues of specific Maximo reports. The main thing to understand here is that 95% of the times the problem is related to a long execution time of the underlying SQL query .
What I typically do is the following:
  1. Look at the 'Performance' tab of the Report Administration application and take note of the 'Last Run Duration'.
  2. Configure an Eclipse Birt Designer environment to run the reports against the production database.
  3. Import the report into Eclipse.
  4. Change the rptdesign to log in a local file: mxReportScriptContext.setDefaultLogFile("D:/birtreport.log");
  5. Add a row to print the SQL query into the log file: mxReportScriptContext.getReportScriptLogger().debug(">>> sqlText=" + where);
  6. Run the report within Eclipse.
  7. Copy and paste the SQL query from the birt log file into a SQL client and try to execute the query straight to the database.

After this you have many elements to understand what may be the problem. First you need to find the cause performance issue and then work out the solution. Here are some examples:
  • Long runng SQL query: The problem is in the database query or poor database server performance. Generate the query access plan and analyze the results. You can typically solve this issue creating one or two appropriate indexes. Here you may need excellent SQL skills. Do not improvise. Shout for some help from an SQL techie.
  • SQL performances are good but Maximo is slow generating the report. This may be caused by a performance problem on the application server or a slow nettwork connection.
  • One typical problem that I have seen many times is the HTTP timeout. If the report doesn't appear in the viewer but you see a reasonable execution time in Report Administration than you have to tweak your HTTP server configuration.
I wish you a merry debugging  :-)