data: maktlines type standard table of makt,
url type string,
cached_response type ref to if_http_response,
salvobject type ref to cl_salv_table,
filexstring type xstring.
*Build a simple file with some data in it
select * up to 10 rows from makt into table maktlines.
cl_salv_table=>factory( importing r_salv_table = salvobject changing t_table = maktlines ).
filexstring = salvobject->to_xml( 10 ) .
*Build a dynamic URL
url = |/sap/public/| && cl_system_uuid=>create_uuid_x16_static( ).
*Load the file into the URL
cached_response = new cl_http_response( add_c_msg = 1 ).
cached_response->set_status( code = 200 reason = 'OK' ).
cached_response->set_header_field( name = if_http_header_fields=>cache_control
value = 'no-cache' ).
cached_response->set_header_field( name = if_http_header_fields=>content_disposition
value = |attachment;filename=testfile.xlsx| ).
cached_response->set_header_field( name = if_http_header_fields=>content_type
value = |application/octet-stream| ).
cached_response->set_data( data = filexstring
length = xstrlen( filexstring ) ).
cached_response->set_compression( options = cached_response->co_compress_based_on_mime_type ).
cached_response->server_cache_expire_rel( expires_rel = '60' ).
cl_http_server=>server_cache_upload( url = url
response = cached_response ).
*Note the changes in below screenshot
url = |javascript:window.open("{ url }");|.
*Open the newly built URL
call function 'ITS_BROWSER_WINDOW_OPEN'
exporting
url = url
*Note the changes in below screenshot
window_name = '_self'
exceptions
error_message = 1
its_not_available = 1
others = 2.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
6 | |
5 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 |