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

round without round function

Former Member
0 Likes
842

currently, we face a issue, given PO amount 3230.58, after calling function "round", it becomes 3231.00, this is ok, but if PO amount 3230.12, after calling function round, it becomes 3230.12, it should be 3230.00,how to fix this?

if without calling function round, can any piece of code to fix the issue? thanks

4 REPLIES 4
Read only

Former Member
0 Likes
614

Hi,

Have you specified 'SIGN' in the EXPORTING PARAMETERS.

Following are the options.

Flag for rounding up, rounding down, commercial roundoff

SPACE : no rounding (input = output)

'+' : round up

'-' : round down

'X' : commercial rounding

Naveen Vajja

Read only

Former Member
0 Likes
614

Hi, Please try the following code

DATA: v_two_decimal type i VALUE '100',

v_amount1 TYPE MAXBT VALUE '100.12',

x_amount1 TYPE maxbt.

CALL FUNCTION 'HR_IN_ROUND_AMT'

EXPORTING

amount = v_amount1

rndoff = v_two_decimal " round off precision 2 decimal places

RNDLMT = 'N'

IMPORTING

RETAMT = x_amount1.

x_amount1 will give 100.00

if the value of v_amount1 is 100.58,

it will give 101.00

Read only

Former Member
0 Likes
614

Hi

Try this


REPORT zteste_raul.

DATA: x TYPE p DECIMALS 3 VALUE '3230.58'.
DATA: y TYPE p DECIMALS 3 VALUE '3230.12'.

WRITE: x DECIMALS 0.
NEW-LINE.
WRITE: y DECIMALS 0.

--

Raul Natu

Read only

MarcinPciak
Active Contributor
0 Likes
614

DATA: x TYPE p DECIMALS 2 VALUE '3230.58'.
DATA: y TYPE p DECIMALS 2 VALUE '3230.12'.

x = FLOOR( x + '0.5' ).
y = FLOOR( y  + '0.5' ).

WRITE: x, "3231   
       y. "3230

Regards

Marcin