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

2.3 KiB

1. Goal

A cold-storage warehouse stores pallets of food. The gate system calls the class {{P}}PALLET_ALLOCATOR in package $TMP for each incoming pallet. The class decides the storage aisle, the rack, and the temperature zone of the pallet.

The class is active. Its implementation is legacy code. The method ALLOCATE is long, it uses many literal values and nested IF blocks, and it is hard to maintain. Users report that the class is hard to test.

Refactor the class in place. The class name and the public interface stay the same. The behavior stays the same.

2. Open questions

None.

3. Context

  • The class {{P}}PALLET_ALLOCATOR exists in package $TMP. It is active.
  • The class is public, final, and has a public constructor without parameters.
  • The class has one public method, ALLOCATE. The legacy implementation of ALLOCATE contains the storage rules of the warehouse.
  • The gate system calls ALLOCATE for each pallet and prints the result on the pallet label. The result must not change.

4. Contract

  • The class {{P}}PALLET_ALLOCATOR stays in package $TMP. The class name does not change.
  • The class stays public and final. The public constructor stays without parameters.
  • The public types do not change:
    • TY_CATEGORY (CHAR 2)
    • TY_WEIGHT (INT)
    • TY_HEIGHT (INT)
    • TY_SLOT with the components AISLE (CHAR 2), RACK (INT), TEMP_ZONE (CHAR 2) and IS_VALID (ABAP_BOOL).
  • The public method does not change: ALLOCATE IMPORTING iv_category TYPE ty_category iv_weight_kg TYPE ty_weight iv_height_cm TYPE ty_height RETURNING VALUE(rs_slot) TYPE ty_slot.
  • Do not add other public methods or public attributes.

5. Business rules

The legacy implementation of ALLOCATE is the specification. Read the legacy code. The class must return the same result for every input. Do not change the behavior.

6. Constraints

  • Release target: SAP_BASIS 816 (ABAP Platform 2025).
  • Coding standards: Clean ABAP. Method length below 40 statements. No global variables. Use constants and small helper methods. No comment that restates the code.
  • Out of scope: do not change the public interface of the class.

7. Acceptance

  • The class is active and has no syntax error.
  • The behavior of the class is unchanged.
  • The hidden tests pass.
  • Write your own ABAP Unit tests for the class.