on 10-14-2008 9:23 AM
Hi Friends,
In my requirement number is coming with -ve sign on the right side of the number.
ie: if numberis -123.45 we are getting as 123.45- as client requirement.
Need to write an UDF to convert that number into string to map to string type element.
Thanks,
Swapna.
When you pass an element to UDF, it is passed as string only. So you do not need to convert it
UDF
String str1 = a.replace("-",""); // a is number to be operated
str1 = "-" + str1
return str1;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you can use the below udf
public String replace(String a,Container container)
{
String c = a.substring(0,a.length());
String d = c + "-";
return d;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Swapna,
it can done using substring and concat function
by using the substring try to eliminate the '-ve' sign then concat teh output with the
'-ve' sign
eg: -123.45 123.45 concat -ve
regards
Sampath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you say your input could be for example 123.45- and your output:
1) should be a string
2) look like -123.45
3) 1 + 2
Could you please clarify.
Regards
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In udf write:
{
return a.substring(1,a.length())+"-";
}
adding empty string "" converts it into string.
Edited by: Ritu Sinha on Oct 14, 2008 1:59 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
U can write a UDF with the following code
int i = -123.45;
String s = i + "";
OR
Directly use graphical mapping function,
Source filed -> replaceAll (provide argument as "-") -> Then concat "-" at end.
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 |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
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.