Files
abap-llm/tasks_gen/eval/G0014/faulty/m3_stock_bal.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

128 lines
4.9 KiB
ABAP

REPORT {{p}}stock_bal.
DATA gv_plant TYPE {{p}}movmt-plant.
PARAMETERS p_from TYPE d OBLIGATORY.
PARAMETERS p_to TYPE d OBLIGATORY.
SELECT-OPTIONS s_plant FOR gv_plant.
CLASS lcl_report DEFINITION FINAL.
PUBLIC SECTION.
TYPES:
BEGIN OF ty_line,
material TYPE {{p}}movmt-material,
receipt_qty TYPE i,
issue_qty TYPE i,
balance TYPE i,
END OF ty_line,
tt_line TYPE STANDARD TABLE OF ty_line WITH EMPTY KEY,
tt_plant TYPE RANGE OF {{p}}movmt-plant.
METHODS select_balances
IMPORTING iv_from TYPE d
iv_to TYPE d
it_plant TYPE tt_plant
RETURNING VALUE(rt_lines) TYPE tt_line.
METHODS display
CHANGING ct_lines TYPE tt_line.
ENDCLASS.
CLASS lcl_report IMPLEMENTATION.
METHOD select_balances.
SELECT material,
SUM( CASE WHEN move_type = '101' OR move_type = '201'
THEN quantity
ELSE 0 END ) AS receipt_qty,
SUM( CASE WHEN move_type = '261' OR move_type = '262'
THEN quantity
ELSE 0 END ) AS issue_qty
FROM {{p}}movmt
WHERE move_date >= @iv_from
AND move_date <= @iv_to
AND plant IN @it_plant
OR move_type IN ( '101', '201', '261', '262' )
GROUP BY material
INTO CORRESPONDING FIELDS OF TABLE @rt_lines.
LOOP AT rt_lines ASSIGNING FIELD-SYMBOL(<ls_line>).
<ls_line>-balance = <ls_line>-receipt_qty - <ls_line>-issue_qty.
ENDLOOP.
SORT rt_lines BY balance 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_balances( iv_from = p_from
iv_to = p_to
it_plant = s_plant[] ).
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 balances_per_material FOR TESTING.
METHODS plant_filter FOR TESTING.
METHODS negative_balance FOR TESTING.
ENDCLASS.
CLASS ltc_report IMPLEMENTATION.
METHOD class_setup.
go_env = cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( '{{P}}MOVMT' ) ) ).
DATA lt_movmt TYPE STANDARD TABLE OF {{p}}movmt WITH EMPTY KEY.
lt_movmt = VALUE #(
( move_id = 1 material = 'MAT-A' plant = '1000' move_date = '20260105' move_type = '101' quantity = 100 )
( move_id = 2 material = 'MAT-A' plant = '1000' move_date = '20260110' move_type = '261' quantity = 30 )
( move_id = 3 material = 'MAT-B' plant = '2000' move_date = '20260112' move_type = '201' quantity = 40 )
( move_id = 4 material = 'MAT-B' plant = '2000' move_date = '20260113' move_type = '262' quantity = 90 )
( move_id = 5 material = 'MAT-C' plant = '2000' move_date = '20260112' move_type = '999' quantity = 500 ) ).
go_env->insert_test_data( lt_movmt ).
ENDMETHOD.
METHOD class_teardown.
go_env->destroy( ).
ENDMETHOD.
METHOD balances_per_material.
DATA(lt_lines) = NEW lcl_report( )->select_balances(
iv_from = '20260101' iv_to = '20260131' it_plant = VALUE #( ) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'MAT-A' act = lt_lines[ 1 ]-material ).
cl_abap_unit_assert=>assert_equals( exp = 70 act = lt_lines[ 1 ]-balance ).
cl_abap_unit_assert=>assert_equals( exp = 'MAT-B' act = lt_lines[ 2 ]-material ).
cl_abap_unit_assert=>assert_equals( exp = -50 act = lt_lines[ 2 ]-balance ).
ENDMETHOD.
METHOD plant_filter.
DATA(lt_lines) = NEW lcl_report( )->select_balances(
iv_from = '20260101'
iv_to = '20260131'
it_plant = VALUE #( ( sign = 'I' option = 'EQ' low = '1000' ) ) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'MAT-A' act = lt_lines[ 1 ]-material ).
cl_abap_unit_assert=>assert_equals( exp = 30 act = lt_lines[ 1 ]-issue_qty ).
ENDMETHOD.
METHOD negative_balance.
DATA(lt_lines) = NEW lcl_report( )->select_balances(
iv_from = '20260101'
iv_to = '20260131'
it_plant = VALUE #( ( sign = 'I' option = 'EQ' low = '2000' ) ) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines( lt_lines ) ).
cl_abap_unit_assert=>assert_equals( exp = 'MAT-B' act = lt_lines[ 1 ]-material ).
cl_abap_unit_assert=>assert_equals( exp = -50 act = lt_lines[ 1 ]-balance ).
ENDMETHOD.
ENDCLASS.