01-08-2008 7:03 PM
Hi folks,
We have a report, there we must copy files on application server from one directory to another one on the same application server.
I mean it in easiest way just like in Operation System (DOS/Unix): copy path1\file1 to path2\file2
so how it works in ABAP?
thanks & Regards
Alex
01-08-2008 7:25 PM
Alex,
Try this:
report zrsandbox9.
data: SrcFile type SAPB-SAPPFAD.
data: TargetFile type SAPB-SAPPFAD.
SrcFile = '/some_directory/original_file.txt'.
TargetFile = '/new_directory/new_file.txt'.
CALL FUNCTION 'ARCHIVFILE_SERVER_TO_SERVER'
EXPORTING
SOURCEPATH = srcfile
TARGETPATH = targetfile
IMPORTING
LENGTH =
EXCEPTIONS
ERROR_FILE = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
01-08-2008 7:22 PM
Alex,
You can certainly issue a 'cp' command (if you are running UNIX/Linux) in ABAP.
But I would suggest using this func module instead - ARCHIVFILE_SERVER_TO_SERVER
It is VERY straightforward.
01-08-2008 7:25 PM
Alex,
Try this:
report zrsandbox9.
data: SrcFile type SAPB-SAPPFAD.
data: TargetFile type SAPB-SAPPFAD.
SrcFile = '/some_directory/original_file.txt'.
TargetFile = '/new_directory/new_file.txt'.
CALL FUNCTION 'ARCHIVFILE_SERVER_TO_SERVER'
EXPORTING
SOURCEPATH = srcfile
TARGETPATH = targetfile
IMPORTING
LENGTH =
EXCEPTIONS
ERROR_FILE = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
01-08-2008 8:15 PM
Hello Alexander
As long as you have an RFC destination available between your application servers I usually use function modules
EPS_FTP_GET or EPS_FTP_MGET
EPS_FTP_PUT or EPS_FTP_MPUT
The interface of these function modules is quite obvious.
If you want to copy between different directories on the same server simply use 'NONE' as RFC destination.
Regards,
Uwe