on 08-28-2014 12:35 PM
Hi experts,
I would like to know how to split a source string in XI mapping, based on "+" seperator.
eg: source : ABC|DEF|GHI
target1: ABC
target2:DEF
target3:GHI
How can this be achieved using UDF in mapping?
Regards
Hi Tanzoom,
Please use below udf
String[] arg = a[0].split("+");
for(int j=0; j<arg.length; j++)
{
result.addValue(arg[j]);
}
after this udf u can use INDEX function
for Index1 u can use target 1
for index2 u can use target2
Let mw know if u face any issue...
Thanks,
Sreenivas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sreenivas,
There is a small correction in the UDF. it should be
String[] arg = a[0].split("//+");
this udf results in an array with all the splitted values.
However, i am trying to get it as 2 different output strings which can be mapped to the target directly.
i.e ABC|DEF should result in
output 1: ABC
output 2: DEF (not in array)
Please let me now if this can be achieved.
Thanks
hi Sreenivas,
I wanted to modify this UDF to include an empty value, ie
If Source: ABC|DEF|GHI
Target1 : ABC
Target2: DEF
Target3: GHI
else if Source = ABC|DEF - the udf should not fail in this case and instead the target should get blank
Target1: ABC
Target2: DEF
Target3: (Blank)
any pointers for this?
Hi All,
I am trying to have someting without the use of string tokeniser. Some java function with split?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
public String SplitString(String var1, int var2, String separator Container container) throws StreamTransformationException{
String str = var1;
String[] value;
/* given string will be splitted by the argument delimeter provided. */
value = str.split(separator);
/* print splitted substrings - var2 (01,2,3 etc...) is the index you can define as parameter and call in each target field*/
return value[var2];
http://wiki.scn.sap.com/wiki/display/Snippets/taking+strings+apart+using+StringTokenizer
To do udf, it is very simple . Pass the input value and use java class stringtokenizer to extract string from "+" token from the string.
You can follow the above wiki as code snippet to do this.. In your case use '+' instead of ''," given in the example.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
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.