Currently base on training material, we usually redefine GET_STREAM method and pass mime type and stream value to the result.
ls_stream-mime_type = output-return-MIME_TYPE .
ls_stream-value = output-return-DOCUMENT_STREAM .
copy_data_to_ref( 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’.
Problem
Solution
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 ).
ls_lheader-name = 'Content-Disposition'.
ls_lheader-value = 'outline; filename="Mobile.pdf";'.
set_header( is_header = ls_lheader ).
ls_stream-mime_type = output-return-MIME_TYPE .
ls_stream-value = output-return-DOCUMENT_STREAM .
copy_data_to_ref( 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_lheader-value = '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 a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
26 | |
13 | |
12 | |
11 | |
9 | |
9 | |
7 | |
5 | |
5 | |
5 |