on 04-29-2006 6:59 AM
hi ,
i have the requirement to find out the fn module to round off the third decimal value.for eg..if the value is 155.123 then it should print 155.10 and if the value is 155.126 then it should print 155.13.is there any fn module availabel for this type of rounding...
thnax in advance...
Praveen.Nekkanti
Hi All
Use the below code and it is so simple
For 2 decimal places
data(lv_round) = round( val = '5678.65800341' dec = 2 ).
lv_round will be 5678.66
data(lv_round) = round( val = '5678.65300341' dec = 2 ).
lv_round will be 5678.65
For 5 decimals
data(lv_round) = round( val = '5678.65800741' dec = 5 ).
lv_round will be 5678.65801
data(lv_round) = round( val = '5678.65800341' dec = 5 ).
lv_round will be 5678.65800
Thanks,
Murugan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Praveen,
If the conversion logic you want to implement is within a loop:
Use Simple SAP arithmethic function <b>CEIL</b> this will round of the value to the next upper value or use <b>FLOOR</b> to the lower value.
If the conversion logic you want to implement is outside a loop use the FM mentioned in the post above.
Just for better performance
Cheers
VJ
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
chk whether this FM works for u:
HR_NZ_ROUNDING_DECIMALS
rgds,
Latheesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Praveen,
Use function module ROUND.
Regards,
Tanveer.
Please mark helpful answers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Naveen,
You can use ROUND function Module to satisfy your requirement.
Just check this code.
REPORT ZTEST_SHAIL4 .
data: out type p decimals 2,
inp type f.
inp = '123.324'.
CALL FUNCTION 'ROUND'
EXPORTING
DECIMALS =
input = inp
SIGN = ' '
IMPORTING
OUTPUT = out
EXCEPTIONS
INPUT_INVALID = 1
OVERFLOW = 2
TYPE_INVALID = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
write out.
The output will be 123.32.
Reward points if found useful.
Regards,
SP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.