SAP Attachments Mass Extraction for Sales Documents (ABAP)

SAP Attachment: The following ABAP program sample is optimized to Mass extraction of SAP Attachments (GOS) for Sales Documents.

SAP Mass Attachments Extraction using ABAP.

The same ABAP Code can be user to mass extract Attachment for

The original post is SAP GOS Attachment Technical

SAP Attachment : Miscellaneous Tips

Search Help for Directory Selection

The method cl_gui_frontend_services=>directory_browse offers to select a folder from presentation server ( local ).

The result SELECTED_FOLDER is the full path for a local directory.

Check if a file exists on presentation Server

The method cl_gui_frontend_services=>file_exist checks if a file exists locally ( on presentation server).

The result is initial if the file dosn’t exist.

Jump to the new ABAP Programming, check the following book: Mastering SAP ABAP: A complete guide to developing fast, durable, and maintainable ABAP programs in SAP

SAP Functions Modules Used for SAP Attachment

Here the list of the main SAP Function Modules & Methods used below in order to extract and to download Attachment


This standard Method cl_gui_frontend_services=>directory_browse will retrieve list of local (desktop) folder.

In the most of cases, it is used to select a folder at presentation server as help search for local Directory Search .


This method cl_gui_frontend_services=>file_exist checks if a file exists already .


SO_OBJECT_DOWNLOAD function module will create a file from internal table in SAP to a given pathname.

ABAP Code for SAP Attachment Mass extraction

Let’s start with the Data declaration we need to Extract Attachment:

The second step is to define the Select Screen

The last step is the extraction of SAP Attachments: