11-04-2012 4:35 PM
hi experts,
I have a column of packed data type with 3 decimals.The values are from a calculation.
I need to round ig=t off as
1)855.999 should be rounded of as 866.000
2)143.1400005589 should be rounded off as 143.144,
is it possible,please let me know.
11-04-2012 4:46 PM
Did you check the fixed point arithmetic in the program attributes, then read the calculation type documentation for rounding rules.
Regards,
Raymond
11-05-2012 6:26 AM
Hello,
You can Formatting option for round off. Chec below link
http://help.sap.com/saphelp_470/helpdata/en/9f/db9e3d35c111d1829f0000e829fbfe/content.htm
Regards,
Deepti
05-27-2014 3:43 PM
Since you want the next number if there is a remainder , the use the mod function to determine if there is a remainder , if there is a remainder then add 1 to the result.
the code will look like this
Data : test type i. v_value = im_ekpo-menge/v_umrez. test = im_ekpo-menge mod v_umrez. if test ne 0. v_value = v_value + 1. endif.
OR
DATA:
L_MENGE_P5(16) TYPE P DECIMALS 5,
L_MENGE_P3(16) TYPE P DECIMALS 3,
L_ANDEC like T006-ANDEC value 0.
L_MENGE_P5 = '56.4456'.
CALL FUNCTION 'ROUND'
EXPORTING
DECIMALS = L_ANDEC
input = L_MENGE_P5 "over here u need to pass other than char
SIGN = '+'
IMPORTING
OUTPUT = L_MENGE_P3
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:/ L_MENGE_P3.
OR
Goto Attributes of the program and tick the check box 'Fixed point Arithmetic' and it will do rounding off the numeric values.
OR
DATA pack TYPE p VALUE '12345678'.
WRITE pack NO-GROUPING ROUND 2 DECIMALS 4.