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
563

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
525

Hi,

I did not get you ..

but yuo can check ceil or floor function for same.

Ashutosh

Read only

0 Likes
525

Hi ..

Thanks for response...

I need that if i give the value 12.33 then its o/p = 12.50 and 12.67 then its o/p = 13 and 12.50 then its o/p 12.50 and 12 then its o/p 12 only i need

based on 0.5 value we can put condtion

Read only

0 Likes
525

Hello

Your code, but a little modified:


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.
lv_amt = '0.50'.
lv_amt = lv_data + lv_amt.
endif.

WRITE lv_amt.

Read only

Former Member
0 Likes
525

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.

Regards

Harish Kumar