on 02-24-2015 10:58 AM
Hello,
I am trying to create dynamically receiver filename based on input filename
Filename length are fixed (41).
For instance :
File that I have receive is called XXXX-XXXX-XXXXX-AAAAA-QQQQQ-EEE
Filename that I should have in my receiver is XXXX-XXXX-XXXXX-EEE-AAAAA-QQQQQ
I am using a UDF and dynamic configuration for this purpose with substring that I am using at root level of my mapping.
When I am using only one substing, it works correctly but as soon as I am adding a second one, it is crashing saying :
Details: com.sap.aii.mappingtool.tf7.MessageMappingException; Runtime exception
when processing target-field mapping /ns0:Document; root message: Exception:[java.lang.StringIndexOutOfBoundsException:
String index out of range: -17]
I don't understand as it seems that I am wrong in filename length but that is not possible...
Maybe I am missing something else in my code... or in the execution type of my UDF (using Single values in that case)
public String FileName(String a, Container container) throws StreamTransformationException{
String filename2 = "";
DynamicConfiguration conf1 = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
//if (conf1 != null) {
DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");
String b = conf1.get(key1);
String e = b.substring(0, 16);
String c = b.substring(18, 11);
String d = b.substring(31, 3);
filename2 = e + d + c ;
conf1.put(key1, filename2);
//}
return "";
Thank you in advance for your help.
Hi,
Length is always 41. And I know when I am using b.length().
Problem here is not if parameters of substring or not are correct but when I am using more than one substring...
For instance :
- If I use String e = b.substring(0, 35); it will works...whatever the parameter..Filename in output will be 35 long.
- BUT if I use 2 substring in a row in the same UDF such as String e = b.substring(0, 35); and String c = b.substring(0, 35); it will failed when I am testing from an E2E.
I must have forget something somewhere...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Jean,
You need to return your filename2 and you don't need any input parameter. Code should be like below. Adjust your substring parameter if needed.
Regards,
Soumyadip
Hi Basu,
I still have the same failed :
Mapping "http://test/OM_TEST_XX" failed to execute: MappingException: Mapping failed in runtimeRuntime Exception when executing application mapping program com/sap/xi/tf/_MM_TEST_XX_; Details: com.sap.aii.mappingtool.tf7.MessageMappingException; Runtime exception when processing target-field mapping /ns0:Document; root message: Exception:[java.lang.StringIndexOutOfBoundsException: String index out of range: -17] in class com.sap.xi.tf._MM_TEST_XX_ method FileName[com.sap.aii.mappingtool.tf7.rt.Context@6c6961a], ApplicationRuntimeException: Runtime Exception when executing application mapping program com/sap/xi/tf/_MM_TEST_XX_; Details: com.sap.aii.mappingtool.tf7.MessageMappingException; Runtime exception when processing target-field mapping /ns0:Document; root message: Exception:[java.lang.StringIndexOutOfBoundsException: String index out of range: -17] in class com.sap.xi.tf._MM_TEST_XX_ method FileName[com.sap.aii.mappingtool.tf7.rt.Context@6c6961a], MessageMappingException: Runtime exception when processing target-field mapping /ns0:Document; root message: Exception:[java.lang.StringIndexOutOfBoundsException: String index out of range: -17] in class com.sap.xi.tf._MM_TEST_XX_ method FileName[com.sap.aii.mappingtool.tf7.rt.Context@6c6961a], BaseRuntimeException: Exception:[java.lang.StringIndexOutOfBoundsException: String index out of range: -17] in class com.sap.xi.tf._MM_TEST_XX_ method FileName[com.sap.aii.mappingtool.tf7.rt.Context@6c6961a], java.lang.reflect.InvocationTargetException, StringIndexOutOfBoundsException: String index out of range: -17
It seems that doing a second substring is making it lost the length...
Hi,
I have changed to (see below) but still the same error....
Nevertheless, it is working for just one substring...
Could it come from MM structure occurrences or missing some java libs...I am quite lost as it should work like that.
String filename2 = "";
DynamicConfiguration conf1 = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
//if (conf1 != null) {
DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");
//String OurSourceFileName = conf1.get(key1);
String b = conf1.get(key1);
String var1 = b;
String var2 = b;
String var3 = b;
String e = var1.substring(0, 19);
String c = var2.substring(20, 3);
String d = var3.substring(25, 5);
filename2 = e + c +d ;
conf1.put(key1, filename2);
//}
return filename2;
Hello Jean,
While doing substring operation the first parameter indicates start index and second parameter indicates last index. So in your case it will be like below:
I hope this will solve your problem.
Regards,
Soumyadip
Hello Jean,
Seems your Input file name String b...is less than 31.
Can you check the Length prior to doing Substring in your UDF.
Regards,
Azhar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
96 | |
11 | |
11 | |
10 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.