Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to copy files on the application Server using coding in report

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

3 REPLIES 3

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

uwe_schieferstein
Active Contributor
0 Kudos

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