2.7 KiB
2.7 KiB
1. Goal
Create the message class and the class-based exception for the training course booking service. The booking service reports every problem with a message from the message class. The exception class carries the text of such a message.
2. Open questions
None.
3. Context
- All objects are in package $TMP.
- The booking service books participants into training courses.
- The old exception class {{P}}CX_LEGACY exists. It takes a hard-coded text and does not use a message class. The new exception class replaces it.
- All texts of the booking service come from one message class.
4. Contract
- Create the message class {{P}}MSG with the messages of section 5.
- Create the exception class {{P}}CX_BOOKING:
- It is a class-based exception and inherits from CX_STATIC_CHECK.
- The constructor has these parameters:
- iv_msgno TYPE symsgno
- iv_arg1 TYPE string, default ''
- iv_arg2 TYPE string, default ''
- The method GET_TEXT of the interface IF_MESSAGE returns the text of the message with the number iv_msgno from {{P}}MSG. The placeholder &1 is replaced by iv_arg1 and the placeholder &2 is replaced by iv_arg2.
5. Business rules
Message class {{P}}MSG:
- Message 001, error message, text "Course &1 is fully booked". The booking service uses it when a course has no free seat.
- Message 002, error message, text "Participant &1 is already booked for course &2". The booking service uses it for a double booking.
- Message 003, warning message, text "Course &1 has only &2 free seats left". The booking service uses it when a course has few free seats left.
- Message 004, information message, text "Booking for course &1 is confirmed". The booking service uses it for a successful booking.
- Message 005, warning message, text "Course &1 was cancelled on &2". The booking service uses it for a cancelled course.
Exception class {{P}}CX_BOOKING:
- The constructor stores the message number and the two placeholders.
- GET_TEXT returns the text of the message with the number iv_msgno from {{P}}MSG. The placeholder &1 is replaced by iv_arg1 and the placeholder &2 is replaced by iv_arg2.
6. Constraints
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
- Coding standards: Clean ABAP. Keep every method below 40 statements. Do not produce ATC findings of priority 1 or 2.
- Out of scope: database tables, CDS views, reports, dynpro, and the old exception class {{P}}CX_LEGACY.
7. Acceptance
- The message class {{P}}MSG is active. It contains the messages 001 to 005 with the exact texts of section 5.
- The exception class {{P}}CX_BOOKING is active and has no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests for the messages and the exception class in a global test class.