Snapshot: new training tasks (balanced generation), docs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 22:08:59 +02:00
parent eb13453097
commit 6984fc7917
572 changed files with 30024 additions and 0 deletions

View File

@@ -0,0 +1,108 @@
REPORT {{p}}compost_sum.
DATA gv_round TYPE {{p}}gwaste-round_id.
PARAMETERS p_from TYPE d OBLIGATORY.
SELECT-OPTIONS s_round FOR gv_round.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
TYPES:
BEGIN OF ty_line,
round_id TYPE {{p}}gwaste-round_id,
total_kg TYPE {{p}}gwaste-weight_kg,
deliveries TYPE i,
heavy TYPE i,
END OF ty_line,
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY,
tt_round TYPE RANGE OF {{p}}gwaste-round_id.
CONSTANTS c_heavy_kg TYPE {{p}}gwaste-weight_kg VALUE '1000.00'.
METHODS select_totals
IMPORTING iv_from TYPE d
it_round TYPE tt_round
RETURNING VALUE(rt_lines) TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD select_totals.
SELECT round_id, weight_kg
FROM {{p}}gwaste
WHERE deliv_date < @iv_from
AND round_id IN @it_round
INTO TABLE @DATA(lt_deliveries).
DATA lt_work TYPE SORTED TABLE OF ty_line WITH UNIQUE KEY round_id.
LOOP AT lt_deliveries INTO DATA(ls_delivery).
READ TABLE lt_work WITH TABLE KEY round_id = ls_delivery-round_id
ASSIGNING FIELD-SYMBOL(<ls_line>).
IF sy-subrc <> 0.
INSERT VALUE #( round_id = ls_delivery-round_id ) INTO TABLE lt_work ASSIGNING <ls_line>.
ENDIF.
<ls_line>-total_kg += ls_delivery-weight_kg.
<ls_line>-deliveries += 1.
IF ls_delivery-weight_kg >= c_heavy_kg.
<ls_line>-heavy += 1.
ENDIF.
ENDLOOP.
rt_lines = lt_work.
SORT rt_lines BY total_kg DESCENDING.
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_totals( iv_from = p_from it_round = s_round[] ).
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 totals_per_round FOR TESTING.
METHODS heavy_and_sorted FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}GWASTE' ) ) ).
DATA lt_waste TYPE STANDARD TABLE OF {{p}}gwaste WITH EMPTY KEY.
lt_waste = VALUE #(
( delivery_id = 1 round_id = 'A' waste_type = 'GRAS' deliv_date = '20260101' weight_kg = '1200.00' )
( delivery_id = 2 round_id = 'A' waste_type = 'HEDG' deliv_date = '20260102' weight_kg = '500.00' )
( delivery_id = 3 round_id = 'B' waste_type = 'BRAN' deliv_date = '20260101' weight_kg = '900.00' ) ).
go_env->insert_test_data( lt_waste ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD totals_per_round.
DATA(lt_lines) = NEW lcl_report( )->select_totals( iv_from = '20260101' it_round = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'A' act = lt_lines[ 1 ]-round_id ).
DATA(lv_total) = lt_lines[ 1 ]-total_kg.
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}gwaste-weight_kg( 1700 ) act = lv_total ).
ENDMETHOD.
METHOD heavy_and_sorted.
DATA(lt_lines) = NEW lcl_report( )->select_totals( iv_from = '20260101' it_round = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_lines[ 1 ]-heavy ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 2 ]-heavy ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_lines[ 2 ]-deliveries ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,108 @@
REPORT {{p}}compost_sum.
DATA gv_round TYPE {{p}}gwaste-round_id.
PARAMETERS p_from TYPE d OBLIGATORY.
SELECT-OPTIONS s_round FOR gv_round.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
TYPES:
BEGIN OF ty_line,
round_id TYPE {{p}}gwaste-round_id,
total_kg TYPE {{p}}gwaste-weight_kg,
deliveries TYPE i,
heavy TYPE i,
END OF ty_line,
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY,
tt_round TYPE RANGE OF {{p}}gwaste-round_id.
CONSTANTS c_heavy_kg TYPE {{p}}gwaste-weight_kg VALUE '1000.00'.
METHODS select_totals
IMPORTING iv_from TYPE d
it_round TYPE tt_round
RETURNING VALUE(rt_lines) TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD select_totals.
SELECT round_id, weight_kg
FROM {{p}}gwaste
WHERE deliv_date >= @iv_from
OR round_id IN @it_round
INTO TABLE @DATA(lt_deliveries).
DATA lt_work TYPE SORTED TABLE OF ty_line WITH UNIQUE KEY round_id.
LOOP AT lt_deliveries INTO DATA(ls_delivery).
READ TABLE lt_work WITH TABLE KEY round_id = ls_delivery-round_id
ASSIGNING FIELD-SYMBOL(<ls_line>).
IF sy-subrc <> 0.
INSERT VALUE #( round_id = ls_delivery-round_id ) INTO TABLE lt_work ASSIGNING <ls_line>.
ENDIF.
<ls_line>-total_kg += ls_delivery-weight_kg.
<ls_line>-deliveries += 1.
IF ls_delivery-weight_kg >= c_heavy_kg.
<ls_line>-heavy += 1.
ENDIF.
ENDLOOP.
rt_lines = lt_work.
SORT rt_lines BY total_kg DESCENDING.
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_totals( iv_from = p_from it_round = s_round[] ).
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 totals_per_round FOR TESTING.
METHODS heavy_and_sorted FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}GWASTE' ) ) ).
DATA lt_waste TYPE STANDARD TABLE OF {{p}}gwaste WITH EMPTY KEY.
lt_waste = VALUE #(
( delivery_id = 1 round_id = 'A' waste_type = 'GRAS' deliv_date = '20260101' weight_kg = '1200.00' )
( delivery_id = 2 round_id = 'A' waste_type = 'HEDG' deliv_date = '20260102' weight_kg = '500.00' )
( delivery_id = 3 round_id = 'B' waste_type = 'BRAN' deliv_date = '20260101' weight_kg = '900.00' ) ).
go_env->insert_test_data( lt_waste ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD totals_per_round.
DATA(lt_lines) = NEW lcl_report( )->select_totals( iv_from = '20260101' it_round = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'A' act = lt_lines[ 1 ]-round_id ).
DATA(lv_total) = lt_lines[ 1 ]-total_kg.
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}gwaste-weight_kg( 1700 ) act = lv_total ).
ENDMETHOD.
METHOD heavy_and_sorted.
DATA(lt_lines) = NEW lcl_report( )->select_totals( iv_from = '20260101' it_round = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_lines[ 1 ]-heavy ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 2 ]-heavy ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_lines[ 2 ]-deliveries ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,108 @@
REPORT {{p}}compost_sum.
DATA gv_round TYPE {{p}}gwaste-round_id.
PARAMETERS p_from TYPE d OBLIGATORY.
SELECT-OPTIONS s_round FOR gv_round.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
TYPES:
BEGIN OF ty_line,
round_id TYPE {{p}}gwaste-round_id,
total_kg TYPE {{p}}gwaste-weight_kg,
deliveries TYPE i,
heavy TYPE i,
END OF ty_line,
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY,
tt_round TYPE RANGE OF {{p}}gwaste-round_id.
CONSTANTS c_heavy_kg TYPE {{p}}gwaste-weight_kg VALUE '1000.00'.
METHODS select_totals
IMPORTING iv_from TYPE d
it_round TYPE tt_round
RETURNING VALUE(rt_lines) TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD select_totals.
SELECT round_id, weight_kg
FROM {{p}}gwaste
WHERE deliv_date >= @iv_from
AND round_id IN @it_round
INTO TABLE @DATA(lt_deliveries).
DATA lt_work TYPE SORTED TABLE OF ty_line WITH UNIQUE KEY round_id.
LOOP AT lt_deliveries INTO DATA(ls_delivery).
READ TABLE lt_work WITH TABLE KEY round_id = ls_delivery-round_id
ASSIGNING FIELD-SYMBOL(<ls_line>).
IF sy-subrc <> 0.
INSERT VALUE #( round_id = ls_delivery-round_id ) INTO TABLE lt_work ASSIGNING <ls_line>.
ENDIF.
<ls_line>-total_kg += ls_delivery-weight_kg.
<ls_line>-deliveries += 1.
IF ls_delivery-weight_kg < c_heavy_kg.
<ls_line>-heavy += 1.
ENDIF.
ENDLOOP.
rt_lines = lt_work.
SORT rt_lines BY total_kg DESCENDING.
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_totals( iv_from = p_from it_round = s_round[] ).
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 totals_per_round FOR TESTING.
METHODS heavy_and_sorted FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}GWASTE' ) ) ).
DATA lt_waste TYPE STANDARD TABLE OF {{p}}gwaste WITH EMPTY KEY.
lt_waste = VALUE #(
( delivery_id = 1 round_id = 'A' waste_type = 'GRAS' deliv_date = '20260101' weight_kg = '1200.00' )
( delivery_id = 2 round_id = 'A' waste_type = 'HEDG' deliv_date = '20260102' weight_kg = '500.00' )
( delivery_id = 3 round_id = 'B' waste_type = 'BRAN' deliv_date = '20260101' weight_kg = '900.00' ) ).
go_env->insert_test_data( lt_waste ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD totals_per_round.
DATA(lt_lines) = NEW lcl_report( )->select_totals( iv_from = '20260101' it_round = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'A' act = lt_lines[ 1 ]-round_id ).
DATA(lv_total) = lt_lines[ 1 ]-total_kg.
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}gwaste-weight_kg( 1700 ) act = lv_total ).
ENDMETHOD.
METHOD heavy_and_sorted.
DATA(lt_lines) = NEW lcl_report( )->select_totals( iv_from = '20260101' it_round = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_lines[ 1 ]-heavy ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 2 ]-heavy ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_lines[ 2 ]-deliveries ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,24 @@
{
"id": "G1941",
"pool": "train",
"object_type": "PROG",
"category": "C",
"attempts": [
{
"stage": "validate",
"oracle": 95.5,
"null": 0
},
{
"stage": "validate",
"oracle": 100.0,
"null": 0,
"mutation": {
"valid": 3,
"killed": 3,
"ok": true
}
}
],
"accepted": true
}

View File

@@ -0,0 +1,106 @@
CLASS {{p}}compost_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
TYPES tt_round TYPE RANGE OF {{p}}gwaste-round_id.
METHODS run
IMPORTING iv_from TYPE d
it_round TYPE tt_round OPTIONAL
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 assert_value
IMPORTING ir_data TYPE REF TO data
iv_row TYPE i
iv_col TYPE string
iv_exp TYPE string.
METHODS all_rounds FOR TESTING.
METHODS sorted_by_total FOR TESTING.
METHODS totals_and_counts FOR TESTING.
METHODS heavy_count FOR TESTING.
METHODS round_filter FOR TESTING.
METHODS date_filter FOR TESTING.
METHODS empty_result FOR TESTING.
ENDCLASS.
CLASS {{p}}compost_hidden IMPLEMENTATION.
METHOD run.
cl_salv_bs_runtime_info=>set( display = abap_false metadata = abap_false data = abap_true ).
SUBMIT {{p}}compost_sum WITH p_from = iv_from WITH s_round IN it_round 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 assert_value.
cl_abap_unit_assert=>assert_equals(
exp = iv_exp
act = value_of( ir_data = ir_data iv_row = iv_row iv_col = iv_col ) ).
ENDMETHOD.
METHOD all_rounds.
cl_abap_unit_assert=>assert_equals( exp = 3 act = lines_of( run( '20251201' ) ) ).
ENDMETHOD.
METHOD sorted_by_total.
DATA(lr_data) = run( '20251201' ).
assert_value( ir_data = lr_data iv_row = 1 iv_col = `ROUND_ID` iv_exp = `R1003` ).
assert_value( ir_data = lr_data iv_row = 3 iv_col = `ROUND_ID` iv_exp = `R1001` ).
ENDMETHOD.
METHOD totals_and_counts.
DATA(lr_data) = run( '20260101' ).
assert_value( ir_data = lr_data iv_row = 1 iv_col = `ROUND_ID` iv_exp = `R1002` ).
assert_value( ir_data = lr_data iv_row = 1 iv_col = `TOTAL_KG` iv_exp = `3000.00` ).
assert_value( ir_data = lr_data iv_row = 1 iv_col = `DELIVERIES` iv_exp = `1` ).
assert_value( ir_data = lr_data iv_row = 2 iv_col = `TOTAL_KG` iv_exp = `2000.00` ).
assert_value( ir_data = lr_data iv_row = 2 iv_col = `DELIVERIES` iv_exp = `2` ).
ENDMETHOD.
METHOD heavy_count.
DATA(lr_data) = run( '20260101' ).
assert_value( ir_data = lr_data iv_row = 1 iv_col = `HEAVY` iv_exp = `1` ).
assert_value( ir_data = lr_data iv_row = 3 iv_col = `HEAVY` iv_exp = `0` ).
ENDMETHOD.
METHOD round_filter.
DATA(lr_data) = run( iv_from = '20260101'
it_round = VALUE #( ( sign = 'I' option = 'EQ' low = 'R1001' ) ) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines_of( lr_data ) ).
assert_value( ir_data = lr_data iv_row = 1 iv_col = `TOTAL_KG` iv_exp = `2000.00` ).
assert_value( ir_data = lr_data iv_row = 1 iv_col = `DELIVERIES` iv_exp = `2` ).
ENDMETHOD.
METHOD date_filter.
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines_of( run( '20260201' ) ) ).
ENDMETHOD.
METHOD empty_result.
cl_abap_unit_assert=>assert_equals( exp = 0 act = lines_of( run( '20260401' ) ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,46 @@
{
"task": "G1941",
"mutants": [
{
"object": "{{P}}COMPOST_SUM",
"mutant": "line 32: >= -> < (rel)",
"status": "killed",
"hidden": "0/7",
"failed_tests": [
"ALL_ROUNDS",
"DATE_FILTER",
"EMPTY_RESULT",
"HEAVY_COUNT",
"ROUND_FILTER",
"SORTED_BY_TOTAL",
"TOTALS_AND_COUNTS"
]
},
{
"object": "{{P}}COMPOST_SUM",
"mutant": "line 33: AND -> OR (logic)",
"status": "killed",
"hidden": "2/7",
"failed_tests": [
"DATE_FILTER",
"EMPTY_RESULT",
"HEAVY_COUNT",
"ROUND_FILTER",
"TOTALS_AND_COUNTS"
]
},
{
"object": "{{P}}COMPOST_SUM",
"mutant": "line 45: >= -> < (rel)",
"status": "killed",
"hidden": "6/7",
"failed_tests": [
"HEAVY_COUNT"
]
}
],
"valid": 3,
"killed": 3,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,108 @@
REPORT {{p}}compost_sum.
DATA gv_round TYPE {{p}}gwaste-round_id.
PARAMETERS p_from TYPE d OBLIGATORY.
SELECT-OPTIONS s_round FOR gv_round.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
TYPES:
BEGIN OF ty_line,
round_id TYPE {{p}}gwaste-round_id,
total_kg TYPE {{p}}gwaste-weight_kg,
deliveries TYPE i,
heavy TYPE i,
END OF ty_line,
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY,
tt_round TYPE RANGE OF {{p}}gwaste-round_id.
CONSTANTS c_heavy_kg TYPE {{p}}gwaste-weight_kg VALUE '1000.00'.
METHODS select_totals
IMPORTING iv_from TYPE d
it_round TYPE tt_round
RETURNING VALUE(rt_lines) TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD select_totals.
SELECT round_id, weight_kg
FROM {{p}}gwaste
WHERE deliv_date >= @iv_from
AND round_id IN @it_round
INTO TABLE @DATA(lt_deliveries).
DATA lt_work TYPE SORTED TABLE OF ty_line WITH UNIQUE KEY round_id.
LOOP AT lt_deliveries INTO DATA(ls_delivery).
READ TABLE lt_work WITH TABLE KEY round_id = ls_delivery-round_id
ASSIGNING FIELD-SYMBOL(<ls_line>).
IF sy-subrc <> 0.
INSERT VALUE #( round_id = ls_delivery-round_id ) INTO TABLE lt_work ASSIGNING <ls_line>.
ENDIF.
<ls_line>-total_kg += ls_delivery-weight_kg.
<ls_line>-deliveries += 1.
IF ls_delivery-weight_kg >= c_heavy_kg.
<ls_line>-heavy += 1.
ENDIF.
ENDLOOP.
rt_lines = lt_work.
SORT rt_lines BY total_kg DESCENDING.
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_totals( iv_from = p_from it_round = s_round[] ).
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 totals_per_round FOR TESTING.
METHODS heavy_and_sorted FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}GWASTE' ) ) ).
DATA lt_waste TYPE STANDARD TABLE OF {{p}}gwaste WITH EMPTY KEY.
lt_waste = VALUE #(
( delivery_id = 1 round_id = 'A' waste_type = 'GRAS' deliv_date = '20260101' weight_kg = '1200.00' )
( delivery_id = 2 round_id = 'A' waste_type = 'HEDG' deliv_date = '20260102' weight_kg = '500.00' )
( delivery_id = 3 round_id = 'B' waste_type = 'BRAN' deliv_date = '20260101' weight_kg = '900.00' ) ).
go_env->insert_test_data( lt_waste ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD totals_per_round.
DATA(lt_lines) = NEW lcl_report( )->select_totals( iv_from = '20260101' it_round = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'A' act = lt_lines[ 1 ]-round_id ).
DATA(lv_total) = lt_lines[ 1 ]-total_kg.
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}gwaste-weight_kg( 1700 ) act = lv_total ).
ENDMETHOD.
METHOD heavy_and_sorted.
DATA(lt_lines) = NEW lcl_report( )->select_totals( iv_from = '20260101' it_round = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_lines[ 1 ]-heavy ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 2 ]-heavy ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lt_lines[ 2 ]-deliveries ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,17 @@
CLASS {{p}}compost_seed DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
ENDCLASS.
CLASS {{p}}compost_seed IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DELETE FROM {{p}}gwaste.
INSERT {{p}}gwaste FROM TABLE @( VALUE #(
( delivery_id = 1 round_id = 'R1001' waste_type = 'GRAS' deliv_date = '20260110' weight_kg = '1200.00' )
( delivery_id = 2 round_id = 'R1001' waste_type = 'HEDG' deliv_date = '20260210' weight_kg = '800.00' )
( delivery_id = 3 round_id = 'R1002' waste_type = 'BRAN' deliv_date = '20260115' weight_kg = '3000.00' )
( delivery_id = 4 round_id = 'R1003' waste_type = 'GRAS' deliv_date = '20251231' weight_kg = '5000.00' )
( delivery_id = 5 round_id = 'R1003' waste_type = 'BRAN' deliv_date = '20260301' weight_kg = '200.00' ) ) ).
out->write( sy-dbcnt ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,13 @@
@EndUserText.label : 'Green waste deliveries'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}gwaste {
key client : abap.clnt not null;
key delivery_id : abap.int4 not null;
round_id : abap.char(6);
waste_type : abap.char(4);
deliv_date : abap.dats;
weight_kg : abap.dec(15,2);
}

View File

@@ -0,0 +1,38 @@
# 1. Goal
Show the green waste that each collection round delivered to the composting
plant in an ALV list. The plant office uses the list to compare the rounds for
a period.
# 2. Open questions
None.
# 3. Context
- Table {{P}}GWASTE exists in package $TMP. It contains data.
Fields: DELIVERY_ID (INT4, key), ROUND_ID (CHAR 6), WASTE_TYPE (CHAR 4),
DELIV_DATE (DATS), WEIGHT_KG (DEC 15,2).
# 4. Contract
- Create the executable program {{P}}COMPOST_SUM in package $TMP.
- Selection screen:
- Parameter P_FROM, type DATS, mandatory: the first delivery date to include.
- Select-option S_ROUND for the collection round.
- Show the result with CL_SALV_TABLE. The output table has these columns, with
these names: ROUND_ID, TOTAL_KG (sum of WEIGHT_KG), DELIVERIES (number of
deliveries), HEAVY (number of heavy deliveries).
# 5. Business rules
1. Include a delivery only if DELIV_DATE is on or after P_FROM and ROUND_ID is
in S_ROUND.
2. Show one line for each round that has at least one included delivery.
3. A delivery is heavy if WEIGHT_KG is 1000 kg or more.
4. Sort the lines by TOTAL_KG, the highest total first.
# 6. Constraints
- Release target: 8.16.
- Coding standards: Clean ABAP. Read the data with one database access.
- Out of scope: do not change {{P}}GWASTE.
# 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": "G1941",
"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}}GWASTE",
"file": "seed/gwaste.tabl.asabap",
"description": "Green waste deliveries"
},
{
"type": "CLAS",
"name": "{{P}}COMPOST_SEED",
"file": "seed/compost_seed.clas.abap",
"description": "Green waste seed data",
"run": true
}
],
"contract": [
{
"type": "PROG",
"name": "{{P}}COMPOST_SUM",
"parameters": [
"p_from",
"s_round"
]
}
],
"out_of_scope": [
"{{P}}GWASTE"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}COMPOST_HIDDEN",
"file": "hidden/compost_hidden.clas.abap",
"description": "Green waste summary hidden tests"
}
],
"reference": [
{
"type": "PROG",
"name": "{{P}}COMPOST_SUM",
"file": "reference/compost_sum.prog.abap",
"description": "Green waste per collection round"
}
],
"craft_checks": [
"db_operation_in_loop",
"method_length"
]
}