cancel
Showing results for 
Search instead for 
Did you mean: 

cl_wd_runtime_services=>attach_file_to_response not saving the file

david_fryda2
Participant
0 Kudos

Hi everyone,

I am trying to save a content of type xstring to a shared location on a server but it does not work.

But I can display the content.

Can anyone help ?

Thanks.

Regards.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi David,

Where you are getting problem, kindly paste the code...

Cheers..

Kris.

david_fryda2
Participant
0 Kudos

Hi Kissnas,

I already solved it. Thanks anyway!

The problem is that I set TRUE the i_in_new_window and i_inplace parameters.

They should be set to FALSE.

Not it is working.

Here is the code :

DATA lo_nd_nd_main TYPE REF TO if_wd_context_node.

DATA lo_el_nd_main TYPE REF TO if_wd_context_element.

DATA ls_nd_main TYPE wd_this->element_nd_main.

DATA lv_data LIKE ls_nd_main-data.

  • navigate from <CONTEXT> to <ND_MAIN> via lead selection

lo_nd_nd_main = wd_context->get_child_node( name = wd_this->wdctx_nd_main ).

  • get element via lead selection

lo_el_nd_main = lo_nd_nd_main->get_element( ).

  • get single attribute

lo_el_nd_main->get_attribute(

EXPORTING

name = `DATA`

IMPORTING

value = lv_data ).

DATA: lv_file_name TYPE string VALUE '
server\file.txt'.

cl_wd_runtime_services=>attach_file_to_response(

i_filename = lv_file_name

i_content = lv_data

i_mime_type = 'text/plain'

i_in_new_window = abap_false

i_inplace = abap_false ).

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>DATA: lv_file_name TYPE string VALUE '
server\file.txt'.

You can't force a silent download or force the location with cl_wd_runtime_services=>attach_file_to_response due to browser security restrictions. cl_wd_runtime_services=>attach_file_to_response will simply open the dialog within the browser asking the user to save the file. The user will then choose the location.

david_fryda2
Participant
0 Kudos

Thanks Thomas!