Dynamic File Name in Multimapping – Standard Solution
Fellow SCNers,
Dynamic File Name in Multimapping – Standard Solution: All of us at one point of time in our career as SAP PO consultants would have have faced a requirement needing multimapping and to go with it a need for dynamic file name after multimapping. And at the same time, we would have realized that we cannot assign ASMA using a UDF in case of multimapping.
This blog does not intend to showcase any hidden functionality which makes it possible as it is still not possible to do a 1:N multimapping without using custom solutions. One such solution has been brilliantly showcased by my friend Praveen Gujjeti in A new approach: Multi-mapping Dynamic Configuration using a generic custom module
However, it is possible to do multimapping and Dynamic Configuration in cases of 1:N multimapping if the value of N is known and fixed. I have achieved this to Dynamically assign ASMA values to child messages in case of a 1:5 split.
I would like to mention our colleague and guru Stefan Grube whose blog Unknown use case of DynamicConfigurationBean: Store file name to JMS header without mapping showed me the light for the approach.
Solution:
In your multimapping program, insert a UDF having the below code snippet. Please note that the you can increase the number of DynamicConfigurationKey objects based on the number of messages you have in your target.
public String putFileName(String inputFileName1, String inputFileName2, String inputFileName3, String inputFileName4, String inputFileName5, Container container) throws StreamTransformationException{
try {
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key1 = DynamicConfigurationKey.create(“https://sap.com/xi/XI/System/Test“,”Message1”);
DynamicConfigurationKey key2 = DynamicConfigurationKey.create(“https://sap.com/xi/XI/System/Test“,”Message2”);
DynamicConfigurationKey key3 = DynamicConfigurationKey.create(“https://sap.com/xi/XI/System/Test“,”Message3”);
DynamicConfigurationKey key4 = DynamicConfigurationKey.create(“https://sap.com/xi/XI/System/Test“,”Message4”);
DynamicConfigurationKey key5 = DynamicConfigurationKey.create(“https://sap.com/xi/XI/System/Test“,”Message5”);
conf.put(key1,inputFileName1);
conf.put(key2,inputFileName2);
conf.put(key3,inputFileName3);
conf.put(key4,inputFileName4);
conf.put(key5,inputFileName5);
return “”;
}
catch(Exception e){
return “Could not write filename”;
}
And then, in your receiver communication channels(Assuming you will have different communication channels to process each of the split messages) you need to maintain the below entries in the module tab.
With the below settings in Module Configuration.
And that’s it!!! The above example pick the value assigned to Dynamic Configuration Key Message3 from mapping to DCJMSMessageProperty0 attribute of the JMS adapter. Similar thing can be done for the attributes of File adapter to dynamically name the files at receiver end.
New NetWeaver Information at SAP.com
Very Helpfull