cancel
Showing results for 
Search instead for 
Did you mean: 

RFx script - link creation does not work (Project -> RFx)

Former Member
0 Kudos

Hello,

I'm working with SAP Sourcing 7 and having problem with the following scenario & script extension:

My script is triggered when RFX document is saved (RFX document context, Saved event). First, I read field PROJ_NUMBER (extension field) which stores associated Project number.

The goal of the script is to:

1. Find associated Project document (by PROJ_NUMBER field).

2. Create the link from Project to RFX (script run in RFx context).

3. Save Project document.

I try with the following code:

nrProj  = doc.getExtensionField("PROJ_NUMBER").get();

myProjHome =  IBeanHomeLocator.lookup(session, ProjectIBeanHomeIfc.sHOME_NAME );

relProjectIfc = myProjHome.findByUniqueDocName(nrProj);   

myProjHome.upgradeToEdit(relProjectIfc);

linkDefnHome = IBeanHomeLocator.lookup(session, DocumentLinkDefinitionIBeanHomeIfc.sHOME_NAME);

docLinkDef = linkDefnHome.findUnique("FCI-RFP RELATED"); 

docLinkList = relProjectIfc.getDocumentLinkList();

docLink = docLinkList.create();

docLink.setDisplayName( doc.getDisplayName() );

docLink.setLinkDefinitionType( new DocLinkDefinitionTypeEnumType(DocLinkDefinitionTypeEnumType.DaVinciBusinessDocument) );

docLink.setLinkDocObjRef( doc.getObjectReference() );

docLink.setLinkDefinitionObjRef( docLinkDef.getObjectReference() );

docLinkList.add(docLink);

relProjectIfc.getIBeanHomeIfc().save(relProjectIfc);

During .save I'm getting the following error:

Facility=local4;sessionid=odp_event_data_import_process;tenantid=\#system\#;username=daemon;DB2 SQL Error: SQLCODE=-803, SQLSTATE=23505, SQLERRMC=2;SAPEJD.FCI_PRO_DOCLINK_REF, DRIVER=3.63.75 Object: 272629761:1106:null:: OBJECTID : 272629761, CONTEXTID : -2147483545, REVISION_COUNT : 0, UNIQUE_DOC_NAME : 2726297611358957952313, DISPLAY_NAME : null, COLLN_METADATA : 0.340.size=0

0.525.size=0

, PARENT : -2147483291:1100:4, INACTIVE : false, IN_COST_REPORT : false, DOC : -2147481623:509:6300001698#

COLLN:4:1106-COLLN:4:1106-At least one of the items below is invalid. Mouse over the highlighted area for more details.

Anyone had the same problem?

Best regards,

Tomasz Gałdyś

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Tomasz,

There was this similar kind of issue in which project created from RFx is attached in the document link of RFx. The script was written on RFx side.

import com.sap.eso.api.projects.ProjectIBeanHomeIfc;

import com.sap.eso.api.projects.ProjectIBeanIfc;

import com.sap.eso.api.rfx.RfxDocIBeanIfc;

import com.sap.odp.api.doc.DocLinkDefinitionTypeEnumType;

import com.sap.odp.api.doc.DocumentLinkIBeanIfc;

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

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

import com.sap.odp.api.ibean.AssociativeCollectionIfc;

import com.sap.odp.api.ibean.IBeanHomeLocator;

import com.sap.odp.api.ibean.IBeanIfc;

String nrProj  = (String) doc.getExtensionField("PROJ_NUMBER").get();

        ProjectIBeanHomeIfc myProjHome =(ProjectIBeanHomeIfc) IBeanHomeLocator.lookup(session, ProjectIBeanHomeIfc.sHOME_NAME);

        ProjectIBeanIfc relProjectIfc =(ProjectIBeanIfc) myProjHome.findByUniqueDocName(nrProj);

        //upgrade the project to edit

        myProjHome.upgradeToEdit(relProjectIfc);

        DocumentLinkDefinitionIBeanHomeIfc linkDefnHome=(DocumentLinkDefinitionIBeanHomeIfc) IBeanHomeLocator.lookup(session, DocumentLinkDefinitionIBeanHomeIfc.sHOME_NAME);

        DocumentLinkDefinitionIBeanIfc projBeanLinkDef=(DocumentLinkDefinitionIBeanIfc)linkDefnHome.findUnique("FCI-RFP RELATED");

        AssociativeCollectionIfc docLinkList = relProjectIfc.getDocumentLinkList();

        DocumentLinkIBeanIfc docLink = (DocumentLinkIBeanIfc) docLinkList.create();

        docLink.setLinkDefinitionObjRef(projBeanLinkDef.getObjectReference());

        docLink.setLinkDocObjRef(doc.getObjectReference());

        docLink.setLinkDefinitionType(new DocLinkDefinitionTypeEnumType (DocLinkDefinitionTypeEnumType.DaVinciBusinessDocument));

        docLink.setLinkDate(new SysDatetime(new Date()));

        docLinkList.add(docLink);

        relProjectIfc.getIBeanHomeIfc().save(relProjectIfc);

        myProjHome.save(relProjectIfc);

Hope this would help.

Regards,

Kumud