Skip to Content

SAP Gateway download Excel via Parameter &$format=xlsx -> Change Filename

Aug 03, 2017 at 12:28 PM


avatar image
Former Member

Hey guys,

following Scenario: I want to download an Excel File through OData (SAP Gateway) via Parameter &$format=xlsx. How can I change the filename?

Refering to the documenation there is a field in the response that is responsible for the filename.

"The HTTP response header content-disposition is filled to suggest as file name the entity set name to the client:

content-disposition: attachment; filename=Employees.xlsx


But I am not able to set this field in my GET_ENTITYSET Method. Any ideas?

Thanks and regards


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Nabi Zamani Mar 18 at 11:36 AM

This is standard HTTP, in other words: You have to add a simple http header to the response. However, you do this in GET_STREAM and not in GET_ENTITYSET.

So in your redefined GET_STREAM do something like this:

    ls_header TYPE ihttpnvp,
    lv_filename type string.


lv_filename     = 'Employees.xlsx'.  "get the value from somewhere...
ls_header-name  = 'Content-Disposition'.
ls_header-value = 'attachment; filename="' && lv_filename && '"'.

me->/iwbep/if_mgw_conv_srv_runtime~set_header( is_header = ls_header ).  

10 |10000 characters needed characters left characters exceeded