Files

1.3 KiB

1. Goal

Show the energy that each charging station has delivered. A dashboard and an OData service will read the energy totals, so the calculation must be in the database, in a CDS view.

2. Open questions

None.

3. Context

  • Table {{P}}STATION (charging station), package $TMP. Key: STATION_ID (CHAR 10). Fields: CITY (CHAR 40), CAPACITY_KW (DEC 5,1).
  • Table {{P}}SESSION (charging session), package $TMP. Key: SESSION_ID (CHAR 10). Fields: STATION_ID (CHAR 10), START_DATE (DATS), START_TIME (TIMS), ENERGY_KWH (DEC 9,2), STATUS (CHAR 1). STATUS can be 'C' (completed), 'A' (aborted), or 'R' (running).

4. Contract

  • Create the CDS view entity {{P}}I_STATION_ENERGY in package $TMP.
  • Elements, with these names: STATION_ID (key), CITY, SESSION_COUNT, TOTAL_ENERGY.
  • No authorization check (#NOT_REQUIRED).

5. Business rules

  1. Show one row for each charging station.
  2. SESSION_COUNT is the number of charging sessions of the station.
  3. TOTAL_ENERGY is the sum of the energy of the charging sessions of the station, in kWh with 2 decimals.

6. Constraints

  • Release target: 8.16 (SAP_BASIS 816).
  • Coding standards: Clean ABAP.
  • Out of scope: do not change {{P}}STATION and {{P}}SESSION.

7. Acceptance

  • The view is active and has no syntax error.
  • Write ABAP Unit tests with CL_CDS_TEST_ENVIRONMENT in a global test class.