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

2.3 KiB

1. Goal

A fitness chain runs several studios. Each studio sends the attendance list of its classes for one day. The head office needs one summary row for each class type. The summary shows how many classes took place, how many members attended, and the total fee.

2. Open questions

None.

3. Context

  • All objects are in package $TMP.
  • The class {{P}}STUDIO_SUMMARY does not exist yet.
  • Each studio sends its own list. The caller appends the lists of all studios into one table and calls the class once.

4. Contract

  • Create the class {{P}}STUDIO_SUMMARY in package $TMP.
  • The class is public, final, and has a public constructor without parameters.
  • The class defines these public types:
    • ty_attendance: studio (CHAR 4), class_id (CHAR 8), class_type (CHAR 10), member_id (CHAR 8), fee (PACKED, length 8, 2 decimals).
    • tt_attendance: a table of ty_attendance.
    • ty_summary: class_type (CHAR 10), class_count (INT4), member_count (INT4), total_fee (PACKED, length 8, 2 decimals).
    • tt_summary: a table of ty_summary.
  • The class has this public method: summarize IMPORTING it_attendance TYPE tt_attendance RETURNING VALUE(rt_summary) TYPE tt_summary.
  • Do not add other public methods.

5. Business rules

  1. Use only entries with a class_type that is not empty and a fee greater than zero. Ignore all other entries.
  2. If two of the remaining entries have the same studio, class_id and member_id, keep only the first of these entries in the input order and ignore the later entries.
  3. Group the remaining entries by class_type.
  4. class_count is the number of different combinations of studio and class_id in the group.
  5. member_count is the number of different member_id values in the group.
  6. total_fee is the sum of the fee of all entries in the group.
  7. Return one row for each class_type that has at least one entry. Sort the rows by class_type in ascending order.

6. Constraints

  • Release target: ABAP Platform 2025 (SAP_BASIS 816).
  • 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 list, no report, no function module.

7. Acceptance

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