cancel
Showing results for 
Search instead for 
Did you mean: 

Regardding UDF

Former Member
0 Kudos

Hi

from the source I am getting 50:US:9000

target I required only 50.(this is ok)

if the input comes 5:US:9000

target I required 05.

can you please any one send me udf for this

regards

venkat.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try with this udf

Use cache parameter context

public void extract1(String[] a,ResultList result,Container container)
{
String b[] = a[0].split(":");
 if(b[0].length() >2)
    result.addValue(b[0]);
else
    result.addValue( "0" + b[0]);
}

Edited by: malini balasubramaniam on Sep 1, 2008 1:19 PM

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

A small change in the condition

if(b[0].length() >=  2)
    result.addValue(b[0]);
else
    result.addValue( "0" + b[0]);

Former Member
0 Kudos

Hi venky,

create a simple udf with the cache type Value.

Code:

public String simple(String a,Container container)
{
     String val=a.split(":")[0];
     int l=val.length();
     for(int i=0;i<2-l;i++)    val="0"+val;
     return val;
}

Regards,

Sankar Choudhury

Former Member
0 Kudos

Hi Venky,

it can de done by using mapping functions ie. substring and concat function

target : 5:US:9000 sutstring value (01)

then u get only five

after that take a constant and give tha value as 0

then the req output will be 05

if found worth pls do the req

Regrads

Sampath

Former Member
0 Kudos

Hi,

guess it's also possible with standard functions:

If input length > Constant "0"

if indexOf (input; Constant ":") equalsS Constant "1"

then output = concat (Constant "0", input.substring(0, 1))

else output = input.substring(0,2)

Regards

Patrick