11-02-2010 1:23 PM
Hi
I am trying to create an Excel File in FTP using an Internal table data.
I am able to create the file. But there is no data transferred.
Only empty file is being created
Help me with any solution
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = l_pwd
sourcelen = l_slen
key = c_key
IMPORTING
destination = l_pwd.
To Connect to the Server using FTP
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = 'FTP_MIGDE'
password = l_pwd
host = l_host
rfc_destination = 'SAPFTP'
IMPORTING
handle = gv_hdl
EXCEPTIONS
OTHERS = 1.
*Delete the existing file
CONCATENATE 'del' g_file INTO gv_delfile SEPARATED BY space.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = gv_hdl
command = 'cd folder'
TABLES
data = result
EXCEPTIONS
command_error = 1
tcpip_error = 2.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = gv_hdl
command = gv_delfile
TABLES
data = result
EXCEPTIONS
command_error = 1
tcpip_error = 2.
DATA: gv_lines TYPE i,
gv_length TYPE i.
*FTP_R3_TO_SERVER:used to transfer the internal table data as a file to other system in the character mode.
DESCRIBE TABLE gt_line_final LINES gv_lines.
gv_length = gv_lines * 2000.
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
handle = gv_hdl
fname = g_file "file path of destination system
character_mode = 'X'
blob_length = gv_length
TABLES
text = gt_line_final
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
RAISING invalid_output_file.
ENDIF.
*FTP_DISCONNECT: This is used to disconnect the connection between SAP and other system.
To disconnect the FTP
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = gv_hdl.
*RFC_CONNECTION_CLOSE:This is used to disconnect the RFC connection between SAP and other system.
CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
destination = 'SAPFTP'
EXCEPTIONS
OTHERS = 1.he R/3 Internal table.
11-02-2010 1:36 PM
Hi,
Can you check in debugging that in 'FTP_R3_TO_SERVER' function which value 'ftp_handles' internal table is getting.
Edited by: Mukund Kansara on Nov 2, 2010 2:36 PM
11-03-2010 11:50 AM
Hi!
Try this:
data: path type char256.
path = '/home/test.txt'. "FTP file localization with filename and extension
open dataset path for output in text mode encoding default.
if sy-subrc eq 0.
loop at it_fil.
if it_fil <> space.
transfer it_fil to line.
endif.
endloop.
else.
exit.
endif.
close dataset line.