1:
go_cds_test_environment = cl_cds_test_environment=>create_for_multiple_cds( i_for_entities = VALUE #(
( i_for_entity = 'I_Product' )
( i_for_entity = 'I_ProductSalesDelivery')
) ).
CLASS lcl_ut_dis_chain_sales_status DEFINITION DEFERRED. CLASS cl_crms4_product_api DEFINITION LOCAL FRIENDS lcl_ut_dis_chain_sales_status. CLASS lcl_ut_dis_chain_sales_status DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS . PRIVATE SECTION. DATA: f_cut TYPE REF TO cl_crms4_product_api. "class under test CLASS-DATA: go_cds_test_environment TYPE REF TO if_cds_test_environment. CLASS-DATA: go_osql_test_environment TYPE REF TO cl_osql_test_environment. CLASS-METHODS: class_setup. CLASS-METHODS: class_teardown. METHODS: setup. METHODS: teardown. METHODS: get_dis_chain_sales_status FOR TESTING. ENDCLASS. "lcl_Ut_Dis_Chain_Sales_Status CLASS lcl_ut_dis_chain_sales_status IMPLEMENTATION. METHOD class_setup. * go_cds_test_environment = cl_cds_test_environment=>create_for_multiple_cds( i_for_entities = VALUE #( ** ( i_for_entity = 'I_Product' ) * ( i_for_entity = 'I_ProductSalesDelivery') * ) ). go_osql_test_environment ?= cl_osql_test_environment=>create( i_dependency_list = VALUE #( ( 'mvke' ) ( 'mara' ) ) ). ENDMETHOD. METHOD class_teardown. go_osql_test_environment->if_osql_test_environment~destroy( ). * go_cds_test_environment->destroy( ). ENDMETHOD. METHOD setup. CREATE OBJECT f_cut. go_osql_test_environment->if_osql_test_environment~clear_doubles( ). * go_cds_test_environment->clear_doubles( ). ENDMETHOD. METHOD teardown. go_osql_test_environment->if_osql_test_environment~clear_doubles( ). * go_cds_test_environment->clear_doubles( ). ENDMETHOD. METHOD get_dis_chain_sales_status. DATA lv_product_guid TYPE /scmb/mdl_matid. DATA lv_sales_org TYPE crmt_sales_org. DATA lv_distr_chan TYPE crmt_distribution_channel. * DATA lv_langu TYPE spras. * DATA lv_text_required TYPE boolean. * DATA lv_sales_org_sd TYPE vkorg. * DATA lv_check_authorizations TYPE abap_boolean. DATA ls_product_sales_status TYPE crms4s_product_sales_status. DATA lt_i_productsalesdelivery TYPE STANDARD TABLE OF mvke. DATA lt_i_product TYPE STANDARD TABLE OF mara. DATA lv_adopt TYPE char1 VALUE 'X'. cl_crms4_orgman_helper=>set_mock_status_adopt_sdorg( iv_adopt = lv_adopt ). TEST-INJECTION get_sd_common_dis_channel. lv_vkorg = 'CTU2'. lv_vtweg = '01'. END-TEST-INJECTION. lt_i_productsalesdelivery = VALUE #( ( lvorm = 'X' vmsta = '01' vmstd = '20190827' ) ). lt_i_product = VALUE #( ( scm_matid_guid16 = '0000000000000001' lvorm = 'D' volum = '100' ) ). go_osql_test_environment->IF_OSQL_TEST_ENVIRONMENT~insert_test_data( i_data = lt_i_productsalesdelivery ). go_osql_test_environment->IF_OSQL_TEST_ENVIRONMENT~insert_test_data( i_data = lt_i_product ). * CALL METHOD f_cut->if_crms4_product_api~get_dis_chain_sales_status * EXPORTING * iv_product_guid = '12345678' * iv_sales_org = 'CTU2' * iv_distr_chan = '01' * IMPORTING * es_product_sales_status = ls_product_sales_status * EXCEPTIONS * not_found = 1 * wrong_call = 2 * conv_error = 3 * OTHERS = 4. * cl_abap_unit_assert=>assert_equals( act = ls_product_sales_status-productuuid * exp = '0000000000000001' ). ENDMETHOD.