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® Manage 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, the MXPO object structure provides the irData element to the MYPO publish channel for processing. An automation script is configured to run on the external exit class of the publish channel. A literal value, world, is defined as an input variable on the automation script. The script queries the irData element for purchase orders that contain purchase order lines. The script numbers each purchase order line in a sequence that starts at 1, sets hello as the value in the description field, and adds the input variable from the automation script. The script updates the parent purchase order before the erData element is constructed and forwarded to the external system.
lines = irData.getChildrenData("POLINE")
i = 0
if lines is not None:
for value in lines:
++i
irData.setAsCurrent(lines,i);
irData.setCurrentData("DESCRIPTION","hello"+world)
irData.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