on 01-08-2007 12:29 PM
Hi Group,
In designing I have one element with value 19- ,I need to conver it in to -19 ,
Can any body suggest how to do this using UDF.
Hi swabap,
best is to google with
java split array
if after the split
array.length = 1 --> no minus wa found
if
array.length = 2
then return = '-'+ arry[1].
Regards Mario
Regards Mario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Group,
I am using the following code,when I am getting a<i> value negative like 19- its converting to -19 but its still failing.Can any bodyu suggest.
Here I am attaching the UDF code.
BigDecimal sum = new BigDecimal("0");
BigDecimal amt = new BigDecimal("0");
for(int i=0;i<a.length;i++)
{
if(a<i>.endsWith("-"))
{
a<i> = a<i>.replace('-',' ');
a<i> = "-" + a<i>;
}
amt = new BigDecimal(a<i>);
sum = sum.add(amt);
// sum = sum + Double.parseDouble(a<i>);
}
result.addValue(String.valueOf(sum));
Try this:
BigDecimal sum = new BigDecimal("0");
BigDecimal amt = new BigDecimal("0");
for(int i=0;i<a.length;i++)
{
if(a<i>.endsWith("-"))
{
a<i> = a<i>.replaceAll("-","");
a<i> = "-" + a<i>;
}
amt = new BigDecimal(a<i>);
sum = sum.add(amt);
// sum = sum + Double.parseDouble(a<i>);
}
result.addValue(String.valueOf(sum));
HI,
Actually this is the same code which I posted,it is not working may be due to this statement ,where the BigDecimal function not returning the neagtive number.
Can any body Suggest.
<b> amt = new BigDecimal(a<i>);</b>
PS:In my earlier post In the code Part I have by mistake I typed <b>' > '</b>.
First use the java function ReplaceString("originalString","replacement") on your value and replace the Minus with "". Then use concat your "old"value with the minus: valNew = "-".concat(valOld);
Hope this helps.
Dominic
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Swabap,
you can do that with standard function "substring". Plz have a look to <a href="http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm">Standard Functions</a>
Regards,
Udo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
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.