Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
63 lines
2.9 KiB
Markdown
63 lines
2.9 KiB
Markdown
# 1. Goal
|
|
Check the temperature log of a refrigerated shipment. A logistics program calls the
|
|
check before it releases the shipment. The check must give one reason code for each
|
|
log that is not correct.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The exception class {{P}}CX_COLD_CHAIN exists in package $TMP. It is active.
|
|
- The class inherits from CX_STATIC_CHECK. It has the read-only attribute MV_RULE
|
|
(type STRING), the constructor with the importing parameter IV_RULE (type STRING),
|
|
and the redefined method GET_TEXT.
|
|
- GET_TEXT returns the text Cold chain check failed: <rule code>.
|
|
- A temperature log is a table of readings. One reading has the time offset in
|
|
minutes (OFFSET_MIN) and the temperature in tenths of a degree Celsius
|
|
(TEMP_TENTHS). Example: the value -185 means -18.5 degrees Celsius.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}COLD_CHAIN_CHECK in package $TMP.
|
|
- The class is public, final, and has a public constructor.
|
|
- The class has these public types:
|
|
- TY_READING: a structure with the fields OFFSET_MIN (type I) and TEMP_TENTHS
|
|
(type I).
|
|
- TT_READINGS: a standard table of TY_READING with an empty key.
|
|
- TY_CONFIG: a structure with the fields MIN_TENTHS (type I), MAX_TENTHS
|
|
(type I), MIN_DURATION (type I), and MAX_GAP (type I).
|
|
- The constructor has the importing parameter IS_CONFIG of type TY_CONFIG.
|
|
- The class has the method CHECK with the importing parameter IT_READINGS of type
|
|
TT_READINGS, the returning parameter RV_MEAN of type I, and the addition
|
|
RAISING {{P}}CX_COLD_CHAIN.
|
|
- Do not add other public methods.
|
|
- Do not change {{P}}CX_COLD_CHAIN.
|
|
|
|
# 5. Business rules
|
|
Apply the rules in this sequence. Raise the exception {{P}}CX_COLD_CHAIN with the
|
|
rule code of the first rule that fails. Pass the rule code in the parameter IV_RULE.
|
|
The rule codes are the character strings TOO_FEW, NO_START, TIME_ORDER, TOO_SHORT,
|
|
GAP, TOO_HIGH, and TOO_LOW.
|
|
The caller always passes a configuration with MIN_TENTHS less than or equal to
|
|
MAX_TENTHS.
|
|
1. If IT_READINGS has less than 2 entries, use TOO_FEW.
|
|
2. If the offset of the first entry is not 0, use NO_START.
|
|
3. If the offsets are not strictly increasing, use TIME_ORDER.
|
|
4. If the offset of the last entry is less than MIN_DURATION, use TOO_SHORT.
|
|
5. If the difference between the offsets of two consecutive entries is greater than
|
|
MAX_GAP, use GAP.
|
|
6. Read the entries in the table order. If TEMP_TENTHS is greater than MAX_TENTHS,
|
|
use TOO_HIGH. If TEMP_TENTHS is less than MIN_TENTHS, use TOO_LOW.
|
|
7. Else return the sum of all TEMP_TENTHS divided by the number of entries. Truncate
|
|
the result toward zero.
|
|
|
|
# 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 {{P}}CX_COLD_CHAIN.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|