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:
29
tasks_gen/train/G1021/generation.json
Normal file
29
tasks_gen/train/G1021/generation.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"id": "G1021",
|
||||
"pool": "train",
|
||||
"object_type": "CLAS",
|
||||
"category": "C",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
}
|
||||
],
|
||||
"accepted": false
|
||||
}
|
||||
235
tasks_gen/train/G1021/hidden/t41_hidden.clas.abap
Normal file
235
tasks_gen/train/G1021/hidden/t41_hidden.clas.abap
Normal file
@@ -0,0 +1,235 @@
|
||||
CLASS {{p}}t41_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}roast_merger.
|
||||
|
||||
METHODS setup.
|
||||
METHODS weight_of
|
||||
IMPORTING iv_text TYPE string
|
||||
RETURNING VALUE(rv_weight) TYPE {{p}}roast_merger=>ty_weight.
|
||||
METHODS total_of
|
||||
IMPORTING it_totals TYPE {{p}}roast_merger=>tt_lot_totals
|
||||
iv_lot TYPE {{p}}roast_merger=>ty_lot_id
|
||||
RETURNING VALUE(rs_total) TYPE {{p}}roast_merger=>ty_lot_total.
|
||||
|
||||
METHODS merges_two_plants FOR TESTING.
|
||||
METHODS result_sorted_by_lot FOR TESTING.
|
||||
METHODS dedup_keeps_larger FOR TESTING.
|
||||
METHODS dedup_keeps_first FOR TESTING.
|
||||
METHODS dedup_within_one_plant FOR TESTING.
|
||||
METHODS last_date_is_latest FOR TESTING.
|
||||
METHODS ignores_zero_weight FOR TESTING.
|
||||
METHODS ignores_empty_batch_id FOR TESTING.
|
||||
METHODS empty_input_gives_empty FOR TESTING.
|
||||
METHODS lot_with_only_invalid FOR TESTING.
|
||||
METHODS single_batch FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}t41_hidden IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}roast_merger( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weight_of.
|
||||
rv_weight = iv_text.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD total_of.
|
||||
READ TABLE it_totals WITH KEY lot_id = iv_lot INTO rs_total.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD merges_two_plants.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240110' roasted_kg = '100.00' )
|
||||
( batch_id = 'B2' plant = 'P001' lot_id = 'LOT002'
|
||||
roast_date = '20240111' roasted_kg = '50.00' ) ).
|
||||
DATA(lt_b) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B3' plant = 'P002' lot_id = 'LOT002'
|
||||
roast_date = '20240112' roasted_kg = '25.00' )
|
||||
( batch_id = 'B4' plant = 'P002' lot_id = 'LOT003'
|
||||
roast_date = '20240113' roasted_kg = '10.00' ) ).
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 3 ).
|
||||
|
||||
DATA(ls_lot1) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot1-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot1-total_kg exp = weight_of( '100.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot1-last_date exp = '20240110' ).
|
||||
|
||||
DATA(ls_lot2) = total_of( it_totals = lt_totals iv_lot = 'LOT002' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot2-batch_count exp = 2 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot2-total_kg exp = weight_of( '75.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot2-last_date exp = '20240112' ).
|
||||
|
||||
DATA(ls_lot3) = total_of( it_totals = lt_totals iv_lot = 'LOT003' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot3-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot3-total_kg exp = weight_of( '10.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD result_sorted_by_lot.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT300'
|
||||
roast_date = '20240101' roasted_kg = '10.00' )
|
||||
( batch_id = 'B2' plant = 'P001' lot_id = 'LOT100'
|
||||
roast_date = '20240102' roasted_kg = '20.00' ) ).
|
||||
DATA(lt_b) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B3' plant = 'P002' lot_id = 'LOT200'
|
||||
roast_date = '20240103' roasted_kg = '30.00' ) ).
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 3 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lt_totals[ 1 ]-lot_id exp = 'LOT100' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lt_totals[ 2 ]-lot_id exp = 'LOT200' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lt_totals[ 3 ]-lot_id exp = 'LOT300' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD dedup_keeps_larger.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240101' roasted_kg = '40.00' ) ).
|
||||
DATA(lt_b) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P002' lot_id = 'LOT001'
|
||||
roast_date = '20240102' roasted_kg = '60.00' ) ).
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '60.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240102' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD dedup_keeps_first.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240105' roasted_kg = '70.00' ) ).
|
||||
DATA(lt_b) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P002' lot_id = 'LOT001'
|
||||
roast_date = '20240106' roasted_kg = '30.00' ) ).
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '70.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240105' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD dedup_within_one_plant.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240101' roasted_kg = '20.00' )
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240102' roasted_kg = '35.00' )
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240103' roasted_kg = '10.00' ) ).
|
||||
DATA lt_b TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '35.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240102' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD last_date_is_latest.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240120' roasted_kg = '10.00' )
|
||||
( batch_id = 'B2' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240105' roasted_kg = '10.00' )
|
||||
( batch_id = 'B3' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240131' roasted_kg = '10.00' ) ).
|
||||
DATA lt_b TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 3 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '30.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240131' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ignores_zero_weight.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240101' roasted_kg = '0.00' )
|
||||
( batch_id = 'B2' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240102' roasted_kg = '10.00' )
|
||||
( batch_id = 'B3' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240103' roasted_kg = '-5.00' ) ).
|
||||
DATA lt_b TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '10.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240102' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ignores_empty_batch_id.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = '' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240101' roasted_kg = '50.00' )
|
||||
( batch_id = 'B2' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240102' roasted_kg = '10.00' ) ).
|
||||
DATA lt_b TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '10.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240102' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD empty_input_gives_empty.
|
||||
DATA lt_empty TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_empty it_plant_b = lt_empty ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 0 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD lot_with_only_invalid.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240101' roasted_kg = '0.00' )
|
||||
( batch_id = 'B2' plant = 'P001' lot_id = 'LOT002'
|
||||
roast_date = '20240102' roasted_kg = '10.00' ) ).
|
||||
DATA lt_b TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lt_totals[ 1 ]-lot_id exp = 'LOT002' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD single_batch.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240107' roasted_kg = '12.50' ) ).
|
||||
DATA lt_b TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '12.50' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240107' ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
88
tasks_gen/train/G1021/reference/roast_merger.clas.abap
Normal file
88
tasks_gen/train/G1021/reference/roast_merger.clas.abap
Normal file
@@ -0,0 +1,88 @@
|
||||
CLASS {{p}}roast_merger DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
TYPES:
|
||||
ty_batch_id TYPE c LENGTH 10,
|
||||
ty_plant TYPE c LENGTH 4,
|
||||
ty_lot_id TYPE c LENGTH 8,
|
||||
ty_weight TYPE p LENGTH 7 DECIMALS 2,
|
||||
BEGIN OF ty_batch,
|
||||
batch_id TYPE ty_batch_id,
|
||||
plant TYPE ty_plant,
|
||||
lot_id TYPE ty_lot_id,
|
||||
roast_date TYPE d,
|
||||
roasted_kg TYPE ty_weight,
|
||||
END OF ty_batch,
|
||||
tt_batches TYPE STANDARD TABLE OF ty_batch WITH EMPTY KEY,
|
||||
BEGIN OF ty_lot_total,
|
||||
lot_id TYPE ty_lot_id,
|
||||
batch_count TYPE i,
|
||||
total_kg TYPE ty_weight,
|
||||
last_date TYPE d,
|
||||
END OF ty_lot_total,
|
||||
tt_lot_totals TYPE STANDARD TABLE OF ty_lot_total WITH EMPTY KEY.
|
||||
|
||||
METHODS merge
|
||||
IMPORTING it_plant_a TYPE tt_batches
|
||||
it_plant_b TYPE tt_batches
|
||||
RETURNING VALUE(rt_totals) TYPE tt_lot_totals.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES tt_unique TYPE HASHED TABLE OF ty_batch WITH UNIQUE KEY batch_id.
|
||||
|
||||
METHODS add_batches
|
||||
IMPORTING it_batches TYPE tt_batches
|
||||
CHANGING ct_unique TYPE tt_unique.
|
||||
|
||||
METHODS build_totals
|
||||
IMPORTING it_unique TYPE tt_unique
|
||||
RETURNING VALUE(rt_totals) TYPE tt_lot_totals.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}roast_merger IMPLEMENTATION.
|
||||
METHOD merge.
|
||||
DATA lt_unique TYPE tt_unique.
|
||||
add_batches( EXPORTING it_batches = it_plant_a
|
||||
CHANGING ct_unique = lt_unique ).
|
||||
add_batches( EXPORTING it_batches = it_plant_b
|
||||
CHANGING ct_unique = lt_unique ).
|
||||
rt_totals = build_totals( lt_unique ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD add_batches.
|
||||
LOOP AT it_batches INTO DATA(ls_batch).
|
||||
IF ls_batch-batch_id IS INITIAL OR ls_batch-roasted_kg <= 0.
|
||||
CONTINUE.
|
||||
ENDIF.
|
||||
READ TABLE ct_unique WITH TABLE KEY batch_id = ls_batch-batch_id
|
||||
ASSIGNING FIELD-SYMBOL(<ls_kept>).
|
||||
IF sy-subrc <> 0.
|
||||
INSERT ls_batch INTO TABLE ct_unique.
|
||||
ELSEIF ls_batch-roasted_kg > <ls_kept>-roasted_kg.
|
||||
<ls_kept> = ls_batch.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD build_totals.
|
||||
DATA lt_totals TYPE SORTED TABLE OF ty_lot_total WITH UNIQUE KEY lot_id.
|
||||
LOOP AT it_unique INTO DATA(ls_batch).
|
||||
READ TABLE lt_totals WITH TABLE KEY lot_id = ls_batch-lot_id
|
||||
ASSIGNING FIELD-SYMBOL(<ls_total>).
|
||||
IF sy-subrc <> 0.
|
||||
INSERT VALUE #( lot_id = ls_batch-lot_id
|
||||
batch_count = 1
|
||||
total_kg = ls_batch-roasted_kg
|
||||
last_date = ls_batch-roast_date )
|
||||
INTO TABLE lt_totals.
|
||||
CONTINUE.
|
||||
ENDIF.
|
||||
<ls_total>-batch_count = <ls_total>-batch_count + 1.
|
||||
<ls_total>-total_kg = <ls_total>-total_kg + ls_batch-roasted_kg.
|
||||
IF ls_batch-roast_date > <ls_total>-last_date.
|
||||
<ls_total>-last_date = ls_batch-roast_date.
|
||||
ENDIF.
|
||||
ENDLOOP.
|
||||
rt_totals = lt_totals.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
147
tasks_gen/train/G1021/reference/roast_merger.testclasses.abap
Normal file
147
tasks_gen/train/G1021/reference/roast_merger.testclasses.abap
Normal file
@@ -0,0 +1,147 @@
|
||||
CLASS ltc_roast_merger DEFINITION FINAL FOR TESTING
|
||||
DURATION SHORT RISK LEVEL HARMLESS.
|
||||
PRIVATE SECTION.
|
||||
DATA mo_cut TYPE REF TO {{p}}roast_merger.
|
||||
|
||||
METHODS setup.
|
||||
METHODS weight_of
|
||||
IMPORTING iv_text TYPE string
|
||||
RETURNING VALUE(rv_weight) TYPE {{p}}roast_merger=>ty_weight.
|
||||
METHODS total_of
|
||||
IMPORTING it_totals TYPE {{p}}roast_merger=>tt_lot_totals
|
||||
iv_lot TYPE {{p}}roast_merger=>ty_lot_id
|
||||
RETURNING VALUE(rs_total) TYPE {{p}}roast_merger=>ty_lot_total.
|
||||
|
||||
METHODS merges_two_plants FOR TESTING.
|
||||
METHODS keeps_larger_weight FOR TESTING.
|
||||
METHODS ignores_invalid FOR TESTING.
|
||||
METHODS sorts_by_lot FOR TESTING.
|
||||
METHODS empty_input FOR TESTING.
|
||||
METHODS last_date_is_latest FOR TESTING.
|
||||
METHODS single_batch FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_roast_merger IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}roast_merger( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD weight_of.
|
||||
rv_weight = iv_text.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD total_of.
|
||||
READ TABLE it_totals WITH KEY lot_id = iv_lot INTO rs_total.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD merges_two_plants.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240110' roasted_kg = '100.00' )
|
||||
( batch_id = 'B2' plant = 'P001' lot_id = 'LOT002'
|
||||
roast_date = '20240111' roasted_kg = '50.00' ) ).
|
||||
DATA(lt_b) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B3' plant = 'P002' lot_id = 'LOT002'
|
||||
roast_date = '20240112' roasted_kg = '25.00' ) ).
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 2 ).
|
||||
DATA(ls_lot2) = total_of( it_totals = lt_totals iv_lot = 'LOT002' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot2-batch_count exp = 2 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot2-total_kg exp = weight_of( '75.00' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot2-last_date exp = '20240112' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD keeps_larger_weight.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240101' roasted_kg = '40.00' ) ).
|
||||
DATA(lt_b) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P002' lot_id = 'LOT001'
|
||||
roast_date = '20240102' roasted_kg = '60.00' ) ).
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '60.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD ignores_invalid.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = '' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240101' roasted_kg = '50.00' )
|
||||
( batch_id = 'B2' plant = 'P001' lot_id = 'LOT002'
|
||||
roast_date = '20240102' roasted_kg = '0.00' )
|
||||
( batch_id = 'B3' plant = 'P001' lot_id = 'LOT002'
|
||||
roast_date = '20240103' roasted_kg = '10.00' ) ).
|
||||
DATA lt_b TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT002' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '10.00' ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD sorts_by_lot.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT300'
|
||||
roast_date = '20240101' roasted_kg = '10.00' )
|
||||
( batch_id = 'B2' plant = 'P001' lot_id = 'LOT100'
|
||||
roast_date = '20240102' roasted_kg = '20.00' ) ).
|
||||
DATA(lt_b) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B3' plant = 'P002' lot_id = 'LOT200'
|
||||
roast_date = '20240103' roasted_kg = '30.00' ) ).
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 3 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lt_totals[ 1 ]-lot_id exp = 'LOT100' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lt_totals[ 2 ]-lot_id exp = 'LOT200' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = lt_totals[ 3 ]-lot_id exp = 'LOT300' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD empty_input.
|
||||
DATA lt_empty TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_empty it_plant_b = lt_empty ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 0 ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD last_date_is_latest.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240120' roasted_kg = '10.00' )
|
||||
( batch_id = 'B2' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240105' roasted_kg = '10.00' )
|
||||
( batch_id = 'B3' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240131' roasted_kg = '10.00' ) ).
|
||||
DATA lt_b TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240131' ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD single_batch.
|
||||
DATA(lt_a) = VALUE {{p}}roast_merger=>tt_batches(
|
||||
( batch_id = 'B1' plant = 'P001' lot_id = 'LOT001'
|
||||
roast_date = '20240107' roasted_kg = '12.50' ) ).
|
||||
DATA lt_b TYPE {{p}}roast_merger=>tt_batches.
|
||||
|
||||
DATA(lt_totals) = mo_cut->merge( it_plant_a = lt_a it_plant_b = lt_b ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( act = lines( lt_totals ) exp = 1 ).
|
||||
DATA(ls_lot) = total_of( it_totals = lt_totals iv_lot = 'LOT001' ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-batch_count exp = 1 ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-total_kg exp = weight_of( '12.50' ) ).
|
||||
cl_abap_unit_assert=>assert_equals( act = ls_lot-last_date exp = '20240107' ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
65
tasks_gen/train/G1021/spec.md
Normal file
65
tasks_gen/train/G1021/spec.md
Normal file
@@ -0,0 +1,65 @@
|
||||
# 1. Goal
|
||||
A coffee roastery operates two roasting plants. Each plant sends a list of roast
|
||||
batches. The roastery needs one consolidated list. The list shows the totals of
|
||||
each green coffee lot. A planning program calls the consolidation before it
|
||||
plans the next roasting week.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- Plant A and plant B record their roast batches independently. The same batch
|
||||
ID can occur in both lists. A batch ID can also occur more than one time in
|
||||
one list.
|
||||
- A batch has a batch ID, a plant, a lot ID, a roast date, and a roasted weight
|
||||
in kilograms. The roasted weight has two decimal places.
|
||||
|
||||
# 4. Contract
|
||||
- Create the class {{P}}ROAST_MERGER in package $TMP.
|
||||
- The class is public and final. The class has a public constructor without
|
||||
parameters.
|
||||
- The class has these public types:
|
||||
- TY_BATCH_ID (character, length 10)
|
||||
- TY_PLANT (character, length 4)
|
||||
- TY_LOT_ID (character, length 8)
|
||||
- TY_WEIGHT (packed number, length 7, 2 decimal places)
|
||||
- TY_BATCH (structure): BATCH_ID, PLANT, LOT_ID, ROAST_DATE (date),
|
||||
ROASTED_KG (TY_WEIGHT)
|
||||
- TT_BATCHES: standard table of TY_BATCH with empty key
|
||||
- TY_LOT_TOTAL (structure): LOT_ID, BATCH_COUNT (integer), TOTAL_KG
|
||||
(TY_WEIGHT), LAST_DATE (date)
|
||||
- TT_LOT_TOTALS: standard table of TY_LOT_TOTAL with empty key
|
||||
- The class has this public method and no other public method:
|
||||
MERGE
|
||||
IMPORTING it_plant_a TYPE tt_batches
|
||||
it_plant_b TYPE tt_batches
|
||||
RETURNING VALUE(rt_totals) TYPE tt_lot_totals
|
||||
|
||||
# 5. Business rules
|
||||
The method MERGE applies these rules in this sequence.
|
||||
1. A batch is invalid if the batch ID is empty, or if the roasted weight is zero
|
||||
or negative. Ignore all invalid batches.
|
||||
2. A batch ID identifies a batch. If the same batch ID occurs more than one
|
||||
time, keep the first occurrence. Replace the kept occurrence only if a later
|
||||
occurrence has a larger roasted weight. The order of the occurrences is: all
|
||||
batches of plant A first, then all batches of plant B.
|
||||
3. Group the remaining batches by lot ID.
|
||||
4. For each lot ID calculate:
|
||||
- BATCH_COUNT: the number of batches with this lot ID.
|
||||
- TOTAL_KG: the sum of the roasted weights of these batches.
|
||||
- LAST_DATE: the latest roast date of these batches.
|
||||
5. The result has one row for each lot ID with at least one batch.
|
||||
6. The result is sorted by LOT_ID in ascending order.
|
||||
7. If both input tables are empty, the result is empty.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
|
||||
- Coding standards: Clean ABAP. Method length below 40 statements. No global
|
||||
variables. No comment that restates the code.
|
||||
- Out of scope: no database table, no CDS view, no report, no function module,
|
||||
no change of the public contract.
|
||||
|
||||
# 7. Acceptance
|
||||
- The class is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests for the class.
|
||||
49
tasks_gen/train/G1021/task.json
Normal file
49
tasks_gen/train/G1021/task.json
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"id": "G1021",
|
||||
"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}}ROAST_MERGER"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"Database tables",
|
||||
"CDS views",
|
||||
"Reports",
|
||||
"Function modules",
|
||||
"Other public methods of {{P}}ROAST_MERGER"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}T41_HIDDEN",
|
||||
"file": "hidden/t41_hidden.clas.abap",
|
||||
"description": "T41 hidden tests for the roast batch consolidation"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}ROAST_MERGER",
|
||||
"file": "reference/roast_merger.clas.abap",
|
||||
"description": "Roast batch consolidator",
|
||||
"testclasses_file": "reference/roast_merger.testclasses.abap"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"internal_table_kind",
|
||||
"table_key",
|
||||
"access_path",
|
||||
"method_length"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user