Files
Kral 5de5e2851c Generator: pilot analysis and fixes; G0002-G0021 tasks; handover notes merged
- Static bundle checks (name length, seed type, reserved words, contract test classes,
  testclasses_file), local abaplint parser check before SAP, max_tokens, robust JSON parse
- Runner: G2 for CDS views with parameters, contract_check detail in report
- G0020 and G0013 fixed by review and revalidated (oracle 100, null 0)
- Pilot results in docs/faz1-tasarim.md 11e; handover notes merged into CLAUDE.md and docs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 05:04:23 +02:00

2.8 KiB

1. Goal

A training provider sells seats in courses. The booking program needs one service that answers three questions:

  • How many seats are free in a course?
  • Can we book a given number of seats in a course?
  • Which courses of a category still have enough free seats?

2. Open questions

None.

3. Context

  • The database table {{P}}COURSE exists in package $TMP. It has these columns: MANDT (client), COURSE_ID (CHAR 10, key), CATEGORY (CHAR 10), TITLE (CHAR 40), CAPACITY (INT4), BOOKED (INT4).
  • CAPACITY is the number of seats of the course. BOOKED is the number of seats that are already sold.
  • The class {{P}}SEED_COURSES fills the table with example data. It is active.

4. Contract

  • Create the class {{P}}COURSE_BOOKING in package $TMP.
  • The class is public, final, and has a public constructor without parameters.
  • The class has these public types:
    • TY_COURSE_ID, type C, length 10.
    • TY_CATEGORY, type C, length 10.
    • TY_COURSE_INFO, a structure with the components COURSE_ID (type TY_COURSE_ID), TITLE (type C, length 40) and FREE_SEATS (type I).
    • TT_COURSE_INFO, a standard table of TY_COURSE_INFO with an empty key.
  • The class has these public methods:
    • GET_FREE_SEATS, importing IV_COURSE_ID type TY_COURSE_ID, returning RV_FREE_SEATS type I.
    • IS_BOOKABLE, importing IV_COURSE_ID type TY_COURSE_ID and IV_SEATS type I, returning RV_BOOKABLE type ABAP_BOOL.
    • LIST_BOOKABLE_COURSES, importing IV_CATEGORY type TY_CATEGORY and IV_SEATS type I, returning RT_COURSES type TT_COURSE_INFO.
  • Do not add other public methods.

5. Business rules

Free seats

  1. Read the course with the course ID.
  2. If the table has no course with this ID, the free seats are 0.
  3. The free seats are the capacity minus the booked seats.
  4. If the capacity minus the booked seats is less than 0, the free seats are 0.

GET_FREE_SEATS returns the free seats of the course.

IS_BOOKABLE 5. If IV_SEATS is less than 1, the result is false. 6. If the table has no course with this ID, the result is false. 7. The result is true if IV_SEATS is less than or equal to the free seats of the course. Else the result is false.

LIST_BOOKABLE_COURSES 8. Read all courses with the category IV_CATEGORY. 9. Use only the courses whose free seats are greater than or equal to IV_SEATS. 10. Sort the result in ascending order by COURSE_ID. 11. Each result row has the COURSE_ID, the TITLE and the free seats of the course. 12. If no course matches, the result is empty.

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 the table {{P}}COURSE and the class {{P}}SEED_COURSES.

7. Acceptance

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