on 03-03-2009 1:34 PM
Hi All,
Can you please help me out in this.
I need to write a UDF
1. Check if any perficular field is balnk then return a hypen ( -)
or Check if any that fields contains any leading zeros then also return a hypen .
Ex:
Field = Name
Length = 40
If there is no data provided in the name fields then i will populate ( - )
if there is a single zeros i will return ( - )
If there are multiple zeros then also i need to return ( - ).
I will be glad for the help.
Thanks,
Jay
here a sample on i have written :
int i;
int counter = 0;
for( i = 0; i< a.length;i++)
{
if a<i>.equal( " ")
counter = counter +1;
}
if counter > 0
result.addvalue( "-");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shweta,
Many thanks for the logic.
Yes it works.
-
String s = a;
boolean flag = false;
for(int i=0;i<s.length();i++)
{
if(!s.substring(i,i+1).equals("0"))
flag = true;
if(flag == true)
{
return s;
// break;
}
}
return "-";
-
Point Rewarded.
Best Regards,
Jay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Partick for the quick reply.
However, here i want to check the total field to be zeros not only the starting string. suppose say the name may start with 00000000ABC00000(length is different , this is just an example) then here i have to pass as it is not hypen.
but if i have all the values as zeros or a single value as zeros then i need to pass a hypen .
I can provide another example:
Feild = Business partner
Length = 5
if 00000 then pass ( - )
or if 0000 then pass ( - )
or if 000 then pass ( - )
or if 00 then pass ( - )
or if 0 then pass ( - )
but if 00001 then pass as it is .
Thanks,
Jay.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you could do it with standard functions:
if (Name equalsS Constant "" or Name startsWith "0")
then "-"
else Name
Regards
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.