Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
101 lines
3.8 KiB
Markdown
101 lines
3.8 KiB
Markdown
# 1. Goal
|
|
|
|
A rostering system assigns pilots to flight duties. Before the system confirms an
|
|
assignment, it calls one check. The check rejects the assignment with a reason if
|
|
the pilot may not fly the duty. The system needs one exception for each reason.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
|
|
- All objects are in package $TMP.
|
|
- The check uses only the data that the caller passes. It does not read a database.
|
|
- The caller fills the structure TY_DUTY and calls the method CHECK.
|
|
|
|
# 4. Contract
|
|
|
|
## 4.1 Class {{P}}CREW_DUTY_CHECK
|
|
|
|
- Package $TMP. The class is public, final and create public.
|
|
- The class can be created without parameters.
|
|
- Public type TY_HOURS: packed number, length 4, 1 decimal place.
|
|
- Public type TY_DUTY, a structure with these components:
|
|
|
|
| Component | Type |
|
|
| --- | --- |
|
|
| CREW_ID | c LENGTH 10 |
|
|
| LICENCE_VALID | abap_bool |
|
|
| TYPE_RATING | c LENGTH 4 |
|
|
| AIRCRAFT_TYPE | c LENGTH 4 |
|
|
| REST_HOURS | ty_hours |
|
|
| DUTY_HOURS | ty_hours |
|
|
| MONTH_HOURS | ty_hours |
|
|
|
|
- Public method CHECK:
|
|
- IMPORTING is_duty TYPE ty_duty
|
|
- RAISING {{P}}CX_LICENCE_INVALID, {{P}}CX_RATING_MISSING,
|
|
{{P}}CX_REST_TOO_SHORT, {{P}}CX_DUTY_TOO_LONG, {{P}}CX_MONTH_LIMIT
|
|
- The method has no return value.
|
|
|
|
## 4.2 Exception classes
|
|
|
|
Create these five classes in package $TMP. Each class is public, final, create public
|
|
and inherits from CX_STATIC_CHECK.
|
|
|
|
{{P}}CX_LICENCE_INVALID
|
|
- No own components.
|
|
|
|
{{P}}CX_RATING_MISSING
|
|
- Public type TY_RATING: character, length 4.
|
|
- Public read-only attributes MV_REQUIRED and MV_HELD, type TY_RATING.
|
|
- Public constructor with importing parameters IV_REQUIRED and IV_HELD, type TY_RATING.
|
|
The constructor copies IV_REQUIRED to MV_REQUIRED and IV_HELD to MV_HELD.
|
|
|
|
{{P}}CX_REST_TOO_SHORT
|
|
- Public type TY_HOURS: packed number, length 4, 1 decimal place.
|
|
- Public read-only attribute MV_REST_HOURS, type TY_HOURS.
|
|
- Public constructor with importing parameter IV_REST_HOURS, type TY_HOURS.
|
|
The constructor copies IV_REST_HOURS to MV_REST_HOURS.
|
|
|
|
{{P}}CX_DUTY_TOO_LONG
|
|
- Public type TY_HOURS: packed number, length 4, 1 decimal place.
|
|
- Public read-only attribute MV_DUTY_HOURS, type TY_HOURS.
|
|
- Public constructor with importing parameter IV_DUTY_HOURS, type TY_HOURS.
|
|
The constructor copies IV_DUTY_HOURS to MV_DUTY_HOURS.
|
|
|
|
{{P}}CX_MONTH_LIMIT
|
|
- Public type TY_HOURS: packed number, length 4, 1 decimal place.
|
|
- Public read-only attribute MV_TOTAL_HOURS, type TY_HOURS.
|
|
- Public constructor with importing parameter IV_TOTAL_HOURS, type TY_HOURS.
|
|
The constructor copies IV_TOTAL_HOURS to MV_TOTAL_HOURS.
|
|
|
|
# 5. Business rules
|
|
|
|
The method CHECK applies these rules in this sequence. It raises the exception of the
|
|
first rule that fails and stops. If no rule fails, the method returns to the caller.
|
|
|
|
1. Licence. If is_duty-licence_valid is not abap_true, raise {{P}}CX_LICENCE_INVALID.
|
|
2. Type rating. If is_duty-type_rating is not equal to is_duty-aircraft_type, raise
|
|
{{P}}CX_RATING_MISSING. Pass is_duty-aircraft_type as IV_REQUIRED and
|
|
is_duty-type_rating as IV_HELD.
|
|
3. Rest. If is_duty-rest_hours is less than 10.0, raise {{P}}CX_REST_TOO_SHORT.
|
|
Pass is_duty-rest_hours as IV_REST_HOURS.
|
|
4. Duty period. If is_duty-duty_hours is greater than 13.0, raise
|
|
{{P}}CX_DUTY_TOO_LONG. Pass is_duty-duty_hours as IV_DUTY_HOURS.
|
|
5. Monthly hours. Add is_duty-month_hours and is_duty-duty_hours. If the sum is
|
|
greater than 100.0, raise {{P}}CX_MONTH_LIMIT. Pass the sum as IV_TOTAL_HOURS.
|
|
|
|
# 6. Constraints
|
|
|
|
- Release target: SAP_BASIS 8.16.
|
|
- Coding standards: Clean ABAP. Methods below 40 statements. No global variables.
|
|
No comment that restates the code.
|
|
- Out of scope: database tables, message classes, reports, function modules, dynpros.
|
|
|
|
# 7. Acceptance
|
|
|
|
- The six classes are active and have no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class {{P}}CREW_DUTY_CHECK.
|