Programmatically create and retrieve documents attached in GOS (Generic Object Services) via Stored business document.
Few days back I came across a requirement, to programmatically create and retrieve documents attached in GOS (Generic Object Services) via Stored business object. It took significant amount of time for me to do this. Thought sharing the solution might help someone who may come across this requirement.
I have tried to cover the scenario which I have solved with this. Any suggestions/improvements/modifications in this document are appreciated.
Business object, Object ID, Document type are the prerequisite for this process. To get these details, refer T-code OAC3.
A. Existing attachments to the material.
B. To create attachment:
Following are the function modules required to be executed for attaching the document.
- Use FM ARCHIVOBJECT_CREATE_FILE to generate document id.
A different ARCHIV_DOC_ID is generated every time FM is executed.
- Use FM ARCHIV_CONNECTION_INSERT to attach the document.
C. To fetch attachment:
Following are the function modules required to be executed to get the X-string value of the attachment.
- Use FM ARCHIVOBJECT_GET_URI to get Archive document id i.e. ARC_DOC_ID.
This FM gives document id of the attachment which is required to be passed in next function module. Pass your Business object in OBJECTTYPE (e.g. BUS1001006 for Material Master, BUS2012 for Purchase Order) & object in OBJECT (e.g. Material code, Purchase order number).
- Use FM ARCHIVOBJECT_GET_TABLE to get X-sting.
This function module takes ARC_DOC_ID as an input & gives the X-sting value of the attached document.
Pass Content repository to the ARCHIVE_ID, Document type to DOCUMENT_TYPE & get ARCHIV_DOC_ID from FM ARCHIVOBJECT_GET_URI.
This will give the X-string value for the attachment. You can use this X-string value for the further process.
Happy Learning!!! 🙂