2014 Apr 08 7:29 PM
Hi,
Please, can anyone help me?
I have a smartform and inside a program line I have the following code:
DATA: NUM TYPE i.
NUM = WA_LIPS-LFIMG.
WRITE NUM TO V_LFIMG .
SHIFT V_LFIMG LEFT DELETING LEADING SPACE.
V_CONT_LOTE = V_CONT_LOTE + 1.
The problem is about to show the result number with decimals like '12.345'. I try to add 3 decimals in the result number but the following line of code
"write num to v_lfimg" the result round to next higher number just like in:
"write NUM TO v_lfimg decimals 3" but this way
How can I show the result number with the correct decimals?
PS: wa_lips (input parameter)
v_lfimg type char17 (Output parameter)
LFIMG type quan length 13 decimals 3 (LIPS table).
2014 Apr 08 7:43 PM
Hi, open SE37, set name of FM: ROUND, display, klick icon Documentacion of Fm.... Its a good way how to round up/down/middle a number to other number
data: LV_MENGE type MENGE_D.
data: LV_MENGE1 type MENGE_D.
data: LV_MENGE_C type C LENGTH 20.
LV_MENGE = '5.432'.
call function 'ROUND'
exporting
DECIMALS = 0
INPUT = LV_MENGE
SIGN = '-' " for this, check the documentation!
importing
OUTPUT = LV_MENGE1
exceptions
others = 4.
if SY-SUBRC <> 0.
break-point.
endif.
write: / LV_MENGE1. " 5,000 in numeric form...
write LV_MENGE1 to LV_MENGE_C.
write: / LV_MENGE_C. " 5,000 in char form...
2014 Apr 08 7:43 PM
Hi, open SE37, set name of FM: ROUND, display, klick icon Documentacion of Fm.... Its a good way how to round up/down/middle a number to other number
data: LV_MENGE type MENGE_D.
data: LV_MENGE1 type MENGE_D.
data: LV_MENGE_C type C LENGTH 20.
LV_MENGE = '5.432'.
call function 'ROUND'
exporting
DECIMALS = 0
INPUT = LV_MENGE
SIGN = '-' " for this, check the documentation!
importing
OUTPUT = LV_MENGE1
exceptions
others = 4.
if SY-SUBRC <> 0.
break-point.
endif.
write: / LV_MENGE1. " 5,000 in numeric form...
write LV_MENGE1 to LV_MENGE_C.
write: / LV_MENGE_C. " 5,000 in char form...
2014 Apr 08 7:55 PM
Thank you Bohuslav Riha for help.
I'm sorry I wasn't clear, it's completely the opposite I must show the number but it automatic round.
I don't need to show like this. I have to show the 'unround' number as the result.
Thanks anyway.
2014 Apr 08 7:59 PM
ok then just write the unrounded numer to a char value, this should do what you want or not? the number you are writing (WA_LIPS-LFIMG) has to be in the format you need to output to the char
write WA_LIPS-LFIMG to LV_MENGE_C.
2014 Apr 08 8:18 PM
I've already found it.
I just replaced 'NUM TYPE i' to 'NUM TYPE p length 13 DECIMALS 2.