‎2008 Apr 02 10:01 AM
Hello Everyone,
I need to connect to another server via FTP, and I am using FTP_CONNECT for that. After connection is established, I need to get the file based on the directory. How do I do that? I found FM FTP_COMMAND, but what command should I use?
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
HANDLE =
command =
COMPRESS =
RFC_DESTINATION =
VERIFY =
IMPORTING
FILESIZE =
FILEDATE =
FILETIME =
tables
data =
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3
OTHERS = 4
.
What value should I pass to each field?
Thanks,
Louisse
‎2008 Apr 02 11:28 AM
Go through this blog.
Link : [https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/4743] [original link is broken] [original link is broken] [original link is broken];
Result_itab will have values like
1.FTP is connected
2.local directory has been changed
3.File has been placed.
This approach is used to get the file from legacy and put it into application server then you can read the file with Open dataset and read dataset command.
Rajesh Pichholiya
‎2008 Apr 02 10:09 AM
hi,
*--> Scramble the password.
CALL FUNCTION 'SCRAMBLE_STRING'
EXPORTING
source = password
key = 26101957
IMPORTING
target = password.
*--> Connect to the FTP server.
* user is the logon user for the FTP server.
password is the password you have just scrambled.
host is the ip address of the FTP server.
rfc_destination is 'SAPFTPA'.
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = user
password = password
host = host
rfc_destination = rfc_destination
IMPORTING
handle = wa_handle
EXCEPTIONS
not_connected = 1
OTHERS = 2.
*--> Carry out the command on the FTP server
* wa_command is the command you wish to carry out on the FTP server (e.g.
wa_command = 'ascii' will specify ascii mode). Result_itab will contain the
result of your commands.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = wa_handle
command = wa_command
TABLES
data = result_itab
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
*--> Disconnect from the target host.
CHECK NOT wa_handle IS INITIAL.
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = wa_handle
EXCEPTIONS
OTHERS = 1.
The IMPORT parameters are as :
USER i.e the userid
PASSWORD,
HOST i.e the FTP server
RFC_DESTINATION ( the parameter passed corresponding to this must be of type RFCDES_RFCDEST ).
All these IMPORT parameters except RFC_DESTINATION are of TYPE C.
The EXPORT parameter is the
HANDLE ( this identifies the FTP connection ). Its of TYPE I.
Hope this helps
Edited by: Runal Singh on Apr 2, 2008 2:40 PM
‎2008 Apr 02 10:15 AM
Hello,
Thanks for your prompt reply. I would just like to confirm that if I put a value of ASCII to wa_command parameter of FM FTP_COMMAND, will this retrieve the files from the server? And that the file will be stored in internal table result_itab?
Thanks,
Louisse
‎2008 Apr 02 11:28 AM
Go through this blog.
Link : [https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/4743] [original link is broken] [original link is broken] [original link is broken];
Result_itab will have values like
1.FTP is connected
2.local directory has been changed
3.File has been placed.
This approach is used to get the file from legacy and put it into application server then you can read the file with Open dataset and read dataset command.
Rajesh Pichholiya