Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
2.1 KiB
2.1 KiB
1. Goal
A facility management company operates a fleet of vehicles. The fleet manager needs a report that shows the distance that each vehicle drove in a period. The fleet manager uses the report to compare the vehicles.
2. Open questions
None.
3. Context
The tables {{P}}VEH and {{P}}ODOM exist in package $TMP. Both tables contain data.
Table {{P}}VEH holds the vehicles. Fields: VEH_ID (CHAR 10, key), DEPOT (CHAR 4), VEH_TYPE (CHAR 10).
Table {{P}}ODOM holds the odometer readings of the vehicles. Fields: READ_ID (INT4, key), VEH_ID (CHAR 10), READ_DATE (DATS), ODOMETER (INT4, the odometer value in kilometres).
A vehicle can have many odometer readings. An odometer reading can belong to a vehicle that is not in {{P}}VEH.
4. Contract
- Create the executable program {{P}}FLEET_DIST in package $TMP.
- Selection screen:
- Parameter P_FROM, type DATS, mandatory: the first reading date to include.
- Parameter P_TO, type DATS, mandatory: the last reading date to include.
- Select-option S_DEPOT for the depot.
- Show the result with CL_SALV_TABLE. The output table has these columns, with these names: VEH_ID, DEPOT, DISTANCE, READINGS.
5. Business rules
- Include an odometer reading only if READ_DATE is on or after P_FROM and on or before P_TO.
- Include a vehicle only if the vehicle is in {{P}}VEH and its DEPOT is in S_DEPOT.
- Include a vehicle only if at least two of its readings are included.
- DISTANCE is the highest included ODOMETER value of the vehicle minus the lowest included ODOMETER value of the vehicle.
- READINGS is the number of included readings of the vehicle.
- Show one line for each included vehicle.
- Sort the lines by DISTANCE. The highest distance comes first. If two lines have the same DISTANCE, the line with the smaller VEH_ID comes first.
6. Constraints
- Release target: 8.16.
- Coding standards: Clean ABAP.
- Out of scope: do not change {{P}}VEH and {{P}}ODOM.
7. Acceptance
- The program is active and has no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests as local test classes in the program.