Hard batch G0022-G0026: 5/5 accepted; budget floor, CDS checks, mutation check

- generator: budget floor (2x oracle activations, 3x calls), static checks for CDS
  $parameters and UNION annotation
- harness/mutation.py: deterministic mutants of the reference; hidden tests must fail
- G0022 revalidated with harness fixes: oracle 100, null 0
- results in docs/faz1-tasarim.md 11f

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-03 05:16:30 +02:00
parent 3570d7ef9b
commit 32f03fcad4
53 changed files with 2931 additions and 14 deletions

View File

@@ -0,0 +1,37 @@
{
"id": "G0026",
"pool": "eval",
"object_type": "FUNC",
"category": "A",
"attempts": [
{
"stage": "bundle",
"errors": [
"reference/t14_test.clas.abap line 81: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"cl_abap_unit_assert\""
],
"by_check": {
"abaplint": 1
}
},
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "bundle",
"errors": [
"reference/t14_test.clas.abap line 81: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"cl_abap_unit_assert\""
],
"by_check": {
"abaplint": 1
}
},
{
"stage": "validate",
"oracle": 100.0,
"null": 0
}
],
"accepted": true
}

View File

@@ -0,0 +1,149 @@
CLASS {{p}}t14_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
TYPES: BEGIN OF ty_result,
time_fee TYPE decfloat34,
distance_fee TYPE decfloat34,
surcharge TYPE decfloat34,
discount TYPE decfloat34,
total TYPE decfloat34,
END OF ty_result.
METHODS price
IMPORTING iv_class TYPE string
iv_minutes TYPE i
iv_km TYPE i
iv_member TYPE abap_bool DEFAULT abap_false
iv_weekend TYPE abap_bool DEFAULT abap_false
EXPORTING es_result TYPE ty_result
ev_subrc TYPE sysubrc.
METHODS time_fee_blocks FOR TESTING.
METHODS distance_fee_free_km FOR TESTING.
METHODS weekend_surcharge FOR TESTING.
METHODS weekday_no_surcharge FOR TESTING.
METHODS member_discount FOR TESTING.
METHODS minimum_total FOR TESTING.
METHODS minimum_total_member FOR TESTING.
METHODS invalid_duration FOR TESTING.
METHODS invalid_distance FOR TESTING.
METHODS invalid_class FOR TESTING.
ENDCLASS.
CLASS {{p}}t14_hidden IMPLEMENTATION.
METHOD price.
CLEAR es_result.
CALL FUNCTION '{{P}}RENT_PRICE'
EXPORTING
iv_vehicle_class = iv_class
iv_minutes = iv_minutes
iv_km = iv_km
iv_member = iv_member
iv_weekend = iv_weekend
IMPORTING
ev_time_fee = es_result-time_fee
ev_distance_fee = es_result-distance_fee
ev_surcharge = es_result-surcharge
ev_discount = es_result-discount
ev_total = es_result-total
EXCEPTIONS
invalid_duration = 1
invalid_distance = 2
invalid_class = 3
OTHERS = 4.
ev_subrc = sy-subrc.
ENDMETHOD.
METHOD time_fee_blocks.
price( EXPORTING iv_class = `S` iv_minutes = 15 iv_km = 0
IMPORTING es_result = DATA(ls_15) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 3 ) act = ls_15-time_fee ).
price( EXPORTING iv_class = `S` iv_minutes = 16 iv_km = 0
IMPORTING es_result = DATA(ls_16) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 6 ) act = ls_16-time_fee ).
price( EXPORTING iv_class = `L` iv_minutes = 61 iv_km = 0
IMPORTING es_result = DATA(ls_61) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 40 ) act = ls_61-time_fee ).
ENDMETHOD.
METHOD distance_fee_free_km.
price( EXPORTING iv_class = `L` iv_minutes = 60 iv_km = 10
IMPORTING es_result = DATA(ls_free) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = ls_free-distance_fee ).
price( EXPORTING iv_class = `L` iv_minutes = 60 iv_km = 14
IMPORTING es_result = DATA(ls_paid) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 1 ) act = ls_paid-distance_fee ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 33 ) act = ls_paid-total ).
ENDMETHOD.
METHOD weekend_surcharge.
price( EXPORTING iv_class = `M` iv_minutes = 30 iv_km = 0 iv_weekend = abap_true
IMPORTING es_result = DATA(ls) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '2.50' ) act = ls-surcharge ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '12.50' ) act = ls-total ).
ENDMETHOD.
METHOD weekday_no_surcharge.
price( EXPORTING iv_class = `M` iv_minutes = 30 iv_km = 0
IMPORTING es_result = DATA(ls) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = ls-surcharge ).
ENDMETHOD.
METHOD member_discount.
" 6.50 * 15 % = 0.975 -> 0.98
price( EXPORTING iv_class = `M` iv_minutes = 15 iv_km = 11
iv_weekend = abap_true iv_member = abap_true
IMPORTING es_result = DATA(ls_half) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '0.98' ) act = ls_half-discount ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '5.52' ) act = ls_half-total ).
" 10.75 * 15 % = 1.6125 -> 1.61
price( EXPORTING iv_class = `M` iv_minutes = 30 iv_km = 13 iv_member = abap_true
IMPORTING es_result = DATA(ls_round) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '1.61' ) act = ls_round-discount ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '9.14' ) act = ls_round-total ).
" 7.50 * 15 % = 1.125 -> 1.13
price( EXPORTING iv_class = `S` iv_minutes = 15 iv_km = 28 iv_member = abap_true
IMPORTING es_result = DATA(ls_up) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '1.13' ) act = ls_up-discount ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '6.37' ) act = ls_up-total ).
ENDMETHOD.
METHOD minimum_total.
price( EXPORTING iv_class = `S` iv_minutes = 15 iv_km = 0
IMPORTING es_result = DATA(ls) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 3 ) act = ls-time_fee ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = ls-discount ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 5 ) act = ls-total ).
ENDMETHOD.
METHOD minimum_total_member.
price( EXPORTING iv_class = `S` iv_minutes = 15 iv_km = 0 iv_member = abap_true
IMPORTING es_result = DATA(ls) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '0.45' ) act = ls-discount ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 5 ) act = ls-total ).
ENDMETHOD.
METHOD invalid_duration.
price( EXPORTING iv_class = `S` iv_minutes = 0 iv_km = 0
IMPORTING ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_subrc ).
ENDMETHOD.
METHOD invalid_distance.
price( EXPORTING iv_class = `S` iv_minutes = 15 iv_km = -1
IMPORTING ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_subrc ).
ENDMETHOD.
METHOD invalid_class.
price( EXPORTING iv_class = `X` iv_minutes = 15 iv_km = 0
IMPORTING ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 3 act = lv_subrc ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,158 @@
CLASS {{p}}cl_rent DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_class TYPE string.
TYPES ty_money TYPE decfloat34.
TYPES ty_err_code TYPE c LENGTH 1.
CONSTANTS: BEGIN OF c_err,
ok TYPE ty_err_code VALUE ' ',
duration TYPE ty_err_code VALUE 'D',
distance TYPE ty_err_code VALUE 'K',
bad_class TYPE ty_err_code VALUE 'C',
END OF c_err.
TYPES: BEGIN OF ty_request,
vehicle_class TYPE ty_class,
minutes TYPE i,
km TYPE i,
member TYPE abap_bool,
weekend TYPE abap_bool,
END OF ty_request.
TYPES: BEGIN OF ty_result,
err_code TYPE ty_err_code,
time_fee TYPE ty_money,
distance_fee TYPE ty_money,
surcharge TYPE ty_money,
discount TYPE ty_money,
total TYPE ty_money,
END OF ty_result.
CLASS-METHODS calculate
IMPORTING is_request TYPE ty_request
RETURNING VALUE(rs_result) TYPE ty_result.
PRIVATE SECTION.
CONSTANTS: BEGIN OF c_block_price,
small TYPE ty_money VALUE '3.00',
medium TYPE ty_money VALUE '5.00',
large TYPE ty_money VALUE '8.00',
END OF c_block_price.
CONSTANTS c_block_minutes TYPE i VALUE 15.
CONSTANTS c_free_km TYPE i VALUE 10.
CONSTANTS c_km_price TYPE ty_money VALUE '0.25'.
CONSTANTS c_weekend_share TYPE ty_money VALUE '0.25'.
CONSTANTS c_member_share TYPE ty_money VALUE '0.15'.
CONSTANTS c_min_total TYPE ty_money VALUE '5.00'.
CONSTANTS c_decimals TYPE i VALUE 2.
CLASS-METHODS validate
IMPORTING is_request TYPE ty_request
RETURNING VALUE(rv_err_code) TYPE ty_err_code.
CLASS-METHODS time_fee
IMPORTING is_request TYPE ty_request
RETURNING VALUE(rv_fee) TYPE ty_money.
CLASS-METHODS distance_fee
IMPORTING is_request TYPE ty_request
RETURNING VALUE(rv_fee) TYPE ty_money.
CLASS-METHODS block_price
IMPORTING is_request TYPE ty_request
RETURNING VALUE(rv_price) TYPE ty_money.
CLASS-METHODS block_count
IMPORTING iv_minutes TYPE i
RETURNING VALUE(rv_blocks) TYPE i.
CLASS-METHODS round_money
IMPORTING iv_value TYPE ty_money
RETURNING VALUE(rv_value) TYPE ty_money.
ENDCLASS.
CLASS {{p}}cl_rent IMPLEMENTATION.
METHOD calculate.
rs_result-err_code = validate( is_request ).
IF rs_result-err_code <> c_err-ok.
RETURN.
ENDIF.
rs_result-time_fee = time_fee( is_request ).
rs_result-distance_fee = distance_fee( is_request ).
IF is_request-weekend = abap_true.
rs_result-surcharge = round_money( rs_result-time_fee * c_weekend_share ).
ELSE.
rs_result-surcharge = 0.
ENDIF.
DATA(lv_gross) = rs_result-time_fee + rs_result-distance_fee + rs_result-surcharge.
IF is_request-member = abap_true.
rs_result-discount = round_money( lv_gross * c_member_share ).
ELSE.
rs_result-discount = 0.
ENDIF.
rs_result-total = round_money( lv_gross - rs_result-discount ).
IF rs_result-total < c_min_total.
rs_result-total = c_min_total.
ENDIF.
ENDMETHOD.
METHOD validate.
IF is_request-minutes < 1.
rv_err_code = c_err-duration.
ELSEIF is_request-km < 0.
rv_err_code = c_err-distance.
ELSEIF is_request-vehicle_class <> 'S'
AND is_request-vehicle_class <> 'M'
AND is_request-vehicle_class <> 'L'.
rv_err_code = c_err-bad_class.
ELSE.
rv_err_code = c_err-ok.
ENDIF.
ENDMETHOD.
METHOD time_fee.
rv_fee = block_count( is_request-minutes ) * block_price( is_request ).
ENDMETHOD.
METHOD distance_fee.
DATA(lv_chargeable_km) = is_request-km - c_free_km.
IF lv_chargeable_km > 0.
rv_fee = lv_chargeable_km * c_km_price.
ELSE.
rv_fee = 0.
ENDIF.
ENDMETHOD.
METHOD block_price.
CASE is_request-vehicle_class.
WHEN 'S'.
rv_price = c_block_price-small.
WHEN 'M'.
rv_price = c_block_price-medium.
WHEN 'L'.
rv_price = c_block_price-large.
WHEN OTHERS.
rv_price = 0.
ENDCASE.
ENDMETHOD.
METHOD block_count.
rv_blocks = ( iv_minutes + c_block_minutes - 1 ) DIV c_block_minutes.
ENDMETHOD.
METHOD round_money.
rv_value = round( val = iv_value
dec = c_decimals
mode = cl_abap_math=>round_half_up ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,87 @@
CLASS {{p}}lcl_rent_test DEFINITION FOR TESTING
DURATION SHORT RISK LEVEL HARMLESS FINAL.
PRIVATE SECTION.
METHODS price_for
IMPORTING iv_class TYPE string
iv_minutes TYPE i
iv_km TYPE i
iv_member TYPE abap_bool DEFAULT abap_false
iv_weekend TYPE abap_bool DEFAULT abap_false
RETURNING VALUE(rs_result) TYPE {{p}}cl_rent=>ty_result.
METHODS time_fee_blocks FOR TESTING.
METHODS distance_fee_free_km FOR TESTING.
METHODS weekend_surcharge FOR TESTING.
METHODS member_discount FOR TESTING.
METHODS minimum_total FOR TESTING.
METHODS invalid_input FOR TESTING.
ENDCLASS.
CLASS {{p}}lcl_rent_test IMPLEMENTATION.
METHOD price_for.
DATA(ls_request) = VALUE {{p}}cl_rent=>ty_request(
vehicle_class = iv_class
minutes = iv_minutes
km = iv_km
member = iv_member
weekend = iv_weekend ).
rs_result = {{p}}cl_rent=>calculate( ls_request ).
ENDMETHOD.
METHOD time_fee_blocks.
DATA(ls_15) = price_for( iv_class = `S` iv_minutes = 15 iv_km = 0 ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 3 ) act = ls_15-time_fee ).
DATA(ls_16) = price_for( iv_class = `S` iv_minutes = 16 iv_km = 0 ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 6 ) act = ls_16-time_fee ).
DATA(ls_61) = price_for( iv_class = `L` iv_minutes = 61 iv_km = 0 ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 40 ) act = ls_61-time_fee ).
ENDMETHOD.
METHOD distance_fee_free_km.
DATA(ls_free) = price_for( iv_class = `L` iv_minutes = 60 iv_km = 10 ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = ls_free-distance_fee ).
DATA(ls_paid) = price_for( iv_class = `L` iv_minutes = 60 iv_km = 14 ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 1 ) act = ls_paid-distance_fee ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 33 ) act = ls_paid-total ).
ENDMETHOD.
METHOD weekend_surcharge.
DATA(ls) = price_for( iv_class = `M` iv_minutes = 30 iv_km = 0 iv_weekend = abap_true ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '2.50' ) act = ls-surcharge ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '12.50' ) act = ls-total ).
ENDMETHOD.
METHOD member_discount.
DATA(ls_half) = price_for( iv_class = `M` iv_minutes = 15 iv_km = 11
iv_weekend = abap_true iv_member = abap_true ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '0.98' ) act = ls_half-discount ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '5.52' ) act = ls_half-total ).
DATA(ls_up) = price_for( iv_class = `S` iv_minutes = 15 iv_km = 28 iv_member = abap_true ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '1.13' ) act = ls_up-discount ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '6.37' ) act = ls_up-total ).
ENDMETHOD.
METHOD minimum_total.
DATA(ls) = price_for( iv_class = `S` iv_minutes = 15 iv_km = 0 ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 3 ) act = ls-time_fee ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 5 ) act = ls-total ).
ENDMETHOD.
METHOD invalid_input.
cl_abap_unit_assert=>assert_equals(
exp = {{p}}cl_rent=>c_err-duration
act = price_for( iv_class = `S` iv_minutes = 0 iv_km = 0 )-err_code ).
cl_abap_unit_assert=>assert_equals(
exp = {{p}}cl_rent=>c_err-distance
act = price_for( iv_class = `S` iv_minutes = 15 iv_km = -1 )-err_code ).
cl_abap_unit_assert=>assert_equals(
exp = {{p}}cl_rent=>c_err-bad_class
act = price_for( iv_class = `X` iv_minutes = 15 iv_km = 0 )-err_code ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,30 @@
CLASS {{p}}cx_rent_invalid DEFINITION
PUBLIC
INHERITING FROM cx_static_check
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
METHODS constructor
IMPORTING textid LIKE textid OPTIONAL
previous LIKE previous OPTIONAL
iv_reason TYPE string OPTIONAL.
METHODS get_reason
RETURNING VALUE(rv_reason) TYPE string.
PRIVATE SECTION.
DATA mv_reason TYPE string.
ENDCLASS.
CLASS {{p}}cx_rent_invalid IMPLEMENTATION.
METHOD constructor.
super->constructor( textid = textid previous = previous ).
mv_reason = iv_reason.
ENDMETHOD.
METHOD get_reason.
rv_reason = mv_reason.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,43 @@
FUNCTION {{p}}rent_price
IMPORTING
iv_vehicle_class TYPE string
iv_minutes TYPE i
iv_km TYPE i
iv_member TYPE abap_bool
iv_weekend TYPE abap_bool
EXPORTING
ev_time_fee TYPE decfloat34
ev_distance_fee TYPE decfloat34
ev_surcharge TYPE decfloat34
ev_discount TYPE decfloat34
ev_total TYPE decfloat34
EXCEPTIONS
invalid_duration
invalid_distance
invalid_class.
DATA ls_request TYPE {{p}}cl_rent=>ty_request.
ls_request-vehicle_class = iv_vehicle_class.
ls_request-minutes = iv_minutes.
ls_request-km = iv_km.
ls_request-member = iv_member.
ls_request-weekend = iv_weekend.
DATA(ls_result) = {{p}}cl_rent=>calculate( ls_request ).
CASE ls_result-err_code.
WHEN {{p}}cl_rent=>c_err-duration.
RAISE invalid_duration.
WHEN {{p}}cl_rent=>c_err-distance.
RAISE invalid_distance.
WHEN {{p}}cl_rent=>c_err-bad_class.
RAISE invalid_class.
WHEN OTHERS.
ev_time_fee = ls_result-time_fee.
ev_distance_fee = ls_result-distance_fee.
ev_surcharge = ls_result-surcharge.
ev_discount = ls_result-discount.
ev_total = ls_result-total.
ENDCASE.
ENDFUNCTION.

View File

@@ -0,0 +1,90 @@
CLASS {{p}}t14_test DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
TYPES: BEGIN OF ty_result,
time_fee TYPE decfloat34,
distance_fee TYPE decfloat34,
surcharge TYPE decfloat34,
discount TYPE decfloat34,
total TYPE decfloat34,
END OF ty_result.
METHODS price
IMPORTING iv_class TYPE string
iv_minutes TYPE i
iv_km TYPE i
iv_member TYPE abap_bool DEFAULT abap_false
iv_weekend TYPE abap_bool DEFAULT abap_false
EXPORTING es_result TYPE ty_result
ev_subrc TYPE sysubrc.
METHODS time_fee_blocks FOR TESTING.
METHODS distance_fee_free_km FOR TESTING.
METHODS weekend_surcharge FOR TESTING.
METHODS member_discount FOR TESTING.
METHODS minimum_total FOR TESTING.
METHODS invalid_duration FOR TESTING.
ENDCLASS.
CLASS {{p}}t14_test IMPLEMENTATION.
METHOD price.
CLEAR es_result.
CALL FUNCTION '{{P}}RENT_PRICE'
EXPORTING
iv_vehicle_class = iv_class
iv_minutes = iv_minutes
iv_km = iv_km
iv_member = iv_member
iv_weekend = iv_weekend
IMPORTING
ev_time_fee = es_result-time_fee
ev_distance_fee = es_result-distance_fee
ev_surcharge = es_result-surcharge
ev_discount = es_result-discount
ev_total = es_result-total
EXCEPTIONS
invalid_duration = 1
invalid_distance = 2
invalid_class = 3
OTHERS = 4.
ev_subrc = sy-subrc.
ENDMETHOD.
METHOD time_fee_blocks.
price( EXPORTING iv_class = `S` iv_minutes = 16 iv_km = 0
IMPORTING es_result = DATA(ls) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 6 ) act = ls-time_fee ).
ENDMETHOD.
METHOD distance_fee_free_km.
price( EXPORTING iv_class = `L` iv_minutes = 60 iv_km = 14
IMPORTING es_result = DATA(ls) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 1 ) act = ls-distance_fee ).
ENDMETHOD.
METHOD weekend_surcharge.
price( EXPORTING iv_class = `M` iv_minutes = 30 iv_km = 0 iv_weekend = abap_true
IMPORTING es_result = DATA(ls) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '2.50' ) act = ls-surcharge ).
ENDMETHOD.
METHOD member_discount.
price( EXPORTING iv_class = `S` iv_minutes = 15 iv_km = 28 iv_member = abap_true
IMPORTING es_result = DATA(ls) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '1.13' ) act = ls-discount ).
ENDMETHOD.
METHOD minimum_total.
price( EXPORTING iv_class = `S` iv_minutes = 15 iv_km = 0
IMPORTING es_result = DATA(ls) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 5 ) act = ls-total ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 3 ) act = ls-time_fee ).
ENDMETHOD.
METHOD invalid_duration.
price( EXPORTING iv_class = `S` iv_minutes = 0 iv_km = 0
IMPORTING ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_subrc ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,25 @@
FUNCTION {{p}}rent_sample
IMPORTING
iv_vehicle_class TYPE string
iv_minutes TYPE i
iv_km TYPE i
iv_member TYPE abap_bool
iv_weekend TYPE abap_bool
EXPORTING
ev_time_fee TYPE decfloat34
ev_distance_fee TYPE decfloat34
ev_surcharge TYPE decfloat34
ev_discount TYPE decfloat34
ev_total TYPE decfloat34
EXCEPTIONS
invalid_duration
invalid_distance
invalid_class.
CLEAR: ev_time_fee,
ev_distance_fee,
ev_surcharge,
ev_discount,
ev_total.
ENDFUNCTION.

View File

@@ -0,0 +1,81 @@
# 1. Goal
Calculate the price of a finished car-sharing rental. A booking program calls
one function module for each finished rental. The function module must have
the same interface as the sample function module, because the booking program
calls all pricing modules in the same way.
# 2. Open questions
None.
# 3. Context
- Function group {{P}}FG_RENT exists in package $TMP.
- Function module {{P}}RENT_SAMPLE exists in this function group. It is the
sample pricing module. Its interface is the interface that all pricing
modules must use.
- All rental data is in the input parameters. No database access is necessary.
# 4. Contract
Create the function module {{P}}RENT_PRICE in function group {{P}}FG_RENT.
The interface is:
IMPORTING
iv_vehicle_class TYPE string
iv_minutes TYPE i
iv_km TYPE i
iv_member TYPE abap_bool
iv_weekend TYPE abap_bool
EXPORTING
ev_time_fee TYPE decfloat34
ev_distance_fee TYPE decfloat34
ev_surcharge TYPE decfloat34
ev_discount TYPE decfloat34
ev_total TYPE decfloat34
EXCEPTIONS
invalid_duration
invalid_distance
invalid_class
This interface is the same as the interface of {{P}}RENT_SAMPLE.
Put the calculation logic in a new class in package $TMP. The function module
must only call this class. The function module must not contain the
calculation itself. The class is your own design decision. The function module
maps the result of the class to its exporting parameters and exceptions.
# 5. Business rules
1. Check the input in this sequence:
a. If iv_minutes is less than 1, raise INVALID_DURATION.
b. If iv_km is less than 0, raise INVALID_DISTANCE.
c. If iv_vehicle_class is not 'S', not 'M' and not 'L', raise INVALID_CLASS.
2. Charge the rental duration in started 15-minute blocks. A duration of 15
minutes is one block. A duration of 16 minutes is two blocks.
3. The price of one block depends on the vehicle class: 'S' costs 3.00, 'M'
costs 5.00 and 'L' costs 8.00. The time fee is the number of blocks
multiplied by the block price.
4. The first 10 kilometres of a rental are free. Each further kilometre costs
0.25. The distance fee is the number of kilometres above 10 multiplied by
0.25.
5. If iv_weekend is true, the weekend surcharge is 25 % of the time fee.
Otherwise the weekend surcharge is 0.
6. The gross amount is the time fee plus the distance fee plus the weekend
surcharge.
7. If iv_member is true, the member discount is 15 % of the gross amount.
Otherwise the member discount is 0.
8. The total price is the gross amount minus the member discount. If this
value is less than 5.00, the total price is 5.00.
9. Round the weekend surcharge, the member discount and the total price half
up to 2 decimals.
10. Return the time fee in ev_time_fee, the distance fee in ev_distance_fee,
the weekend surcharge in ev_surcharge, the member discount in ev_discount
and the total price in ev_total.
# 6. Constraints
- Release target: ABAP Platform 2025 (SAP_BASIS 816).
- Coding standards: Clean ABAP. Keep every method below 40 statements.
- Out of scope: do not change {{P}}RENT_SAMPLE.
# 7. Acceptance
- The function module {{P}}RENT_PRICE is active and has no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests for the new class as local test classes.
- Write ABAP Unit tests for the function module in a global test class.

View File

@@ -0,0 +1,111 @@
{
"id": "G0026",
"category": "A",
"object_type": "FUNC",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 40,
"max_activations": 10
},
"seed": [
{
"type": "FUGR",
"name": "{{P}}FG_RENT",
"description": "Rental pricing"
},
{
"type": "FUNC",
"name": "{{P}}RENT_SAMPLE",
"functionGroup": "{{P}}FG_RENT",
"file": "seed/rent_sample.func.abap",
"description": "Sample pricing module"
}
],
"contract": [
{
"type": "FUNC",
"name": "{{P}}RENT_PRICE",
"functionGroup": "{{P}}FG_RENT",
"params": [
{
"name": "iv_vehicle_class",
"type": "string"
},
{
"name": "iv_minutes",
"type": "i"
},
{
"name": "iv_km",
"type": "i"
},
{
"name": "iv_member",
"type": "abap_bool"
},
{
"name": "iv_weekend",
"type": "abap_bool"
},
{
"name": "ev_time_fee",
"type": "decfloat34"
},
{
"name": "ev_distance_fee",
"type": "decfloat34"
},
{
"name": "ev_surcharge",
"type": "decfloat34"
},
{
"name": "ev_discount",
"type": "decfloat34"
},
{
"name": "ev_total",
"type": "decfloat34"
}
]
}
],
"out_of_scope": [
"{{P}}RENT_SAMPLE"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}T14_HIDDEN",
"file": "hidden/t14_hidden.clas.abap",
"description": "T14 hidden tests"
}
],
"reference": [
{
"type": "CLAS",
"name": "{{P}}CL_RENT",
"file": "reference/cl_rent.clas.abap",
"testclasses_file": "reference/cl_rent.clas.testclasses.abap",
"description": "Rental price calculation"
},
{
"type": "FUNC",
"name": "{{P}}RENT_PRICE",
"functionGroup": "{{P}}FG_RENT",
"file": "reference/rent_price.func.abap",
"description": "Rental pricing module"
},
{
"type": "CLAS",
"name": "{{P}}T14_TEST",
"file": "reference/t14_test.clas.abap",
"description": "T14 own tests"
}
],
"craft_checks": [
"method_length"
]
}