ADT fallback: Accept headers for FUNC; G0189 accepted; regen2 results
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
@@ -1,85 +1,69 @@
|
||||
# 1. Goal
|
||||
|
||||
A bike-sharing operator moves bikes between its stations. A background job
|
||||
calls one function module to apply the planned moves of the operator. The
|
||||
function module reads the planned moves and the current state of the stations
|
||||
from the database, applies the moves, and writes the new state of the stations
|
||||
back to the database. The function module returns the number of applied moves
|
||||
and the number of rejected moves.
|
||||
A rail infrastructure manager charges a track access fee to train operating
|
||||
companies. A billing program calls one function module for each operating day.
|
||||
The function module calculates the fee of each train path and groups the result
|
||||
by train category.
|
||||
|
||||
# 2. Open questions
|
||||
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
|
||||
- Function group {{P}}FG_BIKE exists in package $TMP.
|
||||
- Table {{P}}STATION exists in package $TMP. It holds the current state of the
|
||||
stations of the operator. The table is client-dependent.
|
||||
- Table {{P}}MOVE exists in package $TMP. It holds the planned moves. The table
|
||||
is client-dependent.
|
||||
- The station IDs in {{P}}STATION are unique. The move numbers in {{P}}MOVE are
|
||||
unique.
|
||||
- The function module reads and changes the two tables. It works on the data of
|
||||
the current client.
|
||||
- Function group {{P}}FG_TRACK exists in package $TMP.
|
||||
- Function module {{P}}TRACK_SAMPLE exists in this group. It shows the interface
|
||||
that the billing program uses. Do not change it.
|
||||
- The global class {{P}}TRACK_TYPES exists in package $TMP. It only holds the row
|
||||
types of the input and of the result. Do not change it. Its public types are:
|
||||
- TY_PATH: PATH_ID (type N, length 8), TRAIN_CAT (type C, length 2),
|
||||
DISTANCE_KM (packed, length 13, 2 decimals), NIGHT_FLAG (type C, length 1).
|
||||
- TT_PATH: standard table of TY_PATH.
|
||||
- TY_FEE: TRAIN_CAT (type C, length 2), PATH_COUNT (type I), TOTAL_KM (packed,
|
||||
length 13, 2 decimals), TOTAL_FEE (packed, length 13, 2 decimals).
|
||||
- TT_FEE: standard table of TY_FEE.
|
||||
- The billing program builds a standard table with the components of TY_PATH and
|
||||
reads a standard table with the components of TY_FEE. The component names are
|
||||
the interface between the billing program and the function module.
|
||||
|
||||
# 4. Contract
|
||||
|
||||
Function module {{P}}BIKE_REBALANCE in the function group {{P}}FG_BIKE:
|
||||
|
||||
IMPORTING
|
||||
iv_dry_run TYPE abap_bool
|
||||
EXPORTING
|
||||
ev_applied TYPE i
|
||||
ev_rejected TYPE i
|
||||
|
||||
Table {{P}}STATION:
|
||||
|
||||
client (key)
|
||||
station_id (key) TYPE c LENGTH 6
|
||||
station_name TYPE c LENGTH 30
|
||||
capacity TYPE i
|
||||
bikes TYPE i
|
||||
|
||||
Table {{P}}MOVE:
|
||||
|
||||
client (key)
|
||||
move_no (key) TYPE i
|
||||
source_id TYPE c LENGTH 6
|
||||
target_id TYPE c LENGTH 6
|
||||
quantity TYPE i
|
||||
Create the function module {{P}}TRACK_FEE in function group {{P}}FG_TRACK with
|
||||
this interface:
|
||||
- Importing parameter IT_PATHS, type STANDARD TABLE.
|
||||
- Exporting parameter ET_FEES, type STANDARD TABLE.
|
||||
- Exceptions INVALID_DISTANCE and INVALID_CATEGORY.
|
||||
The two table parameters are generic standard tables. Their row components are
|
||||
fixed by TY_PATH and TY_FEE of {{P}}TRACK_TYPES.
|
||||
|
||||
# 5. Business rules
|
||||
|
||||
1. Read all rows of {{P}}STATION and all rows of {{P}}MOVE.
|
||||
2. Apply the moves in ascending order of move_no. Do not apply them in the
|
||||
order of the table.
|
||||
3. A move is rejected if at least one of these conditions is true:
|
||||
- quantity is less than or equal to 0;
|
||||
- source_id and target_id are equal;
|
||||
- source_id is not the ID of a station in {{P}}STATION;
|
||||
- target_id is not the ID of a station in {{P}}STATION;
|
||||
- the source station has fewer bikes than quantity;
|
||||
- the target station has fewer free docks than quantity. The free docks of
|
||||
a station are capacity minus bikes.
|
||||
4. A rejected move does not change any station.
|
||||
5. An accepted move subtracts quantity from the bikes of the source station
|
||||
and adds quantity to the bikes of the target station.
|
||||
6. After the last move, the function module writes the new bikes value of the
|
||||
stations back to {{P}}STATION. station_name and capacity do not change.
|
||||
7. If iv_dry_run is true, the function module does not change {{P}}STATION.
|
||||
8. ev_applied is the number of accepted moves. ev_rejected is the number of
|
||||
rejected moves. Both numbers are also returned if iv_dry_run is true.
|
||||
1. A train path with DISTANCE_KM less than or equal to zero is not valid. Raise
|
||||
the exception INVALID_DISTANCE.
|
||||
2. The rate of a train category is:
|
||||
- IC: 1.20 per kilometre
|
||||
- RG: 0.90 per kilometre
|
||||
- FR: 0.60 per kilometre
|
||||
- SP: 1.50 per kilometre
|
||||
3. A train category that is not in rule 2 is not valid. Raise the exception
|
||||
INVALID_CATEGORY.
|
||||
4. The fee of one path is DISTANCE_KM multiplied by the rate of its train
|
||||
category.
|
||||
5. If NIGHT_FLAG is 'X', multiply the fee of the path by 1.20.
|
||||
6. Round the fee of the path half up to two decimals.
|
||||
7. The minimum fee of one path is 5.00. If the fee of the path is less than
|
||||
5.00, use 5.00.
|
||||
8. The result table has one row for each train category that occurs in the
|
||||
input table.
|
||||
9. PATH_COUNT is the number of paths of the category.
|
||||
10. TOTAL_KM is the sum of DISTANCE_KM of the paths of the category.
|
||||
11. TOTAL_FEE is the sum of the fees of the paths of the category.
|
||||
12. Sort the result table in ascending order of TRAIN_CAT.
|
||||
13. If the input table is empty, the result table is empty. Do not raise an
|
||||
exception.
|
||||
|
||||
# 6. Constraints
|
||||
|
||||
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
|
||||
- Package: $TMP. Do not create a transport request.
|
||||
- Clean ABAP. Keep the function module and every method below 40 statements.
|
||||
- Out of scope: do not change {{P}}STATION, {{P}}MOVE and {{P}}SEED_BIKE.
|
||||
- Release target: 8.16.
|
||||
- Coding standard: Clean ABAP. Keep methods below 40 statements. Pass large
|
||||
parameters by reference.
|
||||
- Out of scope: do not change {{P}}TRACK_SAMPLE or {{P}}TRACK_TYPES.
|
||||
|
||||
# 7. Acceptance
|
||||
|
||||
- The function module is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write ABAP Unit tests for the function module in a global test class.
|
||||
|
||||
Reference in New Issue
Block a user