2.6 KiB
2.6 KiB
1. Goal
A fishing cooperative auctions the catch of its boats. Each boat reports its catch as a list of entries. The auctioneer needs one consolidated list for each species. A program calls the class before it prints the auction list.
2. Open questions
None.
3. Context
- Package $TMP.
- The class is new. No other object exists for this task.
4. Contract
Create the class {{P}}FISH_AUCTION in package $TMP.
- The class is public and final.
- The class has a public constructor without parameters.
- Public types:
- TY_SPECIES: character, length 10.
- TY_BOAT_ID: character, length 10.
- TY_CATCH: structure with the components BOAT_ID (type ty_boat_id), SPECIES (type ty_species), and WEIGHT_KG (type i).
- TT_CATCH: table type of ty_catch. The table can hold more than one entry with the same boat ID and the same species.
- TY_SUMMARY: structure with the components SPECIES (type ty_species), TOTAL_WEIGHT (type i), and BOAT_COUNT (type i).
- TT_SUMMARY: table type of ty_summary.
- Public methods:
- SUMMARIZE, importing IT_CATCH type tt_catch, returning VALUE(RT_SUMMARY) type tt_summary.
- BEST_SPECIES, importing IT_CATCH type tt_catch, returning VALUE(RV_SPECIES) type ty_species.
- Do not add other public methods.
5. Business rules
SUMMARIZE:
- Do not change the input table.
- For each entry, build the species key: remove the leading and the trailing blanks from SPECIES and convert all letters to upper case.
- Ignore the entry if the species key is empty. Ignore the entry if WEIGHT_KG is zero or less.
- Group the remaining entries by the species key.
- TOTAL_WEIGHT of a group is the sum of WEIGHT_KG of all entries in the group.
- BOAT_COUNT of a group is the number of different boat IDs in the group.
- The result has one row for each group. The rows are in ascending order of the species key.
- If no entry remains, the result is empty.
BEST_SPECIES:
- Build the groups with the rules 1 to 8.
- Return the species key of the group with the highest TOTAL_WEIGHT.
- If two groups have the same highest TOTAL_WEIGHT, return the species key that is first in ascending order.
- If there is no group, return an empty value.
6. Constraints
- Release target: ABAP Platform 2025 (SAP_BASIS 816).
- Coding standards: Clean ABAP. Method length below 40 statements. No global variables. No comment that restates the code.
- Out of scope: do not create or change other objects.
7. Acceptance
- The class is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.