Files
abap-llm/tasks_gen/train/G1065/spec.md
2026-10-05 18:02:52 +02:00

2.5 KiB

1. Goal

A canal boat hire company prices the hire of a narrowboat. The booking program calls the calculation before it creates a booking confirmation. The calculation returns the hire price in euro and a reason code. A valid request returns the reason OK.

2. Open questions

None.

3. Context

  • The class {{P}}HIRE_RATES exists in package $TMP. It is active and public.
  • The class provides the daily rate of each boat category and the season factor of each month. Read the class in the system to learn its interface, the category names and the rates. Do not change the class.

4. Contract

  • Create the class {{P}}BOAT_HIRE_PRICER in package $TMP.
  • The class is public, final, and has a public constructor without parameters.
  • Public types:
    • TY_REASON, type c, length 10.
    • TY_PRICE, type p, length 10, 2 decimals.
    • TY_RESULT, a structure with the components PRICE (type TY_PRICE) and REASON (type TY_REASON).
  • Public constant structure C_REASON with the components OK, CATEGORY, DAYS, CREW and MONTH. Each component has the type TY_REASON. The values are 'OK', 'CATEGORY', 'DAYS', 'CREW' and 'MONTH'.
  • One public method: PRICE IMPORTING iv_category TYPE string iv_days TYPE i iv_crew TYPE i iv_month TYPE i RETURNING VALUE(rs_result) TYPE ty_result.
  • Do not add other public methods.

5. Business rules

Apply the rules in this sequence. The first rule that fails decides the reason. If a rule fails, the result has this reason and the price 0.

  1. The category must be a category that {{P}}HIRE_RATES knows. The category name is not case-sensitive. If not, return CATEGORY.
  2. iv_days must be between 1 and 28. If not, return DAYS.
  3. iv_crew must be between 1 and 12. If not, return CREW.
  4. iv_month must be between 1 and 12. If not, return MONTH.
  5. Calculate the base price: the daily rate of the category multiplied by iv_days multiplied by the season factor of iv_month.
  6. If iv_days is 7 or more, subtract 10 % from the base price.
  7. If iv_crew is more than 6, add 15.00 EUR for each crew member above 6 for each day of the hire.
  8. Round the result of rule 7 to 2 decimals. Return OK.

6. Constraints

  • Release target: 8.16.
  • Coding standards: Clean ABAP. Method length below 40 statements. No global variables. No comment that restates the code.
  • Out of scope: do not change {{P}}HIRE_RATES.

7. Acceptance

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