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: 

Moving files from one folder to another in ABAP program

Former Member
0 Kudos

Dear all

I have a requirement in ABAP where i should read a file from a particular folder say to be processed folder after sucessful proceesing the file i should move this file to another folder say processed folder. This program will run in the background.

Is there any FM for this process or any other way to achive this.

Thank you in advance.

Karan

8 REPLIES 8

former_member188685
Active Contributor
0 Kudos

Hi,

You can use <b>CL_GUI_FRONTEND_SERVICES=>FILE_COPY</b>.

after process use file_copy method of the above class.

regards

vijay

0 Kudos

Hi

If you are talking about the application server files.

then

data: begin of tabl occurs 500,
        line(400),
      end of tabl.
 refresh tabl.
data: unixcom like   rlgrap-filename.
 unixcom = 'cp file1 processed'.
  call 'SYSTEM' id 'COMMAND' field unixcom
                id 'TAB'     field tabl[].

Former Member
0 Kudos

Karan,

I hope the files are on the app server. If they are the Presentation Server, you cannot execute the program in the background. So, CL_GUI_FRONTEND_SERVICES will not work in the background mode.

1. You can read the files and then rewrite the files into a different folder.

2. You can try using the OS Command.

Regards,

Ravi

Message was edited by: Ravikumar Allampallam

0 Kudos

Hi Ravi

Yes you are right, the file is in the application server. Can you please tell me the os command and how to use in the ABAP program.

Thanks

0 Kudos

Hi Karan,

If it is in the application server, then you can actually read the file with OPEN DATASET and READ DATASET, and TRANSFER each record to another file wherever you would like the file to be. Once the reading and the transfer operation is over, you can delete the original file using DELETE dataset.

Hope this helps.

Regards,

Srikanth

andreas_mann3
Active Contributor
0 Kudos

Hi,

look here:

Andreas

Former Member
0 Kudos

Hi Karan,

1. First use GUI_UPLOAD function module to read the file content. Here U built the Internal table.

2. then use GUI_DOWNLOAD function module with ur destination path. Here u pass thar Internal table.

Regards,

Digesh Panchal

0 Kudos

Hi,

Maintain an OS command in SM69 and get it executed using SXPG_COMMAND_EXECUTE.

Cheers

JK