Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
70 lines
3.1 KiB
Markdown
70 lines
3.1 KiB
Markdown
# 1. Goal
|
|
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_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
|
|
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. 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: 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.
|