cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to split single value to multiple using separator &

Former Member
0 Kudos

Hi,

can any one please provide an udf to split single value into mulitple using separator &, I have one field data as-PO&1100000001&&32424234234&. here PO is constant concated with three values in reverse order.

i.e first value A-32424234234 ,second value B- blank,third value C-1100000001.

i need to map the splliting values to target side(A->A,B->B,C->C).

regards

Mahesh.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try this:

Input: Var1

Execution type: All values of a context

String delimiter ="&" ;

String[] temp = var1[0].split(delimiter);

int a = temp.length;

for(int i = a-1; i>0; i--)

{

result.addValue(temp<i>);

}

Thanks

Amit

Former Member
0 Kudos

Hi Amit,

Thanks,the problem solved with the help of your code.

regards

mahesh.

Answers (3)

Answers (3)

rajasekhar_reddy14
Active Contributor
0 Kudos

convert below code in to UDF, it will work..

public class StringSplit {
  public static void main(String args[]) throws Exception{
    String testString = "PO&1100000001&&32424234234&";
    
    System.out.println(java.util.Arrays.toString(
        testString.split("&")
        
    ));
  
  }
}

Regards,

Raj

Former Member
0 Kudos

Hi Amol,

can you please provide more detial on this with respective to udf code and relvant imports.

regards

mahesh.

Former Member
0 Kudos

Hi Mahesh,

Try with below code,

int i = 0;

StringTokenizer st = new StringTokenizer(var1,"&");

while (st.hasMoreTokens()) {

temp = st.nextToken();

i++;

}

Regards

Amol

Former Member
0 Kudos

Hi,

Using String Tokenizer you can acheive this.

Rerer below blog:

Link: [http://wiki.sdn.sap.com/wiki/display/Java/String+Tokenizer]

Regards

Amol