cancel
Showing results for 
Search instead for 
Did you mean: 

File Adapter Scenario - Deleting target directory

Former Member
0 Kudos

Hello,

I have the following scenario:

SAP R/3 (via ABAP Proxy or RFC Adapter) -> XI -> File Adapter

For each document generated in SAP R/3 I create one file in the target directories.

I have the following target directories.

->Root Directory

--->Child 1

--->Child 2

--->Child 3

--->...

Each day there is a batch job in SAP R/3 that runs at 05:00AM and generates the files.

What I want to do before the process runs on SAP R/3 is to delete all the files from the day before (in the target directories) so that after running the process only remains the files for the current date.

Any ideias?

Thanks in advance,

Diz IsMi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Check if this method can help you,

Create a User Defined function which does the job of Deleting the previous day's Folder/files by a normal File I/O operation.

Use this function in your mapping and when this gets executed for the first time for that day in the batch process, the Files will get deleated. Then set a flag say, <i>isFilesDeleated = 'true'</i> in the Global container, next time the function will not execute since the job has been done and the flag is set in the Global container.

Former Member
0 Kudos

Thanks to you all,

I will try the suggestions

Best regards

Diz

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

May be You can use File Adapter Module to delete the files. Initially you send the dummy file for which the Module is written and that module can delete the day before files.

I dont know about the performance of this method, but you may consider doing like this.

regards,

P.Venkat

MichalKrawczyk
Active Contributor
0 Kudos

hi,

you can use:

Executing Operating System Commands <b>Before</b>/After Message Processing - option in the receiver file adapter

and this command will delete all files in the folders

Regards,

michal

-


<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions">XI FAQ - Frequently Asked Questions</a>

Former Member
0 Kudos

Hello Michal,

Thanks for your answer. Yes... that is one of the solutions I had in my mind but the problem is that this way I would be executing the same OS command for each file I was receiving. I mean:

Receive file 1 in /root/currentday/child1 => rm root/daybefore/*

Receive file 2 in /root/currentday/child1 => rm root/daybefore/*

and so on

Don't you think this is an "ugly" solution?

And probably it is not very performant also, don't you think?

Tha other solution I thougth was to adapt the process in SAP R/3 so that it would send a DUMMY file before sending real files. I would use this DUMMY file to delete the day before files with the functionality provided by the receiver file adapter.

Any other ideias?

Thanks again

Diz

Former Member
0 Kudos

Hi Diz,

I am just curious ....Can i ask you one thing..

If you want to delete all the OLD files / directories...can't you write a batch job on the system( where files are written) to delete all unwanted old files ? (independent of XI / SAP R3 etc....)

Or should it be done only on receiving some particular message from SAP R/3 ?

Thanks,

Renjith

Former Member
0 Kudos

Hi,

I could do that... the thing is that I would like to maximize the time that the files are kept each day. So I would like to delete the old files just before the new ones are created...

Thanks

Diz

Former Member
0 Kudos

Hi,

Anymore ideias?

thanks

diz