‎2007 Aug 21 7:13 PM
Hi Guys,
I have a condition where I need to round off the number:
1st case: 15/2= 7.5 then it should return 8
IInd cse : 13/3 = 4.3 then it should return 4
and IIIrd case: 17/3= 5.67 then it should return 6
So is tehre any function module that will help me out.
Thanks
Rajeev gupta
‎2007 Aug 21 7:35 PM
‎2007 Aug 21 7:30 PM
Check with below FM's :
ROUND_AMOUNT
ROUND
if you need any other FM's ,just goto SE37 Transaction -> search like round -> here you get list of FM's
Thanks
Seshu
‎2007 Aug 21 7:32 PM
Hi,
Observe the below code which is useful for you .
**************************************************
REPORT RAMESH.
*trunc, ceil and
data:A TYPE P LENGTH 5 DECIMALS 2,
B TYPE P LENGTH 5 DECIMALS 2,
C TYPE P LENGTH 5 DECIMALS 2,
A1 TYPE I,
B1 TYPE I,
C1 TYPE I.
A = '7.5'.
A1 = CEIL( A ).
WRITE:/ A1.
B = '4.3'.
B1 = TRUNC( B ).
WRITE: / B1.
C = '5.67'.
C1 = CEIL( C ).
WRITE:/ C1.
************************************************
Regards
Ramesh mavilla.
‎2007 Aug 21 7:35 PM
‎2007 Aug 21 7:44 PM
Thanks for the reply Aneesh, can you be more specific about the function module. I mean can you help me out how to use it.
Thanks
Rajeev Gupta
‎2007 Aug 21 7:49 PM
DATA: out TYPE i.
DATA: input TYPE f.
DATA : v_input(10) TYPE c.
input = '10.1'.
DATA : v_dec(2) TYPE c,
v_value(10) TYPE c.
DATA : v_sign TYPE c.
v_input = input.
SPLIT v_input AT '.' INTO v_value v_dec.
IF v_dec GE 5.
v_sign = '+'.
ELSE.
v_sign = '-'.
ENDIF.
CALL FUNCTION 'ROUND'
EXPORTING
DECIMALS = 0
input = input
sign = v_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.
‎2007 Aug 21 7:36 PM
Just use a integer to store the values:
DATA: I1 TYPE I.
DATA: I2 TYPE I.
DATA: I3 TYPE I.
I1 = 15 / 2.
I2 = 13 / 3.
I3 = 17 / 3.
WRITE:/ I1, I2, I3.
result: 8, 4 and 6.