Files
Kral 32f03fcad4 Hard batch G0022-G0026: 5/5 accepted; budget floor, CDS checks, mutation check
- generator: budget floor (2x oracle activations, 3x calls), static checks for CDS
  $parameters and UNION annotation
- harness/mutation.py: deterministic mutants of the reference; hidden tests must fail
- G0022 revalidated with harness fixes: oracle 100, null 0
- results in docs/faz1-tasarim.md 11f

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 05:16:30 +02:00

73 lines
3.5 KiB
Markdown

# 1. Goal
Validate an employee expense claim before it is posted to accounting. The check
reports the first rule that fails as a class-based exception. Each exception
carries the value that caused the failure and a short message.
# 2. Open questions
None.
# 3. Context
- The interface {{P}}IF_EXPENSE_CLAIM exists in package $TMP and is active. It
contains types only and has no methods:
- TY_AMOUNT, a packed number with length 8 and 2 decimals.
- TY_CURRENCY, a character field with length 3.
- TY_COST_CENTER, a character field with length 10.
- TY_CLAIM, a structure with the components AMOUNT (TY_AMOUNT), CURRENCY
(TY_CURRENCY), CLAIM_DATE (type D), COST_CENTER (TY_COST_CENTER) and
HAS_RECEIPT (ABAP_BOOL).
- The class {{P}}CX_CLAIM_ERROR exists in package $TMP and is active. It is a
direct subclass of CX_STATIC_CHECK. Its constructor has the importing
parameter IV_MESSAGE (TYPE string). The method GET_MESSAGE returns this text
(TYPE string).
# 4. Contract
- Create the class {{P}}EXPENSE_VALIDATOR in package $TMP.
- The class is public and final and has a public constructor without parameters.
- The class has exactly one public method:
VALIDATE IMPORTING is_claim TYPE {{p}}if_expense_claim=>ty_claim
RAISING {{p}}cx_claim_error.
- Create these exception classes in package $TMP. Each one inherits from
{{P}}CX_CLAIM_ERROR, is final and has a public constructor.
- {{P}}CX_CLAIM_AMOUNT: constructor parameter IV_AMOUNT of type TY_AMOUNT of
{{P}}IF_EXPENSE_CLAIM. Public read-only attribute MV_AMOUNT of the same
type. Message: Amount must be positive
- {{P}}CX_CLAIM_CURRENCY: constructor parameter IV_CURRENCY of type
TY_CURRENCY. Public read-only attribute MV_CURRENCY of the same type.
Message: Currency is not supported
- {{P}}CX_CLAIM_DATE: constructor parameter IV_CLAIM_DATE of type D. Public
read-only attribute MV_CLAIM_DATE of type D. Message: Claim date is in the
future
- {{P}}CX_CLAIM_RECEIPT: constructor parameter IV_AMOUNT of type TY_AMOUNT.
Public read-only attribute MV_AMOUNT of the same type. Message: Receipt is
required
- {{P}}CX_CLAIM_COSTCENTER: constructor parameter IV_AMOUNT of type TY_AMOUNT.
Public read-only attribute MV_AMOUNT of the same type. Message: Cost center
is required
- GET_MESSAGE returns the message of the exception.
- Do not add other public methods or attributes.
# 5. Business rules
Check the claim in this sequence. Raise the exception of the first rule that
fails. If no rule fails, the method ends without an exception.
1. AMOUNT must be greater than zero. Else raise {{P}}CX_CLAIM_AMOUNT with
IV_AMOUNT = AMOUNT.
2. CURRENCY must be one of EUR, USD, GBP, CHF. Else raise
{{P}}CX_CLAIM_CURRENCY with IV_CURRENCY = CURRENCY.
3. CLAIM_DATE must not be later than the current date. Else raise
{{P}}CX_CLAIM_DATE with IV_CLAIM_DATE = CLAIM_DATE.
4. If AMOUNT is 100.00 or more, HAS_RECEIPT must be true. Else raise
{{P}}CX_CLAIM_RECEIPT with IV_AMOUNT = AMOUNT.
5. If AMOUNT is 1000.00 or more, COST_CENTER must not be initial. Else raise
{{P}}CX_CLAIM_COSTCENTER with IV_AMOUNT = AMOUNT.
# 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}}IF_EXPENSE_CLAIM and {{P}}CX_CLAIM_ERROR.
# 7. Acceptance
- All objects are active and have no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for {{P}}EXPENSE_VALIDATOR.