cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Config for Target directory

Former Member
0 Kudos

Hello Experts,

My interface is from MQ (JMS) to FILE.

I have one sender and one receiver.

I have the Lockbox data placed into the single Queue for 2 countries (AU u2013 Australia and NZ u2013 Newzeland)

Point 1: My PI Interface Picks the lockbox data up from the Queue, then the respective file (dynamically by using dynamic configuration) is being created based on the condition in mapping.

Here my mapping logic:

SourceStrucutre ReceiveStrucutre

Filed1 Filed1

Filed2 Filed2

INPUT -


 FIXED VALUES u2026u2026u2026..> UDF1 u2026u2026u2026> ReceiveStrucutre ( root node)

Expected input values for INPUT: ABC and XYZ (ABC for AU and XYZ for NZ)

Expected values in FIXED VALUES: ( if ABC - create file name FILE1.TXT; if XYZ - create file name FILE2.TXT)

The below UDF is mapped to root node of Receiver Structure.

UDF1 code: ( with single Argument with name : arg)

DynamicConfiguration conf = (DynamicConfiguration) container

.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

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

conf.put(key, arg);

return "";

the above mentioned logic works fine and am able to generate the file names (FILE1.TXT & FILE2.TXT ) in the target directory ( /tmp/common ) which mentioned in the receiver file adapter.

Point 2:

My Requirement is to generate the target directory dynamically based the file name generated..

Expected Target directory:

/tmp/AU/FILE1.TXT for the file FILE1.TXT

/tmp/NZ/FILE2.TXT for the file FILE2.TXT

I know we can do this by writing another UDF2 (DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "Directory"); for the directory and by making ASMA ticked for Directory in communication channel..

My question is how to map the two UDFs to the same root node of receiver..

Valuable inputs are much appreciated!!

Thanks,

Kumar

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Dear friends,

Thank you so much for valuable inputs...

cheers,

Kumar

Former Member
0 Kudos

can you try combining two UDFs like this

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

conf.put(key, arg)
String fileName = conf.get(key);

if(filename.equals("file1.txt")){
	conf.put(key1, Directory1)
else
	conf.put(key1, Directory2)

return "";

former_member200962
Active Contributor
0 Kudos

what i mean is have :

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

and

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

conf.put(key, arg)

conf.put(key1, value for Directory)

If you are worried on how to map two UDFs to root node then FYI you can map the o/p of the UDFs to any node in your target structure......it wont cause any harm....

If you say no node is free then you can have two inputs to your UDF and then in the return statement send out the value that you want to pass to the target node (presently you are using return"".......if applying above then you will have return arg2)....

Regards,

Abhishek.

former_member200962
Active Contributor
0 Kudos
My question is how to map the two UDFs to the same root node of receiver..

Why are you using two UDFs....the logic can be clubbed in the same UDF (for FileName and Directory)......

just use key and key1...then in conf put the required value in key and key1.....check it out

Edited by: abhishek salvi on Jul 2, 2009 2:37 PM

Former Member
0 Kudos

Hi Abishek,

Thanks for your quick response.. could you please Elaborate a bit more with same code

thanks,

Kumar