CLASS {{p}}t31_test DEFINITION PUBLIC FINAL CREATE PUBLIC FOR TESTING DURATION SHORT RISK LEVEL HARMLESS. PRIVATE SECTION. CLASS-DATA go_env TYPE REF TO if_cds_test_environment. CLASS-METHODS class_setup. CLASS-METHODS class_teardown. METHODS setup. METHODS one_row_for_multi_zone FOR TESTING. METHODS total_of_two_parcels FOR TESTING. ENDCLASS. CLASS {{p}}t31_test IMPLEMENTATION. METHOD class_setup. go_env = cl_cds_test_environment=>create( i_for_entity = '{{P}}I_TOUR_LOAD' ). ENDMETHOD. METHOD class_teardown. go_env->destroy( ). ENDMETHOD. METHOD setup. go_env->clear_doubles( ). ENDMETHOD. METHOD one_row_for_multi_zone. DATA lt_tour TYPE STANDARD TABLE OF {{p}}tour WITH EMPTY KEY. DATA lt_parcel TYPE STANDARD TABLE OF {{p}}parcel WITH EMPTY KEY. lt_tour = VALUE #( ( tour_id = 'A' driver = 'DA' depot = 'N01' ) ). lt_parcel = VALUE #( ( tour_id = 'A' parcel_no = 1 dest_zone = 'A' weight = '1.000' ) ( tour_id = 'A' parcel_no = 2 dest_zone = 'B' weight = '2.000' ) ). go_env->insert_test_data( lt_tour ). go_env->insert_test_data( lt_parcel ). SELECT COUNT(*) FROM {{p}}i_tour_load INTO @DATA(lv_rows). cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rows ). ENDMETHOD. METHOD total_of_two_parcels. DATA lt_tour TYPE STANDARD TABLE OF {{p}}tour WITH EMPTY KEY. DATA lt_parcel TYPE STANDARD TABLE OF {{p}}parcel WITH EMPTY KEY. lt_tour = VALUE #( ( tour_id = 'B' driver = 'DB' depot = 'S02' ) ). lt_parcel = VALUE #( ( tour_id = 'B' parcel_no = 1 dest_zone = 'A' weight = '1.500' ) ( tour_id = 'B' parcel_no = 2 dest_zone = 'A' weight = '2.500' ) ). go_env->insert_test_data( lt_tour ). go_env->insert_test_data( lt_parcel ). SELECT SINGLE parcel_count, total_weight FROM {{p}}i_tour_load WHERE tour_id = 'B' INTO @DATA(ls_row). cl_abap_unit_assert=>assert_equals( exp = 2 act = ls_row-parcel_count ). cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '4.000' ) act = CONV decfloat34( ls_row-total_weight ) ). ENDMETHOD. ENDCLASS.