Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
70 lines
2.9 KiB
Markdown
70 lines
2.9 KiB
Markdown
# 1. Goal
|
|
A blood donation centre checks a person before it takes a blood donation. The
|
|
check is one function module. The function module rejects a person who may not
|
|
donate. A rejection is a class-based exception. The exception tells the caller
|
|
the reason for the rejection and the waiting time.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- Function group {{P}}FG_DONOR exists in package $TMP.
|
|
- The centre uses class-based exceptions for rejected checks. The exception
|
|
class for this check does not exist yet.
|
|
|
|
# 4. Contract
|
|
Exception class {{P}}CX_DONOR_CHECK in package $TMP:
|
|
- The class is public and final. It inherits from CX_STATIC_CHECK. Its creation
|
|
type is CREATE PUBLIC.
|
|
- The class has these public attributes:
|
|
- MV_REASON, type string: the reason for the rejection.
|
|
- MV_RETRY_DAYS, type i: the number of days after which the person may try
|
|
again.
|
|
- The constructor has the importing parameters IV_REASON (type string) and
|
|
IV_RETRY_DAYS (type i, default 0).
|
|
|
|
Function module {{P}}DONOR_CHECK in function group {{P}}FG_DONOR:
|
|
- Importing parameters:
|
|
- IV_AGE, type i: the age of the person in years.
|
|
- IV_WEIGHT, type decfloat34: the weight of the person in kilograms.
|
|
- IV_HB, type decfloat34: the haemoglobin value of the person in grams per
|
|
decilitre.
|
|
- IV_DAYS_SINCE_LAST, type i: the number of days since the last whole-blood
|
|
donation. The value is 99999 if the person never donated blood.
|
|
- The function module raises the exception {{P}}CX_DONOR_CHECK.
|
|
- The function module has no exporting and no changing parameters.
|
|
|
|
# 5. Business rules
|
|
The function module checks the rules below in the given order. The first rule
|
|
that matches raises the exception. The function module does not check the other
|
|
rules after a match.
|
|
|
|
1. If IV_AGE, IV_WEIGHT, IV_HB, or IV_DAYS_SINCE_LAST is less than 0, raise the
|
|
exception with reason INVALID_INPUT and 0 retry days.
|
|
2. If IV_AGE is less than 18, raise the exception with reason TOO_YOUNG and 0
|
|
retry days.
|
|
3. If IV_AGE is greater than 65, raise the exception with reason TOO_OLD and 0
|
|
retry days.
|
|
4. If IV_WEIGHT is less than 50, raise the exception with reason UNDERWEIGHT
|
|
and 0 retry days.
|
|
5. If IV_HB is less than 12.5, raise the exception with reason LOW_HB and 0
|
|
retry days.
|
|
6. If IV_DAYS_SINCE_LAST is less than 56, raise the exception with reason
|
|
TOO_SOON. The retry days are 56 minus IV_DAYS_SINCE_LAST.
|
|
7. If no rule matches, the person may donate. The function module does not
|
|
raise an exception.
|
|
|
|
The reason is the value of the attribute MV_REASON of the exception. The retry
|
|
days are the value of the attribute MV_RETRY_DAYS of the exception.
|
|
|
|
# 6. Constraints
|
|
- Release target: 8.16 (SAP_BASIS 816).
|
|
- Use Clean ABAP. Keep every method below 40 statements.
|
|
- Out of scope: no other objects.
|
|
|
|
# 7. Acceptance
|
|
- The exception class and the function module are active and have no syntax
|
|
error.
|
|
- The hidden tests pass.
|
|
- Write ABAP Unit tests for the function module in a global test class.
|