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

rounding value.

Former Member
0 Likes
582

PARAMETER: lv_amt type p DECIMALS 2.

data: lv_data type p.

lv_data = lv_amt.

if lv_data > lv_amt.

lv_amt = '0.50'.

lv_amt = lv_data - lv_amt.

else.

lv_amt = '0.50'.

lv_amt = lv_data + lv_amt.

endif.

WRITE lv_amt.

sample code: if I'm entering the value 12.33 then it comes 12.50

12.67 then 13

but i need when im entering the 12.50 then no chanegs same as value 12.50

first 2cases it is okay! for my program.

4 REPLIES 4
Read only

Former Member
0 Likes
538

Nagaraju,

I exexcuted the same program and if i enter 12,50 i am getting 12,50 only.

Thanks

Bala Duvvuri

Read only

Former Member
0 Likes
538

i also execute same and i entering the 12.50 and i got 12.50


data: lv_amt type p DECIMALS 2.
lv_amt = '12.50'.

data: lv_data type p.

lv_data = lv_amt.
if lv_data > lv_amt.
lv_amt = '0.50'.
lv_amt = lv_data - lv_amt.
else.
lv_amt = '0.50'.
lv_amt = lv_data + lv_amt.
endif.

WRITE lv_amt.

Read only

0 Likes
538

H i thanks for reply

No its not working

If i enter 12.50 its coming 13 value and

I need like this

if i enter 12 then o/p 12

12.50 then o/p 12.50

12.33 then 0.p 12.50

12.67 then o/p 13

like this the logic is nt working

Read only

Former Member
0 Likes
538

Dear Nagaraju Gaddam,

I hope the below code will help you to fix the issue,

PARAMETER: lv_amt TYPE p DECIMALS 2.
 
DATA: lv_data TYPE p,
      d TYPE p DECIMALS 2.
 
lv_data = lv_amt.
d = FRAC( lv_amt ).
IF lv_data > lv_amt.
  IF d > '0.50'.
    lv_amt = lv_data.
  ENDIF.
ELSE.
  IF d EQ 0.
  ELSE.
    lv_amt = '0.50'.
    lv_amt = lv_data + lv_amt.
  ENDIF.
ENDIF.
 
WRITE lv_amt.

Note : Please do not repeat the thread.

Regards,