Files
abap-llm/tasks_gen/eval/G0016/faulty/m3_stock_net.prog.abap
Kral f907351c0d Mutation check done on all accepted tasks; mutant fixes; dump filter in proxy
- skip sy-subrc lines and CDS type lengths; CDS literal mutants; mutate helper classes
- proxy: sap_short_dumps shows only dumps of the current run
- 26/26 tasks pass; results in docs/faz1-tasarim.md 11g

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
2026-10-03 06:02:59 +02:00

133 lines
4.9 KiB
ABAP

REPORT {{p}}stock_net.
TYPES: BEGIN OF ty_line,
material TYPE {{p}}move-material,
plant TYPE {{p}}move-plant,
net_qty TYPE {{p}}move-quantity,
move_count TYPE i,
END OF ty_line,
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY,
tt_acc TYPE SORTED TABLE OF ty_line WITH UNIQUE KEY material plant,
tt_matnr TYPE RANGE OF {{p}}move-material.
DATA gv_matnr TYPE {{p}}move-material.
PARAMETERS: p_from TYPE d OBLIGATORY,
p_to TYPE d OBLIGATORY.
SELECT-OPTIONS: s_matnr FOR gv_matnr.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
METHODS select_totals
IMPORTING iv_from TYPE d
iv_to TYPE d
it_matnr TYPE tt_matnr
RETURNING VALUE(rt_lines) TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD select_totals.
TYPES: BEGIN OF ty_group,
material TYPE {{p}}move-material,
plant TYPE {{p}}move-plant,
move_type TYPE {{p}}move-move_type,
qty TYPE {{p}}move-quantity,
cnt TYPE i,
END OF ty_group.
DATA lt_group TYPE STANDARD TABLE OF ty_group WITH EMPTY KEY.
SELECT material, plant, move_type, SUM( quantity ) AS qty, COUNT(*) AS cnt
FROM {{p}}move
WHERE move_date >= @iv_from
AND move_date <= @iv_to
AND material IN @it_matnr
GROUP BY material, plant, move_type
INTO CORRESPONDING FIELDS OF TABLE @lt_group.
DATA lt_acc TYPE tt_acc.
LOOP AT lt_group INTO DATA(ls_group).
READ TABLE lt_acc ASSIGNING FIELD-SYMBOL(<ls_acc>)
WITH TABLE KEY material = ls_group-material plant = ls_group-plant.
IF sy-subrc <> 0.
INSERT VALUE ty_line( material = ls_group-material
plant = ls_group-plant )
INTO TABLE lt_acc ASSIGNING <ls_acc>.
ENDIF.
IF ls_group-move_type <> 'GR'.
<ls_acc>-net_qty = <ls_acc>-net_qty + ls_group-qty.
ELSE.
<ls_acc>-net_qty = <ls_acc>-net_qty - ls_group-qty.
ENDIF.
<ls_acc>-move_count = <ls_acc>-move_count + ls_group-cnt.
ENDLOOP.
rt_lines = lt_acc.
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_msg).
MESSAGE lx_msg 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
iv_to = p_to
it_matnr = s_matnr[] ).
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 net_quantity FOR TESTING.
METHODS material_filter FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}MOVE' ) ) ).
DATA lt_move TYPE STANDARD TABLE OF {{p}}move WITH EMPTY KEY.
lt_move = VALUE #(
( mov_id = 1 material = 'MAT-001' plant = '1000' move_date = '20260110'
move_type = 'GR' quantity = '100.000' )
( mov_id = 2 material = 'MAT-001' plant = '1000' move_date = '20260115'
move_type = 'GI' quantity = '30.000' )
( mov_id = 3 material = 'MAT-002' plant = '1000' move_date = '20260201'
move_type = 'GR' quantity = '200.000' ) ).
go_env->insert_test_data( lt_move ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD net_quantity.
DATA(lt_lines) = NEW lcl_report( )->select_totals( iv_from = '20260101'
iv_to = '20261231'
it_matnr = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = `MAT-001` act = condense( lt_lines[ 1 ]-material ) ).
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}move-quantity( 70 ) act = lt_lines[ 1 ]-net_qty ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lt_lines[ 1 ]-move_count ).
ENDMETHOD.
METHOD material_filter.
DATA(lt_lines) = NEW lcl_report( )->select_totals(
iv_from = '20260101'
iv_to = '20261231'
it_matnr = VALUE #( ( sign = 'I' option = 'EQ' low = 'MAT-002' ) ) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = CONV {{p}}move-quantity( 200 ) act = lt_lines[ 1 ]-net_qty ).
ENDMETHOD.
ENDCLASS.