on 06-17-2010 5:12 PM
Hello,
could you pelase help on how to set negative values in PI
my requirement is: i am getting input data for a filed TOTAL as 123456.78- now i want to set this negative value as prefix.
please let me know how to remove that postfix "-" and make it as prefix in mapping. my final output should be like -123456.78
thanks in advance...SARAN
Hi SARAN
> my requirement is: i am getting input data for a filed TOTAL as 123456.78- now i want to set this negative value as prefix.
> please let me know how to remove that postfix "-" and make it as prefix in mapping. my final output should be like -123456.78
create simple UDF (Here input value is strVal)
return ("-"+strVal.substring(0,(strVal.length()-1)));
Regards
Ramesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You dont need a UDF..use node function "REPLACE WITH" and replace your"-" with a space and then just before sending it to the output you can concatenate "-" to the value.
Thanks
S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Adding to venkats comment..
you can use the below code to check whether value contains "-" to append the "-" prefix.
Parameter : strVal
if(strVal.indexOf('-')!=-1) {
return ("-"+strVal.substring(0,(strVal.length()-1)));
}else {
return strVal;
}
You can also use Text function "endwith" to achieve this
Source + Constant -- > endWith --- > ifelse --> Target
Endwith will return boolean true or false. In the "then" constant(-) + source --> concat --> Then
Regards
Ramg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ramesh,
as i am new to this UDFs, could you pelase let me know what i have to specify at Arguments (type,name.javatype) and so ineed any imports for this UDF.
now if i copy your code in UDF editor, i am not able to run. it shows error as " cannot be applied to java.lang.String,int if (strVal >0) ^ 1 error"
i have selected radio button" value" and added name as "strVal".
hi Saran,
UDF:
Please use the suggested UDF in my earlier comment. It should work perfectly.
EndWith Function:
http://www.flickr.com/photos/51263811@N03/4711354049/
Regards
Ramg.
Edited by: Ramkumar Ganesh on Jun 18, 2010 4:52 PM
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.