cancel
Showing results for 
Search instead for 
Did you mean: 

Download pdf to local path directly

Former Member
0 Kudos

hi, experts

I want to download pdf to local path directly, but when i

use the class method "cl_wd_runtime_services=>attach_file_to_response", the file is opened by web page.

How can i download file to a specified path directly?

This is a very urgent issue.

Thanks a lot!

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Li Ken,

I am not sure what do you mean for "download pdf to local path directly ".

To my understanding, it might be impossible for the case below.

=> Click a button in webdynpro view, then nothing happens, but you can find the pdf file in desired local path.

However, it is possible to have a pop-up window for specifying local pah, then pdf file is downloaded. (like Internet downloading).

Implement it using UI control - FileDownload

=> Add a control "FileDownload" in the view, then bind with property data a context attribute, which is associated with pdf source (type xstring).

Implement it using the method cl_wd_runtime_services=>attach_file_to_response.

=> please have a look at the code below.

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->element_context.

DATA lv_pdf_file LIKE ls_context-pdf_file.

* get element via lead selection

lo_el_context = wd_context->get_element( ).

* get single attribute

lo_el_context->get_attribute(

EXPORTING

name = `PDF_FILE`

IMPORTING

value = lv_pdf_file ).

CALL METHOD cl_wd_runtime_services=>attach_file_to_response

EXPORTING

i_filename = 'file.pdf'

i_content = lv_pdf_file

i_mime_type = 'application/pdf'

* i_in_new_window = ABAP_FALSE

* i_inplace = ABAP_FALSE

.

Please reward points if helpful!

Best regards!

Gordon

Former Member
0 Kudos

Hi, Gordon

Thanks you for you reply!

My mean is that when I click the button, it do not need pop-up window or open a new web page, but wrote the pdf file to specified path directly.

Is there a other solution to solve this problem?

Thanks you very much!