3.1 KiB
3.1 KiB
1. Goal
A watch and clock workshop repairs customer orders. Two intake points send their order lists: the front desk and a partner shop. The workshop program needs one merged list of all orders and the total repair time of each customer. The class {{P}}WATCH_ORDER_POOL does this work.
2. Open questions
None.
3. Context
- The interface {{P}}IF_WATCH_ORDER exists in package $TMP. It is active.
- The interface contains the types TY_ORDER_ID (CHAR 10), TY_CUSTOMER (CHAR 20), TY_STATUS (CHAR 1), TY_ORDER, TT_ORDERS, TY_CUSTOMER_TOTAL and TT_CUSTOMER_TOTALS. Read the interface for the exact definition.
- TY_ORDER has the components ORDER_ID, CUSTOMER, DURATION_MIN (integer) and STATUS.
- TY_CUSTOMER_TOTAL has the components CUSTOMER and TOTAL_MIN (integer).
- The interface contains the constant structure C_STATUS with the components OPEN (value 'O') and CLOSED (value 'C').
- All objects are in package $TMP.
4. Contract
- Create the class {{P}}WATCH_ORDER_POOL in package $TMP.
- The class is public and final. It has a public constructor without parameters.
- The class implements the interface {{P}}IF_WATCH_ORDER.
- Do not add other public methods.
The interface methods do these tasks:
- merge_orders: merge the two intake lists into one order list.
- open_orders: select the open orders of one order list.
- customer_totals: calculate the total repair time of each customer.
- find_order: find one order in a list by its order ID.
5. Business rules
General:
- An order ID is never empty. A customer name is never empty.
- DURATION_MIN is never negative.
merge_orders:
- Read the orders of IT_INTAKE first. Then read the orders of IT_WORKSHOP.
- If one order ID occurs more than once, keep the first occurrence and ignore all later occurrences. This rule holds inside one list and across the two lists.
- The result contains all orders. The result is sorted in ascending order of ORDER_ID.
open_orders:
- Use the orders of IT_ORDERS.
- If one order ID occurs more than once, keep the first occurrence.
- Keep only the orders with STATUS = C_STATUS-OPEN.
- The result is sorted in ascending order of ORDER_ID.
customer_totals:
- Use only the orders of IT_ORDERS with STATUS = C_STATUS-OPEN.
- If one order ID occurs more than once, count it one time only (the first occurrence).
- Sum DURATION_MIN for each customer.
- The result has one row for each customer with at least one open order.
- The result is sorted in ascending order of CUSTOMER.
find_order:
- Search IT_ORDERS for the order with ORDER_ID = IV_ORDER_ID.
- If one order ID occurs more than once, return the first occurrence.
- If no order has this order ID, return a structure with initial components: ORDER_ID initial, CUSTOMER initial, DURATION_MIN = 0, STATUS initial.
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: do not change {{P}}IF_WATCH_ORDER.
7. Acceptance
- The class is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.