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 TYPE STANDARD TABLE. IF ir_data IS BOUND. ASSIGN ir_data->* TO . rv_lines = lines( ). ENDIF. ENDMETHOD. METHOD text_of. FIELD-SYMBOLS TYPE STANDARD TABLE. ASSIGN ir_data->* TO . ASSIGN [ iv_row ] TO FIELD-SYMBOL(). cl_abap_unit_assert=>assert_subrc( exp = 0 msg = |Row { iv_row } is missing| ). ASSIGN COMPONENT iv_col OF STRUCTURE TO FIELD-SYMBOL(). cl_abap_unit_assert=>assert_subrc( exp = 0 msg = |Column { iv_col } is missing| ). DATA lv_text TYPE string. lv_text = . rv_text = condense( lv_text ). ENDMETHOD. METHOD qty_of. FIELD-SYMBOLS TYPE STANDARD TABLE. ASSIGN ir_data->* TO . ASSIGN [ iv_row ] TO FIELD-SYMBOL(). cl_abap_unit_assert=>assert_subrc( exp = 0 msg = |Row { iv_row } is missing| ). ASSIGN COMPONENT 'NET_QTY' OF STRUCTURE TO FIELD-SYMBOL(). cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'Column NET_QTY is missing' ). DATA lv_qty TYPE {{p}}move-quantity. lv_qty = . rv_qty = lv_qty. ENDMETHOD. METHOD count_of. FIELD-SYMBOLS TYPE STANDARD TABLE. ASSIGN ir_data->* TO . ASSIGN [ iv_row ] TO FIELD-SYMBOL(). cl_abap_unit_assert=>assert_subrc( exp = 0 msg = |Row { iv_row } is missing| ). ASSIGN COMPONENT 'MOVE_COUNT' OF STRUCTURE TO FIELD-SYMBOL(). cl_abap_unit_assert=>assert_subrc( exp = 0 msg = 'Column MOVE_COUNT is missing' ). DATA lv_count TYPE i. lv_count = . 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.