cancel
Showing results for 
Search instead for 
Did you mean: 

FILE DOWNLOAD ISSUE IN WEB DYNPRO

Former Member
0 Kudos

Hello,

I've developed wd to display table then I placed a 'getpdf' button on the view to download the contents of that table, In that action button I wrote the following code.

But it doesn't seem to be working.

DATA lo_nd_emp_det TYPE REF TO if_wd_context_node.

  DATA:

  lt_emp_det TYPE wd_this->elements_emp_det,

  ls_emp_det TYPE wd_this->element_emp_det.

  DATA:

  str  TYPE string,

  xstr TYPE xstring.

* navigate from <CONTEXT> to <EMP_DET> via lead selection

  lo_nd_emp_det = wd_context->get_child_node( name = wd_this->wdctx_emp_det ).

  lo_nd_emp_det->get_static_attributes_table( IMPORTING table = lt_emp_det ).

  "Prepare download file.

  LOOP AT lt_emp_det INTO ls_emp_det.

   CONCATENATE  str

  ls_emp_det-pernr

  ls_emp_det-nachn

  ls_emp_det-vorna

  ls_emp_det-gbdat

  cl_abap_char_utilities=>newline

   INTO str

   SEPARATED BY cl_abap_char_utilities=>horizontal_tab.

  ENDLOOP.

  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

   EXPORTING

  text  = str

   IMPORTING

  buffer = xstr

   EXCEPTIONS

  failed = 1.

  "Attach file

  CALL METHOD cl_wd_runtime_services=>attach_file_to_response

   EXPORTING

  i_filename  = 'Download.xls'

  i_content  = xstr

  i_mime_type  = 'EXCEL'

  i_in_new_window = abap_false

  i_inplace  = abap_false.

The sy-subrc retruning zero, But I couldn't see file downloaded.

Please help me.

regards,

Nagendra

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Its working fine in my system. I'm using IE.Check the attachement for reference.

Thanks

KH

Former Member
0 Kudos

Hi,

Have you checked whether value for XSTR is getting filled before using it in attach_file_to_response( ) . Refer this thread which might help you.

FPM / Method cl_wd_runtime_services=>attach_file_to_response is not working

Thanks

KH

Former Member
0 Kudos

Hi KH,

Yes , I'm getting the value into xstr I also tried wdr_task but didn't work.any issue with the browser ? i'm using chrome

thanks

regards,

Nagendra