Quantcast
Channel: SCN : Discussion List - SAP Sourcing
Viewing all articles
Browse latest Browse all 1416

Copy line items from Master Agreement to SubAgreement

$
0
0

Dear all,

 

As a requirement, we need to create a dummy line item at master agreement and subagreement level to be able to publish them to ERP without need

to complete line items (they are completed in ERP via a development).

 

We have created master agreement templates with a dummy line item but at subagreement level, templates are not available.

 

What we are trying to develop is a script on post_create at agreement level to copy line items from Master Agreement to SubAgreement. We are able to get Master Agreement line items and copy them to the SubAgreement, but the subagreement is not created. This is the code we are using:

 

import com.sap.odp.api.doccommon.masterdata.ValueListValueIBeanHomeIfc;

import com.sap.odp.api.doccommon.masterdata.ValueListValueIBeanIfc;

import com.sap.odp.api.doccommon.masterdata.ValueListTypeIBeanHomeIfc;

import com.sap.odp.api.doccommon.masterdata.ValueListTypeIBeanIfc;

 

import com.sap.eso.api.contracts.ContractIBeanHomeIfc;

 

Mst_agreementBean = doc.getParentIBean();

lineItemCollectionSub = doc.getLineItems();

lineItemCollection = Mst_agreementBean.getLineItems();

 

collectionsize = lineItemCollection.size();

colln = Mst_agreementBean.getCollectionMetadata("MA_LINEITEMS").get(Mst_agreementBean);

colln2 = doc.getCollectionMetadata("MA_LINEITEMS").get(doc)

 

newProject = Mst_agreementBean.getIBeanHomeIfc().createFromAnother(Mst_agreementBean);

 

newMember = colln.get(1);

 

//  Get Values Line Item

assCat = newMember.getAcctAssignCategory();

actLimP         = newMember.getActualLimitPercent();

delAdCity       = newMember.getDeliveryAddressCity();

delAdCount    = newMember.getDeliveryAddressCountryRef();

delAdDist       = newMember.getDeliveryAddressDistrict();

//... (all fields included in the script)

 

// Create Line

newMember2 = newMember;

 

AgreementHome = IBeanHomeLocator.lookup(session, doc.getObjectReference());

AgreementHome.upgradeToEdit(doc);

 

// Set Values

newMember2.setAcctAssignCategory(assCat);

newMember2.setActualLimitPercent(actLimP);

newMember2.setDeliveryAddressCity(delAdCity);

newMember2.setDeliveryAddressCountryRef(delAdCount);

newMember2.setDeliveryAddressDistrict(delAdDist);

//... (all fields included in the script)

 

 

try{

 

colln2.add(newMember2);

AgreementHome.save(doc);

AgreementHome.downgradeToView(doc);

 

collectionbean = colln2.get(0);

logInfo("Value of  collectionbeanSub " + collectionbean );

 

}catch (ApplicationException e){

logInfo("Error " + e.getClass() + ". " + e.getMessage());

}

 


When we try to create an Agreement under a Master Agreement (clicking Add on Agreement tab), following error message is shown related to the line in blue:


Facility=local4;sessionid=4e73bb8e73304d6284816f93f4e04522a7c387b; tenantid=#tenant.ecb#;username=LUGUELL; exception=Sourced file: inline evaluation of: ``// **   import com.sap.odp.api.doccommon.masterdata.ValueListValueIBeanHomeI ... '' : Method Invocation AgreementHome.save : at Line: 164 : in file: inline evaluation of: ``// **    import com.sap.odp.api.doccommon.masterdata.ValueListValueIBeanHomeI ... '' : AgreementHome .save ( doc )


Target exception: java.lang.NullPointerException: while trying to invoke the method com.sap.eso.contracts.ContractTypeBo.getVendorVisible()

of a null object returned from com.sap.eso.contracts.ContractCommonBo.getTypeBo()
;stacktrace=Sourced file: inline evaluation of: ``// *JLA*    import com.sap.odp.api.doccommon.masterdata.ValueListValueIBeanHomeI ... '' : Method Invocation AgreementHome.save : at Line: 164 : in file: inline evaluation of: ``// *JLA*    import com.sap.odp.api.doccommon.masterdata.ValueListValueIBeanHomeI ... '' : AgreementHome .save ( doc )

Target exception: java.lang.NullPointerException: while trying to invoke the method com.sap.eso.contracts.ContractTypeBo.getVendorVisible()

of a null object returned from com.sap.eso.contracts.ContractCommonBo.getTypeBo()


Any ideas what is causing the error? What are we missing on our code to copy line items?


Many thanks,


Marc Romagosa

 

Message was edited by: Marc Romagosa de Riba


Viewing all articles
Browse latest Browse all 1416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>