56 lines
2.2 KiB
Markdown
56 lines
2.2 KiB
Markdown
# 1. Goal
|
|
An ice cream parlour sells ice cream by the scoop. The checkout program calls
|
|
one function module for each order. The function module calculates the price of
|
|
the order.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- Function group {{P}}FG_ICE is in package $TMP.
|
|
- Function module {{P}}ICE_SAMPLE is in this group. It is a sample module. Its
|
|
interface is the interface that all modules of this group use.
|
|
|
|
# 4. Contract
|
|
- Create the function module {{P}}ICE_FEE in function group {{P}}FG_ICE.
|
|
- Use exactly the interface of {{P}}ICE_SAMPLE:
|
|
- iv_flavour, importing, type string. The flavour code.
|
|
- iv_scoops, importing, type i. The number of scoops.
|
|
- iv_topping, importing, type string. The topping code.
|
|
- iv_here, importing, type abap_bool. True if the customer eats the ice cream
|
|
in the parlour.
|
|
- ev_price, exporting, type decfloat34. The price of the order.
|
|
- Exceptions: invalid_scoops, unknown_flavour, unknown_topping.
|
|
|
|
# 5. Business rules
|
|
1. The number of scoops must be between 1 and 5. If it is not, raise the
|
|
exception INVALID_SCOOPS.
|
|
2. The flavour code gives the price of one scoop:
|
|
- VA: 1.20
|
|
- CH: 1.50
|
|
- ST: 1.40
|
|
Any other flavour code raises the exception UNKNOWN_FLAVOUR.
|
|
3. The topping code gives the price of the topping:
|
|
- NON or empty: 0.00
|
|
- NUT: 0.60
|
|
- SPR: 0.40
|
|
Any other topping code raises the exception UNKNOWN_TOPPING.
|
|
4. The base price is the number of scoops multiplied by the price of one scoop,
|
|
plus the price of the topping.
|
|
5. If iv_here is true, add a service charge of 5 percent of the base price. If
|
|
iv_here is false, there is no service charge.
|
|
6. Round the final price half up to 2 decimals. Return the result in ev_price.
|
|
|
|
# 6. Constraints
|
|
- Release target: 7.40 SP05. Use only ABAP syntax that exists in 7.40 SP05. Do
|
|
not use syntax that was introduced later. For example, do not use common
|
|
table expressions (WITH), UNION, INTERSECT or EXCEPT in Open SQL, IS INSTANCE
|
|
OF, or CASE TYPE OF.
|
|
- Coding standard: Clean ABAP.
|
|
- Out of scope: do not change {{P}}ICE_SAMPLE.
|
|
|
|
# 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.
|