Files

2.1 KiB

1. Goal

Refactor the legacy function module {{P}}BOWL_FEE_OLD in function group {{P}}FG_BOWL. The function module calculates the fee of a booking of bowling lanes at a bowling centre. The booking program calls the function module for each booking. The code is old, hard to read, and hard to maintain. Refactor the code in place. Read the legacy code. The legacy code contains the calculation rules. The behaviour stays the same.

2. Open questions

None.

3. Context

  • Function group {{P}}FG_BOWL exists in package $TMP.
  • Function module {{P}}BOWL_FEE_OLD exists in this group. It contains the legacy code.
  • The booking program calls {{P}}BOWL_FEE_OLD. The booking program also calls {{P}}BOWL_INFO.

4. Contract

  • Refactor the function module {{P}}BOWL_FEE_OLD in function group {{P}}FG_BOWL.
  • The name, the parameter names, the parameter kinds, the parameter types, and the exceptions stay exactly as they are:
    • IMPORTING iv_lanes TYPE i
    • IMPORTING iv_minutes TYPE i
    • IMPORTING iv_players TYPE i
    • IMPORTING iv_day TYPE string
    • IMPORTING iv_start TYPE t
    • IMPORTING iv_member TYPE abap_bool
    • EXPORTING ev_fee TYPE decfloat34
    • EXCEPTIONS invalid_input

5. Business rules

  1. The legacy code defines the calculation. Read the legacy code. The result stays the same for every input combination.
  2. The code follows Clean ABAP: small units with one task, no deep nesting, no magic numbers, and meaningful names.
  3. No unit has more than 40 statements.
  4. The code has no syntax error and no ATC finding of priority 1 or 2.

6. Constraints

  • Release target: SAP_BASIS 816 (ABAP Platform 2025).
  • Package $TMP. Do not use transports.
  • The refactored code stays in the body of {{P}}BOWL_FEE_OLD, between the FUNCTION statement and the ENDFUNCTION statement. Do not add local classes after ENDFUNCTION; the source tooling does not activate them.
  • Out of scope: do not change {{P}}BOWL_INFO. Do not change the interface of {{P}}BOWL_FEE_OLD.

7. Acceptance

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