Files

1.5 KiB

1. Goal

Show how much each bike of a bike-sharing fleet is used. The operations team needs the heavily used bikes, so that it can plan maintenance. A report and an OData service will read the usage figures. Therefore the calculation must run in the database, in a CDS view.

2. Open questions

None.

3. Context

  • Table {{P}}BIKE holds the bikes, package $TMP. Key: BIKE_ID (CHAR 10). Fields: STATION (CHAR 10), BIKE_TYPE (CHAR 4).
  • Table {{P}}RIDE holds the rides, package $TMP. Key: RIDE_ID (CHAR 10). Fields: BIKE_ID (CHAR 10), RIDE_DATE (DATS), DISTANCE_KM (DEC 5,1, the distance of the ride in kilometres).

4. Contract

  • Create the CDS view entity {{P}}I_BIKE_USE in package $TMP.
  • The view has these elements, with these names: BIKE_ID (key), STATION, RIDE_COUNT, TOTAL_DISTANCE.
  • Use no authorization check (#NOT_REQUIRED).

5. Business rules

  1. The view shows one row for each bike that has at least one ride. A bike without rides is not shown.
  2. RIDE_COUNT is the number of rides of the bike.
  3. TOTAL_DISTANCE is the sum of DISTANCE_KM of all rides of the bike.
  4. The view shows only the bikes whose total distance is more than 50.0 kilometres. A bike with a total distance of exactly 50.0 kilometres is not shown.

6. Constraints

  • Release target: 7.58.
  • Coding standards: Clean ABAP.
  • Out of scope: do not change {{P}}BIKE and {{P}}RIDE.

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.