2023 Jan 16 7:23 AM
I want to copy the file from one folder to another.
I am using SAPFTPA.
these function modules are used Function module used CALL FUNCTION 'HTTP_SCRAMBLE' , CALL FUNCTION 'FTP_CONNECT',
CALL FUNCTION 'FTP_COMMAND' , CALL FUNCTION 'FTP_SERVER_TO_R3'
. The path D:\Sales\Macine\Product\fail_log contains file test.csv
and i want to move test.csv file to another path D:\Sales\Macine\Product\fail_log_n
can any one guide me.....
2023 Jan 16 7:26 AM
The file is in presentation server or Application server ? Why do you used FTP command for non FTP protocol ?
2023 Jan 16 7:48 AM
frdric.girod
We have third party integration process about sales data. the third party is send files on ftp server (with ip ).
Our program picking the files from that path , reading it and then deleting files .
But before deleting these file we want the copy of this file on another folder for backup purpose,
Thank you
2023 Jan 16 8:05 AM
Hello,
Can you try this ARCHIVFILE_SERVER_TO_SERVER function?
2023 Jan 16 8:29 AM
You can use the FTP command "rename" (via function module FTP_COMMAND), which also works for moving.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = ftp_handle
command =
'rename D:\Sales\Macine\Product\fail_log\test.csv D:\Sales\Macine\Product\fail_log_n\test.csv'
TABLES
data = result
EXCEPTIONS
command_error = 1
tcpip_error = 2.
NB: don't forget to wrap it will all classic calls to HTTP_SCRAMBLE, FTP_CONNECT and FTP_DISCONNECT of course.
2023 Jan 16 11:29 AM
There is one issue that i missed in my first query ....The third party software placing the file after one hour scheduling and file is placing with naming
D:\Sales\Macine\Product\fail_log\test_16.01.2023_15.30.22.
D:\Sales\Macine\Product\fail_log\test_16.01.2023_16.30.22. and so on ...
I have to pick all the files . so i cannot use rename D:\Sales\Macine\Product\fail_log\test.csv D:\Sales\Macine\Product\fail_log_n\test.csv' so cannot fix the file name.
Before reading the files from folder i have to keep the backup of all files from this folder.
Thank you.
2023 Jan 16 11:56 AM
So, I answered your question and future visitors will find the answer how to move a file (in FTP).
But you have other questions, not sure, please clarify:
NB: in command, you can indicate a variable for the command parameter, so you can indicate any file name you want at runtime.
2024 Oct 14 10:32 AM - edited 2024 Oct 14 10:45 AM
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = lv_ftp_handle
command = 'RNFR D:\Sales\Macine\Product\fail_log\test.csv'
IMPORTING
reply = lv_reply.CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = lv_ftp_handle
command = 'RNTO D:\Sales\Macine\Product\fail_log_n\test.csv'
IMPORTING
reply = lv_reply.
I also have a similar requirement. the thing is this is rename right. my lead says we dont have the authorization to rename. we need to transfer files among two folders within same ftp, server read and copy to another program. Is there any way.
2024 Oct 14 11:57 AM
Please post a new question here and see also the List of FTP commands - Wikipedia (mainly RFC 959).