2.3 KiB
2.3 KiB
1. Goal
The CDS view entity {{P}}I_HONEY_YIELD shows the honey yield of each apiary of a beekeeping cooperative. The view is active, but its numbers are wrong. Fix the view in place. A report and an OData service read the view.
2. Open questions
None.
3. Context
- Table {{P}}APIARY (apiary header), package $TMP. Key: APIARY_ID (CHAR 10). Fields: BEEKEEPER (CHAR 10), REGION (CHAR 4), HIVE_COUNT (INT4).
- Table {{P}}HONEY (honey harvest), package $TMP. Key: APIARY_ID (CHAR 10), HARVEST_NO (INT4). Fields: REGION (CHAR 4, region of the apiary at the time of the harvest), HARVEST_DATE (DATS), KILOGRAMS (DEC 15,2).
- The view {{P}}I_HONEY_YIELD is in package $TMP and is active. The name, the package and the element names stay the same.
4. Contract
- Fix the CDS view entity {{P}}I_HONEY_YIELD in package $TMP. Do not create a new view.
- Elements, with these names: APIARY_ID (key), BEEKEEPER, REGION, HARVEST_COUNT, TOTAL_KG.
- No authorization check (#NOT_REQUIRED).
5. Business rules
The users report these symptoms:
- TOTAL_KG is too high for several apiaries. Expected: TOTAL_KG is the sum of the KILOGRAMS of the harvests of that apiary only.
- HARVEST_COUNT is too high for the same apiaries. Expected: HARVEST_COUNT is the number of harvest records of that apiary only.
- The list also shows apiaries that delivered no honey. Expected: the view shows one row for each apiary that has at least one record in {{P}}HONEY. An apiary without harvest records is not shown. All other behavior stays the same. In particular:
- BEEKEEPER is the beekeeper of the apiary, and REGION is the region of the apiary.
- An apiary with harvest records has exactly one row, also when no other apiary of its region has harvest records.
6. Constraints
- Release target: ABAP Platform 2025 (SAP_BASIS 816).
- Coding standards: Clean ABAP. The view must be active and must not have a syntax error. ATC must not report findings of priority 1 or priority 2.
- Out of scope: do not change {{P}}APIARY and {{P}}HONEY. Do not change the name of the view or the names of its elements.
7. Acceptance
- The view {{P}}I_HONEY_YIELD 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.