Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

help with conversion

bruno_franzini1
Explorer
0 Likes
845

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).

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
782

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...

4 REPLIES 4
Read only

Former Member
0 Likes
783

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...

Read only

0 Likes
782

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.

Read only

0 Likes
782

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.

Read only

0 Likes
782

I've already found it.

I just replaced 'NUM TYPE i' to 'NUM TYPE p length 13 DECIMALS 2.