<?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: function module for downloading in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-for-downloading/m-p/3464450#M832615</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this program and  &lt;STRONG&gt;&amp;lt;REMOVED BY MODERATOR&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
tables:mara.

data:begin of i_header occurs 0,
     field(30) type c,
     end of i_header,

    begin of itab occurs 0,
     matnr type mara-matnr,
     ersda type mara-ersda,
     ernam type mara-ernam,
     laeda type mara-laeda,
     end of itab.
select matnr ersda ernam laeda from mara into corresponding fields of table itab.
REFRESH i_header.
  i_header-field = 'Material number'.
  append i_header.
  i_header-field = 'creation Date'.
  append i_header.
  i_header-field = 'name of person'.
  append i_header.
  i_header-field = 'last date'.
  append i_header.

  clear i_header.


CALL FUNCTION 'WS_DOWNLOAD'
 EXPORTING
*   BIN_FILESIZE                  = ' '
*   CODEPAGE                      = ' '
    FILENAME                     = 'D:\prsr\3.xls'
   FILETYPE                      = 'DAT'
*   MODE                          = ' '
*   WK1_N_FORMAT                  = ' '
*   WK1_N_SIZE                    = ' '
*   WK1_T_FORMAT                  = ' '
*   WK1_T_SIZE                    = ' '
*   COL_SELECT                    = ' '
*   COL_SELECTMASK                = ' '
*   NO_AUTH_CHECK                 = ' '
* IMPORTING
*   FILELENGTH                    =
  TABLES
    data_tab                      = itab
    FIELDNAMES                    = i_header
 EXCEPTIONS
*   FILE_OPEN_ERROR               = 1
*   FILE_WRITE_ERROR              = 2
*   INVALID_FILESIZE              = 3
*   INVALID_TYPE                  = 4
*   NO_BATCH                      = 5
*   UNKNOWN_ERROR                 = 6
*   INVALID_TABLE_WIDTH           = 7
*   GUI_REFUSE_FILETRANSFER       = 8
*   CUSTOMER_ERROR                = 9
*   NO_AUTHORITY                  = 10
   OTHERS                        = 0
          .
IF sy-subrc &amp;lt;&amp;gt; 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alvaro Tejada Galindo on Feb 26, 2008 11:47 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Feb 2008 12:59:25 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-02-26T12:59:25Z</dc:date>
    <item>
      <title>function module for downloading</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-for-downloading/m-p/3464449#M832614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi friends,&lt;/P&gt;&lt;P&gt;    i want function module to download the sap data in to flat file in particular format...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1#harish#bombay&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regard's&lt;/P&gt;&lt;P&gt;mahesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 12:56:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-for-downloading/m-p/3464449#M832614</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-26T12:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: function module for downloading</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-for-downloading/m-p/3464450#M832615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try this program and  &lt;STRONG&gt;&amp;lt;REMOVED BY MODERATOR&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
tables:mara.

data:begin of i_header occurs 0,
     field(30) type c,
     end of i_header,

    begin of itab occurs 0,
     matnr type mara-matnr,
     ersda type mara-ersda,
     ernam type mara-ernam,
     laeda type mara-laeda,
     end of itab.
select matnr ersda ernam laeda from mara into corresponding fields of table itab.
REFRESH i_header.
  i_header-field = 'Material number'.
  append i_header.
  i_header-field = 'creation Date'.
  append i_header.
  i_header-field = 'name of person'.
  append i_header.
  i_header-field = 'last date'.
  append i_header.

  clear i_header.


CALL FUNCTION 'WS_DOWNLOAD'
 EXPORTING
*   BIN_FILESIZE                  = ' '
*   CODEPAGE                      = ' '
    FILENAME                     = 'D:\prsr\3.xls'
   FILETYPE                      = 'DAT'
*   MODE                          = ' '
*   WK1_N_FORMAT                  = ' '
*   WK1_N_SIZE                    = ' '
*   WK1_T_FORMAT                  = ' '
*   WK1_T_SIZE                    = ' '
*   COL_SELECT                    = ' '
*   COL_SELECTMASK                = ' '
*   NO_AUTH_CHECK                 = ' '
* IMPORTING
*   FILELENGTH                    =
  TABLES
    data_tab                      = itab
    FIELDNAMES                    = i_header
 EXCEPTIONS
*   FILE_OPEN_ERROR               = 1
*   FILE_WRITE_ERROR              = 2
*   INVALID_FILESIZE              = 3
*   INVALID_TYPE                  = 4
*   NO_BATCH                      = 5
*   UNKNOWN_ERROR                 = 6
*   INVALID_TABLE_WIDTH           = 7
*   GUI_REFUSE_FILETRANSFER       = 8
*   CUSTOMER_ERROR                = 9
*   NO_AUTHORITY                  = 10
   OTHERS                        = 0
          .
IF sy-subrc &amp;lt;&amp;gt; 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alvaro Tejada Galindo on Feb 26, 2008 11:47 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 12:59:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-for-downloading/m-p/3464450#M832615</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-26T12:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: function module for downloading</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-for-downloading/m-p/3464451#M832616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Uma,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to download the data to flat file on presentation server use the function mdoule &lt;STRONG&gt;GUI_DOWNLOAD&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the # you need is actually the horizontal tab separator in SAP represented by CL_ABAP_CHAR_UTILITIES=&amp;gt;HORIZONRAL_TAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So say you have an internal table &amp;lt;itab&amp;gt; with work area &amp;lt;wa&amp;gt; with 2 columns &amp;lt;field1&amp;gt; and &amp;lt;field2&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can create a single internal table with one field of type string and &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
loop at &amp;lt;itab&amp;gt; into &amp;lt;wa&amp;gt;.
concatenate &amp;lt;wa&amp;gt;-&amp;lt;field1&amp;gt; &amp;lt;wa&amp;gt;-&amp;lt;field2&amp;gt; into &amp;lt;wa_string&amp;gt; separated by cl_abap_char_utilities=&amp;gt;horizontal_tab.
append &amp;lt;wa_string&amp;gt; to &amp;lt;itab_string&amp;gt;.
endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then download the internal table &amp;lt;itab_string&amp;gt; using GUI_DOWNLOAD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 13:01:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-for-downloading/m-p/3464451#M832616</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-26T13:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: function module for downloading</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-for-downloading/m-p/3464452#M832617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
* These variable are for file download.
DATA: ld_filename TYPE string,
      ld_path TYPE string,
      ld_fullpath TYPE string,
      ld_result TYPE i.

* Display save dialog window
  CALL METHOD cl_gui_frontend_services=&amp;gt;file_save_dialog
    EXPORTING
*      window_title      = ' '
      default_extension = 'XLS'
      default_file_name = 'accountsdata'
      initial_directory = 'c:\temp\'
    CHANGING
      filename          = ld_filename
      path              = ld_path
      fullpath          = ld_fullpath
      user_action       = ld_result.

* Check user did not cancel request
  CHECK ld_result EQ '0'.

  CALL FUNCTION 'GUI_DOWNLOAD'
   EXPORTING
        filename         = ld_fullpath
        filetype         = 'ASC'
*       APPEND           = 'X'
        write_field_separator = 'X'
*       CONFIRM_OVERWRITE = 'X'
   TABLES
        data_tab         = t_partner[]     "need to declare and populate
   EXCEPTIONS
        file_open_error  = 1
        file_write_error = 2
        OTHERS           = 3.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use the above code for download the file and save it into front end in excel format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t_partner[] is an internal table to display the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;lt;REMOVED BY MODERATOR&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Alvaro Tejada Galindo on Feb 26, 2008 11:48 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 13:06:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-for-downloading/m-p/3464452#M832617</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-26T13:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: function module for downloading</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-for-downloading/m-p/3464453#M832618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use the function module gui_download to download the data to the flat file.&lt;/P&gt;&lt;P&gt;use the function module gui_upload  to upload the flat file&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2008 16:51:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/function-module-for-downloading/m-p/3464453#M832618</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-26T16:51:19Z</dc:date>
    </item>
  </channel>
</rss>

