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

2.8 KiB

1. Goal

A glazier workshop replaces window panes. For each pane of a job, the quotation program calls one function module. The function module returns the fee of the pane. Other programs of the workshop reuse the same calculation, so the calculation must also be available as a method of a new class.

2. Open questions

None.

3. Context

  • Function group {{P}}FG_GLAZ is in package $TMP.
  • Function module {{P}}GLAZ_SAMPLE is in this function group. It is the sample module. All pane fee modules use the interface of the sample module.
  • The quotation program calls {{P}}GLAZ_FEE for each pane of a job.

4. Contract

  • Create the function module {{P}}GLAZ_FEE in function group {{P}}FG_GLAZ. Use exactly the interface of {{P}}GLAZ_SAMPLE: the same parameter names, the same parameter kinds, the same types and the same exceptions.

  • Create the class {{P}}GLAZ_CALC in package $TMP. The class is public and final. The class has a public constructor without parameters. The class has this public method:

    METHOD calculate IMPORTING iv_width_mm TYPE i iv_height_mm TYPE i iv_glass TYPE string iv_urgent TYPE abap_bool RETURNING VALUE(rv_fee) TYPE decfloat34 RAISING cx_abap_invalid_value.

  • For the same input, {{P}}GLAZ_FEE returns the same fee as the method calculate.

5. Business rules

The input of the calculation is:

  • iv_width_mm: the width of the pane in millimetres.
  • iv_height_mm: the height of the pane in millimetres.
  • iv_glass: the code of the glass type.
  • iv_urgent: the urgent flag.
  1. The width and the height must be greater than 0. If not, the input is invalid.
  2. The glass type code must be SIMPLE, SAFETY or INSULATED. If not, the input is invalid.
  3. The area of the pane in square metres is the width multiplied by the height and divided by 1 000 000.
  4. The price of one square metre is 45.00 for SIMPLE, 90.00 for SAFETY and 140.00 for INSULATED.
  5. The fee is the area multiplied by the price of one square metre.
  6. If the fee is less than 35.00, the fee is 35.00.
  7. If iv_urgent is true, the fee is multiplied by 1.5.
  8. If the fee is more than 480.00, the fee is 480.00.
  9. Round the fee half up to 2 decimals. This is the last step.
  10. For invalid input, the method calculate raises cx_abap_invalid_value and {{P}}GLAZ_FEE raises the exception invalid_input.

6. Constraints

  • Release target: SAP_BASIS 816 (ABAP Platform 2025).
  • Coding standards: Clean ABAP. A method has fewer than 40 statements.
  • Out of scope: do not change {{P}}GLAZ_SAMPLE.

7. Acceptance

  • {{P}}GLAZ_FEE and {{P}}GLAZ_CALC are active and have no syntax error.
  • The hidden tests pass.
  • Write ABAP Unit tests: local test classes for {{P}}GLAZ_CALC and a global test class for {{P}}GLAZ_FEE.