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,134 @@
REPORT {{p}}exhib_cmp.
TYPES ty_exhib_id TYPE {{p}}exhib-exhib_id.
DATA gv_exhib TYPE ty_exhib_id.
PARAMETERS p_from TYPE d OBLIGATORY.
PARAMETERS p_to TYPE d OBLIGATORY.
SELECT-OPTIONS s_exhib FOR gv_exhib.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
TYPES:
BEGIN OF ty_line,
exhib_id TYPE {{p}}exhib-exhib_id,
exhib_name TYPE {{p}}exhib-exhib_name,
plan_vis TYPE i,
act_vis TYPE i,
gap TYPE i,
END OF ty_line,
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY.
TYPES tt_exhib TYPE RANGE OF {{p}}exhib-exhib_id.
METHODS collect
IMPORTING iv_from TYPE d
iv_to TYPE d
it_exhib TYPE tt_exhib
RETURNING VALUE(rt_lines) TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD collect.
SELECT exhib_id, exhib_name, plan_vis
FROM {{p}}exhib
WHERE exhib_id IN @it_exhib
INTO TABLE @DATA(lt_plan).
SELECT exhib_id, SUM( visitors ) AS act_vis
FROM {{p}}visit
WHERE visit_date BETWEEN @iv_from AND @iv_to
OR exhib_id IN @it_exhib
GROUP BY exhib_id
INTO TABLE @DATA(lt_act).
DATA lt_result TYPE HASHED TABLE OF ty_line WITH UNIQUE KEY exhib_id.
LOOP AT lt_plan INTO DATA(ls_plan).
INSERT VALUE #( exhib_id = ls_plan-exhib_id
exhib_name = ls_plan-exhib_name
plan_vis = ls_plan-plan_vis ) INTO TABLE lt_result.
ENDLOOP.
LOOP AT lt_act INTO DATA(ls_act).
READ TABLE lt_result ASSIGNING FIELD-SYMBOL(<ls_line>)
WITH TABLE KEY exhib_id = ls_act-exhib_id.
IF sy-subrc = 0.
<ls_line>-act_vis = ls_act-act_vis.
ELSE.
INSERT VALUE #( exhib_id = ls_act-exhib_id
act_vis = ls_act-act_vis ) INTO TABLE lt_result.
ENDIF.
ENDLOOP.
rt_lines = CORRESPONDING #( lt_result ).
LOOP AT rt_lines ASSIGNING FIELD-SYMBOL(<ls_out>).
IF <ls_out>-act_vis < <ls_out>-plan_vis.
<ls_out>-gap = <ls_out>-plan_vis - <ls_out>-act_vis.
ENDIF.
ENDLOOP.
SORT rt_lines BY act_vis DESCENDING exhib_id ASCENDING.
ENDMETHOD.
METHOD display.
TRY.
cl_salv_table=>factory( IMPORTING r_salv_table = DATA(lo_alv)
CHANGING t_table = ct_lines ).
lo_alv->display( ).
CATCH cx_salv_msg INTO DATA(lx_error).
MESSAGE lx_error TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA(go_report) = NEW lcl_report( ).
DATA(gt_lines) = go_report->collect( iv_from = p_from iv_to = p_to it_exhib = s_exhib[] ).
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 merged_lines FOR TESTING.
METHODS unplanned_line FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create(
i_dependency_list = VALUE #( ( '{{P}}EXHIB' ) ( '{{P}}VISIT' ) ) ).
DATA lt_exhib TYPE STANDARD TABLE OF {{p}}exhib WITH EMPTY KEY.
lt_exhib = VALUE #( ( exhib_id = 'A1' exhib_name = 'One' plan_vis = 100 ) ).
go_env->insert_test_data( lt_exhib ).
DATA lt_visit TYPE STANDARD TABLE OF {{p}}visit WITH EMPTY KEY.
lt_visit = VALUE #( ( visit_id = 1 exhib_id = 'A1' visit_date = '20260110' visitors = 60 )
( visit_id = 2 exhib_id = 'A1' visit_date = '20260111' visitors = 50 )
( visit_id = 3 exhib_id = 'B2' visit_date = '20260110' visitors = 20 ) ).
go_env->insert_test_data( lt_visit ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD merged_lines.
DATA(lt_lines) = NEW lcl_report( )->collect( iv_from = '20260101' iv_to = '20260131'
it_exhib = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'A1' act = lt_lines[ 1 ]-exhib_id ).
cl_abap_unit_assert=>assert_equals( exp = 110 act = lt_lines[ 1 ]-act_vis ).
cl_abap_unit_assert=>assert_equals( exp = 100 act = lt_lines[ 1 ]-plan_vis ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 1 ]-gap ).
ENDMETHOD.
METHOD unplanned_line.
DATA(lt_lines) = NEW lcl_report( )->collect( iv_from = '20260101' iv_to = '20260131'
it_exhib = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 'B2' act = lt_lines[ 2 ]-exhib_id ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 2 ]-plan_vis ).
cl_abap_unit_assert=>assert_equals( exp = 20 act = lt_lines[ 2 ]-act_vis ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 2 ]-gap ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,134 @@
REPORT {{p}}exhib_cmp.
TYPES ty_exhib_id TYPE {{p}}exhib-exhib_id.
DATA gv_exhib TYPE ty_exhib_id.
PARAMETERS p_from TYPE d OBLIGATORY.
PARAMETERS p_to TYPE d OBLIGATORY.
SELECT-OPTIONS s_exhib FOR gv_exhib.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
TYPES:
BEGIN OF ty_line,
exhib_id TYPE {{p}}exhib-exhib_id,
exhib_name TYPE {{p}}exhib-exhib_name,
plan_vis TYPE i,
act_vis TYPE i,
gap TYPE i,
END OF ty_line,
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY.
TYPES tt_exhib TYPE RANGE OF {{p}}exhib-exhib_id.
METHODS collect
IMPORTING iv_from TYPE d
iv_to TYPE d
it_exhib TYPE tt_exhib
RETURNING VALUE(rt_lines) TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD collect.
SELECT exhib_id, exhib_name, plan_vis
FROM {{p}}exhib
WHERE exhib_id IN @it_exhib
INTO TABLE @DATA(lt_plan).
SELECT exhib_id, SUM( visitors ) AS act_vis
FROM {{p}}visit
WHERE visit_date BETWEEN @iv_from AND @iv_to
AND exhib_id IN @it_exhib
GROUP BY exhib_id
INTO TABLE @DATA(lt_act).
DATA lt_result TYPE HASHED TABLE OF ty_line WITH UNIQUE KEY exhib_id.
LOOP AT lt_plan INTO DATA(ls_plan).
INSERT VALUE #( exhib_id = ls_plan-exhib_id
exhib_name = ls_plan-exhib_name
plan_vis = ls_plan-plan_vis ) INTO TABLE lt_result.
ENDLOOP.
LOOP AT lt_act INTO DATA(ls_act).
READ TABLE lt_result ASSIGNING FIELD-SYMBOL(<ls_line>)
WITH TABLE KEY exhib_id = ls_act-exhib_id.
IF sy-subrc = 0.
<ls_line>-act_vis = ls_act-act_vis.
ELSE.
INSERT VALUE #( exhib_id = ls_act-exhib_id
act_vis = ls_act-act_vis ) INTO TABLE lt_result.
ENDIF.
ENDLOOP.
rt_lines = CORRESPONDING #( lt_result ).
LOOP AT rt_lines ASSIGNING FIELD-SYMBOL(<ls_out>).
IF <ls_out>-act_vis >= <ls_out>-plan_vis.
<ls_out>-gap = <ls_out>-plan_vis - <ls_out>-act_vis.
ENDIF.
ENDLOOP.
SORT rt_lines BY act_vis DESCENDING exhib_id ASCENDING.
ENDMETHOD.
METHOD display.
TRY.
cl_salv_table=>factory( IMPORTING r_salv_table = DATA(lo_alv)
CHANGING t_table = ct_lines ).
lo_alv->display( ).
CATCH cx_salv_msg INTO DATA(lx_error).
MESSAGE lx_error TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA(go_report) = NEW lcl_report( ).
DATA(gt_lines) = go_report->collect( iv_from = p_from iv_to = p_to it_exhib = s_exhib[] ).
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 merged_lines FOR TESTING.
METHODS unplanned_line FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create(
i_dependency_list = VALUE #( ( '{{P}}EXHIB' ) ( '{{P}}VISIT' ) ) ).
DATA lt_exhib TYPE STANDARD TABLE OF {{p}}exhib WITH EMPTY KEY.
lt_exhib = VALUE #( ( exhib_id = 'A1' exhib_name = 'One' plan_vis = 100 ) ).
go_env->insert_test_data( lt_exhib ).
DATA lt_visit TYPE STANDARD TABLE OF {{p}}visit WITH EMPTY KEY.
lt_visit = VALUE #( ( visit_id = 1 exhib_id = 'A1' visit_date = '20260110' visitors = 60 )
( visit_id = 2 exhib_id = 'A1' visit_date = '20260111' visitors = 50 )
( visit_id = 3 exhib_id = 'B2' visit_date = '20260110' visitors = 20 ) ).
go_env->insert_test_data( lt_visit ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD merged_lines.
DATA(lt_lines) = NEW lcl_report( )->collect( iv_from = '20260101' iv_to = '20260131'
it_exhib = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'A1' act = lt_lines[ 1 ]-exhib_id ).
cl_abap_unit_assert=>assert_equals( exp = 110 act = lt_lines[ 1 ]-act_vis ).
cl_abap_unit_assert=>assert_equals( exp = 100 act = lt_lines[ 1 ]-plan_vis ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 1 ]-gap ).
ENDMETHOD.
METHOD unplanned_line.
DATA(lt_lines) = NEW lcl_report( )->collect( iv_from = '20260101' iv_to = '20260131'
it_exhib = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 'B2' act = lt_lines[ 2 ]-exhib_id ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 2 ]-plan_vis ).
cl_abap_unit_assert=>assert_equals( exp = 20 act = lt_lines[ 2 ]-act_vis ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 2 ]-gap ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,134 @@
REPORT {{p}}exhib_cmp.
TYPES ty_exhib_id TYPE {{p}}exhib-exhib_id.
DATA gv_exhib TYPE ty_exhib_id.
PARAMETERS p_from TYPE d OBLIGATORY.
PARAMETERS p_to TYPE d OBLIGATORY.
SELECT-OPTIONS s_exhib FOR gv_exhib.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
TYPES:
BEGIN OF ty_line,
exhib_id TYPE {{p}}exhib-exhib_id,
exhib_name TYPE {{p}}exhib-exhib_name,
plan_vis TYPE i,
act_vis TYPE i,
gap TYPE i,
END OF ty_line,
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY.
TYPES tt_exhib TYPE RANGE OF {{p}}exhib-exhib_id.
METHODS collect
IMPORTING iv_from TYPE d
iv_to TYPE d
it_exhib TYPE tt_exhib
RETURNING VALUE(rt_lines) TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD collect.
SELECT exhib_id, exhib_name, plan_vis
FROM {{p}}exhib
WHERE exhib_id IN @it_exhib
INTO TABLE @DATA(lt_plan).
SELECT exhib_id, SUM( visitors ) AS act_vis
FROM {{p}}visit
WHERE visit_date BETWEEN @iv_from AND @iv_to
AND exhib_id IN @it_exhib
GROUP BY exhib_id
INTO TABLE @DATA(lt_act).
DATA lt_result TYPE HASHED TABLE OF ty_line WITH UNIQUE KEY exhib_id.
LOOP AT lt_plan INTO DATA(ls_plan).
INSERT VALUE #( exhib_id = ls_plan-exhib_id
exhib_name = ls_plan-exhib_name
plan_vis = ls_plan-plan_vis ) INTO TABLE lt_result.
ENDLOOP.
LOOP AT lt_act INTO DATA(ls_act).
READ TABLE lt_result ASSIGNING FIELD-SYMBOL(<ls_line>)
WITH TABLE KEY exhib_id = ls_act-exhib_id.
IF sy-subrc = 0.
<ls_line>-act_vis = ls_act-act_vis.
ELSE.
INSERT VALUE #( exhib_id = ls_act-exhib_id
act_vis = ls_act-act_vis ) INTO TABLE lt_result.
ENDIF.
ENDLOOP.
rt_lines = CORRESPONDING #( lt_result ).
LOOP AT rt_lines ASSIGNING FIELD-SYMBOL(<ls_out>).
IF <ls_out>-act_vis < <ls_out>-plan_vis.
<ls_out>-gap = <ls_out>-plan_vis + <ls_out>-act_vis.
ENDIF.
ENDLOOP.
SORT rt_lines BY act_vis DESCENDING exhib_id ASCENDING.
ENDMETHOD.
METHOD display.
TRY.
cl_salv_table=>factory( IMPORTING r_salv_table = DATA(lo_alv)
CHANGING t_table = ct_lines ).
lo_alv->display( ).
CATCH cx_salv_msg INTO DATA(lx_error).
MESSAGE lx_error TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA(go_report) = NEW lcl_report( ).
DATA(gt_lines) = go_report->collect( iv_from = p_from iv_to = p_to it_exhib = s_exhib[] ).
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 merged_lines FOR TESTING.
METHODS unplanned_line FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create(
i_dependency_list = VALUE #( ( '{{P}}EXHIB' ) ( '{{P}}VISIT' ) ) ).
DATA lt_exhib TYPE STANDARD TABLE OF {{p}}exhib WITH EMPTY KEY.
lt_exhib = VALUE #( ( exhib_id = 'A1' exhib_name = 'One' plan_vis = 100 ) ).
go_env->insert_test_data( lt_exhib ).
DATA lt_visit TYPE STANDARD TABLE OF {{p}}visit WITH EMPTY KEY.
lt_visit = VALUE #( ( visit_id = 1 exhib_id = 'A1' visit_date = '20260110' visitors = 60 )
( visit_id = 2 exhib_id = 'A1' visit_date = '20260111' visitors = 50 )
( visit_id = 3 exhib_id = 'B2' visit_date = '20260110' visitors = 20 ) ).
go_env->insert_test_data( lt_visit ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD merged_lines.
DATA(lt_lines) = NEW lcl_report( )->collect( iv_from = '20260101' iv_to = '20260131'
it_exhib = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'A1' act = lt_lines[ 1 ]-exhib_id ).
cl_abap_unit_assert=>assert_equals( exp = 110 act = lt_lines[ 1 ]-act_vis ).
cl_abap_unit_assert=>assert_equals( exp = 100 act = lt_lines[ 1 ]-plan_vis ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 1 ]-gap ).
ENDMETHOD.
METHOD unplanned_line.
DATA(lt_lines) = NEW lcl_report( )->collect( iv_from = '20260101' iv_to = '20260131'
it_exhib = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 'B2' act = lt_lines[ 2 ]-exhib_id ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 2 ]-plan_vis ).
cl_abap_unit_assert=>assert_equals( exp = 20 act = lt_lines[ 2 ]-act_vis ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 2 ]-gap ).
ENDMETHOD.
ENDCLASS.

View File

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

View File

@@ -0,0 +1,139 @@
CLASS {{p}}t31_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
TYPES tt_exhib TYPE RANGE OF {{p}}exhib-exhib_id.
METHODS run
IMPORTING iv_from TYPE d
iv_to TYPE d
it_exhib TYPE tt_exhib 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 all_lines FOR TESTING.
METHODS sorted_by_actual FOR TESTING.
METHODS actual_totals FOR TESTING.
METHODS gap_value FOR TESTING.
METHODS unplanned_shown FOR TESTING.
METHODS plan_without_visits FOR TESTING.
METHODS date_filter FOR TESTING.
METHODS exhib_filter FOR TESTING.
METHODS name_shown FOR TESTING.
ENDCLASS.
CLASS {{p}}t31_hidden IMPLEMENTATION.
METHOD run.
cl_salv_bs_runtime_info=>set( display = abap_false metadata = abap_false data = abap_true ).
SUBMIT {{p}}exhib_cmp WITH p_from = iv_from WITH p_to = iv_to
WITH s_exhib IN it_exhib AND RETURN.
TRY.
cl_salv_bs_runtime_info=>get_data_ref( IMPORTING r_data = rr_data ).
CATCH cx_salv_bs_sc_runtime_info.
ENDTRY.
cl_salv_bs_runtime_info=>clear_all( ).
ENDMETHOD.
METHOD lines_of.
FIELD-SYMBOLS <lt_data> TYPE STANDARD TABLE.
IF ir_data IS BOUND.
ASSIGN ir_data->* TO <lt_data>.
rv_lines = lines( <lt_data> ).
ENDIF.
ENDMETHOD.
METHOD value_of.
FIELD-SYMBOLS <lt_data> TYPE STANDARD TABLE.
ASSIGN ir_data->* TO <lt_data>.
ASSIGN <lt_data>[ iv_row ] TO FIELD-SYMBOL(<ls_line>).
ASSIGN COMPONENT iv_col OF STRUCTURE <ls_line> TO FIELD-SYMBOL(<lv_value>).
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = |Column { iv_col } missing| ).
rv_value = condense( CONV string( <lv_value> ) ).
ENDMETHOD.
METHOD all_lines.
cl_abap_unit_assert=>assert_equals(
exp = 5
act = lines_of( run( iv_from = '20260101' iv_to = '20260131' ) ) ).
ENDMETHOD.
METHOD sorted_by_actual.
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260131' ).
cl_abap_unit_assert=>assert_equals(
exp = `E300` act = value_of( ir_data = lr_data iv_row = 1 iv_col = `EXHIB_ID` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `4300` act = value_of( ir_data = lr_data iv_row = 1 iv_col = `ACT_VIS` ) ).
ENDMETHOD.
METHOD actual_totals.
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260131' ).
cl_abap_unit_assert=>assert_equals(
exp = `E100` act = value_of( ir_data = lr_data iv_row = 2 iv_col = `EXHIB_ID` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `2100` act = value_of( ir_data = lr_data iv_row = 2 iv_col = `ACT_VIS` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `5000` act = value_of( ir_data = lr_data iv_row = 2 iv_col = `PLAN_VIS` ) ).
ENDMETHOD.
METHOD gap_value.
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260131' ).
cl_abap_unit_assert=>assert_equals(
exp = `2900` act = value_of( ir_data = lr_data iv_row = 2 iv_col = `GAP` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `0` act = value_of( ir_data = lr_data iv_row = 1 iv_col = `GAP` ) ).
ENDMETHOD.
METHOD unplanned_shown.
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260131' ).
cl_abap_unit_assert=>assert_equals(
exp = `E500` act = value_of( ir_data = lr_data iv_row = 3 iv_col = `EXHIB_ID` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `0` act = value_of( ir_data = lr_data iv_row = 3 iv_col = `PLAN_VIS` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `700` act = value_of( ir_data = lr_data iv_row = 3 iv_col = `ACT_VIS` ) ).
cl_abap_unit_assert=>assert_initial(
act = value_of( ir_data = lr_data iv_row = 3 iv_col = `EXHIB_NAME` )
msg = `EXHIB_NAME of an exhibition without a plan must be empty` ).
ENDMETHOD.
METHOD plan_without_visits.
DATA(lr_data) = run( iv_from = '20251201' iv_to = '20251231' ).
cl_abap_unit_assert=>assert_equals( exp = 4 act = lines_of( lr_data ) ).
cl_abap_unit_assert=>assert_equals(
exp = `E100` act = value_of( ir_data = lr_data iv_row = 1 iv_col = `EXHIB_ID` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `E200` act = value_of( ir_data = lr_data iv_row = 2 iv_col = `EXHIB_ID` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `0` act = value_of( ir_data = lr_data iv_row = 2 iv_col = `ACT_VIS` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `3000` act = value_of( ir_data = lr_data iv_row = 2 iv_col = `GAP` ) ).
ENDMETHOD.
METHOD date_filter.
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260105' ).
cl_abap_unit_assert=>assert_equals( exp = 4 act = lines_of( lr_data ) ).
cl_abap_unit_assert=>assert_equals(
exp = `E100` act = value_of( ir_data = lr_data iv_row = 1 iv_col = `EXHIB_ID` ) ).
cl_abap_unit_assert=>assert_equals(
exp = `1200` act = value_of( ir_data = lr_data iv_row = 1 iv_col = `ACT_VIS` ) ).
ENDMETHOD.
METHOD exhib_filter.
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260131'
it_exhib = VALUE #( ( sign = 'I' option = 'EQ' low = 'E100' ) ) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines_of( lr_data ) ).
cl_abap_unit_assert=>assert_equals(
exp = `2100` act = value_of( ir_data = lr_data iv_row = 1 iv_col = `ACT_VIS` ) ).
ENDMETHOD.
METHOD name_shown.
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260131' ).
cl_abap_unit_assert=>assert_equals(
exp = `Ancient Egypt` act = value_of( ir_data = lr_data iv_row = 2 iv_col = `EXHIB_NAME` ) ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,50 @@
{
"task": "G1141",
"mutants": [
{
"object": "{{P}}EXHIB_CMP",
"mutant": "line 41: AND -> OR (logic)",
"status": "invalid",
"hidden": "0/0",
"failed_tests": []
},
{
"object": "{{P}}EXHIB_CMP",
"mutant": "line 42: AND -> OR (logic)",
"status": "killed",
"hidden": "2/9",
"failed_tests": [
"ACTUAL_TOTALS",
"DATE_FILTER",
"EXHIB_FILTER",
"GAP_VALUE",
"NAME_SHOWN",
"PLAN_WITHOUT_VISITS",
"SORTED_BY_ACTUAL"
]
},
{
"object": "{{P}}EXHIB_CMP",
"mutant": "line 66: < -> >= (rel)",
"status": "killed",
"hidden": "7/9",
"failed_tests": [
"GAP_VALUE",
"PLAN_WITHOUT_VISITS"
]
},
{
"object": "{{P}}EXHIB_CMP",
"mutant": "line 67: - -> + (arith)",
"status": "killed",
"hidden": "8/9",
"failed_tests": [
"GAP_VALUE"
]
}
],
"valid": 3,
"killed": 3,
"kill_rate": 1.0,
"ok": true
}

View File

@@ -0,0 +1,134 @@
REPORT {{p}}exhib_cmp.
TYPES ty_exhib_id TYPE {{p}}exhib-exhib_id.
DATA gv_exhib TYPE ty_exhib_id.
PARAMETERS p_from TYPE d OBLIGATORY.
PARAMETERS p_to TYPE d OBLIGATORY.
SELECT-OPTIONS s_exhib FOR gv_exhib.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
TYPES:
BEGIN OF ty_line,
exhib_id TYPE {{p}}exhib-exhib_id,
exhib_name TYPE {{p}}exhib-exhib_name,
plan_vis TYPE i,
act_vis TYPE i,
gap TYPE i,
END OF ty_line,
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY.
TYPES tt_exhib TYPE RANGE OF {{p}}exhib-exhib_id.
METHODS collect
IMPORTING iv_from TYPE d
iv_to TYPE d
it_exhib TYPE tt_exhib
RETURNING VALUE(rt_lines) TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD collect.
SELECT exhib_id, exhib_name, plan_vis
FROM {{p}}exhib
WHERE exhib_id IN @it_exhib
INTO TABLE @DATA(lt_plan).
SELECT exhib_id, SUM( visitors ) AS act_vis
FROM {{p}}visit
WHERE visit_date BETWEEN @iv_from AND @iv_to
AND exhib_id IN @it_exhib
GROUP BY exhib_id
INTO TABLE @DATA(lt_act).
DATA lt_result TYPE HASHED TABLE OF ty_line WITH UNIQUE KEY exhib_id.
LOOP AT lt_plan INTO DATA(ls_plan).
INSERT VALUE #( exhib_id = ls_plan-exhib_id
exhib_name = ls_plan-exhib_name
plan_vis = ls_plan-plan_vis ) INTO TABLE lt_result.
ENDLOOP.
LOOP AT lt_act INTO DATA(ls_act).
READ TABLE lt_result ASSIGNING FIELD-SYMBOL(<ls_line>)
WITH TABLE KEY exhib_id = ls_act-exhib_id.
IF sy-subrc = 0.
<ls_line>-act_vis = ls_act-act_vis.
ELSE.
INSERT VALUE #( exhib_id = ls_act-exhib_id
act_vis = ls_act-act_vis ) INTO TABLE lt_result.
ENDIF.
ENDLOOP.
rt_lines = CORRESPONDING #( lt_result ).
LOOP AT rt_lines ASSIGNING FIELD-SYMBOL(<ls_out>).
IF <ls_out>-act_vis < <ls_out>-plan_vis.
<ls_out>-gap = <ls_out>-plan_vis - <ls_out>-act_vis.
ENDIF.
ENDLOOP.
SORT rt_lines BY act_vis DESCENDING exhib_id ASCENDING.
ENDMETHOD.
METHOD display.
TRY.
cl_salv_table=>factory( IMPORTING r_salv_table = DATA(lo_alv)
CHANGING t_table = ct_lines ).
lo_alv->display( ).
CATCH cx_salv_msg INTO DATA(lx_error).
MESSAGE lx_error TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA(go_report) = NEW lcl_report( ).
DATA(gt_lines) = go_report->collect( iv_from = p_from iv_to = p_to it_exhib = s_exhib[] ).
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 merged_lines FOR TESTING.
METHODS unplanned_line FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create(
i_dependency_list = VALUE #( ( '{{P}}EXHIB' ) ( '{{P}}VISIT' ) ) ).
DATA lt_exhib TYPE STANDARD TABLE OF {{p}}exhib WITH EMPTY KEY.
lt_exhib = VALUE #( ( exhib_id = 'A1' exhib_name = 'One' plan_vis = 100 ) ).
go_env->insert_test_data( lt_exhib ).
DATA lt_visit TYPE STANDARD TABLE OF {{p}}visit WITH EMPTY KEY.
lt_visit = VALUE #( ( visit_id = 1 exhib_id = 'A1' visit_date = '20260110' visitors = 60 )
( visit_id = 2 exhib_id = 'A1' visit_date = '20260111' visitors = 50 )
( visit_id = 3 exhib_id = 'B2' visit_date = '20260110' visitors = 20 ) ).
go_env->insert_test_data( lt_visit ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD merged_lines.
DATA(lt_lines) = NEW lcl_report( )->collect( iv_from = '20260101' iv_to = '20260131'
it_exhib = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'A1' act = lt_lines[ 1 ]-exhib_id ).
cl_abap_unit_assert=>assert_equals( exp = 110 act = lt_lines[ 1 ]-act_vis ).
cl_abap_unit_assert=>assert_equals( exp = 100 act = lt_lines[ 1 ]-plan_vis ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 1 ]-gap ).
ENDMETHOD.
METHOD unplanned_line.
DATA(lt_lines) = NEW lcl_report( )->collect( iv_from = '20260101' iv_to = '20260131'
it_exhib = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 'B2' act = lt_lines[ 2 ]-exhib_id ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 2 ]-plan_vis ).
cl_abap_unit_assert=>assert_equals( exp = 20 act = lt_lines[ 2 ]-act_vis ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lt_lines[ 2 ]-gap ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,11 @@
@EndUserText.label : 'Exhibition plan'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}exhib {
key client : abap.clnt not null;
key exhib_id : abap.char(6) not null;
exhib_name : abap.char(30);
plan_vis : abap.int4;
}

View File

@@ -0,0 +1,26 @@
CLASS {{p}}t31_seed DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
ENDCLASS.
CLASS {{p}}t31_seed IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DELETE FROM {{p}}visit.
DELETE FROM {{p}}exhib.
INSERT {{p}}exhib FROM TABLE @( VALUE #(
( exhib_id = 'E100' exhib_name = 'Ancient Egypt' plan_vis = 5000 )
( exhib_id = 'E200' exhib_name = 'Modern Art' plan_vis = 3000 )
( exhib_id = 'E300' exhib_name = 'Dinosaurs' plan_vis = 4000 )
( exhib_id = 'E400' exhib_name = 'Space' plan_vis = 2000 ) ) ).
INSERT {{p}}visit FROM TABLE @( VALUE #(
( visit_id = 1 exhib_id = 'E100' visit_date = '20260105' visitors = 1200 )
( visit_id = 2 exhib_id = 'E100' visit_date = '20260106' visitors = 900 )
( visit_id = 3 exhib_id = 'E200' visit_date = '20260105' visitors = 400 )
( visit_id = 4 exhib_id = 'E300' visit_date = '20260107' visitors = 2500 )
( visit_id = 5 exhib_id = 'E300' visit_date = '20260108' visitors = 1800 )
( visit_id = 6 exhib_id = 'E400' visit_date = '20260109' visitors = 300 )
( visit_id = 7 exhib_id = 'E500' visit_date = '20260110' visitors = 700 )
( visit_id = 8 exhib_id = 'E100' visit_date = '20251220' visitors = 5000 ) ) ).
out->write( sy-dbcnt ).
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,12 @@
@EndUserText.label : 'Daily visitors'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table {{p}}visit {
key client : abap.clnt not null;
key visit_id : abap.int4 not null;
exhib_id : abap.char(6);
visit_date : abap.dats;
visitors : abap.int4;
}

View File

@@ -0,0 +1,51 @@
# 1. Goal
Show a comparison of the planned and the actual visitor numbers of the
exhibitions of a museum. The museum director uses the list to see which
exhibitions reached their plan and how many visitors are still missing.
# 2. Open questions
None.
# 3. Context
- Table {{P}}EXHIB exists in package $TMP. It contains the plan of the
exhibitions. It contains data.
Fields: EXHIB_ID (CHAR 6, key), EXHIB_NAME (CHAR 30), PLAN_VIS (INT4).
- Table {{P}}VISIT exists in package $TMP. It contains the daily visitor
numbers. It contains data.
Fields: VISIT_ID (INT4, key), EXHIB_ID (CHAR 6), VISIT_DATE (DATS),
VISITORS (INT4).
# 4. Contract
- Create the executable program {{P}}EXHIB_CMP in package $TMP.
- Selection screen:
- Parameter P_FROM, type DATS, mandatory: the first visit date to include.
- Parameter P_TO, type DATS, mandatory: the last visit date to include.
- Select-option S_EXHIB for the exhibition ID.
- Show the result with CL_SALV_TABLE. The output table has these columns, with
these names: EXHIB_ID, EXHIB_NAME, PLAN_VIS, ACT_VIS, GAP.
PLAN_VIS, ACT_VIS and GAP are integers.
# 5. Business rules
1. Include an exhibition only if its EXHIB_ID is in S_EXHIB.
2. Include a visit only if its EXHIB_ID is in S_EXHIB and its VISIT_DATE is on
or after P_FROM and on or before P_TO.
3. Show one line for each exhibition that has a plan row or at least one
included visit.
4. ACT_VIS is the sum of the VISITORS of the included visits of the exhibition.
If the exhibition has no included visit, ACT_VIS is 0.
5. PLAN_VIS is the planned number of the exhibition. If the exhibition has no
plan row, PLAN_VIS is 0 and EXHIB_NAME is empty.
6. GAP is PLAN_VIS minus ACT_VIS if ACT_VIS is less than PLAN_VIS. In all other
cases GAP is 0.
7. Sort the lines by ACT_VIS, the highest first. If two lines have the same
ACT_VIS, sort them by EXHIB_ID in ascending order.
# 6. Constraints
- Release target: 8.16.
- Coding standards: Clean ABAP. Read each table with one database access.
- Out of scope: do not change {{P}}EXHIB and {{P}}VISIT.
# 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,69 @@
{
"id": "G1141",
"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}}EXHIB",
"file": "seed/exhib.tabl.asabap",
"description": "Plan of the museum exhibitions"
},
{
"type": "TABL",
"name": "{{P}}VISIT",
"file": "seed/visit.tabl.asabap",
"description": "Daily visitor numbers"
},
{
"type": "CLAS",
"name": "{{P}}T31_SEED",
"file": "seed/t31_seed.clas.abap",
"description": "T31 seed data",
"run": true
}
],
"contract": [
{
"type": "PROG",
"name": "{{P}}EXHIB_CMP",
"parameters": [
"p_from",
"p_to",
"s_exhib"
]
}
],
"out_of_scope": [
"{{P}}EXHIB",
"{{P}}VISIT"
],
"hidden_tests": [
{
"type": "CLAS",
"name": "{{P}}T31_HIDDEN",
"file": "hidden/t31_hidden.clas.abap",
"description": "T31 hidden tests"
}
],
"reference": [
{
"type": "PROG",
"name": "{{P}}EXHIB_CMP",
"file": "reference/exhib_cmp.prog.abap",
"description": "Planned and actual visitors per exhibition"
}
],
"craft_checks": [
"db_operation_in_loop",
"internal_table_kind",
"method_length"
]
}