cancel
Showing results for 
Search instead for 
Did you mean: 

Writing to 2 different directory using file receiver channel

NishantChavan
Participant
0 Kudos

I have a scenario where i am picking multiple files from one server and writing it on another. While writing the files, i want to write them to different folders using one communication channels based on the filename. is it possible? if yes how?

Accepted Solutions (1)

Accepted Solutions (1)

gagandeep_batra
Active Contributor
0 Kudos

Hi Nishant,

you have two option

1 using OS command after message processing at receiver CC use copy command with %F option

2other option is create another Receiver  CC and define that with another Receiver

Regards

GB


Answers (3)

Answers (3)

Former Member
0 Kudos

Hello,

IMO, best solution is to either write a adapter module or java mapping to define target folders dynamically.

Adapter module:

http://wiki.sdn.sap.com/wiki/display/Snippets/Dynamic+file+name+in+a+File+to+File+pass+through+scena...

 

Java mapping:

http://wiki.sdn.sap.com/wiki/display/XI/Dynamic+file+name+for+pass-through+scenario

Thanks

Amit Srivastava

iaki_vila
Active Contributor
0 Kudos

Hi Nishat,

If you dont need to make any mapping the easier way in my opinion is to access to the global variable fileName and in the condition of the Configured Receivers determine the final target. Check , and you can do something similar but with filename instead of directory.

former_member184720
Active Contributor
0 Kudos

You have to go for dynamic configuration UDF in the mapping.

Refer to the below document

http://wiki.scn.sap.com/wiki/display/XI/Dynamic+file+name+and+directory+in+Receiver+File+Adapter+-+s...

Also http://saptechnical.com/Tips/XI/ASMA/Index.htm

You just need to add filters/fix value lookup and pass it to UDF to determine the target directory

Message was edited by: Hareesh Gampa

former_member184720
Active Contributor
0 Kudos

If you have mapping in place then i would try with the below UDF -

String filename = new String("");

DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");

DynamicConfigurationKey key2 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","Directory");

filename = conf1.get(key1);  //reading source filename

if (filename.equals("test"))
{
conf1.put(key2,"first directory name");
}
else
{
conf1.put(key2,"second directory name");
}
return "";

You need to enable dynamic attributes in both sender and receiver channel..