on 11-08-2012 6:33 PM
Hi All,
I have requirement where I need to retain only hundred files in my receiver FTP folder based on the file name which has a date (for example - abc_yyyymmdd.txt).
For example, lets say the receiver FTP folder has hundred files until yesterday and when I run the interface today, the least dated file must get deleted and the new file should be added to the folder so that the files in the folder will be hundred always.
Is this possible doing from PI point of view? Please suggest me a solution?
Thanks,
Nani
Yes this is possible but i dont advice to do it in PI.
PI Solution:
Write a JAVA mapping and perfrom File look and count number of files and delete old file. this is possible using JAVA code.
or
You can try using Shell script.
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nani,
Do you know what operating system the receiver FTP server is running on? I also think trying to achieve this through SAP PI is going to cause more problems than it will solve...You are essentially trying to manage archiving on the FTP server? If so, the archiving responsibility needs to be on that side.
If you were trying to manage this on the PI file system this would work fine. If your PI system runs on Unix you could issue a a few commands like :
- ls | head -100 (default listing sorted by filename) - OR -
- ls -lt | head -100 (listing by timestamp).
Then write the listing output to a file. Then use a Unix FOR loop to interate through the files in the directory and move all files out that do not appear in you top 100 listing.
To achieve this while in FTP mode, would result in poor design. In the script you could essentially end up doing a scenario like the following example...
- need to do 2 file listings (1 full listing & 1 top 100 listing), write the 2 outputs to files, then FTP those back to the PI server.
- Still in the script, do a FOR LOOP to loop through the full listing output file and do a GREP against the top 100 file. If it doesn't exist, FTP to receiver and issue a move or delete FTP command for that file.
You will iterate through this doing an FTP for each file that doesn't exist in the top 100 listing. This could equate to a lot of FTP calls - hence my poor design suggestion...
Regards, Trevor
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.