Files

1.9 KiB

1. Goal

Calculate the price of a classified advertisement for a newspaper. The sales desk calls one function module for each advertisement order, before it saves the order.

2. Open questions

None.

3. Context

  • Function group {{P}}FG_AD exists in package $TMP.
  • The sales desk calls the new function module for each advertisement order.

4. Contract

  • Create the function module {{P}}AD_PRICE in function group {{P}}FG_AD.
  • The interface of {{P}}AD_PRICE is:
    • importing iv_lines type i: the number of lines of the advertisement.
    • importing iv_insertions type i: the number of times that the advertisement is printed.
    • importing iv_photo type abap_bool: abap_true if the advertisement has a photo.
    • exporting ev_price type decfloat34: the price of the advertisement in euro.
    • exceptions invalid_lines and invalid_insertions.

5. Business rules

  1. If iv_lines is less than 1, raise the exception INVALID_LINES.
  2. If iv_insertions is less than 1, raise the exception INVALID_INSERTIONS.
  3. One line of the advertisement costs 12.45 euro.
  4. A photo costs 25.00 euro. Charge the photo once for each order.
  5. The discount applies to the sum of the line price and the photo price:
    • 1 or 2 insertions: no discount.
    • 3, 4 or 5 insertions: 10 % discount.
    • 6 or more insertions: 20 % discount.
  6. Round the price half up to 2 decimals.
  7. The minimum price is 20.00 euro. Apply the minimum price after the discount and after the rounding.

6. Constraints

  • Release target: 7.40 SP05. Use only ABAP syntax that release 7.40 SP05 supports. Do not use inline declarations or constructor expressions.
  • Coding standards: Clean ABAP. Keep every method below 40 statements.
  • Out of scope: database tables, reports, ALV lists, and other function modules.

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.