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: 

Rounding off currency value

Former Member
0 Kudos

Hi all,

Is there a function module to round off the currency value to nearest 0.05 , ie. if the currency value is 10.63, it should be rounded off to 10.65 and when it is 10.68, it should be rounded off to 10.70?

If yes, could you please let me know?

Any help in this regard is appreciated.

Regards,

Partha.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi all,

Thanks for all your replies.But my requirements are still not met.Let me quoate it again.If the currency value is 10.63 , it should be rounded off to 10.65 and when it is 10.67 , it should be rounded to 10.70.

<u><b> 'ROUND' function module</b></u>

The importing parameters as suplied by me:

Decimal : '2'

Input : '10.63'

Sign : '+'.

This returns 10.63 as output and not 10.65.The problem here is that i dont the two decimal to be rounded to one.

Is there any other of giving importing parameters to ROUND function module to get it to rounded off to 0.05th decimal place.

<u><b>Use of CEIL & FLOOR statements</b></u>

These statements seem to be rounding the currency value to the nearest integer value.Rounds 10.63 to either 10 or to 11.

More clarifications in this regard would be appreciated.

Regards,

Partha

9 REPLIES 9

suresh_datti
Active Contributor
0 Kudos

Did you try the function module ROUND ?

Regards,

Suresh Datti

0 Kudos

use FM <b>ROUND</b>

Former Member
0 Kudos

Hi Partha,

You can use CEIL or FLOOR abap commands to achieve the same.

Alternatively use the FM's

1) ROUND_AMOUNT

2) FI_ROUND_AMOUNT

Cheers

VJ

rahulkavuri
Active Contributor
0 Kudos

Check the above thread and dont forget to award points if found helpful

Former Member
0 Kudos

Hi all,

Thanks for all your replies.But my requirements are still not met.Let me quoate it again.If the currency value is 10.63 , it should be rounded off to 10.65 and when it is 10.67 , it should be rounded to 10.70.

<u><b> 'ROUND' function module</b></u>

The importing parameters as suplied by me:

Decimal : '2'

Input : '10.63'

Sign : '+'.

This returns 10.63 as output and not 10.65.The problem here is that i dont the two decimal to be rounded to one.

Is there any other of giving importing parameters to ROUND function module to get it to rounded off to 0.05th decimal place.

<u><b>Use of CEIL & FLOOR statements</b></u>

These statements seem to be rounding the currency value to the nearest integer value.Rounds 10.63 to either 10 or to 11.

More clarifications in this regard would be appreciated.

Regards,

Partha

0 Kudos

hi ,

try that coding:

PARAMETERS val TYPE p DECIMALS 2 DEFAULT '10.62'.

DATA val1 TYPE p DECIMALS 1.
DATA val2 TYPE p DECIMALS 2.
DATA zc(4).
DATA zt.
DATA zh.
DATA v05 TYPE p DECIMALS 2 VALUE '0.05'.
zc = frac( val ).
zt = zc+2.
zh = zc+3.
MOVE val TO val1.

CASE zh.
  WHEN 3 OR 4.
    val2 = val1 + v05.
  WHEN 5 or 6 or 7.
    val2 = val1 - v05.
  WHEN OTHERS.
    val2 = val1.
ENDCASE.

WRITE: val , val2.

Andreas

0 Kudos

use

HR_IN_ROUND_AMT

HR_NZ_ROUNDING_DECIMALS

reward point if it helps

gunjan

Former Member
0 Kudos

hi,

try this out.here is the sample program.

pl look into my modified program,

i am assuming your requirement is like

if the last digit in your value is < 5. it should be rounded to 5.

like 10.23 should come to 10.25

& if the last character value is > 5 , it should be rounded to next value with 0.

10.67 should be 10.70

10.98 should be 11.00.

with this assumption, i developed this small code. let me know, if i am wrong.

regards

srikanth

DATA : V_CURR TYPE VBAK-NETWR,

V_CHAR(10) TYPE C.

V_CURR = '10.67'.

WRITE V_CURR TO V_CHAR.

CONDENSE V_CHAR NO-GAPS.

DATA : V_STRLEN TYPE I.

BREAK-POINT.

V_STRLEN = STRLEN( V_CHAR ).

IF V_STRLEN <> 0 .

V_STRLEN = V_STRLEN - 1.

IF V_CHAR+V_STRLEN < '5'.

V_CHAR+V_STRLEN = '5'.

V_CURR = V_CHAR.

ELSE.

IF V_CHAR+V_STRLEN = '6'.

V_CURR = V_CURR + '0.04'.

ELSEIF V_CHAR+V_STRLEN = '7'.

V_CURR = V_CURR + '0.03'.

ELSEIF V_CHAR+V_STRLEN = '8'.

V_CURR = V_CURR + '0.02'.

ELSEIF V_CHAR+V_STRLEN = '9'.

V_CURR = V_CURR + '0.01'.

ENDIF.

ENDIF.

ENDIF.

write 😕 v_curr,

v_char.

added modified code.

Message was edited by: Srikanth Kidambi

Former Member
0 Kudos

Hi Gunjan,

The function module HR_IN_ROUND_AMT looks to be perfect.Thank you.

Thanks all for your replies and timely help.

Regards,

Partha