Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
2.1 KiB
2.1 KiB
1. Goal
Refactor the legacy function module {{P}}CRANE_FEE_OLD in function group {{P}}FG_CRANE. The function module calculates the fee of a crane hire job. The refactoring must improve the quality of the code. The behavior stays the same. The name and the public interface stay the same.
2. Open questions
None.
3. Context
- Function group {{P}}FG_CRANE exists in package $TMP.
- Function module {{P}}CRANE_FEE_OLD exists in this group. It is the legacy implementation of the fee calculation. Read its source. The source defines the fee rules of the crane hire company.
- A crane hire company uses the function module to price jobs. The dispatcher enters the crane type, the number of hours, the distance in kilometres, whether the job is on a weekend, and the customer category. The function module returns the base fee, the travel fee, the surcharge, the discount, and the total fee.
4. Contract
- Refactor the function module {{P}}CRANE_FEE_OLD in function group {{P}}FG_CRANE in place.
- Keep the name and the public interface exactly as they are.
- The interface is:
- Importing: iv_crane_type TYPE string, iv_hours TYPE decfloat34, iv_distance_km TYPE i, iv_weekend TYPE abap_bool, iv_customer TYPE string.
- Exporting: ev_base_fee TYPE decfloat34, ev_travel_fee TYPE decfloat34, ev_surcharge TYPE decfloat34, ev_discount TYPE decfloat34, ev_total TYPE decfloat34.
- Exceptions: invalid_crane_type, invalid_hours.
5. Business rules
The behavior of the current implementation is the specification. The refactored function module must return exactly the same values as the current implementation for every input. Read the legacy source carefully to learn the rules. Do not change the behavior.
6. Constraints
- Release target: 7.58.
- Coding standards: Clean ABAP. Methods must be shorter than 40 statements. Pass large parameters by reference.
- Out of scope: do not change the function group {{P}}FG_CRANE.
7. Acceptance
- The function module {{P}}CRANE_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.