2.4 KiB
2.4 KiB
1. Goal
A brewery plans the delivery tours of its beer kegs. Two depots send their tour lists for one day. Merge the two lists into one tour list. Also find the pubs with the largest demand.
2. Open questions
None.
3. Context
- Package $TMP.
- No other object is necessary. Create all objects that you need.
4. Contract
- Create the class {{P}}KEG_TOUR_MERGER in package $TMP.
- The class is public and final. It has a public constructor without parameters.
- Public types:
- TY_ENTRY: PUB_ID (type c, length 8), KEG_TYPE (type c, length 4), KEGS (type i).
- TT_ENTRY: standard table of TY_ENTRY with empty key.
- TY_PUB: PUB_ID (type c, length 8), KEGS (type i).
- TT_PUB: standard table of TY_PUB with empty key.
- Public methods:
- MERGE_TOURS IMPORTING it_tour_a TYPE tt_entry it_tour_b TYPE tt_entry RETURNING VALUE(rt_tour) TYPE tt_entry.
- TOP_PUBS IMPORTING it_tour TYPE tt_entry iv_count TYPE i RETURNING VALUE(rt_pubs) TYPE tt_pub.
- Do not add other public methods.
5. Business rules
MERGE_TOURS
- An entry with KEGS less than 1 is not valid. Ignore all not valid entries of both lists.
- Convert PUB_ID and KEG_TYPE of a valid entry to upper case.
- Two valid entries with the same PUB_ID and the same KEG_TYPE are one delivery. Add their KEGS.
- Return one row for each combination of PUB_ID and KEG_TYPE. The row contains the PUB_ID, the KEG_TYPE and the total KEGS.
- Sort the result by PUB_ID ascending and then by KEG_TYPE ascending.
- If no valid entry exists, return an empty table.
TOP_PUBS 7. An entry with KEGS less than 1 is not valid. Ignore all not valid entries. 8. Convert PUB_ID of a valid entry to upper case. 9. Add the KEGS of all valid entries with the same PUB_ID. 10. Return one row for each PUB_ID with the total KEGS. 11. Sort the result by KEGS descending and then by PUB_ID ascending. 12. Return only the first IV_COUNT rows. If IV_COUNT is less than 1, return an empty table.
6. Constraints
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
- Coding standards: Clean ABAP. Method length below 40 statements. No global variables. No comment that restates the code.
- Out of scope: no database table, no CDS view, no report, no function module.
7. Acceptance
- The class is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.