FUNCTION {{p}}dep_calc IMPORTING iv_code TYPE c iv_quantity TYPE i iv_damaged TYPE abap_bool EXPORTING ev_deposit TYPE decfloat34 EXCEPTIONS invalid_quantity invalid_container. DATA lv_unit TYPE decfloat34. IF iv_quantity < 1. RAISE invalid_quantity. ENDIF. CASE iv_code. WHEN 'A'. lv_unit = '1.50'. WHEN 'B'. lv_unit = '3.00'. WHEN 'G'. lv_unit = '0.08'. WHEN 'P'. lv_unit = '0.25'. WHEN OTHERS. RAISE invalid_container. ENDCASE. IF iv_damaged = abap_true. lv_unit = lv_unit / 2. lv_unit = round( val = lv_unit dec = 2 mode = cl_abap_math=>round_half_up ). ENDIF. ev_deposit = round( val = lv_unit / iv_quantity dec = 2 mode = cl_abap_math=>round_half_up ). ENDFUNCTION.