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

2.7 KiB

1. Goal

A company collects used cooking oil from restaurants. The company pays the restaurants for the oil. Each collection is recorded with the restaurant, the collection date and the volume in litres. A settlement program calls the class once for each settlement run. The class returns one row for each restaurant.

2. Open questions

None.

3. Context

  • The class {{P}}OIL_SETTLEMENT does not exist. Create it in package $TMP.
  • The caller sends a list of collection records. One restaurant can appear in more than one record.
  • The class does not read the database. All data comes from the caller.

4. Contract

  • Create the class {{P}}OIL_SETTLEMENT in package $TMP.
  • The class is public and final. It has a public constructor without parameters.
  • The class has these public types:
    • ty_restaurant: character, length 10.
    • ty_collection: structure with the components restaurant (ty_restaurant), collected_on (date) and litres (integer).
    • tt_collections: table of ty_collection. The table can hold more than one row for the same restaurant.
    • ty_settlement: structure with the components restaurant (ty_restaurant), total_litres (integer), round_count (integer) and last_collection (date).
    • tt_settlements: table of ty_settlement.
  • The class has this public method: settle IMPORTING it_collections TYPE tt_collections RETURNING VALUE(rt_settlements) TYPE tt_settlements.
  • Do not add other public methods.

5. Business rules

  1. Two restaurant names are the same when they are equal after you remove all spaces and convert the letters to upper case. A restaurant is empty when it contains only spaces.
  2. A collection record is valid when its restaurant is not empty and its volume is greater than zero.
  3. Ignore every record that is not valid. An ignored record does not change a total and it does not increase a counter.
  4. The result has exactly one row for each restaurant that has at least one valid record.
  5. A result row has these values:
    • restaurant: the name of the valid records, without spaces and in upper case.
    • total_litres: the sum of the volumes of the valid records.
    • round_count: the number of the valid records.
    • last_collection: the latest collection date of the valid records.
  6. The result is sorted in ascending order of restaurant.
  7. If there is no valid record, the result is empty.

6. Constraints

  • Release target: SAP_BASIS 816 (ABAP Platform 2025).
  • Coding standards: Clean ABAP. Method length below 40 statements. No global variables. No comment that restates the code.
  • Out of scope: no database access, no ALV, no dynpro, no RAP.

7. Acceptance

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