1.7 KiB
1.7 KiB
1. Goal
Show the air quality of each measuring station. A dashboard and an OData service will read the values, so the calculation must be in the database, in a CDS view.
2. Open questions
None.
3. Context
- Table {{P}}STATION (measuring station), package $TMP. Key: STATION_ID (CHAR 10). Fields: STATION_NAME (CHAR 20), LIMIT_PM (DEC 5,1, the permitted fine dust value of the station).
- Table {{P}}READING (single fine dust reading), package $TMP. Key: STATION_ID (CHAR 10), READING_NO (INT4). Fields: PM_VALUE (DEC 5,1, the measured fine dust value).
4. Contract
- Create the CDS view entity {{P}}I_AIR_QUALITY in package $TMP.
- Elements, with these names: STATION_ID (key), STATION_NAME, READING_COUNT, AVG_PM, MAX_PM, RATING, DEVIATION.
- No authorization check (#NOT_REQUIRED).
5. Business rules
- Show one row for each station that has at least one reading. Do not show a station without readings.
- STATION_NAME is the name of the station.
- READING_COUNT is the number of readings of the station.
- AVG_PM is the average PM_VALUE of the readings of the station, with 1 decimal place.
- MAX_PM is the highest PM_VALUE of the station.
- RATING is the class of the station:
- 'HIGH' if MAX_PM is greater than LIMIT_PM,
- 'MEDIUM' if MAX_PM is greater than 80 percent of LIMIT_PM,
- 'LOW' in all other cases.
- DEVIATION is the distance between MAX_PM and LIMIT_PM, as a positive number.
6. Constraints
- Release target: 8.16.
- Coding standards: Clean ABAP. No ATC priority 1 or priority 2 findings.
- Out of scope: do not change {{P}}STATION and {{P}}READING.
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.