Skip to Content
avatar image
Former Member

Regarding the udf


Hi experts,

               i had a requirement where i need to send the customer no to the target .the input can be either numeric or alpha numeric or it can be null some times. if it is numeric value i need get input no preceeded by '0'  i have tried the following code and it worked for both the alphanumeric input values but it doesnot work for the null values.could you please suggest me . suggested person will be appriciated.

Execution type: single values i have taken


int count = 0;

for (int i = 0; i <= var1.length(); i++)

{

if(!Character.isDigit (var1.charAt(i)))

{

count = count +1;

break;

}

}

if (count>=0)

{

return var1;

}

else

{

String format = String.format("%010d",Integer.parseInt(var1));

return format;

}

Thanks

Giridhar

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Jan 08, 2015 at 11:25 AM

    Hi Girdhar,

    Have you tried this?:

    int count = 0;

    if  (var1.length() == 0) {

    return null;

    }

    for (int i = 0; i <= var1.length(); i++)

    {

    if(!Character.isDigit (var1.charAt(i)))

    {

    count = count +1;

    break;

    }

    }

    if (count>=0)

    {

    return var1;

    }

    else

    {

    String format = String.format("%010d",Integer.parseInt(var1));

    return format;

    }

    You can control the null values at the beginning.

    Regards.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 08, 2015 at 10:47 AM

    Hi Giridhar,

    Please try with following UDF:

    int count = 0;

    for (int i = 0; i <var1.length(); i++)

    {

    if(!Character.isDigit (var1.charAt(i)))

    {

    count = count +1;

    break;

    }

    }

    if (count>0 || var1.length() == 0)

    //Updated this IF condn to handle Null input

    {

    return var1;

    }

    else

    {

    String format = String.format("%010d",Integer.parseInt(var1));

    return format;

    }

    Regards,

    Azhar

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 08, 2015 at 12:20 PM

    Hi Giridhar,

    you can do this without UDF also...

    Please find my mapping screenshot

    Mention fixed values like this

    Thanks,

    Sreenivas


    mapping.jpg (44.2 kB)
    fixedvalues.jpg (32.0 kB)
    Add comment
    10|10000 characters needed characters exceeded