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: 

decimal rounding..

Former Member
0 Kudos
234

hi,

i went thru the forum for this and tried but did not work out..

my requirement is to round off a decimal number to zero decimals. so if the value is 1.3456 it should be 1.00 and if it is 1.8767 then it should be 2.00.

i used the ROUND FM, no help..anything else is can do ?

i am trying to set this rounded number in my dialog screen text element whose data type is set as INIT1.

do i need to change anything ?? pl suggest.

thks

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos
191

Just move the content to TYPE I field.

Like:


DATA: P_VAL TYPE P DECIMALS 3 VALUE '1.887',
P_INT TYPE I.

P_INT = P_VAL.
P_VAL = P_INT.

WRITE: P_VAL.

Regards,

Naimesh Patel

4 REPLIES 4

naimesh_patel
Active Contributor
0 Kudos
192

Just move the content to TYPE I field.

Like:


DATA: P_VAL TYPE P DECIMALS 3 VALUE '1.887',
P_INT TYPE I.

P_INT = P_VAL.
P_VAL = P_INT.

WRITE: P_VAL.

Regards,

Naimesh Patel

narin_nandivada3
Active Contributor
0 Kudos
191

Hi,

Check this thread..

Hope this would help you.

Good luck

Narin

Former Member
0 Kudos
191

Hi Friend,

You can use the function module:

J_1I6_ROUND_TO_NEAREST_AMT

CALL FUNCTION 'J_1I6_ROUND_TO_NEAREST_AMT'
EXPORTING I_AMOUNT = V_KWERT u201C Amount to convert*
 
I_AMOUNT1 =
I_AMOUNT2 =
I_AMOUNT3 =
I_AMOUNT4 = ...

Regards,

Chandra Sekhar

Former Member
0 Kudos
191

Hi,

you can do this by declaring one more variable of type INT. and then pass the value with decimal to this type.

for e.g

type_p = 12.224.

type_i = type_p . it will store 12

type_p = type_i.

it will store 12.00.

*Please reward if you find the answer useful.

Thanks,

Kamesh