cancel
Showing results for 
Search instead for 
Did you mean: 

Drop the files into different directories based on the filename

Former Member
0 Kudos

Hi,

I had a reqiuirement based on the file name, i should drop the files in to different directories.

I can get the filename through variable substitution in receiver file communication channel, now i want to drop the file into different folders based on conditions.

suppose, if the file name is DDDX234

i should do substring of filename0+(4), if the value is L then i should drop in X directory

suppose, if the file name is DDDY234

i should do substring of filename0+(4), if the value is L then i should drop in Y directory.

How can i drop the file into differnent directories based on filename.

Thanks

Srinivas

Accepted Solutions (1)

Accepted Solutions (1)

MichalKrawczyk
Active Contributor
0 Kudos

hi,

this is pretty easy - you just have to learn to use ASMA - Adapter-Specific Message Attributes instead of variable substitution

one of the parameters that you can set in the mapping for ASMA is DIrectory:

http://help.sap.com/saphelp_NW04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm

so you can set the directory in the mapping and it will be used by the file adapter

you can find many blogs about ASMA setting in mapping on sdn - so it's a pretty easy requirement

try this one:

/people/william.li/blog/2006/04/18/dynamic-configuration-of-some-communication-channel-parameters-using-message-mapping

Regards,

Michal Krawczyk

Former Member
0 Kudos

Thanks Michal,

I mapped the directory and filename to the target header in the mapping

Filename --> UDF --> Header(target)

and in the receiver channel checked the ASMA and given * in the filename and directory name.

But in runtime iam getting the error as

Attempt to process file failed with com.sap.aii.adapter.file.configuration.DynamicConfigurationException: The Adapter Message Property 'FileName' was configured as mandatory element, but there is no 'DynamicConfiguration' element in the XI Message header

MY UDF is

public String Directory(String a,Container container){
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

String FileName = conf.get(key);
FileName = a;
conf.put(key, FileName);
%%%based on filename the directory should change
String Directory = conf.get(key1);
Directory = "/SAPInterface/XI/PPD/DHX/out";
conf.put(key1, Directory);

return "";

Help me in correcting this error.

Thanks

Srinivas

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks Michal

Former Member
0 Kudos

Hi Srinivas,

Handle it in mapping and send the directory name to the communicaiton channel at runtime using adapter specific message attributes.

Regards,

---Satish