Skip to Content
avatar image
Former Member

Dynamic Config for Target directory

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Jul 02, 2009 at 09:06 AM
    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Abishek,

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

      thanks,

      Kumar

  • avatar image
    Former Member
    Jul 02, 2009 at 09:23 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 02, 2009 at 09:29 AM

    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 "";

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 03, 2009 at 08:08 AM

    Dear friends,

    Thank you so much for valuable inputs...

    cheers,

    Kumar

    Add comment
    10|10000 characters needed characters exceeded