Skip to Content
0
Jun 16, 2020 at 02:40 PM

ABAP - Failed to download internal table (Loop error)

131 Views Last edit Jun 16, 2020 at 02:56 PM 2 rev

Hey,

I tried to download the internal table, which also worked, but the whole content of the database was copied and not just the one i specified in my internal table (in my loop).

My Code:

DATA: lt_lekud    TYPE TABLE OF lekud,      ls_lekud    TYPE lekud.

...

LOOP AT lt_lekud INTO ls_lekud.
  WRITE: (20) ls_lekud-name, (20) ls_lekud-number, (20) ls_lekud-plz, (20)  ls_lekud-description.
  NEW-LINE.
ENDLOOP.

IF sy-subrc = 0.

  CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
      default_extension = 'csv'
      default_file_name = 'member'
      file_filter       = |Excel-File (*.csv)\|*.csv\|{ cl_gui_frontend_services=>filetype_all }|
    CHANGING
      filename          = lv_filename
      path              = lv_path
      fullpath          = lv_fullpath.

  CALL METHOD cl_gui_frontend_services=>gui_download
    EXPORTING
      filename              = lv_filename
      filetype              = 'ASC'
      write_field_separator = 'X'
      bin_filesize          = lv_size
    CHANGING
      data_tab              = lt_lekud
    EXCEPTIONS
      file_write_error      = 1
      OTHERS                = 22.

ENDIF.

The download works fine, but not only the name, number, plz, and description are shown, the complete lekud table, although I refer to my internal table.

Thanks in advance ;)