My task was to perform a migration that uploads files to the Generic Object Service (BC-SRV-GBT-GOS).

I knew that the files are stored via Business Document Service (BC-SRV-BDS) using the Knowledge Provider (BC-SRV-KPR).
So I thought I will google a released and documented API for that:
But, hey this is SAP! We would not earn so much money, if everything is perfectly documented ;-)
I found a few blogs and comments, but non served me well.
So I spend a bit of time finding a solution and I would like to share this with you.
There is an API for that
My input is a binary file, so I need something that can handle RAW data, sometimes also called HEX.
I came across the function module SO_ATTACHMENT_INSERT_API1, but then I would need to call a few undocumented FMs to create a folder and link it to that. For me this was too much undocumented stuff.
At the end I found the static BOR method Message.Create, which is officially released by SAP
Sample
To demonstrate how it works, here is a sample program:
- The file is uploaded with cl_gui_frontend_services=>gui_upload from the frontend.
- Filename and extension are split with the help of DMS function modules
- Storage with BOR method Message.Create
- Linking the document to the original BOR object using BINARY_RELATION_CREATE
Background
Just a few remarks:
2010 SAP enhanced the BCS APIs to handle four digit file name extensions. Check note 1459896.
By default BCS documents are stored in the main SAP database. So keep that in mind when planning a big migration! You can also store the document on a Content Server.
Compare:
Note 904711 - SAPoffice: Where are documents physically stored?
Note 530792 - Storing documents in the generic object services
Hope I could help, if you are on a similar task.