# 1. Goal A coffee roastery operates two roasting plants. Each plant sends a list of roast batches. The roastery needs one consolidated list. The list shows the totals of each green coffee lot. A planning program calls the consolidation before it plans the next roasting week. # 2. Open questions None. # 3. Context - Plant A and plant B record their roast batches independently. The same batch ID can occur in both lists. A batch ID can also occur more than one time in one list. - A batch has a batch ID, a plant, a lot ID, a roast date, and a roasted weight in kilograms. The roasted weight has two decimal places. # 4. Contract - Create the class {{P}}ROAST_MERGER in package $TMP. - The class is public and final. The class has a public constructor without parameters. - The class has these public types: - TY_BATCH_ID (character, length 10) - TY_PLANT (character, length 4) - TY_LOT_ID (character, length 8) - TY_WEIGHT (packed number, length 7, 2 decimal places) - TY_BATCH (structure): BATCH_ID, PLANT, LOT_ID, ROAST_DATE (date), ROASTED_KG (TY_WEIGHT) - TT_BATCHES: standard table of TY_BATCH with empty key - TY_LOT_TOTAL (structure): LOT_ID, BATCH_COUNT (integer), TOTAL_KG (TY_WEIGHT), LAST_DATE (date) - TT_LOT_TOTALS: standard table of TY_LOT_TOTAL with empty key - The class has this public method and no other public method: MERGE IMPORTING it_plant_a TYPE tt_batches it_plant_b TYPE tt_batches RETURNING VALUE(rt_totals) TYPE tt_lot_totals # 5. Business rules The method MERGE applies these rules in this sequence. 1. A batch is invalid if the batch ID is empty, or if the roasted weight is zero or negative. Ignore all invalid batches. 2. A batch ID identifies a batch. If the same batch ID occurs more than one time, keep the first occurrence. Replace the kept occurrence only if a later occurrence has a larger roasted weight. The order of the occurrences is: all batches of plant A first, then all batches of plant B. 3. Group the remaining batches by lot ID. 4. For each lot ID calculate: - BATCH_COUNT: the number of batches with this lot ID. - TOTAL_KG: the sum of the roasted weights of these batches. - LAST_DATE: the latest roast date of these batches. 5. The result has one row for each lot ID with at least one batch. 6. The result is sorted by LOT_ID in ascending order. 7. If both input tables are empty, the result is empty. # 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, no change of the public contract. # 7. Acceptance - The class is active and has no syntax error. - The hidden tests pass. - Write your own ABAP Unit tests for the class.