59 lines
2.5 KiB
Markdown
59 lines
2.5 KiB
Markdown
# 1. Goal
|
|
A regional parcel delivery company plans the tours of its vans. For each parcel
|
|
the dispatch program calls one function module. The function module finds the
|
|
delivery zone of the parcel, assigns the parcel to a tour, and calculates the
|
|
transport fee. The dispatch program adds the fee to the invoice of the parcel,
|
|
except when the skip flag is true.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- Function group {{P}}FG_PARCEL exists in package $TMP.
|
|
- Function module {{P}}ZONE_LOOKUP exists in this group. It returns the
|
|
delivery zone of a postcode. Read its interface and its source before you use
|
|
it. The zone of a postcode is the value that {{P}}ZONE_LOOKUP returns for that
|
|
postcode.
|
|
- The dispatch program calls {{P}}PARCEL_FEE for each parcel. It adds ev_fee to
|
|
the invoice of the parcel. If ev_skip is true, it does not add the fee.
|
|
|
|
# 4. Contract
|
|
- Create the function module {{P}}PARCEL_FEE in function group {{P}}FG_PARCEL.
|
|
- Importing parameters:
|
|
- iv_postcode TYPE string
|
|
- iv_weight TYPE decfloat34 (the weight of the parcel in kilograms)
|
|
- iv_express TYPE abap_bool
|
|
- Exporting parameters:
|
|
- ev_tour TYPE string
|
|
- ev_skip TYPE abap_bool
|
|
- ev_fee TYPE decfloat34
|
|
- Exceptions: UNKNOWN_ZONE, INVALID_WEIGHT.
|
|
|
|
# 5. Business rules
|
|
1. If iv_weight is less than or equal to 0, raise the exception INVALID_WEIGHT.
|
|
2. Find the zone of iv_postcode with {{P}}ZONE_LOOKUP. If the zone is empty,
|
|
raise the exception UNKNOWN_ZONE.
|
|
3. Set the skip flag to false.
|
|
4. Set the tour to the zone. If iv_weight is more than 10, append the character
|
|
H to the tour.
|
|
5. The base fee of a zone is: N 4.90, W 5.50, C 6.20, E 7.10, S 8.40.
|
|
6. The weight surcharge is 0.35 for each started kilogram above the first
|
|
kilogram. A started kilogram is a kilogram that is not fully reached.
|
|
Examples: 1.00 kg gives 0.00, 1.01 kg gives 0.35, 3.00 kg gives 0.70,
|
|
3.01 kg gives 1.05.
|
|
7. The fee is the base fee of the zone plus the weight surcharge.
|
|
8. If iv_express is true, add 3.50 to the fee.
|
|
9. The fee of one parcel is never more than 25.00.
|
|
10. A parcel of zone S is collected only as an express parcel. If the zone is S
|
|
and iv_express is false, set the skip flag to true and set the fee to 0.00.
|
|
|
|
# 6. Constraints
|
|
- Release target: 8.16.
|
|
- Coding standards: Clean ABAP.
|
|
- Out of scope: do not change {{P}}ZONE_LOOKUP.
|
|
|
|
# 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.
|