61 lines
2.6 KiB
Markdown
61 lines
2.6 KiB
Markdown
# 1. Goal
|
|
A seed company releases seed lots from its warehouse. Before the warehouse
|
|
releases a lot, it calls a check for that lot and for one check date. The check
|
|
raises a class-based exception with a message when the lot must not be released.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The exception classes exist in package $TMP and are active:
|
|
- {{P}}CX_SEED_LOT is the superclass of the other four classes. It inherits
|
|
from CX_STATIC_CHECK. It has the public method GET_MESSAGE that returns the
|
|
message text of the exception.
|
|
- {{P}}CX_LOT_FORMAT, {{P}}CX_LOT_DATE, {{P}}CX_LOT_GERMINATION and
|
|
{{P}}CX_LOT_MOISTURE inherit from {{P}}CX_SEED_LOT. Each of them has a
|
|
constant C_TEXT with its message text and a constructor without parameters.
|
|
- The warehouse terminal calls the check for one lot and for one check date.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}SEED_LOT_CHECKER in package $TMP.
|
|
- The class is public, final and has a public constructor without parameters.
|
|
- The class has this public type:
|
|
TYPES: BEGIN OF ty_lot,
|
|
lot_no TYPE c LENGTH 10,
|
|
germination TYPE i,
|
|
moisture TYPE p LENGTH 4 DECIMALS 1,
|
|
harvest_date TYPE d,
|
|
END OF ty_lot.
|
|
- The class has this public method:
|
|
METHODS check_lot
|
|
IMPORTING is_lot TYPE ty_lot
|
|
iv_check_date TYPE d
|
|
RAISING {{P}}CX_SEED_LOT.
|
|
- Do not add other public methods.
|
|
|
|
# 5. Business rules
|
|
Apply the rules in this sequence. Raise the exception of the first rule that
|
|
fails. If no rule fails, the method ends normally and the lot is released.
|
|
1. Lot number: positions 1 to 4 must be the letters A to Z. Positions 5 to 10
|
|
must be the digits 0 to 9. If not, raise {{P}}CX_LOT_FORMAT.
|
|
2. Harvest date: the harvest date must not be initial. The harvest date must
|
|
not be later than the check date. The harvest date must not be earlier than
|
|
the check date minus 365 days. If one of these conditions is not true, raise
|
|
{{P}}CX_LOT_DATE.
|
|
3. Germination: the germination rate must be at least 85. If not, raise
|
|
{{P}}CX_LOT_GERMINATION.
|
|
4. Moisture: the moisture must be at most 12.0. If not, raise
|
|
{{P}}CX_LOT_MOISTURE.
|
|
|
|
# 6. Constraints
|
|
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
|
|
- Coding standards: Clean ABAP. Method length below 40 statements. No global
|
|
variables. No comment that restates the code.
|
|
- Out of scope: do not change {{P}}CX_SEED_LOT, {{P}}CX_LOT_FORMAT,
|
|
{{P}}CX_LOT_DATE, {{P}}CX_LOT_GERMINATION or {{P}}CX_LOT_MOISTURE.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|