cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding the udf

giridhar_vegi
Participant
0 Kudos


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

Accepted Solutions (1)

Accepted Solutions (1)

iaki_vila
Active Contributor
0 Kudos

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.

Answers (2)

Answers (2)

former_member191435
Contributor
0 Kudos

Hi Giridhar,

you can do this without UDF also...

Please find my mapping screenshot

Mention fixed values like this

Thanks,

Sreenivas

giridhar_vegi
Participant
0 Kudos

Thank  u sreenivas i will try that way. any way may issue is completed

azharshaikh
Active Contributor
0 Kudos

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