IBM Support

Automation Script for Maximo Integration Framework (MIF) - Enterprise Service

Technical Blog Post


Abstract

Automation Script for Maximo Integration Framework (MIF) - Enterprise Service

Body

In the last Blog I talked about the automation script for Object Structure. Follow the link:

/support/pages/node/1131279

 

Now I will show an example and explain all details of an automation script using Enterprise Service.

 

Go to System Configuration =>  Platform Configuration => Automation Scripts.

Click on Select Action=> Create=>Script for Integration.

The pop up below will appear for you:

image

 

First select the option Enterprise Service. On this example I am using the Enterprise Service for ITEM. (MXITEMInterface).

The follow options, where I indicated using the red rectangle, basically indicate when your Automation Script will be executed. This option could change depend on what rule you are creating and when do you expect to be executed.

To understand these options click on the link below:

http://www.ibm.com/support/knowledgecenter/en/SSLKT6_7.6.0/com.ibm.mif.doc/mif_scripting/c_custom_points_es_sync.html

 

I am going to use the Script Language JavaScript.

Copy and paste the following code on Source Code. This code will concatenate the information of others fields and paste on the field DESCRIPTION.

//This line should not be required

irData.breakData();

 

 

var comm = irData.getCurrentData("COMMODITYGROUP");

if (comm == 'ELEC'){

irData.setCurrentData("DESCRIPTION","Desc - "+ comm + " - " + irData.getCurrentData("ITEMSETID"));

}

 

Done, the automation is ready to work.

 

I created a Web Service using the Enterprise Service MXITEMInterface and sent the xml below:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:max="http://www.ibm.com/maximo"&gt;

   <soapenv:Header/>

   <soapenv:Body>

      <max:SyncMXITEM>

         <max:MXITEMSet>

             <max:ITEM action="AddChange">

               <max:COMMODITYGROUP>ELEC</max:COMMODITYGROUP>

               <max:ITEMNUM>PF1002</max:ITEMNUM>

               <max:ITEMSETID>SET1</max:ITEMSETID>

               <max:DESCRIPTION>TESTPEDRO</max:DESCRIPTION>

            </max:ITEM>

         </max:MXITEMSet>

      </max:SyncMXITEM>

   </soapenv:Body>

</soapenv:Envelope>

 

This is the result:

image

 

Now let’s understand my Javascript code.

This is a simple code. If the ITEM belongs to the commodity group ELEC, the description will be replaced for Desc – ELEC – Item Set.

 

Probably you noticed this line:

//This line should not be required

irData.breakData();

This command breaks the input XML so the data can be manipulated. This line should not be necessary, because the framework should do this for you. But in my case if I do not use this command the error below was returned:

Stack:
Caused by: java.lang.NullPointerException
                at psdi.iface.mic.StructureObject.getCurrentNamespaceURI(StructureObject.java:1059)
                at psdi.iface.mic.StructureObject.setCurrentData(StructureObject.java:775)

 

So if this error happens if you too, just add that line.

 

There are two mains object that you can manipulate into the Automation script: irData and erData.

erData: External document, is the document(XML) that you receive on the enterprise service. The manipulation of erData can only be done using XML. (Like JSON).

irData: Internal converted document, is what ends up getting mapped to the mbos(maximo business objects). This is the XML converted into object. So in this case to manipulate the data use the object irData.

 

 Stay tuned for more.

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSLKT6","label":"IBM Maximo Asset Management"},"Component":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

UID

ibm11130889