Stage 2 summary at 50 accepted trajectories

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 18:02:52 +02:00
parent 332fb4601d
commit 5bcd1bf9cd
1230 changed files with 77563 additions and 33 deletions

View File

@@ -0,0 +1,33 @@
{
"id": "G1153",
"pool": "train",
"object_type": "PROG",
"category": "C",
"attempts": [
{
"stage": "validate",
"oracle": 93.3,
"null": 0
},
{
"stage": "bundle",
"errors": [
"invalid JSON: Expecting value: line 1 column 1 (char 0)"
],
"by_check": {
"json": 1
}
},
{
"stage": "validate",
"oracle": 75.0,
"null": 0
},
{
"stage": "validate",
"oracle": 93.3,
"null": 0
}
],
"accepted": false
}

View File

@@ -0,0 +1,102 @@
CLASS {{p}}dealer_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS run
IMPORTING iv_from TYPE d
iv_to TYPE d
iv_city TYPE {{p}}dealer-city
RETURNING VALUE(rr_data) TYPE REF TO data.
METHODS value_of
IMPORTING ir_data TYPE REF TO data
iv_row TYPE i
iv_col TYPE string
RETURNING VALUE(rv_value) TYPE string.
METHODS lines_of
IMPORTING ir_data TYPE REF TO data
RETURNING VALUE(rv_lines) TYPE i.
METHODS all_dealers FOR TESTING.
METHODS sorted_by_revenue FOR TESTING.
METHODS revenue_and_sales FOR TESTING.
METHODS top_model FOR TESTING.
METHODS city_filter FOR TESTING.
METHODS date_filter FOR TESTING.
ENDCLASS.
CLASS {{p}}dealer_hidden IMPLEMENTATION.
METHOD run.
cl_salv_bs_runtime_info=>clear_all( ).
cl_salv_bs_runtime_info=>set( display = abap_false metadata = abap_false data = abap_true ).
SUBMIT {{p}}dealer_sum WITH p_from = iv_from WITH p_to = iv_to WITH p_city = iv_city AND RETURN.
TRY.
cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = rr_data ).
CATCH cx_salv_bs_sc_runtime_info.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).
ENDMETHOD.
METHOD lines_of.
FIELD-SYMBOLS <lt_data> TYPE STANDARD TABLE.
IF ir_data IS BOUND.
ASSIGN ir_data->* TO <lt_data>.
rv_lines = lines( <lt_data> ).
ENDIF.
ENDMETHOD.
METHOD value_of.
FIELD-SYMBOLS <lt_data> TYPE STANDARD TABLE.
ASSIGN ir_data->* TO <lt_data>.
ASSIGN <lt_data>[ iv_row ] TO FIELD-SYMBOL(<ls_line>).
ASSIGN COMPONENT iv_col OF STRUCTURE <ls_line> TO FIELD-SYMBOL(<lv_value>).
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = |Column { iv_col } missing| ).
rv_value = condense( CONV string( <lv_value> ) ).
ENDMETHOD.
METHOD all_dealers.
cl_abap_unit_assert=>assert_equals(
exp = 4
act = lines_of( run( iv_from = '20260101' iv_to = '20260331' iv_city = '' ) ) ).
ENDMETHOD.
METHOD sorted_by_revenue.
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260331' iv_city = '' ).
cl_abap_unit_assert=>assert_equals(
exp = `North Motors` act = value_of( ir_data = lr_data iv_row = 1 iv_col = `DEALER` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `River Motors` act = value_of( ir_data = lr_data iv_row = 2 iv_col = `DEALER` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `Lake Cars` act = value_of( ir_data = lr_data iv_row = 4 iv_col = `DEALER` ) ).
ENDMETHOD.
METHOD revenue_and_sales.
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260331' iv_city = '' ).
cl_abap_unit_assert=>assert_equals(
exp = `Berlin` act = value_of( ir_data = lr_data iv_row = 1 iv_col = `CITY` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `56000.00` act = value_of( ir_data = lr_data iv_row = 1 iv_col = `REVENUE` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `4` act = value_of( ir_data = lr_data iv_row = 1 iv_col = `SALES` ) ).
ENDMETHOD.
METHOD top_model.
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260331' iv_city = '' ).
cl_abap_unit_assert=>assert_equals(
exp = `SUV` act = value_of( ir_data = lr_data iv_row = 1 iv_col = `TOP_MODEL` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `HATCH` act = value_of( ir_data = lr_data iv_row = 3 iv_col = `TOP_MODEL` ) ).
ENDMETHOD.
METHOD city_filter.
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260331' iv_city = 'Berlin' ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines_of( lr_data ) ).
cl_abap_unit_assert=>assert_equals(
exp = `North Motors` act = value_of( ir_data = lr_data iv_row = 1 iv_col = `DEALER` ) ).
ENDMETHOD.
METHOD date_filter.
DATA(lr_data) = run( iv_from = '20260201' iv_to = '20260331' iv_city = '' ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines_of( lr_data ) ).
cl_abap_unit_assert=>assert_equals(
exp = `36000.00` act = value_of( ir_data = lr_data iv_row = 2 iv_col = `REVENUE` ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,40 @@
{
"task": "T15",
"mutants": [
{
"object": "{{P}}DEALER_SUM",
"mutant": "line 80: <> -> = (rel)",
"status": "killed",
"hidden": "1/6",
"failed_tests": [
"ALL_DEALERS",
"SORTED_BY_REVENUE",
"REVENUE_AND_SALES",
"TOP_MODEL",
"DATE_FILTER"
]
},
{
"object": "{{P}}DEALER_SUM",
"mutant": "line 95: > -> >= (rel)",
"status": "killed",
"hidden": "5/6",
"failed_tests": [
"TOP_MODEL"
]
},
{
"object": "{{P}}DEALER_SUM",
"mutant": "line 67: = -> <> (rel)",
"status": "killed",
"hidden": "5/6",
"failed_tests": [
"CITY_FILTER"
]
}
],
"valid": 3,
"killed": 3,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,167 @@
REPORT {{p}}dealer_sum.
PARAMETERS p_from TYPE d OBLIGATORY.
PARAMETERS p_to TYPE d OBLIGATORY.
PARAMETERS p_city TYPE {{p}}dealer-city.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
TYPES:
BEGIN OF ty_line,
dealer TYPE {{p}}dealer-dealer_name,
city TYPE {{p}}dealer-city,
sales TYPE i,
revenue TYPE {{p}}vsale-price,
top_model TYPE {{p}}vsale-model_code,
END OF ty_line,
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY,
BEGIN OF ty_model,
dealer_id TYPE {{p}}dealer-dealer_id,
dealer_name TYPE {{p}}dealer-dealer_name,
city TYPE {{p}}dealer-city,
model_code TYPE {{p}}vsale-model_code,
model_sum TYPE {{p}}vsale-price,
model_cnt TYPE i,
END OF ty_model,
tt_model TYPE STANDARD TABLE OF ty_model WITH EMPTY KEY.
METHODS select_summary
IMPORTING iv_from TYPE d
iv_to TYPE d
iv_city TYPE {{p}}dealer-city
RETURNING VALUE(rt_lines) TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
PRIVATE SECTION.
METHODS read_models
IMPORTING iv_from TYPE d
iv_to TYPE d
iv_city TYPE {{p}}dealer-city
RETURNING VALUE(rt_models) TYPE tt_model.
METHODS reduce
IMPORTING it_models TYPE tt_model
RETURNING VALUE(rt_lines) TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD select_summary.
rt_lines = reduce( read_models( iv_from = iv_from iv_to = iv_to iv_city = iv_city ) ).
ENDMETHOD.
METHOD read_models.
IF iv_city IS INITIAL.
SELECT d~dealer_id, d~dealer_name, d~city, s~model_code,
SUM( s~price ) AS model_sum, COUNT( * ) AS model_cnt
FROM {{p}}vsale AS s
INNER JOIN {{p}}dealer AS d ON d~dealer_id = s~dealer_id
WHERE s~sale_date BETWEEN @iv_from AND @iv_to
GROUP BY d~dealer_id, d~dealer_name, d~city, s~model_code
ORDER BY d~dealer_id, s~model_code
INTO CORRESPONDING FIELDS OF TABLE @rt_models.
ELSE.
SELECT d~dealer_id, d~dealer_name, d~city, s~model_code,
SUM( s~price ) AS model_sum, COUNT( * ) AS model_cnt
FROM {{p}}vsale AS s
INNER JOIN {{p}}dealer AS d ON d~dealer_id = s~dealer_id
WHERE s~sale_date BETWEEN @iv_from AND @iv_to
AND d~city = @iv_city
GROUP BY d~dealer_id, d~dealer_name, d~city, s~model_code
ORDER BY d~dealer_id, s~model_code
INTO CORRESPONDING FIELDS OF TABLE @rt_models.
ENDIF.
ENDMETHOD.
METHOD reduce.
DATA ls_line TYPE ty_line.
DATA lv_dealer_id TYPE {{p}}dealer-dealer_id.
DATA lv_top_sum TYPE {{p}}vsale-price.
LOOP AT it_models INTO DATA(ls_model).
IF ls_model-dealer_id <> lv_dealer_id.
IF lv_dealer_id IS NOT INITIAL.
APPEND ls_line TO rt_lines.
ENDIF.
CLEAR ls_line.
lv_dealer_id = ls_model-dealer_id.
lv_top_sum = ls_model-model_sum.
ls_line-dealer = ls_model-dealer_name.
ls_line-city = ls_model-city.
ls_line-top_model = ls_model-model_code.
ls_line-revenue = ls_model-model_sum.
ls_line-sales = ls_model-model_cnt.
ELSE.
ls_line-revenue = ls_line-revenue + ls_model-model_sum.
ls_line-sales = ls_line-sales + ls_model-model_cnt.
IF ls_model-model_sum > lv_top_sum.
lv_top_sum = ls_model-model_sum.
ls_line-top_model = ls_model-model_code.
ENDIF.
ENDIF.
ENDLOOP.
IF lv_dealer_id IS NOT INITIAL.
APPEND ls_line TO rt_lines.
ENDIF.
SORT rt_lines BY revenue DESCENDING dealer ASCENDING.
ENDMETHOD.
METHOD display.
TRY.
cl_salv_table=>factory( IMPORTING r_salv_table = DATA(lo_alv)
CHANGING t_table = ct_lines ).
lo_alv->display( ).
CATCH cx_salv_msg INTO DATA(lx_error).
MESSAGE lx_error TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA(go_report) = NEW lcl_report( ).
DATA(gt_lines) = go_report->select_summary( iv_from = p_from iv_to = p_to iv_city = p_city ).
go_report->display( CHANGING ct_lines = gt_lines ).
CLASS ltc_report DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CLASS-DATA go_env TYPE REF TO if_osql_test_environment.
CLASS-METHODS class_setup.
CLASS-METHODS class_teardown.
METHODS revenue_per_dealer FOR TESTING.
METHODS city_filter FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create(
i_dependency_list = VALUE #( ( '{{P}}DEALER' ) ( '{{P}}VSALE' ) ) ).
DATA lt_dealer TYPE STANDARD TABLE OF {{p}}dealer WITH EMPTY KEY.
lt_dealer = VALUE #( ( dealer_id = 'D1' dealer_name = 'One' city = 'X' )
( dealer_id = 'D2' dealer_name = 'Two' city = 'Y' ) ).
go_env->insert_test_data( lt_dealer ).
DATA lt_sale TYPE STANDARD TABLE OF {{p}}vsale WITH EMPTY KEY.
lt_sale = VALUE #( ( sale_id = 1 dealer_id = 'D1' sale_date = '20260101' model_code = 'A' price = 10 )
( sale_id = 2 dealer_id = 'D1' sale_date = '20260102' model_code = 'B' price = 30 )
( sale_id = 3 dealer_id = 'D2' sale_date = '20260103' model_code = 'A' price = 5 ) ).
go_env->insert_test_data( lt_sale ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD revenue_per_dealer.
DATA(lt_lines) = NEW lcl_report( )->select_summary(
iv_from = '20260101' iv_to = '20260131' iv_city = '' ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'One' act = lt_lines[ 1 ]-dealer ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_lines[ 1 ]-sales ).
ENDMETHOD.
METHOD city_filter.
DATA(lt_lines) = NEW lcl_report( )->select_summary(
iv_from = '20260101' iv_to = '20260131' iv_city = 'X' ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'B' act = lt_lines[ 1 ]-top_model ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,11 @@
@EndUserText.label : 'Dealership'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}dealer {
key client : abap.clnt not null;
key dealer_id : abap.char(4) not null;
dealer_name : abap.char(30);
city : abap.char(20);
}

View File

@@ -0,0 +1,29 @@
CLASS {{p}}dealer_seed DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
ENDCLASS.
CLASS {{p}}dealer_seed IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DELETE FROM {{p}}vsale.
DELETE FROM {{p}}dealer.
INSERT {{p}}dealer FROM TABLE @( VALUE #(
( dealer_id = 'D01' dealer_name = 'North Motors' city = 'Berlin' )
( dealer_id = 'D02' dealer_name = 'City Cars' city = 'Berlin' )
( dealer_id = 'D03' dealer_name = 'River Motors' city = 'Hamburg' )
( dealer_id = 'D04' dealer_name = 'Lake Cars' city = 'Munich' ) ) ).
INSERT {{p}}vsale FROM TABLE @( VALUE #(
( sale_id = 1 dealer_id = 'D01' sale_date = '20260105' model_code = 'HATCH' price = '12000.00' )
( sale_id = 2 dealer_id = 'D01' sale_date = '20260120' model_code = 'HATCH' price = '8000.00' )
( sale_id = 3 dealer_id = 'D01' sale_date = '20260210' model_code = 'SUV' price = '30000.00' )
( sale_id = 4 dealer_id = 'D01' sale_date = '20260301' model_code = 'VAN' price = '6000.00' )
( sale_id = 5 dealer_id = 'D02' sale_date = '20260110' model_code = 'VAN' price = '5000.00' )
( sale_id = 6 dealer_id = 'D02' sale_date = '20260111' model_code = 'VAN' price = '5000.00' )
( sale_id = 7 dealer_id = 'D02' sale_date = '20260112' model_code = 'HATCH' price = '10000.00' )
( sale_id = 8 dealer_id = 'D02' sale_date = '20260401' model_code = 'SUV' price = '40000.00' )
( sale_id = 9 dealer_id = 'D03' sale_date = '20260214' model_code = 'SUV' price = '56000.00' )
( sale_id = 10 dealer_id = 'D04' sale_date = '20260101' model_code = 'VAN' price = '4000.00' )
( sale_id = 11 dealer_id = 'D04' sale_date = '20251231' model_code = 'SUV' price = '90000.00' ) ) ).
out->write( sy-dbcnt ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,13 @@
@EndUserText.label : 'Vehicle sale'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}vsale {
key client : abap.clnt not null;
key sale_id : abap.int4 not null;
dealer_id : abap.char(4);
sale_date : abap.dats;
model_code : abap.char(10);
price : abap.dec(15,2);
}

View File

@@ -0,0 +1,50 @@
# 1. Goal
A car dealership group sells vehicles through several dealerships. The sales
office needs a summary of the vehicle sales of one period. It uses the summary
to compare the dealerships of the group.
# 2. Open questions
None.
# 3. Context
- Table {{P}}DEALER exists in package $TMP. It contains the dealerships.
Fields: DEALER_ID (CHAR 4, key), DEALER_NAME (CHAR 30), CITY (CHAR 20).
- Table {{P}}VSALE exists in package $TMP. It contains the vehicle sales.
Fields: SALE_ID (INT4, key), DEALER_ID (CHAR 4), SALE_DATE (DATS),
MODEL_CODE (CHAR 10), PRICE (DEC 15,2).
# 4. Contract
- Create the executable program {{P}}DEALER_SUM in package $TMP.
- Selection screen:
- Parameter P_FROM, type DATS, mandatory: the first sale date to include.
- Parameter P_TO, type DATS, mandatory: the last sale date to include.
- Parameter P_CITY, type {{P}}DEALER-CITY, optional: the city of the
dealership.
- Show the result with CL_SALV_TABLE. The output table has these columns with
these names: DEALER, CITY, SALES, REVENUE, TOP_MODEL.
# 5. Business rules
1. Include a sale only if its SALE_DATE is on or after P_FROM and on or before
P_TO.
2. If P_CITY is initial, include the sales of all dealerships. If P_CITY is not
initial, include only the sales of dealerships whose CITY equals P_CITY.
3. Show one line for each dealership that has at least one included sale.
4. DEALER is the name of the dealership. CITY is the city of the dealership.
5. SALES is the number of included sales of the dealership.
6. REVENUE is the sum of the PRICE values of the included sales.
7. TOP_MODEL is the model code with the highest total price in the dealership.
If two model codes of the dealership have the same total price, TOP_MODEL is
the code that comes first in ascending alphabetical order.
8. Sort the lines by REVENUE, the highest revenue first. If two dealerships have
the same revenue, sort them by DEALER in ascending order.
# 6. Constraints
- Release target: 8.16.
- Coding standards: Clean ABAP. A method has fewer than 40 statements. Do not
access the database inside a loop.
- Out of scope: do not change {{P}}DEALER and {{P}}VSALE.
# 7. Acceptance
- The program is active and has no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests as local test classes in the program.

View File

@@ -0,0 +1,68 @@
{
"id": "G1153",
"category": "C",
"object_type": "PROG",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "TABL",
"name": "{{P}}DEALER",
"file": "seed/dealer.tabl.asabap",
"description": "Dealerships of the group"
},
{
"type": "TABL",
"name": "{{P}}VSALE",
"file": "seed/vsale.tabl.asabap",
"description": "Vehicle sales"
},
{
"type": "CLAS",
"name": "{{P}}DEALER_SEED",
"file": "seed/dealer_seed.clas.abap",
"description": "Seed data for the two tables",
"run": true
}
],
"contract": [
{
"type": "PROG",
"name": "{{P}}DEALER_SUM",
"parameters": [
"p_from",
"p_to",
"p_city"
]
}
],
"out_of_scope": [
"{{P}}DEALER",
"{{P}}VSALE"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}DEALER_HIDDEN",
"file": "hidden/dealer_hidden.clas.abap",
"description": "Hidden tests for the dealership summary"
}
],
"reference": [
{
"type": "PROG",
"name": "{{P}}DEALER_SUM",
"file": "reference/dealer_sum.prog.abap",
"description": "Sales summary per dealership"
}
],
"craft_checks": [
"db_operation_in_loop",
"method_length"
]
}