Step F first pass: 81/92 accepted; budget floor 60 calls; rejected slots moved for regeneration

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
This commit is contained in:
Kral
2026-10-03 12:10:52 +02:00
parent d3250acfb8
commit 39769afce8
741 changed files with 40573 additions and 317 deletions

View File

@@ -0,0 +1,135 @@
CLASS {{p}}cine_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CONSTANTS: c_evening TYPE t VALUE '200000',
c_matinee TYPE t VALUE '160000',
c_boundary TYPE t VALUE '170000',
c_morning TYPE t VALUE '100000'.
METHODS call_fee
IMPORTING iv_show TYPE string
iv_seats TYPE i
iv_time TYPE t
iv_cust TYPE string
EXPORTING ev_total TYPE decfloat34
ev_disc TYPE decfloat34
ev_subrc TYPE sysubrc.
METHODS base_price_2d FOR TESTING.
METHODS base_prices_3d_imax FOR TESTING.
METHODS invalid_seats FOR TESTING.
METHODS invalid_show_type FOR TESTING.
METHODS invalid_cust_type FOR TESTING.
METHODS matinee_discount FOR TESTING.
METHODS matinee_boundary FOR TESTING.
METHODS child_skips_matinee FOR TESTING.
METHODS group_threshold FOR TESTING.
METHODS discount_cap FOR TESTING.
METHODS rounding_half_up FOR TESTING.
ENDCLASS.
CLASS {{p}}cine_hidden IMPLEMENTATION.
METHOD call_fee.
ev_total = 0.
ev_disc = 0.
CALL FUNCTION '{{P}}CINE_FEE_OLD'
EXPORTING
iv_show_type = iv_show
iv_seats = iv_seats
iv_show_time = iv_time
iv_cust_type = iv_cust
IMPORTING
ev_total = ev_total
ev_discount = ev_disc
EXCEPTIONS
invalid_input = 1
OTHERS = 2.
ev_subrc = sy-subrc.
ENDMETHOD.
METHOD base_price_2d.
call_fee( EXPORTING iv_show = `2D` iv_seats = 1 iv_time = c_evening iv_cust = `ADULT`
IMPORTING ev_total = DATA(lv_total) ev_disc = DATA(lv_disc) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '9.50' ) act = lv_total ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_disc ).
ENDMETHOD.
METHOD base_prices_3d_imax.
call_fee( EXPORTING iv_show = `3D` iv_seats = 1 iv_time = c_evening iv_cust = `ADULT`
IMPORTING ev_total = DATA(lv_total) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '13.00' ) act = lv_total ).
call_fee( EXPORTING iv_show = `IMAX` iv_seats = 1 iv_time = c_evening iv_cust = `ADULT`
IMPORTING ev_total = DATA(lv_total2) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '16.50' ) act = lv_total2 ).
ENDMETHOD.
METHOD invalid_seats.
call_fee( EXPORTING iv_show = `2D` iv_seats = 0 iv_time = c_evening iv_cust = `ADULT`
IMPORTING ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
ENDMETHOD.
METHOD invalid_show_type.
call_fee( EXPORTING iv_show = `XX` iv_seats = 1 iv_time = c_evening iv_cust = `ADULT`
IMPORTING ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
ENDMETHOD.
METHOD invalid_cust_type.
call_fee( EXPORTING iv_show = `2D` iv_seats = 1 iv_time = c_evening iv_cust = `VIP`
IMPORTING ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
ENDMETHOD.
METHOD matinee_discount.
call_fee( EXPORTING iv_show = `2D` iv_seats = 1 iv_time = c_matinee iv_cust = `ADULT`
IMPORTING ev_total = DATA(lv_total) ev_disc = DATA(lv_disc) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '7.25' ) act = lv_total ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 25 ) act = lv_disc ).
ENDMETHOD.
METHOD matinee_boundary.
call_fee( EXPORTING iv_show = `2D` iv_seats = 1 iv_time = c_boundary iv_cust = `ADULT`
IMPORTING ev_total = DATA(lv_total) ev_disc = DATA(lv_disc) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '9.50' ) act = lv_total ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_disc ).
ENDMETHOD.
METHOD child_skips_matinee.
call_fee( EXPORTING iv_show = `2D` iv_seats = 1 iv_time = c_morning iv_cust = `CHILD`
IMPORTING ev_total = DATA(lv_total) ev_disc = DATA(lv_disc) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '5.90' ) act = lv_total ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 40 ) act = lv_disc ).
ENDMETHOD.
METHOD group_threshold.
call_fee( EXPORTING iv_show = `2D` iv_seats = 7 iv_time = c_evening iv_cust = `ADULT`
IMPORTING ev_total = DATA(lv_total) ev_disc = DATA(lv_disc) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '66.50' ) act = lv_total ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_disc ).
call_fee( EXPORTING iv_show = `2D` iv_seats = 8 iv_time = c_evening iv_cust = `ADULT`
IMPORTING ev_total = DATA(lv_total2) ev_disc = DATA(lv_disc2) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '68.80' ) act = lv_total2 ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 10 ) act = lv_disc2 ).
ENDMETHOD.
METHOD discount_cap.
call_fee( EXPORTING iv_show = `2D` iv_seats = 8 iv_time = c_morning iv_cust = `SENIOR`
IMPORTING ev_total = DATA(lv_total) ev_disc = DATA(lv_disc) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '32.80' ) act = lv_total ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 60 ) act = lv_disc ).
ENDMETHOD.
METHOD rounding_half_up.
call_fee( EXPORTING iv_show = `3D` iv_seats = 3 iv_time = c_matinee iv_cust = `ADULT`
IMPORTING ev_total = DATA(lv_total) ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '29.63' ) act = lv_total ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,77 @@
FUNCTION {{p}}cine_fee_old
IMPORTING
iv_show_type TYPE string
iv_seats TYPE i
iv_show_time TYPE t
iv_cust_type TYPE string
EXPORTING
ev_total TYPE decfloat34
ev_discount TYPE decfloat34
EXCEPTIONS
invalid_input.
CONSTANTS:
c_price_2d TYPE decfloat34 VALUE '9.00',
c_price_3d TYPE decfloat34 VALUE '12.50',
c_price_imax TYPE decfloat34 VALUE '16.00',
c_booking_fee TYPE decfloat34 VALUE '0.50',
c_percent TYPE decfloat34 VALUE 100,
c_disc_child TYPE decfloat34 VALUE 40,
c_disc_senior TYPE decfloat34 VALUE 30,
c_disc_student TYPE decfloat34 VALUE 20,
c_disc_matinee TYPE decfloat34 VALUE 25,
c_disc_group TYPE decfloat34 VALUE 10,
c_disc_max TYPE decfloat34 VALUE 60,
c_group_seats TYPE i VALUE 8,
c_matinee_end TYPE t VALUE '170000'.
DATA: lv_base TYPE decfloat34,
lv_discount TYPE decfloat34,
lv_price TYPE decfloat34.
IF iv_seats < 1.
RAISE invalid_input.
ENDIF.
CASE iv_show_type.
WHEN '2D'.
lv_base = c_price_2d.
WHEN '3D'.
lv_base = c_price_3d.
WHEN 'IMAX'.
lv_base = c_price_imax.
WHEN OTHERS.
RAISE invalid_input.
ENDCASE.
CASE iv_cust_type.
WHEN 'CHILD'.
lv_discount = c_disc_child.
WHEN 'SENIOR'.
lv_discount = c_disc_senior.
WHEN 'STUDENT'.
lv_discount = c_disc_student.
WHEN 'ADULT'.
lv_discount = 0.
WHEN OTHERS.
RAISE invalid_input.
ENDCASE.
IF iv_show_time < c_matinee_end AND iv_cust_type <> 'CHILD'.
lv_discount = lv_discount + c_disc_matinee.
ENDIF.
IF iv_seats >= c_group_seats.
lv_discount = lv_discount + c_disc_group.
ENDIF.
IF lv_discount > c_disc_max.
lv_discount = c_disc_max.
ENDIF.
lv_price = lv_base - lv_base * lv_discount / c_percent + c_booking_fee.
ev_total = round( val = lv_price * iv_seats dec = 2 mode = cl_abap_math=>round_half_up ).
ev_discount = lv_discount.
ENDFUNCTION.

View File

@@ -0,0 +1,72 @@
CLASS {{p}}cine_test DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CONSTANTS: c_evening TYPE t VALUE '200000',
c_matinee TYPE t VALUE '160000'.
METHODS fee
IMPORTING iv_show TYPE string
iv_seats TYPE i
iv_time TYPE t
iv_cust TYPE string
RETURNING VALUE(rv_total) TYPE decfloat34.
METHODS adult_evening FOR TESTING.
METHODS matinee_discount FOR TESTING.
METHODS child_price FOR TESTING.
METHODS invalid_seats FOR TESTING.
ENDCLASS.
CLASS {{p}}cine_test IMPLEMENTATION.
METHOD fee.
CALL FUNCTION '{{P}}CINE_FEE_OLD'
EXPORTING
iv_show_type = iv_show
iv_seats = iv_seats
iv_show_time = iv_time
iv_cust_type = iv_cust
IMPORTING
ev_total = rv_total
EXCEPTIONS
invalid_input = 1
OTHERS = 2.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
ENDMETHOD.
METHOD adult_evening.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '9.50' )
act = fee( iv_show = `2D` iv_seats = 1 iv_time = c_evening iv_cust = `ADULT` ) ).
ENDMETHOD.
METHOD matinee_discount.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '7.25' )
act = fee( iv_show = `2D` iv_seats = 1 iv_time = c_matinee iv_cust = `ADULT` ) ).
ENDMETHOD.
METHOD child_price.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '5.90' )
act = fee( iv_show = `2D` iv_seats = 1 iv_time = c_matinee iv_cust = `CHILD` ) ).
ENDMETHOD.
METHOD invalid_seats.
DATA lv_total TYPE decfloat34.
CALL FUNCTION '{{P}}CINE_FEE_OLD'
EXPORTING
iv_show_type = `2D`
iv_seats = 0
iv_show_time = c_evening
iv_cust_type = `ADULT`
IMPORTING
ev_total = lv_total
EXCEPTIONS
invalid_input = 1
OTHERS = 2.
cl_abap_unit_assert=>assert_equals( exp = 1 act = sy-subrc ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,71 @@
FUNCTION {{p}}cine_fee_old
IMPORTING
iv_show_type TYPE string
iv_seats TYPE i
iv_show_time TYPE t
iv_cust_type TYPE string
EXPORTING
ev_total TYPE decfloat34
ev_discount TYPE decfloat34
EXCEPTIONS
invalid_input.
" legacy: price per seat
DATA: lv_x TYPE decfloat34,
lv_y TYPE decfloat34,
lv_z TYPE i.
IF iv_seats < 1.
RAISE invalid_input.
ENDIF.
IF iv_show_type = '2D' OR iv_show_type = '3D' OR iv_show_type = 'IMAX'.
IF iv_show_type = '2D'.
lv_x = 9.
ELSEIF iv_show_type = '3D'.
lv_x = '12.50'.
ELSE.
lv_x = 16.
ENDIF.
ELSE.
RAISE invalid_input.
ENDIF.
IF iv_cust_type = 'CHILD'.
lv_y = 40.
ELSEIF iv_cust_type = 'SENIOR'.
lv_y = 30.
ELSEIF iv_cust_type = 'STUDENT'.
lv_y = 20.
ELSEIF iv_cust_type = 'ADULT'.
lv_y = 0.
ELSE.
RAISE invalid_input.
ENDIF.
IF iv_show_time < '170000'.
IF iv_cust_type <> 'CHILD'.
lv_y = lv_y + 25.
ENDIF.
ENDIF.
IF iv_seats >= 8.
lv_y = lv_y + 10.
ENDIF.
IF lv_y > 60.
lv_y = 60.
ENDIF.
lv_x = lv_x - lv_x * lv_y / 100.
lv_x = lv_x + '0.5'.
lv_z = 0.
DO iv_seats TIMES.
lv_z = lv_z + 1.
ENDDO.
ev_total = round( val = lv_x * lv_z dec = 2 mode = cl_abap_math=>round_half_up ).
ev_discount = lv_y.
ENDFUNCTION.

View File

@@ -0,0 +1,44 @@
# 1. Goal
The function module {{P}}CINE_FEE_OLD in function group {{P}}FG_CINE calculates
the price of a cinema ticket order. The code is legacy code. Refactor the
function module in place. The behavior stays the same. The name and the public
interface stay the same.
# 2. Open questions
None.
# 3. Context
- Function group {{P}}FG_CINE exists in package $TMP.
- The function module {{P}}CINE_FEE_OLD exists in this function group. It holds
the legacy code.
- A ticket desk program calls {{P}}CINE_FEE_OLD for each ticket order. This call
must not change.
# 4. Contract
- Object: the function module {{P}}CINE_FEE_OLD in function group {{P}}FG_CINE.
- Keep the name and the interface of the function module: the same parameter
names, parameter kinds, parameter types and the same exception.
- Importing parameters: iv_show_type TYPE string, iv_seats TYPE i,
iv_show_time TYPE t, iv_cust_type TYPE string.
- Exporting parameters: ev_total TYPE decfloat34, ev_discount TYPE decfloat34.
- Exception: invalid_input.
# 5. Business rules
The legacy source code of {{P}}CINE_FEE_OLD is the only source of the business
rules. Read this source code. The one rule of this task: for every input the
function module returns the same output values and the same exception as before
the refactoring. Do not add, remove or change a rule.
# 6. Constraints
- Release target: SAP_BASIS 816.
- Coding standards: Clean ABAP. No ATC priority 1 or priority 2 finding. Keep
every procedure and every method below 40 statements. Replace literal numbers
with named constants. Use meaningful names.
- Out of scope: do not change the interface. Do not change the function group
{{P}}FG_CINE.
# 7. Acceptance
- {{P}}CINE_FEE_OLD is active and has no syntax error.
- The behavior is unchanged.
- The hidden tests pass.
- Write ABAP Unit tests for the function module in a global test class.

View File

@@ -0,0 +1,89 @@
{
"id": "G0144",
"category": "E",
"object_type": "FUNC",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "FUGR",
"name": "{{P}}FG_CINE",
"description": "Cinema ticket function group"
},
{
"type": "FUNC",
"name": "{{P}}CINE_FEE_OLD",
"functionGroup": "{{P}}FG_CINE",
"file": "seed/cine_fee_old.func.abap",
"description": "Legacy ticket price calculation"
}
],
"contract": [
{
"type": "FUNC",
"name": "{{P}}CINE_FEE_OLD",
"functionGroup": "{{P}}FG_CINE",
"params": [
{
"name": "iv_show_type",
"type": "string"
},
{
"name": "iv_seats",
"type": "i"
},
{
"name": "iv_show_time",
"type": "t"
},
{
"name": "iv_cust_type",
"type": "string"
},
{
"name": "ev_total",
"type": "decfloat34"
},
{
"name": "ev_discount",
"type": "decfloat34"
}
]
}
],
"out_of_scope": [
"{{P}}FG_CINE"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}CINE_HIDDEN",
"file": "hidden/cine_hidden.clas.abap",
"description": "Hidden behavior tests for the refactored ticket price calculation"
}
],
"reference": [
{
"type": "FUNC",
"name": "{{P}}CINE_FEE_OLD",
"functionGroup": "{{P}}FG_CINE",
"file": "reference/cine_fee_old.func.abap",
"description": "Refactored ticket price calculation, same interface and behavior",
"overwrite": true
},
{
"type": "CLAS",
"name": "{{P}}CINE_TEST",
"file": "reference/cine_test.clas.abap",
"description": "Own tests for the ticket price calculation"
}
],
"craft_checks": [
"method_length"
]
}