Skip to Content
author's profile photo Former Member
Former Member

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

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ś

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Mar 01, 2013 at 11:51 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.