This article opens Part 5, about integration scripts. We checked IBM’s integration pages against the behaviour of Manage in the MAS 9.2 series, and we checked the methods of IBM’s examples on our test system. Where the pages and Manage disagree, this page follows Manage.
Found by name#
The Automation Scripts application creates integration scripts through a wizard: Create, then Script for Integration. The wizard builds the name from your choices, and that name is the only link between the script and its object structure, channel or service. Neither IBM page lists the names:
| Script point | Name Manage looks for |
|---|---|
| Object structure, inbound processing | OSIN.<STRUCTURE> |
| Object structure, outbound definition | OSOUT.<STRUCTURE> |
| Publish channel, event filter | PUBLISH.<CHANNEL>.EVENTFILTER |
| Publish channel, external exit | PUBLISH.<CHANNEL>.EXTEXIT.OUT |
| Enterprise service, external exit | <MESSAGETYPE>.<SERVICE>.EXTEXIT.IN, the response .OUT |
| Invoke channel, request and response | INVOKE.<CHANNEL>.EXTEXIT.OUT and .IN |
| REST query and action | OSQUERY.<STRUCTURE>.<QUERY>, OSACTION.<STRUCTURE>.<ACTION> |
The user exits use the same names with USEREXIT in place of EXTEXIT, and one more part for the
moment: USEREXIT.OUT.BEFORE, USEREXIT.OUT.AFTER, USEREXIT.IN.BEFORE and USEREXIT.IN.AFTER.
Three details decide whether the name matches:
- Upper case. The names are stored in upper case.
- The message type is part of the name. A publish channel uses its own message type, which is
normally Publish. A channel with another message type looks for another name than the wizard
wrote. An enterprise service starts with its message type, for example
SYNC.. - Endpoints are different. An endpoint names its script in a property. Article 20 covers them.
The order of the exits#
On the way out, the event filter runs before anything is serialized, so it is the cheap place to drop an event. The exits get the serialized message, so dropping data there costs the serialization first. On the way in, the exits run before the processing class.
The exits run once for each enabled external system of a channel. service.raiseSkipTransaction()
skips the message for that one system, and the loop goes on with the next. In an enterprise service,
the same call ends the message quietly.
What each exit sees#
Two variables carry the message: irData, the internal format of Manage, and erData, the external
format.
| Exit | Way out | Way in |
|---|---|---|
| Before user exit | irData only | erData only |
| External exit | irData; erData is None and the script fills it | erData; irData is None and the script fills it |
| After user exit | both: erData is the external exit’s result | both: erData is the original input |
Two shortcuts help. On the way out, an external exit can change irData and leave erData empty;
the changed irData is then sent. On the way in, an external exit that leaves irData empty passes
erData on unchanged.
The exits also get ifaceType, ifaceName, osName, messageType, extSystem and userInfo.
The external exit also gets conn, a database connection that is freed when the exit returns. Invoke channel exits get
messageType Invoke and extSystem None.
The user exits get one more: beforeExtExit. On the way in it is true in the before exit and false in
the after exit. On the way out the two values are swapped. Each exit is a script of its own, so the
script already knows where it runs, and the flag is best left alone.
Traps that apply to every integration script#
JDOM 2. Manage 9.2 uses JDOM 2, in the package org.jdom2. IBM’s examples import org.jdom.
On our test system, from org.jdom import Element failed with “No module named jdom”. Import
Namespace and Element from org.jdom2.
The Interface flag. Object structure scripts and endpoint exits work through named functions,
and Manage calls such a function only when the script has the Interface flag. Manage sets the flag by
itself only for new scripts whose names start with OSIN., OSOUT. or LIB.. For any other
callback script, set it yourself. Otherwise the source runs once from top to bottom, and no function
is called. Inside such a function, the global service does not exist. Use the object the function
receives, which offers the same methods.
The class field. Saving an exit script fills in the script exit class on its channel or service when that field is empty. A channel that already names another class refuses the save.
Enterprise services#
An enterprise service turns an external message into the internal format. Three corrections to IBM’s examples:
- Reading XML.
erData.getData()returns a JDOM 2 document. TheNamespaceforgetChildTextmust come fromorg.jdom2. - Reading JSON.
OslcUtils.bytesToJSON(erData.getOriginalByteData())gives the JSON object, as IBM shows. - Setting a number. IBM’s after user exit calls
irData.setCurrentDataAsInt. That method does not exist; on our test system it was missing. UseirData.setCurrentData("wopriority", 1).
Invoke channels#
An invoke channel calls an external system and can map the answer back. The request exits run on the way out, and the response exits run on the way in, but only when the channel has “process response” set.
A request exit can add query parameters to the call: a map under HTTPHandler.HTTPGET_URLPROPS,
stored as the ENDPOINTPROPS property of the current integration context. IBM’s guide shows the full
code. The IBM Docs copy stops before the line that stores the map, so its parameters are never sent.
A response exit can write the answer straight onto the record. The integration context property
targetobject holds the record that the channel was called for. Set the values on it, then call
service.raiseSkipTransaction() to skip the rest of the processing. The call to the channel then
returns None.
One trap sits in the call itself. service.invokeChannel("zipchannel") looks the channel up by its
exact name. It finds the channel only when it was saved in exactly that case. Otherwise the call
fails with a NullPointerException. Write the name exactly as the channel is saved.
What IBM’s pages get wrong here#
| Topic | IBM’s pages | What Manage does |
|---|---|---|
| The names | not listed | the table above; the message type is part of the name |
| JDOM | from org.jdom import ... | Manage 9.2 has org.jdom2; the old import fails |
setCurrentDataAsInt | sets an integer | does not exist; use setCurrentData |
beforeExtExit | true before, false after | swapped on the way out |
| IBM Docs’ invoke request exit | stores the parameters | stops before the line that stores them |
| IBM’s external exit for vendors | builds the internal message | the guide’s copy misses an import and writes false; the IBM Docs copy never builds irData |
Article 33 of this series collects the corrections that matter most.
What comes next#
Article 19 covers object structure scripts: the inbound and outbound hooks.
IBM’s own pages are the reference to keep next to this series:
- Automation scripts in the IBM Maximo Manage documentation.
- All about Maximo scripting, IBM’s scripting guide on GitHub.
The complete list of corrections, with the evidence for each one, is in our member area. Members get access on request, so get in touch if you want it. If you want help with the scripts in your own Manage, our services page shows how we work.
IBM and Maximo are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide.
