# 1. Goal Refactor the legacy CDS view {{P}}I_WIND_GRADE in package $TMP. A wind farm operator uses the view to grade the monthly yield of each wind turbine. The view is active, but its CASE expressions are deeply nested and hard to read. Make the view clean and easy to read. The behavior stays the same. The name {{P}}I_WIND_GRADE and all element names stay the same. A report and an OData service read the view, so the interface must not change. # 2. Open questions None. # 3. Context - Table {{P}}TURBINE (wind turbine master data), package $TMP. Key: TURBINE_ID (CHAR 10). Fields: SITE (CHAR 10), CAPACITY_KW (INT4), COMMISSIONED (DATS). - Table {{P}}YIELD (monthly yield of one wind turbine), package $TMP. Key: TURBINE_ID (CHAR 10), CALMONTH (CHAR 6, format YYYYMM). Fields: ENERGY_KWH (DEC 15,2), DOWNTIME_HRS (INT4). - The view {{P}}I_WIND_GRADE already exists in package $TMP. Its DDL source is the specification of the behavior. Read the DDL source. # 4. Contract - Refactor the CDS view {{P}}I_WIND_GRADE in package $TMP. The name stays the same. - Elements, with these names: TURBINE_ID (key), CALMONTH (key), SITE, ENERGY_KWH, DOWNTIME_HRS, YIELD_GRADE, AVAILABILITY, RATING, PENALTY. - The element names and the element types stay the same. - No authorization check (#NOT_REQUIRED). # 5. Business rules The behavior stays the same. The current DDL source of {{P}}I_WIND_GRADE is the only specification of the behavior. Keep every result value, every limit value and every element. Do not add an element and do not remove an element. # 6. Constraints - Release target: 8.16. - Coding standards: use "define view entity". Write clean CDS. A CASE expression must not contain another CASE expression. - Out of scope: do not change {{P}}TURBINE and {{P}}YIELD. # 7. Acceptance - The view entity 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.