Skip to Content
0

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

Aug 03, 2017 at 12:28 PM

384

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

"

https://help.sap.com/saphelp_nw74/helpdata/en/a2/4c8490449041b88b7890d299b57351/frameset.htm

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

Thanks and regards

Christoph

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
0

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:

DATA: 
    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 ).  

"...
Share
10 |10000 characters needed characters left characters exceeded