Tuesday, 5 May 2015

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()

Monday, 20 April 2015

Throw warning in Maximo Automation Script

To throw warning in automation script:

warning = MXApplicationException(msggroup, msgkey, msgparams);
mbo.getThisMboSet().addWarning(warning);



 

Throw error in Maximo Automation script

In Maximo, all messages like errors, warnings and info are available in maxmessages table with msgkey and msggroup.

To throw an error in autoscript:

errorgroup=<msggroup>
errorkey=<msgkey>

In case of parameters:
errorgroup=<msggroup>
errorkey=<msgkey>
params=[<param1>,<param2>...etc]

For example I have created an error message in maximo using database administration --> Messages

msggroup = TESTGRP
msgkey = TESTKEY
msgvalue = "This is a test message"

in automation script, it is easy to display error message by using below code:

errorgroup=TESTGRP
errorkey=TESTKEY

in case of params:

For ex: my message value has : msgvalue = "This is a test message by {0}"

errorgroup=TESTGRP
errorkey=TESTKEY
params=[user]


 

Maximo Automation Script - Create Action Launch Point

It is simple to create a action launch point.

In my case, I have created a sigoption in Purchase Order application.

1. Sigoption name is : CREATEPOEXT - by using app designer

In sigoption --> Advanced Signature Options --> select the radio button "This is an action that must be invoked by user in the UI"

Give the position in your select action menu in app designer.

Grant access to this sigoption in your security group applications.

2. Automation script

Go to System Configuration --> Platform Configuration --> Automation Script application
From list tab --> Select "Create" --> click on "Script with Action Launch Point"

Enter Launpoint name same as your sigoption created for your application:
Launpoint : CREATEPOEXT
Active: Yes
Object: PO
Action: CREATEPOEXT
Note: Action name will auto generate same as launch point name.
Click next and enter your variables and automation script. Save the record. That's it.

3. Main point is, you don't have to create a Action separately in Actions applications.
for ex: Action "CREATEPOEXT" automatically created in Action applications.

Action will be created like below, in our case:

Action: CREATEPOEXT
Object: PO
Type: Custom Class
Value: com.ibm.tivoli.maximo.script.ScriptAction
Note: Above value is common class for all action launch point related actions.
Parameter: CREATEPOEXT,CREATEPOEXT,CREATEPOEXT
In parameter, you noticed that there are three values. Let me explain what are they
1. Script name
2. Launch point name
3. Action name
in my case all names are "CREATEPOEXT"

So by any chance, if you miss any of those values in your "parameter" field of action, then it will throw error at the point of automation script execution.

 

Tuesday, 29 July 2014

Create multiple instances of Maximo

I found below link to create multiple instances of Maximo in websphere. We strongly recommend that this procedure be used only for educational and experimental environments and must not used in commercial situations.

Source: http://maximo8.com/?p=70

We recommend this procedure be used only for educational and experimental environments. While you may find that you can satisfy Sarbanes-Oxley requirements for multiple environments this way, please don;t. Yes, this is a disclaimer. However, if you insist that you need a second environment and this your only way to go, here's a free, no mystery, step-by-step procedure. Do so at your own risk. Please remember that you didn't get this here.

The "How To" and "Start Here"

First, always create a backup copy of your Maximo production database. It is assumed you know how to do that, but if you don't, google for guide for backing up a DB2, SQL Server or an Oracle database and learn the procedure well. After you have created a backup, restore the database and name it MaxTest.

Log into the Websphere admin console. The default username is 'wasadmin'. Expand 'Servers' and click on 'Application Servers'. There you should find one instance called 'MXServer' which is the one you already installed. Click on 'New' to create a new app server. Enter 'MXTest' as your server name and hit 'Next'.

Accept the default template and check the box for 'Generate Unique Ports'. Finish and confirm your new app server. Finally save directly to your master configuration.

Click on the 'MXTest' app server. Under 'Server Infrastructure', expand 'Java and Process Management' and click on 'Process Definition'. Click on 'Java Virtual Machine' under the Additional Properties. Here you need to set the Initial Heap Size to 512 and the Maximum Heap Size to 1024.
Don't forget to save to master.

Now we need to know what our new application server is using for ports. Go back to your Application Server list and click on 'MXTest', expands 'Ports' and make note of the ports numbers for the four port names that begin with 'WC'. Take note of the port numbers, which should look like this:

Websphere ports 1
Websphere ports 1
Create a new virtual host. Expand 'Environment' in the left pane and click on 'Virtual Hosts'. Here you will see a list o ghosts such as maximo_host, admin_host, etc. Click on 'New' and name it 'maxtest_host' and click on Apply. Now click on 'Host Aliasses'. This list should be empty, and we will be creating 5 new aliases. Click on 'New' and accept the default port 80 and click 'Apply'. Next, create four more ports that look like the following:

Host aliases
Host aliases
Go to your Maximo installation directory, the default is "C:/ibm/SMP". Just beneath SMP you will find a directory named "maximo". Copy that entire directory and rename it 'maxtest'. We find this is a better choice than copying the entire ivm/SMP branch. This will not only save space, but will avoid confusion later on.

Next, navigate to the "C:/ibm/SMP/maxtest/applications/maximo/META-INF" folder and open the 'application.xml' file. Search for '<context-root>/maximo</contextroot>' and change it to '<context-root>/maxtest</context-root>'. This will be used in the url of reconnecting to your new instance. For example, the url for connecting to your  Maximo test application server will be
"http://servername:port/maxtest".

Go find and edit the same property in the 'deployment-application.xml' as well. Save both files.

Open your maximo.properties file at 'C:/ibm/SMP/maxtest/applications/maximo/properties'. Change the 'database' to the name of your newly created SQL Server database. The database property should
look something like this:

database=MAXTEST&amp;language=us_english&amp;nowarnings=true&amp;mars=false

Also change the 'mxe.registry.port' property. Keep it simple, just add one to the existing value.

Finally, the last property to modify is 'mxe.int.webappurl'. Change it to: mxe.int.webappurl=http://{servername}:9081/meaweb/mxe.int.globaldir=MaxTest

Finally, rebuild and deploy your maximo ear fils for the newly created maxtest application server. Access your Maximo test environment at ''http://servername:9081/maxtest'



Copy Job plan description to PM generated Work Order

To copy Job Plan description to auto generated PM Work Order description, I have found below link from IBM website:

http://www-01.ibm.com/support/docview.wss?uid=swg21645602&myns=swgtiv&mynp=OCSSLKT6&mync=R

Source: IBM

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...