Custom Java Action Class Example
Custom Java Action Class Example
July 19, 2013
This entry is part of the Maximo Java Development series.
In a previous post I have described how create a custom action class using Java.
Here is a full example that can help to understand how to navigate objects and set values.
package cust.psdi.app.workorder;import java.rmi.RemoteException;import psdi.common.action.ActionCustomClass;import psdi.mbo.MboConstants;import psdi.mbo.MboRemote;import psdi.mbo.MboSetRemote;import psdi.util.MXException;/** * Sets the Workorder description with a new one obtained concatenating the * following related descriptions: * - :JOBPLAN.DESCRIPTION * - :PM.LOCATIONS.DESCRIPTION * - :PM.ASSET.DESCRIPTION * * @author Bruno Portaluri */public class ActionSetDescriptionFromPm implements ActionCustomClass{ public ActionSetDescriptionFromPm() { super(); } public void applyCustomAction(MboRemote mbo, Object[] params) throws MXException, RemoteException { String desc = ""; // Get the description of the Job Plan MboSetRemote jp = mbo.getMboSet("WO_JOBPLAN"); if (jp.getMbo(0)!=null) { desc = desc + jp.getMbo(0).getString("DESCRIPTION"); } // Get the description of the Job Plan MboSetRemote pm = mbo.getMboSet("WO_PM"); if (pm.getMbo(0)!=null) { // Get the description of the PM's Location MboSetRemote locations = pm.getMbo(0).getMboSet("LOCATIONS"); if (locations.getMbo(0)!=null) { desc = desc + " - " + locations.getMbo(0).getString("DESCRIPTION"); } // Get the description of the PM's Asset MboSetRemote asset = pm.getMbo(0).getMboSet("ASSET"); if (asset.getMbo(0)!=null) { desc = desc + " - " + asset.getMbo(0).getString("DESCRIPTION"); } } // Truncates to fit the field length desc = desc.substring (0, 100); System.out.println("Setting WO's " + mbo.getString("WONUM") + " description:" + desc); mbo.setValue("DESCRIPTION", desc, MboConstants.NOACCESSCHECK|MboConstants.NOVALIDATION_AND_NOACTION); }}