on 04-08-2008 8:45 AM
hello
does anybody know how to round a value to the nearest integer in a smartform
if the value is 2.67, it should be 3
if the value is 3.01, it should be 3
hope this will help you
DATA : l_var(4) TYPE p decimals 3.
DATA : l_var2(4) TYPE p decimals 2.
l_var = '4.017'.
CALL FUNCTION 'ROUND'
EXPORTING
DECIMALS = 3
input = l_var
IMPORTING
OUTPUT = l_var2.
write : l_var2.
plz reward if useful
vivek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Anjali
Check this sample program. It works fine.
Regards,
Venkat.O
REPORT zvenkat_test2.
DATA: l_value1 TYPE p0008-anz02 VALUE '2.67',
l_value2 TYPE p0008-anz02 VALUE '3.10',
l_value3 TYPE i,
l_value4 TYPE i.
CALL FUNCTION 'ROUND'
EXPORTING
decimals = 2
input = l_value1
sign = '+'
IMPORTING
output = l_value3
* 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_value3.
CALL FUNCTION 'ROUND'
EXPORTING
decimals = 2
input = l_value2
sign = '+'
IMPORTING
output = l_value4
* 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_value4.
hi,
use &ITAB-LFKIMG(C)& to write the integer part.
reward points if useful.
regards,
sandhya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.