cancel
Showing results for 
Search instead for 
Did you mean: 

Populate Master agreement effective date in subagreement

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

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;

}

Answers (1)

Answers (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Thanks Uday. I am actually populating an extension field with the data and hence I cannot us the set effective date. My issue was that I was not getting the parent reference, I used the getparentRootbean and now I am getting the correct results.