<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ABAP - Failed to download internal table (Loop error) in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-failed-to-download-internal-table-loop-error/m-p/12138325#M1975789</link>
    <description>&lt;P&gt;You are under the impression, that the following statements has any impact on the File Download?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;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.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above statements merely loop over an internal table and write the part of the conten on the screen. One line per record. This has nothing to do with what is actually being downloaded later.&lt;/P&gt;&lt;P&gt;This is were your download happens, and it happens for your internal table lt_lekud, with all its records and all its colomns. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL METHOD cl_gui_frontend_services=&amp;gt;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.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you want to restrict the columns to just name, number, plz and description, the easiest way would be, to create another internal table but with only the above fields and copy the records from lt_lekud to the new table:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: lt_lekud    TYPE TABLE OF lekud,
      ls_lekud    TYPE lekud,
      begin of ls_lekud_short,                      " your new structure with selective columns
       name LIKE ls_lekud-name,
       number LIKE ls_lekud-number,
       plz    LIKE ls_lekud-plz,
       description LIKE ls_lekud-description,
     end of ls_lekud_short,
     lt_lekud_short LIKE TABLE OF ls_lekud_short. " your new table with structure

....

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.

  MOVE-CORRESPONDING ls_lekud TO ls_lekud_short.    " copy row content for selective columns
  INSERT ls_lekud_short INTO TABLE lt_lekud_short.  " insert row content to new table
ENDLOOP.

IF sy-subrc = 0.

 CALLMETHOD cl_gui_frontend_services=&amp;gt;file_save_dialog
    EXPORTING
      default_extension ='csv'
      default_file_name ='member'
      file_filter       =|Excel-File (*.csv)\|*.csv\|{ cl_gui_frontend_services=&amp;gt;filetype_all }|CHANGING
      filename          = lv_filename
      path              = lv_path
      fullpath          = lv_fullpath.

  CALLMETHOD cl_gui_frontend_services=&amp;gt;gui_download
    EXPORTING
      filename              = lv_filename
      filetype              ='ASC'
      write_field_separator ='X'
      bin_filesize          = lv_size
    CHANGING
      data_tab              = lt_lekud_short   " now you pass only the columns you want
    EXCEPTIONS
      file_write_error      = 1
      OTHERS                = 22.

ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 16 Jun 2020 16:14:45 GMT</pubDate>
    <dc:creator>michael_piesche</dc:creator>
    <dc:date>2020-06-16T16:14:45Z</dc:date>
    <item>
      <title>ABAP - Failed to download internal table (Loop error)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-failed-to-download-internal-table-loop-error/m-p/12138323#M1975787</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;
  &lt;P&gt;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).&lt;/P&gt;
  &lt;P&gt;My Code:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;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=&amp;gt;file_save_dialog
    EXPORTING
      default_extension = 'csv'
      default_file_name = 'member'
      file_filter       = |Excel-File (*.csv)\|*.csv\|{ cl_gui_frontend_services=&amp;gt;filetype_all }|
    CHANGING
      filename          = lv_filename
      path              = lv_path
      fullpath          = lv_fullpath.

  CALL METHOD cl_gui_frontend_services=&amp;gt;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.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;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.&lt;/P&gt;
  &lt;P&gt;Thanks in advance &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2020 14:40:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-failed-to-download-internal-table-loop-error/m-p/12138323#M1975787</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-06-16T14:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP - Failed to download internal table (Loop error)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-failed-to-download-internal-table-loop-error/m-p/12138324#M1975788</link>
      <description>&lt;P&gt;Hello &lt;/P&gt;&lt;P&gt;What is LT_ZEKUD?&lt;/P&gt;Kind regards,&lt;BR /&gt;Mateusz</description>
      <pubDate>Tue, 16 Jun 2020 14:52:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-failed-to-download-internal-table-loop-error/m-p/12138324#M1975788</guid>
      <dc:creator>MateuszAdamus</dc:creator>
      <dc:date>2020-06-16T14:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP - Failed to download internal table (Loop error)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-failed-to-download-internal-table-loop-error/m-p/12138325#M1975789</link>
      <description>&lt;P&gt;You are under the impression, that the following statements has any impact on the File Download?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;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.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above statements merely loop over an internal table and write the part of the conten on the screen. One line per record. This has nothing to do with what is actually being downloaded later.&lt;/P&gt;&lt;P&gt;This is were your download happens, and it happens for your internal table lt_lekud, with all its records and all its colomns. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL METHOD cl_gui_frontend_services=&amp;gt;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.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you want to restrict the columns to just name, number, plz and description, the easiest way would be, to create another internal table but with only the above fields and copy the records from lt_lekud to the new table:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: lt_lekud    TYPE TABLE OF lekud,
      ls_lekud    TYPE lekud,
      begin of ls_lekud_short,                      " your new structure with selective columns
       name LIKE ls_lekud-name,
       number LIKE ls_lekud-number,
       plz    LIKE ls_lekud-plz,
       description LIKE ls_lekud-description,
     end of ls_lekud_short,
     lt_lekud_short LIKE TABLE OF ls_lekud_short. " your new table with structure

....

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.

  MOVE-CORRESPONDING ls_lekud TO ls_lekud_short.    " copy row content for selective columns
  INSERT ls_lekud_short INTO TABLE lt_lekud_short.  " insert row content to new table
ENDLOOP.

IF sy-subrc = 0.

 CALLMETHOD cl_gui_frontend_services=&amp;gt;file_save_dialog
    EXPORTING
      default_extension ='csv'
      default_file_name ='member'
      file_filter       =|Excel-File (*.csv)\|*.csv\|{ cl_gui_frontend_services=&amp;gt;filetype_all }|CHANGING
      filename          = lv_filename
      path              = lv_path
      fullpath          = lv_fullpath.

  CALLMETHOD cl_gui_frontend_services=&amp;gt;gui_download
    EXPORTING
      filename              = lv_filename
      filetype              ='ASC'
      write_field_separator ='X'
      bin_filesize          = lv_size
    CHANGING
      data_tab              = lt_lekud_short   " now you pass only the columns you want
    EXCEPTIONS
      file_write_error      = 1
      OTHERS                = 22.

ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jun 2020 16:14:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-failed-to-download-internal-table-loop-error/m-p/12138325#M1975789</guid>
      <dc:creator>michael_piesche</dc:creator>
      <dc:date>2020-06-16T16:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP - Failed to download internal table (Loop error)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-failed-to-download-internal-table-loop-error/m-p/12138326#M1975790</link>
      <description>&lt;P&gt;Thank you very much, I really appreciate that &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2020 18:06:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-failed-to-download-internal-table-loop-error/m-p/12138326#M1975790</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-06-16T18:06:19Z</dc:date>
    </item>
  </channel>
</rss>

