ADT fallback: Accept headers for FUNC; G0189 accepted; regen2 results

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
Kral
2026-10-03 16:31:03 +02:00
parent 428b3565b2
commit 7510131a7d
335 changed files with 12047 additions and 5545 deletions

View File

@@ -1,85 +1,62 @@
# 1. Goal
Calculate the internal price of a print job for the print shop of a company. A
billing program calls the calculation before it charges the cost centre of a
department. Invalid job data must raise a class-based exception.
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
- Package $TMP. No other object exists for this topic.
- The billing program catches the exceptions and shows the reason to the user.
The names of the classes and their public components are fixed.
- 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 three classes in package $TMP.
## {{P}}CX_PRINT_JOB_ERROR
- Public, final, inherits from CX_ROOT.
- Public type TY_REASON, character 10.
- Public constant structure C_REASON with the components PAGES, COPIES, PAPER,
COLOR and DEPT. The values are 'PAGES', 'COPIES', 'PAPER', 'COLOR' and
'DEPT'.
- Public attribute MV_REASON of type TY_REASON.
- Public constructor with the importing parameter IV_REASON of type TY_REASON.
The constructor writes IV_REASON to MV_REASON.
## {{P}}CX_PRINT_LIMIT
- Public, final, inherits from CX_ROOT.
- Public attribute MV_PAGES of type I.
- Public constructor with the importing parameter IV_PAGES of type I. The
constructor writes IV_PAGES to MV_PAGES.
## {{P}}PRINT_JOB_PRICER
- Public, final, public constructor without parameters.
- Public types: TY_PAPER (character 4), TY_COLOR (character 1), TY_DEPT
(character 4), TY_PRICE (packed number, length 8, 2 decimals).
- Public method CALCULATE_PRICE with these parameters:
- IMPORTING IV_PAGES TYPE I
- IMPORTING IV_COPIES TYPE I
- IMPORTING IV_PAPER TYPE TY_PAPER
- IMPORTING IV_COLOR TYPE TY_COLOR
- IMPORTING IV_DEPT TYPE TY_DEPT
- RETURNING VALUE(RV_PRICE) TYPE TY_PRICE
- RAISING {{P}}CX_PRINT_JOB_ERROR and {{P}}CX_PRINT_LIMIT
- 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.
1. Check the input in this order. Raise the exception of the first rule that
fails.
1. IV_PAGES is smaller than 1: raise {{P}}CX_PRINT_JOB_ERROR with the
reason PAGES.
2. IV_COPIES is smaller than 1: raise {{P}}CX_PRINT_JOB_ERROR with the
reason COPIES.
3. IV_PAPER is not 'A4', 'A3' or 'A5': raise {{P}}CX_PRINT_JOB_ERROR with
the reason PAPER.
4. IV_COLOR is not 'C' or 'M': raise {{P}}CX_PRINT_JOB_ERROR with the
reason COLOR.
5. IV_DEPT is not 'SALE', 'HR', 'IT' or 'PROD': raise
{{P}}CX_PRINT_JOB_ERROR with the reason DEPT.
2. The total number of pages is IV_PAGES multiplied by IV_COPIES.
3. If the total number of pages is greater than 5000, raise
{{P}}CX_PRINT_LIMIT with MV_PAGES equal to the total number of pages.
4. The price of one page is 0.03 for A5, 0.05 for A4 and 0.09 for A3. For the
color mode 'C', multiply the price of one page by 4.
5. The gross price is the total number of pages multiplied by the price of one
page.
6. Volume discount on the gross price: 10 per cent if the total number of
pages is 1000 or more, 5 per cent if the total number of pages is 500 or
more, otherwise no discount.
7. The net price is the gross price minus the discount.
8. If the net price is smaller than 1.00, the price is 1.00 (minimum charge).
9. Return the price.
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: SAP_BASIS 8.16.
- 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: no database table, no report, no function module, no CDS view.
- Out of scope: do not change {{P}}CX_COLD_CHAIN.
# 7. Acceptance
- The three classes are active and have no syntax error.
- The class is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for {{P}}PRINT_JOB_PRICER.
- Write your own ABAP Unit tests for the class.