- Static bundle checks (name length, seed type, reserved words, contract test classes, testclasses_file), local abaplint parser check before SAP, max_tokens, robust JSON parse - Runner: G2 for CDS views with parameters, contract_check detail in report - G0020 and G0013 fixed by review and revalidated (oracle 100, null 0) - Pilot results in docs/faz1-tasarim.md 11e; handover notes merged into CLAUDE.md and docs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
187 lines
6.9 KiB
ABAP
187 lines
6.9 KiB
ABAP
CLASS {{p}}t15_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
TYPES tt_matnr TYPE RANGE OF {{p}}move-material.
|
|
|
|
METHODS run
|
|
IMPORTING iv_from TYPE d
|
|
iv_to TYPE d
|
|
it_matnr TYPE tt_matnr OPTIONAL
|
|
RETURNING VALUE(rr_data) TYPE REF TO data.
|
|
|
|
METHODS lines_of
|
|
IMPORTING ir_data TYPE REF TO data
|
|
RETURNING VALUE(rv_lines) TYPE i.
|
|
|
|
METHODS text_of
|
|
IMPORTING ir_data TYPE REF TO data
|
|
iv_row TYPE i
|
|
iv_col TYPE string
|
|
RETURNING VALUE(rv_text) TYPE string.
|
|
|
|
METHODS qty_of
|
|
IMPORTING ir_data TYPE REF TO data
|
|
iv_row TYPE i
|
|
RETURNING VALUE(rv_qty) TYPE {{p}}move-quantity.
|
|
|
|
METHODS count_of
|
|
IMPORTING ir_data TYPE REF TO data
|
|
iv_row TYPE i
|
|
RETURNING VALUE(rv_count) TYPE i.
|
|
|
|
METHODS all_groups FOR TESTING.
|
|
METHODS sort_order FOR TESTING.
|
|
METHODS net_quantity FOR TESTING.
|
|
METHODS move_count FOR TESTING.
|
|
METHODS material_filter FOR TESTING.
|
|
METHODS date_from_filter FOR TESTING.
|
|
METHODS date_to_filter FOR TESTING.
|
|
METHODS no_matching_data FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}t15_hidden IMPLEMENTATION.
|
|
METHOD run.
|
|
cl_salv_bs_runtime_info=>set( display = abap_false metadata = abap_false data = abap_true ).
|
|
SUBMIT {{p}}stock_net
|
|
WITH p_from = iv_from
|
|
WITH p_to = iv_to
|
|
WITH s_matnr IN it_matnr
|
|
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 text_of.
|
|
FIELD-SYMBOLS <lt_data> TYPE STANDARD TABLE.
|
|
ASSIGN ir_data->* TO <lt_data>.
|
|
ASSIGN <lt_data>[ iv_row ] TO FIELD-SYMBOL(<ls_line>).
|
|
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = |Row { iv_row } is missing| ).
|
|
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 } is missing| ).
|
|
DATA lv_text TYPE string.
|
|
lv_text = <lv_value>.
|
|
rv_text = condense( lv_text ).
|
|
ENDMETHOD.
|
|
|
|
METHOD qty_of.
|
|
FIELD-SYMBOLS <lt_data> TYPE STANDARD TABLE.
|
|
ASSIGN ir_data->* TO <lt_data>.
|
|
ASSIGN <lt_data>[ iv_row ] TO FIELD-SYMBOL(<ls_line>).
|
|
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = |Row { iv_row } is missing| ).
|
|
ASSIGN COMPONENT 'NET_QTY' OF STRUCTURE <ls_line> TO FIELD-SYMBOL(<lv_value>).
|
|
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'Column NET_QTY is missing' ).
|
|
DATA lv_qty TYPE {{p}}move-quantity.
|
|
lv_qty = <lv_value>.
|
|
rv_qty = lv_qty.
|
|
ENDMETHOD.
|
|
|
|
METHOD count_of.
|
|
FIELD-SYMBOLS <lt_data> TYPE STANDARD TABLE.
|
|
ASSIGN ir_data->* TO <lt_data>.
|
|
ASSIGN <lt_data>[ iv_row ] TO FIELD-SYMBOL(<ls_line>).
|
|
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = |Row { iv_row } is missing| ).
|
|
ASSIGN COMPONENT 'MOVE_COUNT' OF STRUCTURE <ls_line> TO FIELD-SYMBOL(<lv_value>).
|
|
cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'Column MOVE_COUNT is missing' ).
|
|
DATA lv_count TYPE i.
|
|
lv_count = <lv_value>.
|
|
rv_count = lv_count.
|
|
ENDMETHOD.
|
|
|
|
METHOD all_groups.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 4
|
|
act = lines_of( run( iv_from = '20260101' iv_to = '20261231' ) ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD sort_order.
|
|
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20261231' ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = `MAT-001`
|
|
act = text_of( ir_data = lr_data iv_row = 1 iv_col = 'MATERIAL' ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = `1000`
|
|
act = text_of( ir_data = lr_data iv_row = 1 iv_col = 'PLANT' ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = `2000`
|
|
act = text_of( ir_data = lr_data iv_row = 2 iv_col = 'PLANT' ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = `MAT-002`
|
|
act = text_of( ir_data = lr_data iv_row = 3 iv_col = 'MATERIAL' ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = `MAT-002`
|
|
act = text_of( ir_data = lr_data iv_row = 4 iv_col = 'MATERIAL' ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD net_quantity.
|
|
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20261231' ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}move-quantity( 120 )
|
|
act = qty_of( ir_data = lr_data iv_row = 1 ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}move-quantity( -40 )
|
|
act = qty_of( ir_data = lr_data iv_row = 2 ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}move-quantity( -15 )
|
|
act = qty_of( ir_data = lr_data iv_row = 4 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD move_count.
|
|
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20261231' ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 3 act = count_of( ir_data = lr_data iv_row = 1 ) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 1 act = count_of( ir_data = lr_data iv_row = 2 ) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 2 act = count_of( ir_data = lr_data iv_row = 4 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD material_filter.
|
|
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20261231'
|
|
it_matnr = VALUE #( ( sign = 'I' option = 'EQ' low = 'MAT-002' ) ) ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 2 act = lines_of( lr_data ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = `MAT-002`
|
|
act = text_of( ir_data = lr_data iv_row = 1 iv_col = 'MATERIAL' ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = `1000`
|
|
act = text_of( ir_data = lr_data iv_row = 1 iv_col = 'PLANT' ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}move-quantity( 200 )
|
|
act = qty_of( ir_data = lr_data iv_row = 1 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD date_from_filter.
|
|
DATA(lr_data) = run( iv_from = '20260201' iv_to = '20261231' ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 1 act = lines_of( lr_data ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = `MAT-002`
|
|
act = text_of( ir_data = lr_data iv_row = 1 iv_col = 'MATERIAL' ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}move-quantity( 200 )
|
|
act = qty_of( ir_data = lr_data iv_row = 1 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD date_to_filter.
|
|
DATA(lr_data) = run( iv_from = '20260101' iv_to = '20260131' ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 3 act = lines_of( lr_data ) ).
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = CONV {{p}}move-quantity( -15 )
|
|
act = qty_of( ir_data = lr_data iv_row = 3 ) ).
|
|
ENDMETHOD.
|
|
|
|
METHOD no_matching_data.
|
|
cl_abap_unit_assert=>assert_equals(
|
|
exp = 0
|
|
act = lines_of( run( iv_from = '20270101' iv_to = '20271231' ) ) ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|