cancel
Showing results for 
Search instead for 
Did you mean: 

Moving a file to a different location after creating it in XI

Former Member
0 Kudos

Hello all,

I have to write an Interface the creates a file in a FTP server with user + password.

after the file had been created I have to move it to a different folder in the same server.

my problem is: do I have to give the user and password again where i write the OS command?

Thanks,

Naama

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos
Former Member
0 Kudos

Hi,

Thanks to all of you,

i found the solition if anyone is intrested

I created a regular bat file - not ftp one, and send to it parameters using %,

and that bat file created another one but now an FTP one

echo user username > Input_file

echo passward >> Input_file

echo rename XI_temp/%1 XI/%1 >> Input_file

echo bye >> Input_file

ftp -n -s:Input_file hostname

former_member193376
Active Contributor
0 Kudos

Hi

your question is : *Can i use the dynamic path/file name in the script? using the %f, %F parameters *

Yes you can dynamically set your name in the script using the % % parameters.

Below i have written the code.

In your receiver communication channel in the processing tab->Run operating system command after message processing, there you have to write a batch program.

for eg :

======================

open 10.4.71.145

mmdftp =========== username

Eimskip123======== password

cd /TestSource

get TestData1.xml

cd /TestTarget

put TestData1.xml

ren Testdata.xml %TestData1%.xml

quit

Batch File Content (File_Copy_Batch.bat)

=====================

This link will help you out

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/xi/sap%2bxi%2bfile%2badapter%2bos%2bcommand%2blin...

Hope this answers your question

Thanks

Saiyog

Former Member
0 Kudos

Hi,

Thanks for your help,

but its still not working' I don't manage to transfer parameters to the batch file'

I try to do this also not threw the XI, but threw the cmd window and its not working,

maybe in a ftp command the script cant get parameters?

my script looks like this:

open 156.12.7.9

username

passward

rename XI\%1 XI_temp\%1

bye

and I try to run it by: ftp -s:
sapdx1\xifiles\com.bat %f

Thanks,

Naama

Former Member
0 Kudos

Hi ,

Please check these blogs to deal with dynamic folder and file name.

Dynamic File Name Part 1

Dynamic File Name Part 2

Thanks

Sudharshan

Former Member
0 Kudos

Hi,

Thanks,

My problem is not variable substitution, its transferring parameters to bat file.

from my previous experience i know the in ftp server there is a chance that when i am creating a file,

the other system that reads the file can read it before i finish writing,

so i want to write the file to temp dir and then move it using an OS command

Thanks,

naama

Former Member
0 Kudos

Hi Naama,

I am not sure how variables are passed to batch files. I have worked with shell script files for dealing with almost similar requirements. I have passed the file name using %f and %F using receiver communication channel. The command looked some thing like this

sh /home/scriptdir/MERGE.sh %f

With in script we use $1 for getting the parameter passed as an arguement.

Regards,

Jaishankar

Former Member
0 Kudos

Thanks for your answer,

I have another question,

can i use the dynamic path/file name in the script? using the %f, %F parameters?

Thanks a lot,

Naama.

Former Member
0 Kudos

Hi ,

You can try this - don't know wether it works. take two adapter specific parameters ( var1 , var2 ) and set values to those values dynamically in message mapping . Use these two adapter specific parameters and configure the file communication channel with the OS command .

OS command you can set - ex : movefile.bat Var1 Var2

Pls try this and let us know.

Regards,

Kishore

Former Member
0 Kudos

Hi,

>>my problem is: do I have to give the user and password again where i write the OS command?

Usually srcipt files are used when the target location is XI server file path. Coz the script file that needs to be invoked should be placed in XI server file path. If you need to use script file for handling files in a FTP server, then you should login to the FTP server from the script files using FTP commands. So you need to use the user name and password with in the script file.

Regards,

Jaishankar

Former Member
0 Kudos

Thanks for your answer,

I have another question,

can i use the dynamic path/file name in the script? using the %f, %F parameters?

Thanks a lot,

Naama.

GabrielSagaya
Active Contributor
0 Kudos

you need not have to give the user and password again where you write the OS command in batch file(bat file).