Hy everybody,

I recently had the requirement to provide a download URL for a document, that was stored in an Database Table of a SAP ERP System. The idea of the customer was, that the download link should be sent by mail. As i can not provide all tables and infos that are available in customer system, i’ve added a short section to get a document into a sap database table. At customer place, the documents were already stored in a table.

Now i would like to briefly describe the solution for interested people:
(Replace patterns like <value> with your proper values)

Basicly these steps are required.

Step 1) Get Document into Database Table

Step 2) Get Document out of the Database Table

Step 3) Download Document by SICF Service Implementation

Step 4) Add Link to E-Mail Text

Step 1) Get Document into Database Table:

First of all create a database table like this:


The database table is kept simple. Usually you would provide additional info like filetype and so on. Also the dataelements are simple.

Secondly create a simple upload report. You can find a sample report in the attachments (ZZTAB_UPLOAD.abap) (The file can be opened with Notepad or similar application).

Keep in Mind: The sample report is not designed for productive execution. Some Major requirements like error handling, coding style and so on are not properly implemented in this report. It’s just a quick and really dirty solution to upload a file into the a database table. I’m sure you would be able to upgrade this report for your productive system, if you may be in need of it.

Try this example with a simple text file. As shown here it will not work for other file types eg. word/pdf documents. To achieve this, enhance the table with information about the uploaded file mime type & in the handler method set the corresponding mime type with following code:

server->response->set_header_field( name = ‘Content-Type’ value = ‘application/msword’ )

A list of supported mime-types can be found here: MimeTypes

Check your database table if you have your file properly uploaded by the report. Therefore just use SE16/SE16N to check the database entry.


Check Step 1): Finished –  A file is stored in a database table as XSTRING

Step 2) Get Document out of the Database Table

Basicly this step is pretty simple.

data: ls_dbtab type zztab_files.

select single * from zztab_files into ls_files where id = <id>.

if sy-subrc <> 0.

write ‘error on select of document’


Check Step 2): Finished – A file is selected from a database table – But not downloaded using a SICF Service.

So now what to do with the selected file?

You could send it to the frontend like shown in the sample report using cl_gui_frontend_services. In a scenario where you’re users are only using SAP GUI the solution would already fit (except for the coding issues mentioned above). Like mentioned in the introduction, i had a usecase where users needed to download the file by calling an url. Let us head to Step 3) now.

Step 3) Download Document by SICF Service Implementation

So what do we need? We need access to transaction SICF to create a service and activate it. We need to implement the http interface to send our selected file from the database to the frontend using a browser for example. So let’s start.

First of all we need to create a class that implements the following interface IF_HTTP_EXTENSION. I assume that it’s no problem to implement an interface – if there are questions about this, write me a pm or google is a good source achieving this. Implement the interface methods they can be empty by now, as we are coming to the implementation at a later point in this document.


Copy the class name into your clipboard as you require it shortly.

Call Transaction SICF & Execute it without any parameters. You should land in a view similiar to the following printscreen.

Create a new subelement at default_host/sap/bc node. There is a namespace warning appearing -> you can confirm the warning.


Now this screen appears: Enter a name for your service – i called it ZZTEST_FILE. Leave radiobuttons as they are set by default and click continue.


The following screen appears: Switch to the tab “Handler-List” and enter the class you just created in the handler list, add a meanigful description and save your changes.


The system will prompt you for package assignemt and a transport request. I’ve created them as local objects.

Hit the back button to get into the sicf tree overview. Search your service name unter default_host/sap/bc/<your_service_name> – Right Click on it and activate it. Confirm the the message and your service is up running. In the same context menu there is also an option “Test Service” keep this in mind and let transaction SICF open in a single mode of SAP GUI.


So in the transaction SICF now everything is set up for our file download. For security issues usually as developer i never had access to the SICF transaction and therefore always asked someone in the basis team to help out. They usually now SICF pretty well & can decide from a security viewpoint where the service has to be maintained. I’m sure they will help you out.

Let’s get back to the Handler Class we created earlier. If you set a break-point at the endmethod statement of the method you can try if everything works by using the option Test Service in the SICF Context Menu on your service. Be sure to set an external breakpoint.


if you now test the service from SICF like mentioned above. You should end up in the debugger at the endmethod statement.


So now there is one single thing to do for Step 3) and that’s implementing the handle_request method. I’ve provide the sample code also in the attachments.

handler method.png

Basicly the following things happen:

Read GET Parameters (as we will provide a GET Parameter fileid in the url call)

Check that only numeric values ar passed using the GET Parameter fileid / i want to prevent somebody executing sql via sql injection.

Select the file from the db tab

Set File Content in Response

Be aware, that in this context of programming lots of security aspects have to be covered. Thats why i strictly advise you to implement this example only on sandbox systems to get a basic understanding of the topic. If you want to use this approach on production => Improve the simple example drastically 

So now lets check the downloaded content:

Test your service using the SICF Test Service functionality described above.

There should be a browser starting & depending on your system settings your credentials will be prompted. Enter them. The following result should appear. I’ve hided the browser & unnecessary information but this should not disturb you.


You will see a URI with following pattern:


The bold part in the url is exactly the navigation path in the SICF nodes. Then your service name is followed & by default sap-client parameter is also present.

To check your downloaded file append following GET parameter to your URI:

&fileid=<ID in DBTAB>

In my case it would be &fileid=4

So the complete URI for downloading a file is:


Step 4) Sending the Link by E-Mail

This step is pretty easy using Business Document Classes. If you need help sending an E-Mail let me know and i’ll complete this tutorial. By know i think there is plenty of good stuff available for sending mails with SAP.

I hope you enjoyed the tutorial and that there was something new for you and you have learned something. Have fun while giving it a try.

Best regards,


To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Katan Patel

    Nice blog.  I’m kind of suprised nobody has written about this before.  I’ve done a few searches and found nothing specifically to expose a file download service.  

    I think it’s really important to know how to do this. More specifically how to expose a service over SICF and also to have a good understanding of HTTP Interactions between client and server.  I absolutely recommend folks have a peak at the Chrome developer tools and see how the server behaves to the requests from a web client.

    I’m also glad you emphasised the quick and dirty aspect of using this approach. 

    Keep up the good work..



    1. Michael Albrecht Post author

      Hy Katan,

      thank you for your comment. I completly agree with u, that a good understanding of http interactions is necessary to ensure proper communication from client to server. I think it is absolutly necessary to point at quick and dirty aspects because such tutorials might seem like a productive solution and can lead developers who are fresh at a topic to miss basic requirements, that are not mentioned in detail while specifications are written down.

      I’ll continue writing some tutorials and approches that could be used to solve problems. As i have some pretty usefull code implemented during my time as abap developer that i frequently reuse in most of my projects.

      the next topic that i’ll write about is handling rfc destinations in various abap code in a configurable & flexible way, so that all developers of a dev team can use such kind of an approach. right now it is in my head and i need some time to write it down properly on scn.

      have a nice day everyone and if you’re interested feel free to follow me on scn.




Leave a Reply