cancel
Showing results for 
Search instead for 
Did you mean: 

Download an internal table to a txt file from CRM WEB CLIENT

donovan_lemus
Explorer
0 Kudos

Hi everybody,

I'm working with CRM WEB CLIENT 7.0 and I have a problem with a requirement, it is the following:

I develop a certain process to have the data that I need in an internal table.

I have to download that internal table into any folder of my local computer as a txt file by clicking a button.

I've used some methods to do it, but I can't download the data to a file, it just appear in the web browser.

Do you have any ideas guys?

These are the methods:

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

text = lv_log

IMPORTING

buffer = lv_xstring

EXCEPTIONS

FAILED = 1

OTHERS = 2

CALL METHOD cl_bsp_utility=>download

EXPORTING

object_s = lv_xstring

content_type = 'application/download'

content_disposition = 'attachment;filename=prueba.txt'

response = response

navigation = navigation

Thanks in advance,

Regards,

Lemus

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

I have the same problem: I can't download the data to a file, it just appear in the web browser.

Have you found the answer on you question?

Thx.

Former Member
0 Kudos

Hi,

    I have the same problem, but how do you get the values of

      response

      navigation ?

  I'm trying to do this in an action.

thanks

ajaya_kumar
Active Participant
0 Kudos

Hi,

You can try the followng:


DATA: lv_fname           TYPE string,
        lv_outfile         TYPE string,
        timestamp_t(14)    TYPE c,
        p_timestamp        TYPE timestamp.

  GET TIME STAMP FIELD p_timestamp.
  WRITE p_timestamp TO timestamp_t.

  CONCATENATE filedir '\' 'Docu_flow_' timestamp_t '.txt' INTO lv_outfile.

  lv_fname = lv_outfile.

  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename                = lv_fname
      filetype                = 'ASC'
      write_field_separator   = 'X'
      confirm_overwrite       = 'X'
    TABLES
      data_tab                = lt_output_ref_ui
    EXCEPTIONS
      file_write_error        = 1
      no_batch                = 2
      gui_refuse_filetransfer = 3
      invalid_type            = 4
      no_authority            = 5
      unknown_error           = 6
      header_not_allowed      = 7
      separator_not_allowed   = 8
      filesize_not_allowed    = 9
      header_too_long         = 10
      dp_error_create         = 11
      dp_error_send           = 12
      dp_error_write          = 13
      unknown_dp_error        = 14
      access_denied           = 15
      dp_out_of_memory        = 16
      disk_full               = 17
      dp_timeout              = 18
      file_not_found          = 19
      dataprovider_exception  = 20
      control_flush_error     = 21
      OTHERS                  = 22.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

Here lt_output_ref_ui has the data that is to be downloaded.

Hope this helps!

Regards

Ajay

PatrickDean
Participant
0 Kudos

Doubt that will work, Ajaya. GUI_DOWNLOAD makes use of the GUI's relationship with the OS. This doesn't work with the WebBrowser. In fact WebBrowsers require user authentication before just writing files willy-nilly to the OS - otherwise dodgysite.com could write anything it wanted onto your computer without you knowing about it!