To query a Maximo table using Java you need to perform the following steps:
- Get a reference to the MboSet.
- Specify a where clause.
- Loop through the MboSet and fetch Mbos.
MboSetRemote assetSet = getMboSet("ASSET");
assetSet.setWhere("LOCATION='BEDFORD'");
MboRemote asset=null;
for(int i=0; (asset=assetSet.getMbo(i))!=null; i++)
{
...
}
- The getMboSet method gets a reference the ASSET table.
- The setWhere method specifies the SQL where clause that must be applied to filter data. If the setWhere is not invoked, the entire table will be fetched.
- The getMbo method returns a specific element of the MboSet collection. The first invocation of getMbo method automatically fetches data and initialize the MboSet.
Just one question: Why don't you use the "best solution" without an "i" like said in your article "Best way to loop through an MboSet"? ;-)
ReplyDeleteP.J.
You are right, there is a more elegant solution to loop through an MboSet.
DeleteHowever, in basic articles like this, I prefer to use this method that can be simpler for people who don't know Java very well.
It seems you are reading my blog very well ;-)
You are welcome.
Bruno
This comment has been removed by the author.
Deletei need a mbo customization.give me the best links iam lerner.....i dont know java please give me best articles,,,,,,,,
DeleteHey Bruno...do you know the Code to get the current set based on the query that was entered on the search screen?
ReplyDeleteI've tried getMboSet() but that just gives me all the records in the entire WORKORDER application. I'm doing this in a Bean Class
If you are into an AppBean class you should be able to do something like that:
DeleteDataBean databean = app.getDataBean();
int currrow = databean.getCurrentRow();
String where = databean.getAppWhere();
you should probably use Qbe (mySet.setQbe("ASSETNUM","1001") instead of hand-formatted whereClause.
ReplyDeleteIf you need more advanced whereClause, I suggest you to use SqlFormat object.
Hi Bruno,
ReplyDeleteIs there anyway to limit the resultset returned when we do query with MboSetRemote? For instance I have an ASSET table with more than 50,000 records and I want to limit the number of results returned, eg records from row 5000 to 5500.
MboSetRemote assetSet = getMboSet("ASSET");
MboRemote asset = assetSet.getMbo(j);
This will hit MXApplicationException fetchStop exception if j is too large (value). Thanks!
Hi Bruno
ReplyDeleteI got problem this code:
MboSetRemote assetMboSet = session.getMboSet("ASSET");
and appear on Console:
Exception in thread "main" psdi.util.MXSystemException: system#remoteexception
at psdi.util.RMISession.getMboSet(RMISession.java:358)
at com.maximodev.MxRemoteConnection.main(MxRemoteConnection.java:26)
Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.lang.ClassNotFoundException: psdi.plusg.app.asset.PlusGAssetSet_Stub (no security manager: RMI class loader disabled)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at psdi.server.MXServer_Stub.getMboSet(Unknown Source)
at psdi.util.RMISession.getMboSet(RMISession.java:350)
What is mean the problem above and solve the problem?
Thank you...
Hello Wakeel. I can see a ClassNotFoundException. Did you import the necessary package? i.e. import psdi.mbo.MboSetRemote
ReplyDeleteHello, Bruno!
ReplyDeleteCan you help me?
There is no information about how to create mbo in Automation Script. Can you say how to do this?