Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
88 lines
3.8 KiB
Markdown
88 lines
3.8 KiB
Markdown
# 1. Goal
|
|
A catering company runs two canteens. Each canteen sends a list of ingredient
|
|
orders for the next day. The purchasing team needs one demand list for both
|
|
canteens, the number of packs to order for each ingredient, and the ingredients
|
|
that the ingredient master data does not contain.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The interface {{P}}IF_CANTEEN_PLAN exists in package $TMP. It is active.
|
|
- The interface declares these data types:
|
|
- TY_INGREDIENT: an ingredient ID, character 10.
|
|
- TY_QUANTITY: a quantity, packed number with 3 decimals.
|
|
- TY_ORDER: a structure with the components INGREDIENT (TYPE TY_INGREDIENT)
|
|
and QUANTITY (TYPE TY_QUANTITY).
|
|
- TT_ORDER: a table type with the line type TY_ORDER.
|
|
- TY_MASTER: a structure with the components INGREDIENT (TYPE TY_INGREDIENT)
|
|
and PACK_SIZE (TYPE TY_QUANTITY).
|
|
- TT_MASTER: a table type with the line type TY_MASTER.
|
|
- TY_PACK: a structure with the components INGREDIENT (TYPE TY_INGREDIENT)
|
|
and PACKS (TYPE i).
|
|
- TT_PACK: a table type with the line type TY_PACK.
|
|
- TT_INGREDIENT: a table type with the line type TY_INGREDIENT.
|
|
- The interface declares these methods:
|
|
- MERGE_ORDERS: importing IT_ORDERS_A and IT_ORDERS_B (TYPE TT_ORDER),
|
|
returning RT_DEMAND (TYPE TT_ORDER).
|
|
- PACK_REQUIREMENT: importing IT_DEMAND (TYPE TT_ORDER) and IT_CATALOGUE
|
|
(TYPE TT_MASTER), returning RT_PACKS (TYPE TT_PACK).
|
|
- MISSING_INGREDIENTS: importing IT_DEMAND (TYPE TT_ORDER) and IT_CATALOGUE
|
|
(TYPE TT_MASTER), returning RT_MISSING (TYPE TT_INGREDIENT).
|
|
- An order list is a table of TY_ORDER. A line has an ingredient ID and a
|
|
quantity.
|
|
- The ingredient master data is a table of TY_MASTER. A line has an ingredient
|
|
ID and the pack size of one pack of this ingredient.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}CANTEEN_PLANNER in package $TMP.
|
|
- The class is public and final and has a public constructor without parameters.
|
|
- The class implements {{P}}IF_CANTEEN_PLAN.
|
|
- Do not add other public methods.
|
|
|
|
# 5. Business rules
|
|
Apply the rules in this sequence.
|
|
|
|
MERGE_ORDERS
|
|
1. Read the two order lists. Ignore every line whose quantity is zero or less.
|
|
2. The result contains one line per ingredient that occurs in at least one of
|
|
the two order lists after rule 1.
|
|
3. The quantity of an ingredient in the result is the sum of all its quantities
|
|
in both order lists.
|
|
4. The result is sorted in ascending order of the ingredient ID.
|
|
5. If no line remains after rule 1, the result is empty.
|
|
|
|
PACK_REQUIREMENT
|
|
6. If an ingredient occurs more than once in the demand list, add its quantities
|
|
first.
|
|
7. The pack size of an ingredient is always greater than zero.
|
|
8. For each ingredient of the demand list, look for the ingredient in the
|
|
catalogue.
|
|
9. If the catalogue contains the ingredient, the number of packs is the demand
|
|
quantity divided by the pack size, rounded up to the next whole number.
|
|
10. The result contains one line per demand ingredient that the catalogue
|
|
contains. The line has the ingredient ID and the number of packs.
|
|
11. The result is sorted in ascending order of the ingredient ID.
|
|
12. If the demand list is empty, the result is empty.
|
|
|
|
MISSING_INGREDIENTS
|
|
13. The result contains the ingredient IDs of the demand list that the
|
|
catalogue does not contain.
|
|
14. Each ingredient ID occurs at most once in the result.
|
|
15. The result is sorted in ascending order of the ingredient ID.
|
|
16. If the catalogue contains every ingredient of the demand list, the result
|
|
is empty.
|
|
|
|
The catalogue contains each ingredient at most once.
|
|
|
|
# 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_CANTEEN_PLAN.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|