Pipeline controller: plan 2 (hard +, error +50 %), backlog throttle, 2 trajectory workers, stop rules, summaries every 50; budget reserve

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 13:35:54 +02:00
parent 1c4667a0fc
commit 13360292dd
781 changed files with 50211 additions and 22 deletions

View File

@@ -0,0 +1,96 @@
CLASS {{p}}fish_auction DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_species TYPE c LENGTH 10.
TYPES ty_boat_id TYPE c LENGTH 10.
TYPES:
BEGIN OF ty_catch,
boat_id TYPE ty_boat_id,
species TYPE ty_species,
weight_kg TYPE i,
END OF ty_catch.
TYPES tt_catch TYPE STANDARD TABLE OF ty_catch WITH EMPTY KEY.
TYPES:
BEGIN OF ty_summary,
species TYPE ty_species,
total_weight TYPE i,
boat_count TYPE i,
END OF ty_summary.
TYPES tt_summary TYPE STANDARD TABLE OF ty_summary WITH EMPTY KEY.
METHODS summarize
IMPORTING it_catch TYPE tt_catch
RETURNING VALUE(rt_summary) TYPE tt_summary.
METHODS best_species
IMPORTING it_catch TYPE tt_catch
RETURNING VALUE(rv_species) TYPE ty_species.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_boat_species,
species TYPE ty_species,
boat_id TYPE ty_boat_id,
END OF ty_boat_species,
tt_boat_species TYPE HASHED TABLE OF ty_boat_species
WITH UNIQUE KEY species boat_id.
METHODS species_key
IMPORTING iv_species TYPE ty_species
RETURNING VALUE(rv_species) TYPE ty_species.
ENDCLASS.
CLASS {{p}}fish_auction IMPLEMENTATION.
METHOD summarize.
DATA lt_total TYPE SORTED TABLE OF ty_summary WITH UNIQUE KEY species.
DATA lt_boat_species TYPE tt_boat_species.
DATA lv_species TYPE ty_species.
LOOP AT it_catch INTO DATA(ls_catch).
lv_species = species_key( ls_catch-species ).
IF lv_species IS INITIAL AND ls_catch-weight_kg <= 0.
CONTINUE.
ENDIF.
READ TABLE lt_total WITH TABLE KEY species = lv_species
ASSIGNING FIELD-SYMBOL(<ls_total>).
IF sy-subrc <> 0.
INSERT VALUE #( species = lv_species ) INTO TABLE lt_total.
READ TABLE lt_total WITH TABLE KEY species = lv_species
ASSIGNING <ls_total>.
ENDIF.
<ls_total>-total_weight = <ls_total>-total_weight + ls_catch-weight_kg.
INSERT VALUE #( species = lv_species boat_id = ls_catch-boat_id )
INTO TABLE lt_boat_species.
IF sy-subrc = 0.
<ls_total>-boat_count = <ls_total>-boat_count + 1.
ENDIF.
ENDLOOP.
rt_summary = lt_total.
ENDMETHOD.
METHOD best_species.
DATA(lt_summary) = summarize( it_catch ).
DATA lv_best_weight TYPE i.
LOOP AT lt_summary INTO DATA(ls_summary).
IF ls_summary-total_weight > lv_best_weight.
lv_best_weight = ls_summary-total_weight.
rv_species = ls_summary-species.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD species_key.
DATA lv_species TYPE ty_species.
lv_species = iv_species.
SHIFT lv_species LEFT DELETING LEADING space.
rv_species = to_upper( lv_species ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,96 @@
CLASS {{p}}fish_auction DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_species TYPE c LENGTH 10.
TYPES ty_boat_id TYPE c LENGTH 10.
TYPES:
BEGIN OF ty_catch,
boat_id TYPE ty_boat_id,
species TYPE ty_species,
weight_kg TYPE i,
END OF ty_catch.
TYPES tt_catch TYPE STANDARD TABLE OF ty_catch WITH EMPTY KEY.
TYPES:
BEGIN OF ty_summary,
species TYPE ty_species,
total_weight TYPE i,
boat_count TYPE i,
END OF ty_summary.
TYPES tt_summary TYPE STANDARD TABLE OF ty_summary WITH EMPTY KEY.
METHODS summarize
IMPORTING it_catch TYPE tt_catch
RETURNING VALUE(rt_summary) TYPE tt_summary.
METHODS best_species
IMPORTING it_catch TYPE tt_catch
RETURNING VALUE(rv_species) TYPE ty_species.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_boat_species,
species TYPE ty_species,
boat_id TYPE ty_boat_id,
END OF ty_boat_species,
tt_boat_species TYPE HASHED TABLE OF ty_boat_species
WITH UNIQUE KEY species boat_id.
METHODS species_key
IMPORTING iv_species TYPE ty_species
RETURNING VALUE(rv_species) TYPE ty_species.
ENDCLASS.
CLASS {{p}}fish_auction IMPLEMENTATION.
METHOD summarize.
DATA lt_total TYPE SORTED TABLE OF ty_summary WITH UNIQUE KEY species.
DATA lt_boat_species TYPE tt_boat_species.
DATA lv_species TYPE ty_species.
LOOP AT it_catch INTO DATA(ls_catch).
lv_species = species_key( ls_catch-species ).
IF lv_species IS INITIAL OR ls_catch-weight_kg > 0.
CONTINUE.
ENDIF.
READ TABLE lt_total WITH TABLE KEY species = lv_species
ASSIGNING FIELD-SYMBOL(<ls_total>).
IF sy-subrc <> 0.
INSERT VALUE #( species = lv_species ) INTO TABLE lt_total.
READ TABLE lt_total WITH TABLE KEY species = lv_species
ASSIGNING <ls_total>.
ENDIF.
<ls_total>-total_weight = <ls_total>-total_weight + ls_catch-weight_kg.
INSERT VALUE #( species = lv_species boat_id = ls_catch-boat_id )
INTO TABLE lt_boat_species.
IF sy-subrc = 0.
<ls_total>-boat_count = <ls_total>-boat_count + 1.
ENDIF.
ENDLOOP.
rt_summary = lt_total.
ENDMETHOD.
METHOD best_species.
DATA(lt_summary) = summarize( it_catch ).
DATA lv_best_weight TYPE i.
LOOP AT lt_summary INTO DATA(ls_summary).
IF ls_summary-total_weight > lv_best_weight.
lv_best_weight = ls_summary-total_weight.
rv_species = ls_summary-species.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD species_key.
DATA lv_species TYPE ty_species.
lv_species = iv_species.
SHIFT lv_species LEFT DELETING LEADING space.
rv_species = to_upper( lv_species ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,96 @@
CLASS {{p}}fish_auction DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_species TYPE c LENGTH 10.
TYPES ty_boat_id TYPE c LENGTH 10.
TYPES:
BEGIN OF ty_catch,
boat_id TYPE ty_boat_id,
species TYPE ty_species,
weight_kg TYPE i,
END OF ty_catch.
TYPES tt_catch TYPE STANDARD TABLE OF ty_catch WITH EMPTY KEY.
TYPES:
BEGIN OF ty_summary,
species TYPE ty_species,
total_weight TYPE i,
boat_count TYPE i,
END OF ty_summary.
TYPES tt_summary TYPE STANDARD TABLE OF ty_summary WITH EMPTY KEY.
METHODS summarize
IMPORTING it_catch TYPE tt_catch
RETURNING VALUE(rt_summary) TYPE tt_summary.
METHODS best_species
IMPORTING it_catch TYPE tt_catch
RETURNING VALUE(rv_species) TYPE ty_species.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_boat_species,
species TYPE ty_species,
boat_id TYPE ty_boat_id,
END OF ty_boat_species,
tt_boat_species TYPE HASHED TABLE OF ty_boat_species
WITH UNIQUE KEY species boat_id.
METHODS species_key
IMPORTING iv_species TYPE ty_species
RETURNING VALUE(rv_species) TYPE ty_species.
ENDCLASS.
CLASS {{p}}fish_auction IMPLEMENTATION.
METHOD summarize.
DATA lt_total TYPE SORTED TABLE OF ty_summary WITH UNIQUE KEY species.
DATA lt_boat_species TYPE tt_boat_species.
DATA lv_species TYPE ty_species.
LOOP AT it_catch INTO DATA(ls_catch).
lv_species = species_key( ls_catch-species ).
IF lv_species IS INITIAL OR ls_catch-weight_kg <= 0.
CONTINUE.
ENDIF.
READ TABLE lt_total WITH TABLE KEY species = lv_species
ASSIGNING FIELD-SYMBOL(<ls_total>).
IF sy-subrc <> 0.
INSERT VALUE #( species = lv_species ) INTO TABLE lt_total.
READ TABLE lt_total WITH TABLE KEY species = lv_species
ASSIGNING <ls_total>.
ENDIF.
<ls_total>-total_weight = <ls_total>-total_weight - ls_catch-weight_kg.
INSERT VALUE #( species = lv_species boat_id = ls_catch-boat_id )
INTO TABLE lt_boat_species.
IF sy-subrc = 0.
<ls_total>-boat_count = <ls_total>-boat_count + 1.
ENDIF.
ENDLOOP.
rt_summary = lt_total.
ENDMETHOD.
METHOD best_species.
DATA(lt_summary) = summarize( it_catch ).
DATA lv_best_weight TYPE i.
LOOP AT lt_summary INTO DATA(ls_summary).
IF ls_summary-total_weight > lv_best_weight.
lv_best_weight = ls_summary-total_weight.
rv_species = ls_summary-species.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD species_key.
DATA lv_species TYPE ty_species.
lv_species = iv_species.
SHIFT lv_species LEFT DELETING LEADING space.
rv_species = to_upper( lv_species ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,96 @@
CLASS {{p}}fish_auction DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_species TYPE c LENGTH 10.
TYPES ty_boat_id TYPE c LENGTH 10.
TYPES:
BEGIN OF ty_catch,
boat_id TYPE ty_boat_id,
species TYPE ty_species,
weight_kg TYPE i,
END OF ty_catch.
TYPES tt_catch TYPE STANDARD TABLE OF ty_catch WITH EMPTY KEY.
TYPES:
BEGIN OF ty_summary,
species TYPE ty_species,
total_weight TYPE i,
boat_count TYPE i,
END OF ty_summary.
TYPES tt_summary TYPE STANDARD TABLE OF ty_summary WITH EMPTY KEY.
METHODS summarize
IMPORTING it_catch TYPE tt_catch
RETURNING VALUE(rt_summary) TYPE tt_summary.
METHODS best_species
IMPORTING it_catch TYPE tt_catch
RETURNING VALUE(rv_species) TYPE ty_species.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_boat_species,
species TYPE ty_species,
boat_id TYPE ty_boat_id,
END OF ty_boat_species,
tt_boat_species TYPE HASHED TABLE OF ty_boat_species
WITH UNIQUE KEY species boat_id.
METHODS species_key
IMPORTING iv_species TYPE ty_species
RETURNING VALUE(rv_species) TYPE ty_species.
ENDCLASS.
CLASS {{p}}fish_auction IMPLEMENTATION.
METHOD summarize.
DATA lt_total TYPE SORTED TABLE OF ty_summary WITH UNIQUE KEY species.
DATA lt_boat_species TYPE tt_boat_species.
DATA lv_species TYPE ty_species.
LOOP AT it_catch INTO DATA(ls_catch).
lv_species = species_key( ls_catch-species ).
IF lv_species IS INITIAL OR ls_catch-weight_kg <= 0.
CONTINUE.
ENDIF.
READ TABLE lt_total WITH TABLE KEY species = lv_species
ASSIGNING FIELD-SYMBOL(<ls_total>).
IF sy-subrc <> 0.
INSERT VALUE #( species = lv_species ) INTO TABLE lt_total.
READ TABLE lt_total WITH TABLE KEY species = lv_species
ASSIGNING <ls_total>.
ENDIF.
<ls_total>-total_weight = <ls_total>-total_weight + ls_catch-weight_kg.
INSERT VALUE #( species = lv_species boat_id = ls_catch-boat_id )
INTO TABLE lt_boat_species.
IF sy-subrc = 0.
<ls_total>-boat_count = <ls_total>-boat_count - 1.
ENDIF.
ENDLOOP.
rt_summary = lt_total.
ENDMETHOD.
METHOD best_species.
DATA(lt_summary) = summarize( it_catch ).
DATA lv_best_weight TYPE i.
LOOP AT lt_summary INTO DATA(ls_summary).
IF ls_summary-total_weight > lv_best_weight.
lv_best_weight = ls_summary-total_weight.
rv_species = ls_summary-species.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD species_key.
DATA lv_species TYPE ty_species.
lv_species = iv_species.
SHIFT lv_species LEFT DELETING LEADING space.
rv_species = to_upper( lv_species ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,96 @@
CLASS {{p}}fish_auction DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_species TYPE c LENGTH 10.
TYPES ty_boat_id TYPE c LENGTH 10.
TYPES:
BEGIN OF ty_catch,
boat_id TYPE ty_boat_id,
species TYPE ty_species,
weight_kg TYPE i,
END OF ty_catch.
TYPES tt_catch TYPE STANDARD TABLE OF ty_catch WITH EMPTY KEY.
TYPES:
BEGIN OF ty_summary,
species TYPE ty_species,
total_weight TYPE i,
boat_count TYPE i,
END OF ty_summary.
TYPES tt_summary TYPE STANDARD TABLE OF ty_summary WITH EMPTY KEY.
METHODS summarize
IMPORTING it_catch TYPE tt_catch
RETURNING VALUE(rt_summary) TYPE tt_summary.
METHODS best_species
IMPORTING it_catch TYPE tt_catch
RETURNING VALUE(rv_species) TYPE ty_species.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_boat_species,
species TYPE ty_species,
boat_id TYPE ty_boat_id,
END OF ty_boat_species,
tt_boat_species TYPE HASHED TABLE OF ty_boat_species
WITH UNIQUE KEY species boat_id.
METHODS species_key
IMPORTING iv_species TYPE ty_species
RETURNING VALUE(rv_species) TYPE ty_species.
ENDCLASS.
CLASS {{p}}fish_auction IMPLEMENTATION.
METHOD summarize.
DATA lt_total TYPE SORTED TABLE OF ty_summary WITH UNIQUE KEY species.
DATA lt_boat_species TYPE tt_boat_species.
DATA lv_species TYPE ty_species.
LOOP AT it_catch INTO DATA(ls_catch).
lv_species = species_key( ls_catch-species ).
IF lv_species IS INITIAL OR ls_catch-weight_kg <= 0.
CONTINUE.
ENDIF.
READ TABLE lt_total WITH TABLE KEY species = lv_species
ASSIGNING FIELD-SYMBOL(<ls_total>).
IF sy-subrc <> 0.
INSERT VALUE #( species = lv_species ) INTO TABLE lt_total.
READ TABLE lt_total WITH TABLE KEY species = lv_species
ASSIGNING <ls_total>.
ENDIF.
<ls_total>-total_weight = <ls_total>-total_weight + ls_catch-weight_kg.
INSERT VALUE #( species = lv_species boat_id = ls_catch-boat_id )
INTO TABLE lt_boat_species.
IF sy-subrc = 0.
<ls_total>-boat_count = <ls_total>-boat_count + 1.
ENDIF.
ENDLOOP.
rt_summary = lt_total.
ENDMETHOD.
METHOD best_species.
DATA(lt_summary) = summarize( it_catch ).
DATA lv_best_weight TYPE i.
LOOP AT lt_summary INTO DATA(ls_summary).
IF ls_summary-total_weight <= lv_best_weight.
lv_best_weight = ls_summary-total_weight.
rv_species = ls_summary-species.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD species_key.
DATA lv_species TYPE ty_species.
lv_species = iv_species.
SHIFT lv_species LEFT DELETING LEADING space.
rv_species = to_upper( lv_species ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,29 @@
{
"id": "G1009",
"pool": "train",
"object_type": "CLAS",
"category": "C",
"attempts": [
{
"stage": "validate",
"oracle": 0,
"null": 0
},
{
"stage": "validate",
"oracle": 63.4,
"null": 0
},
{
"stage": "validate",
"oracle": 100.0,
"null": 0,
"mutation": {
"valid": 5,
"killed": 5,
"ok": true
}
}
],
"accepted": true
}

View File

@@ -0,0 +1,140 @@
CLASS {{p}}t31_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA mo_cut TYPE REF TO {{p}}fish_auction.
METHODS setup.
METHODS sums_two_species FOR TESTING.
METHODS counts_distinct_boats FOR TESTING.
METHODS ignores_zero_weight FOR TESTING.
METHODS ignores_blank_species FOR TESTING.
METHODS trims_and_uppercases FOR TESTING.
METHODS sorts_by_species FOR TESTING.
METHODS empty_input FOR TESTING.
METHODS all_entries_invalid FOR TESTING.
METHODS best_species_highest FOR TESTING.
METHODS best_species_tie FOR TESTING.
METHODS best_species_none FOR TESTING.
ENDCLASS.
CLASS {{p}}t31_hidden IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}fish_auction( ).
ENDMETHOD.
METHOD sums_two_species.
DATA lt_result TYPE STANDARD TABLE OF {{p}}fish_auction=>ty_summary WITH EMPTY KEY.
lt_result = mo_cut->summarize( VALUE #(
( boat_id = 'B1' species = 'COD' weight_kg = 100 )
( boat_id = 'B2' species = 'COD' weight_kg = 50 )
( boat_id = 'B1' species = 'HERRING' weight_kg = 30 ) ) ).
cl_abap_unit_assert=>assert_equals( act = lines( lt_result ) exp = 2 ).
READ TABLE lt_result INTO DATA(ls_row) WITH KEY species = 'COD'.
cl_abap_unit_assert=>assert_equals( act = ls_row-total_weight exp = 150 ).
cl_abap_unit_assert=>assert_equals( act = ls_row-boat_count exp = 2 ).
READ TABLE lt_result INTO ls_row WITH KEY species = 'HERRING'.
cl_abap_unit_assert=>assert_equals( act = ls_row-total_weight exp = 30 ).
cl_abap_unit_assert=>assert_equals( act = ls_row-boat_count exp = 1 ).
ENDMETHOD.
METHOD counts_distinct_boats.
DATA lt_result TYPE STANDARD TABLE OF {{p}}fish_auction=>ty_summary WITH EMPTY KEY.
lt_result = mo_cut->summarize( VALUE #(
( boat_id = 'B1' species = 'COD' weight_kg = 10 )
( boat_id = 'B1' species = 'COD' weight_kg = 20 )
( boat_id = 'B2' species = 'COD' weight_kg = 5 ) ) ).
READ TABLE lt_result INTO DATA(ls_row) WITH KEY species = 'COD'.
cl_abap_unit_assert=>assert_equals( act = ls_row-total_weight exp = 35 ).
cl_abap_unit_assert=>assert_equals( act = ls_row-boat_count exp = 2 ).
ENDMETHOD.
METHOD ignores_zero_weight.
DATA lt_result TYPE STANDARD TABLE OF {{p}}fish_auction=>ty_summary WITH EMPTY KEY.
lt_result = mo_cut->summarize( VALUE #(
( boat_id = 'B1' species = 'COD' weight_kg = 0 )
( boat_id = 'B2' species = 'COD' weight_kg = -5 )
( boat_id = 'B3' species = 'COD' weight_kg = 7 ) ) ).
cl_abap_unit_assert=>assert_equals( act = lines( lt_result ) exp = 1 ).
READ TABLE lt_result INTO DATA(ls_row) WITH KEY species = 'COD'.
cl_abap_unit_assert=>assert_equals( act = ls_row-total_weight exp = 7 ).
cl_abap_unit_assert=>assert_equals( act = ls_row-boat_count exp = 1 ).
ENDMETHOD.
METHOD ignores_blank_species.
DATA lt_result TYPE STANDARD TABLE OF {{p}}fish_auction=>ty_summary WITH EMPTY KEY.
lt_result = mo_cut->summarize( VALUE #(
( boat_id = 'B1' species = '' weight_kg = 10 )
( boat_id = 'B2' species = ' ' weight_kg = 20 )
( boat_id = 'B3' species = 'COD' weight_kg = 5 ) ) ).
cl_abap_unit_assert=>assert_equals( act = lines( lt_result ) exp = 1 ).
READ TABLE lt_result INTO DATA(ls_row) WITH KEY species = 'COD'.
cl_abap_unit_assert=>assert_equals( act = ls_row-total_weight exp = 5 ).
ENDMETHOD.
METHOD trims_and_uppercases.
DATA lt_result TYPE STANDARD TABLE OF {{p}}fish_auction=>ty_summary WITH EMPTY KEY.
lt_result = mo_cut->summarize( VALUE #(
( boat_id = 'B1' species = ' cod ' weight_kg = 10 )
( boat_id = 'B2' species = 'COD' weight_kg = 20 ) ) ).
cl_abap_unit_assert=>assert_equals( act = lines( lt_result ) exp = 1 ).
READ TABLE lt_result INTO DATA(ls_row) WITH KEY species = 'COD'.
cl_abap_unit_assert=>assert_equals( act = ls_row-total_weight exp = 30 ).
cl_abap_unit_assert=>assert_equals( act = ls_row-boat_count exp = 2 ).
ENDMETHOD.
METHOD sorts_by_species.
DATA lt_result TYPE STANDARD TABLE OF {{p}}fish_auction=>ty_summary WITH EMPTY KEY.
lt_result = mo_cut->summarize( VALUE #(
( boat_id = 'B1' species = 'TUNA' weight_kg = 10 )
( boat_id = 'B2' species = 'COD' weight_kg = 20 )
( boat_id = 'B3' species = 'MACKEREL' weight_kg = 5 ) ) ).
cl_abap_unit_assert=>assert_equals( act = lines( lt_result ) exp = 3 ).
READ TABLE lt_result INTO DATA(ls_row) INDEX 1.
cl_abap_unit_assert=>assert_equals( act = ls_row-species exp = 'COD' ).
READ TABLE lt_result INTO ls_row INDEX 3.
cl_abap_unit_assert=>assert_equals( act = ls_row-species exp = 'TUNA' ).
ENDMETHOD.
METHOD empty_input.
DATA lt_result TYPE STANDARD TABLE OF {{p}}fish_auction=>ty_summary WITH EMPTY KEY.
lt_result = mo_cut->summarize( VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( act = lines( lt_result ) exp = 0 ).
ENDMETHOD.
METHOD all_entries_invalid.
DATA lt_result TYPE STANDARD TABLE OF {{p}}fish_auction=>ty_summary WITH EMPTY KEY.
lt_result = mo_cut->summarize( VALUE #(
( boat_id = 'B1' species = ' ' weight_kg = 10 )
( boat_id = 'B2' species = 'COD' weight_kg = 0 ) ) ).
cl_abap_unit_assert=>assert_equals( act = lines( lt_result ) exp = 0 ).
ENDMETHOD.
METHOD best_species_highest.
cl_abap_unit_assert=>assert_equals(
act = mo_cut->best_species( VALUE #(
( boat_id = 'B1' species = 'COD' weight_kg = 10 )
( boat_id = 'B2' species = 'TUNA' weight_kg = 40 )
( boat_id = 'B3' species = 'HERRING' weight_kg = 25 ) ) )
exp = 'TUNA' ).
ENDMETHOD.
METHOD best_species_tie.
cl_abap_unit_assert=>assert_equals(
act = mo_cut->best_species( VALUE #(
( boat_id = 'B1' species = 'TUNA' weight_kg = 30 )
( boat_id = 'B2' species = 'COD' weight_kg = 30 ) ) )
exp = 'COD' ).
ENDMETHOD.
METHOD best_species_none.
cl_abap_unit_assert=>assert_initial( mo_cut->best_species( VALUE #( ) ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,74 @@
{
"task": "G1009",
"mutants": [
{
"object": "{{P}}FISH_AUCTION",
"mutant": "line 55: OR -> AND (logic)",
"status": "killed",
"hidden": "8/11",
"failed_tests": [
"ALL_ENTRIES_INVALID",
"IGNORES_BLANK_SPECIES",
"IGNORES_ZERO_WEIGHT"
]
},
{
"object": "{{P}}FISH_AUCTION",
"mutant": "line 55: <= -> > (rel)",
"status": "killed",
"hidden": "2/11",
"failed_tests": [
"ALL_ENTRIES_INVALID",
"BEST_SPECIES_HIGHEST",
"BEST_SPECIES_TIE",
"COUNTS_DISTINCT_BOATS",
"IGNORES_BLANK_SPECIES",
"IGNORES_ZERO_WEIGHT",
"SORTS_BY_SPECIES",
"SUMS_TWO_SPECIES",
"TRIMS_AND_UPPERCASES"
]
},
{
"object": "{{P}}FISH_AUCTION",
"mutant": "line 66: + -> - (arith)",
"status": "killed",
"hidden": "4/11",
"failed_tests": [
"BEST_SPECIES_HIGHEST",
"BEST_SPECIES_TIE",
"COUNTS_DISTINCT_BOATS",
"IGNORES_BLANK_SPECIES",
"IGNORES_ZERO_WEIGHT",
"SUMS_TWO_SPECIES",
"TRIMS_AND_UPPERCASES"
]
},
{
"object": "{{P}}FISH_AUCTION",
"mutant": "line 71: + -> - (arith)",
"status": "killed",
"hidden": "7/11",
"failed_tests": [
"COUNTS_DISTINCT_BOATS",
"IGNORES_ZERO_WEIGHT",
"SUMS_TWO_SPECIES",
"TRIMS_AND_UPPERCASES"
]
},
{
"object": "{{P}}FISH_AUCTION",
"mutant": "line 83: > -> <= (rel)",
"status": "killed",
"hidden": "9/11",
"failed_tests": [
"BEST_SPECIES_HIGHEST",
"BEST_SPECIES_TIE"
]
}
],
"valid": 5,
"killed": 5,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,96 @@
CLASS {{p}}fish_auction DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_species TYPE c LENGTH 10.
TYPES ty_boat_id TYPE c LENGTH 10.
TYPES:
BEGIN OF ty_catch,
boat_id TYPE ty_boat_id,
species TYPE ty_species,
weight_kg TYPE i,
END OF ty_catch.
TYPES tt_catch TYPE STANDARD TABLE OF ty_catch WITH EMPTY KEY.
TYPES:
BEGIN OF ty_summary,
species TYPE ty_species,
total_weight TYPE i,
boat_count TYPE i,
END OF ty_summary.
TYPES tt_summary TYPE STANDARD TABLE OF ty_summary WITH EMPTY KEY.
METHODS summarize
IMPORTING it_catch TYPE tt_catch
RETURNING VALUE(rt_summary) TYPE tt_summary.
METHODS best_species
IMPORTING it_catch TYPE tt_catch
RETURNING VALUE(rv_species) TYPE ty_species.
PRIVATE SECTION.
TYPES:
BEGIN OF ty_boat_species,
species TYPE ty_species,
boat_id TYPE ty_boat_id,
END OF ty_boat_species,
tt_boat_species TYPE HASHED TABLE OF ty_boat_species
WITH UNIQUE KEY species boat_id.
METHODS species_key
IMPORTING iv_species TYPE ty_species
RETURNING VALUE(rv_species) TYPE ty_species.
ENDCLASS.
CLASS {{p}}fish_auction IMPLEMENTATION.
METHOD summarize.
DATA lt_total TYPE SORTED TABLE OF ty_summary WITH UNIQUE KEY species.
DATA lt_boat_species TYPE tt_boat_species.
DATA lv_species TYPE ty_species.
LOOP AT it_catch INTO DATA(ls_catch).
lv_species = species_key( ls_catch-species ).
IF lv_species IS INITIAL OR ls_catch-weight_kg <= 0.
CONTINUE.
ENDIF.
READ TABLE lt_total WITH TABLE KEY species = lv_species
ASSIGNING FIELD-SYMBOL(<ls_total>).
IF sy-subrc <> 0.
INSERT VALUE #( species = lv_species ) INTO TABLE lt_total.
READ TABLE lt_total WITH TABLE KEY species = lv_species
ASSIGNING <ls_total>.
ENDIF.
<ls_total>-total_weight = <ls_total>-total_weight + ls_catch-weight_kg.
INSERT VALUE #( species = lv_species boat_id = ls_catch-boat_id )
INTO TABLE lt_boat_species.
IF sy-subrc = 0.
<ls_total>-boat_count = <ls_total>-boat_count + 1.
ENDIF.
ENDLOOP.
rt_summary = lt_total.
ENDMETHOD.
METHOD best_species.
DATA(lt_summary) = summarize( it_catch ).
DATA lv_best_weight TYPE i.
LOOP AT lt_summary INTO DATA(ls_summary).
IF ls_summary-total_weight > lv_best_weight.
lv_best_weight = ls_summary-total_weight.
rv_species = ls_summary-species.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD species_key.
DATA lv_species TYPE ty_species.
lv_species = iv_species.
SHIFT lv_species LEFT DELETING LEADING space.
rv_species = to_upper( lv_species ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,77 @@
CLASS ltc_fish_auction DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA mo_cut TYPE REF TO {{p}}fish_auction.
METHODS setup.
METHODS sums_and_counts FOR TESTING.
METHODS ignores_invalid_entries FOR TESTING.
METHODS normalizes_species FOR TESTING.
METHODS result_is_sorted FOR TESTING.
METHODS best_species_wins FOR TESTING.
METHODS best_species_tie FOR TESTING.
ENDCLASS.
CLASS ltc_fish_auction IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}fish_auction( ).
ENDMETHOD.
METHOD sums_and_counts.
DATA lt_result TYPE STANDARD TABLE OF {{p}}fish_auction=>ty_summary WITH EMPTY KEY.
lt_result = mo_cut->summarize( VALUE #(
( boat_id = 'B1' species = 'COD' weight_kg = 100 )
( boat_id = 'B2' species = 'COD' weight_kg = 50 )
( boat_id = 'B1' species = 'COD' weight_kg = 25 ) ) ).
cl_abap_unit_assert=>assert_equals( act = lines( lt_result ) exp = 1 ).
READ TABLE lt_result INTO DATA(ls_row) WITH KEY species = 'COD'.
cl_abap_unit_assert=>assert_equals( act = ls_row-total_weight exp = 175 ).
cl_abap_unit_assert=>assert_equals( act = ls_row-boat_count exp = 2 ).
ENDMETHOD.
METHOD ignores_invalid_entries.
DATA lt_result TYPE STANDARD TABLE OF {{p}}fish_auction=>ty_summary WITH EMPTY KEY.
lt_result = mo_cut->summarize( VALUE #(
( boat_id = 'B1' species = ' ' weight_kg = 10 )
( boat_id = 'B2' species = 'COD' weight_kg = 0 ) ) ).
cl_abap_unit_assert=>assert_equals( act = lines( lt_result ) exp = 0 ).
ENDMETHOD.
METHOD normalizes_species.
DATA lt_result TYPE STANDARD TABLE OF {{p}}fish_auction=>ty_summary WITH EMPTY KEY.
lt_result = mo_cut->summarize( VALUE #(
( boat_id = 'B1' species = ' tuna' weight_kg = 10 )
( boat_id = 'B2' species = 'TUNA ' weight_kg = 20 ) ) ).
cl_abap_unit_assert=>assert_equals( act = lines( lt_result ) exp = 1 ).
READ TABLE lt_result INTO DATA(ls_row) WITH KEY species = 'TUNA'.
cl_abap_unit_assert=>assert_equals( act = ls_row-total_weight exp = 30 ).
ENDMETHOD.
METHOD result_is_sorted.
DATA lt_result TYPE STANDARD TABLE OF {{p}}fish_auction=>ty_summary WITH EMPTY KEY.
lt_result = mo_cut->summarize( VALUE #(
( boat_id = 'B1' species = 'TUNA' weight_kg = 10 )
( boat_id = 'B2' species = 'COD' weight_kg = 10 ) ) ).
READ TABLE lt_result INTO DATA(ls_row) INDEX 1.
cl_abap_unit_assert=>assert_equals( act = ls_row-species exp = 'COD' ).
ENDMETHOD.
METHOD best_species_wins.
cl_abap_unit_assert=>assert_equals(
act = mo_cut->best_species( VALUE #(
( boat_id = 'B1' species = 'COD' weight_kg = 10 )
( boat_id = 'B2' species = 'TUNA' weight_kg = 40 ) ) )
exp = 'TUNA' ).
ENDMETHOD.
METHOD best_species_tie.
cl_abap_unit_assert=>assert_equals(
act = mo_cut->best_species( VALUE #(
( boat_id = 'B1' species = 'TUNA' weight_kg = 30 )
( boat_id = 'B2' species = 'COD' weight_kg = 30 ) ) )
exp = 'COD' ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,74 @@
# 1. Goal
A fishing cooperative auctions the catch of its boats. Each boat reports its catch
as a list of entries. The auctioneer needs one consolidated list for each species.
A program calls the class before it prints the auction list.
# 2. Open questions
None.
# 3. Context
- Package $TMP.
- The class is new. No other object exists for this task.
# 4. Contract
Create the class {{P}}FISH_AUCTION in package $TMP.
- The class is public and final.
- The class has a public constructor without parameters.
- Public types:
- TY_SPECIES: character, length 10.
- TY_BOAT_ID: character, length 10.
- TY_CATCH: structure with the components BOAT_ID (type ty_boat_id),
SPECIES (type ty_species), and WEIGHT_KG (type i).
- TT_CATCH: table type of ty_catch. The table can hold more than one entry
with the same boat ID and the same species.
- TY_SUMMARY: structure with the components SPECIES (type ty_species),
TOTAL_WEIGHT (type i), and BOAT_COUNT (type i).
- TT_SUMMARY: table type of ty_summary.
- Public methods:
- SUMMARIZE, importing IT_CATCH type tt_catch, returning VALUE(RT_SUMMARY)
type tt_summary.
- BEST_SPECIES, importing IT_CATCH type tt_catch, returning VALUE(RV_SPECIES)
type ty_species.
- Do not add other public methods.
# 5. Business rules
SUMMARIZE:
1. Do not change the input table.
2. For each entry, build the species key: remove the leading and the trailing
blanks from SPECIES and convert all letters to upper case.
3. Ignore the entry if the species key is empty. Ignore the entry if WEIGHT_KG
is zero or less.
4. Group the remaining entries by the species key.
5. TOTAL_WEIGHT of a group is the sum of WEIGHT_KG of all entries in the group.
6. BOAT_COUNT of a group is the number of different boat IDs in the group.
7. The result has one row for each group. The rows are in ascending order of the
species key.
8. If no entry remains, the result is empty.
BEST_SPECIES:
9. Build the groups with the rules 1 to 8.
10. Return the species key of the group with the highest TOTAL_WEIGHT.
11. If two groups have the same highest TOTAL_WEIGHT, return the species key that
is first in ascending order.
12. If there is no group, return an empty value.
# 6. Constraints
- Release target: ABAP Platform 2025 (SAP_BASIS 816).
- Coding standards: Clean ABAP. Method length below 40 statements. No global
variables. No comment that restates the code.
- Out of scope: do not create or change other objects.
# 7. Acceptance
- The class is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.

View File

@@ -0,0 +1,43 @@
{
"id": "G1009",
"category": "C",
"object_type": "CLAS",
"difficulty": 2,
"release_target": "v816",
"expected_outcome": "implement",
"budget": {
"max_tool_calls": 60,
"max_activations": 15
},
"seed": [],
"contract": [
{
"type": "CLAS",
"name": "{{P}}FISH_AUCTION"
}
],
"out_of_scope": [
"No other object in package $TMP."
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}T31_HIDDEN",
"file": "hidden/t31_hidden.clas.abap",
"description": "T31 hidden tests"
}
],
"reference": [
{
"type": "CLAS",
"name": "{{P}}FISH_AUCTION",
"file": "reference/fish_auction.clas.abap",
"description": "Consolidates the catch of the fishing boats",
"testclasses_file": "reference/fish_auction.testclasses.abap"
}
],
"craft_checks": [
"method_length",
"nested_loops"
]
}