Snapshot: new training tasks (balanced generation), docs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 22:08:59 +02:00
parent eb13453097
commit 6984fc7917
572 changed files with 30024 additions and 0 deletions

View File

@@ -0,0 +1,119 @@
# 1. Goal
A laundry and dry-cleaning shop prices the orders of its customers. The checkout
program of the shop and the pricing class of the shop must use the same contract.
Create the interface {{P}}IF_LAUNDRY_FEE in package $TMP. The interface holds the
item codes, the service codes, the reason codes, the price table, the factor
table and the three methods.
# 2. Open questions
None.
# 3. Context
- The interface {{P}}IF_LAUNDRY_FEE does not exist. Create it in package $TMP.
- The checkout program calls the method CHECK_ITEM before it calls the method
CALCULATE_FEE.
- The pricing class that implements the interface is written by another
developer. It is not part of this task.
- The interface contains declarations only.
# 4. Contract
Create the interface {{P}}IF_LAUNDRY_FEE in package $TMP. The interface has these
components.
Types:
- TY_ITEM: character, length 7.
- TY_SERVICE: character, length 4.
- TY_REASON: character, length 10.
- TY_QUANTITY: integer.
- TY_AMOUNT: packed number, length 8, 2 decimal places.
- TY_FLAG: the type of ABAP_BOOL.
- TY_ORDER_LINE: structure with the components ITEM (TY_ITEM), SERVICE
(TY_SERVICE), QUANTITY (TY_QUANTITY) and EXPRESS (TY_FLAG).
- TT_ORDER_LINE: standard table of TY_ORDER_LINE with an empty key.
Constants:
- C_REASON: structure with the components OK, ITEM, SERVICE and QTY. Each
component has the type TY_REASON.
- C_ITEM: structure with the components SHIRT, TROUSERS, SUIT, COAT, DRESS and
CURTAIN. Each component has the type TY_ITEM.
- C_SERVICE: structure with the components WASH, DRYC, IRON and MEND. Each
component has the type TY_SERVICE.
- C_PRICE: structure with the components SHIRT, TROUSERS, SUIT, COAT, DRESS and
CURTAIN. Each component has the type TY_AMOUNT.
- C_FACTOR: structure with the components WASH, DRYC, IRON and MEND. Each
component has the integer type.
- C_MAX_QTY: type TY_QUANTITY.
- C_BULK_MIN_QTY: type TY_QUANTITY.
- C_BULK_DISCOUNT: integer.
- C_EXPRESS_SURCHARGE: integer.
- C_MIN_FEE: type TY_AMOUNT.
Methods:
- CHECK_ITEM, importing IV_ITEM (TY_ITEM), IV_SERVICE (TY_SERVICE) and
IV_QUANTITY (TY_QUANTITY), returning RV_REASON (TY_REASON).
- CALCULATE_FEE, importing IV_ITEM (TY_ITEM), IV_SERVICE (TY_SERVICE),
IV_QUANTITY (TY_QUANTITY) and IV_EXPRESS (TY_FLAG), returning RV_FEE
(TY_AMOUNT).
- CALCULATE_ORDER, importing IT_LINES (TT_ORDER_LINE), returning RV_TOTAL
(TY_AMOUNT).
Do not add other public components.
# 5. Business rules
The values of the constants:
1. C_REASON: OK = 'OK', ITEM = 'ITEM', SERVICE = 'SERVICE', QTY = 'QTY'.
2. C_ITEM: SHIRT = 'SHIRT', TROUSERS = 'TROUS', SUIT = 'SUIT', COAT = 'COAT',
DRESS = 'DRESS', CURTAIN = 'CURTAIN'.
3. C_SERVICE: WASH = 'WASH', DRYC = 'DRYC', IRON = 'IRON', MEND = 'MEND'.
4. C_PRICE is the price of one piece in euro: SHIRT = 3.50, TROUSERS = 5.00,
SUIT = 12.00, COAT = 14.50, DRESS = 8.00, CURTAIN = 9.50.
5. C_FACTOR is the service factor in percent: WASH = 100, DRYC = 180, IRON = 40,
MEND = 220.
6. C_MAX_QTY = 99, C_BULK_MIN_QTY = 10, C_BULK_DISCOUNT = 10,
C_EXPRESS_SURCHARGE = 25, C_MIN_FEE = 5.00.
The rules of CHECK_ITEM. The first failing rule wins.
7. If IV_ITEM is not one of the six codes of C_ITEM, the reason is ITEM.
8. Else if IV_SERVICE is not one of the four codes of C_SERVICE, the reason is
SERVICE.
9. Else if IV_QUANTITY is less than 1 or greater than C_MAX_QTY, the reason is
QTY.
10. Else the reason is OK.
The rules of CALCULATE_FEE.
11. If CHECK_ITEM does not return OK, the fee is 0.00 and no other rule applies.
12. The base amount is the quantity multiplied by the price of the item.
13. If the quantity is at least C_BULK_MIN_QTY, reduce the base amount by
C_BULK_DISCOUNT percent.
14. Multiply the base amount by the factor of the service and divide the result
by 100.
15. If IV_EXPRESS is ABAP_TRUE, increase the result by C_EXPRESS_SURCHARGE
percent.
16. Round the result of rule 13, of rule 14 and of rule 15 to 2 decimal places.
Round a half away from zero.
17. If the fee is below C_MIN_FEE, the fee is C_MIN_FEE.
The rules of CALCULATE_ORDER.
18. The total is the sum of the fees of all lines. A line with an invalid item,
an invalid service or an invalid quantity adds 0.00.
19. The total of an empty table is 0.00.
# 6. Constraints
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
- Coding standards: Clean ABAP. The interface contains declarations only. Do not
use obsolete syntax. Do not write a comment that restates the code.
- Out of scope: do not create the pricing class that implements the interface. Do
not create database tables, CDS views, programs or function modules.
# 7. Acceptance
- The interface {{P}}IF_LAUNDRY_FEE is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the interface in a global test class in
package $TMP.