on 07-02-2013 3:56 PM
Hi,
We have a requirement to display master agreement effective date in the subagreement under it. I am new to scripting and have tried the following (of course it does not work). Could someone help or guide me in the right direction ?
// Script triggered when creating SubAgreement
import com.sap.eso.api.contracts.ContractIBeanIfc;
import com.sap.eso.api.contracts.ContractIBeanHomeIfc;
import com.sap.eso.api.contracts.AgreementIBeanIfc;
import com.sap.eso.api.contracts.AgreementIBeanHomeIfc;
import com.sap.odp.api.ibean.IBeanHomeLocator;
import com.sap.odp.api.doc.IapiDocumentLockManager;
maBean = doc.getRootParentIBean();
maHome = IBeanHomeLocator.lookup(session, maBean.getObjectReference());
maEffDate = maBean.getEffectiveDate();
agrHome= IBeanHomeLocator.lookup(session,doc.getStatusRef());
agr = agrHome.find(doc.getStatusRef());
doc.getExtensionField("MAEFFDATE").set(maEffDate);
Thanks,
Rani
Hi Rani,
Instead of this,
maEffDate = maBean.getEffectiveDate();
agrHome= IBeanHomeLocator.lookup(session,doc.getStatusRef());
agr = agrHome.find(doc.getStatusRef());
doc.getExtensionField("MAEFFDATE").set(maEffDate);
Try just this,
doc.setEffectiveDate(maBean.getEffectiveDate());
This should work.
Regards,
Lopita
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Lopita. As I mentioned to Uday , it is an extension field. I was able to get the desired results in the create event with the following script:
// Script triggered when creating SubAgreement from Master
import com.sap.eso.api.contracts.ContractIBeanIfc;
import com.sap.eso.api.contracts.ContractIBeanHomeIfc;
import com.sap.eso.api.contracts.AgreementIBeanIfc;
import com.sap.eso.api.contracts.AgreementIBeanHomeIfc;
import com.sap.odp.api.ibean.IBeanHomeLocator;
import com.sap.odp.api.doc.IapiDocumentLockManager;
SetMAEffectiveDate()
{
parentBean = doc.getRootParentIBean();
parentHome = IBeanHomeLocator.lookup(session, parentBean.getObjectReference());
maEffDate = parentBean.getEffectiveDate();
doc.getExtensionField("MASTEREFFDATE").set(maEffDate);
IapiDocumentLockManager.lockField(session,doc,"MASTEREFFDATE");
}
ApplicationException exceptionChain = new ApplicationException(session);
try {
SetMAEffectiveDate();
}
catch (ApplicationException ae)
{
exceptionChain.chainAtEnd(ae);
throw ae;
}
Hi Rani ,
Effective date is a standard field , you shall use the standard method available for setting effective date ie.setEffectiveDate(SysDateIfc value) .
As you got the parent MA date , just set it in the agreement by calling the method.
Hope it helps
Thanks
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.