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,84 +1,73 @@
# 1. Goal
A pharmacy dispenses prescription items. Before the pharmacy dispenses a
prescription, it validates the prescription. The validation raises a class-based
exception with one reason and one message for each problem. The pharmacy program
needs the validation class and the exception class.
A ship chandler supplies provisions to vessels. The ordering program of the
chandler calls one service for each provisioning order. The service checks the
lines of the order and calculates the net value of the order. The service
reports each violation as a class-based exception with one reason code.
# 2. Open questions
None.
# 3. Context
- The class {{P}}DRUG_MASTER is in package $TMP. It is active. It is the drug
master data of the pharmacy. Do not change it.
- Public type TY_DRUG_ID: character, length 10.
- Public structure TY_DRUG with the components DRUG_ID (TY_DRUG_ID) and
MAX_DAILY_DOSE (integer, milligram).
- Public method GET_DRUG with the importing parameter IV_DRUG_ID (TY_DRUG_ID)
and the returning parameter RS_DRUG (TY_DRUG). If the drug is not in the
master data, RS_DRUG is initial.
- The drug master data contains these drugs and maximum daily doses:
PARA500 4000, IBU400 1200, AMOX500 1500, META50 200, SALB100 800.
- A prescription has an issue date, a number of valid days and items. Each item
has a drug, a quantity and a daily dose.
- The exception class {{P}}CX_PROV_ERROR exists in package $TMP. It is active.
- The class inherits from CX_STATIC_CHECK. It has the type TY_REASON (CHAR 20),
the read-only attribute REASON, and a constructor with the importing
parameter IV_REASON of type TY_REASON.
- The ordering program catches the exception and shows the reason code.
# 4. Contract
## 4.1 Exception class {{P}}CX_PRESC_ERROR
- Create the class in package $TMP.
- The class inherits from CX_ROOT.
- Public type TY_REASON: character, length 12.
- Public constant structure C_REASON with the components EMPTY, EXPIRED,
QUANTITY, UNKNOWN, DOSE and DUPLICATE. Each component has the type TY_REASON
and the value of its own name.
- Public constructor with the importing parameter IV_REASON (TY_REASON).
- Public method GET_REASON with the returning parameter RV_REASON (TY_REASON).
- Public method GET_MESSAGE_TEXT with the returning parameter RV_TEXT (string).
GET_MESSAGE_TEXT returns the message of the reason:
- EMPTY: The prescription has no items
- EXPIRED: The prescription is expired
- QUANTITY: The quantity is not positive
- UNKNOWN: The drug is not in the drug master
- DOSE: The daily dose is not allowed
- DUPLICATE: The drug appears more than once
## 4.2 Check class {{P}}PRESCRIPTION_CHECK
- Create the class in package $TMP.
- Create the class {{P}}PROVISION_CALC in package $TMP.
- The class is public and final. It has a public constructor without parameters.
- Public type TY_DRUG_ID: character, length 10.
- Public structure TY_ITEM with the components DRUG_ID (TY_DRUG_ID), QUANTITY
(integer) and DAILY_DOSE (integer).
- Public table type TT_ITEM: standard table of TY_ITEM with empty key.
- Public method VALIDATE with these importing parameters:
- IV_ISSUE_DATE (type d)
- IV_VALID_DAYS (integer)
- IV_AS_OF_DATE (type d)
- IT_ITEM (TT_ITEM)
and the addition RAISING {{P}}CX_PRESC_ERROR.
- Public types of the class:
- TY_MATERIAL (CHAR 18), TY_QUANTITY (packed, length 13, 3 decimals),
TY_PRICE (packed, length 11, 2 decimals), TY_AMOUNT (packed, length 13,
2 decimals), TY_REASON (CHAR 20).
- TY_LINE with the components MATERIAL, QUANTITY and PRICE.
- TT_LINES, a standard table of TY_LINE with an empty key.
- Public constants of the class:
- C_MAX_LINES (type I) with the value 999.
- C_VALUE_LIMIT (type TY_AMOUNT) with the value 100000.00.
- C_EMPTY_ORDER, C_TOO_MANY_LINES, C_MATERIAL_MISSING, C_QUANTITY_INVALID,
C_PRICE_NEGATIVE, C_DUPLICATE_MATERIAL and C_LIMIT_EXCEEDED, all of type
TY_REASON, with the values EMPTY_ORDER, TOO_MANY_LINES, MATERIAL_MISSING,
QUANTITY_INVALID, PRICE_NEGATIVE, DUPLICATE_MATERIAL and LIMIT_EXCEEDED.
- Public methods of the class:
- CHECK_ORDER, importing IT_LINES of type TT_LINES, raising
{{P}}CX_PROV_ERROR.
- CALCULATE_VALUE, importing IT_LINES of type TT_LINES, returning RV_VALUE
of type TY_AMOUNT, raising {{P}}CX_PROV_ERROR.
- Do not add other public methods.
# 5. Business rules
VALIDATE applies the rules in this sequence. It raises {{P}}CX_PRESC_ERROR with
the reason of the first rule that fails.
1. If IT_ITEM is empty, the reason is EMPTY.
2. If IV_AS_OF_DATE is later than IV_ISSUE_DATE plus IV_VALID_DAYS days, the
reason is EXPIRED.
3. Process the items in the sequence of the table. For each item:
3.1 If QUANTITY is less than 1, the reason is QUANTITY.
3.2 If DRUG_ID is not in the drug master data, the reason is UNKNOWN.
3.3 If DAILY_DOSE is less than 1, or if DAILY_DOSE is greater than the
maximum daily dose of the drug, the reason is DOSE.
4. If one DRUG_ID occurs in more than one item, the reason is DUPLICATE.
5. Else VALIDATE returns without an exception.
The dates are always valid dates.
The value of a line is the quantity multiplied by the price. The net value of
the order is the sum of the exact line values. Round only the net value, and
only once, to 2 decimals. Half values round away from zero.
CHECK_ORDER applies these rules in this sequence. It raises {{P}}CX_PROV_ERROR
with the reason of the first rule that fails.
1. If the order has no line, the reason is C_EMPTY_ORDER.
2. If the order has more than C_MAX_LINES lines, the reason is
C_TOO_MANY_LINES.
3. Check the lines in the given order. For each line apply these rules in this
sequence:
a. If the material is empty or contains only spaces, the reason is
C_MATERIAL_MISSING.
b. If the quantity is not greater than zero, the reason is
C_QUANTITY_INVALID.
c. If the price is less than zero, the reason is C_PRICE_NEGATIVE.
d. If the material occurs in an earlier line, the reason is
C_DUPLICATE_MATERIAL.
4. If the net value of the order is greater than C_VALUE_LIMIT, the reason is
C_LIMIT_EXCEEDED.
CALCULATE_VALUE applies the same checks and returns the net value.
# 6. Constraints
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
- Package: $TMP. Do not use a transport request.
- Coding standards: Clean ABAP. Methods below 40 statements. No global
variables. Pass large parameters by reference. No comment that restates the
code.
- Out of scope: do not change {{P}}DRUG_MASTER.
- Release target: SAP_BASIS 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_PROV_ERROR.
# 7. Acceptance
- Both 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}}PRESCRIPTION_CHECK.
- Write your own ABAP Unit tests for the class.