on 12-24-2012 7:27 AM
Hi,
I want file name as output in a target message field. I have SAP PI 7.1.
What will be input and what will be java code for it.
Now, i am passing a constant null value as input to UDF which has below code.Its giving error.
public String getFileName(String var1, Container container) throws StreamTransformationException
{
String S= "";
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");
S= conf.get(key);
return S ;
}
Now I am getting below error while testing it in message mapping tab :
Runtime exception when processing target-field mapping /ns1:Mail/Subject; root message: Exception:[java.lang.NullPointerException: while trying to invoke the method com.sap.aii.mapping.api.DynamicConfiguration.get(com.sap.aii.mapping.api.DynamicConfigurationKey) of an object loaded from local variable '<4>'] in class com.sap.xi.tf._mm_HR_to_MailReceive_ method getFileName[, com.sap.aii.mappingtool.tf7.rt.Context@58dca53d]
Please guide on it.
regards
Hi SAP PI,
The code in UDF seems to be ok. The settings in sender file adapter should be as shown below
the UDF does not require any input variable
public String getFileName(Container container) throws StreamTransformationException
{
String S= "";
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/File","FileName");
S= conf.get(key);
return S ;
}
As Amit Srivastava has rightly pointed out the UDF will give errors during testing without try catch block. I feel if you would run the scenario end to end , there will be no errors even without try/catch block.
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
U can't test the DC code at mapping level..it will only work at runtime.
However, if u want to test ur mapping (apart from DC) at design time then use try/catch block in ur UDF code.
Thanks
Amit Srivastava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.