Files
2026-10-05 18:02:52 +02:00

2.9 KiB

1. Goal

A paint shop mixes custom paint colours. A customer order contains one or more tint components. The checkout program calls one function module for each order. The function module returns the total volume and the price of the mix.

2. Open questions

None.

3. Context

  • The class {{P}}PAINT_MIX exists in package $TMP. It contains the public types ty_tint and ty_tints. The checkout program and the function module use these types.
  • The table {{P}}TINTPR exists in package $TMP. It contains the price of one millilitre of each tint. The class {{P}}PAINT_MIX fills this table.
  • The function group {{P}}FG_PAINT exists in package $TMP.
  • The function module {{P}}MIX_SAMPLE exists in this function group. It is a sample. It shows the interface that the checkout program uses.

4. Contract

  • Create the function module {{P}}MIX_PRICE in function group {{P}}FG_PAINT.

  • Use exactly this interface:

    IMPORTING it_tints TYPE {{P}}PAINT_MIX=>TY_TINTS EXPORTING ev_volume TYPE decfloat34 ev_price TYPE decfloat34 EXCEPTIONS no_components invalid_quantity unknown_tint

  • The type {{P}}PAINT_MIX=>ty_tint has these components: tint_id type c, length 4 quantity_ml type i

  • The type {{P}}PAINT_MIX=>ty_tints is a table of ty_tint.

  • The table {{P}}TINTPR has these fields: tint_id type c, length 4 price_ml type packed number, 13 digits, 3 decimals

  • The table {{P}}TINTPR contains this data: WHIT 0.020 BLUE 0.045 GREY 0.030 GOLD 0.250

5. Business rules

  1. The component quantity_ml is a volume in millilitres.
  2. If it_tints is empty, raise the exception NO_COMPONENTS.
  3. If a component has a quantity_ml of zero or less, raise the exception INVALID_QUANTITY.
  4. If a component has a tint_id that is not in the table {{P}}TINTPR, raise the exception UNKNOWN_TINT.
  5. Check rule 2 first. Then check rule 3 for all components. Then check rule 4 for all components. Raise only the first exception that occurs.
  6. ev_volume is the sum of the quantity_ml of all components. If the same tint_id occurs more than once, all its quantities count.
  7. The material price of a component is its quantity_ml multiplied by the price_ml of its tint.
  8. The mixing fee is 1.50 for each different tint_id in the order. A tint_id that occurs more than once counts once.
  9. ev_price is the sum of the material prices of all components plus the mixing fee. Round ev_price half up to 2 decimals.

6. Constraints

  • Release target: 7.58 (the system runs SAP_BASIS 816).
  • Use Clean ABAP. Keep each method below 40 statements.
  • Out of scope: do not change the class {{P}}PAINT_MIX, the table {{P}}TINTPR, and the function module {{P}}MIX_SAMPLE.

7. Acceptance

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