Skip to Content
avatar image
Former Member

FILE DOWNLOAD ISSUE IN WEB DYNPRO

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jan 13, 2015 at 12:15 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

      debug.png (23.8 kB)
  • avatar image
    Former Member
    Jan 13, 2015 at 12:26 PM

    Hi,

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

    Thanks

    KH


    Excel Download.xml (131.3 kB)
    Add comment
    10|10000 characters needed characters exceeded