GOS attachments download

user3175371 picture user3175371 · Jan 8, 2014 · Viewed 9.6k times · Source

Basically I have some attachments listed in the Generic Object Services (GOS) and I need to download all of them to my computer.

I need to know how do download these attachments programatically from my program/report.

Answer

Smigs picture Smigs · Jan 9, 2014

I've never actually had to do this myself, but I think this is how it's done:

Get the list of attachments by calling cl_binary_relation=>read_links passing in the ID of the object that the attachments are attached to. The it_relation_options table should be filled with a relation like so:

la_relat-sign = 'I'.
la_relat-option = 'EQ'.
la_relat-low = 'ATTA'.     "Attachements
APPEND la_relat TO lt_relat.

This tells read_links to get the related objects classed as attachments.

Once you've successfully got the attachment details, you should be able to loop over the results table and pass each to the SO_OBJECT_READ function module (if that doesn't work try SO_DOCUMENT_READ_API1). This expects a folder id and a document id; in the results of read_links these may be concatenated together into one string (with the object type, e.g. SOFM at the front).

SO_OBJECT_READ will give you the binary content. You can then call SO_OBJECT_DOWNLOAD with (I think) filetype = 'BIN'.

Hope that helps!