Skip to Content
0
Former Member
Aug 11, 2005 at 12:34 PM

Rounding a Currency Value

18 Views

I have written a BW routine that takes a fiscal period value and divides into weeks. I do the division and take away the divided value from the original, except on the last pass, where is use the remaining value.

I expected the remaining value to be under a dollar, but in some cases it is as much as $4.00 USD.

I am wondering if there is a reason for the large remainder, and perhaps if I should be doing something differently?

    l_original_amt = COMM_STRUCTURE-debit.
    l_weekly_amt = l_original_amt / l_weeks_in_period.

    LOOP....
      IF sy-index < l_weeks_in_period.
        RESULT_TABLE-debit = l_weekly_amt.
        l_original_amt = l_original_amt - l_weekly_amt.
      ELSE.
        RESULT_TABLE-debit = l_original_amt.
      ENDIF.
      ...
    ENDLOOP