on 04-11-2007 8:57 PM
Hi Team,
I have a File to Idoc scenario where the file is picked up by XI from the FTP server and transferred to the backend ERP system as IDOC. The file is archived in an Archive directory in the Sender communication channel for the sender File Adapter. The requirement is to rename another file on the FTP server as soon as the Archive operation is finished.
I tried writing a small and quick Adapter module for the file adapter and am calling the module as the last step in my sender channel. Can someone help me with writing the Java code in this module to connect to the FTP server and run the "rename" ftp command?
I tried the following and could not get this to work
Runtime rt = Runtime.getRuntime();
Process process = rt.exec("ftp rename /DEV/OLD.txt /DEV/NEW.txt");
Is this even possible? Can someone give me pointers in correct direction please? Should I use the URL class to open a connection first? If yes, what are the next steps? Should we use other class libraries for FTP support, which ones? Any sample code would be very helpful. I just want to perform two steps. 1)Connect to FTP 2) Rename a file in the Adapter Module.
Please let me know your thoughts. Thanks for your time.
Regards
Sanjay
Thank you Satish,
I tried the OS command and it works fine with file rename commands for a static Folder on the XI server. But it does not work for the FTP server not residing on the XI server. Also my target file folder has to be derived from the filename and I don't know if that can be done in a batch file. Any thoughts? Do we still have to go back to the adapter module where I can derive the target folder very easily using Java? My problem still remains: How do I connect to FTP using Java and run a rename command? Either from the Adapter Module or from the batch file where the file folder is derived from the file name.
Thanks much for your attention and time.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sanjay,
If you want to rename the file then you can use the OS commands after message processing. Check this weblog on using the OS commands:
/people/michal.krawczyk2/blog/2007/02/08/xipi-command-line-sample-functions
/people/michal.krawczyk2/blog/2005/08/17/xi-operation-system-command--error-catching
So use the rename command to rename the file.
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I am not sure using the adapter user module will work. The user module is executed during the processing of the message before the file would be archived.
Is it possible to execute a system command after processing? This system command or batch command can contain the FTP command and the script to execute (to rename the file).
See the SAP Help:
http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/frameset.htm
Regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.