Technical Articles
Akshay Yerawar
Posted onApril 22, 2018 2 minute read
Programmatically create and retrieve documents attached in GOS (Generic Object Services) via Stored business document.
FollowRSS feedLike
15 Likes 16,716 Views 8 Comments
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.
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.
Following are the function modules required to be executed to get the binary 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 binary value.
This function module takes ARC_DOC_ID as an input & gives the binary 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 binary value for the attachment.
If you want to download the file in ECC, you can call method cl_gui_frontend_services=>gui_download. With this method file can be downloaded in given path.
If you want to use this in Ui5 application, you can use FM “SCMS_BINARY_TO_XSTRING“, which will convert binary value to XSTRING value. Ui5 developer can consume this Xstring value through Odata service.
Happy Learning!!!
Alert Moderator
Assigned tags
PLM Document Management System (DMS)
generic object services attachment
Generic Object Services FM
Generic Object Services programtically
Generic Object Services via stored business objects
View more...
Related Blog Posts
DMS HR - Enhancing GOS List option and Changing the Title of the attached document created using Store Business Document (SBD) in GOS
By Firoz Ashraf, Dec 30, 2012
Content Repository Migration in mind ?
By Sagar Shridhar Bhide, Dec 09, 2019
Avoid storage of Attachments in SAP Office tables (SOOD, SOFM, SOC3, SOFFCONT1) & Store it on OpenText Archive Server
By Kolusu Suresh Kumar, Dec 17, 2015
Related Questions
SOFFPHIO and GOS attachment
By Former Member, Nov 16, 2010
Storing Document in content server through Create Attachment(GOS)
By Former Member, Apr 17, 2013
ArchiveLink
By Former Member, May 16, 2011
8 Comments
Pratik Doshi
April 23, 2018 at 11:52 am
Excellent document akshay. Keep it up.
Like(1)
Reply
Alert Moderator
Akshay Yerawar Post author
April 23, 2018 at 11:54 am
Thank you Pratik. Appreciate that.
Like(0)
Reply
Alert Moderator
Michelle Crapo
April 23, 2018 at 12:14 pm
Interesting. We don’t have any sort of document management . We save documents to a drive on the database server. OAC3 is not set up. This might be an interesting future project for me. As to load onto the database server a custom program is used anyway. Then another customer program to pull back the data for display. This seems like a better way.
Michelle
Like(1)
Reply
Alert Moderator
Akshay Yerawar Post author
May 27, 2020 at 10:27 am
Thanks Michelle. I’m happy that you found it useful.
Like(0)
Reply
Alert Moderator
Sayantani Sensharma
July 15, 2020 at 9:48 pm
I was searching for a way to achieve this for two days and couldn’t find anything. Thankfully I stumbled upon your blog! This has been a life saver! Thank you
I have an additional requirement to enable deletion of the attached files as well. Can you tell me the FM name for it?
Like(1)
Reply
Alert Moderator
Akshay Yerawar Post author
October 24, 2020 at 9:58 am
Hi Sayantani,
Glad to hear this blog helped you.
For deletion functionality you may use FM “ARCHIVOBJECT_DELETE“.
Like(0)
Reply
Alert Moderator
Shruti Shah
September 17, 2020 at 6:50 pm
Where will you enter download document logic if I want to download document when the user clicks on the attachments option.
Like(0)
Reply
Alert Moderator
Akshay Yerawar Post author
October 24, 2020 at 10:04 am
Hi Shruti,
It depends in which application you are implementing the logic.
If you are implementing this logic in Module pool, you have write logic in PAI.
If you are implementing this logic in Webdynpro application, you have to write logic on that Action.
If you are implementing this logic in UI5 application, you have to write logic in respective entity set of the oData service.
Like(0)
Reply