‎2007 May 30 6:51 AM
Hi,
Iam doing a report ALV grid display & FTP download. I need a code for FTP download.
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.
Thanks & Regards
Mahesh D.R
‎2007 May 30 7:04 AM
Hi Mahesh,
Please check this weblog.
/people/thomas.jung3/blog/2004/11/15/performing-ftp-commands-from-abap
Also Search in <b>SDN with key - FTP syntax</b>
Will get few more useful related Posts. - Refer Ferry Lianto's answer.
Reward points if this helps.
Manish
‎2007 May 30 7:04 AM
Hi Mahesh,
Please check this weblog.
/people/thomas.jung3/blog/2004/11/15/performing-ftp-commands-from-abap
Also Search in <b>SDN with key - FTP syntax</b>
Will get few more useful related Posts. - Refer Ferry Lianto's answer.
Reward points if this helps.
Manish
‎2007 May 30 7:27 AM
* 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 <> 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 <> 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.
Girish
‎2007 May 30 7:29 AM
simple method ......
*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.
Girish
‎2007 May 30 10:05 AM
Hi All,
Thanks for your replies But my scenario is :
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.
Please provide the solution.
Thanks & Regards
Mahesh D.R