data : l_val type p decimals 2, l_val2 type p decimals 3. l_val2 = 1.236. move l_val2 to l_val. write :/ l_val.
Best regards,
Prashant
Hi,
Use the following code:
DATA: num1 TYPE p DECIMALS 3 VALUE '1.232', num2 TYPE p DECIMALS 2. CALL FUNCTION 'ROUND' EXPORTING decimals = 2 input = num1 sign = '+' IMPORTING output = num2 EXCEPTIONS input_invalid = 1 overflow = 2 type_invalid = 3 OTHERS = 4. IF sy-subrc EQ 0. WRITE:/ num1, num2. ENDIF.
This will work for all the cases:
num1 = 1.232 then num2 = 1.24
num1 = 1.23 then num2 = 1.23
num1 = 1.236 then num2 = 1.24
Regards,
Lavanya
Edited by: Lavanya Gourisetty on Dec 23, 2008 9:49 AM
Edited by: Lavanya Gourisetty on Dec 23, 2008 10:23 AM
Add a comment