cancel
Showing results for 
Search instead for 
Did you mean: 

Rounding a quantity field to one decimal place. PLEASE URGENT

Former Member
0 Kudos

I have a quantity field with three decimal places. I have to print this field with only one decimal place. This is in a smartform.

suppose: qty = 45.678

I want it to be printed as 45.7

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

anversha_s
Active Contributor
0 Kudos

hi,

chk this.

data: out_qty type p decimals 1,
        in_qty type p decimels 3 value ' 45.678'.

out_qty = in_qty.

write out_qty.

Rgds

Anver

Former Member
0 Kudos

Hey Anver,

Sorry for having confused you. Thanks for your help

Thanks n Regards,

rik

Answers (4)

Answers (4)

dev_parbutteea
Active Contributor
0 Kudos

Hi,

use : move qty to Temp_qty decimal 1.

Regards,

Sooness.

dev_parbutteea
Active Contributor
0 Kudos

or write qty to Temp_qty decimals 1.

Former Member
0 Kudos

declare a variable and pass the value to this.

<b>data: v_qty type p decimals 1.</b>

Thanks

eswar

Former Member
0 Kudos

Hi Riki,

I think you can use Function Module ROUND to round off the value...

REPORT ZTEST_SHAIL4 .

data: out type p decimals 1,

inp type f.

inp = '45.678'.

CALL FUNCTION 'ROUND'

EXPORTING

  • DECIMALS =

input = inp

  • SIGN = ' '

IMPORTING

OUTPUT = out

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.

Now use the variable 'out' to display the rounded off value...

Regards,

SP.

Former Member
0 Kudos

Hi,

Use &QTY&(.1) if you want to only display 1 decimal.