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.
While adding another Business Document, the following data needs to be populated.
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.
// Creating Document Links Home through DocumentLinkDefinitionIBeanHomeIfc
// For instance, let us assume that the document is project
// Creating Project Home
// 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
This Script can be used with any Document Life cycle event or toolbar based on Business requirement.