on 06-02-2011 3:12 PM
hi Experts,
I am using dynamic config using java function in my message mapping.
The source message has a field called "fname".
The value of "fname" is the input to my java UDF.
The java UDF code is:
public String getDynamicFile(String fname, Container container) throws StreamTransformationException{
String str = fname + ".xml";
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey FileName = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");
conf.put(FileName, str);
return str;
}
When I test this message mapping I get the following exception:
Runtime Exception:[java.lang.NullPointerException: while trying to invoke the method com.sap.aii.mapping.api.DynamicConfiguration.put(com.sap.aii.mapping.api.DynamicConfigurationKey, java.lang.String) of an object loaded from local variable '<4>'] in class com.sap.xi.tf._<message mapping>_ method getDynamicFile[test, com.sap.aii.mappingtool.tf7.rt.Context@2e52cb31]
What am I doing wrong in this UDF?
Thanks
Gopal
Hi,
Your UDF will run fine in an end to end execution,i.e, during runtime. However, if you want to test your message mapping test tab without the dynamic config UDF throwing an exception, encpasulate the code in a try catch block
public String getDynamicFile(String fname, Container container) throws StreamTransformationException{
String str = fname + ".xml";
try{
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey FileName = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");
conf.put(FileName, str);
}catch(Exception ex){}
return str;
}
The above code should run fine when you test in the message mapping test tab.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>> When I test this message mapping I get the following exception:
Dynamic configuration code works during runtime.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
/people/shabarish.vijayakumar/blog/2009/03/26/dynamic-configuration-vs-variable-substitution--the-ultimate-battle-for-the-file-name
are you testing it in message mapping? refer the blog.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.