Files

2.2 KiB

1. Goal

Calculate the fee of a campsite pitch booking. The booking program calls one function module for each booking. The function module must have the same interface as the sample module {{P}}CAMP_SAMPLE, because the booking program calls all fee modules in the same way.

2. Open questions

None.

3. Context

  • Function group {{P}}FG_CAMP exists in package $TMP.
  • Function module {{P}}CAMP_SAMPLE exists in this group. It is the sample module. Its interface is the interface that all campsite fee modules use.
  • A booking has a pitch type, a number of nights, a number of adults, and an electricity flag.

4. Contract

  • Create the function module {{P}}CAMP_FEE in function group {{P}}FG_CAMP.
  • Use exactly the interface of {{P}}CAMP_SAMPLE:
    • Importing parameter iv_pitch_type, type string.
    • Importing parameter iv_nights, type i.
    • Importing parameter iv_adults, type i.
    • Importing parameter iv_electricity, type abap_bool.
    • Exporting parameter ev_discount, type abap_bool.
    • Changing parameter cv_fee, type decfloat34.
    • Exception invalid_nights.

5. Business rules

  1. If iv_nights is less than 1, raise the exception INVALID_NIGHTS.
  2. The nightly rate depends on the pitch type:
    • STD: 12.00
    • CMF: 18.00
    • PRM: 25.00
    • Any other pitch type is unknown.
  3. If the pitch type is unknown, set cv_fee to 0.00, set ev_discount to false, and stop. Do not apply rules 4 to 8.
  4. Each adult adds 4.00 per night. If iv_adults is less than 1, count one adult.
  5. If iv_electricity is true, add 3.50 per night.
  6. The subtotal is the sum of the nightly rate, the adult charge, and the electricity charge, multiplied by the number of nights.
  7. If iv_nights is 7 or more, reduce the subtotal by 15 % and set ev_discount to true. Otherwise set ev_discount to false.
  8. Round cv_fee half up to 2 decimals.

6. Constraints

  • Release target: 7.40 SP05. Do not use ABAP syntax that is newer than this release.
  • Coding standards: Clean ABAP. Keep methods below 40 statements.
  • Out of scope: do not change {{P}}CAMP_SAMPLE.

7. Acceptance

  • The function module is active and has no syntax error.
  • The hidden tests pass.
  • Write ABAP Unit tests for the function module in a global test class.