Tuesday 26 May 2015

Automation Script - get current date and time.

In automation script, there is no implicit variable available to get current date and time. I followed below procedure, to get current date and time to set date time field.

from java.util import Calendar

#Create a instance for Calendar
cal = Calendar.setInstance();

#Get Current date and time by using cal.getTime()
currentDateTime = cal.getTime();

#AS I AM APPLYING THIS SCRIPT TO WORKTYPE OF WORKORDER, ALREADY DECLARED VARIABLES FOR WORKTYPE as worktype AND TARGSTARTDATE as tsd

if worktype="CM":
 tsd = currentDateTime


Hope it helps to someone who are new to set date time in automation script.

 

Friday 22 May 2015

Route stops data loading

While loading route stops, make sure below fields are exist in your file:

ASSETLOCORGID
ASSETLOCSITEID
ROUTESTOPID (This field is to provide sequence number of route stop for a respective route)

If those fields are not exist and trying to load route stops with locations, error will appear "XXXXX is not a valid location".

ROUTESTOPID will help to avoid routestop duplicates.
For example:
ROUTE,ASSETNUM,LOCATION,JPNUM,STOPSEQUENCE,SITEID,ROUTESTOPID
1001,,LOC1,,10,SITE1,1
1001,,LOC2,,20,SITE1,2
1002,LOC21,,10,SITE1,1
1002,LOC22,,10,SITE1,2
1002,LOC23,,10,SITE1,3
1002,LOC24,,10,SITE1,4

if you don't provide ROUTESTOPID, when doing routes data loading second time, it will add duplicate records.
Below format will create duplicate records in route stops:
ROUTE,ASSETNUM,LOCATION,JPNUM,STOPSEQUENCE,SITEID
1001,,LOC1,,10,SITE1
1001,,LOC2,,20,SITE1
1002,LOC21,,10,SITE1
1002,LOC22,,10,SITE1
1002,LOC23,,10,SITE1
1002,LOC24,,10,SITE1 

PM Records data loading

While data loading PM records, make sure USEFREQUENCY = 1 for frequency based PMs.

Otherwise, problem is, even though you saved the record, it will ask again to save the pm record. PM Work orders will not generate.

Monday 18 May 2015

Actions in Maximo Integration Framework

Add – Add records
AddChange – Add or update existing records
Change – Update existing records
Delete – Delete records
Replace – Substitute existing records
null – Add records or replace records depending on whether the primary record exists in the database.
  • If the primary record does NOT exist in the database, the system performs an Add action
  • If the primary record DOES exist in the database, the system performs a Replace action.

Friday 8 May 2015

Maximo training videos

IBM Maximo Education Assistant:

http://www-01.ibm.com/support/knowledgecenter/#!/tivoli_iea/com.ibm.iea.mam/mam/7.6/content_list.html 

Tuesday 5 May 2015

Increase list of display applications in "My Recent Applications"

System properties has a property called "webclient.maxRecentApps".

Default value is 8.
Increase/decrease the value and save the record. Click on the 'Live Refresh' and click Ok.

The property will now be updated.

If you want to disable this option. Set value to 0 and save the record. Click on the 'Live Refresh' and click Ok.

Automation Script - get difference between dates

If you want to get a difference between two dates in Maximo automation scripts, I tried below process:

For example:
In Work Order, you want to find a days between Target Start Date and Target Finish Date.

Target Start Date is "01/Apr/2015"
Target Finish Date is "25/Apr/2015"
Difference from Target Start Date and Target Finish Date is 25

Lets see how to write automation script:

Object: WORKORDER

Varibles declared as:

tsd = Target Start Date
tfd = Target Finish Date
dayselapsed = CUSTOM_DAYSELAPSED (Custom attribute to set days - integer)

Script as follows:

#************** AUTO SCRIPT START ***************
#Define a function to get date difference
#************** FUNCTION START ***************
def getDateDiff(timeDiff):

#Seconds in Millis
 milliseconds = 1000

#Minutes in Millis
 milliminutes = milliseconds * 60

#Hours in Millis
 millihours = milliminutes * 60

#Days in Millis
 millidays = millihours * 24

#Get days diff
daysDiff = timeDiff / millidays

#Get hours diff
hoursDiff = timeDiff/millihours

#Get minutes diff
minDiff = timeDiff / milliminutes


#Return days difference
if(daysDiff != 0):
 return int(daysDiff)

#Return hours difference
if(hoursDiff != 0):
 return int(hoursDiff)

#Return minutes difference
if(minDiff != 0):
 return int(minDiff )

#************** FUNCTION END ***************

#Time difference between two dates
timeDiff = tsd.getTime() - tfd.getTime()
daysDiffernce = getDateDiff(timeDiff)
dayselapsed = daysDifference

#************** AUTO SCRIPT END ***************

For few developers, if above script confuses you, below script without comments, to return days difference:

#************** AUTO SCRIPT START ***************
#Define a function to get date difference
#************** FUNCTION START ***************

def getDateDiff(timeDiff):
 milliseconds = 1000
 milliminutes = milliseconds * 60
 millihours = milliminutes * 60
 millidays = millihours * 24

daysDiff = timeDiff / millidays
hoursDiff = timeDiff/millihours
minDiff = timeDiff / milliminutes

if(daysDiff != 0):
 return int(daysDiff)

#************** FUNCTION END ***************

timeDiff = tsd.getTime() - tfd.getTime()
daysDiffernce = getDateDiff(timeDiff)
dayselapsed = daysDifference

#************** AUTO SCRIPT END ***************

 

Automation script integer variables

When I started writing a auto script to copy one INTEGER value into another INTEGER value, I feel that it is very easy to do. Offcourse it is easy, except you are able to solve the below error:

java.lang.ClassCastException: java.math.BigInteger incompatible with java.lang.String

I will explain you in detail, when you will face this error

For example, in work order I would like to set wopriority and assetlocpriority based on work type.

Created a attribute launch point script.

Variables declared as follows:

object is WORKORDER

wp = WOPRIORITY
alp = ASSETLOCPRIORITY
worktype = WORKTYPE

Script as follows:
#Script is for if work type is CM, then copy assetlocpriority to wopriority

if worktype == "CM":
 wp = alp

# Here you will get a error that
"java.lang.ClassCastException: java.math.BigInteger incompatible with java.lang.String"

This is because auto script considering these wp and alp as longs. I am not sure why it is like that and why it is throwing an error.
Hence I tried to print it.

print wp
#output is 2L
print alp
#output is 4L

From above output, I felt that, error is because of "L". Hence I tried to change to output without "L" like 2 and 4

So I did casting with integer like int(alp), it is printing output as "2" (without "L")

Corrected Script as follows:
#Script is for if work type is CM, then copy assetlocpriority to wopriority

if worktype == "CM":
 wp = int(alp)

Now it is working fine. No error.

 

Automation Script dates

To add DAYS to date:

For example, in Work Order we have target start date and target finish date:

now we will get the Target Start Date and Target Finish Date as variables tsd" and "tfd respectively.

In automation script, if we want to add two days to "Target Start Date" and copy it into "Target Finish Date"

# First import Calendar
from java.util import Calendar

#Create a Calendar instance
cal = Calendar.getInstance()

#Set calendar date as Target Start Date. Variable is defined in automation script as "tsd"
cal.setTime(tsd);
# ADD TWO DAYS TO TARGET START DATE
cal.add(cal.DATE,2)

#SUBSTRACT TWO DAYS TO TARGET START DATE
cal.add(cal.DATE,-2)

#ADD TWO WEEKS TO TARGET START DATE
cal.add(cal.DATE, 2*7)

#SUBSTRACT TWO WEEKS TO TARGET START DATE
cal.add(cal.DATE, -2*7)

#ADD 4 MONTHS TO TARGET START DATE
cal.add(cal.MONTH,4)

#SUBSTRACT 4 MONTHS TO TARGET START DATE
cal.add(cal.MONTH,-4)

#ADD 5 YEARS TO TARGET START DATE
cal.add(cal.YEAR,5)

#SUBSTRACT 5 YEARS TO TARGET START DATE
cal.add(cal.YEAR,-5)
#SET NEW DATE WITH INCREMENT/DECREMENT FROM CALENDAR TO TARGET FINSIH DATE
tfd = cal.getTime();



 

Maximo automation script mboset iteration

To iterate mboset records using automation script:

Usually we do below coding in java using Maximo API:

In the below example, taking PR as MboSet:

MboSetRemote prSet = MXServer.getMXServer().getMboSet("PR",MXServer.getMXServer().getSystemUserInfo());
prSet.setWhere("prnum = '"+<PRNUM>+"' and siteid = '"+<SITEID>+"'");
prSet.reset();

MboRemote pr = null;
int i = 0;

if(!prSet.isEmpty()){
  while((pr=prSet.getMbo(i)) != null){
      pr.setValue("description","TEST PR");
      i++;

     }
  prSet.save();
}

Now we will do above logic in Automation Script:



from psdi.server import MXServer

mxServer = MXServer.getMXServer()

prSet = mxServer.getMboSet("PR",mxServer.getUserInfo())
prSet.setWhere("prnum = '"+<PRNUM>+"' and siteid = '"+<SITEID>+"'")
prSet.reset()

prRemote= prSet.moveFirst()
while prRemote:
 prRemote= prSet.moveNext()

prSet.save()

Maximo SOAPUI error javax.xml.ws.WebServiceException

SOAPUI error while sending payload to below url (in cluster environment) http://localhost:9080/meaweb/services/MXASSET Error : <f...