Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
62 lines
2.2 KiB
Markdown
62 lines
2.2 KiB
Markdown
# 1. Goal
|
|
|
|
An energy supplier bills households for electricity. The billing program calls
|
|
one function module for each household. The function module calculates the bill
|
|
of one month.
|
|
|
|
# 2. Open questions
|
|
|
|
None.
|
|
|
|
# 3. Context
|
|
|
|
- The function group {{P}}FG_BILL exists in package $TMP. The group is empty.
|
|
- The billing program calls the function module once for each household. It
|
|
passes the consumption of the month, the tariff, and the payment method.
|
|
- The consumption is a quantity in kilowatt hours (kWh).
|
|
- The bill is an amount in euro.
|
|
|
|
# 4. Contract
|
|
|
|
- Create the function module {{P}}ENERGY_BILL in function group {{P}}FG_BILL.
|
|
- Use this interface:
|
|
|
|
| Parameter | Kind | Type | Meaning |
|
|
| --- | --- | --- | --- |
|
|
| iv_consumption | Importing | decfloat34 | Consumption of the month in kWh |
|
|
| iv_tariff | Importing | string | Tariff code |
|
|
| iv_direct_debit | Importing | abap_bool | abap_true if the customer pays by direct debit |
|
|
| ev_bill | Exporting | decfloat34 | Bill in euro |
|
|
| invalid_consumption | Exception | | See rule 1 |
|
|
| invalid_tariff | Exception | | See rule 2 |
|
|
|
|
# 5. Business rules
|
|
|
|
1. If the consumption is less than zero, raise the exception
|
|
INVALID_CONSUMPTION. Do not set the bill.
|
|
2. The valid tariff codes are BASIC, GREEN, and NIGHT. Any other tariff code
|
|
raises the exception INVALID_TARIFF. Do not set the bill.
|
|
3. Every bill contains a base fee of 12.00 euro.
|
|
4. The working price for one kWh is:
|
|
- BASIC: 0.32 euro
|
|
- GREEN: 0.38 euro
|
|
- NIGHT: 0.24 euro
|
|
5. For a consumption above 300 kWh, the working price of the part above 300 kWh
|
|
is 80 % of the working price of the tariff.
|
|
6. If the customer pays by direct debit, the bill is 2 % lower.
|
|
7. Round the bill half up to 2 decimals.
|
|
|
|
# 6. Constraints
|
|
|
|
- Release target: ABAP Platform 2025 (SAP_BASIS 816).
|
|
- Package: $TMP. Do not use transports.
|
|
- Coding standard: Clean ABAP. Keep every method below 40 statements.
|
|
- Out of scope: database access, CDS views, reports, ALV, dynpro, and changes
|
|
to other objects.
|
|
|
|
# 7. Acceptance
|
|
|
|
- The function module {{P}}ENERGY_BILL is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write ABAP Unit tests for the function module in a global test class.
|