Skip to Content

How to show file name when calling GET_STREAM

This document is about how to enhancement our OData service  – Download File.

Currently base on training material, we usually redefine GET_STREAM method and pass mime type and stream value to the result.

ls_streammime_type = outputreturnMIME_TYPE .
-value = outputreturnDOCUMENT_STREAM .
( EXPORTING is_data = ls_stream
CHANGING  cr_data = er_stream ).

This works, however the problem is if you trigger the service in Chrome. You can only get a document with named ‘entity’.



  • What if customer has already stored file name in ECM or in Database? They want to see the real name.
  • What if customer don’t want to direct download, they may want to review the file before download.


Solution to this is to set a header to http framework. I attached code below.

DATA ls_lheader TYPE ihttpnvp.
“DATA lv_filename TYPE string.
“lv_filename = escape( val = lv_filename format = cl_abap_format=>e_url ).
name = ‘Content-Disposition’.
value = ‘outline; filename=”Mobile.pdf”;’.
( is_header = ls_lheader ).

ls_streammime_type = outputreturnMIME_TYPE .
value = outputreturnDOCUMENT_STREAM .
( EXPORTING is_data = ls_stream
CHANGING  cr_data = er_stream ).

Let’s test the result now:


If customer want to preview the document instead of directly download, please change code as below.

ls_lheadervalue = ‘inline; filename=”Mobile.pdf”;’.

Let’s test the result:

A new page was opened for preview, you can right click and choose to save. File name ‘Mobile.pdf’ comes up.


You must be Logged on to comment or reply to a post.
  • Thanks for document.

    It does not work in ie 10 browser.

    Does anyone have any suggestions?

    I use below code in sapui5.“/sap/opu/odata/sap/MYSERVICE_SRV/DownloadFileSet(‘”+ guid +”‘)/$value”);

  • Good afternoon  Eric Zhao,

    I just want to say THANK YOU for this SOLUTION which I used right now. Through this I was also able to learn new things. THANKS and have a GREAT DAY 🙂 🙂 🙂

  • Hi Eric. Outstanding post!

    I have written same code as stated above but still file gets downloaded with name $ value . Does above code support only some browser version or fiori version .

    Thanks in advance for your support .


  • Hi,

    I have a Master-Detail app. The pdf file opens successfully in the browser as planned.

    But the file is still titled $value.pdf, and switching outline/inline has no effect.

    ls_stream-value = pdf_stream.
    ls_stream-mime_type = 'application/pdf'.
    ls_header-name = 'Content-Disposition'.
    ls_header-value = 'inline; filename="Report.pdf";'.
    set_header( is_header = ls_header ).
    copy_data_to_ref( EXPORTING is_data = ls_stream
                      CHANGING  cr_data = er_stream ).

    Best Regards.

  • Just noticed that if you want to download the file, you should choose “attachment” instead of “outline”, more information here: