2.0 KiB
2.0 KiB
1. Goal
The CDS view entity {{P}}I_PO_VALUE shows the value of each purchase order of an electronics company. The view gives a wrong result. When two purchase orders have the same order number in two different fiscal years, the view shows a total that is too high and an item count that is too high for both orders. Fix the view. Each row must use only the items of its own purchase order.
2. Open questions
None.
3. Context
- The CDS view entity {{P}}I_PO_VALUE is in package $TMP. It is active. It reads the tables {{P}}PO_HEAD and {{P}}PO_ITEM.
- Table {{P}}PO_HEAD (purchase order header), package $TMP. Key: PO_NO (CHAR 10), FISCAL_YEAR (CHAR 4). Fields: SUPPLIER (CHAR 10), PO_DATE (DATS).
- Table {{P}}PO_ITEM (purchase order item), package $TMP. Key: PO_NO (CHAR 10), FISCAL_YEAR (CHAR 4), ITEM_NO (INT4). Fields: QUANTITY (INT4), PRICE (DEC 15,2, the price for one unit).
- An order number is unique only inside one fiscal year. Two purchase orders can have the same PO_NO in two different fiscal years.
- Read the current source of the view before you change it.
4. Contract
- Fix the CDS view entity {{P}}I_PO_VALUE in package $TMP. The name of the view and the names of the elements do not change.
- Elements: PO_NO (key), FISCAL_YEAR (key), SUPPLIER, ITEM_COUNT, TOTAL_VALUE.
- The authorization check stays #NOT_REQUIRED.
5. Business rules
- A purchase order is identified by PO_NO together with FISCAL_YEAR.
- A row uses only the items of its own purchase order. Items of another purchase order with the same PO_NO must not change ITEM_COUNT and must not change TOTAL_VALUE.
- All other behavior of the view stays the same.
6. Constraints
- Release target: 8.16 (SAP_BASIS 816, ABAP Platform 2025).
- Coding standards: Clean ABAP. Keep the view simple.
- Out of scope: do not change the tables {{P}}PO_HEAD and {{P}}PO_ITEM.
7. Acceptance
- The view is active and has no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests with CL_CDS_TEST_ENVIRONMENT in a global test class.