FUNCTION {{p}}carpet_fee IMPORTING iv_clean_type TYPE string iv_area_sqm TYPE decfloat34 iv_stain TYPE abap_bool EXPORTING ev_fee TYPE decfloat34 ev_note TYPE string EXCEPTIONS invalid_type invalid_area stain_not_allowed area_too_large. IF iv_clean_type <> 'CP' AND iv_clean_type <> 'UP' AND iv_clean_type <> 'RU'. RAISE invalid_type. ENDIF. IF iv_area_sqm <= 0. RAISE invalid_area. ENDIF. IF iv_stain = abap_true AND iv_clean_type = 'RU'. RAISE stain_not_allowed. ENDIF. IF iv_clean_type <> 'CP' AND iv_area_sqm > 100. RAISE area_too_large. ENDIF. DATA lv_rate TYPE decfloat34. CASE iv_clean_type. WHEN 'CP'. lv_rate = '3.50'. WHEN 'UP'. lv_rate = '5.00'. WHEN OTHERS. lv_rate = '2.00'. ENDCASE. DATA(lv_fee) = iv_area_sqm * lv_rate. IF iv_stain = abap_true. lv_fee = lv_fee + 25. ENDIF. lv_fee = round( val = lv_fee dec = 2 mode = cl_abap_math=>round_half_up ). IF lv_fee < 40. ev_fee = 40. ev_note = 'MINIMUM FEE APPLIED'. ELSE. ev_fee = lv_fee. ev_note = ''. ENDIF. ENDFUNCTION.