on ‎2013 Apr 24 6:29 PM
Request clarification before answering.
Hi ,
As you are trying to write Explicit Scripts , I dont think you can use any of the implicit object like doc etc , which would be available by default in all other contexts.
Explicit scripts can be scheduled therefore you shall look into find a particular master agreement and create a object and look for doing the desired functionalities.
Thanks
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Krish,
To get the Master Agreement you can use one way like below mentioned:
import java.util.List;
import com.sap.eso.api.contracts.ContractIBeanHomeIfc;
import com.sap.eso.api.contracts.ContractIBeanIfc;
import com.sap.odp.api.common.types.ObjectReferenceIfc;
import com.sap.odp.api.ibean.IBeanHomeLocator;
ContractIBeanIfc masterAgreement= null;
Integer masterAgr= doc.getObjectReference().getObjectId() ;
ContractIBeanHomeIfc masterAgrHome= (ContractIBeanHomeIfc)IBeanHomeLocator.lookup(session, ContractIBeanHomeIfc.sHOME_NAME);
String whrClause="OBJECTID= "+"'"+masterAgr+"'";
List masterAgrList=masterAgrHome.findWhere(whrClause);
if (masterAgrList.size()>0)
{
masterAgreement=(ContractIBeanIfc)masterAgrList.get(0);
}
This will give you master Agreement. I believe master Agreements do not have phases. Are you talking about the changing the status?
Hope this helps.
Regards,
Kumud
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kumud,
Thanks for your post.
My understanding from your post is as follows, please correct me if I am wrong.
1. Reading the MA Object ID
2.Getting the MA's Home Bean
3.Getting the MA list with the help of MA Object ID.
4.Printing the First MA from the Master Agreement List.
Is there any alternative approach to get only one Master Agreement, instead of getting list of MAs ?
Integer masterAgr= doc.getObjectReference().getObjectId() ---- Here we are trying to read Object ID. Can we get object id of only one MA ?
Thanks
Krish
Hi Krish,
Yes, you are right. One thing I would add that as you mentioned in step 4 the master Agreement list would have only one MA with the given object id, as in master data with the same object id we cannot find more than one MA.
Integer masterAgr= doc.getObjectReference().getObjectId() would return you the object id of current doc you are running script for.
You can use alternate methods as well;
ContractIBeanHomeIfc maHome= IBeanHomeLocator.lookup(session, ContractIBeanHomeIfc.sHOME_NAME);
ContractIBeanIfc ma1=(ContractIBeanIfc) maHome.find(doc.getObjectReference());
ContractIBeanIfc ma2=(ContractIBeanIfc) maHome.findByUniqueDocName(doc.getDisplayName());
ContractIBeanIfc ma3= (ContractIBeanIfc) maHome.findForEdit(doc.getObjectReference());//you can edit the MA using this method.
Hope this would solve your issue,
Regards,
Kumud
Hi Kumud,
Thank you for your reply.
I have a question :
How does the script know the Master agreement's ID which we are trying to get, without passing the Master agreement ID as a parameter ?
However, I tried to implement your suggestions, but I got "Null pointer Exception error".
First I tried to print the ObjectID of the MA.
Integer masterAgr= doc.getObjectReference().getObjectId() ;
logmsg(" MA ObjectID" +masterAgr);
When I checked in the logs it gave me "Null method invocation error".
I tried it in another way
MAID = "MA-12345";
Integer masterAgr= doc.getObjectReference().getObjectId(MAID) ;
logmsg(" MA ObjectID" +masterAgr);
I got same error in logs.
Could you please suggest me how to solve it.
Thanks
Krish
Hi Krish,
Could you please confirm if you are using the script in validate/saved target? Using objectid in created/duplicated target would not work.
This should have worked.
If possible you can please check this script to find out whether you are getting the document bean or not.... try to print:
ObjectReferenceIfc masterAgrRef= (ObjectReferenceIfc)doc.getObjectReference();
logMsg("masterAgrRef--"+masterAgrRef.getDisplayName()+"-id-"+masterAgrRef.getObjectId());
The script will store the object id in an object and using HomeIbeanIfc of the bean it would search from the master data whether there exists any document with this objectid or not. If yes, it would return that bean.
Please let me know if you have any issues with this.
Regards,
Kumud
Hi Kumud,
Thank you for your reply.
You are correct, your code will work for targeted events.
But I am not using any target. I am trying to create explicitly called script, that is why I asked the question.
I guess, for explicitly called script we need not to select any target.
Can you please share your ideas..
Thank you
Krish
Hi Krish,
From what I understand after reading this discussion is that you want to create an explicit script to change status of Master Agreement.
However, how do you wish to run the script?
I would suggest using the scripting context as Toolbar.
Script logic could be as follows:
1. Hard code the MA number in script.
2. Use ContractIBeanHomeIfc API to get current document context
3. Use ContractIBeanIfc API to find the MA reference using the hard coded value
4. Then make changes to the MA status
5. Save the document
Please let me know in case the above was able to help you.
Regards,
Rohit Singhal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.