IBM Support

Total cost is not updated

Troubleshooting


Problem

In IBM Maximo Health, IBM Maximo Predict, and IBM Maximo Health and Predict - Utilities, if you run a report in your other enterprise asset management (EAM) system to calculate the total cost value for work orders, the value is not updated for assets in the applications or industry solution.

Resolving The Problem

  1. In the application or industry solution, create a TOTALCOST cron task. In the Description field, specify Total Cost Update Cron.
  2. Set the following class name: com.ibm.tivoli.maximo.script.ScriptCrontask
  3. Create an instance and set a frequency, for example, once a day. 
  4. For the SCRIPTNAME parameter value, specify TOTALCOST. TOTALCOST is an automation script that is created in step 7. 
  5. For the SCRIPTARG parameter value, specify the name of an OSLC query that exists in your Maximo EAM system. This query is used to retrieve asset's total cost and update the corresponding total cost in the application or industry solution. If the parameter value is null, all asset's total costs are retrieved, which can impact performance.
  6. Save the cron task definition.
  7. In the Automation Script application in the application or industry solution, in the More Actions menu, create a new script by selecting Create > script option.
  8. For the Script name, specify TOTALCOST. For Description, specify Total Cost Automation Script.
  9. For the language, select Python.
  10. Paste the following script and click Create.
    from java.lang import String
    from java.lang import System
    from java.lang import Exception
    from java.util import HashMap
    from java.net import URLEncoder
    from java.nio.charset import StandardCharsets
    from com.ibm.json.java import JSONObject
    from psdi.server import MXServer
    from psdi.iface.router import Router
    from psdi.mbo import MboConstants
    handler = Router.getHandler("TOTALCOST")
    url = handler.getUrl()
    if arg is not None and len(arg) > 0:
        arg = URLEncoder.encode(arg, StandardCharsets.UTF_8.toString())
        url = handler.getUrl()+"&savedquery=\""+arg+"\""
    map = HashMap()
    map.put("HTTPMETHOD", "GET")
    map.put("URL", url)
    responseBytes = handler.invoke(map, None)
    jsonObject = JSONObject.parse(String(responseBytes))
    assets = jsonObject.get("member")
    for asset in assets:
        mxServer = MXServer.getMXServer()
        assetSet = mxServer.getMboSet("ASSET", runAsUserInfo)
        assetSet.setQbe("assetnum", asset.get("assetnum"))
        assetSet.setQbe("siteid", asset.get("siteid"))
        existingAsset = assetSet.getMbo(0);
        if existingAsset is not None:
            try:
                existingAsset.setValue("totalcost", asset.get("totalcost"), MboConstants.NOACCESSCHECK)
                assetSet.save()
            except Exception as ex:
                System.out.println("TOTALCOST Automation Script- problem saving totalcost for asset: " + asset.get("assetnum") + " siteid: " + asset.get("siteid"))
                System.out.println("Exception message: " + ex.getMessage())
            finally:
                assetSet.close()
  11. In the End Point application, create a new endpoint.
  12. For the name, specify TOTALCOST and select HTTP Handler.
  13. For the HEADERS property, specify an API key.
  14. For the HTTPMETHOD property, specify GET and ensure that Allow override is selected. 
  15. Set the URL as the URL of the Maximo EAM system and ensure that Allow override is selected.
  16. Save the endpoint.
  17. In the Cron Task Setup application, open the TOTALCOST cron task.
  18. Select the Active checkbox to activate the cron task.
  19. Select Reload request.
Wait for the cron to run and then check whether the asset's total cost values are updated. If the total cost values are not updated, check the logs and fix the problem.

In step 10, the Python script is a simple script that uses OSLC query available in the Maximo EAM system. This script retrieves the total cost value for assets that match the query and updates each corresponding asset in the application or industry solution. You can set one cron task instance for each separate OSLC query.

Document Location

Worldwide

[{"Type":"SW","Line of Business":{"code":"LOB59","label":"Sustainability Software"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSRHPA","label":"IBM Maximo Application Suite"},"ARM Category":[{"code":"a8m0z000000cxN3AAI","label":"Maximo Health"},{"code":"a8m0z000000cxN8AAI","label":"Maximo Predict"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"8.2.0;8.3.0;8.4.0"}]

Document Information

Modified date:
27 July 2021

UID

ibm16453733