Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
52 lines
2.1 KiB
Markdown
52 lines
2.1 KiB
Markdown
# 1. Goal
|
|
A scrapyard buys scrap metal from customers. A weighing program calls one
|
|
calculation to get the payout for a delivery. The payout has an amount and a
|
|
reason code.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The interface {{P}}IF_SCRAP_PAYOUT exists in package $TMP. It is active.
|
|
- The interface defines one method, the material codes, the reason codes, and the
|
|
structure of the result.
|
|
- Read the interface {{P}}IF_SCRAP_PAYOUT in package $TMP. This specification does
|
|
not repeat the signature of the interface.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}SCRAP_PAYOUT in package $TMP.
|
|
- The class is public and final.
|
|
- The class implements the interface {{P}}IF_SCRAP_PAYOUT.
|
|
- The class has a public constructor without parameters.
|
|
- Do not add other public methods.
|
|
|
|
# 5. Business rules
|
|
Apply the rules in this sequence. Stop at the first rule that fails.
|
|
|
|
1. Convert the material code to upper case. The result must be one of the material
|
|
codes in the constant structure {{P}}IF_SCRAP_PAYOUT=>C_MATERIAL. If not, return
|
|
the reason MATERIAL and the amount 0.
|
|
2. The weight in kilograms must be greater than 0. If not, return the reason WEIGHT
|
|
and the amount 0.
|
|
3. The contamination in percent must be between 0 and 100. If not, return the reason
|
|
DIRTY and the amount 0.
|
|
4. The base price per kilogram is 4.20 for copper, 1.10 for aluminium, 0.30 for
|
|
steel, and 3.00 for brass.
|
|
5. The payable weight is the weight multiplied by the difference between 100 and the
|
|
contamination, divided by 100.
|
|
6. The amount is the payable weight multiplied by the base price of the material.
|
|
Round the amount to 2 decimal places.
|
|
7. Return the reason OK and the amount.
|
|
|
|
# 6. Constraints
|
|
- Release target: SAP_BASIS 816.
|
|
- Coding standards: Clean ABAP. Keep every method below 40 statements. Do not use
|
|
global variables. Pass large parameters by reference. Do not write comments that
|
|
restate the code.
|
|
- Out of scope: do not change the interface {{P}}IF_SCRAP_PAYOUT.
|
|
|
|
# 7. Acceptance
|
|
- The class {{P}}SCRAP_PAYOUT is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|