1.7 KiB
1.7 KiB
1. Goal
A ferry operator wants to know the load of each of its routes. A report and an OData service will read the load. The calculation must run in the database, in a CDS view.
2. Open questions
None.
3. Context
- Table {{P}}SAIL (ferry sailing), package $TMP. Key: SAIL_ID (CHAR 10). Fields: ROUTE_ID (CHAR 10), SAIL_DATE (DATS).
- Table {{P}}VEH (vehicle on board), package $TMP. Key: SAIL_ID (CHAR 10) and VEH_NO (INT4). Fields: VEH_TYPE (CHAR 4), WEIGHT_KG (INT4), FEE (DEC 15,2, the fee that the vehicle pays for the crossing).
- A route has one or more sailings. A sailing has zero or more vehicles.
4. Contract
- Create the CDS view entity {{P}}I_ROUTE_LOAD in package $TMP.
- Elements, with these names: ROUTE_ID (key), VEH_COUNT, TOTAL_WEIGHT, TOTAL_FEE.
- No authorization check (#NOT_REQUIRED).
5. Business rules
- Show one row for each route that has at least one vehicle on one of its sailings. Do not show a route without vehicles.
- VEH_COUNT is the number of vehicles on all sailings of the route. A sailing without vehicles does not add to VEH_COUNT.
- TOTAL_WEIGHT is the sum of WEIGHT_KG of these vehicles, in kilograms.
- TOTAL_FEE is the sum of FEE of these vehicles, with 2 decimals.
- Show only the routes whose total weight is more than 10,000 kg. A route whose total weight is 10,000 kg or less must not appear. A route whose total weight is 10,001 kg must appear.
6. Constraints
- Release target: 8.16 (ABAP Platform 2025).
- Coding standards: Clean ABAP. Keep methods below 40 statements.
- Out of scope: do not change {{P}}SAIL and {{P}}VEH.
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.