- Static bundle checks (name length, seed type, reserved words, contract test classes, testclasses_file), local abaplint parser check before SAP, max_tokens, robust JSON parse - Runner: G2 for CDS views with parameters, contract_check detail in report - G0020 and G0013 fixed by review and revalidated (oracle 100, null 0) - Pilot results in docs/faz1-tasarim.md 11e; handover notes merged into CLAUDE.md and docs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68 lines
3.3 KiB
Markdown
68 lines
3.3 KiB
Markdown
# 1. Goal
|
|
Refactor the class {{P}}FREIGHT_CALCULATOR. The class calculates the freight cost of a
|
|
parcel. The calculation is correct, but the code is hard to read and hard to maintain.
|
|
Make the code clean. The behavior and the public API must not change.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The class {{P}}FREIGHT_CALCULATOR exists in package $TMP. It is active.
|
|
- The class contains legacy code: one long method, nested IF blocks, hard-coded
|
|
numbers, a private attribute that is written but never read, and commented-out code.
|
|
- A logistics program calls the class. That program must continue to work without a
|
|
change. Therefore the behavior of the class must stay the same.
|
|
|
|
# 4. Contract
|
|
The public part of the class must stay exactly as it is:
|
|
- The class {{P}}FREIGHT_CALCULATOR is public, final, and has a public constructor
|
|
without parameters.
|
|
- Public type TY_RESULT with these components: STATUS TYPE c LENGTH 10,
|
|
BASE TYPE p LENGTH 9 DECIMALS 2, SURCHARGE TYPE p LENGTH 9 DECIMALS 2,
|
|
TOTAL TYPE p LENGTH 9 DECIMALS 2.
|
|
- Public constant structure C_STATUS with the components OK, WEIGHT and ZONE. Each
|
|
component has the type c LENGTH 10. The values are 'OK', 'WEIGHT' and 'ZONE'.
|
|
- Public method CALCULATE:
|
|
IMPORTING iv_weight_kg TYPE p LENGTH 8 DECIMALS 2
|
|
iv_zone TYPE string
|
|
iv_express TYPE abap_bool DEFAULT abap_false
|
|
RETURNING VALUE(rs_result) TYPE ty_result.
|
|
- Public method IS_ZONE_SUPPORTED:
|
|
IMPORTING iv_zone TYPE string
|
|
RETURNING VALUE(rv_supported) TYPE abap_bool.
|
|
- Do not add other public components or public methods.
|
|
|
|
# 5. Business rules
|
|
The rules below describe the behavior of the class. The behavior must not change.
|
|
1. Normalize the zone: remove all blanks and convert all letters to upper case. A
|
|
zone is known only if the normalized zone is exactly equal to a zone code. Do not
|
|
shorten the zone and do not extend the zone.
|
|
2. Check the weight first. If the weight is not greater than zero, return the status
|
|
WEIGHT with BASE, SURCHARGE and TOTAL equal to zero. This check comes before the
|
|
zone check.
|
|
3. If the normalized zone is not known, return the status ZONE with BASE, SURCHARGE
|
|
and TOTAL equal to zero.
|
|
4. The rate per kilogram depends on the zone: DE 4.50, AT 5.20, CH 7.80, FR 6.40,
|
|
NL 4.90, PL 5.10, ES 6.90.
|
|
5. BASE = rate x weight. Round BASE to 2 decimal places. Round half away from zero.
|
|
6. If iv_express is abap_true, SURCHARGE = BASE x 25 / 100, rounded to 2 decimal
|
|
places. Else SURCHARGE is zero.
|
|
7. TOTAL = BASE + SURCHARGE.
|
|
8. Return the status OK.
|
|
9. IS_ZONE_SUPPORTED returns abap_true if the normalized zone is known, else
|
|
abap_false. A blank zone is not known.
|
|
|
|
# 6. Constraints
|
|
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
|
|
- Coding standards: Clean ABAP. Every method has less than 40 statements. No global
|
|
variables. No IF block nested deeper than 2 levels. No hard-coded rate in a
|
|
statement: use a constant or a table. Remove the private attribute that is never
|
|
read. Remove the commented-out code. No comment that restates the code.
|
|
- Out of scope: do not change the public API, do not change the behavior, do not
|
|
create new global objects, do not change the class name.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests as local test classes in the class.
|