‎2007 May 28 10:15 AM
Hi Friends,
Pls tell me how to round a number to given digit.
Thanks.
‎2007 May 28 10:18 AM
hi,
Pass it to type P Variable.
i,e,
<b>data: var type P decimals 2.</b>
Regards,
Santosh
‎2007 May 28 10:17 AM
Effect of different ROUND specifications:
DATA: X TYPE P DECIMALS 2 VALUE '12493.97'.
WRITE: /X ROUND -2, "output: 1,249,397.00
/X ROUND 0, "output: 12,493.97
/X ROUND 2, "output: 124.94
/X ROUND 5, "output: 0.12
‎2007 May 28 10:17 AM
Hi,
Data : num type i.
num = round (given_num).
Thanks
sandeep
Reward if helpful
‎2007 May 28 10:18 AM
hi,
Pass it to type P Variable.
i,e,
<b>data: var type P decimals 2.</b>
Regards,
Santosh
‎2007 May 28 10:18 AM
Hi
see this Maths functions and try doing them.
abs -Absolute value of the argument arg
sign- Plus/minus sign of the argument arg: -1, if the value of arg is negative; 0 if the value of arg is 0; 1 if the value of arg is positive.
ceil -Smallest integer number that is not smaller than the value of the argument arg.
floor- Largest integer number that is not larger than the value of the argument arg.
trunc- Value of the integer part of the argument arg
frac- Value of the decimal places of the argument arg
Reward points if useful
Regards
Anji
‎2007 May 28 10:28 AM
hi,
try these simple codes:
DATA :
varxx type p LENGTH 4 DECIMALS 2 VALUE '2.96' ,
varx2 type p LENGTH 4 DECIMALS 2 VALUE '2.46' ,
vari1 TYPE n LENGTH 4,
vari2 TYPE n LENGTH 4,
num TYPE n LENGTH 4.
WRITE varxx to vari1 DECIMALS 0.
WRITE varx2 to vari2 DECIMALS 0.
WRITE:/ varxx , ' ', vari1.
WRITE:/ varx2 , ' ', vari2.
Regards,
Sooness
‎2007 May 28 10:34 AM
Hi,
Use ROUND function, Number is rounded up or down during conversion. The different formats of ROUND are:
ROUND <r> : Type P fields are multiplied by 10**(-r) and then rounded.
Ex:
DATA pack TYPE p VALUE '123.456'
DECIMALS 3.
WRITE pack DECIMALS 2.
WRITE: / pack ROUND -2,
/ pack ROUND -1,
/ pack ROUND 1,
/ pack ROUND 2.
Output:
123,46
12.345,600
1.234,560
12,346
1,235
Regards,
Bhaskar
‎2008 Sep 02 7:09 AM
Hello,
In case of pricing procedure, you can tackle this by using standard routine in your pricing procedure.
In the 'Caltype' column in pricing that is "Condition formula for alternative calculation type", you need to add routine number "17 Rounding as perT001R", before those excise conditions which you want rounded.
Additionally, in table T001R such rounding data should be maintained.
For this goto SPRO - SAP NetWeaver - General Settings - Currencies - Define rounding rules for currencies
here maintain: Co, Code + Currency = 100
Additionally you can convey this to your consultant
This will solve your problem
Regards
Dhananjay
‎2008 Sep 02 7:20 AM
hi
use floor statement or Fm Round
for Fm ROUND refer to its documentation for better understanding
and for Statement floor . Put an cursur over it in abap editor and press F1 u fet the documentaion of it .
Cheers
Snehi
Edited by: snehi chouhan on Sep 2, 2008 8:21 AM