FUNCTION {{p}}theme_fee IMPORTING iv_visitor_type TYPE string iv_tickets TYPE i iv_date TYPE d EXPORTING ev_unit_price TYPE decfloat34 ev_total_price TYPE decfloat34 ev_discount TYPE decfloat34 EXCEPTIONS invalid_visitor_type invalid_tickets. DATA lv_base_price TYPE decfloat34. DATA lv_gross TYPE decfloat34. DATA lv_discount_pct TYPE decfloat34. DATA lv_month TYPE c LENGTH 2. IF iv_tickets <= 0. RAISE invalid_tickets. ENDIF. CASE iv_visitor_type. WHEN 'ADULT'. lv_base_price = '45.50'. WHEN 'CHILD'. lv_base_price = '25.25'. WHEN 'SENIOR'. lv_base_price = '30.75'. WHEN 'FAMILY'. lv_base_price = '40.00'. WHEN OTHERS. RAISE invalid_visitor_type. ENDCASE. " Peak season surcharge: June, July, August IF iv_date IS NOT INITIAL. lv_month = iv_date+5(2). IF lv_month = '06' OR lv_month = '07' OR lv_month = '08'. lv_base_price = lv_base_price + 5. ENDIF. ENDIF. " Group discount IF iv_tickets >= 20. lv_discount_pct = 15. ELSEIF iv_tickets >= 10. lv_discount_pct = 10. ENDIF. lv_gross = lv_base_price * iv_tickets. ev_discount = round( val = lv_gross * lv_discount_pct / 100 dec = 2 mode = cl_abap_math=>round_half_up ). ev_total_price = round( val = lv_gross - ev_discount dec = 2 mode = cl_abap_math=>round_half_up ). ev_unit_price = round( val = lv_base_price dec = 2 mode = cl_abap_math=>round_half_up ). ENDFUNCTION.