cancel
Showing results for 
Search instead for 
Did you mean: 

Moving file from one directory to another using message mapping in ESR

0 Kudos

Hi,

We have a requirement to implement a logic in message mapping using java functions to pick file from one directory in application server and place it in another directory.

I have seen blog http://scn.sap.com/thread/255042 that deals with Access file in file directory during mapping.

Is it possible using java functions to place file from one directory to another of sap pi application server?

If yes Can you please tell me how we can acheive that using java functions?

Best Regards,

Shilpi Agarwal

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Why do you want to move the file to another folder using mapping only..?

what is your exact requirement... if you can provide more details some one here can guide you...

Cheers

Rajesh

Former Member
0 Kudos

Hello,

>>Is it possible using java functions to place file from one directory to another of sap pi application server?

Yes it is possible.

Chk this link (you have to alter the code given in the link):

http://scn.sap.com/thread/1569382

Ur code will be something like this:

String a ="";
File file1 = new File ("/usr/sap/PI/SYS/src/File1");

FileReader fr = new FileReader (file1);
BufferedReader br =  new BufferedReader(fr);


File file2 = new File ("/usr/sap/PI/SYS/src/File2");
Writer output = new BufferedWriter(new FileWriter(file2));

boolean resp = file1.delete();
   

while((a=br.readLine())!=null)
{
output1.write(a);
}
output1.close();

Note: i havent tested this code so please chk for syntax errors and do remember to implement proper error handling.

Thanks

Amit Srivastava

nabendu_sen
Active Contributor