Files
abap-llm/tasks_gen/train/G1030/spec.md

2.3 KiB

1. Goal

A waste container hire company rents skips to its customers. The depot terminal calls the class {{P}}SKIP_HIRE_CALC for each hire order. The class is legacy code. Refactor the class. The behavior must stay the same.

2. Open questions

None.

3. Context

  • The class {{P}}SKIP_HIRE_CALC exists in package $TMP. It is active.
  • The class is public and final. It has a public constructor without parameters.
  • The legacy implementation is hard to read. It has a long method, deep nesting, duplicated logic, and unnamed numbers.
  • The depot terminal calls the class. The result of a call must not change.

4. Contract

  • Refactor the class {{P}}SKIP_HIRE_CALC in package $TMP. The name of the class stays the same. The class stays public and final and keeps a public constructor without parameters.
  • Keep the public interface. Do not change a name and do not change a type:
    • TYPES ty_size TYPE c LENGTH 6.
    • TYPES ty_amount TYPE p LENGTH 8 DECIMALS 2.
    • TYPES BEGIN OF ty_container. Components: size TYPE ty_size, days TYPE i, hazardous TYPE abap_bool, permit TYPE abap_bool. END OF ty_container.
    • TYPES tt_containers TYPE STANDARD TABLE OF ty_container WITH DEFAULT KEY.
    • METHOD hire_charge IMPORTING it_containers TYPE tt_containers RETURNING VALUE(rv_charge) TYPE ty_amount.
    • METHOD container_charge IMPORTING is_container TYPE ty_container RETURNING VALUE(rv_charge) TYPE ty_amount.
    • METHOD bulk_discount IMPORTING iv_count TYPE i RETURNING VALUE(rv_percent) TYPE i.
  • Do not add other public methods.

5. Business rules

  • The behavior of the class must stay the same for every input.
  • The legacy implementation in the seed defines the behavior. Read the legacy code. The legacy code contains all the rules of the calculation.
  • Do not change the result of a call.

6. Constraints

  • Release target: SAP_BASIS 816 (ABAP Platform 2025).
  • Coding standards: Clean ABAP. Methods below 40 statements. No deep nesting. No duplicated logic. Replace each unnamed number with a named constant. Use modern ABAP syntax. No global variable. No comment that restates the code.
  • Out of scope: do not create new objects. Do not change other objects.

7. Acceptance

  • The class {{P}}SKIP_HIRE_CALC 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.