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,37 @@
{
"id": "G1126",
"pool": "train",
"object_type": "PROG",
"category": "G",
"attempts": [
{
"stage": "bundle",
"errors": [
"seed/vet_seed.clas.abap line 9: syntax error for release v702 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"INSERT\"",
"hidden/vet_hidden.clas.abap line 48: syntax error for release v702 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"ASSIGN\"",
"hidden/vet_hidden.clas.abap line 49: syntax error for release v702 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"ASSIGN\"",
"hidden/vet_hidden.clas.abap line 51: syntax error for release v702 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"rv_value\"",
"hidden/vet_hidden.clas.abap line 79: syntax error for release v702 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"DATA\""
],
"by_check": {
"abaplint": 5
}
},
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "validate",
"oracle": 80.5,
"null": 0
}
],
"accepted": false
}

View File

@@ -0,0 +1,135 @@
CLASS {{p}}vet_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
TYPES tt_anim TYPE RANGE OF {{p}}treat-animal.
METHODS run
IMPORTING iv_from TYPE d
it_anim TYPE tt_anim OPTIONAL
RETURNING VALUE(rr_data) TYPE REF TO data.
METHODS lines_of
IMPORTING ir_data TYPE REF TO data
RETURNING VALUE(rv_lines) TYPE i.
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 all_animals FOR TESTING.
METHODS sorted_by_total FOR TESTING.
METHODS totals_and_counts FOR TESTING.
METHODS frequent_flag FOR TESTING.
METHODS animal_filter FOR TESTING.
METHODS date_filter FOR TESTING.
ENDCLASS.
CLASS {{p}}vet_hidden IMPLEMENTATION.
METHOD run.
cl_salv_bs_runtime_info=>set( display = abap_false metadata = abap_false data = abap_true ).
SUBMIT {{p}}vet_sum WITH p_from = iv_from WITH s_anim IN it_anim 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.
FIELD-SYMBOLS <ls_line> TYPE any.
FIELD-SYMBOLS <lv_value> TYPE any.
DATA lv_str TYPE string.
ASSIGN ir_data->* TO <lt_data>.
READ TABLE <lt_data> INDEX iv_row ASSIGNING <ls_line>.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'Row missing' ).
ASSIGN COMPONENT iv_col OF STRUCTURE <ls_line> TO <lv_value>.
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'Column missing' ).
lv_str = <lv_value>.
CONDENSE lv_str.
rv_value = lv_str.
ENDMETHOD.
METHOD all_animals.
DATA lr_data TYPE REF TO data.
DATA lv_lines TYPE i.
lr_data = run( '20260101' ).
lv_lines = lines_of( lr_data ).
cl_abap_unit_assert=>assert_equals( exp = 3 act = lv_lines ).
ENDMETHOD.
METHOD sorted_by_total.
DATA lr_data TYPE REF TO data.
DATA lv_value TYPE string.
lr_data = run( '20260101' ).
lv_value = value_of( ir_data = lr_data iv_row = 1 iv_col = 'ANIMAL' ).
cl_abap_unit_assert=>assert_equals( exp = 'CAT' act = lv_value ).
lv_value = value_of( ir_data = lr_data iv_row = 3 iv_col = 'ANIMAL' ).
cl_abap_unit_assert=>assert_equals( exp = 'BIRD' act = lv_value ).
ENDMETHOD.
METHOD totals_and_counts.
DATA lr_data TYPE REF TO data.
DATA lv_value TYPE string.
lr_data = run( '20260101' ).
lv_value = value_of( ir_data = lr_data iv_row = 1 iv_col = 'TOTAL' ).
cl_abap_unit_assert=>assert_equals( exp = '340.00' act = lv_value ).
lv_value = value_of( ir_data = lr_data iv_row = 1 iv_col = 'CNT' ).
cl_abap_unit_assert=>assert_equals( exp = '2' act = lv_value ).
lv_value = value_of( ir_data = lr_data iv_row = 2 iv_col = 'TOTAL' ).
cl_abap_unit_assert=>assert_equals( exp = '250.00' act = lv_value ).
lv_value = value_of( ir_data = lr_data iv_row = 2 iv_col = 'CNT' ).
cl_abap_unit_assert=>assert_equals( exp = '3' act = lv_value ).
ENDMETHOD.
METHOD frequent_flag.
DATA lr_data TYPE REF TO data.
DATA lv_value TYPE string.
lr_data = run( '20260101' ).
lv_value = value_of( ir_data = lr_data iv_row = 2 iv_col = 'FREQUENT' ).
cl_abap_unit_assert=>assert_equals( exp = 'X' act = lv_value ).
lv_value = value_of( ir_data = lr_data iv_row = 1 iv_col = 'FREQUENT' ).
cl_abap_unit_assert=>assert_equals( exp = '' act = lv_value ).
ENDMETHOD.
METHOD animal_filter.
DATA lr_data TYPE REF TO data.
DATA lv_lines TYPE i.
DATA lv_value TYPE string.
DATA lt_anim TYPE tt_anim.
DATA ls_anim LIKE LINE OF lt_anim.
CLEAR ls_anim.
ls_anim-sign = 'I'.
ls_anim-option = 'EQ'.
ls_anim-low = 'DOG'.
APPEND ls_anim TO lt_anim.
lr_data = run( iv_from = '20260101' it_anim = lt_anim ).
lv_lines = lines_of( lr_data ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_lines ).
lv_value = value_of( ir_data = lr_data iv_row = 1 iv_col = 'TOTAL' ).
cl_abap_unit_assert=>assert_equals( exp = '250.00' act = lv_value ).
ENDMETHOD.
METHOD date_filter.
DATA lr_data TYPE REF TO data.
DATA lv_lines TYPE i.
lr_data = run( '20260210' ).
lv_lines = lines_of( lr_data ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_lines ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,42 @@
{
"task": "T15",
"mutants": [
{
"object": "{{P}}VET_SUM",
"mutant": "line 43: >= -> < (rel)",
"status": "killed",
"hidden": "0/6",
"failed_tests": [
"ALL_ANIMALS",
"SORTED_BY_TOTAL",
"TOTALS_AND_COUNTS",
"FREQUENT_FLAG",
"ANIMAL_FILTER",
"DATE_FILTER"
]
},
{
"object": "{{P}}VET_SUM",
"mutant": "line 68: >= -> > (rel)",
"status": "killed",
"hidden": "5/6",
"failed_tests": [
"FREQUENT_FLAG"
]
},
{
"object": "{{P}}VET_SUM",
"mutant": "line 73: DESCENDING -> ASCENDING (sort)",
"status": "killed",
"hidden": "4/6",
"failed_tests": [
"SORTED_BY_TOTAL",
"TOTALS_AND_COUNTS"
]
}
],
"valid": 3,
"killed": 3,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,203 @@
REPORT {{p}}vet_sum.
TYPES: BEGIN OF ty_treat,
treat_date TYPE {{p}}treat-treat_date,
animal TYPE {{p}}treat-animal,
fee TYPE {{p}}treat-fee,
END OF ty_treat.
TYPES tt_treat TYPE STANDARD TABLE OF ty_treat.
TYPES: BEGIN OF ty_line,
animal TYPE {{p}}treat-animal,
total TYPE {{p}}treat-fee,
cnt TYPE i,
frequent TYPE c LENGTH 1,
END OF ty_line.
TYPES tt_line TYPE STANDARD TABLE OF ty_line.
TYPES tt_anim TYPE RANGE OF {{p}}treat-animal.
DATA gv_animal TYPE {{p}}treat-animal.
PARAMETERS p_from TYPE d OBLIGATORY.
SELECT-OPTIONS s_anim FOR gv_animal.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
METHODS read_treatments
IMPORTING iv_from TYPE d
it_anim TYPE tt_anim
EXPORTING et_treat TYPE tt_treat.
METHODS build_lines
IMPORTING it_treat TYPE tt_treat
EXPORTING et_lines TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD read_treatments.
SELECT treat_date animal fee
FROM {{p}}treat
INTO TABLE et_treat
WHERE treat_date >= iv_from
AND animal IN it_anim.
ENDMETHOD.
METHOD build_lines.
DATA ls_treat TYPE ty_treat.
DATA ls_line TYPE ty_line.
FIELD-SYMBOLS <ls_line> TYPE ty_line.
CLEAR et_lines.
LOOP AT it_treat INTO ls_treat.
READ TABLE et_lines ASSIGNING <ls_line> WITH KEY animal = ls_treat-animal.
IF sy-subrc = 0.
<ls_line>-total = <ls_line>-total + ls_treat-fee.
<ls_line>-cnt = <ls_line>-cnt + 1.
ELSE.
CLEAR ls_line.
ls_line-animal = ls_treat-animal.
ls_line-total = ls_treat-fee.
ls_line-cnt = 1.
INSERT ls_line INTO TABLE et_lines.
ENDIF.
ENDLOOP.
LOOP AT et_lines ASSIGNING <ls_line>.
IF <ls_line>-cnt >= 3.
<ls_line>-frequent = 'X'.
ENDIF.
ENDLOOP.
SORT et_lines BY total DESCENDING.
ENDMETHOD.
METHOD display.
DATA lo_alv TYPE REF TO cl_salv_table.
DATA lx_msg TYPE REF TO cx_salv_msg.
TRY.
cl_salv_table=>factory(
IMPORTING r_salv_table = lo_alv
CHANGING t_table = ct_lines ).
lo_alv->display( ).
CATCH cx_salv_msg INTO lx_msg.
MESSAGE lx_msg TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
ENDMETHOD.
ENDCLASS.
DATA: go_report TYPE REF TO lcl_report,
gt_treat TYPE tt_treat,
gt_lines TYPE tt_line.
START-OF-SELECTION.
CREATE OBJECT go_report.
go_report->read_treatments( EXPORTING iv_from = p_from
it_anim = s_anim[]
IMPORTING et_treat = gt_treat ).
go_report->build_lines( EXPORTING it_treat = gt_treat
IMPORTING et_lines = gt_lines ).
go_report->display( CHANGING ct_lines = gt_lines ).
CLASS ltc_report DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA mt_treat TYPE tt_treat.
METHODS add_treatment
IMPORTING iv_date TYPE d
iv_animal TYPE {{p}}treat-animal
iv_fee TYPE {{p}}treat-fee.
METHODS aggregate
EXPORTING et_lines TYPE tt_line.
METHODS totals_per_animal FOR TESTING.
METHODS frequent_flag FOR TESTING.
METHODS sorted_by_total FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD add_treatment.
DATA ls_treat TYPE ty_treat.
ls_treat-treat_date = iv_date.
ls_treat-animal = iv_animal.
ls_treat-fee = iv_fee.
APPEND ls_treat TO mt_treat.
ENDMETHOD.
METHOD aggregate.
DATA lo_report TYPE REF TO lcl_report.
CREATE OBJECT lo_report.
lo_report->build_lines( EXPORTING it_treat = mt_treat
IMPORTING et_lines = et_lines ).
ENDMETHOD.
METHOD totals_per_animal.
DATA lt_lines TYPE tt_line.
DATA ls_line TYPE ty_line.
DATA lv_expected TYPE {{p}}treat-fee.
DATA lv_animal TYPE {{p}}treat-animal.
add_treatment( iv_date = '20260101' iv_animal = 'DOG' iv_fee = '10.00' ).
add_treatment( iv_date = '20260102' iv_animal = 'DOG' iv_fee = '5.00' ).
add_treatment( iv_date = '20260101' iv_animal = 'CAT' iv_fee = '40.00' ).
aggregate( IMPORTING et_lines = lt_lines ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
READ TABLE lt_lines INTO ls_line INDEX 1.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
lv_animal = 'CAT'.
cl_abap_unit_assert=>assert_equals( exp = lv_animal act = ls_line-animal ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = ls_line-cnt ).
lv_expected = '40.00'.
cl_abap_unit_assert=>assert_equals( exp = lv_expected act = ls_line-total ).
READ TABLE lt_lines INTO ls_line INDEX 2.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
lv_animal = 'DOG'.
cl_abap_unit_assert=>assert_equals( exp = lv_animal act = ls_line-animal ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = ls_line-cnt ).
lv_expected = '15.00'.
cl_abap_unit_assert=>assert_equals( exp = lv_expected act = ls_line-total ).
ENDMETHOD.
METHOD frequent_flag.
DATA lt_lines TYPE tt_line.
DATA ls_line TYPE ty_line.
DATA lv_animal TYPE {{p}}treat-animal.
add_treatment( iv_date = '20260101' iv_animal = 'DOG' iv_fee = '10.00' ).
add_treatment( iv_date = '20260102' iv_animal = 'DOG' iv_fee = '10.00' ).
add_treatment( iv_date = '20260103' iv_animal = 'DOG' iv_fee = '10.00' ).
add_treatment( iv_date = '20260101' iv_animal = 'CAT' iv_fee = '10.00' ).
aggregate( IMPORTING et_lines = lt_lines ).
lv_animal = 'DOG'.
READ TABLE lt_lines INTO ls_line WITH KEY animal = lv_animal.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
cl_abap_unit_assert=>assert_equals( exp = 'X' act = ls_line-frequent ).
lv_animal = 'CAT'.
READ TABLE lt_lines INTO ls_line WITH KEY animal = lv_animal.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
cl_abap_unit_assert=>assert_initial( act = ls_line-frequent ).
ENDMETHOD.
METHOD sorted_by_total.
DATA lt_lines TYPE tt_line.
DATA ls_line TYPE ty_line.
DATA lv_animal TYPE {{p}}treat-animal.
add_treatment( iv_date = '20260101' iv_animal = 'DOG' iv_fee = '10.00' ).
add_treatment( iv_date = '20260101' iv_animal = 'CAT' iv_fee = '40.00' ).
add_treatment( iv_date = '20260101' iv_animal = 'BIRD' iv_fee = '25.00' ).
aggregate( IMPORTING et_lines = lt_lines ).
READ TABLE lt_lines INTO ls_line INDEX 1.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
lv_animal = 'CAT'.
cl_abap_unit_assert=>assert_equals( exp = lv_animal act = ls_line-animal ).
READ TABLE lt_lines INTO ls_line INDEX 3.
cl_abap_unit_assert=>assert_subrc( exp = 0 ).
lv_animal = 'BIRD'.
cl_abap_unit_assert=>assert_equals( exp = lv_animal act = ls_line-animal ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,12 @@
@EndUserText.label : 'Veterinary treatments'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}treat {
key client : abap.clnt not null;
key treat_id : abap.int4 not null;
treat_date : abap.dats;
animal : abap.char(10);
fee : abap.dec(15,2);
}

View File

@@ -0,0 +1,66 @@
CLASS {{p}}vet_seed DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
ENDCLASS.
CLASS {{p}}vet_seed IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DATA lt_treat TYPE STANDARD TABLE OF {{p}}treat.
DATA ls_treat TYPE {{p}}treat.
DELETE FROM {{p}}treat.
CLEAR ls_treat.
ls_treat-treat_id = 1.
ls_treat-treat_date = '20260105'.
ls_treat-animal = 'DOG'.
ls_treat-fee = '120.00'.
APPEND ls_treat TO lt_treat.
CLEAR ls_treat.
ls_treat-treat_id = 2.
ls_treat-treat_date = '20260120'.
ls_treat-animal = 'DOG'.
ls_treat-fee = '80.00'.
APPEND ls_treat TO lt_treat.
CLEAR ls_treat.
ls_treat-treat_id = 3.
ls_treat-treat_date = '20260201'.
ls_treat-animal = 'DOG'.
ls_treat-fee = '50.00'.
APPEND ls_treat TO lt_treat.
CLEAR ls_treat.
ls_treat-treat_id = 4.
ls_treat-treat_date = '20260110'.
ls_treat-animal = 'CAT'.
ls_treat-fee = '300.00'.
APPEND ls_treat TO lt_treat.
CLEAR ls_treat.
ls_treat-treat_id = 5.
ls_treat-treat_date = '20260215'.
ls_treat-animal = 'CAT'.
ls_treat-fee = '40.00'.
APPEND ls_treat TO lt_treat.
CLEAR ls_treat.
ls_treat-treat_id = 6.
ls_treat-treat_date = '20251220'.
ls_treat-animal = 'BIRD'.
ls_treat-fee = '500.00'.
APPEND ls_treat TO lt_treat.
CLEAR ls_treat.
ls_treat-treat_id = 7.
ls_treat-treat_date = '20260301'.
ls_treat-animal = 'BIRD'.
ls_treat-fee = '25.00'.
APPEND ls_treat TO lt_treat.
INSERT {{p}}treat FROM TABLE lt_treat.
out->write( sy-dbcnt ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,45 @@
# 1. Goal
Show the treatment fee of each animal in an ALV list. The practice manager uses
the list to compare the animals for a period.
# 2. Open questions
None.
# 3. Context
- The table {{P}}TREAT exists in package $TMP. It contains data.
Fields: TREAT_ID (INT4, key), TREAT_DATE (DATS), ANIMAL (CHAR 10),
FEE (DEC 15,2).
- The practice writes one row for each treatment.
# 4. Contract
- Create the executable program {{P}}VET_SUM in package $TMP.
- Selection screen:
- Parameter P_FROM, type DATS, mandatory: the first treatment date to include.
- Select-option S_ANIM for the animal.
- Show the result with CL_SALV_TABLE. The output table has these columns with
these names:
- ANIMAL: the animal.
- TOTAL: the sum of the fees.
- CNT: the number of the treatments.
- FREQUENT: 'X' if CNT is 3 or more, otherwise empty.
# 5. Business rules
1. Include a treatment only if TREAT_DATE is on or after P_FROM and ANIMAL is
in S_ANIM.
2. Show one line for each animal that has at least one included treatment.
3. TOTAL is the sum of the FEE of the included treatments of the animal.
4. CNT is the number of the included treatments of the animal.
5. FREQUENT is 'X' if CNT is 3 or more. Otherwise FREQUENT is empty.
6. Sort the lines by TOTAL, the highest total first.
# 6. Constraints
- Release target: 7.02. Use only ABAP syntax that release 7.02 supports. Do not
use inline declarations, constructor expressions, string templates, table
expressions, the NEW operator, or the character '@' in ABAP SQL.
- Coding standards: Clean ABAP. Read the table with one database access.
- Out of scope: do not change the table {{P}}TREAT.
# 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,60 @@
{
"id": "G1126",
"category": "G",
"object_type": "PROG",
"difficulty": 2,
"release_target": "v702",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [
{
"type": "TABL",
"name": "{{P}}TREAT",
"file": "seed/treat.tabl.asabap",
"description": "Veterinary treatments"
},
{
"type": "CLAS",
"name": "{{P}}VET_SEED",
"file": "seed/vet_seed.clas.abap",
"description": "Seed data for {{P}}TREAT",
"run": true
}
],
"contract": [
{
"type": "PROG",
"name": "{{P}}VET_SUM",
"parameters": [
"p_from",
"s_anim"
]
}
],
"out_of_scope": [
"{{P}}TREAT"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}VET_HIDDEN",
"file": "hidden/vet_hidden.clas.abap",
"description": "Hidden tests for {{P}}VET_SUM"
}
],
"reference": [
{
"type": "PROG",
"name": "{{P}}VET_SUM",
"file": "reference/vet_sum.prog.abap",
"description": "Treatment fee per animal"
}
],
"craft_checks": [
"db_operation_in_loop",
"method_length"
]
}