Quantcast
Channel: SCN : Blog List - SAP Sourcing
Viewing all articles
Browse latest Browse all 92

Adding Project/MA/RFx etc. in Document Links Section via Script.

$
0
0

Introduction

 

In SAP Sourcing, one common question comes up every now and then which is related to Document Links section (MA, project etc.). For convenience, in this blog I am explaining the technical script involved in solving this issue.

 

What is a Document Links Section?

 

Under Header Section of a Business Document, we can see the Document Links Sections where the user can add another Business Document in relation to the current one.

 

DocLinks.png

While adding another Business Document, the following data needs to be populated.

 

relation.png

 

Technical Scenario

 

Generally, based on some business requirement, we would require linking a previous Project (Business Document) to the current one. This can be achieved via scripting which is explained in this blog.

 

//Required imports

 

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

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

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

 

// Creating Document Links Home through DocumentLinkDefinitionIBeanHomeIfc

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

 

// For instance, let us assume that the document is project

// Creating Project  Home

 

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

 

// Finding the Project which needs to be added in Document Links section

 

projBean = projHome.findByUniqueDocName("PROCAT-001--2014");

 

// Find the Relationship with which the Project  should get added. Refer FCI-DocLinkDefList query to view all the relations present in the system.

 

documentLinkDef = docLinkHome.findUnique("FCI-PROJECT PREVIOUS");

 

// A line is added with empty fields in Document Links section

newDocumentLink = doc.getDocumentLinkList().create();

 

// Setting the Type of document which needs to be added (project, RFx, Auction etc.)

 

newDocumentLink.linkDefinitionType = new DocLinkDefinitionTypeEnumType(1);

 

// Setting the Relationship of the document which needs to be added (Previous Project, Future Project etc.)

 

newDocumentLink.linkDefinitionObjRef = documentLinkDef.objectReference;

 

// Setting the Object Reference of the document which needs to be added

 

newDocumentLink.LinkDocObjRef = projBean.objectReference;

 

//A Document is added in the Document Links Section

 

doc.getDocumentLinkList().add(newDocumentLink);

 

This Script can be used with any Document Life cycle event or toolbar based on Business requirement.

 

Regards,

Vignesh


Viewing all articles
Browse latest Browse all 92

Trending Articles



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