<?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: Sample code for FTP download in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-ftp-download/m-p/2241241#M483245</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;simple   method  ...... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*Selecting a File, plus inserting default file extension
parameters: p_file like rlgrap-filename default 'c:hesa.txt' LOWER CASE.

************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR I_FILE.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR i_file.
  CALL FUNCTION 'WS_FILENAME_GET'
       EXPORTING
            def_filename     = p_file
            mask             = ',*.xls.'
            mode             = 'O'
            title            = 'Upload File'(078)
       IMPORTING
            filename         = p_file
       EXCEPTIONS
            inv_winsys       = 1
            no_batch         = 2
            selection_cancel = 3
            selection_error  = 4
            OTHERS           = 5.

CALL FUNCTION 'GUI_DOWNLOAD'
   EXPORTING
        filename         = p_file
        filetype         = 'ASC'
*       APPEND           = 'X'  
        write_field_separator = 'X'
*       CONFIRM_OVERWRITE = 'X'
   TABLES
        data_tab         = it_datatab[]
   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;&lt;/P&gt;&lt;P&gt;Girish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 May 2007 06:29:45 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-05-30T06:29:45Z</dc:date>
    <item>
      <title>Sample code for FTP download</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-ftp-download/m-p/2241238#M483242</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;Iam  doing a report ALV grid display &amp;amp; FTP download. I need a code for FTP download.&lt;/P&gt;&lt;P&gt;I need both options ALV grid display and FTP download in the report.  I Have completed ALV display. Now i need a code for FTP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;Mahesh D.R&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2007 05:51:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-ftp-download/m-p/2241238#M483242</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-30T05:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Sample code for FTP download</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-ftp-download/m-p/2241239#M483243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mahesh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check this weblog.&lt;/P&gt;&lt;P&gt;/people/thomas.jung3/blog/2004/11/15/performing-ftp-commands-from-abap&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also Search in &amp;lt;b&amp;gt;SDN with key - FTP syntax&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Will get few more useful related Posts.  - Refer Ferry Lianto's answer. &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward points if this helps.&lt;/P&gt;&lt;P&gt;Manish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2007 06:04:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-ftp-download/m-p/2241239#M483243</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-30T06:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Sample code for FTP download</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-ftp-download/m-p/2241240#M483244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;
*   Download internal table to Application server file(Unix)
DATA: e_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.      

  open dataset e_file for output in text mode.
  lOOP AT it_datatab......
    transfer it_datatab to e_file.
  ENDLOOP.
 
  close dataset e_file.

  Download internal table to presentation server file(PC)

  DATA: ld_filename TYPE string,
* Pre version 4.7 declaration e_file like rlgrap-filename.

  DATA: begin of it_datatab occurs 0,
  row(500) type c,
 end of it_datatab.

  call function 'GUI_DOWNLOAD'
       exporting
            filename         = ld_filename
            filetype         = 'ASC'
       tables
            data_tab         = it_datatab[]
       exceptions
            file_open_error  = 1
            file_write_error = 2
            others           = 3.

 

*   Download internal table to presentation server file(PC)
*   Separating fields/columns by a tab

  DATA: ld_filename TYPE string,
* Pre version 4.7 declaration e_file like rlgrap-filename.

  DATA: begin of it_datatab occurs 0,
  col1(50) type c,
  col2(50) type c,
  col3(50) type c,
*       etc....
 end of it_datatab.

  CALL FUNCTION 'GUI_DOWNLOAD'
   EXPORTING
        filename         = ld_filename 
        filetype         = 'ASC'
*       APPEND           = 'X'  
        write_field_separator = 'X'
*       CONFIRM_OVERWRITE = 'X'
   TABLES
        data_tab         = it_datatab[]
   EXCEPTIONS
        file_open_error  = 1
        file_write_error = 2
        OTHERS           = 3.

  *********  please  use this   @   run time  it will give  you the pop  to give the file  path 
 File download, uses older techniques but achieves a perfectly 
* acceptable solution which also allows the user to append data to 
* an existing file.
  PARAMETERS: p_file like rlgrap-filename.

* Internal table to store export data   
  DATA: begin of it_excelfile occurs 0,
   row(500) type c,
   end of it_excelfile.

  DATA: rc TYPE sy-ucomm,
        ld_answer TYPE c.

  CALL FUNCTION 'WS_QUERY'
       EXPORTING
            query    = 'FE'  "File Exist?
            filename = p_file
       IMPORTING
            return   = rc.

  IF rc NE 0.                       "If File alread exists
    CALL FUNCTION 'POPUP_TO_CONFIRM'
      EXPORTING
*          TITLEBAR              = ' '
*          DIAGNOSE_OBJECT       = ' '
           text_question         = 'File Already exists!!'
           text_button_1         = 'Replace'
*          ICON_BUTTON_1         = ' '
           text_button_2         = 'New name'
*          ICON_BUTTON_2         = ' '
*          DEFAULT_BUTTON        = '1'
*          DISPLAY_CANCEL_BUTTON = 'X'
*          USERDEFINED_F1_HELP   = ' '
*          START_COLUMN          = 25
*          START_ROW             = 6
*          POPUP_TYPE            =
      IMPORTING
           answer                = ld_answer
*     TABLES
*         PARAMETER              =
      EXCEPTIONS
          text_not_found         = 1
          OTHERS                 = 2.

* Option 1: Overwrite
*********************
    IF ld_answer EQ '1'.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
*            BIN_FILESIZE            =
             filename                = p_file        "File Name
             filetype                = 'ASC'
*       IMPORTING
*            FILELENGTH              =
        TABLES
            data_tab                = it_excelfile   "Data table
        EXCEPTIONS
            file_write_error        = 1
            no_batch                = 2
            gui_refuse_filetransfer = 3
            invalid_type            = 4
            OTHERS                  = 5.
      IF sy-subrc &amp;lt;&amp;gt; 0.
        MESSAGE i003(zp) WITH
                 'There was an error during Excel file creation'(200).
        exit. "Causes short dump if removed and excel document was open  
      ENDIF.
* Option 2: New name.
*********************
    ELSEIF ld_answer EQ '2'.
      CALL FUNCTION 'DOWNLOAD'
        EXPORTING
             filename            = p_file          "File name
             filetype            = 'ASC'           "File type
*             col_select          = 'X'            "COL_SELECT
*             col_selectmask      = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
*                                                   "COL_SELECTMASK
             filetype_no_show    = 'X'     "Show file type selection?
*       IMPORTING
*             act_filename        = filename_dat
        TABLES
             data_tab            = it_excelfile    "Data table
*            fieldnames          = 
        EXCEPTIONS
             file_open_error     = 01
             file_write_error    = 02
             invalid_filesize    = 03
             invalid_table_width = 04
             invalid_type        = 05
             no_batch            = 06
             unknown_error       = 07.
    ENDIF.
  ELSE.                               "File does not alread exist.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
*          BIN_FILESIZE            =
           filename                = p_file         "File name
           filetype                = 'ASC'          "File type
*     IMPORTING
*          FILELENGTH              =
      TABLES
           data_tab                = it_excelfile   "Data table
      EXCEPTIONS
           file_write_error        = 1
           no_batch                = 2
           gui_refuse_filetransfer = 3
           invalid_type            = 4
           OTHERS                  = 5.
    IF sy-subrc &amp;lt;&amp;gt; 0.
      MESSAGE i003(zp) WITH
               'There was an error during Excel file creation'(200).
      exit. "Causes short dump if removed and excel document was open  
    ENDIF.
  ENDIF.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Girish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2007 06:27:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-ftp-download/m-p/2241240#M483244</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-30T06:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sample code for FTP download</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-ftp-download/m-p/2241241#M483245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;simple   method  ...... &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*Selecting a File, plus inserting default file extension
parameters: p_file like rlgrap-filename default 'c:hesa.txt' LOWER CASE.

************************************************************************
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR I_FILE.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR i_file.
  CALL FUNCTION 'WS_FILENAME_GET'
       EXPORTING
            def_filename     = p_file
            mask             = ',*.xls.'
            mode             = 'O'
            title            = 'Upload File'(078)
       IMPORTING
            filename         = p_file
       EXCEPTIONS
            inv_winsys       = 1
            no_batch         = 2
            selection_cancel = 3
            selection_error  = 4
            OTHERS           = 5.

CALL FUNCTION 'GUI_DOWNLOAD'
   EXPORTING
        filename         = p_file
        filetype         = 'ASC'
*       APPEND           = 'X'  
        write_field_separator = 'X'
*       CONFIRM_OVERWRITE = 'X'
   TABLES
        data_tab         = it_datatab[]
   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;&lt;/P&gt;&lt;P&gt;Girish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2007 06:29:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-ftp-download/m-p/2241241#M483245</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-30T06:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Sample code for FTP download</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-ftp-download/m-p/2241242#M483246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your replies But my scenario is :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For downloading the data in the remote system i need to use FTP function modules, So i need the code for downloading the file in the remote system not into application server.&lt;/P&gt;&lt;P&gt;Please provide the solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;Mahesh D.R&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2007 09:05:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sample-code-for-ftp-download/m-p/2241242#M483246</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-30T09:05:39Z</dc:date>
    </item>
  </channel>
</rss>

