Application Development 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: 

regarding decimal rouding off

Former Member
0 Kudos

Hi all,

I have a requirement as given below . Can anyone suggest me what should be done to get this solution.

"Quantity is a decimal number u2013 The integration team is expecting integer , so lets round it off to the nearest integer if there is a decimal value. For eg. if the value is 100.5, we should round it to 101. No decimal places should be sent in the file."

Frnds plzz suggest me solutions.

regards,

karan

8 REPLIES 8

0 Kudos

Hi,

TRY THIS CODE

take second variable of type c and in write statement

write <1st var> to <2nd var> decimals 0.

regards.

sriram.

Former Member
0 Kudos

Hi

It can be done using write statement if you want to round the amount field in the report. This can be easily achieved by the following operation. A constant need to be defined with value 0.5. rounding is achieved by amount = floor( amount + constant ).

alternatively T-code OAYO helps in rounding off.

regards

Divya

0 Kudos

Hi,

other wise try this code.

suppose var1 = 1234.56

write:/ var1 out put is 1,234.560

write:/ var1(.1) output is 1,234.6

write:/ var1(.4) output is 1,234.5600

write:/ var1(.0) output is 1,235

here last one is your answer.

regards.

sriram

Former Member
0 Kudos

hi,

do this way ...


data : v_int type i,
         v_quant like bseg-dmbtr.
  v_quant = '126.67'.
CALL FUNCTION 'ROUND'
  EXPORTING
*   DECIMALS            = 0
    input               = v_quant
*   SIGN                = ' '
 IMPORTING
   OUTPUT              = v_int.

write : v_int.

Regards,

Santosh

.

Former Member
0 Kudos

hi karan,

watch out for this example,i know it will definately help you out.

DATA A TYPE P DECIMALS 3.

A = '123.456'.

WRITE: / A ROUND -2,

/ A ROUND -1,

/ A ROUND 1.

plzz do give points also.

Former Member
0 Kudos

Hi kiran,

There is no need to use any coding OR calling the Function modules ,

The simplest way to solve this problem is just declare one variable with integer type (i.e type i)

and move the deciamal value into that variable( type i), it will be rounded off,

Reward me points if helpfull,

Regards,

Krishna Prasad.K

Former Member
0 Kudos

Hi,

Try this code:


data : amt(10) type p decimals 2 value '100.2',
       res type I.

res = amt.
write : res.

OR

Use can use FM ROUND.

Thanks,

Sriram Ponna.

Former Member
0 Kudos

answered