Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only

Expanding Maximo Formulas

By Nivin Jacob George posted Fri January 22, 2021 08:45 AM

  

Maximo Formulas were introduced from Version 761, which has been a powerful feature when it comes to using basic Excel-like grammar to define expressions that use input from variables to calculate a value.

The existing formulas may not be utilized when it comes to the need of the customer who may require special calculations and values that cover a specific business process. This document describes in brief, an option to expand the footprints of the Maximo formulas by creating new Formula functions and thereby using it to output a value.

New formula functions can be registered under Add/Modify Formula Function, from Database Configuration Application.

Each function name is controlled by a Java class. So, we create our own java class using the Maximo class that defines these functions. An example of a java class created to get the current year from a date is displayed below:

------------------------------------------------------------------------------------------------------------------------------------------

package custom.util;

 

import com.ibm.tivoli.maximo.expression.Expression;

import com.ibm.tivoli.maximo.expression.Function;

import custom.app.financial.FinancialServiceExtRemote;

import psdi.util.MXException;

import java.math.BigDecimal;

import java.rmi.RemoteException;

import java.util.Date;

import java.util.List;

import psdi.server.MXServer;

import psdi.util.logging.MXLogger;

 

public class CURRENTYEAR extends Function { 

               public CURRENTYEAR(Expression exp, String name, int numParams) {

                              super(exp, name, numParams);

               }              

               public BigDecimal eval(List parameters)

    {

        long targetTimeInMillis = 0L;

        int currentYear = 0;

        try

        {

            targetTimeInMillis = MXServer.getMXServer().getDate().getTime();

            FinancialServiceExtRemote fsr = (FinancialServiceExtRemote) MXServer.getMXServer().lookup("FINANCIAL");

                              currentYear = fsr.getCurrentFinancialYear();

        }

        catch(RemoteException e)

        {

            Expression.EXPLOGGER.error(e.getMessage(), e);

        }       

        catch(MXException e)

        {

            Expression.EXPLOGGER.error(e.getMessage(), e);

        }

        return new BigDecimal(currentYear, getExpression().getMathContext());

    }

              

}

 

The class is compiled and deployed to the Maximo class folder and run buildmaximoear.bat.

Restart the Maximo server and navigate to Database Configuration to register the new function.

Name: CURRENTYEAR

Parameters: 0 (since it is programmed to return the year from system date)

Apply the formula to a Non-Persistent Attribute. In our example, we take WORKORDER Object and non-persistent field: PLUSGPREVDEFCOUNT.

 

Add the field to Work Order Tracking Application.


 

Create a new work order

The non-persistent field displays the current year.

In this manner, the capabilities of the Maximo Formula can be expanded to deliver solutions that can be utilized from a single source and utilized in multiple areas.


#MaximoIntegrationandScripting
#AssetandFacilitiesManagement
#Maximo
1 comment
91 views

Permalink

Comments

Wed August 11, 2021 03:55 PM

Thanks!

Do you know if we could use automation scripts for this, instead of custom Java classes, if we wanted to?