cancel
Showing results for 
Search instead for 
Did you mean: 

XI Conversion needed

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

you have function split to do your job..

Former Member
0 Kudos

Hi,

>>you have function split to do your job..

Is that is SplitByValue in Nodefunctions...

Can u please explain me how to do that

Regards

Former Member
0 Kudos

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..

Former Member
0 Kudos

Thanks Prema,

Could you please provide me Graphical View rather than having java Code

Basically iam not aware of JAVA and all

Regards

former_member750652
Contributor
0 Kudos

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..

Former Member
0 Kudos

use combination of indexOf and then substring..

former_member200962
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Iam getting error in UDF, is there Imports we need to mention

Error

Split$(java.lang.String,com.sap.aii.mappingtool.tf3.rt.Container) String a[] = splits.split("/"); ^

symbol : variable alenS location: class com.sap.xi.tf._MM_Material_Material_ System.out.println(alenS-2); ^

Regards

Former Member
0 Kudos

Hi Prema,

could u please give me the view how to use these bith combinations

Regards

Former Member
0 Kudos

we did try this using graphical mapping long back .. but was not possible.. so we used UDF to the task.. i think you will have to go with UDF..

former_member750652
Contributor
0 Kudos

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.

Former Member
0 Kudos

Hi Abishek,

Iam getting the Error while executing the UDF

Do we need to mention any Packages in UDF

Regards

Former Member
0 Kudos

Then Could you please re construct the code

Regards

former_member750652
Contributor
0 Kudos

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.

Former Member
0 Kudos

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

former_member750652
Contributor
0 Kudos

Hi,

You need not import anything .In my previous code the 'str' is 'a' in your code, So try it now.

Thanks,

Ram.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Answers (0)