on 01-29-2009 6:43 AM
Hi Friends,
I aneed to use userdefined function for format number .If i get charecter i should pass the charecte as it is and if i get the value in the source then i have to format the number.Could you please give me the UDF program for this.
Thanks in advance,
Kalam.
Hi,
As you said you will also get characters in your string so in that case you can not use FormatNum function, so in order to suggest you UDF let us know how you want to format if it is numric value.
Regards,
Sarvesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI,
I have a requirement where if the value for a field comes as a blank or as character(non-integer), i want to pass the same value as it is.
If it is a number(Integer) then only i need to format it i.e. padding zeroes.
For Example : Material number is of type character, so it can be either number or character.
i want to add zeroes to Material number if it is only number. if it character or blank i have to leave it like that.
Regards,
Kalam.
Simply use UDF for this condition about finding whether sender fiels is numeric or not. The code below will return the integer if the number is in integer format else will return 0.
int i = 0;
try{
Integer.parseInt(i);
return i;
}
catch(NumberFormatException e){
return "0";
}
After this UDF, you may use formatNum function.
Regards,
Prateek
> For Example : Material number is of type character, so it can be either number or character.
> i want to add zeroes to Material number if it is only number. if it character or blank i have to leave it like that.
Try this UDF..
int k = 0;
int i = 0;
try {
i = Integer.parseInt (a);
} catch (Exception E){
return a;
}
k = 18 - a.length(); // suppose material's std. length is 18
for( int j = 0 ; j < k; j ++)
{
a = "0" + a;
}
return a;
Regards,
Sarvesh
How exactly would you like to format the number? Can't you use standard formatNum function?
Regards,
Prateek
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.