2.6 KiB
2.6 KiB
1. Goal
A wholesaler buys materials from two suppliers. Each supplier sends a price list. The purchasing team needs one merged list. The list shows, for each material, the lowest price and the supplier that offers this price.
2. Open questions
None.
3. Context
- The class is new. It is in package $TMP.
- The class does not read a database table. The caller passes the two price lists.
4. Contract
- Create the class {{P}}QUOTE_MERGER in package $TMP.
- The class is public, final, and has a public constructor without parameters.
- Public types:
- TY_PRICE: packed number, length 11, 2 decimal places.
- TY_QUOTE: structure with the components MATERIAL (CHAR 18), SUPPLIER (CHAR 10) and PRICE (TY_PRICE).
- TT_QUOTE: standard table of TY_QUOTE with default key.
- TY_RESULT: structure with the components MATERIAL (CHAR 18), SUPPLIER (CHAR 10), PRICE (TY_PRICE) and QUOTE_COUNT (integer).
- TT_RESULT: standard table of TY_RESULT with default key.
- Public method MERGE: IMPORTING it_quotes_a TYPE tt_quote it_quotes_b TYPE tt_quote EXPORTING et_result TYPE tt_result ev_rejected TYPE i.
- Do not add other public methods.
5. Business rules
- The method reads all rows of it_quotes_a and all rows of it_quotes_b. The order of the two tables is not important.
- A row is invalid if its material contains only blanks, or if its price is zero or negative. Every invalid row increases ev_rejected by one. Invalid rows do not appear in et_result.
- All valid rows with the same material belong to one group.
- et_result has exactly one row for each group. The PRICE of this row is the lowest price of all valid rows in the group.
- The SUPPLIER of this row is the supplier of a valid row that has this lowest price. If more than one valid row has this lowest price, use the supplier that is first in ascending order of the supplier name.
- QUOTE_COUNT is the number of valid rows in the group. A row that appears two times counts two times.
- Sort et_result in ascending order of material.
- If no valid row exists, et_result is empty and ev_rejected is the number of invalid rows.
- The method does not change it_quotes_a or it_quotes_b.
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.