Examples of using automation scripts during processing by channels and services

Channel and service processing takes a data record from the source system as an input value, manipulates the data as required, and constructs a data record for the target system. The example python scripts query input data and provide logic to manipulate the data before the output data is constructed.

When Maximo® Asset Management starts an integration transaction, the object structure provides an internal record data (irData) element to a publish channel or an invocation channel. Processing manipulates the irData element and constructs an external record data (erData) element before the message is forwarded to its destination. Invocation channel transactions can require a response from the external system. Response processing passes the erData element to the invocation channel, which manipulates the response data and constructs the irData element.

When an external system starts an integration transaction, the message provides an erData element to an enterprise service. Processing manipulates the erData element and constructs an irData element before the message is forwarded to the associated object structure. For messages that require a response, the object structure provides the irData element to the enterprise service. Processing manipulates the data and constructs the erData element that is forwarded to its destination.

The examples consist of simple scripts that can be used for test purposes. You can use the data import and data export features in the External Systems application to start transactions to test scripts.

Example: Script that changes the description of operating assets on outbound transactions

In this scenario, the MXASSET object structure provides irData to the MYASSET publish channel for processing. An automation script is configured to run on the external exit class of the publish channel. The script checks the status of the asset in the irData element. If the asset is in operating status, the script inserts a value in the description field and prints a message to the log file. The erData element is then constructed and is forwarded to the external system.

if irData.getCurrentData("STATUS") == 'OPERATING' :
   irData.setCurrentData("DESCRIPTION","hello")
   print "MYASSET description change"

Example: Script that changes the description of operating assets on inbound transactions

In this example, the MYASSET enterprise service processes an inbound message for the MXASSET object structure. An automation script inserts a script on the external exit class of the enterprise service. The script checks the status of the asset in the erData element. If the asset is in operating status, the script inserts a value in the description field and prints a message to the log file. The irData element is then constructed and is forwarded to the associated object structure for processing.

if erData.getCurrentData("STATUS") == 'OPERATING':
   erData.setCurrentData("DESCRIPTION","hello inbound")
   print "MYASSET inbound description has changed"

Example: Script that changes the description of lines on a purchase order by using an automation script variable

In this example, which will work for JSON and XML, getChildrenData() iterates over the children of a specified parent object to perform some action on each child object of the parent. getChildrenData() obtains the list of child objects. It iterates on the list of child objects to perform a specified action. setParentAsCurrent() sets the current object to its parent.

List childData = strucIn.getChildrenData(childMapInfo.getObjectName());
  if (INTEGRATIONLOGGER.isDebugEnabled())
  {
      INTEGRATIONLOGGER.debug("Creating new object for sibling: " + childMapInfo.getObjectPath());
  }
  Iterator itr = childData.iterator();
  while (itr.hasNext())
  {
      StructureObject subLevel = (StructureObject) itr.next();
      if (subLevel == null)
      {
          //no data existed for this level, or it might have been skipped
          continue;
      }
      strucIn.setAsCurrent(subLevel);
      //do processing here
   }
   strucIn.setParentAsCurrent();

Example: Script that skips transactions based on the status of records

In this example, the MXPO object structure is sent to the MYPO2 publish channel for processing. An automation script is configured to run on the user exit class before the external exit class runs. The script queries the irData element for purchase orders with a status of WAPPR and skips the processing of these purchase orders.

if irData.getCurrentData("STATUS") == 'WAPPR' :
   errorgroup = "iface"
   errorkey ="SKIP_TRANSACTION"

Example: Script that prints transaction information to a log file to assist with troubleshooting

In this example, the MXASSET object structure provides irData to the MYASSET2 publish channel for processing. An automation script is configured to run on the external exit class. The script queries the irData element for assets with a status of operating, prints transaction information to a log file, and constructs the erData element without making any changes. To print information about the transaction, you must set logging to debug. In the Logging application, the logger is set to automation scripts and the logging level is set to DEBUG. In the Automation Scripts application, the logging level for the script is set to DEBUG.

if irData.getCurrentData("STATUS") == 'OPERATING' :
   print "Test script
      variable VAR_EXIT_IFACETYPE  " + ifaceTypeprint "Test script
      variable VAR_EXIT_IFACENAME  " + ifaceNameprint "Test script
      variable VAR_EXIT_EXTSYSTEM  " + extSystemprint "Test script
      variable VAR_EXIT_MESSAGETYPE  " + messageTypeprint "Test script
      variable VAR_EXIT_EXTSYSTEM  " + extSystemprint "Test script
      variable VAR_EXIT_OSNAME  " + osNameprint "Test script

When an asset is exported, the following debugging information is printed to a log file:

18 Mar 2014 11:35:06:877 [DEBUG] [MXServer] [CID-MXSCRIPT-2022] execution completed 
for cached compiled script PUBLISH.MYASSET.EXTEXIT.OUT for launch point null 
Test script variable VAR_EXIT_IFACETYPE MAXIMO
Test script variable VAR_EXIT_IFACENAME MYASSET2
Test script variable VAR_EXIT_EXTSYSTEM MYEXTSYS
Test script variable VAR_EXIT_MESSAGETYPE Publish
Test script variable VAR_EXIT_OSNAME MXASSET


Feedback