on 04-23-2009 4:50 PM
Hi All,
From my Source One field is having the value seperated by "/"
and i need to split that value based on the "/" & need to send to Two target fields
Ex:
Source
Field1 = ABC/123
Target
Field2 =ABC
Field3=123
Can we do this in Xi Mapping
Regards
you have function split to do your job..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
nope.. that is node function..
write your Java code something like this..
public void SplitAt(string[] Field1, ResultList result, String[] delimiter, Container container) throws StreamTransformationException{
String temp[] = Field1[0].split(delimiter[0]);
for (int i=0; i<temp.length;i++)
{
result.addValue(temp<i>);
}
}
here you are passing two parameters Field1 and Delimiter '/'
or i will give you graphical mapping combination..
Hi vamsi,
Split by value creates new context(adds new hierarchy) based on the options u selected by double clickingonit(eg., On value change).
Please refer the following link for more on Split by value.
http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm
In your case if you want to Split the value (dividing it into two based on '/') there is no other way than writing UDF(Java code ) to acheive the operation.
Thanks,
Ram..
Hi,
U need t write two UDFs in your graphical mapping.....in this udf you need to use the split function
SOurce --- UDF1 -- Target1(ABC)
Source --- UDF2 --- Target2(123)
UDF1:
String splits = "a/b";
String a[] = splits.split("/");
int lenS = a.length;
System.out.println(alenS-2);
UDF2:
String splits = "a/b";
String a[] = splits.split("/");
int lenS = a.length;
System.out.println(alenS-1);
Both UDFs should be of type Single value and should have one Argument.
For more info refer this thread:
Regards,
Abhishek.
Edited by: abhishek salvi on Apr 23, 2009 9:50 PM
Hi Vamsi,
In the above piece of code by selvi.You should not use the lines System.out.prin ln. coz u are not going to proint it on a console but returning it to field.so there should be return statement that gives the cut part as output of UDF and u will have to map it to the field u want.
Thanks,
Ram.
Hi vamsi
Try this out
str is your argument that u are passing to UdF
UDF1:
String a;
int b;
b = str.indexOf('/');
a = str.substring(0,b);
Return a;
This gives you the first string.
UDF:2
String a;
int b;
int c;
c = str.length();
b = str.indexOf('/');
a = str.substring(b,c);
Return a;
this gives you 2nd string.
Hope this helps you .jus play around the code.youwill definatly get it.
Thanks,
Ram.
Hi Selvi,
I wrote the UDF like this
public String Split(String a,Container container)
{
//write your code here
String splits = "a/b";
String a[] = splits.split("/");
int lenS = a.length;
System.out.println(alenS-2);
}
With out any Pakages mentioning in Imports
Iam getting Error, is there any change needs to be done
Regards
Hi,
I used the above code as it is and using the str is the input string in UDF
Iam getting this error
Source code has syntax error: E:/usr/sap/DX1/DVEBMGS10/j2ee/cluster/server0/./temp/classpath_resolver/Mapfbdd04f0302611dec17b0017a4770824/source/com/sap/xi/tf/_MM_Material_.java:1589: cannot resolve symbol symbol : class Return location: class com.sap.xi.tf._MM_Material_ Return a; ^ E:/usr/sap/DX1/DVEBMGS10/j2ee/cluster/server0/./temp/classpath_resolver/Mapfbdd04f0302611dec17b0017a4770824/source/com/sap/xi/tf/_MM_Material_.java:1589: a is already defined in Split$(java.lang.String,com.sap.aii.mappingtool.tf3.rt.Container) Return a; ^ 2 errors
Regards
Hi,
I used the following UDF's and succeded
Thanks Ramakrishna , Prema and all the Guys
UDF1
public String Split(String a,Container container)
{
String C = a;
int b = C.indexOf("/");
C = C.substring(0,b);
return(C);
}
UDF2
public String Split(String a,Container container)
{
String C = a;
int b = C.lastIndexOf("/");
C = C.substring(b+1);
return(C);
}
Regards
Edited by: Vamsi Krishna on Apr 23, 2009 7:35 PM
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
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.