diff --git a/src/#usi#bal_cust_evaluation/#usi#cl_bal_ce_cx_mapper.clas.abap b/src/#usi#bal_cust_evaluation/#usi#cl_bal_ce_cx_mapper.clas.abap index 46b335a..ff221ab 100644 --- a/src/#usi#bal_cust_evaluation/#usi#cl_bal_ce_cx_mapper.clas.abap +++ b/src/#usi#bal_cust_evaluation/#usi#cl_bal_ce_cx_mapper.clas.abap @@ -62,8 +62,7 @@ CLASS /usi/cl_bal_ce_cx_mapper IMPLEMENTATION. ENDMETHOD. METHOD get_mapper_class. - DATA: customizing_entry TYPE ty_customizing_entry, - exception_classname TYPE /usi/bal_exception_classname, + DATA: exception_classname TYPE /usi/bal_exception_classname, superclass_description TYPE REF TO cl_abap_classdescr. FIELD-SYMBOLS: TYPE ty_customizing_entry, @@ -102,10 +101,10 @@ CLASS /usi/cl_bal_ce_cx_mapper IMPLEMENTATION. ENDIF. " Extend customizing to speed up subsequent calls - customizing_entry-exception_class_type = class_type-class. - customizing_entry-exception_class_name = i_exception_class_description->get_relative_name( ). - customizing_entry-mapper_class_name = r_result. - INSERT customizing_entry INTO TABLE customizing_entries. + INSERT VALUE #( exception_class_type = class_type-class + exception_class_name = i_exception_class_description->get_relative_name( ) + mapper_class_name = r_result ) + INTO TABLE customizing_entries. ENDMETHOD. METHOD get_validated_customizing. diff --git a/src/#usi#bal_cust_evaluation/#usi#cl_bal_ce_cx_mapper.clas.testclasses.abap b/src/#usi#bal_cust_evaluation/#usi#cl_bal_ce_cx_mapper.clas.testclasses.abap index 433969c..466c261 100644 --- a/src/#usi#bal_cust_evaluation/#usi#cl_bal_ce_cx_mapper.clas.testclasses.abap +++ b/src/#usi#bal_cust_evaluation/#usi#cl_bal_ce_cx_mapper.clas.testclasses.abap @@ -85,7 +85,6 @@ CLASS lcl_unit_tests IMPLEMENTATION. METHOD test_ignore_invalid_mappers. DATA: test_exception TYPE REF TO /usi/cx_bal_root, customizing_records TYPE /usi/if_bal_cd_cx_mapper=>ty_records, - customizing_record TYPE /usi/if_bal_cd_cx_mapper=>ty_record, expected_result TYPE /usi/bal_exception_mapper. TRY. @@ -93,15 +92,12 @@ CLASS lcl_unit_tests IMPLEMENTATION. CATCH /usi/cx_bal_root INTO test_exception. ENDTRY. - customizing_record-exception_class = '/USI/CX_BAL_NOT_FOUND'. - customizing_record-mapper_class = 'CL_GUI_ALV_GRID'. - INSERT customizing_record INTO TABLE customizing_records. - customizing_record-exception_class = '/USI/CX_BAL_ROOT'. - customizing_record-mapper_class = '/USI/CL_BAL_EM_BASE'. - INSERT customizing_record INTO TABLE customizing_records. - customizing_record-exception_class = '/USI/CX_EXCEPTION'. - customizing_record-mapper_class = '/USI/CL_BAL_UNKNOWN_CLASS'. - INSERT customizing_record INTO TABLE customizing_records. + customizing_records = VALUE #( ( exception_class = '/USI/CX_BAL_NOT_FOUND' + mapper_class = 'CL_GUI_ALV_GRID' ) + ( exception_class = '/USI/CX_BAL_ROOT' + mapper_class = '/USI/CL_BAL_EM_BASE' ) + ( exception_class = '/USI/CX_EXCEPTION' + mapper_class = '/USI/CL_BAL_UNKNOWN_CLASS' ) ). expected_result = cut->get_fallback_mapper_classname( ). diff --git a/src/#usi#bal_cust_evaluation/#usi#cl_bal_object_descr.clas.abap b/src/#usi#bal_cust_evaluation/#usi#cl_bal_object_descr.clas.abap index 58f7be3..342b3fa 100644 --- a/src/#usi#bal_cust_evaluation/#usi#cl_bal_object_descr.clas.abap +++ b/src/#usi#bal_cust_evaluation/#usi#cl_bal_object_descr.clas.abap @@ -103,8 +103,6 @@ CLASS /usi/cl_bal_object_descr IMPLEMENTATION. ENDMETHOD. METHOD is_interface. - IF object_description->kind = cl_abap_typedescr=>kind_intf. - r_result = abap_true. - ENDIF. + r_result = boolc( object_description->kind = cl_abap_typedescr=>kind_intf ). ENDMETHOD. ENDCLASS. diff --git a/src/#usi#bal_cust_evaluation/#usi#cl_bal_sub_object_range.clas.testclasses.abap b/src/#usi#bal_cust_evaluation/#usi#cl_bal_sub_object_range.clas.testclasses.abap index 00e537b..2eb6bee 100644 --- a/src/#usi#bal_cust_evaluation/#usi#cl_bal_sub_object_range.clas.testclasses.abap +++ b/src/#usi#bal_cust_evaluation/#usi#cl_bal_sub_object_range.clas.testclasses.abap @@ -12,8 +12,7 @@ ENDCLASS. CLASS lcl_unit_test_read_only IMPLEMENTATION. METHOD assert_public_attrib_read_only. - DATA cut_description TYPE REF TO /usi/cl_bal_aunit_cut_descr_cl. - cut_description = /usi/cl_bal_aunit_cut_descr_cl=>get_instance( ). + DATA(cut_description) = /usi/cl_bal_aunit_cut_descr_cl=>get_instance( ). cut_description->assert_public_attrib_read_only( ). ENDMETHOD. ENDCLASS. diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_callstack.clas.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_callstack.clas.abap index 3a9aadf..5547d4f 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_callstack.clas.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_callstack.clas.abap @@ -62,13 +62,11 @@ CLASS /usi/cl_bal_dc_callstack IMPLEMENTATION. ENDMETHOD. METHOD /usi/if_bal_data_container~deserialize. - DATA: callstack TYPE abap_callstack, - deserializer TYPE REF TO /usi/cl_bal_serializer. + DATA callstack TYPE abap_callstack. - deserializer = NEW #( ). - deserializer->deserialize_field( EXPORTING i_serialized_data = i_serialized_data_container - i_name = 'CALLSTACK' - CHANGING c_data = callstack ). + NEW /usi/cl_bal_serializer( )->deserialize_field( EXPORTING i_serialized_data = i_serialized_data_container + i_name = 'CALLSTACK' + CHANGING c_data = callstack ). r_result = NEW /usi/cl_bal_dc_callstack( i_callstack = callstack ). ENDMETHOD. @@ -89,11 +87,8 @@ CLASS /usi/cl_bal_dc_callstack IMPLEMENTATION. ENDMETHOD. METHOD /usi/if_bal_data_container~serialize. - DATA serializer TYPE REF TO /usi/cl_bal_serializer. - - serializer = NEW #( ). - r_result = serializer->serialize_field_as_json( i_data = callstack - i_name = 'CALLSTACK' ). + r_result = NEW /usi/cl_bal_serializer( )->serialize_field_as_json( i_data = callstack + i_name = 'CALLSTACK' ). ENDMETHOD. @@ -101,15 +96,14 @@ CLASS /usi/cl_bal_dc_callstack IMPLEMENTATION. callstack = i_callstack. ENDMETHOD. - METHOD get_excluded_grid_functions. - INSERT cl_gui_alv_grid=>mc_fc_excl_all INTO TABLE r_result. - INSERT cl_gui_alv_grid=>mc_fc_loc_copy INTO TABLE r_result. - INSERT cl_gui_alv_grid=>mc_fc_col_optimize INTO TABLE r_result. - INSERT cl_gui_alv_grid=>mc_fc_unfix_columns INTO TABLE r_result. - INSERT cl_gui_alv_grid=>mc_fc_fix_columns INTO TABLE r_result. - INSERT cl_gui_alv_grid=>mc_fc_col_invisible INTO TABLE r_result. - INSERT cl_gui_alv_grid=>mc_fc_current_variant INTO TABLE r_result. + r_result = VALUE #( ( cl_gui_alv_grid=>mc_fc_excl_all ) + ( cl_gui_alv_grid=>mc_fc_loc_copy ) + ( cl_gui_alv_grid=>mc_fc_col_optimize ) + ( cl_gui_alv_grid=>mc_fc_unfix_columns ) + ( cl_gui_alv_grid=>mc_fc_fix_columns ) + ( cl_gui_alv_grid=>mc_fc_col_invisible ) + ( cl_gui_alv_grid=>mc_fc_current_variant ) ). ENDMETHOD. diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_collection.clas.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_collection.clas.abap index 2a063c5..55ca7ae 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_collection.clas.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_collection.clas.abap @@ -6,15 +6,12 @@ CLASS /usi/cl_bal_dc_collection DEFINITION PUBLIC FINAL CREATE PUBLIC. ALIASES: deserialize FOR /usi/if_bal_data_container_col~deserialize, insert FOR /usi/if_bal_data_container_col~insert. - PROTECTED SECTION. - PRIVATE SECTION. TYPES: BEGIN OF ty_data_cont_coll_item, data_container_classname TYPE /usi/bal_data_cont_classname, data_container TYPE REF TO /usi/if_bal_data_container, END OF ty_data_cont_coll_item, - ty_data_cont_coll_items TYPE SORTED TABLE OF ty_data_cont_coll_item - WITH NON-UNIQUE KEY data_container_classname. + ty_data_cont_coll_items TYPE SORTED TABLE OF ty_data_cont_coll_item WITH NON-UNIQUE KEY data_container_classname. TYPES: BEGIN OF ty_serialized_data_container, data_container_classname TYPE /usi/bal_data_cont_classname, @@ -25,23 +22,17 @@ CLASS /usi/cl_bal_dc_collection DEFINITION PUBLIC FINAL CREATE PUBLIC. DATA data_cont_coll_items TYPE ty_data_cont_coll_items. METHODS is_cardinality_violation - IMPORTING - i_data_container TYPE REF TO /usi/if_bal_data_container - RETURNING - VALUE(r_result) TYPE abap_bool. + IMPORTING i_data_container TYPE REF TO /usi/if_bal_data_container + RETURNING VALUE(r_result) TYPE abap_bool. METHODS is_duplicate - IMPORTING - i_data_container TYPE REF TO /usi/if_bal_data_container - RETURNING - VALUE(r_result) TYPE abap_bool - RAISING - /usi/cx_bal_root. + IMPORTING i_data_container TYPE REF TO /usi/if_bal_data_container + RETURNING VALUE(r_result) TYPE abap_bool + RAISING /usi/cx_bal_root. ENDCLASS. - CLASS /usi/cl_bal_dc_collection IMPLEMENTATION. METHOD /usi/if_bal_data_container_col~deserialize. DATA: data_container TYPE REF TO /usi/if_bal_data_container, @@ -49,50 +40,42 @@ CLASS /usi/cl_bal_dc_collection IMPLEMENTATION. exception_text TYPE string, serialized_data_containers TYPE ty_serialized_data_containers. - FIELD-SYMBOLS TYPE ty_serialized_data_container. - TRY. CALL TRANSFORMATION id - SOURCE XML i_serialized_data_cont_coll - RESULT serialized_data_containers = serialized_data_containers. + SOURCE XML i_serialized_data_cont_coll + RESULT serialized_data_containers = serialized_data_containers. CATCH cx_transformation_error INTO exception. RAISE EXCEPTION TYPE /usi/cx_bal_type_mismatch - EXPORTING - textid = /usi/cx_bal_type_mismatch=>/usi/cx_bal_type_mismatch - previous = exception. + EXPORTING textid = /usi/cx_bal_type_mismatch=>/usi/cx_bal_type_mismatch + previous = exception. ENDTRY. - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_collection. - LOOP AT serialized_data_containers ASSIGNING . + r_result = NEW /usi/cl_bal_dc_collection( ). + LOOP AT serialized_data_containers ASSIGNING FIELD-SYMBOL(). TRY. CALL METHOD (-data_container_classname)=>/usi/if_bal_data_container~deserialize - EXPORTING - i_serialized_data_container = -serialized_data_container - RECEIVING - r_result = data_container. + EXPORTING i_serialized_data_container = -serialized_data_container + RECEIVING r_result = data_container. r_result->insert( data_container ). CATCH cx_sy_dyn_call_error /usi/cx_bal_root INTO exception. exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION exception IS NOT BOUND. + FIELDS exception_text + CONDITION exception IS NOT BOUND. CONTINUE. ENDTRY. ENDLOOP. ENDMETHOD. - METHOD /usi/if_bal_data_container_col~get_data_containers. - FIELD-SYMBOLS TYPE ty_data_cont_coll_item. - LOOP AT data_cont_coll_items ASSIGNING . + LOOP AT data_cont_coll_items ASSIGNING FIELD-SYMBOL(). INSERT -data_container INTO TABLE r_result. ENDLOOP. ENDMETHOD. - METHOD /usi/if_bal_data_container_col~has_data_containers. IF data_cont_coll_items IS NOT INITIAL. r_result = abap_true. @@ -100,8 +83,6 @@ CLASS /usi/cl_bal_dc_collection IMPLEMENTATION. ENDMETHOD. METHOD /usi/if_bal_data_container_col~insert. - DATA new_data_cont_coll_item TYPE ty_data_cont_coll_item. - r_result = me. TRY. @@ -113,38 +94,32 @@ CLASS /usi/cl_bal_dc_collection IMPLEMENTATION. RETURN. ENDTRY. - new_data_cont_coll_item-data_container_classname = i_data_container->get_classname( ). - new_data_cont_coll_item-data_container = i_data_container. - INSERT new_data_cont_coll_item INTO TABLE data_cont_coll_items. + INSERT VALUE #( data_container_classname = i_data_container->get_classname( ) + data_container = i_data_container ) + INTO TABLE data_cont_coll_items. ENDMETHOD. - METHOD /usi/if_bal_data_container_col~serialize. - DATA: exception TYPE REF TO /usi/cx_bal_root, - exception_text TYPE string, - serialized_data_containers TYPE ty_serialized_data_containers, - serialized_data_container TYPE ty_serialized_data_container. + DATA serialized_data_containers TYPE ty_serialized_data_containers. - FIELD-SYMBOLS TYPE ty_data_cont_coll_item. - - LOOP AT data_cont_coll_items ASSIGNING . + LOOP AT data_cont_coll_items ASSIGNING FIELD-SYMBOL(). TRY. - serialized_data_container-data_container_classname = -data_container_classname. - serialized_data_container-serialized_data_container = -data_container->serialize( ). - INSERT serialized_data_container INTO TABLE serialized_data_containers. - CATCH /usi/cx_bal_root INTO exception. + INSERT VALUE #( data_container_classname = -data_container_classname + serialized_data_container = -data_container->serialize( ) ) + INTO TABLE serialized_data_containers. + CATCH /usi/cx_bal_root INTO DATA(exception). " Corrupt container data? Drop container! - exception_text = exception->get_text( ). + DATA(exception_text) = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION exception IS NOT BOUND. + FIELDS exception_text + CONDITION exception IS NOT BOUND. CONTINUE. ENDTRY. ENDLOOP. CALL TRANSFORMATION id - SOURCE serialized_data_containers = serialized_data_containers - RESULT XML r_result. + SOURCE serialized_data_containers = serialized_data_containers + RESULT XML r_result. ENDMETHOD. METHOD is_cardinality_violation. diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_collection.clas.testclasses.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_collection.clas.testclasses.abap index adf77e1..01370da 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_collection.clas.testclasses.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_collection.clas.testclasses.abap @@ -1,20 +1,20 @@ *"* use this source file for your ABAP unit test classes -*--------------------------------------------------------------------* -* Test double: Single use container [0-1] -*--------------------------------------------------------------------* +" --------------------------------------------------------------------- +" Test double: Single use container [0-1] +" --------------------------------------------------------------------- CLASS lcl_single_use_container DEFINITION FINAL FOR TESTING. PUBLIC SECTION. INTERFACES /usi/if_bal_data_container. METHODS constructor - IMPORTING - i_serialized_data_container TYPE /usi/bal_xml_string. + IMPORTING i_serialized_data_container TYPE /usi/bal_xml_string. PRIVATE SECTION. DATA serialized_data_container TYPE /usi/bal_xml_string. ENDCLASS. + CLASS lcl_single_use_container IMPLEMENTATION. METHOD constructor. serialized_data_container = i_serialized_data_container. @@ -25,9 +25,7 @@ CLASS lcl_single_use_container IMPLEMENTATION. ENDMETHOD. METHOD /usi/if_bal_data_container~deserialize. - CREATE OBJECT r_result TYPE lcl_single_use_container - EXPORTING - i_serialized_data_container = i_serialized_data_container. + r_result = NEW lcl_single_use_container( i_serialized_data_container = i_serialized_data_container ). ENDMETHOD. METHOD /usi/if_bal_data_container~get_classname. @@ -43,21 +41,22 @@ CLASS lcl_single_use_container IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Test double: Multi use container [0-n] -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Test double: Multi use container [0-n] +" --------------------------------------------------------------------- CLASS lcl_multi_use_container DEFINITION FINAL FOR TESTING. PUBLIC SECTION. INTERFACES /usi/if_bal_data_container. METHODS constructor - IMPORTING - i_serialized_data_container TYPE /usi/bal_xml_string. + IMPORTING i_serialized_data_container TYPE /usi/bal_xml_string. PRIVATE SECTION. DATA serialized_data_container TYPE /usi/bal_xml_string. ENDCLASS. + CLASS lcl_multi_use_container IMPLEMENTATION. METHOD constructor. serialized_data_container = i_serialized_data_container. @@ -68,9 +67,7 @@ CLASS lcl_multi_use_container IMPLEMENTATION. ENDMETHOD. METHOD /usi/if_bal_data_container~deserialize. - CREATE OBJECT r_result TYPE lcl_multi_use_container - EXPORTING - i_serialized_data_container = i_serialized_data_container. + r_result = NEW lcl_multi_use_container( i_serialized_data_container = i_serialized_data_container ). ENDMETHOD. METHOD /usi/if_bal_data_container~get_classname. @@ -86,9 +83,10 @@ CLASS lcl_multi_use_container IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Test double: defect data container -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Test double: defect data container +" --------------------------------------------------------------------- CLASS lcl_defect_container DEFINITION FINAL FOR TESTING. PUBLIC SECTION. INTERFACES /usi/if_bal_data_container. @@ -96,22 +94,18 @@ CLASS lcl_defect_container DEFINITION FINAL FOR TESTING. CLASS-METHODS class_constructor. CLASS-METHODS set_return_invalid_classname - IMPORTING - i_return_invalid_classname TYPE abap_bool. + IMPORTING i_return_invalid_classname TYPE abap_bool. CLASS-METHODS set_throw_on_deserialize - IMPORTING - i_throw_on_deserialize TYPE abap_bool. + IMPORTING i_throw_on_deserialize TYPE abap_bool. CLASS-METHODS set_throw_on_serialize - IMPORTING - i_throw_on_serialize TYPE abap_bool. + IMPORTING i_throw_on_serialize TYPE abap_bool. CLASS-METHODS reset_to_defaults. METHODS constructor - IMPORTING - i_serialized_data_container TYPE /usi/bal_xml_string. + IMPORTING i_serialized_data_container TYPE /usi/bal_xml_string. PRIVATE SECTION. CONSTANTS: BEGIN OF classnames, @@ -126,6 +120,7 @@ CLASS lcl_defect_container DEFINITION FINAL FOR TESTING. DATA serialized_data_container TYPE /usi/bal_xml_string. ENDCLASS. + CLASS lcl_defect_container IMPLEMENTATION. METHOD class_constructor. reset_to_defaults( ). @@ -138,7 +133,7 @@ CLASS lcl_defect_container IMPLEMENTATION. ENDMETHOD. METHOD set_return_invalid_classname. - IF i_return_invalid_classname EQ abap_true. + IF i_return_invalid_classname = abap_true. my_classname = classnames-wrong. ELSE. my_classname = classnames-right. @@ -162,14 +157,11 @@ CLASS lcl_defect_container IMPLEMENTATION. ENDMETHOD. METHOD /usi/if_bal_data_container~deserialize. - IF throw_on_deserialize EQ abap_false. - CREATE OBJECT r_result TYPE lcl_defect_container - EXPORTING - i_serialized_data_container = i_serialized_data_container. + IF throw_on_deserialize = abap_false. + r_result = NEW lcl_defect_container( i_serialized_data_container = i_serialized_data_container ). ELSE. RAISE EXCEPTION TYPE /usi/cx_bal_type_mismatch - EXPORTING - textid = /usi/cx_bal_type_mismatch=>/usi/cx_bal_type_mismatch. + EXPORTING textid = /usi/cx_bal_type_mismatch=>/usi/cx_bal_type_mismatch. ENDIF. ENDMETHOD. @@ -182,22 +174,23 @@ CLASS lcl_defect_container IMPLEMENTATION. ENDMETHOD. METHOD /usi/if_bal_data_container~serialize. - IF throw_on_serialize EQ abap_false. + IF throw_on_serialize = abap_false. r_result = serialized_data_container. ELSE. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>/usi/cx_bal_invalid_input. + EXPORTING textid = /usi/cx_bal_invalid_input=>/usi/cx_bal_invalid_input. ENDIF. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Cardinality -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Cardinality +" --------------------------------------------------------------------- CLASS lcl_unit_test_cardinality DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. DATA cut TYPE REF TO /usi/if_bal_data_container_col. @@ -208,35 +201,28 @@ CLASS lcl_unit_test_cardinality DEFINITION FINAL FOR TESTING. METHODS test_multi_use_is_working FOR TESTING. METHODS get_single_use_container - IMPORTING - i_serialized_data_container TYPE /usi/bal_xml_string - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. + IMPORTING i_serialized_data_container TYPE /usi/bal_xml_string + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. METHODS get_multi_use_container - IMPORTING - i_serialized_data_container TYPE /usi/bal_xml_string - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. + IMPORTING i_serialized_data_container TYPE /usi/bal_xml_string + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. METHODS assert_has_container - IMPORTING - i_data_container TYPE REF TO /usi/if_bal_data_container. + IMPORTING i_data_container TYPE REF TO /usi/if_bal_data_container. METHODS assert_not_has_container - IMPORTING - i_data_container TYPE REF TO /usi/if_bal_data_container. + IMPORTING i_data_container TYPE REF TO /usi/if_bal_data_container. METHODS has_container - IMPORTING - i_data_container TYPE REF TO /usi/if_bal_data_container - RETURNING - VALUE(r_result) TYPE abap_bool. + IMPORTING i_data_container TYPE REF TO /usi/if_bal_data_container + RETURNING VALUE(r_result) TYPE abap_bool. ENDCLASS. + CLASS lcl_unit_test_cardinality IMPLEMENTATION. METHOD setup. - CREATE OBJECT cut TYPE /usi/cl_bal_dc_collection. + cut = NEW /usi/cl_bal_dc_collection( ). ENDMETHOD. METHOD test_single_use_restriction. @@ -259,8 +245,8 @@ CLASS lcl_unit_test_cardinality IMPLEMENTATION. DATA: data_container TYPE REF TO /usi/if_bal_data_container, duplicate TYPE REF TO /usi/if_bal_data_container. - data_container = get_multi_use_container( the_very_same_data ). - duplicate = get_multi_use_container( the_very_same_data ). + data_container = get_multi_use_container( the_very_same_data ). + duplicate = get_multi_use_container( the_very_same_data ). cut->insert( data_container ). cut->insert( duplicate ). @@ -284,15 +270,11 @@ CLASS lcl_unit_test_cardinality IMPLEMENTATION. ENDMETHOD. METHOD get_single_use_container. - CREATE OBJECT r_result TYPE lcl_single_use_container - EXPORTING - i_serialized_data_container = i_serialized_data_container. + r_result = NEW lcl_single_use_container( i_serialized_data_container = i_serialized_data_container ). ENDMETHOD. METHOD get_multi_use_container. - CREATE OBJECT r_result TYPE lcl_multi_use_container - EXPORTING - i_serialized_data_container = i_serialized_data_container. + r_result = NEW lcl_multi_use_container( i_serialized_data_container = i_serialized_data_container ). ENDMETHOD. METHOD assert_has_container. @@ -308,7 +290,7 @@ CLASS lcl_unit_test_cardinality IMPLEMENTATION. METHOD assert_not_has_container. DATA data_container_classname TYPE /usi/bal_data_cont_classname. - IF has_container( i_data_container ) EQ abap_true. + IF has_container( i_data_container ) = abap_true. data_container_classname = i_data_container->get_classname( ). cl_aunit_assert=>fail( msg = `Unexpected container found!` detail = data_container_classname ). @@ -320,21 +302,20 @@ CLASS lcl_unit_test_cardinality IMPLEMENTATION. data_containers = cut->get_data_containers( ). - READ TABLE data_containers - TRANSPORTING NO FIELDS - WITH KEY table_line = i_data_container. - IF sy-subrc EQ 0. + IF line_exists( data_containers[ table_line = i_data_container ] ). r_result = abap_true. ENDIF. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Cardinality -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Cardinality +" --------------------------------------------------------------------- CLASS lcl_unit_test_serialization DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. TYPES: BEGIN OF ty_flattened_data_container, data_container_classname TYPE /usi/bal_data_cont_classname, @@ -350,37 +331,28 @@ CLASS lcl_unit_test_serialization DEFINITION FINAL FOR TESTING. METHODS test_empty_collection FOR TESTING. METHODS serialize_and_deserialize_coll - IMPORTING - i_data_container_collection TYPE REF TO /usi/if_bal_data_container_col - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_data_container_col. + IMPORTING i_data_container_collection TYPE REF TO /usi/if_bal_data_container_col + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_data_container_col. METHODS flatten_data_container - IMPORTING - i_data_container TYPE REF TO /usi/if_bal_data_container - RETURNING - VALUE(r_result) TYPE ty_flattened_data_container. + IMPORTING i_data_container TYPE REF TO /usi/if_bal_data_container + RETURNING VALUE(r_result) TYPE ty_flattened_data_container. METHODS flatten_data_cont_coll - IMPORTING - i_data_container_collection TYPE REF TO /usi/if_bal_data_container_col - RETURNING - VALUE(r_result) TYPE ty_flattened_data_containers. + IMPORTING i_data_container_collection TYPE REF TO /usi/if_bal_data_container_col + RETURNING VALUE(r_result) TYPE ty_flattened_data_containers. METHODS get_bad_data_container - IMPORTING - i_return_invalid_classname TYPE abap_bool DEFAULT abap_false - i_throw_on_deserialize TYPE abap_bool DEFAULT abap_false - RETURNING - VALUE(r_result) TYPE REF TO lcl_defect_container. + IMPORTING i_return_invalid_classname TYPE abap_bool DEFAULT abap_false + i_throw_on_deserialize TYPE abap_bool DEFAULT abap_false + RETURNING VALUE(r_result) TYPE REF TO lcl_defect_container. METHODS get_good_data_container - IMPORTING - i_serialized_data_container TYPE /usi/bal_xml_string - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. + IMPORTING i_serialized_data_container TYPE /usi/bal_xml_string + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. ENDCLASS. + CLASS lcl_unit_test_serialization IMPLEMENTATION. METHOD test_deserialize_bad_cont_data. DATA: good_data_container TYPE REF TO /usi/if_bal_data_container, @@ -389,7 +361,7 @@ CLASS lcl_unit_test_serialization IMPLEMENTATION. actual_result TYPE ty_flattened_data_containers, expected_result TYPE ty_flattened_data_containers. - CREATE OBJECT cut TYPE /usi/cl_bal_dc_collection. + cut = NEW /usi/cl_bal_dc_collection( ). good_data_container = get_good_data_container( `data` ). cut->insert( good_data_container ). expected_result = flatten_data_cont_coll( cut ). @@ -412,7 +384,7 @@ CLASS lcl_unit_test_serialization IMPLEMENTATION. actual_result TYPE ty_flattened_data_containers, expected_result TYPE ty_flattened_data_containers. - CREATE OBJECT cut TYPE /usi/cl_bal_dc_collection. + cut = NEW /usi/cl_bal_dc_collection( ). good_data_container = get_good_data_container( `data` ). cut->insert( good_data_container ). expected_result = flatten_data_cont_coll( cut ). @@ -449,7 +421,7 @@ CLASS lcl_unit_test_serialization IMPLEMENTATION. data_container_2 = get_good_data_container( `Second container` ). data_container_3 = get_good_data_container( `Third container` ). - CREATE OBJECT cut TYPE /usi/cl_bal_dc_collection. + cut = NEW /usi/cl_bal_dc_collection( ). cut->insert( data_container_1 ). cut->insert( data_container_2 ). cut->insert( data_container_3 ). @@ -464,11 +436,10 @@ CLASS lcl_unit_test_serialization IMPLEMENTATION. ENDMETHOD. METHOD test_empty_collection. - DATA: cut TYPE REF TO /usi/if_bal_data_container_col, - actual_result TYPE ty_flattened_data_containers, - expected_result TYPE ty_flattened_data_containers. + DATA: cut TYPE REF TO /usi/if_bal_data_container_col, + actual_result TYPE ty_flattened_data_containers. - CREATE OBJECT cut TYPE /usi/cl_bal_dc_collection. + cut = NEW /usi/cl_bal_dc_collection( ). cut = serialize_and_deserialize_coll( cut ). actual_result = flatten_data_cont_coll( cut ). @@ -477,17 +448,13 @@ CLASS lcl_unit_test_serialization IMPLEMENTATION. ENDMETHOD. METHOD get_bad_data_container. - CREATE OBJECT r_result - EXPORTING - i_serialized_data_container = `Data`. + r_result = NEW #( i_serialized_data_container = `Data` ). r_result->set_return_invalid_classname( i_return_invalid_classname ). r_result->set_throw_on_deserialize( i_throw_on_deserialize ). ENDMETHOD. METHOD get_good_data_container. - CREATE OBJECT r_result TYPE lcl_multi_use_container - EXPORTING - i_serialized_data_container = i_serialized_data_container. + r_result = NEW lcl_multi_use_container( i_serialized_data_container = i_serialized_data_container ). ENDMETHOD. METHOD flatten_data_cont_coll. @@ -527,27 +494,28 @@ CLASS lcl_unit_test_serialization IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test +" --------------------------------------------------------------------- CLASS lcl_unit_test_convenience DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. METHODS test_insert_returns_itself FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_convenience IMPLEMENTATION. METHOD test_insert_returns_itself. DATA: actual_result TYPE REF TO /usi/if_bal_data_container_col, cut TYPE REF TO /usi/if_bal_data_container_col, data_container TYPE REF TO /usi/if_bal_data_container. - CREATE OBJECT data_container TYPE lcl_single_use_container - EXPORTING - i_serialized_data_container = 'Data_1'. + data_container = NEW lcl_single_use_container( i_serialized_data_container = 'Data_1' ). - CREATE OBJECT cut TYPE /usi/cl_bal_dc_collection. + cut = NEW /usi/cl_bal_dc_collection( ). actual_result = cut->insert( data_container ). cl_aunit_assert=>assert_equals( msg = 'Insert( ) has to return the collection itself (me)!' @@ -556,23 +524,26 @@ CLASS lcl_unit_test_convenience IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test +" --------------------------------------------------------------------- CLASS lcl_unit_test_bad_data_cont DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. DATA cut TYPE REF TO /usi/if_bal_data_container_col. METHODS setup. - METHODS test_insert_bad_data_container FOR TESTING. - METHODS test_serialize_bad_data_cont FOR TESTING. + METHODS test_insert_bad_data_container FOR TESTING. + METHODS test_serialize_bad_data_cont FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_bad_data_cont IMPLEMENTATION. METHOD setup. - CREATE OBJECT cut TYPE /usi/cl_bal_dc_collection. + cut = NEW /usi/cl_bal_dc_collection( ). lcl_defect_container=>reset_to_defaults( ). ENDMETHOD. @@ -580,9 +551,7 @@ CLASS lcl_unit_test_bad_data_cont IMPLEMENTATION. DATA: bad_data_container TYPE REF TO lcl_defect_container, has_containers TYPE abap_bool. - CREATE OBJECT bad_data_container - EXPORTING - i_serialized_data_container = `data`. + bad_data_container = NEW #( i_serialized_data_container = `data` ). bad_data_container->set_throw_on_serialize( abap_true ). cut->insert( bad_data_container ). @@ -599,9 +568,7 @@ CLASS lcl_unit_test_bad_data_cont IMPLEMENTATION. serialized_data_cont_coll TYPE /usi/bal_xml_string, unexpected_exception TYPE REF TO /usi/cx_bal_root. - CREATE OBJECT bad_data_container - EXPORTING - i_serialized_data_container = `data`. + bad_data_container = NEW #( i_serialized_data_container = `data` ). cut->insert( bad_data_container ). has_containers = cut->has_data_containers( ). diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_html.clas.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_html.clas.abap index 1801b6f..5759ef9 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_html.clas.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_html.clas.abap @@ -8,14 +8,11 @@ CLASS /usi/cl_bal_dc_html DEFINITION PUBLIC FINAL CREATE PUBLIC. "! Constructor "! - "! @parameter i_html_document | HTML-Document as string + "! @parameter i_html_document | HTML-Document as string "! @parameter i_document_title | Optional: Document title (Useful, if multiple documents are appended) METHODS constructor - IMPORTING - i_html_document TYPE string - i_document_title TYPE REF TO /usi/if_bal_text_container_c40 OPTIONAL. - - PROTECTED SECTION. + IMPORTING i_html_document TYPE string + i_document_title TYPE REF TO /usi/if_bal_text_container_c40 OPTIONAL. PRIVATE SECTION. TYPES: ty_html_table_line TYPE c LENGTH 1000, @@ -26,19 +23,15 @@ CLASS /usi/cl_bal_dc_html DEFINITION PUBLIC FINAL CREATE PUBLIC. html_table TYPE ty_html_table. METHODS get_html_table - IMPORTING - i_html_document TYPE string - RETURNING - VALUE(r_result) TYPE ty_html_table. + IMPORTING i_html_document TYPE string + RETURNING VALUE(r_result) TYPE ty_html_table. METHODS raise_exception_on_subrc - RAISING - /usi/cx_bal_root. + RAISING /usi/cx_bal_root. ENDCLASS. - CLASS /usi/cl_bal_dc_html IMPLEMENTATION. METHOD /usi/if_bal_data_container_rnd~render. DATA: document_size TYPE int4, @@ -46,109 +39,84 @@ CLASS /usi/cl_bal_dc_html IMPLEMENTATION. url TYPE c LENGTH 1024. CREATE OBJECT html_viewer - EXPORTING - parent = i_container - EXCEPTIONS - cntl_error = 1 - cntl_install_error = 2 - dp_install_error = 3 - dp_error = 4 - OTHERS = 5. - IF sy-subrc NE 0. + EXPORTING parent = i_container + EXCEPTIONS cntl_error = 1 + cntl_install_error = 2 + dp_install_error = 3 + dp_error = 4 + OTHERS = 5. + IF sy-subrc <> 0. raise_exception_on_subrc( ). ENDIF. html_table = get_html_table( html_document ). document_size = strlen( html_document ). - html_viewer->load_data( - EXPORTING - size = document_size - IMPORTING - assigned_url = url - CHANGING - data_table = html_table - EXCEPTIONS - dp_invalid_parameter = 1 - dp_error_general = 2 - cntl_error = 3 - html_syntax_notcorrect = 4 - OTHERS = 5 ). - IF sy-subrc NE 0. + html_viewer->load_data( EXPORTING size = document_size + IMPORTING assigned_url = url + CHANGING data_table = html_table + EXCEPTIONS dp_invalid_parameter = 1 + dp_error_general = 2 + cntl_error = 3 + html_syntax_notcorrect = 4 + OTHERS = 5 ). + IF sy-subrc <> 0. raise_exception_on_subrc( ). ENDIF. - html_viewer->show_url( - EXPORTING - url = url - EXCEPTIONS - cntl_error = 1 - cnht_error_not_allowed = 2 - cnht_error_parameter = 3 - dp_error_general = 4 - OTHERS = 5 ). - IF sy-subrc NE 0. + html_viewer->show_url( EXPORTING url = url + EXCEPTIONS cntl_error = 1 + cnht_error_not_allowed = 2 + cnht_error_parameter = 3 + dp_error_general = 4 + OTHERS = 5 ). + IF sy-subrc <> 0. raise_exception_on_subrc( ). ENDIF. ENDMETHOD. - METHOD /usi/if_bal_data_container~deserialize. - DATA: deserializer TYPE REF TO /usi/cl_bal_serializer, - document_title TYPE REF TO /usi/if_bal_text_container_c40, + DATA: document_title TYPE REF TO /usi/if_bal_text_container_c40, document_title_classname TYPE /usi/bal_text_cont_classname, exception TYPE REF TO cx_root, exception_text TYPE string, serialized_document_title TYPE /usi/bal_xml_string, - parameter TYPE abap_trans_srcbind, parameters TYPE abap_trans_srcbind_tab, html_document TYPE string. - parameter-name = `HTML_DOCUMENT`. - GET REFERENCE OF html_document INTO parameter-value. - INSERT parameter INTO TABLE parameters. - - parameter-name = `DOCUMENT_TITLE_CLASSNAME`. - GET REFERENCE OF document_title_classname INTO parameter-value. - INSERT parameter INTO TABLE parameters. - - parameter-name = `SERIALIZED_DOCUMENT_TITLE`. - GET REFERENCE OF serialized_document_title INTO parameter-value. - INSERT parameter INTO TABLE parameters. + parameters = VALUE #( ( name = `HTML_DOCUMENT` + value = REF #( html_document ) ) + ( name = `DOCUMENT_TITLE_CLASSNAME` + value = REF #( document_title_classname ) ) + ( name = `SERIALIZED_DOCUMENT_TITLE` + value = REF #( serialized_document_title ) ) ). - CREATE OBJECT deserializer. - deserializer->deserialize_fields( i_serialized_data = i_serialized_data_container - i_parameters = parameters ). + NEW /usi/cl_bal_serializer( )->deserialize_fields( i_serialized_data = i_serialized_data_container + i_parameters = parameters ). IF document_title_classname IS NOT INITIAL. TRY. CALL METHOD (document_title_classname)=>/usi/if_bal_text_container_c40~deserialize - EXPORTING - i_serialized_text_container = serialized_document_title - RECEIVING - r_result = document_title. + EXPORTING i_serialized_text_container = serialized_document_title + RECEIVING r_result = document_title. CATCH cx_sy_dyn_call_error /usi/cx_bal_root INTO exception. exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION exception IS NOT BOUND. + FIELDS exception_text + CONDITION exception IS NOT BOUND. CLEAR document_title. ENDTRY. ENDIF. - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_html - EXPORTING - i_html_document = html_document - i_document_title = document_title. + r_result = NEW /usi/cl_bal_dc_html( i_html_document = html_document + i_document_title = document_title ). ENDMETHOD. - METHOD /usi/if_bal_data_container~get_classname. r_result = '/USI/CL_BAL_DC_HTML'. ENDMETHOD. - METHOD /usi/if_bal_data_container~get_description. DATA document_title_text TYPE /usi/if_bal_text_container_c40=>ty_text. @@ -158,51 +126,39 @@ CLASS /usi/cl_bal_dc_html IMPLEMENTATION. r_result = TEXT-des. IF document_title_text IS NOT INITIAL. - CONCATENATE r_result `: ` document_title_text INTO r_result IN CHARACTER MODE. + r_result = |{ r_result }: { document_title_text }|. ENDIF. ENDMETHOD. - METHOD /usi/if_bal_data_container~is_multiple_use_allowed. r_result = abap_true. ENDMETHOD. - METHOD /usi/if_bal_data_container~serialize. DATA: document_title_classname TYPE /usi/bal_text_cont_classname, serialized_document_title TYPE /usi/bal_xml_string, - parameter TYPE abap_trans_srcbind, - parameters TYPE abap_trans_srcbind_tab, - serializer TYPE REF TO /usi/cl_bal_serializer. + parameters TYPE abap_trans_srcbind_tab. IF document_title IS BOUND. document_title_classname = document_title->get_classname( ). serialized_document_title = document_title->serialize( ). ENDIF. - parameter-name = `HTML_DOCUMENT`. - GET REFERENCE OF html_document INTO parameter-value. - INSERT parameter INTO TABLE parameters. - - parameter-name = `DOCUMENT_TITLE_CLASSNAME`. - GET REFERENCE OF document_title_classname INTO parameter-value. - INSERT parameter INTO TABLE parameters. + parameters = VALUE #( ( name = `HTML_DOCUMENT` + value = REF #( html_document ) ) + ( name = `DOCUMENT_TITLE_CLASSNAME` + value = REF #( document_title_classname ) ) + ( name = `SERIALIZED_DOCUMENT_TITLE` + value = REF #( serialized_document_title ) ) ). - parameter-name = `SERIALIZED_DOCUMENT_TITLE`. - GET REFERENCE OF serialized_document_title INTO parameter-value. - INSERT parameter INTO TABLE parameters. - - CREATE OBJECT serializer. - r_result = serializer->serialize_fields_as_json( parameters ). + r_result = NEW /usi/cl_bal_serializer( )->serialize_fields_as_json( parameters ). ENDMETHOD. - METHOD constructor. html_document = i_html_document. document_title = i_document_title. ENDMETHOD. - METHOD get_html_table. DATA: html_string TYPE string, result_line TYPE ty_html_table_line, @@ -218,23 +174,17 @@ CLASS /usi/cl_bal_dc_html IMPLEMENTATION. ENDWHILE. ENDMETHOD. - METHOD raise_exception_on_subrc. - DATA textid TYPE scx_t100key. - - textid-msgid = sy-msgid. - textid-msgno = sy-msgno. - textid-attr1 = 'PARAM1'. - textid-attr2 = 'PARAM2'. - textid-attr3 = 'PARAM3'. - textid-attr4 = 'PARAM4'. - RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = textid - param1 = sy-msgv1 - param2 = sy-msgv2 - param3 = sy-msgv3 - param4 = sy-msgv4. + EXPORTING textid = VALUE #( msgid = sy-msgid + msgno = sy-msgno + attr1 = 'PARAM1' + attr2 = 'PARAM2' + attr3 = 'PARAM3' + attr4 = 'PARAM4' ) + param1 = sy-msgv1 + param2 = sy-msgv2 + param3 = sy-msgv3 + param4 = sy-msgv4. ENDMETHOD. ENDCLASS. diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_html.clas.testclasses.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_html.clas.testclasses.abap index c2f408d..057b501 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_html.clas.testclasses.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_html.clas.testclasses.abap @@ -1,25 +1,25 @@ *"* use this source file for your ABAP unit test classes -*--------------------------------------------------------------------* -* Unit test: Serialization -*--------------------------------------------------------------------* +" --------------------------------------------------------------------- +" Unit test: Serialization +" --------------------------------------------------------------------- CLASS lcl_unit_tests_serialization DEFINITION DEFERRED. CLASS /usi/cl_bal_dc_html DEFINITION LOCAL FRIENDS lcl_unit_tests_serialization. CLASS lcl_unit_tests_serialization DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. METHODS test_deserialize_bad_xml FOR TESTING. METHODS test_deserialize_valid_xml FOR TESTING. ENDCLASS. + CLASS lcl_unit_tests_serialization IMPLEMENTATION. METHOD test_deserialize_bad_xml. - DATA cut TYPE REF TO /usi/cl_bal_dc_html. - TRY. - cut ?= /usi/cl_bal_dc_html=>/usi/if_bal_data_container~deserialize( `Garbage input - should fail.` ). + /usi/cl_bal_dc_html=>/usi/if_bal_data_container~deserialize( `Garbage input - should fail.` ). cl_aunit_assert=>fail( 'Input was garbage! Exception expected!' ). CATCH /usi/cx_bal_root. RETURN. @@ -38,14 +38,10 @@ CLASS lcl_unit_tests_serialization IMPLEMENTATION. " serialize document = `

test document

`. - CREATE OBJECT title TYPE /usi/cl_bal_tc_literal_c40 - EXPORTING - i_text = 'Test document title'. + title = NEW /usi/cl_bal_tc_literal_c40( i_text = 'Test document title' ). - CREATE OBJECT cut - EXPORTING - i_html_document = document - i_document_title = title. + cut = NEW #( i_html_document = document + i_document_title = title ). TRY. serialized_data_container = cut->/usi/if_bal_data_container~serialize( ). CATCH /usi/cx_bal_root INTO unexpected_exception. @@ -71,16 +67,19 @@ CLASS lcl_unit_tests_serialization IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Cardinality -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Cardinality +" --------------------------------------------------------------------- CLASS lcl_unit_test_cardinality DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. METHODS assert_is_multi_use FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_cardinality IMPLEMENTATION. METHOD assert_is_multi_use. DATA actual_result TYPE abap_bool. @@ -91,16 +90,19 @@ CLASS lcl_unit_test_cardinality IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Classname -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Classname +" --------------------------------------------------------------------- CLASS lcl_unit_test_classname DEFINITION FINAL CREATE PUBLIC FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. METHODS assert_returns_right_classname FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_classname IMPLEMENTATION. METHOD assert_returns_right_classname. DATA: cut_description TYPE REF TO /usi/cl_bal_aunit_cut_descr_cl, diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_itab.clas.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_itab.clas.abap index aee29d8..26ee595 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_itab.clas.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_itab.clas.abap @@ -10,13 +10,12 @@ CLASS /usi/cl_bal_dc_itab DEFINITION PUBLIC CREATE PUBLIC. "!

Constructor

"! "! @parameter i_internal_table | Internal table - "! @parameter i_title | Optional: Title text (useful, if more than one Itab is appended) - "! @parameter i_fieldcatalog | Optional: Field catalog + "! @parameter i_title | Optional: Title text (useful, if more than one Itab is appended) + "! @parameter i_fieldcatalog | Optional: Field catalog METHODS constructor - IMPORTING - i_internal_table TYPE ANY TABLE - i_title TYPE REF TO /usi/if_bal_text_container_c40 OPTIONAL - i_fieldcatalog TYPE lvc_t_fcat OPTIONAL. + IMPORTING i_internal_table TYPE ANY TABLE + i_title TYPE REF TO /usi/if_bal_text_container_c40 OPTIONAL + i_fieldcatalog TYPE lvc_t_fcat OPTIONAL. PROTECTED SECTION. @@ -29,7 +28,6 @@ CLASS /usi/cl_bal_dc_itab DEFINITION PUBLIC CREATE PUBLIC. ENDCLASS. - CLASS /usi/cl_bal_dc_itab IMPLEMENTATION. METHOD /usi/if_bal_data_container~deserialize. DATA: deserializer TYPE REF TO lif_deserializer, @@ -41,9 +39,7 @@ CLASS /usi/cl_bal_dc_itab IMPLEMENTATION. FIELD-SYMBOLS TYPE STANDARD TABLE. - CREATE OBJECT deserializer TYPE lcl_deserializer - EXPORTING - i_serialized_data_container = i_serialized_data_container. + deserializer = NEW lcl_deserializer( i_serialized_data_container = i_serialized_data_container ). deserialized_data-internal_table = deserializer->get_internal_table( ). ASSIGN deserialized_data-internal_table->* TO . @@ -60,14 +56,11 @@ CLASS /usi/cl_bal_dc_itab IMPLEMENTATION. CLEAR deserialized_data-title. ENDTRY. - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_itab - EXPORTING - i_internal_table = - i_title = deserialized_data-title - i_fieldcatalog = deserialized_data-external_fieldcatalog. + r_result = NEW /usi/cl_bal_dc_itab( i_internal_table = + i_title = deserialized_data-title + i_fieldcatalog = deserialized_data-external_fieldcatalog ). ENDMETHOD. - METHOD constructor. DATA: exception TYPE REF TO /usi/cx_bal_root, exception_text TYPE string, @@ -79,18 +72,16 @@ CLASS /usi/cl_bal_dc_itab IMPLEMENTATION. internal_table_ref = table_descriptor->get_table_type_dref( ). GET REFERENCE OF i_internal_table INTO source_table_ref. - CREATE OBJECT table_content_copier - EXPORTING - i_source_table_ref = source_table_ref - i_target_table_ref = internal_table_ref. + table_content_copier = NEW #( i_source_table_ref = source_table_ref + i_target_table_ref = internal_table_ref ). table_content_copier->copy_table_contents( ). CATCH /usi/cx_bal_root INTO exception. exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION exception IS NOT BOUND. + FIELDS exception_text + CONDITION exception IS NOT BOUND. RETURN. ENDTRY. @@ -98,51 +89,40 @@ CLASS /usi/cl_bal_dc_itab IMPLEMENTATION. external_fieldcatalog = i_fieldcatalog. ENDMETHOD. - METHOD /usi/if_bal_data_container~serialize. DATA serializer TYPE REF TO lif_serializer. IF internal_table_ref IS NOT BOUND. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>unsupported_line_type. + EXPORTING textid = /usi/cx_bal_invalid_input=>unsupported_line_type. ENDIF. - CREATE OBJECT serializer TYPE lcl_serializer - EXPORTING - i_table_reference = internal_table_ref - i_table_descriptor = table_descriptor - i_external_fieldcatalog = external_fieldcatalog - i_title = title. + serializer = NEW lcl_serializer( i_table_reference = internal_table_ref + i_table_descriptor = table_descriptor + i_external_fieldcatalog = external_fieldcatalog + i_title = title ). r_result = serializer->serialize( ). ENDMETHOD. - METHOD /usi/if_bal_data_container_rnd~render. DATA: fieldcatalog_collection TYPE REF TO lcl_fieldcatalog_collection, grid_control TYPE REF TO lcl_grid_control. - CREATE OBJECT fieldcatalog_collection - EXPORTING - i_table_descriptor = table_descriptor - i_external_fieldcatalog = external_fieldcatalog. + fieldcatalog_collection = NEW #( i_table_descriptor = table_descriptor + i_external_fieldcatalog = external_fieldcatalog ). - CREATE OBJECT grid_control - EXPORTING - i_container = i_container - i_fieldcatalog_collection = fieldcatalog_collection - i_internal_table_ref = internal_table_ref. + grid_control = NEW #( i_container = i_container + i_fieldcatalog_collection = fieldcatalog_collection + i_internal_table_ref = internal_table_ref ). grid_control->display( ). ENDMETHOD. - METHOD /usi/if_bal_data_container~get_classname. r_result = '/USI/CL_BAL_DC_ITAB'. ENDMETHOD. - METHOD /usi/if_bal_data_container~get_description. DATA title_text TYPE /usi/if_bal_text_container_c40=>ty_text. @@ -152,11 +132,10 @@ CLASS /usi/cl_bal_dc_itab IMPLEMENTATION. r_result = TEXT-des. IF title_text IS NOT INITIAL. - CONCATENATE r_result `: ` title_text INTO r_result IN CHARACTER MODE. + r_result = |{ r_result }: { title_text }|. ENDIF. ENDMETHOD. - METHOD /usi/if_bal_data_container~is_multiple_use_allowed. r_result = abap_true. ENDMETHOD. diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_itab.clas.locals_imp.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_itab.clas.locals_imp.abap index 80a2e53..1afee02 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_itab.clas.locals_imp.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_itab.clas.locals_imp.abap @@ -4,52 +4,36 @@ CLASS lcl_table_descriptor DEFINITION FINAL CREATE PRIVATE. PUBLIC SECTION. CLASS-METHODS get_by_tabname - IMPORTING - i_tabname TYPE tabname - RETURNING - VALUE(r_result) TYPE REF TO lcl_table_descriptor - RAISING - /usi/cx_bal_root. + IMPORTING i_tabname TYPE tabname + RETURNING VALUE(r_result) TYPE REF TO lcl_table_descriptor + RAISING /usi/cx_bal_root. CLASS-METHODS get_by_data - IMPORTING - i_table TYPE ANY TABLE - RETURNING - VALUE(r_result) TYPE REF TO lcl_table_descriptor - RAISING - /usi/cx_bal_root. + IMPORTING i_table TYPE ANY TABLE + RETURNING VALUE(r_result) TYPE REF TO lcl_table_descriptor + RAISING /usi/cx_bal_root. CLASS-METHODS get_by_fieldcatalog - IMPORTING - i_fieldcatalog TYPE lvc_t_fcat - RETURNING - VALUE(r_result) TYPE REF TO lcl_table_descriptor - RAISING - /usi/cx_bal_root. + IMPORTING i_fieldcatalog TYPE lvc_t_fcat + RETURNING VALUE(r_result) TYPE REF TO lcl_table_descriptor + RAISING /usi/cx_bal_root. METHODS constructor - IMPORTING - i_line_type_description TYPE REF TO cl_abap_typedescr - RAISING - /usi/cx_bal_root. + IMPORTING i_line_type_description TYPE REF TO cl_abap_typedescr + RAISING /usi/cx_bal_root. METHODS get_line_type_dref - RETURNING - VALUE(r_result) TYPE REF TO data. + RETURNING VALUE(r_result) TYPE REF TO data. METHODS get_table_type_dref - RETURNING - VALUE(r_result) TYPE REF TO data. + RETURNING VALUE(r_result) TYPE REF TO data. METHODS get_fieldcatalog - RETURNING - VALUE(r_result) TYPE lvc_t_fcat. + RETURNING VALUE(r_result) TYPE lvc_t_fcat. METHODS get_tabname - RETURNING - VALUE(r_result) TYPE tabname - RAISING - /usi/cx_bal_root. + RETURNING VALUE(r_result) TYPE tabname + RAISING /usi/cx_bal_root. PRIVATE SECTION. DATA: BEGIN OF type_descriptions, @@ -62,83 +46,59 @@ CLASS lcl_table_descriptor DEFINITION FINAL CREATE PRIVATE. END OF buffers. METHODS get_normalized_line_type_desc - IMPORTING - i_line_type_description TYPE REF TO cl_abap_typedescr - RETURNING - VALUE(r_result) TYPE REF TO cl_abap_structdescr - RAISING - /usi/cx_bal_root. + IMPORTING i_line_type_description TYPE REF TO cl_abap_typedescr + RETURNING VALUE(r_result) TYPE REF TO cl_abap_structdescr + RAISING /usi/cx_bal_root. METHODS remove_non_elementary_fields - IMPORTING - i_line_type_description TYPE REF TO cl_abap_structdescr - RETURNING - VALUE(r_result) TYPE REF TO cl_abap_structdescr - RAISING - /usi/cx_bal_root. + IMPORTING i_line_type_description TYPE REF TO cl_abap_structdescr + RETURNING VALUE(r_result) TYPE REF TO cl_abap_structdescr + RAISING /usi/cx_bal_root. CLASS-METHODS get_type_by_fieldcatalog_line - IMPORTING - i_fieldcatalog_line TYPE lvc_s_fcat - RETURNING - VALUE(r_result) TYPE REF TO cl_abap_elemdescr - RAISING - /usi/cx_bal_root. + IMPORTING i_fieldcatalog_line TYPE lvc_s_fcat + RETURNING VALUE(r_result) TYPE REF TO cl_abap_elemdescr + RAISING /usi/cx_bal_root. CLASS-METHODS get_type_by_ddic_reference - IMPORTING - i_tabname TYPE tabname - i_fieldname TYPE fieldname - RETURNING - VALUE(r_result) TYPE REF TO cl_abap_elemdescr - RAISING - /usi/cx_bal_root. + IMPORTING i_tabname TYPE tabname + i_fieldname TYPE fieldname + RETURNING VALUE(r_result) TYPE REF TO cl_abap_elemdescr + RAISING /usi/cx_bal_root. CLASS-METHODS get_type_by_name - IMPORTING - i_type_name TYPE typename - RETURNING - VALUE(r_result) TYPE REF TO cl_abap_elemdescr - RAISING - /usi/cx_bal_root. + IMPORTING i_type_name TYPE typename + RETURNING VALUE(r_result) TYPE REF TO cl_abap_elemdescr + RAISING /usi/cx_bal_root. CLASS-METHODS get_type_by_properties - IMPORTING - i_internal_type TYPE inttype - i_length TYPE intlen - i_decimals TYPE decimals - RETURNING - VALUE(r_result) TYPE REF TO cl_abap_elemdescr - RAISING - /usi/cx_bal_root. + IMPORTING i_internal_type TYPE inttype + i_length TYPE intlen + i_decimals TYPE decimals + RETURNING VALUE(r_result) TYPE REF TO cl_abap_elemdescr + RAISING /usi/cx_bal_root. ENDCLASS. + CLASS lcl_table_descriptor IMPLEMENTATION. METHOD get_by_tabname. DATA type_description TYPE REF TO cl_abap_typedescr. - cl_abap_typedescr=>describe_by_name( - EXPORTING - p_name = i_tabname - RECEIVING - p_descr_ref = type_description - EXCEPTIONS - type_not_found = 1 - OTHERS = 2 ). - IF sy-subrc NE 0. + cl_abap_typedescr=>describe_by_name( EXPORTING p_name = i_tabname + RECEIVING p_descr_ref = type_description + EXCEPTIONS type_not_found = 1 + OTHERS = 2 ). + IF sy-subrc <> 0. ASSERT ID /usi/bal_log_writer - FIELDS sy-subrc - CONDITION 1 EQ 0. + FIELDS sy-subrc + CONDITION 1 = 0. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>unsupported_line_type. + EXPORTING textid = /usi/cx_bal_invalid_input=>unsupported_line_type. ENDIF. - CREATE OBJECT r_result - EXPORTING - i_line_type_description = type_description. + r_result = NEW #( i_line_type_description = type_description ). ENDMETHOD. METHOD get_by_data. @@ -155,19 +115,16 @@ CLASS lcl_table_descriptor IMPLEMENTATION. CATCH cx_sy_move_cast_error INTO exception. exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION 1 EQ 0. + FIELDS exception_text + CONDITION 1 = 0. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>unsupported_line_type - previous = exception. + EXPORTING textid = /usi/cx_bal_invalid_input=>unsupported_line_type + previous = exception. ENDTRY. - CREATE OBJECT r_result - EXPORTING - i_line_type_description = type_description. + r_result = NEW #( i_line_type_description = type_description ). ENDMETHOD. METHOD get_by_fieldcatalog. @@ -190,18 +147,15 @@ CLASS lcl_table_descriptor IMPLEMENTATION. CATCH cx_sy_struct_creation INTO exception. exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION 1 EQ 0. + FIELDS exception_text + CONDITION 1 = 0. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>unsupported_line_type - previous = exception. + EXPORTING textid = /usi/cx_bal_invalid_input=>unsupported_line_type + previous = exception. ENDTRY. - CREATE OBJECT r_result - EXPORTING - i_line_type_description = type_description. + r_result = NEW #( i_line_type_description = type_description ). ENDMETHOD. METHOD get_type_by_fieldcatalog_line. @@ -235,33 +189,24 @@ CLASS lcl_table_descriptor IMPLEMENTATION. TRY. - cl_abap_structdescr=>describe_by_name( - EXPORTING - p_name = i_tabname - RECEIVING - p_descr_ref = type_description - EXCEPTIONS - OTHERS = 0 ). + cl_abap_structdescr=>describe_by_name( EXPORTING p_name = i_tabname + RECEIVING p_descr_ref = type_description + EXCEPTIONS OTHERS = 0 ). struc_description ?= type_description. - struc_description->get_component_type( - EXPORTING - p_name = i_fieldname - RECEIVING - p_descr_ref = type_description - EXCEPTIONS - OTHERS = 0 ). - - IF type_description->kind EQ cl_abap_typedescr=>kind_elem. + struc_description->get_component_type( EXPORTING p_name = i_fieldname + RECEIVING p_descr_ref = type_description + EXCEPTIONS OTHERS = 0 ). + + IF type_description->kind = cl_abap_typedescr=>kind_elem. r_result ?= type_description. ELSE. ASSERT ID /usi/bal_log_writer - FIELDS type_description->kind - CONDITION 1 EQ 0. + FIELDS type_description->kind + CONDITION 1 = 0. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>unsupported_field_type. + EXPORTING textid = /usi/cx_bal_invalid_input=>unsupported_field_type. ENDIF. CATCH cx_sy_move_cast_error @@ -269,13 +214,12 @@ CLASS lcl_table_descriptor IMPLEMENTATION. exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION 1 EQ 0. + FIELDS exception_text + CONDITION 1 = 0. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>unsupported_field_type - previous = exception. + EXPORTING textid = /usi/cx_bal_invalid_input=>unsupported_field_type + previous = exception. ENDTRY. ENDMETHOD. @@ -287,24 +231,19 @@ CLASS lcl_table_descriptor IMPLEMENTATION. TRY. - cl_abap_elemdescr=>describe_by_name( - EXPORTING - p_name = i_type_name - RECEIVING - p_descr_ref = type_description - EXCEPTIONS - OTHERS = 0 ). + cl_abap_elemdescr=>describe_by_name( EXPORTING p_name = i_type_name + RECEIVING p_descr_ref = type_description + EXCEPTIONS OTHERS = 0 ). - IF type_description->kind EQ cl_abap_typedescr=>kind_elem. + IF type_description->kind = cl_abap_typedescr=>kind_elem. r_result ?= type_description. ELSE. ASSERT ID /usi/bal_log_writer - FIELDS type_description->kind - CONDITION 1 EQ 0. + FIELDS type_description->kind + CONDITION 1 = 0. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>unsupported_field_type. + EXPORTING textid = /usi/cx_bal_invalid_input=>unsupported_field_type. ENDIF. CATCH cx_sy_move_cast_error @@ -312,13 +251,12 @@ CLASS lcl_table_descriptor IMPLEMENTATION. exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION 1 EQ 0. + FIELDS exception_text + CONDITION 1 = 0. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>unsupported_field_type - previous = exception. + EXPORTING textid = /usi/cx_bal_invalid_input=>unsupported_field_type + previous = exception. ENDTRY. ENDMETHOD. @@ -397,13 +335,12 @@ CLASS lcl_table_descriptor IMPLEMENTATION. exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION 1 EQ 0. + FIELDS exception_text + CONDITION 1 = 0. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>unsupported_field_type - previous = exception. + EXPORTING textid = /usi/cx_bal_invalid_input=>unsupported_field_type + previous = exception. ENDTRY. ENDMETHOD. @@ -420,101 +357,82 @@ CLASS lcl_table_descriptor IMPLEMENTATION. CATCH cx_sy_type_creation INTO exception. exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION 1 EQ 0. + FIELDS exception_text + CONDITION 1 = 0. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>unsupported_line_type - previous = exception. + EXPORTING textid = /usi/cx_bal_invalid_input=>unsupported_line_type + previous = exception. ENDTRY. ENDMETHOD. METHOD get_normalized_line_type_desc. - DATA: components TYPE abap_component_tab, - component TYPE abap_componentdescr, - exception TYPE REF TO cx_root, - exception_text TYPE string, - structure_description TYPE REF TO cl_abap_structdescr. - TRY. CASE i_line_type_description->kind. WHEN cl_abap_typedescr=>kind_struct. - IF i_line_type_description->type_kind EQ cl_abap_typedescr=>typekind_struct1. + IF i_line_type_description->type_kind = cl_abap_typedescr=>typekind_struct1. r_result ?= i_line_type_description. ELSE. - structure_description ?= i_line_type_description. - r_result = remove_non_elementary_fields( structure_description ). + r_result = remove_non_elementary_fields( CAST #( i_line_type_description ) ). ENDIF. WHEN cl_abap_typedescr=>kind_elem. - component-name = 'COLUMN_1'. - component-type ?= i_line_type_description. - INSERT component INTO TABLE components. - r_result = cl_abap_structdescr=>get( components ). + r_result = cl_abap_structdescr=>get( VALUE #( ( name = 'COLUMN_1' + type = CAST #( i_line_type_description ) ) ) ). WHEN OTHERS. ASSERT ID /usi/bal_log_writer - FIELDS i_line_type_description->kind - CONDITION 1 EQ 0. + FIELDS i_line_type_description->kind + CONDITION 1 = 0. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>unsupported_line_type - previous = exception. + EXPORTING textid = /usi/cx_bal_invalid_input=>unsupported_line_type. ENDCASE. CATCH cx_sy_ref_is_initial cx_sy_type_creation - cx_sy_move_cast_error INTO exception. + cx_sy_move_cast_error INTO DATA(exception). - exception_text = exception->get_text( ). + DATA(exception_text) = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION 1 EQ 0. + FIELDS exception_text + CONDITION 1 = 0. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>unsupported_line_type - previous = exception. + EXPORTING textid = /usi/cx_bal_invalid_input=>unsupported_line_type + previous = exception. ENDTRY. ENDMETHOD. METHOD remove_non_elementary_fields. DATA: data_description TYPE REF TO cl_abap_datadescr, - exception TYPE REF TO cx_root, - exception_text TYPE string, - source_component TYPE REF TO abap_compdescr, - target_component TYPE abap_componentdescr, target_components TYPE abap_component_tab. - LOOP AT i_line_type_description->components REFERENCE INTO source_component. + LOOP AT i_line_type_description->components REFERENCE INTO DATA(source_component). data_description = i_line_type_description->get_component_type( source_component->name ). + IF data_description->kind <> cl_abap_typedescr=>kind_elem. + CONTINUE. + ENDIF. - CHECK data_description->kind EQ cl_abap_typedescr=>kind_elem. - - CLEAR target_component. - target_component-name = source_component->name. - target_component-type = data_description. - INSERT target_component INTO TABLE target_components. + INSERT VALUE #( name = source_component->name + type = data_description ) INTO TABLE target_components. ENDLOOP. - IF lines( i_line_type_description->components ) EQ lines( target_components ). + IF lines( i_line_type_description->components ) = lines( target_components ). r_result = i_line_type_description. ELSE. TRY. r_result = cl_abap_structdescr=>get( target_components ). - CATCH cx_sy_struct_creation INTO exception. - exception_text = exception->get_text( ). + CATCH cx_sy_struct_creation INTO DATA(exception). + DATA(exception_text) = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION 1 EQ 0. + FIELDS exception_text + CONDITION 1 = 0. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>unsupported_line_type - previous = exception. + EXPORTING textid = /usi/cx_bal_invalid_input=>unsupported_line_type + previous = exception. ENDTRY. ENDIF. ENDMETHOD. @@ -534,30 +452,21 @@ CLASS lcl_table_descriptor IMPLEMENTATION. field_description TYPE lvc_s_fcat, ddic_description TYPE dfies. - FIELD-SYMBOLS TYPE abap_compdescr. - IF buffers-fieldcatalog IS NOT BOUND. CREATE DATA buffers-fieldcatalog. - IF type_descriptions-line->is_ddic_type( ) EQ abap_true. + IF type_descriptions-line->is_ddic_type( ) = abap_true. tabname = type_descriptions-line->get_relative_name( ). CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' - EXPORTING - i_structure_name = tabname - CHANGING - ct_fieldcat = buffers-fieldcatalog->* - EXCEPTIONS - OTHERS = 0. + EXPORTING i_structure_name = tabname + CHANGING ct_fieldcat = buffers-fieldcatalog->* + EXCEPTIONS OTHERS = 0. ELSE. - LOOP AT type_descriptions-line->components ASSIGNING . - type_descriptions-line->get_component_type( - EXPORTING - p_name = -name - RECEIVING - p_descr_ref = data_description - EXCEPTIONS - OTHERS = 0 ). + LOOP AT type_descriptions-line->components ASSIGNING FIELD-SYMBOL(). + type_descriptions-line->get_component_type( EXPORTING p_name = -name + RECEIVING p_descr_ref = data_description + EXCEPTIONS OTHERS = 0 ). TRY. elem_description ?= data_description. CATCH cx_sy_move_cast_error. @@ -570,12 +479,9 @@ CLASS lcl_table_descriptor IMPLEMENTATION. field_description-decimals = -decimals. field_description-outputlen = elem_description->output_length. - IF elem_description->is_ddic_type( ) EQ abap_true. - elem_description->get_ddic_field( - RECEIVING - p_flddescr = ddic_description - EXCEPTIONS - OTHERS = 0 ). + IF elem_description->is_ddic_type( ) = abap_true. + elem_description->get_ddic_field( RECEIVING p_flddescr = ddic_description + EXCEPTIONS OTHERS = 0 ). field_description-intlen = ddic_description-leng. field_description-domname = ddic_description-domname. @@ -597,11 +503,11 @@ CLASS lcl_table_descriptor IMPLEMENTATION. ELSE. field_description-coltext = -name. field_description-seltext = -name. - IF -type_kind EQ cl_abap_typedescr=>typekind_char - OR -type_kind EQ cl_abap_typedescr=>typekind_hex - OR -type_kind EQ cl_abap_typedescr=>typekind_num - OR -type_kind EQ cl_abap_typedescr=>typekind_packed. - field_description-intlen = -length. + IF -type_kind = cl_abap_typedescr=>typekind_char + OR -type_kind = cl_abap_typedescr=>typekind_hex + OR -type_kind = cl_abap_typedescr=>typekind_num + OR -type_kind = cl_abap_typedescr=>typekind_packed. + field_description-intlen = -length. ENDIF. ENDIF. @@ -615,28 +521,25 @@ CLASS lcl_table_descriptor IMPLEMENTATION. ENDMETHOD. METHOD get_tabname. - IF type_descriptions-line->is_ddic_type( ) EQ abap_true. + IF type_descriptions-line->is_ddic_type( ) = abap_true. r_result = type_descriptions-line->get_relative_name( ). ELSE. RAISE EXCEPTION TYPE /usi/cx_bal_not_found - EXPORTING - textid = /usi/cx_bal_not_found=>generic_not_found. + EXPORTING textid = /usi/cx_bal_not_found=>generic_not_found. ENDIF. ENDMETHOD. ENDCLASS. + CLASS lcl_table_content_copier DEFINITION FINAL CREATE PUBLIC. PUBLIC SECTION. METHODS constructor - IMPORTING - i_source_table_ref TYPE REF TO data - i_target_table_ref TYPE REF TO data - RAISING - /usi/cx_bal_root. + IMPORTING i_source_table_ref TYPE REF TO data + i_target_table_ref TYPE REF TO data + RAISING /usi/cx_bal_root. METHODS copy_table_contents - RAISING - /usi/cx_bal_root. + RAISING /usi/cx_bal_root. PRIVATE SECTION. DATA: BEGIN OF source_table, @@ -652,22 +555,18 @@ CLASS lcl_table_content_copier DEFINITION FINAL CREATE PUBLIC. END OF target_table. METHODS get_table_type_description - IMPORTING - i_table_ref TYPE REF TO data - RETURNING - VALUE(r_result) TYPE REF TO cl_abap_tabledescr - RAISING - /usi/cx_bal_root. + IMPORTING i_table_ref TYPE REF TO data + RETURNING VALUE(r_result) TYPE REF TO cl_abap_tabledescr + RAISING /usi/cx_bal_root. METHODS copy_elementary_to_structured - RAISING - /usi/cx_bal_root. + RAISING /usi/cx_bal_root. METHODS copy_structured_to_structured - RAISING - /usi/cx_bal_root. + RAISING /usi/cx_bal_root. ENDCLASS. + CLASS lcl_table_content_copier IMPLEMENTATION. METHOD constructor. source_table-content = i_source_table_ref. @@ -680,34 +579,27 @@ CLASS lcl_table_content_copier IMPLEMENTATION. target_table-line_type ?= target_table-table_type->get_table_line_type( ). CATCH cx_sy_move_cast_error. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>unsupported_line_type. + EXPORTING textid = /usi/cx_bal_invalid_input=>unsupported_line_type. ENDTRY. ENDMETHOD. METHOD get_table_type_description. DATA type_description TYPE REF TO cl_abap_typedescr. - cl_abap_typedescr=>describe_by_data_ref( - EXPORTING - p_data_ref = i_table_ref - RECEIVING - p_descr_ref = type_description - EXCEPTIONS - reference_is_initial = 1 - OTHERS = 2 ). - IF sy-subrc NE 0. + cl_abap_typedescr=>describe_by_data_ref( EXPORTING p_data_ref = i_table_ref + RECEIVING p_descr_ref = type_description + EXCEPTIONS reference_is_initial = 1 + OTHERS = 2 ). + IF sy-subrc <> 0. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>itab_required. + EXPORTING textid = /usi/cx_bal_invalid_input=>itab_required. ENDIF. TRY. r_result ?= type_description. CATCH cx_sy_move_cast_error. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>itab_required. + EXPORTING textid = /usi/cx_bal_invalid_input=>itab_required. ENDTRY. ENDMETHOD. @@ -721,8 +613,7 @@ CLASS lcl_table_content_copier IMPLEMENTATION. WHEN OTHERS. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>unsupported_line_type. + EXPORTING textid = /usi/cx_bal_invalid_input=>unsupported_line_type. ENDCASE. ENDMETHOD. @@ -740,7 +631,7 @@ CLASS lcl_table_content_copier IMPLEMENTATION. ASSIGN source_table-content->* TO . ASSIGN target_table-content->* TO . - READ TABLE target_table-line_type->components INDEX 1 ASSIGNING . + ASSIGN target_table-line_type->components[ 1 ] TO . CREATE DATA target_line TYPE HANDLE target_table-line_type. ASSIGN target_line->* TO . ASSIGN COMPONENT -name OF STRUCTURE TO . @@ -764,7 +655,7 @@ CLASS lcl_table_content_copier IMPLEMENTATION. ASSIGN target_table-content->* TO . source_line_type ?= source_table-line_type. - IF target_table-line_type->components EQ source_line_type->components. + IF target_table-line_type->components = source_line_type->components. = . ELSE. @@ -780,6 +671,7 @@ CLASS lcl_table_content_copier IMPLEMENTATION. ENDMETHOD. ENDCLASS. + CLASS lcl_persistency_flavor_enum DEFINITION FINAL CREATE PRIVATE. PUBLIC SECTION. TYPES ty_persistency_flavor TYPE n LENGTH 2. @@ -794,16 +686,12 @@ CLASS lcl_persistency_flavor_enum DEFINITION FINAL CREATE PRIVATE. CLASS-METHODS class_constructor. CLASS-METHODS get_by_value - IMPORTING - i_value TYPE ty_persistency_flavor - RETURNING - VALUE(r_result) TYPE REF TO lcl_persistency_flavor_enum - RAISING - /usi/cx_bal_root. + IMPORTING i_value TYPE ty_persistency_flavor + RETURNING VALUE(r_result) TYPE REF TO lcl_persistency_flavor_enum + RAISING /usi/cx_bal_root. METHODS constructor - IMPORTING - i_value TYPE ty_persistency_flavor. + IMPORTING i_value TYPE ty_persistency_flavor. PRIVATE SECTION. TYPES: BEGIN OF ty_instance, @@ -815,29 +703,21 @@ CLASS lcl_persistency_flavor_enum DEFINITION FINAL CREATE PRIVATE. CLASS-DATA instances TYPE ty_instances. CLASS-METHODS buffer_instance - IMPORTING - i_value TYPE ty_persistency_flavor - i_instance TYPE REF TO lcl_persistency_flavor_enum. + IMPORTING i_value TYPE ty_persistency_flavor + i_instance TYPE REF TO lcl_persistency_flavor_enum. ENDCLASS. + CLASS lcl_persistency_flavor_enum IMPLEMENTATION. METHOD class_constructor. - CREATE OBJECT tabname_xml - EXPORTING - i_value = 1. + tabname_xml = NEW #( i_value = 1 ). - CREATE OBJECT fieldcatalog_xml - EXPORTING - i_value = 2. + fieldcatalog_xml = NEW #( i_value = 2 ). - CREATE OBJECT tabname_json - EXPORTING - i_value = 3. + tabname_json = NEW #( i_value = 3 ). - CREATE OBJECT fieldcatalog_json - EXPORTING - i_value = 4. + fieldcatalog_json = NEW #( i_value = 4 ). " For the sake of backwards compatibility " (Previous versions used flavor 1, but since they @@ -866,16 +746,16 @@ CLASS lcl_persistency_flavor_enum IMPLEMENTATION. DATA instance TYPE REF TO ty_instance. READ TABLE instances REFERENCE INTO instance WITH TABLE KEY value = i_value. - IF sy-subrc EQ 0. + IF sy-subrc = 0. r_result = instance->instance. ELSE. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>/usi/cx_bal_invalid_input. + EXPORTING textid = /usi/cx_bal_invalid_input=>/usi/cx_bal_invalid_input. ENDIF. ENDMETHOD. ENDCLASS. + INTERFACE lif_persistency_constants. TYPES ty_parameter_name TYPE string. @@ -893,48 +773,43 @@ INTERFACE lif_persistency_constants. ENDINTERFACE. + INTERFACE lif_serializer. INTERFACES lif_persistency_constants. METHODS serialize - RETURNING - VALUE(r_result) TYPE /usi/bal_serialized_data - RAISING - /usi/cx_bal_root. + RETURNING VALUE(r_result) TYPE /usi/bal_serialized_data + RAISING /usi/cx_bal_root. ENDINTERFACE. + INTERFACE lif_deserializer. INTERFACES lif_persistency_constants. METHODS get_internal_table - RETURNING - VALUE(r_result) TYPE REF TO data. + RETURNING VALUE(r_result) TYPE REF TO data. METHODS get_external_fieldcatalog - RETURNING - VALUE(r_result) TYPE lvc_t_fcat - RAISING - /usi/cx_bal_root. + RETURNING VALUE(r_result) TYPE lvc_t_fcat + RAISING /usi/cx_bal_root. METHODS get_title - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_text_container_c40 - RAISING - /usi/cx_bal_root. + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_text_container_c40 + RAISING /usi/cx_bal_root. ENDINTERFACE. + CLASS lcl_serializer DEFINITION FINAL CREATE PUBLIC. PUBLIC SECTION. INTERFACES lif_serializer. METHODS constructor - IMPORTING - i_table_reference TYPE REF TO data - i_table_descriptor TYPE REF TO lcl_table_descriptor - i_external_fieldcatalog TYPE lvc_t_fcat OPTIONAL - i_title TYPE REF TO /usi/if_bal_text_container_c40 OPTIONAL. + IMPORTING i_table_reference TYPE REF TO data + i_table_descriptor TYPE REF TO lcl_table_descriptor + i_external_fieldcatalog TYPE lvc_t_fcat OPTIONAL + i_title TYPE REF TO /usi/if_bal_text_container_c40 OPTIONAL. PRIVATE SECTION. DATA: BEGIN OF input, @@ -947,37 +822,29 @@ CLASS lcl_serializer DEFINITION FINAL CREATE PUBLIC. serializer TYPE REF TO /usi/cl_bal_serializer. METHODS get_persistency_flavor - RETURNING - VALUE(r_result) TYPE REF TO lcl_persistency_flavor_enum. + RETURNING VALUE(r_result) TYPE REF TO lcl_persistency_flavor_enum. METHODS serialize_persistency_flavor - RETURNING - VALUE(r_result) TYPE abap_trans_srcbind_tab. + RETURNING VALUE(r_result) TYPE abap_trans_srcbind_tab. METHODS serialize_table_descriptor - RETURNING - VALUE(r_result) TYPE abap_trans_srcbind_tab - RAISING - /usi/cx_bal_root. + RETURNING VALUE(r_result) TYPE abap_trans_srcbind_tab + RAISING /usi/cx_bal_root. METHODS serialize_table_data - RETURNING - VALUE(r_result) TYPE abap_trans_srcbind_tab - RAISING - /usi/cx_bal_root. + RETURNING VALUE(r_result) TYPE abap_trans_srcbind_tab + RAISING /usi/cx_bal_root. METHODS serialize_external_fieldcat - RETURNING - VALUE(r_result) TYPE abap_trans_srcbind_tab - RAISING - /usi/cx_bal_root. + RETURNING VALUE(r_result) TYPE abap_trans_srcbind_tab + RAISING /usi/cx_bal_root. METHODS serialize_title - RETURNING - VALUE(r_result) TYPE abap_trans_srcbind_tab. + RETURNING VALUE(r_result) TYPE abap_trans_srcbind_tab. ENDCLASS. + CLASS lcl_serializer IMPLEMENTATION. METHOD constructor. input-table_reference = i_table_reference. @@ -987,7 +854,7 @@ CLASS lcl_serializer IMPLEMENTATION. persistency_flavor = get_persistency_flavor( ). - CREATE OBJECT serializer. + serializer = NEW #( ). ENDMETHOD. METHOD get_persistency_flavor. @@ -1062,8 +929,8 @@ CLASS lcl_serializer IMPLEMENTATION. WHEN lcl_persistency_flavor_enum=>fieldcatalog_json. fieldcatalog = input-table_descriptor->get_fieldcatalog( ). serialized_fieldcatalog = serializer->serialize_field_as_json( - i_data = fieldcatalog - i_name = lif_persistency_constants~c_parameter_names-internal_fieldcatalog ). + i_data = fieldcatalog + i_name = lif_persistency_constants~c_parameter_names-internal_fieldcatalog ). result_line-name = lif_persistency_constants~c_parameter_names-internal_fieldcatalog. CREATE DATA result_line-value TYPE /usi/bal_json_string. @@ -1086,11 +953,11 @@ CLASS lcl_serializer IMPLEMENTATION. CREATE DATA parameter-value TYPE /usi/bal_json_string. ASSIGN parameter-value->* TO . - CREATE OBJECT json_converter. + json_converter = NEW #( ). ASSIGN input-table_reference->* TO . = json_converter->serialize_field_as_json( - i_name = lif_persistency_constants~c_parameter_names-internal_table - i_data = ). + i_name = lif_persistency_constants~c_parameter_names-internal_table + i_data = ). INSERT parameter INTO TABLE r_result. ENDMETHOD. @@ -1109,10 +976,10 @@ CLASS lcl_serializer IMPLEMENTATION. CREATE DATA result_line-value TYPE /usi/bal_json_string. ASSIGN result_line-value->* TO . - CREATE OBJECT json_converter. + json_converter = NEW #( ). = json_converter->serialize_field_as_json( - i_name = lif_persistency_constants~c_parameter_names-external_fieldcatalog - i_data = input-external_fieldcatalog ). + i_name = lif_persistency_constants~c_parameter_names-external_fieldcatalog + i_data = input-external_fieldcatalog ). INSERT result_line INTO TABLE r_result. ENDMETHOD. @@ -1123,33 +990,34 @@ CLASS lcl_serializer IMPLEMENTATION. FIELD-SYMBOLS: TYPE /usi/bal_text_cont_classname, TYPE /usi/bal_xml_string. - IF input-title IS BOUND. - CLEAR result_line. - result_line-name = lif_persistency_constants~c_parameter_names-title_classname. - CREATE DATA result_line-value TYPE /usi/bal_text_cont_classname. - ASSIGN result_line-value->* TO . - = input-title->get_classname( ). - INSERT result_line INTO TABLE r_result. - - CLEAR result_line. - result_line-name = lif_persistency_constants~c_parameter_names-serialized_title. - CREATE DATA result_line-value TYPE /usi/bal_xml_string. - ASSIGN result_line-value->* TO . - = input-title->serialize( ). - INSERT result_line INTO TABLE r_result. + IF input-title IS NOT BOUND. + RETURN. ENDIF. + + CLEAR result_line. + result_line-name = lif_persistency_constants~c_parameter_names-title_classname. + CREATE DATA result_line-value TYPE /usi/bal_text_cont_classname. + ASSIGN result_line-value->* TO . + = input-title->get_classname( ). + INSERT result_line INTO TABLE r_result. + + CLEAR result_line. + result_line-name = lif_persistency_constants~c_parameter_names-serialized_title. + CREATE DATA result_line-value TYPE /usi/bal_xml_string. + ASSIGN result_line-value->* TO . + = input-title->serialize( ). + INSERT result_line INTO TABLE r_result. ENDMETHOD. ENDCLASS. + CLASS lcl_deserializer DEFINITION FINAL CREATE PUBLIC. PUBLIC SECTION. INTERFACES lif_deserializer. METHODS constructor - IMPORTING - i_serialized_data_container TYPE /usi/bal_serialized_data - RAISING - /usi/cx_bal_root. + IMPORTING i_serialized_data_container TYPE /usi/bal_serialized_data + RAISING /usi/cx_bal_root. PRIVATE SECTION. DATA: BEGIN OF deserialized_data, @@ -1162,54 +1030,40 @@ CLASS lcl_deserializer DEFINITION FINAL CREATE PUBLIC. deserializer TYPE REF TO /usi/cl_bal_serializer. METHODS get_persistency_flavor - IMPORTING - i_serialized_data_container TYPE /usi/bal_serialized_data - RETURNING - VALUE(r_result) TYPE REF TO lcl_persistency_flavor_enum - RAISING - /usi/cx_bal_root. + IMPORTING i_serialized_data_container TYPE /usi/bal_serialized_data + RETURNING VALUE(r_result) TYPE REF TO lcl_persistency_flavor_enum + RAISING /usi/cx_bal_root. METHODS get_table_descriptor - IMPORTING - i_persistency_flavor TYPE REF TO lcl_persistency_flavor_enum - i_serialized_data_container TYPE /usi/bal_serialized_data - RETURNING - VALUE(r_result) TYPE REF TO lcl_table_descriptor - RAISING - /usi/cx_bal_root. + IMPORTING i_persistency_flavor TYPE REF TO lcl_persistency_flavor_enum + i_serialized_data_container TYPE /usi/bal_serialized_data + RETURNING VALUE(r_result) TYPE REF TO lcl_table_descriptor + RAISING /usi/cx_bal_root. METHODS get_table_data - IMPORTING - i_persistency_flavor TYPE REF TO lcl_persistency_flavor_enum - i_serialized_data_container TYPE /usi/bal_serialized_data - i_table_descriptor TYPE REF TO lcl_table_descriptor - RETURNING - VALUE(r_result) TYPE REF TO data - RAISING - /usi/cx_bal_root. + IMPORTING i_persistency_flavor TYPE REF TO lcl_persistency_flavor_enum + i_serialized_data_container TYPE /usi/bal_serialized_data + i_table_descriptor TYPE REF TO lcl_table_descriptor + RETURNING VALUE(r_result) TYPE REF TO data + RAISING /usi/cx_bal_root. METHODS get_external_fieldcatalog - IMPORTING - i_persistency_flavor TYPE REF TO lcl_persistency_flavor_enum - i_serialized_data_container TYPE /usi/bal_serialized_data - RETURNING - VALUE(r_result) TYPE lvc_t_fcat - RAISING - /usi/cx_bal_root. + IMPORTING i_persistency_flavor TYPE REF TO lcl_persistency_flavor_enum + i_serialized_data_container TYPE /usi/bal_serialized_data + RETURNING VALUE(r_result) TYPE lvc_t_fcat + RAISING /usi/cx_bal_root. METHODS get_title - IMPORTING - i_serialized_data_container TYPE /usi/bal_serialized_data - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_text_container_c40 - RAISING - /usi/cx_bal_root. + IMPORTING i_serialized_data_container TYPE /usi/bal_serialized_data + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_text_container_c40 + RAISING /usi/cx_bal_root. ENDCLASS. + CLASS lcl_deserializer IMPLEMENTATION. METHOD constructor. - CREATE OBJECT deserializer. + deserializer = NEW #( ). deserialized_data-persistency_flavor = get_persistency_flavor( i_serialized_data_container ). deserialized_data-table_descriptor = get_table_descriptor( @@ -1239,11 +1093,9 @@ CLASS lcl_deserializer IMPLEMENTATION. DATA persistency_flavor TYPE lcl_persistency_flavor_enum=>ty_persistency_flavor. deserializer->deserialize_field( - EXPORTING - i_serialized_data = i_serialized_data_container - i_name = lif_persistency_constants~c_parameter_names-persistency_flavor - CHANGING - c_data = persistency_flavor ). + EXPORTING i_serialized_data = i_serialized_data_container + i_name = lif_persistency_constants~c_parameter_names-persistency_flavor + CHANGING c_data = persistency_flavor ). r_result = lcl_persistency_flavor_enum=>get_by_value( persistency_flavor ). ENDMETHOD. @@ -1258,40 +1110,32 @@ CLASS lcl_deserializer IMPLEMENTATION. OR lcl_persistency_flavor_enum=>tabname_json. deserializer->deserialize_field( - EXPORTING - i_serialized_data = i_serialized_data_container - i_name = lif_persistency_constants~c_parameter_names-table_name - CHANGING - c_data = tabname ). + EXPORTING i_serialized_data = i_serialized_data_container + i_name = lif_persistency_constants~c_parameter_names-table_name + CHANGING c_data = tabname ). r_result = lcl_table_descriptor=>get_by_tabname( tabname ). WHEN lcl_persistency_flavor_enum=>fieldcatalog_xml. deserializer->deserialize_field( - EXPORTING - i_serialized_data = i_serialized_data_container - i_name = lif_persistency_constants~c_parameter_names-internal_fieldcatalog - CHANGING - c_data = fieldcat ). + EXPORTING i_serialized_data = i_serialized_data_container + i_name = lif_persistency_constants~c_parameter_names-internal_fieldcatalog + CHANGING c_data = fieldcat ). r_result = lcl_table_descriptor=>get_by_fieldcatalog( fieldcat ). WHEN lcl_persistency_flavor_enum=>fieldcatalog_json. deserializer->deserialize_field( - EXPORTING - i_serialized_data = i_serialized_data_container - i_name = lif_persistency_constants~c_parameter_names-internal_fieldcatalog - CHANGING - c_data = json_string ). + EXPORTING i_serialized_data = i_serialized_data_container + i_name = lif_persistency_constants~c_parameter_names-internal_fieldcatalog + CHANGING c_data = json_string ). deserializer->deserialize_field( - EXPORTING - i_serialized_data = json_string - i_name = lif_persistency_constants~c_parameter_names-internal_fieldcatalog - CHANGING - c_data = fieldcat ). + EXPORTING i_serialized_data = json_string + i_name = lif_persistency_constants~c_parameter_names-internal_fieldcatalog + CHANGING c_data = fieldcat ). r_result = lcl_table_descriptor=>get_by_fieldcatalog( fieldcat ). @@ -1315,21 +1159,16 @@ CLASS lcl_deserializer IMPLEMENTATION. ENDCASE. - deserializer->deserialize_field( - EXPORTING - i_serialized_data = i_serialized_data_container - i_name = fieldname - CHANGING - c_data = serialized_table_data ). + deserializer->deserialize_field( EXPORTING i_serialized_data = i_serialized_data_container + i_name = fieldname + CHANGING c_data = serialized_table_data ). r_result = i_table_descriptor->get_table_type_dref( ). ASSIGN r_result->* TO . deserializer->deserialize_field( - EXPORTING - i_name = lif_persistency_constants~c_parameter_names-internal_table - i_serialized_data = serialized_table_data - CHANGING - c_data = ). + EXPORTING i_name = lif_persistency_constants~c_parameter_names-internal_table + i_serialized_data = serialized_table_data + CHANGING c_data = ). ENDMETHOD. METHOD get_external_fieldcatalog. @@ -1340,30 +1179,24 @@ CLASS lcl_deserializer IMPLEMENTATION. OR lcl_persistency_flavor_enum=>tabname_xml. deserializer->deserialize_field( - EXPORTING - i_serialized_data = i_serialized_data_container - i_name = lif_persistency_constants~c_parameter_names-external_fieldcatalog - CHANGING - c_data = r_result ). + EXPORTING i_serialized_data = i_serialized_data_container + i_name = lif_persistency_constants~c_parameter_names-external_fieldcatalog + CHANGING c_data = r_result ). RETURN. WHEN lcl_persistency_flavor_enum=>fieldcatalog_json OR lcl_persistency_flavor_enum=>tabname_json. deserializer->deserialize_field( - EXPORTING - i_serialized_data = i_serialized_data_container - i_name = lif_persistency_constants~c_parameter_names-external_fieldcatalog - CHANGING - c_data = serialized_fieldcatalog ). + EXPORTING i_serialized_data = i_serialized_data_container + i_name = lif_persistency_constants~c_parameter_names-external_fieldcatalog + CHANGING c_data = serialized_fieldcatalog ). IF serialized_fieldcatalog IS NOT INITIAL. deserializer->deserialize_field( - EXPORTING - i_name = lif_persistency_constants~c_parameter_names-external_fieldcatalog - i_serialized_data = serialized_fieldcatalog - CHANGING - c_data = r_result ). + EXPORTING i_name = lif_persistency_constants~c_parameter_names-external_fieldcatalog + i_serialized_data = serialized_fieldcatalog + CHANGING c_data = r_result ). ENDIF. ENDCASE. @@ -1390,29 +1223,25 @@ CLASS lcl_deserializer IMPLEMENTATION. IF classname IS INITIAL. RAISE EXCEPTION TYPE /usi/cx_bal_not_found - EXPORTING - textid = /usi/cx_bal_not_found=>generic_not_found. + EXPORTING textid = /usi/cx_bal_not_found=>generic_not_found. ENDIF. TRY. CALL METHOD (classname)=>/usi/if_bal_text_container_c40~deserialize - EXPORTING - i_serialized_text_container = serialized_title - RECEIVING - r_result = r_result. + EXPORTING i_serialized_text_container = serialized_title + RECEIVING r_result = r_result. CATCH cx_sy_dyn_call_error /usi/cx_bal_root INTO exception. exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION 1 EQ 0. + FIELDS exception_text + CONDITION 1 = 0. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>/usi/cx_bal_invalid_input - previous = exception. + EXPORTING textid = /usi/cx_bal_invalid_input=>/usi/cx_bal_invalid_input + previous = exception. ENDTRY. ENDMETHOD. @@ -1421,8 +1250,7 @@ CLASS lcl_deserializer IMPLEMENTATION. r_result = deserialized_data-external_fieldcatalog. ELSE. RAISE EXCEPTION TYPE /usi/cx_bal_not_found - EXPORTING - textid = /usi/cx_bal_not_found=>generic_not_found. + EXPORTING textid = /usi/cx_bal_not_found=>generic_not_found. ENDIF. ENDMETHOD. @@ -1435,12 +1263,12 @@ CLASS lcl_deserializer IMPLEMENTATION. r_result = deserialized_data-title. ELSE. RAISE EXCEPTION TYPE /usi/cx_bal_not_found - EXPORTING - textid = /usi/cx_bal_not_found=>generic_not_found. + EXPORTING textid = /usi/cx_bal_not_found=>generic_not_found. ENDIF. ENDMETHOD. ENDCLASS. + CLASS lcl_fieldcatalog_name_enum DEFINITION FINAL CREATE PRIVATE. PUBLIC SECTION. TYPES ty_fieldcatalog_name TYPE c LENGTH 10. @@ -1454,24 +1282,18 @@ CLASS lcl_fieldcatalog_name_enum DEFINITION FINAL CREATE PRIVATE. CLASS-METHODS class_constructor. METHODS constructor - IMPORTING - i_fieldcatalog_name TYPE ty_fieldcatalog_name. + IMPORTING i_fieldcatalog_name TYPE ty_fieldcatalog_name. ENDCLASS. + CLASS lcl_fieldcatalog_name_enum IMPLEMENTATION. METHOD class_constructor. - CREATE OBJECT external - EXPORTING - i_fieldcatalog_name = 'EXTERNAL'. + external = NEW #( i_fieldcatalog_name = 'EXTERNAL' ). - CREATE OBJECT internal - EXPORTING - i_fieldcatalog_name = 'INTERNAL'. + internal = NEW #( i_fieldcatalog_name = 'INTERNAL' ). - CREATE OBJECT technical - EXPORTING - i_fieldcatalog_name = 'TECHNICAL'. + technical = NEW #( i_fieldcatalog_name = 'TECHNICAL' ). ENDMETHOD. METHOD constructor. @@ -1479,24 +1301,20 @@ CLASS lcl_fieldcatalog_name_enum IMPLEMENTATION. ENDMETHOD. ENDCLASS. + CLASS lcl_fieldcatalog_collection DEFINITION FINAL CREATE PUBLIC. PUBLIC SECTION. METHODS constructor - IMPORTING - i_table_descriptor TYPE REF TO lcl_table_descriptor - i_external_fieldcatalog TYPE lvc_t_fcat OPTIONAL. + IMPORTING i_table_descriptor TYPE REF TO lcl_table_descriptor + i_external_fieldcatalog TYPE lvc_t_fcat OPTIONAL. METHODS get_fieldcatalog - IMPORTING - i_fieldcatalog_name TYPE REF TO lcl_fieldcatalog_name_enum - RETURNING - VALUE(r_result) TYPE lvc_t_fcat. + IMPORTING i_fieldcatalog_name TYPE REF TO lcl_fieldcatalog_name_enum + RETURNING VALUE(r_result) TYPE lvc_t_fcat. METHODS has_fieldcatalog - IMPORTING - i_fieldcatalog_name TYPE REF TO lcl_fieldcatalog_name_enum - RETURNING - VALUE(r_result) TYPE abap_bool. + IMPORTING i_fieldcatalog_name TYPE REF TO lcl_fieldcatalog_name_enum + RETURNING VALUE(r_result) TYPE abap_bool. PRIVATE SECTION. TYPES: BEGIN OF ty_fieldcatalog, @@ -1508,18 +1326,16 @@ CLASS lcl_fieldcatalog_collection DEFINITION FINAL CREATE PUBLIC. DATA fieldcatalogs TYPE ty_fieldcatalogs. METHODS insert_fieldcatalog - IMPORTING - i_fieldcatalog_name TYPE REF TO lcl_fieldcatalog_name_enum - i_fieldcatalog TYPE lvc_t_fcat. + IMPORTING i_fieldcatalog_name TYPE REF TO lcl_fieldcatalog_name_enum + i_fieldcatalog TYPE lvc_t_fcat. METHODS merge_technical_fieldcatalog - IMPORTING - i_table_descriptor TYPE REF TO lcl_table_descriptor - RETURNING - VALUE(r_result) TYPE lvc_t_fcat. + IMPORTING i_table_descriptor TYPE REF TO lcl_table_descriptor + RETURNING VALUE(r_result) TYPE lvc_t_fcat. ENDCLASS. + CLASS lcl_fieldcatalog_collection IMPLEMENTATION. METHOD constructor. insert_fieldcatalog( i_fieldcatalog_name = lcl_fieldcatalog_name_enum=>internal @@ -1560,7 +1376,7 @@ CLASS lcl_fieldcatalog_collection IMPLEMENTATION. DATA fieldcatalog TYPE REF TO ty_fieldcatalog. READ TABLE fieldcatalogs WITH TABLE KEY name = i_fieldcatalog_name->value REFERENCE INTO fieldcatalog. - IF sy-subrc EQ 0. + IF sy-subrc = 0. r_result = fieldcatalog->fieldcatalog. ELSE. r_result = get_fieldcatalog( lcl_fieldcatalog_name_enum=>internal ). @@ -1568,22 +1384,20 @@ CLASS lcl_fieldcatalog_collection IMPLEMENTATION. ENDMETHOD. METHOD has_fieldcatalog. - READ TABLE fieldcatalogs TRANSPORTING NO FIELDS WITH KEY name = i_fieldcatalog_name->value. - IF sy-subrc EQ 0. + IF line_exists( fieldcatalogs[ name = i_fieldcatalog_name->value ] ). r_result = abap_true. ENDIF. ENDMETHOD. ENDCLASS. + CLASS lcl_grid_control DEFINITION FINAL CREATE PUBLIC. PUBLIC SECTION. METHODS constructor - IMPORTING - i_container TYPE REF TO cl_gui_container - i_fieldcatalog_collection TYPE REF TO lcl_fieldcatalog_collection - i_internal_table_ref TYPE REF TO data - RAISING - /usi/cx_bal_root. + IMPORTING i_container TYPE REF TO cl_gui_container + i_fieldcatalog_collection TYPE REF TO lcl_fieldcatalog_collection + i_internal_table_ref TYPE REF TO data + RAISING /usi/cx_bal_root. METHODS display. @@ -1608,31 +1422,28 @@ CLASS lcl_grid_control DEFINITION FINAL CREATE PUBLIC. END OF grid. METHODS get_excluded_functions - RETURNING - VALUE(r_result) TYPE ui_functions. + RETURNING VALUE(r_result) TYPE ui_functions. METHODS get_layout - RETURNING - VALUE(r_result) TYPE lvc_s_layo. + RETURNING VALUE(r_result) TYPE lvc_s_layo. METHODS on_alv_toolbar FOR EVENT toolbar OF cl_gui_alv_grid - IMPORTING - e_object. + IMPORTING e_object. METHODS on_alv_user_command FOR EVENT user_command OF cl_gui_alv_grid - IMPORTING - e_ucomm. + IMPORTING e_ucomm. METHODS refresh_screen. ENDCLASS. + CLASS lcl_grid_control IMPLEMENTATION. METHOD constructor. input-fieldcatalog_collection = i_fieldcatalog_collection. input-internal_table_ref = i_internal_table_ref. - IF input-fieldcatalog_collection->has_fieldcatalog( lcl_fieldcatalog_name_enum=>external ) EQ abap_true. + IF input-fieldcatalog_collection->has_fieldcatalog( lcl_fieldcatalog_name_enum=>external ) = abap_true. grid-fieldcatalog_name = lcl_fieldcatalog_name_enum=>external. ELSE. grid-fieldcatalog_name = lcl_fieldcatalog_name_enum=>internal. @@ -1642,10 +1453,8 @@ CLASS lcl_grid_control IMPLEMENTATION. grid-layout = get_layout( ). CREATE OBJECT grid-instance - EXPORTING - i_parent = i_container - EXCEPTIONS - OTHERS = 0. + EXPORTING i_parent = i_container + EXCEPTIONS OTHERS = 0. SET HANDLER on_alv_toolbar FOR grid-instance. SET HANDLER on_alv_user_command FOR grid-instance. @@ -1670,38 +1479,38 @@ CLASS lcl_grid_control IMPLEMENTATION. ENDMETHOD. METHOD get_layout. - r_result-zebra = abap_true. - r_result-cwidth_opt = abap_true. + r_result-zebra = abap_true. + r_result-cwidth_opt = abap_true. ENDMETHOD. METHOD on_alv_toolbar. DATA toolbar_button TYPE stb_button. - IF input-fieldcatalog_collection->has_fieldcatalog( lcl_fieldcatalog_name_enum=>external ) EQ abap_true. + IF input-fieldcatalog_collection->has_fieldcatalog( lcl_fieldcatalog_name_enum=>external ) = abap_true. CLEAR toolbar_button. toolbar_button-function = c_user_commands-set_external_fcat. - IF grid-fieldcatalog_name EQ lcl_fieldcatalog_name_enum=>external. + IF grid-fieldcatalog_name = lcl_fieldcatalog_name_enum=>external. toolbar_button-disabled = abap_true. ENDIF. - toolbar_button-text = 'External fieldcatalog'(b01). + toolbar_button-text = 'External fieldcatalog'(b01). INSERT toolbar_button INTO TABLE e_object->mt_toolbar. ENDIF. CLEAR toolbar_button. toolbar_button-function = c_user_commands-set_internal_fcat. - IF grid-fieldcatalog_name EQ lcl_fieldcatalog_name_enum=>internal. + IF grid-fieldcatalog_name = lcl_fieldcatalog_name_enum=>internal. toolbar_button-disabled = abap_true. ENDIF. - toolbar_button-text = 'Regular fieldcatalog'(b02). + toolbar_button-text = 'Regular fieldcatalog'(b02). INSERT toolbar_button INTO TABLE e_object->mt_toolbar. CLEAR toolbar_button. toolbar_button-function = c_user_commands-set_technical_fcat. - IF grid-fieldcatalog_name EQ lcl_fieldcatalog_name_enum=>technical. + IF grid-fieldcatalog_name = lcl_fieldcatalog_name_enum=>technical. toolbar_button-disabled = abap_true. ENDIF. - toolbar_button-text = 'Technical fieldnames'(b03). + toolbar_button-text = 'Technical fieldnames'(b03). INSERT toolbar_button INTO TABLE e_object->mt_toolbar. ENDMETHOD. diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_itab.clas.testclasses.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_itab.clas.testclasses.abap index 4b998ea..f817fcb 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_itab.clas.testclasses.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_itab.clas.testclasses.abap @@ -1,13 +1,14 @@ -*"* use this source file for your ABAP unit test classes -*--------------------------------------------------------------------* -* Unit test: Serialization -*--------------------------------------------------------------------* +" * use this source file for your ABAP unit test classes +" --------------------------------------------------------------------- +" Unit test: Serialization +" --------------------------------------------------------------------- CLASS lcl_unit_tests_serialization DEFINITION DEFERRED. CLASS /usi/cl_bal_dc_itab DEFINITION LOCAL FRIENDS lcl_unit_tests_serialization. CLASS lcl_unit_tests_serialization DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. TYPES: BEGIN OF ty_input, table TYPE REF TO data, @@ -32,14 +33,14 @@ CLASS lcl_unit_tests_serialization DEFINITION FINAL FOR TESTING. METHODS test_rebuild_from_fieldcatalog FOR TESTING. METHODS get_deserialized_cut - IMPORTING - i_input_to_serialize TYPE ty_input - RETURNING - VALUE(r_result) TYPE REF TO /usi/cl_bal_dc_itab. + IMPORTING i_input_to_serialize TYPE ty_input + RETURNING VALUE(r_result) TYPE REF TO /usi/cl_bal_dc_itab. ENDCLASS. + CLASS lcl_unit_tests_serialization IMPLEMENTATION. METHOD test_rejects_invalid_xml. + " TODO: variable is assigned but never used (ABAP cleaner) DATA: cut TYPE REF TO /usi/cl_bal_dc_itab, invalid_input TYPE /usi/bal_xml_string. @@ -57,12 +58,9 @@ CLASS lcl_unit_tests_serialization IMPLEMENTATION. CREATE DATA input-table TYPE bapirettab. CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' - EXPORTING - i_structure_name = 'BAPIRET2' - CHANGING - ct_fieldcat = input-fieldcatalog - EXCEPTIONS - OTHERS = 0. + EXPORTING i_structure_name = 'BAPIRET2' + CHANGING ct_fieldcat = input-fieldcatalog + EXCEPTIONS OTHERS = 0. cut = get_deserialized_cut( input ). @@ -80,9 +78,7 @@ CLASS lcl_unit_tests_serialization IMPLEMENTATION. END OF serialized_title. CREATE DATA input-table TYPE bapirettab. - CREATE OBJECT input-title TYPE /usi/cl_bal_tc_literal_c40 - EXPORTING - i_text = 'Callstack'. + input-title = NEW /usi/cl_bal_tc_literal_c40( i_text = 'Callstack' ). cut = get_deserialized_cut( input ). @@ -211,11 +207,9 @@ CLASS lcl_unit_tests_serialization IMPLEMENTATION. FIELD-SYMBOLS TYPE ANY TABLE. ASSIGN i_input_to_serialize-table->* TO
. - CREATE OBJECT cut - EXPORTING - i_internal_table =
- i_title = i_input_to_serialize-title - i_fieldcatalog = i_input_to_serialize-fieldcatalog. + cut = NEW #( i_internal_table =
+ i_title = i_input_to_serialize-title + i_fieldcatalog = i_input_to_serialize-fieldcatalog ). TRY. serialized_data_container = cut->/usi/if_bal_data_container~serialize( ). @@ -228,35 +222,42 @@ CLASS lcl_unit_tests_serialization IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Cardinality -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Cardinality +" --------------------------------------------------------------------- CLASS lcl_unit_test_cardinality DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. METHODS assert_is_multi_use FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_cardinality IMPLEMENTATION. METHOD assert_is_multi_use. DATA actual_result TYPE abap_bool. + actual_result = /usi/cl_bal_dc_itab=>/usi/if_bal_data_container~is_multiple_use_allowed( ). cl_aunit_assert=>assert_equals( exp = abap_true act = actual_result ). ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Classname -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Classname +" --------------------------------------------------------------------- CLASS lcl_unit_test_classname DEFINITION FINAL CREATE PUBLIC FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. METHODS assert_returns_right_classname FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_classname IMPLEMENTATION. METHOD assert_returns_right_classname. DATA: cut_description TYPE REF TO /usi/cl_bal_aunit_cut_descr_cl, @@ -268,12 +269,14 @@ CLASS lcl_unit_test_classname IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Cardinality -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Cardinality +" --------------------------------------------------------------------- CLASS lcl_unit_test_table_line_types DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. METHODS test_accepts_ddic_structure FOR TESTING. METHODS test_accepts_non_ddic_struct FOR TESTING. @@ -282,16 +285,16 @@ CLASS lcl_unit_test_table_line_types DEFINITION FINAL FOR TESTING. METHODS test_rejects_table_of_orefs FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_table_line_types IMPLEMENTATION. METHOD test_accepts_ddic_structure. + " TODO: variable is assigned but never used (ABAP cleaner) DATA: cut TYPE REF TO /usi/cl_bal_dc_itab, input TYPE abap_callstack, unexpected_exception TYPE REF TO /usi/cx_bal_root. TRY. - CREATE OBJECT cut - EXPORTING - i_internal_table = input. + cut = NEW #( i_internal_table = input ). CATCH /usi/cx_bal_root INTO unexpected_exception. /usi/cl_bal_aunit_exception=>fail_on_unexpected_exception( unexpected_exception ). ENDTRY. @@ -308,9 +311,7 @@ CLASS lcl_unit_test_table_line_types IMPLEMENTATION. unexpected_exception TYPE REF TO /usi/cx_bal_root. TRY. - CREATE OBJECT cut - EXPORTING - i_internal_table = input. + cut = NEW #( i_internal_table = input ). cut->/usi/if_bal_data_container~serialize( ). CATCH /usi/cx_bal_root INTO unexpected_exception. @@ -324,15 +325,12 @@ CLASS lcl_unit_test_table_line_types IMPLEMENTATION. unexpected_exception TYPE REF TO /usi/cx_bal_root. TRY. - CREATE OBJECT cut - EXPORTING - i_internal_table = input. + cut = NEW #( i_internal_table = input ). cut->/usi/if_bal_data_container~serialize( ). CATCH /usi/cx_bal_root INTO unexpected_exception. /usi/cl_bal_aunit_exception=>fail_on_unexpected_exception( unexpected_exception ). ENDTRY. - ENDMETHOD. METHOD test_rejects_table_of_tables. @@ -340,9 +338,7 @@ CLASS lcl_unit_test_table_line_types IMPLEMENTATION. input TYPE STANDARD TABLE OF bapirettab WITH NON-UNIQUE DEFAULT KEY. TRY. - CREATE OBJECT cut - EXPORTING - i_internal_table = input. + cut = NEW #( i_internal_table = input ). cut->/usi/if_bal_data_container~serialize( ). @@ -358,9 +354,7 @@ CLASS lcl_unit_test_table_line_types IMPLEMENTATION. input TYPE STANDARD TABLE OF REF TO cl_gui_alv_grid WITH NON-UNIQUE DEFAULT KEY. TRY. - CREATE OBJECT cut - EXPORTING - i_internal_table = input. + cut = NEW #( i_internal_table = input ). cut->/usi/if_bal_data_container~serialize( ). diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_json.clas.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_json.clas.abap index 76c6ec3..6407708 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_json.clas.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_json.clas.abap @@ -8,14 +8,11 @@ CLASS /usi/cl_bal_dc_json DEFINITION PUBLIC FINAL CREATE PUBLIC. "! Constructor "! - "! @parameter i_json_document | JSON-Document as string + "! @parameter i_json_document | JSON-Document as string "! @parameter i_document_title | Optional: Document title (Useful, if multiple documents are appended) METHODS constructor - IMPORTING - i_json_document TYPE string - i_document_title TYPE REF TO /usi/if_bal_text_container_c40 OPTIONAL. - - PROTECTED SECTION. + IMPORTING i_json_document TYPE string + i_document_title TYPE REF TO /usi/if_bal_text_container_c40 OPTIONAL. PRIVATE SECTION. TYPES: ty_html_table_line TYPE c LENGTH 1000, @@ -26,27 +23,20 @@ CLASS /usi/cl_bal_dc_json DEFINITION PUBLIC FINAL CREATE PUBLIC. html_table TYPE ty_html_table. METHODS convert_json_to_html - IMPORTING - i_json_document TYPE /usi/bal_json_string - RETURNING - VALUE(r_result) TYPE /usi/bal_html_string - RAISING - /usi/cx_bal_root. + IMPORTING i_json_document TYPE /usi/bal_json_string + RETURNING VALUE(r_result) TYPE /usi/bal_html_string + RAISING /usi/cx_bal_root. METHODS get_html_table - IMPORTING - i_json_document TYPE /usi/bal_html_string - RETURNING - VALUE(r_result) TYPE ty_html_table. + IMPORTING i_json_document TYPE /usi/bal_html_string + RETURNING VALUE(r_result) TYPE ty_html_table. METHODS raise_exception_on_subrc - RAISING - /usi/cx_bal_root. + RAISING /usi/cx_bal_root. ENDCLASS. - CLASS /usi/cl_bal_dc_json IMPLEMENTATION. METHOD /usi/if_bal_data_container_rnd~render. DATA: document_size TYPE int4, @@ -55,53 +45,42 @@ CLASS /usi/cl_bal_dc_json IMPLEMENTATION. url TYPE c LENGTH 1024. CREATE OBJECT html_viewer - EXPORTING - parent = i_container - EXCEPTIONS - cntl_error = 1 - cntl_install_error = 2 - dp_install_error = 3 - dp_error = 4 - OTHERS = 5. - IF sy-subrc NE 0. + EXPORTING parent = i_container + EXCEPTIONS cntl_error = 1 + cntl_install_error = 2 + dp_install_error = 3 + dp_error = 4 + OTHERS = 5. + IF sy-subrc <> 0. raise_exception_on_subrc( ). ENDIF. html_document = convert_json_to_html( json_document ). html_table = get_html_table( html_document ). document_size = strlen( json_document ). - html_viewer->load_data( - EXPORTING - size = document_size - IMPORTING - assigned_url = url - CHANGING - data_table = html_table - EXCEPTIONS - dp_invalid_parameter = 1 - dp_error_general = 2 - cntl_error = 3 - html_syntax_notcorrect = 4 - OTHERS = 5 ). - IF sy-subrc NE 0. + html_viewer->load_data( EXPORTING size = document_size + IMPORTING assigned_url = url + CHANGING data_table = html_table + EXCEPTIONS dp_invalid_parameter = 1 + dp_error_general = 2 + cntl_error = 3 + html_syntax_notcorrect = 4 + OTHERS = 5 ). + IF sy-subrc <> 0. raise_exception_on_subrc( ). ENDIF. - html_viewer->show_url( - EXPORTING - url = url - EXCEPTIONS - cntl_error = 1 - cnht_error_not_allowed = 2 - cnht_error_parameter = 3 - dp_error_general = 4 - OTHERS = 5 ). - IF sy-subrc NE 0. + html_viewer->show_url( EXPORTING url = url + EXCEPTIONS cntl_error = 1 + cnht_error_not_allowed = 2 + cnht_error_parameter = 3 + dp_error_general = 4 + OTHERS = 5 ). + IF sy-subrc <> 0. raise_exception_on_subrc( ). ENDIF. ENDMETHOD. - METHOD /usi/if_bal_data_container~deserialize. DATA: deserializer TYPE REF TO /usi/cl_bal_serializer, document_title TYPE REF TO /usi/if_bal_text_container_c40, @@ -125,40 +104,34 @@ CLASS /usi/cl_bal_dc_json IMPLEMENTATION. GET REFERENCE OF serialized_document_title INTO parameter-value. INSERT parameter INTO TABLE parameters. - CREATE OBJECT deserializer. + deserializer = NEW #( ). deserializer->deserialize_fields( i_serialized_data = i_serialized_data_container i_parameters = parameters ). IF document_title_classname IS NOT INITIAL. TRY. CALL METHOD (document_title_classname)=>/usi/if_bal_text_container_c40~deserialize - EXPORTING - i_serialized_text_container = serialized_document_title - RECEIVING - r_result = document_title. + EXPORTING i_serialized_text_container = serialized_document_title + RECEIVING r_result = document_title. CATCH cx_sy_dyn_call_error /usi/cx_bal_root INTO exception. exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION exception IS NOT BOUND. + FIELDS exception_text + CONDITION exception IS NOT BOUND. CLEAR document_title. ENDTRY. ENDIF. - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_json - EXPORTING - i_json_document = json_document - i_document_title = document_title. + r_result = NEW /usi/cl_bal_dc_json( i_json_document = json_document + i_document_title = document_title ). ENDMETHOD. - METHOD /usi/if_bal_data_container~get_classname. r_result = '/USI/CL_BAL_DC_JSON'. ENDMETHOD. - METHOD /usi/if_bal_data_container~get_description. DATA document_title_text TYPE /usi/if_bal_text_container_c40=>ty_text. @@ -172,18 +145,14 @@ CLASS /usi/cl_bal_dc_json IMPLEMENTATION. ENDIF. ENDMETHOD. - METHOD /usi/if_bal_data_container~is_multiple_use_allowed. r_result = abap_true. ENDMETHOD. - METHOD /usi/if_bal_data_container~serialize. DATA: document_title_classname TYPE /usi/bal_text_cont_classname, serialized_document_title TYPE /usi/bal_xml_string, - parameter TYPE abap_trans_srcbind, - parameters TYPE abap_trans_srcbind_tab, - serializer TYPE REF TO /usi/cl_bal_serializer. + parameters TYPE abap_trans_srcbind_tab. " Assert document is valid convert_json_to_html( json_document ). @@ -193,43 +162,33 @@ CLASS /usi/cl_bal_dc_json IMPLEMENTATION. serialized_document_title = document_title->serialize( ). ENDIF. - parameter-name = `JSON_DOCUMENT`. - GET REFERENCE OF json_document INTO parameter-value. - INSERT parameter INTO TABLE parameters. - - parameter-name = `DOCUMENT_TITLE_CLASSNAME`. - GET REFERENCE OF document_title_classname INTO parameter-value. - INSERT parameter INTO TABLE parameters. - - parameter-name = `SERIALIZED_DOCUMENT_TITLE`. - GET REFERENCE OF serialized_document_title INTO parameter-value. - INSERT parameter INTO TABLE parameters. + parameters = VALUE #( ( name = `JSON_DOCUMENT` + value = REF #( json_document ) ) + ( name = `DOCUMENT_TITLE_CLASSNAME` + value = REF #( document_title_classname ) ) + ( name = `SERIALIZED_DOCUMENT_TITLE` + value = REF #( serialized_document_title ) ) ). - CREATE OBJECT serializer. - r_result = serializer->serialize_fields_as_json( parameters ). + r_result = NEW /usi/cl_bal_serializer( )->serialize_fields_as_json( parameters ). ENDMETHOD. - METHOD constructor. json_document = i_json_document. document_title = i_document_title. ENDMETHOD. - METHOD convert_json_to_html. TRY. CALL TRANSFORMATION sjson2html - SOURCE XML i_json_document - RESULT XML r_result. + SOURCE XML i_json_document + RESULT XML r_result. CATCH cx_transformation_error INTO DATA(exception). RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>/usi/cx_bal_invalid_input - previous = exception. + EXPORTING textid = /usi/cx_bal_invalid_input=>/usi/cx_bal_invalid_input + previous = exception. ENDTRY. ENDMETHOD. - METHOD get_html_table. DATA: html_string TYPE string, result_line TYPE ty_html_table_line, @@ -245,23 +204,17 @@ CLASS /usi/cl_bal_dc_json IMPLEMENTATION. ENDWHILE. ENDMETHOD. - METHOD raise_exception_on_subrc. - DATA textid TYPE scx_t100key. - - textid-msgid = sy-msgid. - textid-msgno = sy-msgno. - textid-attr1 = 'PARAM1'. - textid-attr2 = 'PARAM2'. - textid-attr3 = 'PARAM3'. - textid-attr4 = 'PARAM4'. - RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = textid - param1 = sy-msgv1 - param2 = sy-msgv2 - param3 = sy-msgv3 - param4 = sy-msgv4. + EXPORTING textid = VALUE #( msgid = sy-msgid + msgno = sy-msgno + attr1 = 'PARAM1' + attr2 = 'PARAM2' + attr3 = 'PARAM3' + attr4 = 'PARAM4' ) + param1 = sy-msgv1 + param2 = sy-msgv2 + param3 = sy-msgv3 + param4 = sy-msgv4. ENDMETHOD. ENDCLASS. diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_json.clas.testclasses.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_json.clas.testclasses.abap index e45403d..25400e3 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_json.clas.testclasses.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_json.clas.testclasses.abap @@ -1,21 +1,24 @@ *"* use this source file for your ABAP unit test classes -*--------------------------------------------------------------------* -* Unit test: Serialization -*--------------------------------------------------------------------* +" --------------------------------------------------------------------- +" Unit test: Serialization +" --------------------------------------------------------------------- CLASS lcl_unit_tests_serialization DEFINITION DEFERRED. CLASS /usi/cl_bal_dc_json DEFINITION LOCAL FRIENDS lcl_unit_tests_serialization. CLASS lcl_unit_tests_serialization DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. METHODS test_deserialize_bad_xml FOR TESTING. METHODS test_deserialize_valid_xml FOR TESTING. ENDCLASS. + CLASS lcl_unit_tests_serialization IMPLEMENTATION. METHOD test_deserialize_bad_xml. + " TODO: variable is assigned but never used (ABAP cleaner) DATA cut TYPE REF TO /usi/cl_bal_dc_json. TRY. @@ -38,14 +41,10 @@ CLASS lcl_unit_tests_serialization IMPLEMENTATION. " serialize document = `

test document

`. - CREATE OBJECT title TYPE /usi/cl_bal_tc_literal_c40 - EXPORTING - i_text = 'Test document title'. + title = NEW /usi/cl_bal_tc_literal_c40( i_text = 'Test document title' ). - CREATE OBJECT cut - EXPORTING - i_json_document = document - i_document_title = title. + cut = NEW #( i_json_document = document + i_document_title = title ). TRY. serialized_data_container = cut->/usi/if_bal_data_container~serialize( ). CATCH /usi/cx_bal_root INTO unexpected_exception. @@ -71,16 +70,19 @@ CLASS lcl_unit_tests_serialization IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Cardinality -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Cardinality +" --------------------------------------------------------------------- CLASS lcl_unit_test_cardinality DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. METHODS assert_is_multi_use FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_cardinality IMPLEMENTATION. METHOD assert_is_multi_use. DATA actual_result TYPE abap_bool. @@ -91,16 +93,19 @@ CLASS lcl_unit_test_cardinality IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Classname -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Classname +" --------------------------------------------------------------------- CLASS lcl_unit_test_classname DEFINITION FINAL CREATE PUBLIC FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. METHODS assert_returns_right_classname FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_classname IMPLEMENTATION. METHOD assert_returns_right_classname. DATA: cut_description TYPE REF TO /usi/cl_bal_aunit_cut_descr_cl, diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_retcode_and_msg.clas.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_retcode_and_msg.clas.abap index f763eca..7fdfae9 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_retcode_and_msg.clas.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_retcode_and_msg.clas.abap @@ -9,17 +9,14 @@ CLASS /usi/cl_bal_dc_retcode_and_msg DEFINITION PUBLIC FINAL CREATE PUBLIC. "! Constructor "! - "! @parameter i_message | The Message + "! @parameter i_message | The Message "! @parameter i_return_code | The return code METHODS constructor - IMPORTING - i_message TYPE symsg - VALUE(i_return_code) TYPE sysubrc. - - PROTECTED SECTION. + IMPORTING i_message TYPE symsg + VALUE(i_return_code) TYPE sysubrc. PRIVATE SECTION. - TYPES ty_alv_output TYPE STANDARD TABLE OF /usi/bal_fieldname_and_value WITH NON-UNIQUE DEFAULT KEY. + TYPES ty_alv_output TYPE STANDARD TABLE OF /usi/bal_fieldname_and_value WITH EMPTY KEY. DATA: BEGIN OF alv_data, fieldcat TYPE lvc_t_fcat, @@ -29,113 +26,75 @@ CLASS /usi/cl_bal_dc_retcode_and_msg DEFINITION PUBLIC FINAL CREATE PUBLIC. return_code TYPE sysubrc. METHODS get_alv_output_table - RETURNING - VALUE(r_result) TYPE ty_alv_output. + RETURNING VALUE(r_result) TYPE ty_alv_output. ENDCLASS. - CLASS /usi/cl_bal_dc_retcode_and_msg IMPLEMENTATION. METHOD /usi/if_bal_data_container_rnd~render. - DATA: alv_grid TYPE REF TO cl_gui_alv_grid, - excluded_functions TYPE ui_functions, - layout TYPE lvc_s_layo. - - INSERT cl_gui_alv_grid=>mc_fc_excl_all INTO TABLE excluded_functions. - - layout-zebra = abap_true. - layout-cwidth_opt = abap_true. - CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' - EXPORTING - i_structure_name = '/USI/BAL_FIELDNAME_AND_VALUE' - CHANGING - ct_fieldcat = alv_data-fieldcat - EXCEPTIONS - OTHERS = 0. + EXPORTING i_structure_name = '/USI/BAL_FIELDNAME_AND_VALUE' + CHANGING ct_fieldcat = alv_data-fieldcat + EXCEPTIONS OTHERS = 0. alv_data-output = get_alv_output_table( ). - CREATE OBJECT alv_grid - EXPORTING - i_parent = i_container. + DATA(alv_grid) = NEW cl_gui_alv_grid( i_parent = i_container ). alv_grid->set_table_for_first_display( - EXPORTING - is_layout = layout - it_toolbar_excluding = excluded_functions - CHANGING - it_outtab = alv_data-output - it_fieldcatalog = alv_data-fieldcat ). + EXPORTING is_layout = VALUE #( zebra = abap_true + cwidth_opt = abap_true ) + it_toolbar_excluding = VALUE #( ( cl_gui_alv_grid=>mc_fc_excl_all ) ) + CHANGING it_outtab = alv_data-output + it_fieldcatalog = alv_data-fieldcat ). ENDMETHOD. - METHOD /usi/if_bal_data_container~deserialize. - DATA: parameter TYPE abap_trans_resbind, - parameters TYPE abap_trans_resbind_tab, - deserializer TYPE REF TO /usi/cl_bal_serializer, - message TYPE symsg, - return_code TYPE sysubrc. - - parameter-name = 'MESSAGE'. - GET REFERENCE OF message INTO parameter-value. - INSERT parameter INTO TABLE parameters. - - parameter-name = 'RETURN_CODE'. - GET REFERENCE OF return_code INTO parameter-value. - INSERT parameter INTO TABLE parameters. - - CREATE OBJECT deserializer. - deserializer->deserialize_fields( i_serialized_data = i_serialized_data_container - i_parameters = parameters ). - - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_retcode_and_msg - EXPORTING - i_message = message - i_return_code = return_code. - ENDMETHOD. + DATA: parameters TYPE abap_trans_resbind_tab, + message TYPE symsg, + return_code TYPE sysubrc. + parameters = VALUE #( ( name = 'MESSAGE' + value = REF #( message ) ) + ( name = 'RETURN_CODE' + value = REF #( return_code ) ) ). + + NEW /usi/cl_bal_serializer( )->deserialize_fields( i_serialized_data = i_serialized_data_container + i_parameters = parameters ). + + r_result = NEW /usi/cl_bal_dc_retcode_and_msg( i_message = message + i_return_code = return_code ). + ENDMETHOD. METHOD /usi/if_bal_data_container~get_classname. r_result = '/USI/CL_BAL_DC_RETCODE_AND_MSG'. ENDMETHOD. - METHOD /usi/if_bal_data_container~get_description. r_result = TEXT-des. ENDMETHOD. - METHOD /usi/if_bal_data_container~is_multiple_use_allowed. r_result = abap_false. ENDMETHOD. - METHOD /usi/if_bal_data_container~serialize. - DATA: parameter TYPE abap_trans_srcbind, - parameters TYPE abap_trans_srcbind_tab, - serializer TYPE REF TO /usi/cl_bal_serializer. - - parameter-name = 'MESSAGE'. - GET REFERENCE OF message INTO parameter-value. - INSERT parameter INTO TABLE parameters. + DATA parameters TYPE abap_trans_srcbind_tab. - parameter-name = 'RETURN_CODE'. - GET REFERENCE OF return_code INTO parameter-value. - INSERT parameter INTO TABLE parameters. + parameters = VALUE #( ( name = 'MESSAGE' + value = REF #( message ) ) + ( name = 'RETURN_CODE' + value = REF #( return_code ) ) ). - CREATE OBJECT serializer. - r_result = serializer->serialize_fields_as_json( parameters ). + r_result = NEW /usi/cl_bal_serializer( )->serialize_fields_as_json( parameters ). ENDMETHOD. - METHOD constructor. message = i_message. return_code = i_return_code. ENDMETHOD. - METHOD get_alv_output_table. DATA result_line TYPE /usi/bal_fieldname_and_value. @@ -174,8 +133,8 @@ CLASS /usi/cl_bal_dc_retcode_and_msg IMPLEMENTATION. IF message-msgid IS NOT INITIAL. result_line-fieldname = 'MESSAGE'. MESSAGE ID message-msgid TYPE 'S' NUMBER message-msgno - WITH message-msgv1 message-msgv2 message-msgv3 message-msgv4 - INTO result_line-value. + WITH message-msgv1 message-msgv2 message-msgv3 message-msgv4 + INTO result_line-value. INSERT result_line INTO TABLE r_result. ENDIF. ENDMETHOD. diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_retcode_and_msg.clas.testclasses.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_retcode_and_msg.clas.testclasses.abap index 890e316..145e0eb 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_retcode_and_msg.clas.testclasses.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_retcode_and_msg.clas.testclasses.abap @@ -35,16 +35,14 @@ CLASS lcl_unit_tests_serialization IMPLEMENTATION. serialized_data_container TYPE /usi/bal_xml_string, unexpected_exception TYPE REF TO /usi/cx_bal_root. - input-return_code = 4. - input-message-msgty = 'E'. - input-message-msgid = '38'. - input-message-msgno = '000'. - input-message-msgv1 = 'Just a test'. + input = VALUE #( return_code = 4 + message = VALUE #( msgty = 'E' + msgid = '38' + msgno = '000' + msgv1 = 'Just a test' ) ). - CREATE OBJECT cut - EXPORTING - i_message = input-message - i_return_code = input-return_code. + cut = NEW #( i_message = input-message + i_return_code = input-return_code ). TRY. serialized_data_container = cut->/usi/if_bal_data_container~serialize( ). CATCH /usi/cx_bal_root INTO unexpected_exception. diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_src_pos_caller.clas.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_src_pos_caller.clas.abap index 6099a9b..a780f10 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_src_pos_caller.clas.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_src_pos_caller.clas.abap @@ -11,10 +11,7 @@ CLASS /usi/cl_bal_dc_src_pos_caller DEFINITION PUBLIC FINAL CREATE PUBLIC. "! "! @parameter i_source_code_position | The to-be-logged Source-Code-Position of the caller METHODS constructor - IMPORTING - i_source_code_position TYPE /usi/bal_source_code_position. - - PROTECTED SECTION. + IMPORTING i_source_code_position TYPE /usi/bal_source_code_position. PRIVATE SECTION. DATA source_code_position TYPE /usi/bal_source_code_position. @@ -22,63 +19,44 @@ CLASS /usi/cl_bal_dc_src_pos_caller DEFINITION PUBLIC FINAL CREATE PUBLIC. ENDCLASS. - CLASS /usi/cl_bal_dc_src_pos_caller IMPLEMENTATION. METHOD /usi/if_bal_data_container_nav~navigate. CALL FUNCTION 'RS_TOOL_ACCESS' - EXPORTING - operation = 'SHOW' - object_type = 'PROG' - object_name = source_code_position-program_name - include = source_code_position-include_name - position = source_code_position-source_line - EXCEPTIONS - OTHERS = 0. + EXPORTING operation = 'SHOW' + object_type = 'PROG' + object_name = source_code_position-program_name + include = source_code_position-include_name + position = source_code_position-source_line + EXCEPTIONS OTHERS = 0. ENDMETHOD. - METHOD /usi/if_bal_data_container~deserialize. - DATA: deserializer TYPE REF TO /usi/cl_bal_serializer, - source_code_position TYPE /usi/bal_source_code_position. + DATA source_code_position TYPE /usi/bal_source_code_position. - CREATE OBJECT deserializer. - deserializer->deserialize_field( - EXPORTING - i_serialized_data = i_serialized_data_container - i_name = 'SOURCE_CODE_POSITION' - CHANGING - c_data = source_code_position ). + NEW /usi/cl_bal_serializer( )->deserialize_field( EXPORTING i_serialized_data = i_serialized_data_container + i_name = 'SOURCE_CODE_POSITION' + CHANGING c_data = source_code_position ). - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_src_pos_caller - EXPORTING - i_source_code_position = source_code_position. + r_result = NEW /usi/cl_bal_dc_src_pos_caller( i_source_code_position = source_code_position ). ENDMETHOD. - METHOD /usi/if_bal_data_container~get_classname. r_result = '/USI/CL_BAL_DC_SRC_POS_CALLER'. ENDMETHOD. - METHOD /usi/if_bal_data_container~get_description. r_result = TEXT-des. ENDMETHOD. - METHOD /usi/if_bal_data_container~is_multiple_use_allowed. r_result = abap_false. ENDMETHOD. - METHOD /usi/if_bal_data_container~serialize. - DATA serializer TYPE REF TO /usi/cl_bal_serializer. - - CREATE OBJECT serializer. - r_result = serializer->serialize_field_as_json( i_data = source_code_position - i_name = 'SOURCE_CODE_POSITION' ). + r_result = NEW /usi/cl_bal_serializer( )->serialize_field_as_json( i_data = source_code_position + i_name = 'SOURCE_CODE_POSITION' ). ENDMETHOD. - METHOD constructor. source_code_position = i_source_code_position. ENDMETHOD. diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_src_pos_caller.clas.testclasses.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_src_pos_caller.clas.testclasses.abap index 0772a15..feda6e5 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_src_pos_caller.clas.testclasses.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_src_pos_caller.clas.testclasses.abap @@ -37,9 +37,7 @@ CLASS lcl_unit_tests_serialization IMPLEMENTATION. input-include_name = 'BAR'. input-source_line = 42. - CREATE OBJECT cut - EXPORTING - i_source_code_position = input. + cut = NEW #( i_source_code_position = input ). TRY. serialized_data_container = cut->/usi/if_bal_data_container~serialize( ). diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_src_pos_cx.clas.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_src_pos_cx.clas.abap index 0625617..febbaae 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_src_pos_cx.clas.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_src_pos_cx.clas.abap @@ -11,10 +11,7 @@ CLASS /usi/cl_bal_dc_src_pos_cx DEFINITION PUBLIC FINAL CREATE PUBLIC. "! "! @parameter i_source_code_position | The to-be-logged Source-Code-Position of the exception METHODS constructor - IMPORTING - i_source_code_position TYPE /usi/bal_source_code_position. - - PROTECTED SECTION. + IMPORTING i_source_code_position TYPE /usi/bal_source_code_position. PRIVATE SECTION. DATA source_code_position TYPE /usi/bal_source_code_position. @@ -22,63 +19,44 @@ CLASS /usi/cl_bal_dc_src_pos_cx DEFINITION PUBLIC FINAL CREATE PUBLIC. ENDCLASS. - CLASS /usi/cl_bal_dc_src_pos_cx IMPLEMENTATION. METHOD /usi/if_bal_data_container_nav~navigate. CALL FUNCTION 'RS_TOOL_ACCESS' - EXPORTING - operation = 'SHOW' - object_type = 'PROG' - object_name = source_code_position-program_name - include = source_code_position-include_name - position = source_code_position-source_line - EXCEPTIONS - OTHERS = 0. + EXPORTING operation = 'SHOW' + object_type = 'PROG' + object_name = source_code_position-program_name + include = source_code_position-include_name + position = source_code_position-source_line + EXCEPTIONS OTHERS = 0. ENDMETHOD. - METHOD /usi/if_bal_data_container~deserialize. - DATA: deserializer TYPE REF TO /usi/cl_bal_serializer, - source_code_position TYPE /usi/bal_source_code_position. + DATA source_code_position TYPE /usi/bal_source_code_position. - CREATE OBJECT deserializer. - deserializer->deserialize_field( - EXPORTING - i_serialized_data = i_serialized_data_container - i_name = 'SOURCE_CODE_POSITION' - CHANGING - c_data = source_code_position ). + NEW /usi/cl_bal_serializer( )->deserialize_field( EXPORTING i_serialized_data = i_serialized_data_container + i_name = 'SOURCE_CODE_POSITION' + CHANGING c_data = source_code_position ). - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_src_pos_cx - EXPORTING - i_source_code_position = source_code_position. + r_result = NEW /usi/cl_bal_dc_src_pos_cx( i_source_code_position = source_code_position ). ENDMETHOD. - METHOD /usi/if_bal_data_container~get_classname. r_result = '/USI/CL_BAL_DC_SRC_POS_CX'. ENDMETHOD. - METHOD /usi/if_bal_data_container~get_description. r_result = TEXT-des. ENDMETHOD. - METHOD /usi/if_bal_data_container~is_multiple_use_allowed. r_result = abap_false. ENDMETHOD. - METHOD /usi/if_bal_data_container~serialize. - DATA serializer TYPE REF TO /usi/cl_bal_serializer. - - CREATE OBJECT serializer. - r_result = serializer->serialize_field_as_json( i_data = source_code_position - i_name = 'SOURCE_CODE_POSITION' ). + r_result = NEW /usi/cl_bal_serializer( )->serialize_field_as_json( i_data = source_code_position + i_name = 'SOURCE_CODE_POSITION' ). ENDMETHOD. - METHOD constructor. source_code_position = i_source_code_position. ENDMETHOD. diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_src_pos_cx.clas.testclasses.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_src_pos_cx.clas.testclasses.abap index b9ef10f..d41f088 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_src_pos_cx.clas.testclasses.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_src_pos_cx.clas.testclasses.abap @@ -1,21 +1,24 @@ *"* use this source file for your ABAP unit test classes -*--------------------------------------------------------------------* -* Unit test: Serialization -*--------------------------------------------------------------------* +" --------------------------------------------------------------------- +" Unit test: Serialization +" --------------------------------------------------------------------- CLASS lcl_unit_tests_serialization DEFINITION DEFERRED. CLASS /usi/cl_bal_dc_src_pos_cx DEFINITION LOCAL FRIENDS lcl_unit_tests_serialization. CLASS lcl_unit_tests_serialization DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. METHODS test_deserialize_bad_xml FOR TESTING. METHODS test_deserialize_valid_xml FOR TESTING. ENDCLASS. + CLASS lcl_unit_tests_serialization IMPLEMENTATION. METHOD test_deserialize_bad_xml. + " TODO: variable is assigned but never used (ABAP cleaner) DATA cut TYPE REF TO /usi/cl_bal_dc_src_pos_cx. TRY. @@ -37,9 +40,7 @@ CLASS lcl_unit_tests_serialization IMPLEMENTATION. input-include_name = 'BAR'. input-source_line = 42. - CREATE OBJECT cut - EXPORTING - i_source_code_position = input. + cut = NEW #( i_source_code_position = input ). TRY. serialized_data_container = cut->/usi/if_bal_data_container~serialize( ). @@ -61,16 +62,19 @@ CLASS lcl_unit_tests_serialization IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Cardinality -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Cardinality +" --------------------------------------------------------------------- CLASS lcl_unit_test_cardinality DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. METHODS assert_is_single_use FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_cardinality IMPLEMENTATION. METHOD assert_is_single_use. DATA actual_result TYPE abap_bool. @@ -81,16 +85,19 @@ CLASS lcl_unit_test_cardinality IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Classname -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Classname +" --------------------------------------------------------------------- CLASS lcl_unit_test_classname DEFINITION FINAL CREATE PUBLIC FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. METHODS assert_returns_right_classname FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_classname IMPLEMENTATION. METHOD assert_returns_right_classname. DATA: cut_description TYPE REF TO /usi/cl_bal_aunit_cut_descr_cl, diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_structure.clas.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_structure.clas.abap index c2cf611..bef056b 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_structure.clas.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_structure.clas.abap @@ -11,7 +11,7 @@ CLASS /usi/cl_bal_dc_structure DEFINITION PUBLIC FINAL CREATE PUBLIC. i_title TYPE REF TO /usi/if_bal_text_container_c40 OPTIONAL. PRIVATE SECTION. - TYPES ty_alv_output TYPE STANDARD TABLE OF /usi/bal_fieldname_and_value WITH NON-UNIQUE DEFAULT KEY. + TYPES ty_alv_output TYPE STANDARD TABLE OF /usi/bal_fieldname_and_value WITH EMPTY KEY. CONSTANTS: BEGIN OF c_parameter_names, title_classname TYPE fieldname VALUE 'TITLE_CLASSNAME', diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_structure.clas.testclasses.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_structure.clas.testclasses.abap index 7bdfa84..7e2c3ff 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_structure.clas.testclasses.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_structure.clas.testclasses.abap @@ -5,7 +5,7 @@ CLASS /usi/cl_bal_dc_structure DEFINITION LOCAL FRIENDS lcl_private_attribute_re CLASS lcl_private_attribute_reader DEFINITION. PUBLIC SECTION. - TYPES ty_alv_output TYPE STANDARD TABLE OF /usi/bal_fieldname_and_value WITH NON-UNIQUE DEFAULT KEY. + TYPES ty_alv_output TYPE STANDARD TABLE OF /usi/bal_fieldname_and_value WITH EMPTY KEY. CLASS-METHODS get_alv_output IMPORTING i_cut TYPE REF TO /usi/cl_bal_dc_structure diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_xml.clas.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_xml.clas.abap index bd9e080..d176903 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_xml.clas.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_xml.clas.abap @@ -9,34 +9,27 @@ CLASS /usi/cl_bal_dc_xml DEFINITION PUBLIC FINAL CREATE PUBLIC. "! @parameter i_xml_document | XML-Document as string "! @parameter i_document_title | Optional: Document title (Useful, if multiple documents are appended) METHODS constructor - IMPORTING - i_xml_document TYPE string - i_document_title TYPE REF TO /usi/if_bal_text_container_c40 OPTIONAL. - - PROTECTED SECTION. + IMPORTING i_xml_document TYPE string + i_document_title TYPE REF TO /usi/if_bal_text_container_c40 OPTIONAL. PRIVATE SECTION. TYPES: ty_xml_table_line TYPE c LENGTH 1000, - ty_xml_table TYPE STANDARD TABLE OF ty_xml_table_line WITH NON-UNIQUE DEFAULT KEY. + ty_xml_table TYPE STANDARD TABLE OF ty_xml_table_line WITH EMPTY KEY. DATA: xml_document TYPE string, document_title TYPE REF TO /usi/if_bal_text_container_c40, xml_table TYPE ty_xml_table. METHODS get_xml_table - IMPORTING - i_xml_document TYPE string - RETURNING - VALUE(r_result) TYPE ty_xml_table. + IMPORTING i_xml_document TYPE string + RETURNING VALUE(r_result) TYPE ty_xml_table. METHODS raise_exception_on_subrc - RAISING - /usi/cx_bal_root. + RAISING /usi/cx_bal_root. ENDCLASS. - CLASS /usi/cl_bal_dc_xml IMPLEMENTATION. METHOD /usi/if_bal_data_container~deserialize. DATA: deserializer TYPE REF TO /usi/cl_bal_serializer, @@ -61,32 +54,28 @@ CLASS /usi/cl_bal_dc_xml IMPLEMENTATION. GET REFERENCE OF serialized_document_title INTO parameter-value. INSERT parameter INTO TABLE parameters. - CREATE OBJECT deserializer. + deserializer = NEW #( ). deserializer->deserialize_fields( i_serialized_data = i_serialized_data_container i_parameters = parameters ). IF document_title_classname IS NOT INITIAL. TRY. CALL METHOD (document_title_classname)=>/usi/if_bal_text_container_c40~deserialize - EXPORTING - i_serialized_text_container = serialized_document_title - RECEIVING - r_result = document_title. + EXPORTING i_serialized_text_container = serialized_document_title + RECEIVING r_result = document_title. CATCH cx_sy_dyn_call_error /usi/cx_bal_root INTO exception. exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION exception IS NOT BOUND. + FIELDS exception_text + CONDITION exception IS NOT BOUND. CLEAR document_title. ENDTRY. ENDIF. - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_xml - EXPORTING - i_xml_document = xml_document - i_document_title = document_title. + r_result = NEW /usi/cl_bal_dc_xml( i_xml_document = xml_document + i_document_title = document_title ). ENDMETHOD. METHOD constructor. @@ -118,7 +107,7 @@ CLASS /usi/cl_bal_dc_xml IMPLEMENTATION. GET REFERENCE OF serialized_document_title INTO parameter-value. INSERT parameter INTO TABLE parameters. - CREATE OBJECT serializer. + serializer = NEW #( ). r_result = serializer->serialize_fields_as_json( parameters ). ENDMETHOD. @@ -149,48 +138,38 @@ CLASS /usi/cl_bal_dc_xml IMPLEMENTATION. url TYPE c LENGTH 1024. CREATE OBJECT xml_viewer - EXPORTING - parent = i_container - EXCEPTIONS - cntl_error = 1 - cntl_install_error = 2 - dp_install_error = 3 - dp_error = 4 - OTHERS = 5. - IF sy-subrc NE 0. + EXPORTING parent = i_container + EXCEPTIONS cntl_error = 1 + cntl_install_error = 2 + dp_install_error = 3 + dp_error = 4 + OTHERS = 5. + IF sy-subrc <> 0. raise_exception_on_subrc( ). ENDIF. xml_table = get_xml_table( xml_document ). document_size = strlen( xml_document ). - xml_viewer->load_data( - EXPORTING - subtype = 'xml' - size = document_size - IMPORTING - assigned_url = url - CHANGING - data_table = xml_table - EXCEPTIONS - dp_invalid_parameter = 1 - dp_error_general = 2 - cntl_error = 3 - html_syntax_notcorrect = 4 - OTHERS = 5 ). - IF sy-subrc NE 0. + xml_viewer->load_data( EXPORTING subtype = 'xml' + size = document_size + IMPORTING assigned_url = url + CHANGING data_table = xml_table + EXCEPTIONS dp_invalid_parameter = 1 + dp_error_general = 2 + cntl_error = 3 + html_syntax_notcorrect = 4 + OTHERS = 5 ). + IF sy-subrc <> 0. raise_exception_on_subrc( ). ENDIF. - xml_viewer->show_url( - EXPORTING - url = url - EXCEPTIONS - cntl_error = 1 - cnht_error_not_allowed = 2 - cnht_error_parameter = 3 - dp_error_general = 4 - OTHERS = 5 ). - IF sy-subrc NE 0. + xml_viewer->show_url( EXPORTING url = url + EXCEPTIONS cntl_error = 1 + cnht_error_not_allowed = 2 + cnht_error_parameter = 3 + dp_error_general = 4 + OTHERS = 5 ). + IF sy-subrc <> 0. raise_exception_on_subrc( ). ENDIF. ENDMETHOD. @@ -211,21 +190,16 @@ CLASS /usi/cl_bal_dc_xml IMPLEMENTATION. ENDMETHOD. METHOD raise_exception_on_subrc. - DATA textid TYPE scx_t100key. - - textid-msgid = sy-msgid. - textid-msgno = sy-msgno. - textid-attr1 = 'PARAM1'. - textid-attr2 = 'PARAM2'. - textid-attr3 = 'PARAM3'. - textid-attr4 = 'PARAM4'. - RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = textid - param1 = sy-msgv1 - param2 = sy-msgv2 - param3 = sy-msgv3 - param4 = sy-msgv4. + EXPORTING textid = VALUE #( msgid = sy-msgid + msgno = sy-msgno + attr1 = 'PARAM1' + attr2 = 'PARAM2' + attr3 = 'PARAM3' + attr4 = 'PARAM4' ) + param1 = sy-msgv1 + param2 = sy-msgv2 + param3 = sy-msgv3 + param4 = sy-msgv4. ENDMETHOD. ENDCLASS. diff --git a/src/#usi#bal_data_containers/#usi#cl_bal_dc_xml.clas.testclasses.abap b/src/#usi#bal_data_containers/#usi#cl_bal_dc_xml.clas.testclasses.abap index 4feaaea..8b079f7 100644 --- a/src/#usi#bal_data_containers/#usi#cl_bal_dc_xml.clas.testclasses.abap +++ b/src/#usi#bal_data_containers/#usi#cl_bal_dc_xml.clas.testclasses.abap @@ -39,14 +39,10 @@ CLASS lcl_unit_tests_serialization IMPLEMENTATION. " serialize document = `

test document

`. - CREATE OBJECT title TYPE /usi/cl_bal_tc_literal_c40 - EXPORTING - i_text = 'Test document title'. - - CREATE OBJECT cut - EXPORTING - i_xml_document = document - i_document_title = title. + title = NEW /usi/cl_bal_tc_literal_c40( i_text = 'Test document title' ). + + cut = NEW #( i_xml_document = document + i_document_title = title ). TRY. serialized_data_container = cut->/usi/if_bal_data_container~serialize( ). CATCH /usi/cx_bal_root INTO unexpected_exception. diff --git a/src/#usi#bal_delete/#usi#bal_delete.fugr.#usi#bal_delete_custom_data.abap b/src/#usi#bal_delete/#usi#bal_delete.fugr.#usi#bal_delete_custom_data.abap index 96a0ef8..ba3400e 100644 --- a/src/#usi#bal_delete/#usi#bal_delete.fugr.#usi#bal_delete_custom_data.abap +++ b/src/#usi#bal_delete/#usi#bal_delete.fugr.#usi#bal_delete_custom_data.abap @@ -21,11 +21,11 @@ FUNCTION /usi/bal_delete_custom_data. LOOP AT i_log_headers ASSIGNING . READ TABLE log_header_groups - WITH TABLE KEY object = -object - subobject = -subobject - REFERENCE INTO log_header_group. + WITH TABLE KEY object = -object + subobject = -subobject + REFERENCE INTO log_header_group. - IF sy-subrc NE 0. + IF sy-subrc <> 0. CREATE DATA log_header_group. log_header_group->object = -object. log_header_group->subobject = -subobject. @@ -37,13 +37,11 @@ FUNCTION /usi/bal_delete_custom_data. LOOP AT log_header_groups REFERENCE INTO log_header_group. GET BADI badi - FILTERS - object = log_header_group->object - subobject = log_header_group->subobject. + FILTERS + object = log_header_group->object + subobject = log_header_group->subobject. CALL BADI badi->delete_custom_data - EXPORTING - i_log_headers = log_header_group->log_headers. + EXPORTING i_log_headers = log_header_group->log_headers. ENDLOOP. - ENDFUNCTION. diff --git a/src/#usi#bal_delete/#usi#cl_bal_delete_custom_data.clas.abap b/src/#usi#bal_delete/#usi#cl_bal_delete_custom_data.clas.abap index 680505c..fe2f4c0 100644 --- a/src/#usi#bal_delete/#usi#cl_bal_delete_custom_data.clas.abap +++ b/src/#usi#bal_delete/#usi#cl_bal_delete_custom_data.clas.abap @@ -15,18 +15,14 @@ ENDCLASS. CLASS /usi/cl_bal_delete_custom_data IMPLEMENTATION. METHOD /usi/if_bal_delete_custom_data~delete_custom_data. - DATA: dao_factory TYPE REF TO /usi/if_bal_logger_dao_factory, - dao_object TYPE REF TO /usi/if_bal_data_cont_coll_dao, - log_numbers TYPE bal_t_logn. + DATA log_numbers TYPE bal_t_logn. - FIELD-SYMBOLS TYPE balhdr. - - LOOP AT i_log_headers ASSIGNING . + LOOP AT i_log_headers ASSIGNING FIELD-SYMBOL(). INSERT -lognumber INTO TABLE log_numbers. ENDLOOP. - dao_factory = /usi/cl_bal_logger_dao_factory=>get_instance( ). - dao_object = dao_factory->get_data_container_collection( ). + DATA(dao_factory) = /usi/cl_bal_logger_dao_factory=>get_instance( ). + DATA(dao_object) = dao_factory->get_data_container_collection( ). dao_object->delete_collections( log_numbers ). ENDMETHOD. ENDCLASS. diff --git a/src/#usi#bal_demo/#usi#bal_demo_02/#usi#bal_demo_02_d02.prog.abap b/src/#usi#bal_demo/#usi#bal_demo_02/#usi#bal_demo_02_d02.prog.abap index 5500ec2..12ed129 100644 --- a/src/#usi#bal_demo/#usi#bal_demo_02/#usi#bal_demo_02_d02.prog.abap +++ b/src/#usi#bal_demo/#usi#bal_demo_02/#usi#bal_demo_02_d02.prog.abap @@ -3,8 +3,8 @@ *&---------------------------------------------------------------------* CLASS lcl_task_grid DEFINITION FINAL CREATE PUBLIC. PUBLIC SECTION. - TYPES: ty_selected_task_ids TYPE STANDARD TABLE OF /usi/bal_demo_to_do_task_id WITH NON-UNIQUE DEFAULT KEY, - ty_unsorted_tasks TYPE STANDARD TABLE OF /usi/bal_demo_to_do_task WITH NON-UNIQUE DEFAULT KEY. + TYPES: ty_selected_task_ids TYPE STANDARD TABLE OF /usi/bal_demo_to_do_task_id WITH EMPTY KEY, + ty_unsorted_tasks TYPE STANDARD TABLE OF /usi/bal_demo_to_do_task WITH EMPTY KEY. CONSTANTS: BEGIN OF user_commands, refresh TYPE ui_func VALUE 'REFRESH', @@ -18,12 +18,10 @@ CLASS lcl_task_grid DEFINITION FINAL CREATE PUBLIC. METHODS constructor. METHODS refresh_alv_grid - IMPORTING - i_tasks TYPE ty_unsorted_tasks. + IMPORTING i_tasks TYPE ty_unsorted_tasks. METHODS get_selected_task_ids - RETURNING - VALUE(r_result) TYPE ty_selected_task_ids. + RETURNING VALUE(r_result) TYPE ty_selected_task_ids. PRIVATE SECTION. DATA: custom_container TYPE REF TO cl_gui_custom_container, diff --git a/src/#usi#bal_demo/#usi#bal_demo_02/#usi#bal_demo_02_p01.prog.abap b/src/#usi#bal_demo/#usi#bal_demo_02/#usi#bal_demo_02_p01.prog.abap index 1f30d13..0f3d09f 100644 --- a/src/#usi#bal_demo/#usi#bal_demo_02/#usi#bal_demo_02_p01.prog.abap +++ b/src/#usi#bal_demo/#usi#bal_demo_02/#usi#bal_demo_02_p01.prog.abap @@ -3,7 +3,7 @@ *&---------------------------------------------------------------------* CLASS lcl_popup_maintain_task IMPLEMENTATION. METHOD class_constructor. - CREATE OBJECT singleton. + singleton = NEW #( ). ENDMETHOD. METHOD display. @@ -26,7 +26,9 @@ CLASS lcl_popup_maintain_task IMPLEMENTATION. false TYPE c LENGTH 1 VALUE '0'. LOOP AT SCREEN. - CHECK screen-group1 EQ 'ID'. + IF screen-group1 <> 'ID'. + CONTINUE. + ENDIF. IF screen_fields-task-id IS INITIAL. screen-active = false. diff --git a/src/#usi#bal_demo/#usi#bal_demo_02/#usi#bal_demo_02_p02.prog.abap b/src/#usi#bal_demo/#usi#bal_demo_02/#usi#bal_demo_02_p02.prog.abap index 8b380a8..79d7e04 100644 --- a/src/#usi#bal_demo/#usi#bal_demo_02/#usi#bal_demo_02_p02.prog.abap +++ b/src/#usi#bal_demo/#usi#bal_demo_02/#usi#bal_demo_02_p02.prog.abap @@ -8,34 +8,26 @@ CLASS lcl_task_grid IMPLEMENTATION. toolbar_excluding = get_toolbar_excluding( ). CREATE OBJECT custom_container - EXPORTING - container_name = 'CC_MAIN' - EXCEPTIONS - OTHERS = 0. + EXPORTING container_name = 'CC_MAIN' + EXCEPTIONS OTHERS = 0. CREATE OBJECT alv_grid - EXPORTING - i_parent = custom_container - EXCEPTIONS - OTHERS = 0. + EXPORTING i_parent = custom_container + EXCEPTIONS OTHERS = 0. SET HANDLER on_toolbar FOR alv_grid. ENDMETHOD. - METHOD get_field_catalog. FIELD-SYMBOLS TYPE lvc_s_fcat. CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' - EXPORTING - i_structure_name = '/USI/BAL_DEMO_TO_DO_TASK' - CHANGING - ct_fieldcat = r_result - EXCEPTIONS - OTHERS = 0. - - READ TABLE r_result WITH KEY fieldname = 'ID' ASSIGNING . - IF sy-subrc EQ 0. + EXPORTING i_structure_name = '/USI/BAL_DEMO_TO_DO_TASK' + CHANGING ct_fieldcat = r_result + EXCEPTIONS OTHERS = 0. + + ASSIGN r_result[ fieldname = 'ID' ] TO . + IF sy-subrc = 0. -no_out = abap_true. ENDIF. ENDMETHOD. @@ -66,53 +58,42 @@ CLASS lcl_task_grid IMPLEMENTATION. separator TYPE tb_btype VALUE 3, END OF button_types. - DATA button TYPE stb_button. - - CLEAR button. - button-function = user_commands-refresh. - button-butn_type = button_types-button. - button-text = TEXT-b01. - button-icon = icon_refresh. - INSERT button INTO TABLE e_object->mt_toolbar. - - CLEAR button. - button-butn_type = button_types-separator. - INSERT button INTO TABLE e_object->mt_toolbar. - - CLEAR button. - button-function = user_commands-add_task. - button-butn_type = button_types-button. - button-text = TEXT-b02. - button-icon = icon_insert_row. - INSERT button INTO TABLE e_object->mt_toolbar. - - CLEAR button. - button-function = user_commands-edit_task. - button-butn_type = button_types-button. - button-text = TEXT-b03. - button-icon = icon_change_text. - INSERT button INTO TABLE e_object->mt_toolbar. - - CLEAR button. - button-function = user_commands-delete_tasks. - button-butn_type = button_types-button. - button-text = TEXT-b04. - button-icon = icon_delete_row. - INSERT button INTO TABLE e_object->mt_toolbar. + INSERT VALUE #( function = user_commands-refresh + butn_type = button_types-button + text = TEXT-b01 + icon = icon_refresh ) + INTO TABLE e_object->mt_toolbar. + + INSERT VALUE #( butn_type = button_types-separator ) + INTO TABLE e_object->mt_toolbar. + + INSERT VALUE #( function = user_commands-add_task + butn_type = button_types-button + text = TEXT-b02 + icon = icon_insert_row ) + INTO TABLE e_object->mt_toolbar. + + INSERT VALUE #( function = user_commands-edit_task + butn_type = button_types-button + text = TEXT-b03 + icon = icon_change_text ) + INTO TABLE e_object->mt_toolbar. + + INSERT VALUE #( function = user_commands-delete_tasks + butn_type = button_types-button + text = TEXT-b04 + icon = icon_delete_row ) + INTO TABLE e_object->mt_toolbar. ENDMETHOD. METHOD refresh_alv_grid. tasks = i_tasks. - alv_grid->set_table_for_first_display( - EXPORTING - is_layout = layout - it_toolbar_excluding = toolbar_excluding - CHANGING - it_outtab = tasks - it_fieldcatalog = field_catalog - EXCEPTIONS - OTHERS = 0 ). + alv_grid->set_table_for_first_display( EXPORTING is_layout = layout + it_toolbar_excluding = toolbar_excluding + CHANGING it_outtab = tasks + it_fieldcatalog = field_catalog + EXCEPTIONS OTHERS = 0 ). ENDMETHOD. METHOD get_selected_task_ids. @@ -124,7 +105,7 @@ CLASS lcl_task_grid IMPLEMENTATION. alv_grid->get_selected_rows( IMPORTING et_row_no = row_numbers ). LOOP AT row_numbers ASSIGNING . - READ TABLE tasks ASSIGNING INDEX -row_id. + ASSIGN tasks[ -row_id ] TO . INSERT -id INTO TABLE r_result. ENDLOOP. ENDMETHOD. diff --git a/src/#usi#bal_demo/#usi#bal_demo_02/#usi#bal_demo_02_p03.prog.abap b/src/#usi#bal_demo/#usi#bal_demo_02/#usi#bal_demo_02_p03.prog.abap index 96e37b9..2fd56fd 100644 --- a/src/#usi#bal_demo/#usi#bal_demo_02/#usi#bal_demo_02_p03.prog.abap +++ b/src/#usi#bal_demo/#usi#bal_demo_02/#usi#bal_demo_02_p03.prog.abap @@ -3,11 +3,11 @@ *&---------------------------------------------------------------------* CLASS lcl_main_screen IMPLEMENTATION. METHOD class_constructor. - CREATE OBJECT singleton. + singleton = NEW #( ). ENDMETHOD. METHOD constructor. - CREATE OBJECT to_do_list. + to_do_list = NEW #( ). ENDMETHOD. METHOD on_pbo. @@ -23,7 +23,7 @@ CLASS lcl_main_screen IMPLEMENTATION. ENDIF. /usi/cl_auth=>check_tcode( ). - CREATE OBJECT task_grid. + task_grid = NEW #( ). SET HANDLER on_user_command FOR task_grid->alv_grid. refresh_screen_without_log( ). @@ -36,28 +36,28 @@ CLASS lcl_main_screen IMPLEMENTATION. METHOD on_user_command. CASE e_ucomm. WHEN task_grid->user_commands-add_task. - IF screen_fields-with_log EQ abap_true. + IF screen_fields-with_log = abap_true. on_add_task_with_log( ). ELSE. on_add_task_without_log( ). ENDIF. WHEN task_grid->user_commands-edit_task. - IF screen_fields-with_log EQ abap_true. + IF screen_fields-with_log = abap_true. on_edit_task_with_log( ). ELSE. on_edit_task_without_log( ). ENDIF. WHEN task_grid->user_commands-delete_tasks. - IF screen_fields-with_log EQ abap_true. + IF screen_fields-with_log = abap_true. on_delete_tasks_with_log( ). ELSE. on_delete_tasks_without_log( ). ENDIF. WHEN task_grid->user_commands-refresh. - IF screen_fields-with_log EQ abap_true. + IF screen_fields-with_log = abap_true. refresh_screen_with_log( ). ELSE. refresh_screen_without_log( ). @@ -73,7 +73,7 @@ CLASS lcl_main_screen IMPLEMENTATION. start_log( i_sub_object = 'CREATE_TASK' ). lcl_popup_maintain_task=>singleton->display( ). - IF lcl_popup_maintain_task=>singleton->was_input_cancelled( ) EQ abap_false. + IF lcl_popup_maintain_task=>singleton->was_input_cancelled( ) = abap_false. task_text = lcl_popup_maintain_task=>singleton->get_task_text( ). TRY. to_do_list->create_task( task_text ). @@ -92,7 +92,7 @@ CLASS lcl_main_screen IMPLEMENTATION. create_exception TYPE REF TO /usi/cx_bal_demo_root. lcl_popup_maintain_task=>singleton->display( ). - IF lcl_popup_maintain_task=>singleton->was_input_cancelled( ) EQ abap_false. + IF lcl_popup_maintain_task=>singleton->was_input_cancelled( ) = abap_false. task_text = lcl_popup_maintain_task=>singleton->get_task_text( ). TRY. to_do_list->create_task( task_text ). @@ -136,7 +136,7 @@ CLASS lcl_main_screen IMPLEMENTATION. start_log( i_sub_object = 'UPDATE_TASK' ). task_ids = task_grid->get_selected_task_ids( ). - IF lines( task_ids ) NE 1. + IF lines( task_ids ) <> 1. log-logger->add_message( i_message_class = '/USI/BAL_DEMO_02' i_message_number = '020' ). save_and_destroy_log( ). @@ -144,11 +144,11 @@ CLASS lcl_main_screen IMPLEMENTATION. RETURN. ENDIF. - READ TABLE task_ids INDEX 1 ASSIGNING . + ASSIGN task_ids[ 1 ] TO . TRY. task = to_do_list->read_task( ). lcl_popup_maintain_task=>singleton->display( task ). - IF lcl_popup_maintain_task=>singleton->was_input_cancelled( ) EQ abap_false. + IF lcl_popup_maintain_task=>singleton->was_input_cancelled( ) = abap_false. task-text = lcl_popup_maintain_task=>singleton->get_task_text( ). to_do_list->update_task( task ). ENDIF. @@ -172,16 +172,16 @@ CLASS lcl_main_screen IMPLEMENTATION. FIELD-SYMBOLS TYPE /usi/bal_demo_to_do_task_id. task_ids = task_grid->get_selected_task_ids( ). - IF lines( task_ids ) NE 1. + IF lines( task_ids ) <> 1. MESSAGE s020(/usi/bal_demo_02) DISPLAY LIKE 'E'. RETURN. ENDIF. - READ TABLE task_ids INDEX 1 ASSIGNING . + ASSIGN task_ids[ 1 ] TO . TRY. task = to_do_list->read_task( ). lcl_popup_maintain_task=>singleton->display( task ). - IF lcl_popup_maintain_task=>singleton->was_input_cancelled( ) EQ abap_false. + IF lcl_popup_maintain_task=>singleton->was_input_cancelled( ) = abap_false. task-text = lcl_popup_maintain_task=>singleton->get_task_text( ). to_do_list->update_task( task ). ENDIF. @@ -218,7 +218,7 @@ CLASS lcl_main_screen IMPLEMENTATION. i_external_id = i_external_id ). log-token = log-logger->claim_ownership( ). - IF 1 EQ 0. + IF 1 = 0. MESSAGE i030(/usi/bal_demo_02). ENDIF. log-logger->add_message( i_message_type = /usi/cl_bal_enum_message_type=>information diff --git a/src/#usi#bal_demo/#usi#bal_demo_02/#usi#cl_bal_demo_task_dao_fake.clas.abap b/src/#usi#bal_demo/#usi#bal_demo_02/#usi#cl_bal_demo_task_dao_fake.clas.abap index 30416c1..95fe97e 100644 --- a/src/#usi#bal_demo/#usi#bal_demo_02/#usi#cl_bal_demo_task_dao_fake.clas.abap +++ b/src/#usi#bal_demo/#usi#bal_demo_02/#usi#cl_bal_demo_task_dao_fake.clas.abap @@ -1,12 +1,10 @@ CLASS /usi/cl_bal_demo_task_dao_fake DEFINITION PUBLIC FINAL CREATE PRIVATE. PUBLIC SECTION. - "!

Factory method

"! "! @parameter r_result | The singleton CLASS-METHODS get_instance - RETURNING - VALUE(r_result) TYPE REF TO /usi/cl_bal_demo_task_dao_fake. + RETURNING VALUE(r_result) TYPE REF TO /usi/cl_bal_demo_task_dao_fake. "!

Constructor

"! @@ -15,55 +13,43 @@ CLASS /usi/cl_bal_demo_task_dao_fake DEFINITION PUBLIC FINAL CREATE PRIVATE. "!

Insert task into buffer (NO DB-Update)

"! - "! @parameter i_task | new task - "! @raising /usi/cx_bal_demo_root | ID already in use + "! @parameter i_task | new task + "! @raising /usi/cx_bal_demo_root | ID already in use METHODS create_task - IMPORTING - i_task TYPE /usi/bal_demo_to_do_task - RAISING - /usi/cx_bal_demo_root. + IMPORTING i_task TYPE /usi/bal_demo_to_do_task + RAISING /usi/cx_bal_demo_root. "!

Read task from buffer

"! - "! @parameter i_task_id | ID of to-be-read task - "! @parameter r_result | Task data - "! @raising /usi/cx_bal_demo_root | Not found + "! @parameter i_task_id | ID of to-be-read task + "! @parameter r_result | Task data + "! @raising /usi/cx_bal_demo_root | Not found METHODS read_task - IMPORTING - i_task_id TYPE /usi/bal_demo_to_do_task_id - RETURNING - VALUE(r_result) TYPE /usi/bal_demo_to_do_task - RAISING - /usi/cx_bal_demo_root. + IMPORTING i_task_id TYPE /usi/bal_demo_to_do_task_id + RETURNING VALUE(r_result) TYPE /usi/bal_demo_to_do_task + RAISING /usi/cx_bal_demo_root. "!

Read tasks from buffer

"! "! @parameter r_result | Current buffer content METHODS read_tasks - RETURNING - VALUE(r_result) TYPE /usi/bal_demo_to_do_tasks. + RETURNING VALUE(r_result) TYPE /usi/bal_demo_to_do_tasks. "!

Update task in buffer (NO DB-Update)

"! - "! @parameter i_task | to-be-updated task - "! @raising /usi/cx_bal_demo_root | Not found + "! @parameter i_task | to-be-updated task + "! @raising /usi/cx_bal_demo_root | Not found METHODS update_task - IMPORTING - i_task TYPE /usi/bal_demo_to_do_task - RAISING - /usi/cx_bal_demo_root. + IMPORTING i_task TYPE /usi/bal_demo_to_do_task + RAISING /usi/cx_bal_demo_root. "!

Delete task from buffer (NO DB-Update)

"! - "! @parameter i_task_id | Task-ID - "! @raising /usi/cx_bal_demo_root | Not found + "! @parameter i_task_id | Task-ID + "! @raising /usi/cx_bal_demo_root | Not found METHODS delete_task - IMPORTING - i_task_id TYPE /usi/bal_demo_to_do_task_id - RAISING - /usi/cx_bal_demo_root. - - PROTECTED SECTION. + IMPORTING i_task_id TYPE /usi/bal_demo_to_do_task_id + RAISING /usi/cx_bal_demo_root. PRIVATE SECTION. CLASS-DATA singleton TYPE REF TO /usi/cl_bal_demo_task_dao_fake. @@ -73,29 +59,25 @@ CLASS /usi/cl_bal_demo_task_dao_fake DEFINITION PUBLIC FINAL CREATE PRIVATE. METHODS set_fake_data. METHODS log_exception - IMPORTING - i_exception TYPE REF TO cx_root. + IMPORTING i_exception TYPE REF TO cx_root. METHODS log_info_message - IMPORTING - i_message_number TYPE symsgno - i_message_variable_1 TYPE simple OPTIONAL - i_message_variable_2 TYPE simple OPTIONAL - i_message_variable_3 TYPE simple OPTIONAL - i_message_variable_4 TYPE simple OPTIONAL. + IMPORTING i_message_number TYPE symsgno + i_message_variable_1 TYPE simple OPTIONAL + i_message_variable_2 TYPE simple OPTIONAL + i_message_variable_3 TYPE simple OPTIONAL + i_message_variable_4 TYPE simple OPTIONAL. METHODS get_logger - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_logger. + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_logger. ENDCLASS. - CLASS /usi/cl_bal_demo_task_dao_fake IMPLEMENTATION. METHOD get_instance. IF singleton IS NOT BOUND. - CREATE OBJECT singleton. + singleton = NEW #( ). ENDIF. r_result = singleton. @@ -126,23 +108,22 @@ CLASS /usi/cl_bal_demo_task_dao_fake IMPLEMENTATION. propagated_exception TYPE REF TO cx_root. INSERT i_task INTO TABLE tasks. - IF sy-subrc NE 0. - IF 1 EQ 0. + IF sy-subrc <> 0. + IF 1 = 0. MESSAGE e010(/usi/bal_demo_02) WITH i_task-id. ENDIF. TRY. WRITE i_task-id TO message_variable_1 LEFT-JUSTIFIED. RAISE EXCEPTION TYPE /usi/cx_bal_demo_duplicate - EXPORTING - textid = /usi/cx_bal_demo_duplicate=>duplicate_task_id - param1 = message_variable_1. + EXPORTING textid = /usi/cx_bal_demo_duplicate=>duplicate_task_id + param1 = message_variable_1. CLEANUP INTO propagated_exception. log_exception( propagated_exception ). ENDTRY. ELSE. - IF 1 EQ 0. + IF 1 = 0. MESSAGE i011(/usi/bal_demo_02) WITH i_task-id. ENDIF. log_info_message( i_message_number = '011' @@ -157,23 +138,22 @@ CLASS /usi/cl_bal_demo_task_dao_fake IMPLEMENTATION. READ TABLE tasks INTO r_result WITH TABLE KEY id = i_task_id. - IF sy-subrc NE 0. - IF 1 EQ 0. + IF sy-subrc <> 0. + IF 1 = 0. MESSAGE e014(/usi/bal_demo_02) WITH i_task_id. ENDIF. TRY. WRITE i_task_id TO message_variable_1 LEFT-JUSTIFIED. RAISE EXCEPTION TYPE /usi/cx_bal_demo_not_found - EXPORTING - textid = /usi/cx_bal_demo_not_found=>task_not_found_by_id - param1 = message_variable_1. + EXPORTING textid = /usi/cx_bal_demo_not_found=>task_not_found_by_id + param1 = message_variable_1. CLEANUP INTO propagated_exception. log_exception( propagated_exception ). ENDTRY. ELSE. - IF 1 EQ 0. + IF 1 = 0. MESSAGE i017(/usi/bal_demo_02) WITH i_task_id. ENDIF. log_info_message( i_message_number = '017' @@ -189,22 +169,20 @@ CLASS /usi/cl_bal_demo_task_dao_fake IMPLEMENTATION. METHOD update_task. DATA: task_ref TYPE REF TO /usi/bal_demo_to_do_task, message_variable_1 TYPE symsgv, - message_variable_2 TYPE symsgv, propagated_exception TYPE REF TO cx_root. READ TABLE tasks WITH TABLE KEY id = i_task-id REFERENCE INTO task_ref. - IF sy-subrc NE 0. - IF 1 EQ 0. + IF sy-subrc <> 0. + IF 1 = 0. MESSAGE e014(/usi/bal_demo_02) WITH i_task-id. ENDIF. TRY. WRITE i_task-id TO message_variable_1 LEFT-JUSTIFIED. RAISE EXCEPTION TYPE /usi/cx_bal_demo_not_found - EXPORTING - textid = /usi/cx_bal_demo_not_found=>task_not_found_by_id - param1 = message_variable_1. + EXPORTING textid = /usi/cx_bal_demo_not_found=>task_not_found_by_id + param1 = message_variable_1. CLEANUP INTO propagated_exception. log_exception( propagated_exception ). ENDTRY. @@ -212,7 +190,7 @@ CLASS /usi/cl_bal_demo_task_dao_fake IMPLEMENTATION. ELSE. task_ref->text = i_task-text. - IF 1 EQ 0. + IF 1 = 0. MESSAGE i016(/usi/bal_demo_02) WITH i_task-id. ENDIF. log_info_message( i_message_number = '016' @@ -223,28 +201,26 @@ CLASS /usi/cl_bal_demo_task_dao_fake IMPLEMENTATION. METHOD delete_task. DATA: message_variable_1 TYPE symsgv, - message_variable_2 TYPE symsgv, propagated_exception TYPE REF TO cx_root. DELETE TABLE tasks WITH TABLE KEY id = i_task_id. - IF sy-subrc NE 0. - IF 1 EQ 0. + IF sy-subrc <> 0. + IF 1 = 0. MESSAGE e014(/usi/bal_demo_02) WITH i_task_id. ENDIF. TRY. WRITE i_task_id TO message_variable_1 LEFT-JUSTIFIED. RAISE EXCEPTION TYPE /usi/cx_bal_demo_not_found - EXPORTING - textid = /usi/cx_bal_demo_not_found=>task_not_found_by_id - param1 = message_variable_1. + EXPORTING textid = /usi/cx_bal_demo_not_found=>task_not_found_by_id + param1 = message_variable_1. CLEANUP INTO propagated_exception. log_exception( propagated_exception ). ENDTRY. ELSE. - IF 1 EQ 0. + IF 1 = 0. MESSAGE i015(/usi/bal_demo_02) WITH i_task_id. ENDIF. log_info_message( i_message_number = '015' @@ -254,14 +230,14 @@ CLASS /usi/cl_bal_demo_task_dao_fake IMPLEMENTATION. ENDMETHOD. METHOD log_exception. - DATA logger TYPE REF TO /usi/if_bal_logger. + DATA logger TYPE REF TO /usi/if_bal_logger. logger = get_logger( ). logger->add_exception( i_exception ). ENDMETHOD. METHOD log_info_message. - DATA logger TYPE REF TO /usi/if_bal_logger. + DATA logger TYPE REF TO /usi/if_bal_logger. logger = get_logger( ). logger->add_message( i_message_type = /usi/cl_bal_enum_message_type=>information diff --git a/src/#usi#bal_demo/#usi#bal_demo_02/#usi#cl_bal_demo_to_do_list.clas.abap b/src/#usi#bal_demo/#usi#bal_demo_02/#usi#cl_bal_demo_to_do_list.clas.abap index 0b00062..21472d6 100644 --- a/src/#usi#bal_demo/#usi#bal_demo_02/#usi#cl_bal_demo_to_do_list.clas.abap +++ b/src/#usi#bal_demo/#usi#bal_demo_02/#usi#cl_bal_demo_to_do_list.clas.abap @@ -5,56 +5,45 @@ CLASS /usi/cl_bal_demo_to_do_list DEFINITION PUBLIC FINAL CREATE PUBLIC. "!

Create task (In buffer; No DB-Update)

"! - "! @parameter i_task_text | Task text - "! @raising /usi/cx_bal_demo_root | Task with same text already exists + "! @parameter i_task_text | Task text + "! @raising /usi/cx_bal_demo_root | Task with same text already exists METHODS create_task - IMPORTING - i_task_text TYPE /usi/bal_demo_to_do_task_text - RAISING - /usi/cx_bal_demo_root. + IMPORTING i_task_text TYPE /usi/bal_demo_to_do_task_text + RAISING /usi/cx_bal_demo_root. "!

Read task from buffer

"! - "! @parameter i_task_id | Task id - "! @raising /usi/cx_bal_demo_root | Not found + "! @parameter i_task_id | Task id + "! @parameter r_result | + "! @raising /usi/cx_bal_demo_root | Not found METHODS read_task - IMPORTING - i_task_id TYPE /usi/bal_demo_to_do_task_id - RETURNING - VALUE(r_result) TYPE /usi/bal_demo_to_do_task - RAISING - /usi/cx_bal_demo_root. + IMPORTING i_task_id TYPE /usi/bal_demo_to_do_task_id + RETURNING VALUE(r_result) TYPE /usi/bal_demo_to_do_task + RAISING /usi/cx_bal_demo_root. "!

Read all tasks from buffer

"! + "! @parameter r_result | "! @raising /usi/cx_bal_demo_root | Current buffer content METHODS read_tasks - RETURNING - VALUE(r_result) TYPE /usi/bal_demo_to_do_tasks - RAISING - /usi/cx_bal_demo_root. + RETURNING VALUE(r_result) TYPE /usi/bal_demo_to_do_tasks + RAISING /usi/cx_bal_demo_root. "!

Update task in buffer

"! - "! @parameter i_task | Task - "! @raising /usi/cx_bal_demo_root | Not found + "! @parameter i_task | Task + "! @raising /usi/cx_bal_demo_root | Not found METHODS update_task - IMPORTING - i_task TYPE /usi/bal_demo_to_do_task - RAISING - /usi/cx_bal_demo_root. + IMPORTING i_task TYPE /usi/bal_demo_to_do_task + RAISING /usi/cx_bal_demo_root. "!

Delete task from buffer

"! - "! @parameter i_task_id | Task ID - "! @raising /usi/cx_bal_demo_root | Not found + "! @parameter i_task_id | Task ID + "! @raising /usi/cx_bal_demo_root | Not found METHODS delete_task - IMPORTING - i_task_id TYPE /usi/bal_demo_to_do_task_id - RAISING - /usi/cx_bal_demo_root. - - PROTECTED SECTION. + IMPORTING i_task_id TYPE /usi/bal_demo_to_do_task_id + RAISING /usi/cx_bal_demo_root. PRIVATE SECTION. DATA: BEGIN OF to_do_list, @@ -68,44 +57,34 @@ CLASS /usi/cl_bal_demo_to_do_list DEFINITION PUBLIC FINAL CREATE PUBLIC. END OF log. METHODS create_itab_container - IMPORTING - i_table TYPE ANY TABLE - i_title_text_key TYPE /usi/cl_bal_tc_report_text_c40=>ty_text_key - i_title_text TYPE csequence - RETURNING - VALUE(r_result) TYPE REF TO /usi/cl_bal_dc_itab. + IMPORTING i_table TYPE ANY TABLE + i_title_text_key TYPE /usi/cl_bal_tc_report_text_c40=>ty_text_key + i_title_text TYPE csequence + RETURNING VALUE(r_result) TYPE REF TO /usi/cl_bal_dc_itab. METHODS get_tasks_by_text - IMPORTING - i_task_text TYPE /usi/bal_demo_to_do_task_text - RETURNING - VALUE(r_result) TYPE /usi/bal_demo_to_do_tasks - RAISING - /usi/cx_bal_demo_root. + IMPORTING i_task_text TYPE /usi/bal_demo_to_do_task_text + RETURNING VALUE(r_result) TYPE /usi/bal_demo_to_do_tasks + RAISING /usi/cx_bal_demo_root. METHODS log_info_message - IMPORTING - i_message_number TYPE symsgno - i_message_variable_1 TYPE simple OPTIONAL - i_message_variable_2 TYPE simple OPTIONAL - i_message_variable_3 TYPE simple OPTIONAL - i_message_variable_4 TYPE simple OPTIONAL - i_details TYPE REF TO /usi/if_bal_message_details OPTIONAL. + IMPORTING i_message_number TYPE symsgno + i_message_variable_1 TYPE simple OPTIONAL + i_message_variable_2 TYPE simple OPTIONAL + i_message_variable_3 TYPE simple OPTIONAL + i_message_variable_4 TYPE simple OPTIONAL + i_details TYPE REF TO /usi/if_bal_message_details OPTIONAL. METHODS start_log - IMPORTING - i_sub_object TYPE balsubobj - i_external_id TYPE balnrext OPTIONAL. + IMPORTING i_sub_object TYPE balsubobj + i_external_id TYPE balnrext OPTIONAL. METHODS save_and_destroy_log. ENDCLASS. - CLASS /usi/cl_bal_demo_to_do_list IMPLEMENTATION. - - METHOD constructor. DATA: tasks TYPE /usi/bal_demo_to_do_tasks, index_of_last_task TYPE i. @@ -114,33 +93,30 @@ CLASS /usi/cl_bal_demo_to_do_list IMPLEMENTATION. to_do_list-dao_object = /usi/cl_bal_demo_task_dao_fake=>get_instance( ). - tasks = to_do_list-dao_object->read_tasks( ). + tasks = to_do_list-dao_object->read_tasks( ). IF tasks IS NOT INITIAL. index_of_last_task = lines( tasks ). - READ TABLE tasks INDEX index_of_last_task ASSIGNING . + ASSIGN tasks[ index_of_last_task ] TO . to_do_list-highest_task_id = -id. ENDIF. ENDMETHOD. - METHOD create_itab_container. DATA title_text_container TYPE REF TO /usi/cl_bal_tc_report_text_c40. title_text_container = /usi/cl_bal_tc_report_text_c40=>create( i_text_key = i_title_text_key i_text = i_title_text ). - CREATE OBJECT r_result - EXPORTING - i_internal_table = i_table - i_title = title_text_container. + r_result = NEW #( i_internal_table = i_table + i_title = title_text_container ). ENDMETHOD. - METHOD create_task. DATA: duplicates TYPE /usi/bal_demo_to_do_tasks, duplicates_container TYPE REF TO /usi/cl_bal_dc_itab, message_variable TYPE symsgv, new_task TYPE /usi/bal_demo_to_do_task, + " TODO: variable is assigned but never used (ABAP cleaner) no_duplicates_exception TYPE REF TO /usi/cx_bal_demo_root, propagated_exception TYPE REF TO cx_root. @@ -150,15 +126,14 @@ CLASS /usi/cl_bal_demo_to_do_list IMPLEMENTATION. duplicates = get_tasks_by_text( i_task_text ). " We already had that text => Reject the duplicate! - IF 1 EQ 0. + IF 1 = 0. MESSAGE e004(/usi/bal_demo_02) WITH i_task_text. ENDIF. TRY. message_variable = i_task_text. RAISE EXCEPTION TYPE /usi/cx_bal_demo_duplicate - EXPORTING - textid = /usi/cx_bal_demo_duplicate=>duplicate_task_text - param1 = message_variable. + EXPORTING textid = /usi/cx_bal_demo_duplicate=>duplicate_task_text + param1 = message_variable. CLEANUP INTO propagated_exception. duplicates_container = create_itab_container( i_table = duplicates i_title_text_key = 'T02' @@ -178,7 +153,7 @@ CLASS /usi/cl_bal_demo_to_do_list IMPLEMENTATION. to_do_list-dao_object->create_task( new_task ). - IF 1 EQ 0. + IF 1 = 0. MESSAGE i003(/usi/bal_demo_02) WITH new_task-text new_task-id. ENDIF. log_info_message( i_message_number = '003' @@ -190,7 +165,6 @@ CLASS /usi/cl_bal_demo_to_do_list IMPLEMENTATION. ENDTRY. ENDMETHOD. - METHOD delete_task. DATA external_id TYPE balnrext. @@ -203,7 +177,6 @@ CLASS /usi/cl_bal_demo_to_do_list IMPLEMENTATION. save_and_destroy_log( ). ENDMETHOD. - METHOD get_tasks_by_text. DATA: tasks TYPE /usi/bal_demo_to_do_tasks, message_variable_1 TYPE symsgv, @@ -212,27 +185,27 @@ CLASS /usi/cl_bal_demo_to_do_list IMPLEMENTATION. FIELD-SYMBOLS TYPE /usi/bal_demo_to_do_task. tasks = to_do_list-dao_object->read_tasks( ). - LOOP AT tasks ASSIGNING WHERE text EQ i_task_text. + LOOP AT tasks ASSIGNING WHERE text = i_task_text. INSERT INTO TABLE r_result. ENDLOOP. - IF r_result IS INITIAL. - IF 1 EQ 0. - MESSAGE i012(/usi/bal_demo_02) WITH i_task_text. - ENDIF. - TRY. - message_variable_1 = i_task_text. - RAISE EXCEPTION TYPE /usi/cx_bal_demo_not_found - EXPORTING - textid = /usi/cx_bal_demo_not_found=>task_not_found_by_text - param1 = message_variable_1. - CLEANUP INTO propagated_exception. - log-logger->add_exception( i_message_type = /usi/cl_bal_enum_message_type=>information - i_exception = propagated_exception ). - ENDTRY. + IF r_result IS NOT INITIAL. + RETURN. ENDIF. - ENDMETHOD. + IF 1 = 0. + MESSAGE i012(/usi/bal_demo_02) WITH i_task_text. + ENDIF. + TRY. + message_variable_1 = i_task_text. + RAISE EXCEPTION TYPE /usi/cx_bal_demo_not_found + EXPORTING textid = /usi/cx_bal_demo_not_found=>task_not_found_by_text + param1 = message_variable_1. + CLEANUP INTO propagated_exception. + log-logger->add_exception( i_message_type = /usi/cl_bal_enum_message_type=>information + i_exception = propagated_exception ). + ENDTRY. + ENDMETHOD. METHOD log_info_message. log-logger->add_message( i_message_type = /usi/cl_bal_enum_message_type=>information @@ -245,7 +218,6 @@ CLASS /usi/cl_bal_demo_to_do_list IMPLEMENTATION. i_details = i_details ). ENDMETHOD. - METHOD read_task. start_log( 'READ_TASK' ). @@ -254,10 +226,8 @@ CLASS /usi/cl_bal_demo_to_do_list IMPLEMENTATION. save_and_destroy_log( ). ENDMETHOD. - METHOD read_tasks. DATA: line_count TYPE i, - message_variable_1 TYPE symsgv, propagated_exception TYPE REF TO cx_root, table_container TYPE REF TO /usi/cl_bal_dc_itab. @@ -270,7 +240,7 @@ CLASS /usi/cl_bal_demo_to_do_list IMPLEMENTATION. i_title_text_key = 'T01' i_title_text = TEXT-t01 ). - IF 1 EQ 0. + IF 1 = 0. MESSAGE i002(/usi/bal_demo_02) WITH line_count. ENDIF. log_info_message( i_message_number = '002' @@ -280,13 +250,12 @@ CLASS /usi/cl_bal_demo_to_do_list IMPLEMENTATION. save_and_destroy_log( ). ELSE. - IF 1 EQ 0. + IF 1 = 0. MESSAGE s013(/usi/bal_demo_02). ENDIF. TRY. RAISE EXCEPTION TYPE /usi/cx_bal_demo_not_found - EXPORTING - textid = /usi/cx_bal_demo_not_found=>no_tasks_found. + EXPORTING textid = /usi/cx_bal_demo_not_found=>no_tasks_found. CLEANUP INTO propagated_exception. log-logger->add_exception( propagated_exception ). save_and_destroy_log( ). @@ -295,13 +264,11 @@ CLASS /usi/cl_bal_demo_to_do_list IMPLEMENTATION. ENDIF. ENDMETHOD. - METHOD save_and_destroy_log. log-logger->save( log-token ). log-logger->free( log-token ). ENDMETHOD. - METHOD start_log. DATA factory TYPE REF TO /usi/if_bal_factory. @@ -312,7 +279,6 @@ CLASS /usi/cl_bal_demo_to_do_list IMPLEMENTATION. log-token = log-logger->claim_ownership( ). ENDMETHOD. - METHOD update_task. start_log( 'UPDATE_TASK' ). diff --git a/src/#usi#bal_enum/#usi#cl_bal_enum_detail_level.clas.abap b/src/#usi#bal_enum/#usi#cl_bal_enum_detail_level.clas.abap index 99668bf..2726a9b 100644 --- a/src/#usi#bal_enum/#usi#cl_bal_enum_detail_level.clas.abap +++ b/src/#usi#bal_enum/#usi#cl_bal_enum_detail_level.clas.abap @@ -16,58 +16,27 @@ CLASS /usi/cl_bal_enum_detail_level DEFINITION PUBLIC FINAL CREATE PRIVATE. CLASS-METHODS class_constructor. "!

Create instances

+ "! + "! @parameter i_detail_level | Detail level METHODS constructor - IMPORTING - i_detail_level TYPE ballevel. - - PROTECTED SECTION. - - PRIVATE SECTION. + IMPORTING i_detail_level TYPE ballevel. ENDCLASS. - CLASS /usi/cl_bal_enum_detail_level IMPLEMENTATION. METHOD class_constructor. - CREATE OBJECT detail_level_1 - EXPORTING - i_detail_level = '1'. - - CREATE OBJECT detail_level_2 - EXPORTING - i_detail_level = '2'. - - CREATE OBJECT detail_level_3 - EXPORTING - i_detail_level = '3'. - - CREATE OBJECT detail_level_4 - EXPORTING - i_detail_level = '4'. - - CREATE OBJECT detail_level_5 - EXPORTING - i_detail_level = '5'. - - CREATE OBJECT detail_level_6 - EXPORTING - i_detail_level = '6'. - - CREATE OBJECT detail_level_7 - EXPORTING - i_detail_level = '7'. - - CREATE OBJECT detail_level_8 - EXPORTING - i_detail_level = '8'. - - CREATE OBJECT detail_level_9 - EXPORTING - i_detail_level = '9'. + detail_level_1 = NEW #( i_detail_level = '1' ). + detail_level_2 = NEW #( i_detail_level = '2' ). + detail_level_3 = NEW #( i_detail_level = '3' ). + detail_level_4 = NEW #( i_detail_level = '4' ). + detail_level_5 = NEW #( i_detail_level = '5' ). + detail_level_6 = NEW #( i_detail_level = '6' ). + detail_level_7 = NEW #( i_detail_level = '7' ). + detail_level_8 = NEW #( i_detail_level = '8' ). + detail_level_9 = NEW #( i_detail_level = '9' ). ENDMETHOD. - METHOD constructor. value = i_detail_level. ENDMETHOD. diff --git a/src/#usi#bal_enum/#usi#cl_bal_enum_log_level.clas.abap b/src/#usi#bal_enum/#usi#cl_bal_enum_log_level.clas.abap index 45bfbe9..3407928 100644 --- a/src/#usi#bal_enum/#usi#cl_bal_enum_log_level.clas.abap +++ b/src/#usi#bal_enum/#usi#cl_bal_enum_log_level.clas.abap @@ -19,33 +19,29 @@ CLASS /usi/cl_bal_enum_log_level DEFINITION PUBLIC FINAL CREATE PRIVATE. "! "!

This method provides a backwards search and returns the matching instance for the passed value.

"! - "! @parameter i_value | The value to search for - "! @parameter r_result | The corresponding instance - "! @raising /usi/cx_bal_root | Unsupported value + "! @parameter i_value | The value to search for + "! @parameter r_result | The corresponding instance + "! @raising /usi/cx_bal_root | Unsupported value CLASS-METHODS get_by_value - IMPORTING - i_value TYPE /usi/bal_log_level - RETURNING - VALUE(r_result) TYPE REF TO /usi/cl_bal_enum_log_level - RAISING - /usi/cx_bal_root. + IMPORTING i_value TYPE /usi/bal_log_level + RETURNING VALUE(r_result) TYPE REF TO /usi/cl_bal_enum_log_level + RAISING /usi/cx_bal_root. "!

Create instances

+ "! + "! @parameter i_value | METHODS constructor - IMPORTING - i_value TYPE /usi/bal_log_level. + IMPORTING i_value TYPE /usi/bal_log_level. "!

Log-Level comparison

"! "!

Will return abap_true, if this instance represents a higher log-level than the one passed for comparison.

"! "! @parameter i_log_level | The log-level to compare with - "! @parameter r_result | Flag: Is this log-level higher, than i_log_level? + "! @parameter r_result | Flag: Is this log-level higher, than i_log_level? METHODS is_higher_than - IMPORTING - i_log_level TYPE REF TO /usi/cl_bal_enum_log_level - RETURNING - VALUE(r_result) TYPE abap_bool. + IMPORTING i_log_level TYPE REF TO /usi/cl_bal_enum_log_level + RETURNING VALUE(r_result) TYPE abap_bool. "!

Relevance check for problem class

"! @@ -59,14 +55,10 @@ CLASS /usi/cl_bal_enum_log_level DEFINITION PUBLIC FINAL CREATE PRIVATE. "! The passed message will be logged or discarded based on the result.

"! "! @parameter i_problem_class | Problem class of the log message - "! @parameter r_result | Flag: Relevant for current log-level? + "! @parameter r_result | Flag: Relevant for current log-level? METHODS is_problem_class_relevant - IMPORTING - i_problem_class TYPE REF TO /usi/cl_bal_enum_problem_class - RETURNING - VALUE(r_result) TYPE abap_bool. - - PROTECTED SECTION. + IMPORTING i_problem_class TYPE REF TO /usi/cl_bal_enum_problem_class + RETURNING VALUE(r_result) TYPE abap_bool. PRIVATE SECTION. TYPES: BEGIN OF ty_buffered_instance, @@ -78,75 +70,44 @@ CLASS /usi/cl_bal_enum_log_level DEFINITION PUBLIC FINAL CREATE PRIVATE. CLASS-DATA buffered_instances TYPE ty_buffered_instances. METHODS get_min_loglevel_for_probclass - IMPORTING - i_problem_class TYPE REF TO /usi/cl_bal_enum_problem_class - RETURNING - VALUE(r_result) TYPE REF TO /usi/cl_bal_enum_log_level. + IMPORTING i_problem_class TYPE REF TO /usi/cl_bal_enum_problem_class + RETURNING VALUE(r_result) TYPE REF TO /usi/cl_bal_enum_log_level. ENDCLASS. - CLASS /usi/cl_bal_enum_log_level IMPLEMENTATION. METHOD class_constructor. - CREATE OBJECT nothing - EXPORTING - i_value = 0. - - CREATE OBJECT very_important - EXPORTING - i_value = 1. - - CREATE OBJECT important - EXPORTING - i_value = 2. - - CREATE OBJECT medium - EXPORTING - i_value = 3. - - CREATE OBJECT additional_info - EXPORTING - i_value = 4. - - CREATE OBJECT other - EXPORTING - i_value = 5. - - CREATE OBJECT everything - EXPORTING - i_value = 6. + nothing = NEW #( i_value = 0 ). + very_important = NEW #( i_value = 1 ). + important = NEW #( i_value = 2 ). + medium = NEW #( i_value = 3 ). + additional_info = NEW #( i_value = 4 ). + other = NEW #( i_value = 5 ). + everything = NEW #( i_value = 6 ). ENDMETHOD. - METHOD constructor. - DATA buffered_instance TYPE ty_buffered_instance. - value = i_value. - buffered_instance-value = me->value. - buffered_instance-instance = me. - INSERT buffered_instance INTO TABLE buffered_instances. + INSERT VALUE #( value = value + instance = me ) + INTO TABLE buffered_instances. ENDMETHOD. - METHOD get_by_value. FIELD-SYMBOLS TYPE ty_buffered_instance. - READ TABLE buffered_instances - ASSIGNING - WITH TABLE KEY value = i_value. + ASSIGN buffered_instances[ value = i_value ] TO . - IF sy-subrc EQ 0. + IF sy-subrc = 0. r_result = -instance. ELSE. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>/usi/cx_bal_invalid_input. + EXPORTING textid = /usi/cx_bal_invalid_input=>/usi/cx_bal_invalid_input. ENDIF. ENDMETHOD. - METHOD get_min_loglevel_for_probclass. CASE i_problem_class. WHEN /usi/cl_bal_enum_problem_class=>very_important. @@ -162,21 +123,19 @@ CLASS /usi/cl_bal_enum_log_level IMPLEMENTATION. ENDCASE. ENDMETHOD. - METHOD is_higher_than. - IF i_log_level IS BOUND - AND i_log_level->value LT value. + IF i_log_level IS BOUND + AND i_log_level->value < value. r_result = abap_true. ENDIF. ENDMETHOD. - METHOD is_problem_class_relevant. DATA minimum_log_level TYPE REF TO /usi/cl_bal_enum_log_level. minimum_log_level = get_min_loglevel_for_probclass( i_problem_class ). - IF minimum_log_level->is_higher_than( me ) EQ abap_false. + IF minimum_log_level->is_higher_than( me ) = abap_false. r_result = abap_true. ENDIF. ENDMETHOD. diff --git a/src/#usi#bal_enum/#usi#cl_bal_enum_message_param.clas.abap b/src/#usi#bal_enum/#usi#cl_bal_enum_message_param.clas.abap index c883435..668e5b3 100644 --- a/src/#usi#bal_enum/#usi#cl_bal_enum_message_param.clas.abap +++ b/src/#usi#bal_enum/#usi#cl_bal_enum_message_param.clas.abap @@ -23,13 +23,8 @@ ENDCLASS. CLASS /usi/cl_bal_enum_message_param IMPLEMENTATION. METHOD class_constructor. - CREATE OBJECT log_number - EXPORTING - i_value = '%LOGNUMBER'. - - CREATE OBJECT message_number - EXPORTING - i_value = 'MSG_NUMBER'. + log_number = NEW #( i_value = '%LOGNUMBER' ). + message_number = NEW #( i_value = 'MSG_NUMBER' ). ENDMETHOD. METHOD constructor. diff --git a/src/#usi#bal_enum/#usi#cl_bal_enum_message_type.clas.abap b/src/#usi#bal_enum/#usi#cl_bal_enum_message_type.clas.abap index 63fdcbe..557ccb5 100644 --- a/src/#usi#bal_enum/#usi#cl_bal_enum_message_type.clas.abap +++ b/src/#usi#bal_enum/#usi#cl_bal_enum_message_type.clas.abap @@ -18,23 +18,19 @@ CLASS /usi/cl_bal_enum_message_type DEFINITION PUBLIC FINAL CREATE PRIVATE. "! "!

This method provides a backwards search and returns the matching instance for the passed value.

"! - "! @parameter i_value | The value to search for - "! @parameter r_result | The corresponding instance - "! @raising /usi/cx_bal_root | Unsupported value + "! @parameter i_value | The value to search for + "! @parameter r_result | The corresponding instance + "! @raising /usi/cx_bal_root | Unsupported value CLASS-METHODS get_by_value - IMPORTING - i_value TYPE symsgty - RETURNING - VALUE(r_result) TYPE REF TO /usi/cl_bal_enum_message_type - RAISING - /usi/cx_bal_root. + IMPORTING i_value TYPE symsgty + RETURNING VALUE(r_result) TYPE REF TO /usi/cl_bal_enum_message_type + RAISING /usi/cx_bal_root. "!

Create instances

+ "! + "! @parameter i_msgty | METHODS constructor - IMPORTING - i_msgty TYPE symsgty. - - PROTECTED SECTION. + IMPORTING i_msgty TYPE symsgty. PRIVATE SECTION. TYPES: BEGIN OF ty_buffered_instance, @@ -48,59 +44,34 @@ CLASS /usi/cl_bal_enum_message_type DEFINITION PUBLIC FINAL CREATE PRIVATE. ENDCLASS. - CLASS /usi/cl_bal_enum_message_type IMPLEMENTATION. METHOD class_constructor. - CREATE OBJECT abend - EXPORTING - i_msgty = 'A'. - - CREATE OBJECT error - EXPORTING - i_msgty = 'E'. - - CREATE OBJECT exit - EXPORTING - i_msgty = 'X'. - - CREATE OBJECT information - EXPORTING - i_msgty = 'I'. - - CREATE OBJECT success - EXPORTING - i_msgty = 'S'. - - CREATE OBJECT warning - EXPORTING - i_msgty = 'W'. + abend = NEW #( i_msgty = 'A' ). + error = NEW #( i_msgty = 'E' ). + exit = NEW #( i_msgty = 'X' ). + information = NEW #( i_msgty = 'I' ). + success = NEW #( i_msgty = 'S' ). + warning = NEW #( i_msgty = 'W' ). ENDMETHOD. - METHOD constructor. - DATA buffered_instance TYPE ty_buffered_instance. - value = i_msgty. - buffered_instance-value = me->value. - buffered_instance-instance = me. - INSERT buffered_instance INTO TABLE buffered_instances. + INSERT VALUE #( value = value + instance = me ) + INTO TABLE buffered_instances. ENDMETHOD. - METHOD get_by_value. FIELD-SYMBOLS TYPE ty_buffered_instance. - READ TABLE buffered_instances - ASSIGNING - WITH TABLE KEY value = i_value. + ASSIGN buffered_instances[ value = i_value ] TO . - IF sy-subrc EQ 0. + IF sy-subrc = 0. r_result = -instance. ELSE. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>/usi/cx_bal_invalid_input. + EXPORTING textid = /usi/cx_bal_invalid_input=>/usi/cx_bal_invalid_input. ENDIF. ENDMETHOD. ENDCLASS. diff --git a/src/#usi#bal_enum/#usi#cl_bal_enum_problem_class.clas.abap b/src/#usi#bal_enum/#usi#cl_bal_enum_problem_class.clas.abap index 1f38a35..cf6c9d7 100644 --- a/src/#usi#bal_enum/#usi#cl_bal_enum_problem_class.clas.abap +++ b/src/#usi#bal_enum/#usi#cl_bal_enum_problem_class.clas.abap @@ -12,42 +12,23 @@ CLASS /usi/cl_bal_enum_problem_class DEFINITION PUBLIC FINAL CREATE PRIVATE. CLASS-METHODS class_constructor. "!

Create instances

+ "! + "! @parameter i_problem_class | Problem Class METHODS constructor - IMPORTING - i_problem_class TYPE balprobcl. - - PROTECTED SECTION. - - PRIVATE SECTION. + IMPORTING i_problem_class TYPE balprobcl. ENDCLASS. - CLASS /usi/cl_bal_enum_problem_class IMPLEMENTATION. METHOD class_constructor. - CREATE OBJECT very_important - EXPORTING - i_problem_class = '1'. - - CREATE OBJECT important - EXPORTING - i_problem_class = '2'. - - CREATE OBJECT medium - EXPORTING - i_problem_class = '3'. - - CREATE OBJECT additional_information - EXPORTING - i_problem_class = '4'. - - CREATE OBJECT other - EXPORTING - i_problem_class = ' '. + very_important = NEW #( i_problem_class = '1' ). + important = NEW #( i_problem_class = '2' ). + medium = NEW #( i_problem_class = '3' ). + additional_information = NEW #( i_problem_class = '4' ). + other = NEW #( i_problem_class = ' ' ). ENDMETHOD. - METHOD constructor. value = i_problem_class. ENDMETHOD. diff --git a/src/#usi#bal_exception_mappers/#usi#cl_bal_em_base.clas.abap b/src/#usi#bal_exception_mappers/#usi#cl_bal_em_base.clas.abap index fd273ce..67bc9c1 100644 --- a/src/#usi#bal_exception_mappers/#usi#cl_bal_em_base.clas.abap +++ b/src/#usi#bal_exception_mappers/#usi#cl_bal_em_base.clas.abap @@ -4,39 +4,33 @@ CLASS /usi/cl_bal_em_base DEFINITION PUBLIC CREATE PUBLIC. "!

Constructor

"! - "! @parameter i_exception | The to-be-mapped exception - "! @raising /usi/cx_bal_root | Not bound + "! @parameter i_exception | The to-be-mapped exception + "! @raising /usi/cx_bal_root | Not bound METHODS constructor - IMPORTING - i_exception TYPE REF TO cx_root - RAISING - /usi/cx_bal_root. + IMPORTING i_exception TYPE REF TO cx_root + RAISING /usi/cx_bal_root. PROTECTED SECTION. - TYPES ty_object_references TYPE STANDARD TABLE OF REF TO object WITH NON-UNIQUE DEFAULT KEY. + TYPES ty_object_references TYPE STANDARD TABLE OF REF TO object WITH EMPTY KEY. DATA exception TYPE REF TO cx_root. METHODS get_exceptions_oref_attributes - RETURNING - VALUE(r_result) TYPE ty_object_references. + RETURNING VALUE(r_result) TYPE ty_object_references. METHODS get_attached_data_cont_coll - IMPORTING - i_source_data_cont_coll TYPE REF TO object - i_target_data_cont_coll TYPE REF TO /usi/if_bal_data_container_col. + IMPORTING i_source_data_cont_coll TYPE REF TO object + i_target_data_cont_coll TYPE REF TO /usi/if_bal_data_container_col. METHODS get_attached_data_container - IMPORTING - i_source_data_container TYPE REF TO object - i_target_data_cont_coll TYPE REF TO /usi/if_bal_data_container_col. + IMPORTING i_source_data_container TYPE REF TO object + i_target_data_cont_coll TYPE REF TO /usi/if_bal_data_container_col. PRIVATE SECTION. ENDCLASS. - CLASS /usi/cl_bal_em_base IMPLEMENTATION. METHOD /usi/if_bal_exception_mapper~get_data_containers. DATA objects TYPE ty_object_references. @@ -52,28 +46,22 @@ CLASS /usi/cl_bal_em_base IMPLEMENTATION. ENDLOOP. ENDMETHOD. - METHOD /usi/if_bal_exception_mapper~get_t100_message. DATA text_getter TYPE REF TO /usi/cl_exception_text_getter. - CREATE OBJECT text_getter - EXPORTING - i_exception = exception. + text_getter = NEW #( i_exception = exception ). r_result = text_getter->get_text_as_symsg( ). ENDMETHOD. - METHOD constructor. IF i_exception IS NOT BOUND. RAISE EXCEPTION TYPE /usi/cx_bal_type_mismatch - EXPORTING - textid = /usi/cx_bal_type_mismatch=>/usi/cx_bal_type_mismatch. + EXPORTING textid = /usi/cx_bal_type_mismatch=>/usi/cx_bal_type_mismatch. ENDIF. exception = i_exception. ENDMETHOD. - METHOD get_attached_data_container. DATA data_container TYPE REF TO /usi/if_bal_data_container. @@ -87,7 +75,6 @@ CLASS /usi/cl_bal_em_base IMPLEMENTATION. i_target_data_cont_coll->insert( data_container ). ENDMETHOD. - METHOD get_attached_data_cont_coll. DATA: data_container_collection TYPE REF TO /usi/if_bal_data_container_col, data_containers TYPE /usi/bal_data_containers. @@ -106,7 +93,6 @@ CLASS /usi/cl_bal_em_base IMPLEMENTATION. ENDLOOP. ENDMETHOD. - METHOD get_exceptions_oref_attributes. DATA class_description TYPE REF TO cl_abap_classdescr. @@ -114,11 +100,13 @@ CLASS /usi/cl_bal_em_base IMPLEMENTATION. TYPE any. class_description ?= cl_abap_classdescr=>describe_by_object_ref( exception ). - LOOP AT class_description->attributes ASSIGNING WHERE visibility EQ cl_abap_classdescr=>public - AND type_kind EQ cl_abap_classdescr=>typekind_oref. + LOOP AT class_description->attributes ASSIGNING WHERE visibility = cl_abap_classdescr=>public + AND type_kind = cl_abap_classdescr=>typekind_oref. ASSIGN exception->(-name) TO . - CHECK sy-subrc EQ 0 - AND IS BOUND. + IF NOT ( sy-subrc = 0 + AND IS BOUND ). + CONTINUE. + ENDIF. INSERT INTO TABLE r_result. ENDLOOP. diff --git a/src/#usi#bal_logger_bl/#usi#cl_bal_factory.clas.abap b/src/#usi#bal_logger_bl/#usi#cl_bal_factory.clas.abap index f70ea97..bb8b94d 100644 --- a/src/#usi#bal_logger_bl/#usi#cl_bal_factory.clas.abap +++ b/src/#usi#bal_logger_bl/#usi#cl_bal_factory.clas.abap @@ -6,21 +6,17 @@ CLASS /usi/cl_bal_factory DEFINITION PUBLIC FINAL CREATE PRIVATE. "! "! @parameter r_result | Factory instance CLASS-METHODS get_instance - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_factory. + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_factory. "!

Constructor

"! - "! @parameter i_cust_eval_factory | Customizing evaluator factory (Access to API-Customizing) - "! @parameter i_logger_bl_factory | BL-Factory (Creates objects, that only the API should create) + "! @parameter i_cust_eval_factory | Customizing evaluator factory (Access to API-Customizing) + "! @parameter i_logger_bl_factory | BL-Factory (Creates objects, that only the API should create) "! @parameter i_logger_dao_factory | DAO-Factory (Persistency Layer) METHODS constructor - IMPORTING - i_cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory - i_logger_bl_factory TYPE REF TO /usi/if_bal_logger_bl_factory - i_logger_dao_factory TYPE REF TO /usi/if_bal_logger_dao_factory. - - PROTECTED SECTION. + IMPORTING i_cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory + i_logger_bl_factory TYPE REF TO /usi/if_bal_logger_bl_factory + i_logger_dao_factory TYPE REF TO /usi/if_bal_logger_dao_factory. PRIVATE SECTION. CONSTANTS: BEGIN OF fallback_log_object, @@ -36,52 +32,40 @@ CLASS /usi/cl_bal_factory DEFINITION PUBLIC FINAL CREATE PRIVATE. logger TYPE REF TO /usi/if_bal_logger. METHODS get_data_container_classnames - IMPORTING - i_log_object TYPE balobj_d - i_sub_object TYPE balsubobj - i_log_level TYPE REF TO /usi/cl_bal_enum_log_level - RETURNING - VALUE(r_result) TYPE /usi/bal_data_cont_classnames. + IMPORTING i_log_object TYPE balobj_d + i_sub_object TYPE balsubobj + i_log_level TYPE REF TO /usi/cl_bal_enum_log_level + RETURNING VALUE(r_result) TYPE /usi/bal_data_cont_classnames. METHODS get_retention_parameters - IMPORTING - i_log_object TYPE balobj_d - i_sub_object TYPE balsubobj - i_log_level TYPE REF TO /usi/cl_bal_enum_log_level - RETURNING - VALUE(r_result) TYPE /usi/bal_retention_parameters. + IMPORTING i_log_object TYPE balobj_d + i_sub_object TYPE balsubobj + i_log_level TYPE REF TO /usi/cl_bal_enum_log_level + RETURNING VALUE(r_result) TYPE /usi/bal_retention_parameters. METHODS create_logger_internal - IMPORTING - i_log_object TYPE balobj_d - i_sub_object TYPE balsubobj - i_external_id TYPE balnrext - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_logger - RAISING - /usi/cx_bal_root. + IMPORTING i_log_object TYPE balobj_d + i_sub_object TYPE balsubobj + i_external_id TYPE balnrext + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_logger + RAISING /usi/cx_bal_root. METHODS get_log_level - IMPORTING - i_log_object TYPE balobj_d - i_sub_object TYPE balsubobj OPTIONAL - RETURNING - VALUE(r_result) TYPE REF TO /usi/cl_bal_enum_log_level. + IMPORTING i_log_object TYPE balobj_d + i_sub_object TYPE balsubobj OPTIONAL + RETURNING VALUE(r_result) TYPE REF TO /usi/cl_bal_enum_log_level. METHODS get_auto_save_package_size - IMPORTING - i_log_object TYPE balobj_d - i_sub_object TYPE balsubobj OPTIONAL - RETURNING - VALUE(r_result) TYPE /usi/bal_auto_save_pckg_size. + IMPORTING i_log_object TYPE balobj_d + i_sub_object TYPE balsubobj OPTIONAL + RETURNING VALUE(r_result) TYPE /usi/bal_auto_save_pckg_size. METHODS on_log_writer_invalidation - FOR EVENT instance_invalidated OF /usi/if_bal_logger. + FOR EVENT instance_invalidated OF /usi/if_bal_logger. ENDCLASS. - CLASS /usi/cl_bal_factory IMPLEMENTATION. METHOD /usi/if_bal_factory~create_new_logger. DATA: exception TYPE REF TO /usi/cx_bal_root, @@ -97,19 +81,19 @@ CLASS /usi/cl_bal_factory IMPLEMENTATION. " Most likely an invalid combination of log object and subobject => Retry using fallbacks exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION exception IS NOT BOUND. + FIELDS exception_text + CONDITION exception IS NOT BOUND. TRY. - logger = create_logger_internal( i_log_object = fallback_log_object-log_object - i_sub_object = fallback_log_object-sub_object - i_external_id = i_external_id ). + logger = create_logger_internal( i_log_object = fallback_log_object-log_object + i_sub_object = fallback_log_object-sub_object + i_external_id = i_external_id ). CATCH /usi/cx_bal_root INTO exception. " THIS SHOULD _NEVER_ HAPPEN! (If it still happens, the API is broken) exception_text = exception->get_text( ). ASSERT FIELDS exception_text - CONDITION exception IS NOT BOUND. + CONDITION exception IS NOT BOUND. ENDTRY. ENDTRY. @@ -118,10 +102,9 @@ CLASS /usi/cl_bal_factory IMPLEMENTATION. r_result = logger. ENDMETHOD. - METHOD /usi/if_bal_factory~get_existing_logger. ASSERT ID /usi/bal_log_writer - CONDITION logger IS BOUND. + CONDITION logger IS BOUND. IF logger IS BOUND. r_result = logger. @@ -131,14 +114,12 @@ CLASS /usi/cl_bal_factory IMPLEMENTATION. ENDIF. ENDMETHOD. - METHOD constructor. - cust_eval_factory = i_cust_eval_factory. - logger_bl_factory = i_logger_bl_factory. - logger_dao_factory = i_logger_dao_factory. + cust_eval_factory = i_cust_eval_factory. + logger_bl_factory = i_logger_bl_factory. + logger_dao_factory = i_logger_dao_factory. ENDMETHOD. - METHOD create_logger_internal. DATA: auto_save_package_size TYPE /usi/bal_auto_save_pckg_size, data_container_classnames TYPE /usi/bal_data_cont_classnames, @@ -166,21 +147,18 @@ CLASS /usi/cl_bal_factory IMPLEMENTATION. i_external_id = i_external_id i_retention_parameters = retention_parameters ). - data_container_coll_dao = logger_dao_factory->get_data_container_collection( ). + data_container_coll_dao = logger_dao_factory->get_data_container_collection( ). - CREATE OBJECT r_result TYPE /usi/cl_bal_logger - EXPORTING - i_factory = logger_bl_factory - i_relevant_data_containers = data_container_classnames - i_log_level = log_level - i_auto_save_pckg_size = auto_save_package_size - i_log_dao = log_dao - i_data_cont_coll_dao = data_container_coll_dao. + r_result = NEW /usi/cl_bal_logger( i_factory = logger_bl_factory + i_relevant_data_containers = data_container_classnames + i_log_level = log_level + i_auto_save_pckg_size = auto_save_package_size + i_log_dao = log_dao + i_data_cont_coll_dao = data_container_coll_dao ). SET HANDLER on_log_writer_invalidation FOR r_result. ENDMETHOD. - METHOD get_auto_save_package_size. CONSTANTS c_auto_save_disabled TYPE /usi/bal_auto_save_pckg_size VALUE 0. @@ -192,37 +170,36 @@ CLASS /usi/cl_bal_factory IMPLEMENTATION. package_size_by_user TYPE /usi/bal_auto_save_pckg_size, smallest_package_size TYPE /usi/bal_auto_save_pckg_size. - cust_evaluator_by_log_object = cust_eval_factory->get_log_level_by_log_object( ). - package_size_by_log_object = cust_evaluator_by_log_object->get_auto_save_package_size( - i_log_object = i_log_object - i_sub_object = i_sub_object ). + cust_evaluator_by_log_object = cust_eval_factory->get_log_level_by_log_object( ). + package_size_by_log_object = cust_evaluator_by_log_object->get_auto_save_package_size( + i_log_object = i_log_object + i_sub_object = i_sub_object ). cust_evaluator_by_client = cust_eval_factory->get_log_level_by_client( ). package_size_by_client = cust_evaluator_by_client->get_auto_save_package_size( i_log_object = i_log_object i_sub_object = i_sub_object ). - cust_evaluator_by_user = cust_eval_factory->get_log_level_by_user( ). - package_size_by_user = cust_evaluator_by_user->get_auto_save_package_size( i_log_object = i_log_object - i_sub_object = i_sub_object ). + cust_evaluator_by_user = cust_eval_factory->get_log_level_by_user( ). + package_size_by_user = cust_evaluator_by_user->get_auto_save_package_size( i_log_object = i_log_object + i_sub_object = i_sub_object ). - IF package_size_by_user NE c_auto_save_disabled - AND ( package_size_by_client EQ c_auto_save_disabled OR - package_size_by_user LT package_size_by_client ). + IF package_size_by_user <> c_auto_save_disabled + AND ( package_size_by_client = c_auto_save_disabled + OR package_size_by_user < package_size_by_client ). smallest_package_size = package_size_by_user. ELSE. smallest_package_size = package_size_by_client. ENDIF. - IF package_size_by_log_object NE c_auto_save_disabled - AND ( smallest_package_size EQ c_auto_save_disabled OR - package_size_by_log_object LT smallest_package_size ). + IF package_size_by_log_object <> c_auto_save_disabled + AND ( smallest_package_size = c_auto_save_disabled + OR package_size_by_log_object < smallest_package_size ). smallest_package_size = package_size_by_log_object. ENDIF. r_result = smallest_package_size. ENDMETHOD. - METHOD get_data_container_classnames. DATA customizing_evaluator TYPE REF TO /usi/if_bal_ce_data_containers. @@ -232,28 +209,24 @@ CLASS /usi/cl_bal_factory IMPLEMENTATION. i_log_level = i_log_level ). ENDMETHOD. - METHOD get_instance. DATA: cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory, logger_bl_factory TYPE REF TO /usi/if_bal_logger_bl_factory, logger_dao_factory TYPE REF TO /usi/if_bal_logger_dao_factory. IF instance IS NOT BOUND. - cust_eval_factory = /usi/cl_bal_cust_eval_factory=>get_instance( ). - logger_bl_factory = /usi/cl_bal_logger_bl_factory=>get_instance( cust_eval_factory ). - logger_dao_factory = /usi/cl_bal_logger_dao_factory=>get_instance( ). - - CREATE OBJECT instance TYPE /usi/cl_bal_factory - EXPORTING - i_cust_eval_factory = cust_eval_factory - i_logger_bl_factory = logger_bl_factory - i_logger_dao_factory = logger_dao_factory. + cust_eval_factory = /usi/cl_bal_cust_eval_factory=>get_instance( ). + logger_bl_factory = /usi/cl_bal_logger_bl_factory=>get_instance( cust_eval_factory ). + logger_dao_factory = /usi/cl_bal_logger_dao_factory=>get_instance( ). + + instance = NEW /usi/cl_bal_factory( i_cust_eval_factory = cust_eval_factory + i_logger_bl_factory = logger_bl_factory + i_logger_dao_factory = logger_dao_factory ). ENDIF. r_result = instance. ENDMETHOD. - METHOD get_log_level. DATA: cust_evaluator_by_log_object TYPE REF TO /usi/if_bal_ce_log_lv_by_obj, cust_evaluator_by_client TYPE REF TO /usi/if_bal_ce_log_lv_by_clnt, @@ -263,31 +236,30 @@ CLASS /usi/cl_bal_factory IMPLEMENTATION. log_level_by_user TYPE REF TO /usi/cl_bal_enum_log_level, highest_log_level TYPE REF TO /usi/cl_bal_enum_log_level. - cust_evaluator_by_log_object = cust_eval_factory->get_log_level_by_log_object( ). - log_level_by_log_object = cust_evaluator_by_log_object->get_log_level( i_log_object = i_log_object - i_sub_object = i_sub_object ). + cust_evaluator_by_log_object = cust_eval_factory->get_log_level_by_log_object( ). + log_level_by_log_object = cust_evaluator_by_log_object->get_log_level( i_log_object = i_log_object + i_sub_object = i_sub_object ). cust_evaluator_by_client = cust_eval_factory->get_log_level_by_client( ). log_level_by_client = cust_evaluator_by_client->get_log_level( i_log_object = i_log_object i_sub_object = i_sub_object ). - cust_evaluator_by_user = cust_eval_factory->get_log_level_by_user( ). - log_level_by_user = cust_evaluator_by_user->get_log_level( i_log_object = i_log_object - i_sub_object = i_sub_object ). + cust_evaluator_by_user = cust_eval_factory->get_log_level_by_user( ). + log_level_by_user = cust_evaluator_by_user->get_log_level( i_log_object = i_log_object + i_sub_object = i_sub_object ). - IF log_level_by_client->is_higher_than( log_level_by_user ) EQ abap_true. + IF log_level_by_client->is_higher_than( log_level_by_user ) = abap_true. highest_log_level = log_level_by_client. ELSE. highest_log_level = log_level_by_user. ENDIF. - IF log_level_by_log_object->is_higher_than( highest_log_level ) EQ abap_true. + IF log_level_by_log_object->is_higher_than( highest_log_level ) = abap_true. highest_log_level = log_level_by_log_object. ENDIF. r_result = highest_log_level. ENDMETHOD. - METHOD get_retention_parameters. DATA customizing_evaluator TYPE REF TO /usi/if_bal_ce_retention. @@ -297,7 +269,6 @@ CLASS /usi/cl_bal_factory IMPLEMENTATION. i_log_level = i_log_level ). ENDMETHOD. - METHOD on_log_writer_invalidation. CLEAR logger. ENDMETHOD. diff --git a/src/#usi#bal_logger_bl/#usi#cl_bal_logger.clas.abap b/src/#usi#bal_logger_bl/#usi#cl_bal_logger.clas.abap index 38814e4..7e3fb45 100644 --- a/src/#usi#bal_logger_bl/#usi#cl_bal_logger.clas.abap +++ b/src/#usi#bal_logger_bl/#usi#cl_bal_logger.clas.abap @@ -4,22 +4,19 @@ CLASS /usi/cl_bal_logger DEFINITION PUBLIC FINAL CREATE PUBLIC. "!

Constructor

"! - "! @parameter i_factory | BL-Factory (Internal object creation) + "! @parameter i_factory | BL-Factory (Internal object creation) "! @parameter i_relevant_data_containers | Relevant data containers (Customizing) - "! @parameter i_log_level | Current log level (Customizing) - "! @parameter i_auto_save_pckg_size | Package size of auto save (Customizing) - "! @parameter i_log_dao | DAO-Instance for messages (Persistency Layer) - "! @parameter i_data_cont_coll_dao | DAO-Instance for data-containers (Persistency Layer) + "! @parameter i_log_level | Current log level (Customizing) + "! @parameter i_auto_save_pckg_size | Package size of auto save (Customizing) + "! @parameter i_log_dao | DAO-Instance for messages (Persistency Layer) + "! @parameter i_data_cont_coll_dao | DAO-Instance for data-containers (Persistency Layer) METHODS constructor - IMPORTING - i_factory TYPE REF TO /usi/if_bal_logger_bl_factory - i_relevant_data_containers TYPE /usi/bal_data_cont_classnames - i_log_level TYPE REF TO /usi/cl_bal_enum_log_level - i_auto_save_pckg_size TYPE /usi/bal_auto_save_pckg_size - i_log_dao TYPE REF TO /usi/if_bal_log_dao - i_data_cont_coll_dao TYPE REF TO /usi/if_bal_data_cont_coll_dao. - - PROTECTED SECTION. + IMPORTING i_factory TYPE REF TO /usi/if_bal_logger_bl_factory + i_relevant_data_containers TYPE /usi/bal_data_cont_classnames + i_log_level TYPE REF TO /usi/cl_bal_enum_log_level + i_auto_save_pckg_size TYPE /usi/bal_auto_save_pckg_size + i_log_dao TYPE REF TO /usi/if_bal_log_dao + i_data_cont_coll_dao TYPE REF TO /usi/if_bal_data_cont_coll_dao. PRIVATE SECTION. DATA: factory TYPE REF TO /usi/if_bal_logger_bl_factory, @@ -33,7 +30,6 @@ CLASS /usi/cl_bal_logger DEFINITION PUBLIC FINAL CREATE PUBLIC. ENDCLASS. - CLASS /usi/cl_bal_logger IMPLEMENTATION. METHOD /usi/if_bal_logger~add_exception. DATA: exception TYPE REF TO /usi/cx_bal_root, @@ -51,12 +47,11 @@ CLASS /usi/cl_bal_logger IMPLEMENTATION. " Error during operation or not allowed in current state! exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION exception IS NOT BOUND. + FIELDS exception_text + CONDITION exception IS NOT BOUND. ENDTRY. ENDMETHOD. - METHOD /usi/if_bal_logger~add_free_text. DATA: exception TYPE REF TO /usi/cx_bal_root, exception_text TYPE string, @@ -75,12 +70,11 @@ CLASS /usi/cl_bal_logger IMPLEMENTATION. " Error during operation or not allowed in current state! exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION exception IS NOT BOUND. + FIELDS exception_text + CONDITION exception IS NOT BOUND. ENDTRY. ENDMETHOD. - METHOD /usi/if_bal_logger~add_message. DATA: exception TYPE REF TO /usi/cx_bal_root, exception_text TYPE string, @@ -110,12 +104,11 @@ CLASS /usi/cl_bal_logger IMPLEMENTATION. " Error during operation or not allowed in current state! exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION exception IS NOT BOUND. + FIELDS exception_text + CONDITION exception IS NOT BOUND. ENDTRY. ENDMETHOD. - METHOD /usi/if_bal_logger~add_message_from_sy_fields. DATA: exception TYPE REF TO /usi/cx_bal_root, exception_text TYPE string, @@ -123,12 +116,12 @@ CLASS /usi/cl_bal_logger IMPLEMENTATION. " Check sy-msgty and sy-msgid ASSERT ID /usi/bal_log_writer - FIELDS sy-msgty - sy-msgid - CONDITION sy-msgty IS NOT INITIAL - AND sy-msgid IS NOT INITIAL. - IF sy-msgty IS INITIAL - OR sy-msgid IS INITIAL. + FIELDS sy-msgty + sy-msgid + CONDITION sy-msgty IS NOT INITIAL + AND sy-msgid IS NOT INITIAL. + IF sy-msgty IS INITIAL + OR sy-msgid IS INITIAL. RETURN. ENDIF. @@ -138,8 +131,8 @@ CLASS /usi/cl_bal_logger IMPLEMENTATION. " SY-MSGTY contains an invalid message type! exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION exception IS NOT BOUND. + FIELDS exception_text + CONDITION exception IS NOT BOUND. RETURN. ENDTRY. @@ -160,12 +153,11 @@ CLASS /usi/cl_bal_logger IMPLEMENTATION. " Error during operation or not allowed in current state! exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION exception IS NOT BOUND. + FIELDS exception_text + CONDITION exception IS NOT BOUND. ENDTRY. ENDMETHOD. - METHOD /usi/if_bal_logger~claim_ownership. DATA: exception TYPE REF TO /usi/cx_bal_root, exception_text TYPE string. @@ -174,28 +166,25 @@ CLASS /usi/cl_bal_logger IMPLEMENTATION. r_result = state->claim_ownership( ). " State transition: 'Not claimed' -> 'Active' - CREATE OBJECT state TYPE /usi/cl_bal_lstate_active - EXPORTING - i_factory = factory - i_log_level = log_level - i_auto_save_pckg_size = auto_save_pckg_size - i_log_dao = log_dao - i_data_cont_coll_dao = data_container_collection_dao - i_token = r_result - i_relevant_data_containers = relevant_data_containers. + state = NEW /usi/cl_bal_lstate_active( i_factory = factory + i_log_level = log_level + i_auto_save_pckg_size = auto_save_pckg_size + i_log_dao = log_dao + i_data_cont_coll_dao = data_container_collection_dao + i_token = r_result + i_relevant_data_containers = relevant_data_containers ). CATCH /usi/cx_bal_root INTO exception. " Not allowed in current state! exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION exception IS NOT BOUND. + FIELDS exception_text + CONDITION exception IS NOT BOUND. " Return dummy-token, that grants no authorizations. r_result = factory->get_token( ). ENDTRY. ENDMETHOD. - METHOD /usi/if_bal_logger~free. DATA: exception TYPE REF TO /usi/cx_bal_root, exception_text TYPE string. @@ -204,19 +193,18 @@ CLASS /usi/cl_bal_logger IMPLEMENTATION. state->free( i_token ). " State transition: 'Active' -> 'Invalidated' - CREATE OBJECT state TYPE /usi/cl_bal_lstate_invalidated. + state = NEW /usi/cl_bal_lstate_invalidated( ). RAISE EVENT /usi/if_bal_logger~instance_invalidated. CATCH /usi/cx_bal_root INTO exception. " Not allowed in current state! exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION exception IS NOT BOUND. + FIELDS exception_text + CONDITION exception IS NOT BOUND. ENDTRY. ENDMETHOD. - METHOD /usi/if_bal_logger~save. DATA: exception TYPE REF TO /usi/cx_bal_root, exception_text TYPE string. @@ -227,12 +215,11 @@ CLASS /usi/cl_bal_logger IMPLEMENTATION. " Error during operation or not allowed in current state! exception_text = exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS exception_text - CONDITION exception IS NOT BOUND. + FIELDS exception_text + CONDITION exception IS NOT BOUND. ENDTRY. ENDMETHOD. - METHOD constructor. factory = i_factory. log_level = i_log_level. @@ -242,8 +229,6 @@ CLASS /usi/cl_bal_logger IMPLEMENTATION. auto_save_pckg_size = i_auto_save_pckg_size. " Set initial state: 'Not claimed' - CREATE OBJECT state TYPE /usi/cl_bal_lstate_not_claimed - EXPORTING - i_factory = factory. + state = NEW /usi/cl_bal_lstate_not_claimed( i_factory = factory ). ENDMETHOD. ENDCLASS. diff --git a/src/#usi#bal_logger_bl/#usi#cl_bal_logger_bl_factory.clas.abap b/src/#usi#bal_logger_bl/#usi#cl_bal_logger_bl_factory.clas.abap index 71868ab..0103b1c 100644 --- a/src/#usi#bal_logger_bl/#usi#cl_bal_logger_bl_factory.clas.abap +++ b/src/#usi#bal_logger_bl/#usi#cl_bal_logger_bl_factory.clas.abap @@ -5,21 +5,16 @@ CLASS /usi/cl_bal_logger_bl_factory DEFINITION PUBLIC FINAL CREATE PRIVATE. "!

Factory Method (Singleton pattern)

"! "! @parameter i_cust_eval_factory | Customizing evaluator factory (Access to API-Customizing) - "! @parameter r_result | Factory instance + "! @parameter r_result | Factory instance CLASS-METHODS get_instance - IMPORTING - i_cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_logger_bl_factory. + IMPORTING i_cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_logger_bl_factory. "!

Constructor

"! "! @parameter i_cust_eval_factory | Customizing evaluator factory (Access to API-Customizing) METHODS constructor - IMPORTING - i_cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory. - - PROTECTED SECTION. + IMPORTING i_cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory. PRIVATE SECTION. CLASS-DATA instance TYPE REF TO /usi/if_bal_logger_bl_factory. @@ -29,13 +24,10 @@ CLASS /usi/cl_bal_logger_bl_factory DEFINITION PUBLIC FINAL CREATE PRIVATE. ENDCLASS. - CLASS /usi/cl_bal_logger_bl_factory IMPLEMENTATION. METHOD get_instance. IF instance IS NOT BOUND. - CREATE OBJECT instance TYPE /usi/cl_bal_logger_bl_factory - EXPORTING - i_cust_eval_factory = i_cust_eval_factory. + instance = NEW /usi/cl_bal_logger_bl_factory( i_cust_eval_factory = i_cust_eval_factory ). ENDIF. r_result = instance. @@ -48,6 +40,7 @@ CLASS /usi/cl_bal_logger_bl_factory IMPLEMENTATION. METHOD /usi/if_bal_logger_bl_factory~get_exception_mapper. DATA: cust_evaluator TYPE REF TO /usi/if_bal_ce_cx_mapper, classname TYPE seoclsname, + " TODO: variable is assigned but never used (ABAP cleaner) create_error TYPE REF TO cx_sy_create_error. cust_evaluator = cust_eval_factory->get_exception_mapper( ). @@ -55,17 +48,15 @@ CLASS /usi/cl_bal_logger_bl_factory IMPLEMENTATION. TRY. CREATE OBJECT r_result TYPE (classname) - EXPORTING - i_exception = i_exception. + EXPORTING i_exception = i_exception. CATCH cx_sy_create_error INTO create_error. classname = cust_evaluator->get_fallback_mapper_classname( ). CREATE OBJECT r_result TYPE (classname) - EXPORTING - i_exception = i_exception. + EXPORTING i_exception = i_exception. ENDTRY. ENDMETHOD. METHOD /usi/if_bal_logger_bl_factory~get_token. - CREATE OBJECT r_result TYPE /usi/cl_bal_token. + r_result = NEW /usi/cl_bal_token( ). ENDMETHOD. ENDCLASS. diff --git a/src/#usi#bal_logger_bl/#usi#cl_bal_lstate_active.clas.abap b/src/#usi#bal_logger_bl/#usi#cl_bal_lstate_active.clas.abap index 79774ef..c3ee7fe 100644 --- a/src/#usi#bal_logger_bl/#usi#cl_bal_lstate_active.clas.abap +++ b/src/#usi#bal_logger_bl/#usi#cl_bal_lstate_active.clas.abap @@ -4,24 +4,21 @@ CLASS /usi/cl_bal_lstate_active DEFINITION PUBLIC FINAL CREATE PUBLIC. "!

Constructor

"! - "! @parameter i_factory | BL-Factory (Internal object creation) - "! @parameter i_log_level | Current log level (Customizing) - "! @parameter i_auto_save_pckg_size | Package size of auto save (Customizing) - "! @parameter i_log_dao | DAO-Instance for messages (Persistency Layer) - "! @parameter i_data_cont_coll_dao | DAO-Instance for data-containers (Persistency Layer) - "! @parameter i_token | Token (Proof of Ownership - will be needed to authorize critical actions later) + "! @parameter i_factory | BL-Factory (Internal object creation) + "! @parameter i_log_level | Current log level (Customizing) + "! @parameter i_auto_save_pckg_size | Package size of auto save (Customizing) + "! @parameter i_log_dao | DAO-Instance for messages (Persistency Layer) + "! @parameter i_data_cont_coll_dao | DAO-Instance for data-containers (Persistency Layer) + "! @parameter i_token | Token (Proof of Ownership - will be needed to authorize critical actions later) "! @parameter i_relevant_data_containers | Relevant data containers (Customizing) METHODS constructor - IMPORTING - i_factory TYPE REF TO /usi/if_bal_logger_bl_factory - i_log_level TYPE REF TO /usi/cl_bal_enum_log_level - i_auto_save_pckg_size TYPE /usi/bal_auto_save_pckg_size - i_log_dao TYPE REF TO /usi/if_bal_log_dao - i_data_cont_coll_dao TYPE REF TO /usi/if_bal_data_cont_coll_dao - i_token TYPE REF TO /usi/if_bal_token - i_relevant_data_containers TYPE /usi/bal_data_cont_classnames. - - PROTECTED SECTION. + IMPORTING i_factory TYPE REF TO /usi/if_bal_logger_bl_factory + i_log_level TYPE REF TO /usi/cl_bal_enum_log_level + i_auto_save_pckg_size TYPE /usi/bal_auto_save_pckg_size + i_log_dao TYPE REF TO /usi/if_bal_log_dao + i_data_cont_coll_dao TYPE REF TO /usi/if_bal_data_cont_coll_dao + i_token TYPE REF TO /usi/if_bal_token + i_relevant_data_containers TYPE /usi/bal_data_cont_classnames. PRIVATE SECTION. TYPES: BEGIN OF ty_message, @@ -29,8 +26,8 @@ CLASS /usi/cl_bal_lstate_active DEFINITION PUBLIC FINAL CREATE PUBLIC. message TYPE bal_s_msg, data_container_collection TYPE REF TO /usi/if_bal_data_container_col, END OF ty_message, - ty_messages TYPE STANDARD TABLE OF ty_message WITH NON-UNIQUE DEFAULT KEY, - ty_exceptions TYPE STANDARD TABLE OF REF TO cx_root WITH NON-UNIQUE DEFAULT KEY. + ty_messages TYPE STANDARD TABLE OF ty_message WITH EMPTY KEY, + ty_exceptions TYPE STANDARD TABLE OF REF TO cx_root WITH EMPTY KEY. DATA: factory TYPE REF TO /usi/if_bal_logger_bl_factory, token TYPE REF TO /usi/if_bal_token. @@ -52,87 +49,70 @@ CLASS /usi/cl_bal_lstate_active DEFINITION PUBLIC FINAL CREATE PUBLIC. END OF dao_objects. METHODS get_exceptions_inverted_order - IMPORTING - i_main_exception TYPE REF TO cx_root - i_log_previous TYPE abap_bool - RETURNING - VALUE(r_result) TYPE ty_exceptions. + IMPORTING i_main_exception TYPE REF TO cx_root + i_log_previous TYPE abap_bool + RETURNING VALUE(r_result) TYPE ty_exceptions. METHODS insert_message - IMPORTING - i_problem_class TYPE REF TO /usi/cl_bal_enum_problem_class - i_detail_level TYPE REF TO /usi/cl_bal_enum_detail_level - i_message_type TYPE REF TO /usi/cl_bal_enum_message_type - i_message_class TYPE symsgid - i_message_number TYPE symsgno - i_message_variable_1 TYPE symsgv - i_message_variable_2 TYPE symsgv - i_message_variable_3 TYPE symsgv - i_message_variable_4 TYPE symsgv - i_data_container_collection TYPE REF TO /usi/if_bal_data_container_col - i_message_context TYPE bal_s_cont - RAISING - /usi/cx_bal_root. + IMPORTING i_problem_class TYPE REF TO /usi/cl_bal_enum_problem_class + i_detail_level TYPE REF TO /usi/cl_bal_enum_detail_level + i_message_type TYPE REF TO /usi/cl_bal_enum_message_type + i_message_class TYPE symsgid + i_message_number TYPE symsgno + i_message_variable_1 TYPE symsgv + i_message_variable_2 TYPE symsgv + i_message_variable_3 TYPE symsgv + i_message_variable_4 TYPE symsgv + i_data_container_collection TYPE REF TO /usi/if_bal_data_container_col + i_message_context TYPE bal_s_cont + RAISING /usi/cx_bal_root. METHODS get_new_data_container_coll - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_data_container_col. + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_data_container_col. METHODS collect_data_containers - IMPORTING - i_source TYPE REF TO /usi/if_bal_message_details - i_target TYPE REF TO /usi/if_bal_data_container_col. + IMPORTING i_source TYPE REF TO /usi/if_bal_message_details + i_target TYPE REF TO /usi/if_bal_data_container_col. METHODS add_cx_src_pos_container - IMPORTING - i_target_data_cont_coll TYPE REF TO /usi/if_bal_data_container_col - i_exception TYPE REF TO cx_root. + IMPORTING i_target_data_cont_coll TYPE REF TO /usi/if_bal_data_container_col + i_exception TYPE REF TO cx_root. METHODS add_caller_src_pos_container - IMPORTING - i_target_data_cont_coll TYPE REF TO /usi/if_bal_data_container_col. + IMPORTING i_target_data_cont_coll TYPE REF TO /usi/if_bal_data_container_col. METHODS add_callstack_container - IMPORTING - i_target_data_cont_coll TYPE REF TO /usi/if_bal_data_container_col. + IMPORTING i_target_data_cont_coll TYPE REF TO /usi/if_bal_data_container_col. METHODS insert_container_if_relevant - IMPORTING - i_data_containter TYPE REF TO /usi/if_bal_data_container - i_target_data_cont_coll TYPE REF TO /usi/if_bal_data_container_col. + IMPORTING i_data_containter TYPE REF TO /usi/if_bal_data_container + i_target_data_cont_coll TYPE REF TO /usi/if_bal_data_container_col. METHODS is_data_container_relevant - IMPORTING - i_data_container_classname TYPE /usi/bal_data_cont_classname - RETURNING - VALUE(r_result) TYPE abap_bool. + IMPORTING i_data_container_classname TYPE /usi/bal_data_cont_classname + RETURNING VALUE(r_result) TYPE abap_bool. METHODS save_log - RETURNING - VALUE(r_result) TYPE balognr - RAISING - /usi/cx_bal_root. + RETURNING VALUE(r_result) TYPE balognr + RAISING /usi/cx_bal_root. METHODS save_data_container_colls - IMPORTING - i_log_number TYPE balognr - RAISING - /usi/cx_bal_root. + IMPORTING i_log_number TYPE balognr + RAISING /usi/cx_bal_root. ENDCLASS. - CLASS /usi/cl_bal_lstate_active IMPLEMENTATION. METHOD /usi/if_bal_logger_state~add_exception. DATA: exception TYPE REF TO cx_root, - exceptions TYPE STANDARD TABLE OF REF TO cx_root WITH NON-UNIQUE DEFAULT KEY, + exceptions TYPE STANDARD TABLE OF REF TO cx_root WITH EMPTY KEY, exception_mapper TYPE REF TO /usi/if_bal_exception_mapper, target_data_cont_coll TYPE REF TO /usi/if_bal_data_container_col, unfiltered_cx_data_cont_coll TYPE REF TO /usi/if_bal_data_container_col, the_message TYPE symsg. - IF settings-log_level->is_problem_class_relevant( i_problem_class ) NE abap_true. + IF settings-log_level->is_problem_class_relevant( i_problem_class ) <> abap_true. RETURN. ENDIF. @@ -143,20 +123,20 @@ CLASS /usi/cl_bal_lstate_active IMPLEMENTATION. target_data_cont_coll = get_new_data_container_coll( ). " Add containers, that were passed by the caller (Prio 1) - IF exception EQ i_exception. + IF exception = i_exception. collect_data_containers( i_source = i_details i_target = target_data_cont_coll ). ENDIF. " Add containers, that were appended to the exception (Prio 2) - CREATE OBJECT unfiltered_cx_data_cont_coll TYPE /usi/cl_bal_dc_collection. + unfiltered_cx_data_cont_coll = NEW /usi/cl_bal_dc_collection( ). exception_mapper = factory->get_exception_mapper( exception ). exception_mapper->get_data_containers( unfiltered_cx_data_cont_coll ). collect_data_containers( i_source = unfiltered_cx_data_cont_coll i_target = target_data_cont_coll ). " Add automatic containers (Prio 3) - IF exception EQ i_exception. + IF exception = i_exception. add_caller_src_pos_container( target_data_cont_coll ). add_callstack_container( target_data_cont_coll ). ENDIF. @@ -178,11 +158,10 @@ CLASS /usi/cl_bal_lstate_active IMPLEMENTATION. ENDLOOP. ENDMETHOD. - METHOD /usi/if_bal_logger_state~add_free_text. DATA target_data_cont_coll TYPE REF TO /usi/if_bal_data_container_col. - IF settings-log_level->is_problem_class_relevant( i_problem_class ) NE abap_true. + IF settings-log_level->is_problem_class_relevant( i_problem_class ) <> abap_true. RETURN. ENDIF. @@ -206,11 +185,10 @@ CLASS /usi/cl_bal_lstate_active IMPLEMENTATION. i_message_context = i_message_context ). ENDMETHOD. - METHOD /usi/if_bal_logger_state~add_message. DATA target_data_cont_coll TYPE REF TO /usi/if_bal_data_container_col. - IF settings-log_level->is_problem_class_relevant( i_problem_class ) NE abap_true. + IF settings-log_level->is_problem_class_relevant( i_problem_class ) <> abap_true. RETURN. ENDIF. @@ -234,32 +212,26 @@ CLASS /usi/cl_bal_lstate_active IMPLEMENTATION. i_message_context = i_message_context ). ENDMETHOD. - METHOD /usi/if_bal_logger_state~claim_ownership. RAISE EXCEPTION TYPE /usi/cx_bal_not_allowed - EXPORTING - textid = /usi/cx_bal_not_allowed=>wrong_logger_state. + EXPORTING textid = /usi/cx_bal_not_allowed=>wrong_logger_state. ENDMETHOD. - METHOD /usi/if_bal_logger_state~free. - IF token->is_equal( i_token ) EQ abap_true. + IF token->is_equal( i_token ) = abap_true. dao_objects-log->free( ). ELSE. RAISE EXCEPTION TYPE /usi/cx_bal_not_allowed - EXPORTING - textid = /usi/cx_bal_not_allowed=>only_owner_may_do_that. + EXPORTING textid = /usi/cx_bal_not_allowed=>only_owner_may_do_that. ENDIF. ENDMETHOD. - METHOD /usi/if_bal_logger_state~save. DATA log_number TYPE balognr. - IF token->is_equal( i_token ) NE abap_true. + IF token->is_equal( i_token ) <> abap_true. RAISE EXCEPTION TYPE /usi/cx_bal_not_allowed - EXPORTING - textid = /usi/cx_bal_not_allowed=>only_owner_may_do_that. + EXPORTING textid = /usi/cx_bal_not_allowed=>only_owner_may_do_that. ENDIF. TRY. @@ -271,7 +243,6 @@ CLASS /usi/cl_bal_lstate_active IMPLEMENTATION. ENDTRY. ENDMETHOD. - METHOD add_caller_src_pos_container. CONSTANTS caller_level TYPE i VALUE 4. @@ -282,24 +253,19 @@ CLASS /usi/cl_bal_lstate_active IMPLEMENTATION. FIELD-SYMBOLS TYPE abap_callstack_line. CALL FUNCTION 'SYSTEM_CALLSTACK' - EXPORTING - max_level = caller_level - IMPORTING - callstack = callstack. - READ TABLE callstack ASSIGNING INDEX caller_level. + EXPORTING max_level = caller_level + IMPORTING callstack = callstack. + ASSIGN callstack[ caller_level ] TO . source_code_position-program_name = -mainprogram. source_code_position-include_name = -include. source_code_position-source_line = -line. - CREATE OBJECT new_data_container - EXPORTING - i_source_code_position = source_code_position. + new_data_container = NEW #( i_source_code_position = source_code_position ). insert_container_if_relevant( i_data_containter = new_data_container i_target_data_cont_coll = i_target_data_cont_coll ). ENDMETHOD. - METHOD add_callstack_container. CONSTANTS number_of_api_internal_calls TYPE i VALUE 3. @@ -307,38 +273,29 @@ CLASS /usi/cl_bal_lstate_active IMPLEMENTATION. callstack TYPE abap_callstack. CALL FUNCTION 'SYSTEM_CALLSTACK' - IMPORTING - callstack = callstack. + IMPORTING callstack = callstack. DELETE callstack TO number_of_api_internal_calls. - CREATE OBJECT new_data_container - EXPORTING - i_callstack = callstack. + new_data_container = NEW #( i_callstack = callstack ). insert_container_if_relevant( i_data_containter = new_data_container i_target_data_cont_coll = i_target_data_cont_coll ). ENDMETHOD. - METHOD add_cx_src_pos_container. DATA: source_code_position TYPE /usi/bal_source_code_position, new_data_container TYPE REF TO /usi/cl_bal_dc_src_pos_cx. - i_exception->get_source_position( - IMPORTING - program_name = source_code_position-program_name - include_name = source_code_position-include_name - source_line = source_code_position-source_line ). + i_exception->get_source_position( IMPORTING program_name = source_code_position-program_name + include_name = source_code_position-include_name + source_line = source_code_position-source_line ). - CREATE OBJECT new_data_container - EXPORTING - i_source_code_position = source_code_position. + new_data_container = NEW #( i_source_code_position = source_code_position ). insert_container_if_relevant( i_data_containter = new_data_container i_target_data_cont_coll = i_target_data_cont_coll ). ENDMETHOD. - METHOD collect_data_containers. DATA: data_container_collection TYPE REF TO /usi/if_bal_data_container_col, data_container TYPE REF TO /usi/if_bal_data_container, @@ -346,49 +303,49 @@ CLASS /usi/cl_bal_lstate_active IMPLEMENTATION. FIELD-SYMBOLS TYPE REF TO /usi/if_bal_data_container. - IF i_source IS BOUND. - TRY. - data_container_collection ?= i_source. - data_containers = data_container_collection->get_data_containers( ). - CATCH cx_sy_move_cast_error. - CLEAR data_container_collection. - ENDTRY. + IF i_source IS NOT BOUND. + RETURN. + ENDIF. - TRY. - data_container ?= i_source. - INSERT data_container INTO TABLE data_containers. - CATCH cx_sy_move_cast_error. - CLEAR data_container. - ENDTRY. + TRY. + data_container_collection ?= i_source. + data_containers = data_container_collection->get_data_containers( ). + CATCH cx_sy_move_cast_error. + CLEAR data_container_collection. + ENDTRY. - LOOP AT data_containers ASSIGNING . - insert_container_if_relevant( i_data_containter = - i_target_data_cont_coll = i_target ). - ENDLOOP. - ENDIF. - ENDMETHOD. + TRY. + data_container ?= i_source. + INSERT data_container INTO TABLE data_containers. + CATCH cx_sy_move_cast_error. + CLEAR data_container. + ENDTRY. + LOOP AT data_containers ASSIGNING . + insert_container_if_relevant( i_data_containter = + i_target_data_cont_coll = i_target ). + ENDLOOP. + ENDMETHOD. METHOD constructor. factory = i_factory. token = i_token. - settings-log_level = i_log_level. - settings-auto_save_pckg_size = i_auto_save_pckg_size. - settings-relevant_data_containers = i_relevant_data_containers. + settings-log_level = i_log_level. + settings-auto_save_pckg_size = i_auto_save_pckg_size. + settings-relevant_data_containers = i_relevant_data_containers. dao_objects-data_container_collection = i_data_cont_coll_dao. dao_objects-log = i_log_dao. ENDMETHOD. - METHOD get_exceptions_inverted_order. DATA previous TYPE REF TO cx_root. INSERT i_main_exception INTO TABLE r_result. " Invert the sort order of the exceptions, as previous was raised before main. - IF i_log_previous EQ abap_true. + IF i_log_previous = abap_true. previous = i_main_exception->previous. WHILE previous IS BOUND. INSERT previous INTO r_result INDEX 1. @@ -397,24 +354,21 @@ CLASS /usi/cl_bal_lstate_active IMPLEMENTATION. ENDIF. ENDMETHOD. - METHOD get_new_data_container_coll. - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_collection. + r_result = NEW /usi/cl_bal_dc_collection( ). ENDMETHOD. - METHOD insert_container_if_relevant. DATA data_container_classname TYPE /usi/bal_data_cont_classname. data_container_classname = i_data_containter->get_classname( ). - IF is_data_container_relevant( data_container_classname ) EQ abap_false. + IF is_data_container_relevant( data_container_classname ) = abap_false. RETURN. ENDIF. i_target_data_cont_coll->insert( i_data_containter ). ENDMETHOD. - METHOD insert_message. CONSTANTS: BEGIN OF callback_function, @@ -425,41 +379,40 @@ CLASS /usi/cl_bal_lstate_active IMPLEMENTATION. DATA: callback_parameter TYPE bal_s_par, message TYPE ty_message. - IF i_message_class IS INITIAL - OR i_message_type IS INITIAL. + IF i_message_class IS INITIAL + OR i_message_type IS INITIAL. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>/usi/cx_bal_invalid_input. + EXPORTING textid = /usi/cx_bal_invalid_input=>/usi/cx_bal_invalid_input. ENDIF. messages-highest_message_number = messages-highest_message_number + 1. - message-number = messages-highest_message_number. - message-message-detlevel = i_detail_level->value. - message-message-probclass = i_problem_class->value. - message-message-msgty = i_message_type->value. - message-message-msgid = i_message_class. - message-message-msgno = i_message_number. - message-message-msgv1 = i_message_variable_1. - message-message-msgv2 = i_message_variable_2. - message-message-msgv3 = i_message_variable_3. - message-message-msgv4 = i_message_variable_4. - message-message-context = i_message_context. - - IF i_data_container_collection->has_data_containers( ) EQ abap_true. + message-number = messages-highest_message_number. + message-message-detlevel = i_detail_level->value. + message-message-probclass = i_problem_class->value. + message-message-msgty = i_message_type->value. + message-message-msgid = i_message_class. + message-message-msgno = i_message_number. + message-message-msgv1 = i_message_variable_1. + message-message-msgv2 = i_message_variable_2. + message-message-msgv3 = i_message_variable_3. + message-message-msgv4 = i_message_variable_4. + message-message-context = i_message_context. + + IF i_data_container_collection->has_data_containers( ) = abap_true. message-data_container_collection = i_data_container_collection. message-message-params-callback-userexitf = callback_function-function_module. message-message-params-callback-userexitt = callback_function-callback_type. - callback_parameter-parname = /usi/cl_bal_enum_message_param=>message_number->value. - callback_parameter-parvalue = message-number. + callback_parameter-parname = /usi/cl_bal_enum_message_param=>message_number->value. + callback_parameter-parvalue = message-number. INSERT callback_parameter INTO TABLE message-message-params-t_par. ENDIF. INSERT message INTO TABLE messages-message_buffer. - IF settings-auto_save_pckg_size GT 0 - AND lines( messages-message_buffer ) GE settings-auto_save_pckg_size. + IF settings-auto_save_pckg_size > 0 + AND lines( messages-message_buffer ) >= settings-auto_save_pckg_size. TRY. /usi/if_bal_logger_state~save( token ). CATCH /usi/cx_bal_root. @@ -469,17 +422,12 @@ CLASS /usi/cl_bal_lstate_active IMPLEMENTATION. ENDIF. ENDMETHOD. - METHOD is_data_container_relevant. - READ TABLE settings-relevant_data_containers - TRANSPORTING NO FIELDS - WITH KEY table_line = i_data_container_classname. - IF sy-subrc EQ 0. + IF line_exists( settings-relevant_data_containers[ table_line = i_data_container_classname ] ). r_result = abap_true. ENDIF. ENDMETHOD. - METHOD save_data_container_colls. DATA: serialized_data_cont_coll TYPE /usi/bal_xml_string, unexpected_exception TYPE REF TO /usi/cx_bal_root, @@ -489,30 +437,31 @@ CLASS /usi/cl_bal_lstate_active IMPLEMENTATION. FIELD-SYMBOLS TYPE ty_message. LOOP AT messages-message_buffer ASSIGNING WHERE data_container_collection IS BOUND. - CHECK -data_container_collection->has_data_containers( ) EQ abap_true. + IF -data_container_collection->has_data_containers( ) = abap_false. + CONTINUE. + ENDIF. serialized_data_cont_coll = -data_container_collection->serialize( ). TRY. dao_objects-data_container_collection->insert_collection_into_buffer( - i_log_number = i_log_number - i_message_number = -number - i_serialized_data_cont_coll = serialized_data_cont_coll ). + i_log_number = i_log_number + i_message_number = -number + i_serialized_data_cont_coll = serialized_data_cont_coll ). unsaved_data_exists = abap_true. CATCH /usi/cx_bal_root INTO unexpected_exception. unexpected_exception_text = unexpected_exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS unexpected_exception_text - CONDITION unexpected_exception IS NOT BOUND. + FIELDS unexpected_exception_text + CONDITION unexpected_exception IS NOT BOUND. CONTINUE. ENDTRY. ENDLOOP. - IF unsaved_data_exists EQ abap_true. + IF unsaved_data_exists = abap_true. dao_objects-data_container_collection->save_buffer_to_db( ). ENDIF. ENDMETHOD. - METHOD save_log. DATA: unexpected_exception TYPE REF TO /usi/cx_bal_root, unexpected_exception_text TYPE string, @@ -522,8 +471,7 @@ CLASS /usi/cl_bal_lstate_active IMPLEMENTATION. IF messages-message_buffer IS INITIAL. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>log_is_empty. + EXPORTING textid = /usi/cx_bal_invalid_input=>log_is_empty. ENDIF. LOOP AT messages-message_buffer ASSIGNING . @@ -533,14 +481,14 @@ CLASS /usi/cl_bal_lstate_active IMPLEMENTATION. CATCH /usi/cx_bal_root INTO unexpected_exception. unexpected_exception_text = unexpected_exception->get_text( ). ASSERT ID /usi/bal_log_writer - FIELDS unexpected_exception_text - CONDITION unexpected_exception IS NOT BOUND. + FIELDS unexpected_exception_text + CONDITION unexpected_exception IS NOT BOUND. " Don't save the containers, if the message could not be saved! CLEAR -data_container_collection. ENDTRY. ENDLOOP. - IF unsaved_data_exists EQ abap_true. + IF unsaved_data_exists = abap_true. dao_objects-log->save( ). ENDIF. diff --git a/src/#usi#bal_logger_bl/#usi#cl_bal_lstate_active.clas.testclasses.abap b/src/#usi#bal_logger_bl/#usi#cl_bal_lstate_active.clas.testclasses.abap index 63f4283..c2709cd 100644 --- a/src/#usi#bal_logger_bl/#usi#cl_bal_lstate_active.clas.testclasses.abap +++ b/src/#usi#bal_logger_bl/#usi#cl_bal_lstate_active.clas.testclasses.abap @@ -1,8 +1,8 @@ *"* use this source file for your ABAP unit test classes -*--------------------------------------------------------------------* -* Test-Double for Log-DAO -*--------------------------------------------------------------------* +" --------------------------------------------------------------------- +" Test-Double for Log-DAO +" --------------------------------------------------------------------- CLASS lcl_dao_spy DEFINITION FINAL FOR TESTING. PUBLIC SECTION. INTERFACES /usi/if_bal_log_dao. @@ -17,16 +17,17 @@ CLASS lcl_dao_spy DEFINITION FINAL FOR TESTING. DATA method_calls TYPE REF TO /usi/cl_bal_aunit_method_calls READ-ONLY. METHODS constructor. - PRIVATE SECTION. ENDCLASS. + CLASS lcl_dao_spy IMPLEMENTATION. METHOD constructor. - CREATE OBJECT method_calls. + method_calls = NEW #( ). ENDMETHOD. METHOD /usi/if_bal_log_dao~add_message. DATA method_call TYPE REF TO /usi/cl_bal_aunit_method_call. + method_call = method_calls->insert_method_call( method_names-add_message ). method_call->add_parameter( i_parameter_name = 'I_MESSAGE' i_parameter_value = i_message ). @@ -46,9 +47,10 @@ CLASS lcl_dao_spy IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Test-Double for Data-container-collection-DAO -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Test-Double for Data-container-collection-DAO +" --------------------------------------------------------------------- CLASS lcl_data_cont_coll_dao_spy DEFINITION FINAL FOR TESTING. PUBLIC SECTION. INTERFACES /usi/if_bal_data_cont_coll_dao. @@ -57,8 +59,7 @@ CLASS lcl_data_cont_coll_dao_spy DEFINITION FINAL FOR TESTING. BEGIN OF method_names, delete_collection TYPE /usi/cl_bal_aunit_method_call=>ty_method_name VALUE 'DELETE_COLLECTION', get_collection TYPE /usi/cl_bal_aunit_method_call=>ty_method_name VALUE 'GET_COLLECTION', - insert_collection_into_buffer TYPE /usi/cl_bal_aunit_method_call=>ty_method_name - VALUE 'INSERT_COLLECTION_INTO_BUFFER', + insert_collection_into_buffer TYPE /usi/cl_bal_aunit_method_call=>ty_method_name VALUE 'INSERT_COLLECTION_INTO_BUFFER', save_buffer_to_db TYPE /usi/cl_bal_aunit_method_call=>ty_method_name VALUE 'SAVE_BUFFER_TO_DB', END OF method_names. @@ -74,9 +75,10 @@ CLASS lcl_data_cont_coll_dao_spy DEFINITION FINAL FOR TESTING. METHODS constructor. ENDCLASS. + CLASS lcl_data_cont_coll_dao_spy IMPLEMENTATION. METHOD constructor. - CREATE OBJECT method_calls. + method_calls = NEW #( ). ENDMETHOD. METHOD /usi/if_bal_data_cont_coll_dao~delete_collections. @@ -114,41 +116,37 @@ CLASS lcl_data_cont_coll_dao_spy IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Helper-class to access private components of CUT -*--------------------------------------------------------------------* +" --------------------------------------------------------------------- +" Helper-class to access private components of CUT +" --------------------------------------------------------------------- CLASS lcl_private_data DEFINITION DEFERRED. CLASS /usi/cl_bal_lstate_active DEFINITION LOCAL FRIENDS lcl_private_data. CLASS lcl_private_data DEFINITION FINAL FOR TESTING. PUBLIC SECTION. METHODS constructor - IMPORTING - i_cut TYPE REF TO /usi/if_bal_logger_state. + IMPORTING i_cut TYPE REF TO /usi/if_bal_logger_state. METHODS get_message_counter - RETURNING - VALUE(r_result) TYPE int4. + RETURNING VALUE(r_result) TYPE int4. METHODS get_message - IMPORTING - i_index TYPE int4 - RETURNING - VALUE(r_result) TYPE bal_s_msg. + IMPORTING i_index TYPE int4 + RETURNING VALUE(r_result) TYPE bal_s_msg. METHODS get_data_container_collection - IMPORTING - i_index TYPE int4 - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_data_container_col. + IMPORTING i_index TYPE int4 + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_data_container_col. PRIVATE SECTION. DATA cut TYPE REF TO /usi/cl_bal_lstate_active. ENDCLASS. + CLASS lcl_private_data IMPLEMENTATION. METHOD constructor. DATA unexpected_exception TYPE REF TO cx_sy_move_cast_error. + TRY. cut ?= i_cut. CATCH cx_sy_move_cast_error INTO unexpected_exception. @@ -163,8 +161,8 @@ CLASS lcl_private_data IMPLEMENTATION. METHOD get_message. FIELD-SYMBOLS TYPE cut->ty_message. - READ TABLE cut->messages-message_buffer ASSIGNING INDEX i_index. - IF sy-subrc NE 0. + ASSIGN cut->messages-message_buffer[ i_index ] TO . + IF sy-subrc <> 0. cl_aunit_assert=>fail( `Requested entry does not exist!` ). ENDIF. @@ -174,8 +172,8 @@ CLASS lcl_private_data IMPLEMENTATION. METHOD get_data_container_collection. FIELD-SYMBOLS TYPE cut->ty_message. - READ TABLE cut->messages-message_buffer ASSIGNING INDEX i_index. - IF sy-subrc NE 0. + ASSIGN cut->messages-message_buffer[ i_index ] TO . + IF sy-subrc <> 0. cl_aunit_assert=>fail( `Requested entry does not exist!` ). ENDIF. @@ -183,71 +181,58 @@ CLASS lcl_private_data IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Helper class: Data container factory -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Helper class: Data container factory +" --------------------------------------------------------------------- CLASS lcl_data_container_factory DEFINITION FINAL FOR TESTING. PUBLIC SECTION. CLASS-METHODS get_data_container_collection - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_data_container_col. + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_data_container_col. CLASS-METHODS get_callstack_container - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. CLASS-METHODS get_html_container - IMPORTING - i_title TYPE /usi/if_bal_text_container_c40=>ty_text OPTIONAL - i_paragraph_text TYPE string - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. + IMPORTING i_title TYPE /usi/if_bal_text_container_c40=>ty_text OPTIONAL + i_paragraph_text TYPE string + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. CLASS-METHODS get_itab_container - IMPORTING - i_title TYPE /usi/if_bal_text_container_c40=>ty_text DEFAULT 'Test' - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. + IMPORTING i_title TYPE /usi/if_bal_text_container_c40=>ty_text DEFAULT 'Test' + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. CLASS-METHODS get_retcode_msg_container - IMPORTING - i_return_code TYPE sysubrc DEFAULT 4 - i_text TYPE symsgv DEFAULT 'Test' - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. + IMPORTING i_return_code TYPE sysubrc DEFAULT 4 + i_text TYPE symsgv DEFAULT 'Test' + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. CLASS-METHODS get_src_pos_caller_container - IMPORTING - i_program_name TYPE syrepid DEFAULT 'FOO' - i_include_name TYPE include DEFAULT 'BAR' - i_source_line TYPE int4 DEFAULT 42 - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. + IMPORTING i_program_name TYPE syrepid DEFAULT 'FOO' + i_include_name TYPE include DEFAULT 'BAR' + i_source_line TYPE int4 DEFAULT 42 + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. CLASS-METHODS get_src_pos_cx_container - IMPORTING - i_program_name TYPE syrepid DEFAULT 'FOO' - i_include_name TYPE include DEFAULT 'BAR' - i_source_line TYPE int4 DEFAULT 42 - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. + IMPORTING i_program_name TYPE syrepid DEFAULT 'FOO' + i_include_name TYPE include DEFAULT 'BAR' + i_source_line TYPE int4 DEFAULT 42 + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. ENDCLASS. + CLASS lcl_data_container_factory IMPLEMENTATION. METHOD get_data_container_collection. - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_collection. + r_result = NEW /usi/cl_bal_dc_collection( ). ENDMETHOD. METHOD get_callstack_container. DATA callstack TYPE abap_callstack. CALL FUNCTION 'SYSTEM_CALLSTACK' - IMPORTING - callstack = callstack. + IMPORTING callstack = callstack. - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_callstack - EXPORTING - i_callstack = callstack. + r_result = NEW /usi/cl_bal_dc_callstack( i_callstack = callstack ). ENDMETHOD. METHOD get_html_container. @@ -255,23 +240,19 @@ CLASS lcl_data_container_factory IMPLEMENTATION. html_document TYPE string, paragraph_text TYPE string. - paragraph_text = cl_abap_dyn_prg=>escape_xss_xml_html( i_paragraph_text ). + paragraph_text = cl_abap_dyn_prg=>escape_xss_xml_html( i_paragraph_text ). CONCATENATE '

' paragraph_text '

' - INTO html_document - IN CHARACTER MODE. + INTO html_document + IN CHARACTER MODE. IF i_title IS NOT INITIAL. - CREATE OBJECT document_title TYPE /usi/cl_bal_tc_literal_c40 - EXPORTING - i_text = i_title. + document_title = NEW /usi/cl_bal_tc_literal_c40( i_text = i_title ). ENDIF. - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_html - EXPORTING - i_html_document = html_document - i_document_title = document_title. + r_result = NEW /usi/cl_bal_dc_html( i_html_document = html_document + i_document_title = document_title ). ENDMETHOD. METHOD get_itab_container. @@ -284,16 +265,12 @@ CLASS lcl_data_container_factory IMPLEMENTATION. INSERT `test` INTO TABLE string_table. IF i_title IS NOT INITIAL. - CREATE OBJECT title TYPE /usi/cl_bal_tc_literal_c40 - EXPORTING - i_text = i_title. + title = NEW /usi/cl_bal_tc_literal_c40( i_text = i_title ). ENDIF. TRY. - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_itab - EXPORTING - i_internal_table = string_table - i_title = title. + r_result = NEW /usi/cl_bal_dc_itab( i_internal_table = string_table + i_title = title ). CATCH /usi/cx_bal_root INTO unexpected_exception. /usi/cl_bal_aunit_exception=>fail_on_unexpected_exception( unexpected_exception ). ENDTRY. @@ -307,10 +284,8 @@ CLASS lcl_data_container_factory IMPLEMENTATION. message-msgty = 'E'. message-msgv1 = i_text. - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_retcode_and_msg - EXPORTING - i_message = message - i_return_code = i_return_code. + r_result = NEW /usi/cl_bal_dc_retcode_and_msg( i_message = message + i_return_code = i_return_code ). ENDMETHOD. METHOD get_src_pos_caller_container. @@ -320,9 +295,7 @@ CLASS lcl_data_container_factory IMPLEMENTATION. source_code_position-include_name = i_include_name. source_code_position-source_line = i_source_line. - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_src_pos_caller - EXPORTING - i_source_code_position = source_code_position. + r_result = NEW /usi/cl_bal_dc_src_pos_caller( i_source_code_position = source_code_position ). ENDMETHOD. METHOD get_src_pos_cx_container. @@ -332,47 +305,46 @@ CLASS lcl_data_container_factory IMPLEMENTATION. source_code_position-include_name = i_include_name. source_code_position-source_line = i_source_line. - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_src_pos_cx - EXPORTING - i_source_code_position = source_code_position. + r_result = NEW /usi/cl_bal_dc_src_pos_cx( i_source_code_position = source_code_position ). ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Helper class: Exception factory -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Helper class: Exception factory +" --------------------------------------------------------------------- CLASS lcl_exception_factory DEFINITION FINAL FOR TESTING. PUBLIC SECTION. CLASS-METHODS get_exception - IMPORTING - i_text TYPE symsgv DEFAULT 'Test exception' - i_previous TYPE REF TO cx_root OPTIONAL - i_details TYPE REF TO /usi/if_exception_details OPTIONAL - RETURNING - VALUE(r_result) TYPE REF TO /usi/cx_bal_root. + IMPORTING i_text TYPE symsgv DEFAULT 'Test exception' + i_previous TYPE REF TO cx_root OPTIONAL + i_details TYPE REF TO /usi/if_exception_details OPTIONAL + RETURNING VALUE(r_result) TYPE REF TO /usi/cx_bal_root. ENDCLASS. + CLASS lcl_exception_factory IMPLEMENTATION. METHOD get_exception. TRY. RAISE EXCEPTION TYPE /usi/cx_bal_not_found - EXPORTING - textid = /usi/cx_bal_not_found=>free_text - param1 = i_text - previous = i_previous - details = i_details. + EXPORTING textid = /usi/cx_bal_not_found=>free_text + param1 = i_text + previous = i_previous + details = i_details. CATCH /usi/cx_bal_root INTO r_result. RETURN. ENDTRY. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Delegation -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Delegation +" --------------------------------------------------------------------- CLASS lcl_unit_test_dao_delegation DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. DATA: cut TYPE REF TO /usi/if_bal_logger_state, log_dao_spy TYPE REF TO lcl_dao_spy, @@ -380,12 +352,13 @@ CLASS lcl_unit_test_dao_delegation DEFINITION FINAL FOR TESTING. token TYPE REF TO /usi/if_bal_token. METHODS setup. - METHODS test_free FOR TESTING. - METHODS test_save FOR TESTING. - METHODS test_skip_save_for_empty_log FOR TESTING. - METHODS test_save_multiple_times FOR TESTING. + METHODS test_free FOR TESTING. + METHODS test_save FOR TESTING. + METHODS test_skip_save_for_empty_log FOR TESTING. + METHODS test_save_multiple_times FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_dao_delegation IMPLEMENTATION. METHOD setup. DATA: cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory, @@ -396,21 +369,19 @@ CLASS lcl_unit_test_dao_delegation IMPLEMENTATION. cust_eval_factory = /usi/cl_bal_cust_eval_factory=>get_instance( ). logger_bl_factory = /usi/cl_bal_logger_bl_factory=>get_instance( cust_eval_factory ). token = logger_bl_factory->get_token( ). - CREATE OBJECT log_dao_spy. - CREATE OBJECT dc_coll_dao_spy. + log_dao_spy = NEW #( ). + dc_coll_dao_spy = NEW #( ). data_container_classname = /usi/cl_bal_dc_src_pos_caller=>/usi/if_bal_data_container~get_classname( ). INSERT data_container_classname INTO TABLE data_container_classnames. - CREATE OBJECT cut TYPE /usi/cl_bal_lstate_active - EXPORTING - i_factory = logger_bl_factory - i_log_level = /usi/cl_bal_enum_log_level=>everything - i_auto_save_pckg_size = 0 - i_log_dao = log_dao_spy - i_data_cont_coll_dao = dc_coll_dao_spy - i_token = token - i_relevant_data_containers = data_container_classnames. + cut = NEW /usi/cl_bal_lstate_active( i_factory = logger_bl_factory + i_log_level = /usi/cl_bal_enum_log_level=>everything + i_auto_save_pckg_size = 0 + i_log_dao = log_dao_spy + i_data_cont_coll_dao = dc_coll_dao_spy + i_token = token + i_relevant_data_containers = data_container_classnames ). ENDMETHOD. METHOD test_free. @@ -443,8 +414,7 @@ CLASS lcl_unit_test_dao_delegation IMPLEMENTATION. log_dao_spy->method_calls->assert_method_was_called( log_dao_spy->method_names-save ). " Data-Container-Collection-DAO (Saves data container collections) - dc_coll_dao_spy->method_calls->assert_method_was_called( - dc_coll_dao_spy->method_names-insert_collection_into_buffer ). + dc_coll_dao_spy->method_calls->assert_method_was_called( dc_coll_dao_spy->method_names-insert_collection_into_buffer ). dc_coll_dao_spy->method_calls->assert_method_was_called( dc_coll_dao_spy->method_names-save_buffer_to_db ). ENDMETHOD. @@ -470,7 +440,7 @@ CLASS lcl_unit_test_dao_delegation IMPLEMENTATION. " Data-Container-Collection-DAO (Saves data container collections) dc_coll_dao_spy->method_calls->assert_method_was_not_called( - dc_coll_dao_spy->method_names-insert_collection_into_buffer ). + dc_coll_dao_spy->method_names-insert_collection_into_buffer ). dc_coll_dao_spy->method_calls->assert_method_was_not_called( dc_coll_dao_spy->method_names-save_buffer_to_db ). ENDMETHOD. @@ -493,30 +463,32 @@ CLASS lcl_unit_test_dao_delegation IMPLEMENTATION. ENDTRY. log_dao_spy->method_calls->assert_method_called_n_times( - i_method_name = log_dao_spy->method_names-add_message - i_expected_number_of_calls = 1 ). + i_method_name = log_dao_spy->method_names-add_message + i_expected_number_of_calls = 1 ). log_dao_spy->method_calls->assert_method_called_n_times( - i_method_name = log_dao_spy->method_names-save - i_expected_number_of_calls = 1 ). + i_method_name = log_dao_spy->method_names-save + i_expected_number_of_calls = 1 ). dc_coll_dao_spy->method_calls->assert_method_called_n_times( - i_method_name = dc_coll_dao_spy->method_names-insert_collection_into_buffer - i_expected_number_of_calls = 1 ). + i_method_name = dc_coll_dao_spy->method_names-insert_collection_into_buffer + i_expected_number_of_calls = 1 ). dc_coll_dao_spy->method_calls->assert_method_called_n_times( - i_method_name = dc_coll_dao_spy->method_names-save_buffer_to_db - i_expected_number_of_calls = 1 ). + i_method_name = dc_coll_dao_spy->method_names-save_buffer_to_db + i_expected_number_of_calls = 1 ). CATCH /usi/cx_bal_root INTO unexpected_exception. /usi/cl_bal_aunit_exception=>fail_on_unexpected_exception( unexpected_exception ). ENDTRY. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Unbound data container collections -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Unbound data container collections +" --------------------------------------------------------------------- CLASS lcl_unit_test_unbound_dc_coll DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. DATA cut TYPE REF TO /usi/if_bal_logger_state. @@ -526,6 +498,7 @@ CLASS lcl_unit_test_unbound_dc_coll DEFINITION FINAL FOR TESTING. METHODS test_add_message FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_unbound_dc_coll IMPLEMENTATION. METHOD setup. DATA: cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory, @@ -539,8 +512,8 @@ CLASS lcl_unit_test_unbound_dc_coll IMPLEMENTATION. cust_eval_factory = /usi/cl_bal_cust_eval_factory=>get_instance( ). logger_bl_factory = /usi/cl_bal_logger_bl_factory=>get_instance( cust_eval_factory ). token = logger_bl_factory->get_token( ). - CREATE OBJECT log_dao TYPE lcl_dao_spy. - CREATE OBJECT data_container_coll_dao TYPE lcl_data_cont_coll_dao_spy. + log_dao = NEW lcl_dao_spy( ). + data_container_coll_dao = NEW lcl_data_cont_coll_dao_spy( ). relevant_data_container = /usi/cl_bal_dc_callstack=>/usi/if_bal_data_container~get_classname( ). INSERT relevant_data_container INTO TABLE relevant_data_containers. @@ -549,15 +522,13 @@ CLASS lcl_unit_test_unbound_dc_coll IMPLEMENTATION. relevant_data_container = /usi/cl_bal_dc_src_pos_cx=>/usi/if_bal_data_container~get_classname( ). INSERT relevant_data_container INTO TABLE relevant_data_containers. - CREATE OBJECT cut TYPE /usi/cl_bal_lstate_active - EXPORTING - i_factory = logger_bl_factory - i_log_level = /usi/cl_bal_enum_log_level=>everything - i_auto_save_pckg_size = 0 - i_log_dao = log_dao - i_data_cont_coll_dao = data_container_coll_dao - i_token = token - i_relevant_data_containers = relevant_data_containers. + cut = NEW /usi/cl_bal_lstate_active( i_factory = logger_bl_factory + i_log_level = /usi/cl_bal_enum_log_level=>everything + i_auto_save_pckg_size = 0 + i_log_dao = log_dao + i_data_cont_coll_dao = data_container_coll_dao + i_token = token + i_relevant_data_containers = relevant_data_containers ). ENDMETHOD. METHOD test_add_exception. @@ -605,12 +576,14 @@ CLASS lcl_unit_test_unbound_dc_coll IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Automatic creation of data containers -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Automatic creation of data containers +" --------------------------------------------------------------------- CLASS lcl_unit_test_auto_data_cont DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. DATA: cut TYPE REF TO /usi/if_bal_logger_state, dc_coll_dao_spy TYPE REF TO lcl_data_cont_coll_dao_spy, @@ -623,15 +596,14 @@ CLASS lcl_unit_test_auto_data_cont DEFINITION FINAL FOR TESTING. METHODS test_add_message FOR TESTING. METHODS get_data_container_collection - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_data_container_col. + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_data_container_col. METHODS assert_has_container - IMPORTING - i_data_container_collection TYPE REF TO /usi/if_bal_data_container_col - i_data_container_classname TYPE /usi/bal_data_cont_classname. + IMPORTING i_data_container_collection TYPE REF TO /usi/if_bal_data_container_col + i_data_container_classname TYPE /usi/bal_data_cont_classname. ENDCLASS. + CLASS lcl_unit_test_auto_data_cont IMPLEMENTATION. METHOD setup. DATA: cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory, @@ -642,8 +614,8 @@ CLASS lcl_unit_test_auto_data_cont IMPLEMENTATION. cust_eval_factory = /usi/cl_bal_cust_eval_factory=>get_instance( ). logger_bl_factory = /usi/cl_bal_logger_bl_factory=>get_instance( cust_eval_factory ). token = logger_bl_factory->get_token( ). - CREATE OBJECT log_dao_spy. - CREATE OBJECT dc_coll_dao_spy. + log_dao_spy = NEW #( ). + dc_coll_dao_spy = NEW #( ). relevant_data_container = /usi/cl_bal_dc_callstack=>/usi/if_bal_data_container~get_classname( ). INSERT relevant_data_container INTO TABLE relevant_data_containers. @@ -652,15 +624,13 @@ CLASS lcl_unit_test_auto_data_cont IMPLEMENTATION. relevant_data_container = /usi/cl_bal_dc_src_pos_cx=>/usi/if_bal_data_container~get_classname( ). INSERT relevant_data_container INTO TABLE relevant_data_containers. - CREATE OBJECT cut TYPE /usi/cl_bal_lstate_active - EXPORTING - i_factory = logger_bl_factory - i_log_level = /usi/cl_bal_enum_log_level=>everything - i_auto_save_pckg_size = 0 - i_log_dao = log_dao_spy - i_data_cont_coll_dao = dc_coll_dao_spy - i_token = token - i_relevant_data_containers = relevant_data_containers. + cut = NEW /usi/cl_bal_lstate_active( i_factory = logger_bl_factory + i_log_level = /usi/cl_bal_enum_log_level=>everything + i_auto_save_pckg_size = 0 + i_log_dao = log_dao_spy + i_data_cont_coll_dao = dc_coll_dao_spy + i_token = token + i_relevant_data_containers = relevant_data_containers ). ENDMETHOD. METHOD test_add_exception. @@ -751,11 +721,9 @@ CLASS lcl_unit_test_auto_data_cont IMPLEMENTATION. DATA: private_data TYPE REF TO lcl_private_data, message_count TYPE int4. - CREATE OBJECT private_data - EXPORTING - i_cut = cut. + private_data = NEW #( i_cut = cut ). - message_count = private_data->get_message_counter( ). + message_count = private_data->get_message_counter( ). cl_aunit_assert=>assert_equals( exp = 1 act = message_count msg = `The buffer should contain exactly one message!` ). @@ -771,7 +739,9 @@ CLASS lcl_unit_test_auto_data_cont IMPLEMENTATION. data_containers = i_data_container_collection->get_data_containers( ). LOOP AT data_containers ASSIGNING . - CHECK ->get_classname( ) EQ i_data_container_classname. + IF ->get_classname( ) <> i_data_container_classname. + CONTINUE. + ENDIF. RETURN. ENDLOOP. @@ -780,12 +750,14 @@ CLASS lcl_unit_test_auto_data_cont IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Filter data containers -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Filter data containers +" --------------------------------------------------------------------- CLASS lcl_unit_test_filter_data_cont DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. DATA: cut TYPE REF TO /usi/if_bal_logger_state, dc_coll_dao_spy TYPE REF TO lcl_data_cont_coll_dao_spy, @@ -794,12 +766,13 @@ CLASS lcl_unit_test_filter_data_cont DEFINITION FINAL FOR TESTING. token TYPE REF TO /usi/if_bal_token. METHODS setup. - METHODS test_add_exception FOR TESTING. - METHODS test_add_message FOR TESTING. - METHODS test_add_free_text FOR TESTING. + METHODS test_add_exception FOR TESTING. + METHODS test_add_message FOR TESTING. + METHODS test_add_free_text FOR TESTING. METHODS assert_collection_is_empty. ENDCLASS. + CLASS lcl_unit_test_filter_data_cont IMPLEMENTATION. METHOD setup. DATA: cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory, @@ -810,18 +783,16 @@ CLASS lcl_unit_test_filter_data_cont IMPLEMENTATION. cust_eval_factory = /usi/cl_bal_cust_eval_factory=>get_instance( ). logger_bl_factory = /usi/cl_bal_logger_bl_factory=>get_instance( cust_eval_factory ). token = logger_bl_factory->get_token( ). - CREATE OBJECT log_dao_spy. - CREATE OBJECT dc_coll_dao_spy. - - CREATE OBJECT cut TYPE /usi/cl_bal_lstate_active - EXPORTING - i_factory = logger_bl_factory - i_log_level = /usi/cl_bal_enum_log_level=>everything - i_auto_save_pckg_size = 0 - i_log_dao = log_dao_spy - i_data_cont_coll_dao = dc_coll_dao_spy - i_token = token - i_relevant_data_containers = relevant_data_containers. + log_dao_spy = NEW #( ). + dc_coll_dao_spy = NEW #( ). + + cut = NEW /usi/cl_bal_lstate_active( i_factory = logger_bl_factory + i_log_level = /usi/cl_bal_enum_log_level=>everything + i_auto_save_pckg_size = 0 + i_log_dao = log_dao_spy + i_data_cont_coll_dao = dc_coll_dao_spy + i_token = token + i_relevant_data_containers = relevant_data_containers ). irrelevant_data_cont_coll = lcl_data_container_factory=>get_data_container_collection( ). irrelevant_data_container = lcl_data_container_factory=>get_html_container( `Irrelevant container` ). @@ -886,11 +857,9 @@ CLASS lcl_unit_test_filter_data_cont IMPLEMENTATION. data_container_collection TYPE REF TO /usi/if_bal_data_container_col, has_data_containers TYPE abap_bool. - CREATE OBJECT private_data - EXPORTING - i_cut = cut. + private_data = NEW #( i_cut = cut ). - message_count = private_data->get_message_counter( ). + message_count = private_data->get_message_counter( ). cl_aunit_assert=>assert_equals( exp = 1 act = message_count msg = `The buffer should contain exactly one message!` ). @@ -906,12 +875,14 @@ CLASS lcl_unit_test_filter_data_cont IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: CUT must not return a token -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: CUT must not return a token +" --------------------------------------------------------------------- CLASS lcl_unit_test_token DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. DATA: cut TYPE REF TO /usi/if_bal_logger_state, dc_coll_dao TYPE REF TO lcl_data_cont_coll_dao_spy, @@ -925,6 +896,7 @@ CLASS lcl_unit_test_token DEFINITION FINAL FOR TESTING. METHODS add_test_message. ENDCLASS. + CLASS lcl_unit_test_token IMPLEMENTATION. METHOD setup. DATA: cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory, @@ -932,19 +904,17 @@ CLASS lcl_unit_test_token IMPLEMENTATION. token TYPE REF TO /usi/if_bal_token. logger_bl_factory = /usi/cl_bal_logger_bl_factory=>get_instance( cust_eval_factory ). - token = logger_bl_factory->get_token( ). - CREATE OBJECT log_dao. - CREATE OBJECT dc_coll_dao. + token = logger_bl_factory->get_token( ). + log_dao = NEW #( ). + dc_coll_dao = NEW #( ). - CREATE OBJECT cut TYPE /usi/cl_bal_lstate_active - EXPORTING - i_factory = logger_bl_factory - i_log_level = /usi/cl_bal_enum_log_level=>everything - i_auto_save_pckg_size = 0 - i_log_dao = log_dao - i_data_cont_coll_dao = dc_coll_dao - i_token = token - i_relevant_data_containers = relevant_data_containers. + cut = NEW /usi/cl_bal_lstate_active( i_factory = logger_bl_factory + i_log_level = /usi/cl_bal_enum_log_level=>everything + i_auto_save_pckg_size = 0 + i_log_dao = log_dao + i_data_cont_coll_dao = dc_coll_dao + i_token = token + i_relevant_data_containers = relevant_data_containers ). ENDMETHOD. METHOD test_throws_on_get_token. @@ -958,8 +928,7 @@ CLASS lcl_unit_test_token IMPLEMENTATION. ENDMETHOD. METHOD test_free_checks_token. - DATA: unexpected_exception TYPE REF TO /usi/cx_bal_root, - wrong_token TYPE REF TO /usi/if_bal_token. + DATA wrong_token TYPE REF TO /usi/if_bal_token. add_test_message( ). wrong_token = logger_bl_factory->get_token( ). @@ -974,8 +943,7 @@ CLASS lcl_unit_test_token IMPLEMENTATION. ENDMETHOD. METHOD test_save_checks_token. - DATA: unexpected_exception TYPE REF TO /usi/cx_bal_root, - wrong_token TYPE REF TO /usi/if_bal_token. + DATA wrong_token TYPE REF TO /usi/if_bal_token. add_test_message( ). wrong_token = logger_bl_factory->get_token( ). @@ -1004,12 +972,14 @@ CLASS lcl_unit_test_token IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Filtering of messages by log level -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Filtering of messages by log level +" --------------------------------------------------------------------- CLASS lcl_unit_test_msg_filter DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. DATA cut TYPE REF TO /usi/if_bal_logger_state. @@ -1026,10 +996,10 @@ CLASS lcl_unit_test_msg_filter DEFINITION FINAL FOR TESTING. METHODS assert_message_wasnt_appended. METHODS is_message_buffer_initial - RETURNING - VALUE(r_result) TYPE abap_bool. + RETURNING VALUE(r_result) TYPE abap_bool. ENDCLASS. + CLASS lcl_unit_test_msg_filter IMPLEMENTATION. METHOD setup. DATA: cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory, @@ -1042,18 +1012,16 @@ CLASS lcl_unit_test_msg_filter IMPLEMENTATION. cust_eval_factory = /usi/cl_bal_cust_eval_factory=>get_instance( ). logger_bl_factory = /usi/cl_bal_logger_bl_factory=>get_instance( cust_eval_factory ). token = logger_bl_factory->get_token( ). - CREATE OBJECT log_dao. - CREATE OBJECT dc_coll_dao. + log_dao = NEW #( ). + dc_coll_dao = NEW #( ). - CREATE OBJECT cut TYPE /usi/cl_bal_lstate_active - EXPORTING - i_factory = logger_bl_factory - i_log_level = /usi/cl_bal_enum_log_level=>very_important - i_auto_save_pckg_size = 0 - i_log_dao = log_dao - i_data_cont_coll_dao = dc_coll_dao - i_token = token - i_relevant_data_containers = relevant_data_containers. + cut = NEW /usi/cl_bal_lstate_active( i_factory = logger_bl_factory + i_log_level = /usi/cl_bal_enum_log_level=>very_important + i_auto_save_pckg_size = 0 + i_log_dao = log_dao + i_data_cont_coll_dao = dc_coll_dao + i_token = token + i_relevant_data_containers = relevant_data_containers ). ENDMETHOD. METHOD test_add_irrelevant_exception. @@ -1148,17 +1116,16 @@ CLASS lcl_unit_test_msg_filter IMPLEMENTATION. CATCH /usi/cx_bal_root INTO unexpected_exception. /usi/cl_bal_aunit_exception=>fail_on_unexpected_exception( unexpected_exception ). ENDTRY. - ENDMETHOD. METHOD assert_message_wasnt_appended. - IF is_message_buffer_initial( ) NE abap_true. + IF is_message_buffer_initial( ) <> abap_true. cl_aunit_assert=>fail( `Message buffer should be initial!` ). ENDIF. ENDMETHOD. METHOD assert_message_was_appended. - IF is_message_buffer_initial( ) EQ abap_true. + IF is_message_buffer_initial( ) = abap_true. cl_aunit_assert=>fail( `Message buffer should _NOT_ be initial!` ). ENDIF. ENDMETHOD. @@ -1167,23 +1134,23 @@ CLASS lcl_unit_test_msg_filter IMPLEMENTATION. DATA: private_data TYPE REF TO lcl_private_data, message_counter TYPE int4. - CREATE OBJECT private_data - EXPORTING - i_cut = cut. + private_data = NEW #( i_cut = cut ). message_counter = private_data->get_message_counter( ). - IF message_counter EQ 0. + IF message_counter = 0. r_result = abap_true. ENDIF. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Add previous exceptions, if requested -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Add previous exceptions, if requested +" --------------------------------------------------------------------- CLASS lcl_unit_test_log_previous DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. DATA: cut TYPE REF TO /usi/if_bal_logger_state, exception TYPE REF TO /usi/cx_bal_root, @@ -1191,29 +1158,25 @@ CLASS lcl_unit_test_log_previous DEFINITION FINAL FOR TESTING. private_data TYPE REF TO lcl_private_data. METHODS setup. - METHODS test_log_with_previous FOR TESTING. - METHODS test_log_without_previous FOR TESTING. - METHODS test_previous_data_container FOR TESTING. + METHODS test_log_with_previous FOR TESTING. + METHODS test_log_without_previous FOR TESTING. + METHODS test_previous_data_container FOR TESTING. METHODS get_exception - RETURNING - VALUE(r_result) TYPE REF TO /usi/cx_bal_root. + RETURNING VALUE(r_result) TYPE REF TO /usi/cx_bal_root. METHODS get_actual_result - IMPORTING - i_index TYPE int4 - RETURNING - VALUE(r_result) TYPE /usi/bal_data_cont_classnames. + IMPORTING i_index TYPE int4 + RETURNING VALUE(r_result) TYPE /usi/bal_data_cont_classnames. METHODS get_expected_result - IMPORTING - i_exception TYPE REF TO cx_root - i_data_container_collection TYPE REF TO /usi/if_bal_data_container_col OPTIONAL - i_is_previous TYPE abap_bool - RETURNING - VALUE(r_result) TYPE /usi/bal_data_cont_classnames. + IMPORTING i_exception TYPE REF TO cx_root + i_data_container_collection TYPE REF TO /usi/if_bal_data_container_col OPTIONAL + i_is_previous TYPE abap_bool + RETURNING VALUE(r_result) TYPE /usi/bal_data_cont_classnames. ENDCLASS. + CLASS lcl_unit_test_log_previous IMPLEMENTATION. METHOD setup. DATA: cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory, @@ -1226,8 +1189,8 @@ CLASS lcl_unit_test_log_previous IMPLEMENTATION. cust_eval_factory = /usi/cl_bal_cust_eval_factory=>get_instance( ). logger_bl_factory = /usi/cl_bal_logger_bl_factory=>get_instance( cust_eval_factory ). token = logger_bl_factory->get_token( ). - CREATE OBJECT log_dao. - CREATE OBJECT dc_coll_dao. + log_dao = NEW #( ). + dc_coll_dao = NEW #( ). relevant_data_container = /usi/cl_bal_dc_callstack=>/usi/if_bal_data_container~get_classname( ). INSERT relevant_data_container INTO TABLE relevant_data_containers. @@ -1243,19 +1206,15 @@ CLASS lcl_unit_test_log_previous IMPLEMENTATION. relevant_data_container = /usi/cl_bal_dc_itab=>/usi/if_bal_data_container~get_classname( ). INSERT relevant_data_container INTO TABLE relevant_data_containers. - CREATE OBJECT cut TYPE /usi/cl_bal_lstate_active - EXPORTING - i_factory = logger_bl_factory - i_log_level = /usi/cl_bal_enum_log_level=>everything - i_auto_save_pckg_size = 0 - i_log_dao = log_dao - i_data_cont_coll_dao = dc_coll_dao - i_token = token - i_relevant_data_containers = relevant_data_containers. + cut = NEW /usi/cl_bal_lstate_active( i_factory = logger_bl_factory + i_log_level = /usi/cl_bal_enum_log_level=>everything + i_auto_save_pckg_size = 0 + i_log_dao = log_dao + i_data_cont_coll_dao = dc_coll_dao + i_token = token + i_relevant_data_containers = relevant_data_containers ). - CREATE OBJECT private_data - EXPORTING - i_cut = cut. + private_data = NEW #( i_cut = cut ). exception = get_exception( ). ENDMETHOD. @@ -1266,20 +1225,20 @@ CLASS lcl_unit_test_log_previous IMPLEMENTATION. previous TYPE REF TO /usi/cx_bal_root. data_container = lcl_data_container_factory=>get_html_container( `Exception-specific container` ). - previous = lcl_exception_factory=>get_exception( i_text = 'Pre-Previous' - i_details = data_container ). + previous = lcl_exception_factory=>get_exception( i_text = 'Pre-Previous' + i_details = data_container ). data_container_collection = lcl_data_container_factory=>get_data_container_collection( ). data_container = lcl_data_container_factory=>get_retcode_msg_container( ). data_container_collection->insert( data_container ). - previous = lcl_exception_factory=>get_exception( i_text = 'Previous' - i_previous = previous - i_details = data_container_collection ). + previous = lcl_exception_factory=>get_exception( i_text = 'Previous' + i_previous = previous + i_details = data_container_collection ). - data_container = lcl_data_container_factory=>get_itab_container( `Exception-specific container` ). - r_result = lcl_exception_factory=>get_exception( i_text = 'The exception' - i_previous = previous - i_details = data_container ). + data_container = lcl_data_container_factory=>get_itab_container( `Exception-specific container` ). + r_result = lcl_exception_factory=>get_exception( i_text = 'The exception' + i_previous = previous + i_details = data_container ). ENDMETHOD. METHOD test_log_with_previous. @@ -1354,7 +1313,7 @@ CLASS lcl_unit_test_log_previous IMPLEMENTATION. index_starting_with_last_line = message_counter + 1 - sy-index. actual_result = get_actual_result( index_starting_with_last_line ). - IF current_exception EQ exception. + IF current_exception = exception. expected_result = get_expected_result( i_exception = current_exception i_data_container_collection = data_container_collection i_is_previous = abap_false ). @@ -1396,10 +1355,10 @@ CLASS lcl_unit_test_log_previous IMPLEMENTATION. FIELD-SYMBOLS TYPE REF TO /usi/if_bal_data_container. " Exception-Containers (directly attached to the exception itself) - exception_mapper = logger_bl_factory->get_exception_mapper( i_exception ). - exception_data_cont_coll = lcl_data_container_factory=>get_data_container_collection( ). + exception_mapper = logger_bl_factory->get_exception_mapper( i_exception ). + exception_data_cont_coll = lcl_data_container_factory=>get_data_container_collection( ). exception_mapper->get_data_containers( exception_data_cont_coll ). - data_containers = exception_data_cont_coll->get_data_containers( ). + data_containers = exception_data_cont_coll->get_data_containers( ). LOOP AT data_containers ASSIGNING . data_container_classname = ->get_classname( ). INSERT data_container_classname INTO TABLE r_result. @@ -1410,7 +1369,7 @@ CLASS lcl_unit_test_log_previous IMPLEMENTATION. INSERT data_container_classname INTO TABLE r_result. " Caller-related containers (For main-exception only!) - IF i_is_previous NE abap_true. + IF i_is_previous <> abap_true. " Auto-Containers data_container_classname = /usi/cl_bal_dc_src_pos_caller=>/usi/if_bal_data_container~get_classname( ). INSERT data_container_classname INTO TABLE r_result. @@ -1429,30 +1388,31 @@ CLASS lcl_unit_test_log_previous IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Priority of data containers -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Priority of data containers +" --------------------------------------------------------------------- CLASS lcl_unit_test_data_cont_prio DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. DATA: cut TYPE REF TO /usi/if_bal_logger_state, private_data TYPE REF TO lcl_private_data. METHODS setup. - METHODS test_add_exception FOR TESTING. - METHODS test_add_free_text FOR TESTING. - METHODS test_add_message FOR TESTING. + METHODS test_add_exception FOR TESTING. + METHODS test_add_free_text FOR TESTING. + METHODS test_add_message FOR TESTING. METHODS get_data_container_collection - RETURNING - VALUE(r_result) TYPE REF TO /usi/cl_bal_dc_collection. + RETURNING VALUE(r_result) TYPE REF TO /usi/cl_bal_dc_collection. METHODS assert_has_data_cont_coll - IMPORTING - i_data_container_collection TYPE REF TO /usi/if_bal_data_container_col. + IMPORTING i_data_container_collection TYPE REF TO /usi/if_bal_data_container_col. ENDCLASS. + CLASS lcl_unit_test_data_cont_prio IMPLEMENTATION. METHOD setup. DATA: cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory, @@ -1466,8 +1426,8 @@ CLASS lcl_unit_test_data_cont_prio IMPLEMENTATION. cust_eval_factory = /usi/cl_bal_cust_eval_factory=>get_instance( ). logger_bl_factory = /usi/cl_bal_logger_bl_factory=>get_instance( cust_eval_factory ). token = logger_bl_factory->get_token( ). - CREATE OBJECT log_dao. - CREATE OBJECT dc_coll_dao. + log_dao = NEW #( ). + dc_coll_dao = NEW #( ). relevant_data_container = /usi/cl_bal_dc_callstack=>/usi/if_bal_data_container~get_classname( ). INSERT relevant_data_container INTO TABLE relevant_data_containers. @@ -1476,19 +1436,15 @@ CLASS lcl_unit_test_data_cont_prio IMPLEMENTATION. relevant_data_container = /usi/cl_bal_dc_src_pos_cx=>/usi/if_bal_data_container~get_classname( ). INSERT relevant_data_container INTO TABLE relevant_data_containers. - CREATE OBJECT cut TYPE /usi/cl_bal_lstate_active - EXPORTING - i_factory = logger_bl_factory - i_log_level = /usi/cl_bal_enum_log_level=>everything - i_auto_save_pckg_size = 0 - i_log_dao = log_dao - i_data_cont_coll_dao = dc_coll_dao - i_token = token - i_relevant_data_containers = relevant_data_containers. + cut = NEW /usi/cl_bal_lstate_active( i_factory = logger_bl_factory + i_log_level = /usi/cl_bal_enum_log_level=>everything + i_auto_save_pckg_size = 0 + i_log_dao = log_dao + i_data_cont_coll_dao = dc_coll_dao + i_token = token + i_relevant_data_containers = relevant_data_containers ). - CREATE OBJECT private_data - EXPORTING - i_cut = cut. + private_data = NEW #( i_cut = cut ). ENDMETHOD. METHOD test_add_exception. @@ -1502,9 +1458,8 @@ CLASS lcl_unit_test_data_cont_prio IMPLEMENTATION. TRY. RAISE EXCEPTION TYPE /usi/cx_bal_not_found - EXPORTING - textid = /usi/cx_bal_not_found=>no_db_entries_found - details = data_cont_coll_exception. + EXPORTING textid = /usi/cx_bal_not_found=>no_db_entries_found + details = data_cont_coll_exception. CATCH /usi/cx_bal_root INTO exception_to_log. TRY. cut->add_exception( i_problem_class = /usi/cl_bal_enum_problem_class=>very_important @@ -1531,7 +1486,7 @@ CLASS lcl_unit_test_data_cont_prio IMPLEMENTATION. DATA: data_cont_coll_direct TYPE REF TO /usi/if_bal_data_container_col, unexpected_exception TYPE REF TO /usi/cx_bal_root. - data_cont_coll_direct = get_data_container_collection( ). + data_cont_coll_direct = get_data_container_collection( ). TRY. cut->add_free_text( i_problem_class = /usi/cl_bal_enum_problem_class=>very_important @@ -1550,7 +1505,7 @@ CLASS lcl_unit_test_data_cont_prio IMPLEMENTATION. DATA: data_cont_coll_direct TYPE REF TO /usi/if_bal_data_container_col, unexpected_exception TYPE REF TO /usi/cx_bal_root. - data_cont_coll_direct = get_data_container_collection( ). + data_cont_coll_direct = get_data_container_collection( ). TRY. cut->add_message( i_problem_class = /usi/cl_bal_enum_problem_class=>very_important @@ -1570,7 +1525,7 @@ CLASS lcl_unit_test_data_cont_prio IMPLEMENTATION. METHOD get_data_container_collection. DATA data_container TYPE REF TO /usi/if_bal_data_container. - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_collection. + r_result = NEW /usi/cl_bal_dc_collection( ). data_container = lcl_data_container_factory=>get_callstack_container( ). r_result->insert( data_container ). @@ -1591,18 +1546,15 @@ CLASS lcl_unit_test_data_cont_prio IMPLEMENTATION. FIELD-SYMBOLS TYPE REF TO /usi/if_bal_data_container. - expected_data_containers = i_data_container_collection->get_data_containers( ). + expected_data_containers = i_data_container_collection->get_data_containers( ). - actual_result_index = private_data->get_message_counter( ). - actual_data_cont_coll = private_data->get_data_container_collection( actual_result_index ). - actual_data_containers = actual_data_cont_coll->get_data_containers( ). + actual_result_index = private_data->get_message_counter( ). + actual_data_cont_coll = private_data->get_data_container_collection( actual_result_index ). + actual_data_containers = actual_data_cont_coll->get_data_containers( ). LOOP AT expected_data_containers ASSIGNING . - READ TABLE actual_data_containers - TRANSPORTING NO FIELDS - WITH TABLE KEY table_line = . - IF sy-subrc NE 0. + IF NOT line_exists( actual_data_containers[ table_line = ] ). data_container_classname = ->get_classname( ). cl_aunit_assert=>fail( msg = `Expected container not found!` detail = data_container_classname ). @@ -1611,12 +1563,14 @@ CLASS lcl_unit_test_data_cont_prio IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Verify callback functions -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Verify callback functions +" --------------------------------------------------------------------- CLASS lcl_unit_test_callback DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. DATA: cut TYPE REF TO /usi/if_bal_logger_state, log_dao TYPE REF TO lcl_dao_spy, @@ -1627,6 +1581,7 @@ CLASS lcl_unit_test_callback DEFINITION FINAL FOR TESTING. METHODS test_no_callback_without_data FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_callback IMPLEMENTATION. METHOD setup. DATA: cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory, @@ -1639,25 +1594,21 @@ CLASS lcl_unit_test_callback IMPLEMENTATION. cust_eval_factory = /usi/cl_bal_cust_eval_factory=>get_instance( ). logger_bl_factory = /usi/cl_bal_logger_bl_factory=>get_instance( cust_eval_factory ). token = logger_bl_factory->get_token( ). - CREATE OBJECT log_dao. - CREATE OBJECT dc_coll_dao. + log_dao = NEW #( ). + dc_coll_dao = NEW #( ). relevant_data_container = /usi/cl_bal_dc_html=>/usi/if_bal_data_container~get_classname( ). INSERT relevant_data_container INTO TABLE relevant_data_containers. - CREATE OBJECT cut TYPE /usi/cl_bal_lstate_active - EXPORTING - i_factory = logger_bl_factory - i_log_level = /usi/cl_bal_enum_log_level=>everything - i_auto_save_pckg_size = 0 - i_log_dao = log_dao - i_data_cont_coll_dao = dc_coll_dao - i_token = token - i_relevant_data_containers = relevant_data_containers. + cut = NEW /usi/cl_bal_lstate_active( i_factory = logger_bl_factory + i_log_level = /usi/cl_bal_enum_log_level=>everything + i_auto_save_pckg_size = 0 + i_log_dao = log_dao + i_data_cont_coll_dao = dc_coll_dao + i_token = token + i_relevant_data_containers = relevant_data_containers ). - CREATE OBJECT private_data - EXPORTING - i_cut = cut. + private_data = NEW #( i_cut = cut ). ENDMETHOD. METHOD test_message_callback. @@ -1683,11 +1634,9 @@ CLASS lcl_unit_test_callback IMPLEMENTATION. msg = `Callback function is not set!` ). CALL FUNCTION 'FUNCTION_EXISTS' - EXPORTING - funcname = logged_message-params-callback-userexitf - EXCEPTIONS - function_not_exist = 1 - OTHERS = 2. + EXPORTING funcname = logged_message-params-callback-userexitf + EXCEPTIONS function_not_exist = 1 + OTHERS = 2. return_code = sy-subrc. cl_aunit_assert=>assert_equals( exp = 0 act = return_code @@ -1716,12 +1665,14 @@ CLASS lcl_unit_test_callback IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Auto-Save -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Auto-Save +" --------------------------------------------------------------------- CLASS lcl_unit_test_auto_save DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. TYPES: BEGIN OF ty_test_objects, cut TYPE REF TO /usi/if_bal_logger_state, @@ -1729,10 +1680,8 @@ CLASS lcl_unit_test_auto_save DEFINITION FINAL FOR TESTING. END OF ty_test_objects. METHODS prepare_test - IMPORTING - i_auto_save_pckg_size TYPE /usi/bal_auto_save_pckg_size - RETURNING - VALUE(r_result) TYPE ty_test_objects. + IMPORTING i_auto_save_pckg_size TYPE /usi/bal_auto_save_pckg_size + RETURNING VALUE(r_result) TYPE ty_test_objects. METHODS test_auto_save_exception FOR TESTING. METHODS test_auto_save_free_text FOR TESTING. @@ -1740,30 +1689,28 @@ CLASS lcl_unit_test_auto_save DEFINITION FINAL FOR TESTING. METHODS test_no_early_auto_save FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_auto_save IMPLEMENTATION. METHOD prepare_test. DATA: cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory, logger_bl_factory TYPE REF TO /usi/if_bal_logger_bl_factory, dc_coll_dao TYPE REF TO lcl_data_cont_coll_dao_spy, relevant_data_containers TYPE /usi/bal_data_cont_classnames, - relevant_data_container TYPE /usi/bal_data_cont_classname, token TYPE REF TO /usi/if_bal_token. cust_eval_factory = /usi/cl_bal_cust_eval_factory=>get_instance( ). logger_bl_factory = /usi/cl_bal_logger_bl_factory=>get_instance( cust_eval_factory ). token = logger_bl_factory->get_token( ). - CREATE OBJECT r_result-log_dao. - CREATE OBJECT dc_coll_dao. + r_result-log_dao = NEW #( ). + dc_coll_dao = NEW #( ). - CREATE OBJECT r_result-cut TYPE /usi/cl_bal_lstate_active - EXPORTING - i_factory = logger_bl_factory - i_log_level = /usi/cl_bal_enum_log_level=>everything - i_auto_save_pckg_size = i_auto_save_pckg_size - i_log_dao = r_result-log_dao - i_data_cont_coll_dao = dc_coll_dao - i_token = token - i_relevant_data_containers = relevant_data_containers. + r_result-cut = NEW /usi/cl_bal_lstate_active( i_factory = logger_bl_factory + i_log_level = /usi/cl_bal_enum_log_level=>everything + i_auto_save_pckg_size = i_auto_save_pckg_size + i_log_dao = r_result-log_dao + i_data_cont_coll_dao = dc_coll_dao + i_token = token + i_relevant_data_containers = relevant_data_containers ). ENDMETHOD. METHOD test_auto_save_exception. @@ -1790,8 +1737,8 @@ CLASS lcl_unit_test_auto_save IMPLEMENTATION. ENDTRY. test_objects-log_dao->method_calls->assert_method_called_n_times( - i_method_name = test_objects-log_dao->method_names-save - i_expected_number_of_calls = 2 ). + i_method_name = test_objects-log_dao->method_names-save + i_expected_number_of_calls = 2 ). ENDMETHOD. METHOD test_auto_save_free_text. @@ -1864,12 +1811,14 @@ CLASS lcl_unit_test_auto_save IMPLEMENTATION. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Auto-Save -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Auto-Save +" --------------------------------------------------------------------- CLASS lcl_unit_test_multiple_saves DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. DATA: cut TYPE REF TO /usi/if_bal_logger_state, dc_coll_dao_spy TYPE REF TO lcl_data_cont_coll_dao_spy, @@ -1878,13 +1827,14 @@ CLASS lcl_unit_test_multiple_saves DEFINITION FINAL FOR TESTING. METHODS setup. METHODS append_and_save_message. + METHODS get_last_message_number - RETURNING - VALUE(r_result) TYPE /usi/bal_message_number. + RETURNING VALUE(r_result) TYPE /usi/bal_message_number. METHODS test_message_number_is_kept FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_multiple_saves IMPLEMENTATION. METHOD setup. DATA: cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory, @@ -1895,21 +1845,19 @@ CLASS lcl_unit_test_multiple_saves IMPLEMENTATION. cust_eval_factory = /usi/cl_bal_cust_eval_factory=>get_instance( ). logger_bl_factory = /usi/cl_bal_logger_bl_factory=>get_instance( cust_eval_factory ). token = logger_bl_factory->get_token( ). - CREATE OBJECT log_dao_spy. - CREATE OBJECT dc_coll_dao_spy. + log_dao_spy = NEW #( ). + dc_coll_dao_spy = NEW #( ). data_container_classname = /usi/cl_bal_dc_src_pos_caller=>/usi/if_bal_data_container~get_classname( ). INSERT data_container_classname INTO TABLE data_container_classnames. - CREATE OBJECT cut TYPE /usi/cl_bal_lstate_active - EXPORTING - i_factory = logger_bl_factory - i_log_level = /usi/cl_bal_enum_log_level=>everything - i_auto_save_pckg_size = 0 - i_log_dao = log_dao_spy - i_data_cont_coll_dao = dc_coll_dao_spy - i_token = token - i_relevant_data_containers = data_container_classnames. + cut = NEW /usi/cl_bal_lstate_active( i_factory = logger_bl_factory + i_log_level = /usi/cl_bal_enum_log_level=>everything + i_auto_save_pckg_size = 0 + i_log_dao = log_dao_spy + i_data_cont_coll_dao = dc_coll_dao_spy + i_token = token + i_relevant_data_containers = data_container_classnames ). ENDMETHOD. METHOD test_message_number_is_kept. @@ -1949,30 +1897,30 @@ CLASS lcl_unit_test_multiple_saves IMPLEMENTATION. FIELD-SYMBOLS TYPE /usi/cl_bal_aunit_method_calls=>ty_method_call. method_calls = dc_coll_dao_spy->method_calls->get_method_calls( - dc_coll_dao_spy->method_names-insert_collection_into_buffer ). + dc_coll_dao_spy->method_names-insert_collection_into_buffer ). cl_aunit_assert=>assert_not_initial( act = method_calls msg = 'Method was not called!' ). LOOP AT method_calls ASSIGNING . -method_call->get_parameter( - EXPORTING - i_parameter_name = dc_coll_dao_spy->parameter_names-message_number - IMPORTING - e_parameter_value = message_number ). + EXPORTING i_parameter_name = dc_coll_dao_spy->parameter_names-message_number + IMPORTING e_parameter_value = message_number ). - IF message_number GT r_result. + IF message_number > r_result. r_result = message_number. ENDIF. ENDLOOP. ENDMETHOD. ENDCLASS. -*--------------------------------------------------------------------* -* Unit test: Test consistency checks -*--------------------------------------------------------------------* + +" --------------------------------------------------------------------- +" Unit test: Test consistency checks +" --------------------------------------------------------------------- CLASS lcl_unit_test_consistency DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. CONSTANTS: BEGIN OF some_random_message, msgid TYPE symsgid VALUE '/USI/BAL', @@ -1990,32 +1938,31 @@ CLASS lcl_unit_test_consistency DEFINITION FINAL FOR TESTING. METHODS test_message_wo_msgno_accepted FOR TESTING. ENDCLASS. + CLASS lcl_unit_test_consistency IMPLEMENTATION. METHOD setup. DATA: cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory, data_container_classnames TYPE /usi/bal_data_cont_classnames, - data_container_classname TYPE /usi/bal_data_cont_classname, logger_bl_factory TYPE REF TO /usi/if_bal_logger_bl_factory. cust_eval_factory = /usi/cl_bal_cust_eval_factory=>get_instance( ). logger_bl_factory = /usi/cl_bal_logger_bl_factory=>get_instance( cust_eval_factory ). token = logger_bl_factory->get_token( ). - CREATE OBJECT log_dao_spy. - CREATE OBJECT dc_coll_dao_spy. + log_dao_spy = NEW #( ). + dc_coll_dao_spy = NEW #( ). - CREATE OBJECT cut TYPE /usi/cl_bal_lstate_active - EXPORTING - i_factory = logger_bl_factory - i_log_level = /usi/cl_bal_enum_log_level=>everything - i_auto_save_pckg_size = 0 - i_log_dao = log_dao_spy - i_data_cont_coll_dao = dc_coll_dao_spy - i_token = token - i_relevant_data_containers = data_container_classnames. + cut = NEW /usi/cl_bal_lstate_active( i_factory = logger_bl_factory + i_log_level = /usi/cl_bal_enum_log_level=>everything + i_auto_save_pckg_size = 0 + i_log_dao = log_dao_spy + i_data_cont_coll_dao = dc_coll_dao_spy + i_token = token + i_relevant_data_containers = data_container_classnames ). ENDMETHOD. METHOD test_message_wo_msgid_ignored. CONSTANTS illegal_message_id TYPE symsgid VALUE space. + TRY. cut->add_message( i_problem_class = /usi/cl_bal_enum_problem_class=>very_important i_detail_level = /usi/cl_bal_enum_detail_level=>detail_level_1 diff --git a/src/#usi#bal_logger_bl/#usi#cl_bal_lstate_invalidated.clas.testclasses.abap b/src/#usi#bal_logger_bl/#usi#cl_bal_lstate_invalidated.clas.testclasses.abap index a2aef04..0533030 100644 --- a/src/#usi#bal_logger_bl/#usi#cl_bal_lstate_invalidated.clas.testclasses.abap +++ b/src/#usi#bal_logger_bl/#usi#cl_bal_lstate_invalidated.clas.testclasses.abap @@ -24,7 +24,7 @@ CLASS lcl_unit_test IMPLEMENTATION. cust_eval_factory = /usi/cl_bal_cust_eval_factory=>get_instance( ). logger_bl_factory = /usi/cl_bal_logger_bl_factory=>get_instance( cust_eval_factory ). token = logger_bl_factory->get_token( ). - CREATE OBJECT cut TYPE /usi/cl_bal_lstate_invalidated. + cut = NEW /usi/cl_bal_lstate_invalidated( ). ENDMETHOD. METHOD test_throws_on_add_exception. diff --git a/src/#usi#bal_logger_bl/#usi#cl_bal_lstate_not_claimed.clas.testclasses.abap b/src/#usi#bal_logger_bl/#usi#cl_bal_lstate_not_claimed.clas.testclasses.abap index 50f062a..0c8e1c0 100644 --- a/src/#usi#bal_logger_bl/#usi#cl_bal_lstate_not_claimed.clas.testclasses.abap +++ b/src/#usi#bal_logger_bl/#usi#cl_bal_lstate_not_claimed.clas.testclasses.abap @@ -2,6 +2,7 @@ CLASS lcl_unit_test DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. DATA: cut TYPE REF TO /usi/if_bal_logger_state, token TYPE REF TO /usi/if_bal_token. @@ -17,6 +18,7 @@ CLASS lcl_unit_test DEFINITION FINAL FOR TESTING. METHODS test_throws_on_save FOR TESTING. ENDCLASS. + CLASS lcl_unit_test IMPLEMENTATION. METHOD setup. DATA: cust_eval_factory TYPE REF TO /usi/if_bal_cust_eval_factory, @@ -25,9 +27,7 @@ CLASS lcl_unit_test IMPLEMENTATION. cust_eval_factory = /usi/cl_bal_cust_eval_factory=>get_instance( ). logger_bl_factory = /usi/cl_bal_logger_bl_factory=>get_instance( cust_eval_factory ). - CREATE OBJECT cut TYPE /usi/cl_bal_lstate_not_claimed - EXPORTING - i_factory = logger_bl_factory. + cut = NEW /usi/cl_bal_lstate_not_claimed( i_factory = logger_bl_factory ). token = logger_bl_factory->get_token( ). ENDMETHOD. @@ -88,6 +88,7 @@ CLASS lcl_unit_test IMPLEMENTATION. METHOD test_returns_token. DATA: unexpected_exception TYPE REF TO /usi/cx_bal_root, result TYPE REF TO /usi/if_bal_token. + TRY. result = cut->claim_ownership( ). cl_aunit_assert=>assert_bound( act = result diff --git a/src/#usi#bal_logger_bl/#usi#cl_bal_token.clas.abap b/src/#usi#bal_logger_bl/#usi#cl_bal_token.clas.abap index c95626c..44d9123 100644 --- a/src/#usi#bal_logger_bl/#usi#cl_bal_token.clas.abap +++ b/src/#usi#bal_logger_bl/#usi#cl_bal_token.clas.abap @@ -12,8 +12,8 @@ ENDCLASS. CLASS /usi/cl_bal_token IMPLEMENTATION. METHOD /usi/if_bal_token~is_equal. - IF i_token IS BOUND - AND i_token EQ me. + IF i_token IS BOUND + AND i_token = me. r_result = abap_true. ENDIF. ENDMETHOD. diff --git a/src/#usi#bal_logger_bl/#usi#cl_bal_token.clas.testclasses.abap b/src/#usi#bal_logger_bl/#usi#cl_bal_token.clas.testclasses.abap index 1f33099..74493ae 100644 --- a/src/#usi#bal_logger_bl/#usi#cl_bal_token.clas.testclasses.abap +++ b/src/#usi#bal_logger_bl/#usi#cl_bal_token.clas.testclasses.abap @@ -2,20 +2,21 @@ CLASS lcl_unit_tests DEFINITION FINAL FOR TESTING. "#AU Risk_Level Harmless "#AU Duration Short + PRIVATE SECTION. METHODS assert_equals_same_instance FOR TESTING. METHODS assert_not_equals_others FOR TESTING. ENDCLASS. + CLASS lcl_unit_tests IMPLEMENTATION. METHOD assert_equals_same_instance. - DATA: cut TYPE REF TO /usi/if_bal_token, - actual_result TYPE abap_bool. + DATA cut TYPE REF TO /usi/if_bal_token. - CREATE OBJECT cut TYPE /usi/cl_bal_token. + cut = NEW /usi/cl_bal_token( ). - actual_result = cut->is_equal( cut ). + DATA(actual_result) = cut->is_equal( cut ). cl_aunit_assert=>assert_equals( exp = abap_true act = actual_result @@ -24,13 +25,12 @@ CLASS lcl_unit_tests IMPLEMENTATION. METHOD assert_not_equals_others. DATA: cut TYPE REF TO /usi/if_bal_token, - other_instance TYPE REF TO /usi/if_bal_token, - actual_result TYPE abap_bool. + other_instance TYPE REF TO /usi/if_bal_token. - CREATE OBJECT cut TYPE /usi/cl_bal_token. - CREATE OBJECT other_instance TYPE /usi/cl_bal_token. + cut = NEW /usi/cl_bal_token( ). + other_instance = NEW /usi/cl_bal_token( ). - actual_result = cut->is_equal( other_instance ). + DATA(actual_result) = cut->is_equal( other_instance ). cl_aunit_assert=>assert_equals( exp = abap_false act = actual_result diff --git a/src/#usi#bal_logger_dao/#usi#cl_bal_data_cont_coll_dao.clas.abap b/src/#usi#bal_logger_dao/#usi#cl_bal_data_cont_coll_dao.clas.abap index 1182d36..3be36f9 100644 --- a/src/#usi#bal_logger_dao/#usi#cl_bal_data_cont_coll_dao.clas.abap +++ b/src/#usi#bal_logger_dao/#usi#cl_bal_data_cont_coll_dao.clas.abap @@ -2,8 +2,6 @@ CLASS /usi/cl_bal_data_cont_coll_dao DEFINITION PUBLIC FINAL CREATE PUBLIC. PUBLIC SECTION. INTERFACES /usi/if_bal_data_cont_coll_dao. - PROTECTED SECTION. - PRIVATE SECTION. TYPES: ty_db_record TYPE /usi/bal_data, ty_db_records TYPE SORTED TABLE OF ty_db_record WITH UNIQUE KEY lognumber msgnumber record_number. @@ -13,22 +11,17 @@ CLASS /usi/cl_bal_data_cont_coll_dao DEFINITION PUBLIC FINAL CREATE PUBLIC. DATA db_records TYPE ty_db_records. METHODS convert_xml_to_db - IMPORTING - i_log_number TYPE balognr - i_message_number TYPE /usi/bal_message_number - i_serialized_data_cont_coll TYPE /usi/bal_xml_string - RETURNING - VALUE(r_result) TYPE ty_db_records. + IMPORTING i_log_number TYPE balognr + i_message_number TYPE /usi/bal_message_number + i_serialized_data_cont_coll TYPE /usi/bal_xml_string + RETURNING VALUE(r_result) TYPE ty_db_records. METHODS convert_db_to_xml - IMPORTING - i_db_records TYPE ty_db_records - RETURNING - VALUE(r_result) TYPE /usi/bal_xml_string. + IMPORTING i_db_records TYPE ty_db_records + RETURNING VALUE(r_result) TYPE /usi/bal_xml_string. ENDCLASS. - CLASS /usi/cl_bal_data_cont_coll_dao IMPLEMENTATION. METHOD /usi/if_bal_data_cont_coll_dao~delete_collections. TYPES: BEGIN OF ty_database_key, @@ -37,7 +30,7 @@ CLASS /usi/cl_bal_data_cont_coll_dao IMPLEMENTATION. msgnumber TYPE /usi/bal_message_number, record_number TYPE indx_srtf2, END OF ty_database_key, - ty_database_keys TYPE STANDARD TABLE OF ty_database_key WITH NON-UNIQUE DEFAULT KEY. + ty_database_keys TYPE STANDARD TABLE OF ty_database_key WITH EMPTY KEY. DATA database_keys TYPE ty_database_keys. @@ -46,13 +39,12 @@ CLASS /usi/cl_bal_data_cont_coll_dao IMPLEMENTATION. FROM /usi/bal_data INTO TABLE database_keys FOR ALL ENTRIES IN i_log_numbers - WHERE lognumber EQ i_log_numbers-table_line. + WHERE lognumber = i_log_numbers-table_line. DELETE /usi/bal_data FROM TABLE database_keys. ENDIF. ENDMETHOD. - METHOD /usi/if_bal_data_cont_coll_dao~get_collection. DATA db_records TYPE ty_db_records. @@ -65,18 +57,16 @@ CLASS /usi/cl_bal_data_cont_coll_dao IMPLEMENTATION. FROM /usi/bal_data INTO CORRESPONDING FIELDS OF TABLE db_records CONNECTION (db_connection) - WHERE lognumber EQ i_log_number - AND msgnumber EQ i_message_number. - IF sy-subrc NE 0. + WHERE lognumber = i_log_number + AND msgnumber = i_message_number. + IF sy-subrc <> 0. RAISE EXCEPTION TYPE /usi/cx_bal_not_found - EXPORTING - textid = /usi/cx_bal_not_found=>no_db_entries_found. + EXPORTING textid = /usi/cx_bal_not_found=>no_db_entries_found. ENDIF. r_result = convert_db_to_xml( db_records ). ENDMETHOD. - METHOD /usi/if_bal_data_cont_coll_dao~insert_collection_into_buffer. DATA: new_records TYPE ty_db_records, message_parameter_1 TYPE symsgv, @@ -94,20 +84,18 @@ CLASS /usi/cl_bal_data_cont_coll_dao IMPLEMENTATION. LOOP AT new_records ASSIGNING . INSERT INTO TABLE db_records. - IF sy-subrc NE 0. + IF sy-subrc <> 0. WRITE i_log_number TO message_parameter_1 LEFT-JUSTIFIED NO-ZERO. WRITE i_message_number TO message_parameter_2 LEFT-JUSTIFIED NO-ZERO. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - textid = /usi/cx_bal_invalid_input=>duplicate_buffer_entry - param1 = message_parameter_1 - param2 = message_parameter_2. + EXPORTING textid = /usi/cx_bal_invalid_input=>duplicate_buffer_entry + param1 = message_parameter_1 + param2 = message_parameter_2. ENDIF. ENDLOOP. ENDMETHOD. - METHOD /usi/if_bal_data_cont_coll_dao~save_buffer_to_db. DATA message_parameter_1 TYPE symsgv. @@ -118,19 +106,17 @@ CLASS /usi/cl_bal_data_cont_coll_dao IMPLEMENTATION. INSERT /usi/bal_data CONNECTION (db_connection) FROM TABLE db_records. - IF sy-subrc EQ 0. + IF sy-subrc = 0. COMMIT CONNECTION (db_connection). CLEAR db_records. ELSE. WRITE sy-subrc TO message_parameter_1 LEFT-JUSTIFIED NO-ZERO. RAISE EXCEPTION TYPE /usi/cx_bal_db_error - EXPORTING - textid = /usi/cx_bal_db_error=>/usi/cx_bal_db_error - param1 = message_parameter_1. + EXPORTING textid = /usi/cx_bal_db_error=>/usi/cx_bal_db_error + param1 = message_parameter_1. ENDIF. ENDMETHOD. - METHOD convert_db_to_xml. DATA binary_data TYPE xstring. FIELD-SYMBOLS TYPE ty_db_record. @@ -142,7 +128,6 @@ CLASS /usi/cl_bal_data_cont_coll_dao IMPLEMENTATION. IMPORT serialized_data_cont_coll TO r_result FROM DATA BUFFER binary_data. ENDMETHOD. - METHOD convert_xml_to_db. DATA: db_record TYPE ty_db_record, binary_data TYPE xstring, @@ -156,7 +141,7 @@ CLASS /usi/cl_bal_data_cont_coll_dao IMPLEMENTATION. db_record-lognumber = i_log_number. db_record-msgnumber = i_message_number. db_record-data = binary_data. - IF xstrlen( binary_data ) GE bytes_per_record. + IF xstrlen( binary_data ) >= bytes_per_record. db_record-used_bytes = bytes_per_record. ELSE. db_record-used_bytes = xstrlen( binary_data ). diff --git a/src/#usi#bal_logger_dao/#usi#cl_bal_log_dao.clas.abap b/src/#usi#bal_logger_dao/#usi#cl_bal_log_dao.clas.abap index d89ee42..75ec54b 100644 --- a/src/#usi#bal_logger_dao/#usi#cl_bal_log_dao.clas.abap +++ b/src/#usi#bal_logger_dao/#usi#cl_bal_log_dao.clas.abap @@ -4,103 +4,82 @@ CLASS /usi/cl_bal_log_dao DEFINITION PUBLIC FINAL CREATE PUBLIC. "!

Constructor

"! - "! @parameter i_log_object | Log Object (Defined in SLG0) - "! @parameter i_sub_object | Sub Object (Defined in SLG0) - "! @parameter i_external_id | External ID of the log (Filter in SLG1 - use ID of processed object if feasible) + "! @parameter i_log_object | Log Object (Defined in SLG0) + "! @parameter i_sub_object | Sub Object (Defined in SLG0) + "! @parameter i_external_id | External ID of the log (Filter in SLG1 - use ID of processed object if feasible) "! @parameter i_retention_parameters | Retention parameters - "! @parameter i_context | Context structure - "! @parameter i_params | Parameters for standard API - "! @raising /usi/cx_bal_root | Error in standard API + "! @parameter i_context | Context structure + "! @parameter i_params | Parameters for standard API + "! @raising /usi/cx_bal_root | Error in standard API METHODS constructor - IMPORTING - i_log_object TYPE balobj_d - i_sub_object TYPE balsubobj OPTIONAL - i_external_id TYPE balnrext OPTIONAL - i_retention_parameters TYPE /usi/bal_retention_parameters - i_context TYPE bal_s_cont OPTIONAL - i_params TYPE bal_s_parm OPTIONAL - RAISING - /usi/cx_bal_root. - - PROTECTED SECTION. + IMPORTING i_log_object TYPE balobj_d + i_sub_object TYPE balsubobj OPTIONAL + i_external_id TYPE balnrext OPTIONAL + i_retention_parameters TYPE /usi/bal_retention_parameters + i_context TYPE bal_s_cont OPTIONAL + i_params TYPE bal_s_parm OPTIONAL + RAISING /usi/cx_bal_root. PRIVATE SECTION. DATA: log_handle TYPE balloghndl, log_number TYPE balognr. METHODS get_log_header - IMPORTING - i_log_object TYPE balobj_d - i_sub_object TYPE balsubobj - i_external_id TYPE balnrext - i_retention_parameters TYPE /usi/bal_retention_parameters - i_context TYPE bal_s_cont - i_params TYPE bal_s_parm - RETURNING - VALUE(r_result) TYPE bal_s_log. + IMPORTING i_log_object TYPE balobj_d + i_sub_object TYPE balsubobj + i_external_id TYPE balnrext + i_retention_parameters TYPE /usi/bal_retention_parameters + i_context TYPE bal_s_cont + i_params TYPE bal_s_parm + RETURNING VALUE(r_result) TYPE bal_s_log. METHODS create_log - IMPORTING - i_log_header TYPE bal_s_log - RETURNING - VALUE(r_result) TYPE balloghndl - RAISING - /usi/cx_bal_root. + IMPORTING i_log_header TYPE bal_s_log + RETURNING VALUE(r_result) TYPE balloghndl + RAISING /usi/cx_bal_root. METHODS get_data_container_rc_and_msg - IMPORTING - VALUE(i_return_code) TYPE sysubrc - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. + IMPORTING VALUE(i_return_code) TYPE sysubrc + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_data_container. ENDCLASS. - CLASS /usi/cl_bal_log_dao IMPLEMENTATION. METHOD /usi/if_bal_log_dao~add_message. DATA data_container TYPE REF TO /usi/if_bal_data_container. CALL FUNCTION 'BAL_LOG_MSG_ADD' - EXPORTING - i_log_handle = log_handle - i_s_msg = i_message - EXCEPTIONS - log_not_found = 1 - msg_inconsistent = 2 - log_is_full = 3 - OTHERS = 4. - - IF sy-subrc NE 0. + EXPORTING i_log_handle = log_handle + i_s_msg = i_message + EXCEPTIONS log_not_found = 1 + msg_inconsistent = 2 + log_is_full = 3 + OTHERS = 4. + + IF sy-subrc <> 0. data_container = get_data_container_rc_and_msg( sy-subrc ). RAISE EXCEPTION TYPE /usi/cx_bal_external_api_error - EXPORTING - textid = /usi/cx_bal_external_api_error=>message_not_logged - details = data_container. + EXPORTING textid = /usi/cx_bal_external_api_error=>message_not_logged + details = data_container. ENDIF. ENDMETHOD. - METHOD /usi/if_bal_log_dao~free. CALL FUNCTION 'BAL_LOG_REFRESH' - EXPORTING - i_log_handle = log_handle - EXCEPTIONS - OTHERS = 0. + EXPORTING i_log_handle = log_handle + EXCEPTIONS OTHERS = 0. ENDMETHOD. - METHOD /usi/if_bal_log_dao~get_log_number. IF log_number IS NOT INITIAL. r_result = log_number. ELSE. RAISE EXCEPTION TYPE /usi/cx_bal_external_api_error - EXPORTING - textid = /usi/cx_bal_external_api_error=>save_log_first. + EXPORTING textid = /usi/cx_bal_external_api_error=>save_log_first. ENDIF. ENDMETHOD. - METHOD /usi/if_bal_log_dao~save. DATA: data_container TYPE REF TO /usi/if_bal_data_container, log_handles TYPE bal_t_logh, @@ -110,36 +89,29 @@ CLASS /usi/cl_bal_log_dao IMPLEMENTATION. INSERT log_handle INTO TABLE log_handles. CALL FUNCTION 'BAL_DB_SAVE' - EXPORTING - i_t_log_handle = log_handles - i_2th_connection = abap_true - i_2th_connect_commit = abap_true - IMPORTING - e_new_lognumbers = log_numbers - EXCEPTIONS - log_not_found = 1 - save_not_allowed = 2 - numbering_error = 3 - OTHERS = 4. - - IF sy-subrc NE 0. + EXPORTING i_t_log_handle = log_handles + i_2th_connection = abap_true + i_2th_connect_commit = abap_true + IMPORTING e_new_lognumbers = log_numbers + EXCEPTIONS log_not_found = 1 + save_not_allowed = 2 + numbering_error = 3 + OTHERS = 4. + + IF sy-subrc <> 0. data_container = get_data_container_rc_and_msg( sy-subrc ). RAISE EXCEPTION TYPE /usi/cx_bal_external_api_error - EXPORTING - textid = /usi/cx_bal_external_api_error=>log_save_error - details = data_container. + EXPORTING textid = /usi/cx_bal_external_api_error=>log_save_error + details = data_container. ELSEIF log_numbers IS NOT INITIAL. - READ TABLE log_numbers - ASSIGNING - WITH KEY extnumber = /usi/if_bal_log_dao~log_header-extnumber - log_handle = log_handle. - IF sy-subrc EQ 0. + ASSIGN log_numbers[ extnumber = /usi/if_bal_log_dao~log_header-extnumber + log_handle = log_handle ] TO . + IF sy-subrc = 0. log_number = -lognumber. ENDIF. ENDIF. ENDMETHOD. - METHOD constructor. /usi/if_bal_log_dao~log_header = get_log_header( i_log_object = i_log_object i_sub_object = i_sub_object @@ -150,40 +122,31 @@ CLASS /usi/cl_bal_log_dao IMPLEMENTATION. log_handle = create_log( /usi/if_bal_log_dao~log_header ). ENDMETHOD. - METHOD create_log. DATA data_container TYPE REF TO /usi/if_bal_data_container. CALL FUNCTION 'BAL_LOG_CREATE' - EXPORTING - i_s_log = i_log_header - IMPORTING - e_log_handle = r_result - EXCEPTIONS - log_header_inconsistent = 1 - OTHERS = 2. - IF sy-subrc NE 0. + EXPORTING i_s_log = i_log_header + IMPORTING e_log_handle = r_result + EXCEPTIONS log_header_inconsistent = 1 + OTHERS = 2. + IF sy-subrc <> 0. data_container = get_data_container_rc_and_msg( sy-subrc ). RAISE EXCEPTION TYPE /usi/cx_bal_external_api_error - EXPORTING - textid = /usi/cx_bal_external_api_error=>log_create_error - details = data_container. + EXPORTING textid = /usi/cx_bal_external_api_error=>log_create_error + details = data_container. ENDIF. ENDMETHOD. - METHOD get_data_container_rc_and_msg. DATA message TYPE symsg. MOVE-CORRESPONDING sy TO message. - CREATE OBJECT r_result TYPE /usi/cl_bal_dc_retcode_and_msg - EXPORTING - i_message = message - i_return_code = i_return_code. + r_result = NEW /usi/cl_bal_dc_retcode_and_msg( i_message = message + i_return_code = i_return_code ). ENDMETHOD. - METHOD get_log_header. r_result-extnumber = i_external_id. r_result-object = i_log_object. diff --git a/src/#usi#bal_logger_dao/#usi#cl_bal_logger_dao_factory.clas.abap b/src/#usi#bal_logger_dao/#usi#cl_bal_logger_dao_factory.clas.abap index d9cee66..67451d6 100644 --- a/src/#usi#bal_logger_dao/#usi#cl_bal_logger_dao_factory.clas.abap +++ b/src/#usi#bal_logger_dao/#usi#cl_bal_logger_dao_factory.clas.abap @@ -6,10 +6,7 @@ CLASS /usi/cl_bal_logger_dao_factory DEFINITION PUBLIC FINAL CREATE PRIVATE. "! "! @parameter r_result | Factory instance CLASS-METHODS get_instance - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_logger_dao_factory. - - PROTECTED SECTION. + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_logger_dao_factory. PRIVATE SECTION. CLASS-DATA instance TYPE REF TO /usi/if_bal_logger_dao_factory. @@ -17,28 +14,23 @@ CLASS /usi/cl_bal_logger_dao_factory DEFINITION PUBLIC FINAL CREATE PRIVATE. ENDCLASS. - CLASS /usi/cl_bal_logger_dao_factory IMPLEMENTATION. METHOD /usi/if_bal_logger_dao_factory~get_data_container_collection. - CREATE OBJECT r_result TYPE /usi/cl_bal_data_cont_coll_dao. + r_result = NEW /usi/cl_bal_data_cont_coll_dao( ). ENDMETHOD. - METHOD /usi/if_bal_logger_dao_factory~get_log. - CREATE OBJECT r_result TYPE /usi/cl_bal_log_dao - EXPORTING - i_log_object = i_log_object - i_sub_object = i_sub_object - i_external_id = i_external_id - i_retention_parameters = i_retention_parameters - i_context = i_context - i_params = i_params. + r_result = NEW /usi/cl_bal_log_dao( i_log_object = i_log_object + i_sub_object = i_sub_object + i_external_id = i_external_id + i_retention_parameters = i_retention_parameters + i_context = i_context + i_params = i_params ). ENDMETHOD. - METHOD get_instance. IF instance IS NOT BOUND. - CREATE OBJECT instance TYPE /usi/cl_bal_logger_dao_factory. + instance = NEW /usi/cl_bal_logger_dao_factory( ). ENDIF. r_result = instance. ENDMETHOD. diff --git a/src/#usi#bal_reports/#usi#bal_delete_outdated_cust.prog.abap b/src/#usi#bal_reports/#usi#bal_delete_outdated_cust.prog.abap index 6f731bc..c071a11 100644 --- a/src/#usi#bal_reports/#usi#bal_delete_outdated_cust.prog.abap +++ b/src/#usi#bal_reports/#usi#bal_delete_outdated_cust.prog.abap @@ -1,33 +1,33 @@ -*----------------------------------------------------------------------* -* Title | Delete outdated customizing * -*----------------------------------------------------------------------* -* Purpose | The tables /usi/bal_lv_clnt and /usi/bal_lv_user can be * -* | used to increase the log level for a client or user on * -* | demand to get a more verbose log. * -* | * -* | The tables can be maintained directly in the productive * -* | system as a current setting. * -* | * -* | Since a higher log level leads to more log data, the log * -* | level should only be increased temporarily. In order to * -* | enforce that, the field ENDDA has been added to the tables * -* | and the table maintenance view has been enhanced by a * -* | validation, that will refuse enddates, that are too far in * -* | the future. * -* | * -* | This report will delete all outdated entries from the * -* | tables. * -*----------------------------------------------------------------------* +" ----------------------------------------------------------------------- +" Title | Delete outdated customizing - +" ----------------------------------------------------------------------- +" Purpose | The tables /usi/bal_lv_clnt and /usi/bal_lv_user can be - +" | used to increase the log level for a client or user on - +" | demand to get a more verbose log. - +" | - +" | The tables can be maintained directly in the productive - +" | system as a current setting. - +" | - +" | Since a higher log level leads to more log data, the log - +" | level should only be increased temporarily. In order to - +" | enforce that, the field ENDDA has been added to the tables - +" | and the table maintenance view has been enhanced by a - +" | validation, that will refuse enddates, that are too far in - +" | the future. - +" | - +" | This report will delete all outdated entries from the - +" | tables. - +" ----------------------------------------------------------------------- REPORT /usi/bal_delete_outdated_cust. CLASS lcl_report DEFINITION FINAL CREATE PRIVATE. PUBLIC SECTION. CLASS-DATA singleton TYPE REF TO lcl_report READ-ONLY. + CLASS-METHODS class_constructor. METHODS run - IMPORTING - i_test_mode TYPE abap_bool. + IMPORTING i_test_mode TYPE abap_bool. PRIVATE SECTION. CONSTANTS: BEGIN OF c_table_names, @@ -39,18 +39,18 @@ CLASS lcl_report DEFINITION FINAL CREATE PRIVATE. METHODS run_productive. METHODS write_and_display_message_text - IMPORTING - i_message_text TYPE bapi_msg. + IMPORTING i_message_text TYPE bapi_msg. ENDCLASS. + CLASS lcl_report IMPLEMENTATION. METHOD class_constructor. - CREATE OBJECT singleton. + singleton = NEW #( ). ENDMETHOD. METHOD run. - IF i_test_mode EQ abap_true. + IF i_test_mode = abap_true. run_test( ). ELSE. run_productive( ). @@ -62,17 +62,15 @@ CLASS lcl_report IMPLEMENTATION. outdated_client_entries TYPE int4, outdated_user_entries TYPE int4. - SELECT COUNT( * ) - FROM /usi/bal_lv_clnt + SELECT COUNT( * ) FROM /usi/bal_lv_clnt INTO outdated_client_entries - WHERE endda LT sy-datum. + WHERE endda < sy-datum. MESSAGE s025(/usi/bal) WITH outdated_client_entries c_table_names-client INTO message_text. write_and_display_message_text( message_text ). - SELECT COUNT( * ) - FROM /usi/bal_lv_user + SELECT COUNT( * ) FROM /usi/bal_lv_user INTO outdated_user_entries - WHERE endda LT sy-datum. + WHERE endda < sy-datum. MESSAGE s025(/usi/bal) WITH outdated_user_entries c_table_names-user INTO message_text. write_and_display_message_text( message_text ). ENDMETHOD. @@ -82,15 +80,15 @@ CLASS lcl_report IMPLEMENTATION. outdated_client_entries TYPE int4, outdated_user_entries TYPE int4. - DELETE FROM /usi/bal_lv_clnt WHERE endda LT sy-datum. - IF sy-subrc EQ 0. + DELETE FROM /usi/bal_lv_clnt WHERE endda < sy-datum. + IF sy-subrc = 0. outdated_client_entries = sy-dbcnt. ENDIF. MESSAGE s026(/usi/bal) WITH outdated_client_entries c_table_names-client INTO message_text. write_and_display_message_text( message_text ). - DELETE FROM /usi/bal_lv_user WHERE endda LT sy-datum. - IF sy-subrc EQ 0. + DELETE FROM /usi/bal_lv_user WHERE endda < sy-datum. + IF sy-subrc = 0. outdated_user_entries = sy-dbcnt. ENDIF. MESSAGE s026(/usi/bal) WITH outdated_user_entries c_table_names-user INTO message_text. diff --git a/src/#usi#bal_search_helps/#usi#bal_shlp_exits.fugr.#usi#bal_shlp_data_container.abap b/src/#usi#bal_search_helps/#usi#bal_shlp_exits.fugr.#usi#bal_shlp_data_container.abap index c4da991..920343c 100644 --- a/src/#usi#bal_search_helps/#usi#bal_shlp_exits.fugr.#usi#bal_shlp_data_container.abap +++ b/src/#usi#bal_search_helps/#usi#bal_shlp_exits.fugr.#usi#bal_shlp_data_container.abap @@ -1,5 +1,5 @@ -FUNCTION /usi/bal_shlp_data_container. -*"-------------------------------------------------------------------- +FUNCTION /USI/BAL_SHLP_DATA_CONTAINER. +*"---------------------------------------------------------------------- *"*"Local Interface: *" TABLES *" SHLP_TAB TYPE SHLP_DESCT @@ -7,25 +7,20 @@ FUNCTION /usi/bal_shlp_data_container. *" CHANGING *" REFERENCE(SHLP) TYPE SHLP_DESCR *" REFERENCE(CALLCONTROL) LIKE DDSHF4CTRL STRUCTURE DDSHF4CTRL -*"-------------------------------------------------------------------- - +*"---------------------------------------------------------------------- CONSTANTS message_context_data_interface TYPE seoclsname VALUE '/USI/IF_BAL_DATA_CONTAINER'. - DATA plugin_interface TYPE REF TO lcl_plugin_interface. - - IF callcontrol-step EQ 'SELECT'. - - TRY. - CREATE OBJECT plugin_interface - EXPORTING - i_interface_name = message_context_data_interface. - record_tab[] = plugin_interface->get_implementing_classes( ). - CATCH /usi/cx_bal_root. - CLEAR record_tab[]. - ENDTRY. + IF callcontrol-step <> 'SELECT'. + RETURN. + ENDIF. - callcontrol-step = 'DISP'. + TRY. + DATA(plugin_interface) = NEW lcl_plugin_interface( message_context_data_interface ). - ENDIF. + record_tab[] = plugin_interface->get_implementing_classes( ). + CATCH /usi/cx_bal_root. + CLEAR record_tab[]. + ENDTRY. + callcontrol-step = 'DISP'. ENDFUNCTION. diff --git a/src/#usi#bal_search_helps/#usi#bal_shlp_exits.fugr.#usi#bal_shlp_exception_mapper.abap b/src/#usi#bal_search_helps/#usi#bal_shlp_exits.fugr.#usi#bal_shlp_exception_mapper.abap index e8fec09..4cc3e89 100644 --- a/src/#usi#bal_search_helps/#usi#bal_shlp_exits.fugr.#usi#bal_shlp_exception_mapper.abap +++ b/src/#usi#bal_search_helps/#usi#bal_shlp_exits.fugr.#usi#bal_shlp_exception_mapper.abap @@ -1,5 +1,5 @@ -FUNCTION /usi/bal_shlp_exception_mapper. -*"-------------------------------------------------------------------- +FUNCTION /USI/BAL_SHLP_EXCEPTION_MAPPER. +*"---------------------------------------------------------------------- *"*"Local Interface: *" TABLES *" SHLP_TAB TYPE SHLP_DESCT @@ -7,25 +7,20 @@ FUNCTION /usi/bal_shlp_exception_mapper. *" CHANGING *" REFERENCE(SHLP) TYPE SHLP_DESCR *" REFERENCE(CALLCONTROL) LIKE DDSHF4CTRL STRUCTURE DDSHF4CTRL -*"-------------------------------------------------------------------- - +*"---------------------------------------------------------------------- CONSTANTS exception_mapper_interface TYPE seoclsname VALUE '/USI/IF_BAL_EXCEPTION_MAPPER'. - DATA plugin_interface TYPE REF TO lcl_plugin_interface. - - IF callcontrol-step EQ 'SELECT'. - - TRY. - CREATE OBJECT plugin_interface - EXPORTING - i_interface_name = exception_mapper_interface. - record_tab[] = plugin_interface->get_implementing_classes( ). - CATCH /usi/cx_bal_root. - CLEAR record_tab[]. - ENDTRY. + IF callcontrol-step <> 'SELECT'. + RETURN. + ENDIF. - callcontrol-step = 'DISP'. + TRY. + DATA(plugin_interface) = NEW lcl_plugin_interface( exception_mapper_interface ). - ENDIF. + record_tab[] = plugin_interface->get_implementing_classes( ). + CATCH /usi/cx_bal_root. + CLEAR record_tab[]. + ENDTRY. + callcontrol-step = 'DISP'. ENDFUNCTION. diff --git a/src/#usi#bal_search_helps/#usi#bal_shlp_exits.fugr.#usi#lbal_shlp_exitsd01.abap b/src/#usi#bal_search_helps/#usi#bal_shlp_exits.fugr.#usi#lbal_shlp_exitsd01.abap index 6c8929b..8844a66 100644 --- a/src/#usi#bal_search_helps/#usi#bal_shlp_exits.fugr.#usi#lbal_shlp_exitsd01.abap +++ b/src/#usi#bal_search_helps/#usi#bal_shlp_exits.fugr.#usi#lbal_shlp_exitsd01.abap @@ -7,14 +7,11 @@ CLASS lcl_plugin_interface DEFINITION FINAL CREATE PUBLIC. ty_classes TYPE STANDARD TABLE OF ty_class WITH NON-UNIQUE DEFAULT KEY. METHODS constructor - IMPORTING - i_interface_name TYPE seoclsname - RAISING - /usi/cx_bal_root. + IMPORTING i_interface_name TYPE seoclsname + RAISING /usi/cx_bal_root. METHODS get_implementing_classes - RETURNING - VALUE(r_result) TYPE ty_classes. + RETURNING VALUE(r_result) TYPE ty_classes. PRIVATE SECTION. DATA interface TYPE REF TO cl_oo_interface. diff --git a/src/#usi#bal_search_helps/#usi#bal_shlp_exits.fugr.#usi#lbal_shlp_exitsp01.abap b/src/#usi#bal_search_helps/#usi#bal_shlp_exits.fugr.#usi#lbal_shlp_exitsp01.abap index 86f3a2e..3cc9157 100644 --- a/src/#usi#bal_search_helps/#usi#bal_shlp_exits.fugr.#usi#lbal_shlp_exitsp01.abap +++ b/src/#usi#bal_search_helps/#usi#bal_shlp_exits.fugr.#usi#lbal_shlp_exitsp01.abap @@ -7,52 +7,38 @@ CLASS lcl_plugin_interface IMPLEMENTATION. CATCH cx_class_not_existent cx_sy_move_cast_error INTO exception. RAISE EXCEPTION TYPE /usi/cx_bal_invalid_input - EXPORTING - previous = exception - textid = /usi/cx_bal_invalid_input=>/usi/cx_bal_invalid_input. + EXPORTING previous = exception + textid = /usi/cx_bal_invalid_input=>/usi/cx_bal_invalid_input. ENDTRY. ENDMETHOD. METHOD get_implementing_classes. - DATA: implementing_classes TYPE seo_relkeys, - subclasses TYPE seo_relkeys, - oo_object TYPE REF TO cl_oo_object, - oo_class TYPE REF TO cl_oo_class, - result_line TYPE ty_class. + DATA oo_class TYPE REF TO cl_oo_class. - FIELD-SYMBOLS: TYPE seorelkey, - TYPE seorelkey. - - implementing_classes = interface->get_implementing_classes( ). - LOOP AT implementing_classes ASSIGNING . + LOOP AT interface->get_implementing_classes( ) ASSIGNING FIELD-SYMBOL(). TRY. - oo_object = cl_oo_class=>get_instance( -clsname ). - oo_class ?= oo_object. + oo_class = CAST #( cl_oo_class=>get_instance( -clsname ) ). CATCH cx_class_not_existent cx_sy_move_cast_error. CONTINUE. ENDTRY. - IF oo_class->is_abstract( ) EQ abap_false. - result_line-classname = oo_class->class-clsname. - result_line-description = oo_class->class-descript. - INSERT result_line INTO TABLE r_result. + IF oo_class->is_abstract( ) = abap_false. + INSERT VALUE #( classname = oo_class->class-clsname + description = oo_class->class-descript ) INTO TABLE r_result. ENDIF. - subclasses = oo_class->get_subclasses( ). - LOOP AT subclasses ASSIGNING . + LOOP AT oo_class->get_subclasses( ) ASSIGNING FIELD-SYMBOL(). TRY. - oo_object = cl_oo_class=>get_instance( -clsname ). - oo_class ?= oo_object. + oo_class = CAST #( cl_oo_class=>get_instance( -clsname ) ). CATCH cx_class_not_existent cx_sy_move_cast_error. CONTINUE. ENDTRY. - IF oo_class->is_abstract( ) EQ abap_false. - result_line-classname = oo_class->class-clsname. - result_line-description = oo_class->class-descript. - INSERT result_line INTO TABLE r_result. + IF oo_class->is_abstract( ) = abap_false. + INSERT VALUE #( classname = oo_class->class-clsname + description = oo_class->class-descript ) INTO TABLE r_result. ENDIF. ENDLOOP. ENDLOOP. diff --git a/src/#usi#bal_text_containers/#usi#cl_bal_language_priority.clas.abap b/src/#usi#bal_text_containers/#usi#cl_bal_language_priority.clas.abap index f0ad29e..4618cfe 100644 --- a/src/#usi#bal_text_containers/#usi#cl_bal_language_priority.clas.abap +++ b/src/#usi#bal_text_containers/#usi#cl_bal_language_priority.clas.abap @@ -9,14 +9,11 @@ CLASS /usi/cl_bal_language_priority DEFINITION PUBLIC FINAL CREATE PRIVATE. "! "! @parameter r_result | Singleton CLASS-METHODS get_instance - RETURNING - VALUE(r_result) TYPE REF TO /usi/if_bal_language_priority. + RETURNING VALUE(r_result) TYPE REF TO /usi/if_bal_language_priority. "!

Constructor

METHODS constructor. - PROTECTED SECTION. - PRIVATE SECTION. CLASS-DATA instance TYPE REF TO /usi/if_bal_language_priority. @@ -24,29 +21,24 @@ CLASS /usi/cl_bal_language_priority DEFINITION PUBLIC FINAL CREATE PRIVATE. processed_languages TYPE HASHED TABLE OF sylangu WITH UNIQUE KEY table_line. METHODS insert_language - IMPORTING - i_language TYPE sylangu. + IMPORTING i_language TYPE sylangu. METHODS get_fallback_languages. METHODS get_fallback_language - IMPORTING - i_primary_language TYPE sylangu - RETURNING - VALUE(r_result) TYPE sylangu - RAISING - /usi/cx_bal_root. + IMPORTING i_primary_language TYPE sylangu + RETURNING VALUE(r_result) TYPE sylangu + RAISING /usi/cx_bal_root. METHODS get_other_languages. ENDCLASS. - CLASS /usi/cl_bal_language_priority IMPLEMENTATION. METHOD get_instance. IF instance IS NOT BOUND. - CREATE OBJECT instance TYPE /usi/cl_bal_language_priority. + instance = NEW /usi/cl_bal_language_priority( ). ENDIF. r_result = instance. ENDMETHOD. @@ -61,7 +53,7 @@ CLASS /usi/cl_bal_language_priority IMPLEMENTATION. DATA language TYPE /usi/if_bal_language_priority~ty_language. INSERT i_language INTO TABLE processed_languages. - IF sy-subrc EQ 0. + IF sy-subrc = 0. language-priority = lines( languages_by_priority ) + 1. language-language = i_language. INSERT language INTO TABLE languages_by_priority. @@ -83,15 +75,13 @@ CLASS /usi/cl_bal_language_priority IMPLEMENTATION. ENDMETHOD. METHOD get_fallback_language. - SELECT SINGLE lakett - FROM t002c + SELECT SINGLE lakett FROM t002c INTO r_result - WHERE spras EQ i_primary_language - AND lakett NE space. - IF sy-subrc NE 0. + WHERE spras = i_primary_language + AND lakett <> space. + IF sy-subrc <> 0. RAISE EXCEPTION TYPE /usi/cx_bal_not_found - EXPORTING - textid = /usi/cx_bal_not_found=>generic_not_found. + EXPORTING textid = /usi/cx_bal_not_found=>generic_not_found. ENDIF. ENDMETHOD. @@ -105,8 +95,7 @@ CLASS /usi/cl_bal_language_priority IMPLEMENTATION. DATA languages TYPE ty_languages. FIELD-SYMBOLS TYPE ty_language. - SELECT seqen langu - FROM t778l + SELECT seqen langu FROM t778l INTO CORRESPONDING FIELDS OF TABLE languages. LOOP AT languages ASSIGNING . diff --git a/src/#usi#bal_text_containers/#usi#cl_bal_tc_literal_c40.clas.abap b/src/#usi#bal_text_containers/#usi#cl_bal_tc_literal_c40.clas.abap index ff438ae..082a465 100644 --- a/src/#usi#bal_text_containers/#usi#cl_bal_tc_literal_c40.clas.abap +++ b/src/#usi#bal_text_containers/#usi#cl_bal_tc_literal_c40.clas.abap @@ -25,17 +25,14 @@ CLASS /usi/cl_bal_tc_literal_c40 IMPLEMENTATION. TRY. CALL TRANSFORMATION id - SOURCE XML i_serialized_text_container - RESULT text = text. + SOURCE XML i_serialized_text_container + RESULT text = text. - CREATE OBJECT r_result TYPE /usi/cl_bal_tc_literal_c40 - EXPORTING - i_text = text. + r_result = NEW /usi/cl_bal_tc_literal_c40( i_text = text ). CATCH cx_transformation_error INTO exception. RAISE EXCEPTION TYPE /usi/cx_bal_type_mismatch - EXPORTING - textid = /usi/cx_bal_type_mismatch=>/usi/cx_bal_type_mismatch - previous = exception. + EXPORTING textid = /usi/cx_bal_type_mismatch=>/usi/cx_bal_type_mismatch + previous = exception. ENDTRY. ENDMETHOD. @@ -56,8 +53,7 @@ CLASS /usi/cl_bal_tc_literal_c40 IMPLEMENTATION. RESULT XML r_result. ENDMETHOD. - METHOD constructor. - me->text = i_text. + text = i_text. ENDMETHOD. ENDCLASS. diff --git a/src/#usi#bal_text_containers/#usi#cl_bal_tc_report_text_c40.clas.abap b/src/#usi#bal_text_containers/#usi#cl_bal_tc_report_text_c40.clas.abap index d999e57..77c89d6 100644 --- a/src/#usi#bal_text_containers/#usi#cl_bal_tc_report_text_c40.clas.abap +++ b/src/#usi#bal_text_containers/#usi#cl_bal_tc_report_text_c40.clas.abap @@ -6,40 +6,33 @@ CLASS /usi/cl_bal_tc_report_text_c40 DEFINITION PUBLIC FINAL CREATE PRIVATE. "!

Create instance for any program

"! - "! @parameter i_program | Program + "! @parameter i_program | Program "! @parameter i_text_key | Text key - "! @parameter i_text | Text (Dummy - ignored internally, passing the text will avoid ATC-Messages for unused texts) - "! @parameter r_result | Text container instance + "! @parameter i_text | Text (Dummy - ignored internally, passing the text will avoid ATC-Messages for unused texts) + "! @parameter r_result | Text container instance CLASS-METHODS create_for_program - IMPORTING - i_program TYPE programm - i_text_key TYPE ty_text_key - i_text TYPE csequence OPTIONAL - RETURNING - VALUE(r_result) TYPE REF TO /usi/cl_bal_tc_report_text_c40. + IMPORTING i_program TYPE programm + i_text_key TYPE ty_text_key + i_text TYPE csequence OPTIONAL + RETURNING VALUE(r_result) TYPE REF TO /usi/cl_bal_tc_report_text_c40. "!

Create instance for current program

"! "! @parameter i_text_key | Text key - "! @parameter i_text | Text (Dummy - ignored internally, passing the text will avoid ATC-Messages for unused texts) - "! @parameter r_result | Text container instance + "! @parameter i_text | Text (Dummy - ignored internally, passing the text will avoid ATC-Messages for unused texts) + "! @parameter r_result | Text container instance CLASS-METHODS create - IMPORTING - i_text_key TYPE ty_text_key - i_text TYPE csequence OPTIONAL - RETURNING - VALUE(r_result) TYPE REF TO /usi/cl_bal_tc_report_text_c40. + IMPORTING i_text_key TYPE ty_text_key + i_text TYPE csequence OPTIONAL + RETURNING VALUE(r_result) TYPE REF TO /usi/cl_bal_tc_report_text_c40. "!

Constructor

"! - "! @parameter i_program | Program name + "! @parameter i_program | Program name "! @parameter i_text_key | Text key METHODS constructor - IMPORTING - i_program TYPE programm - i_text_key TYPE ty_text_key. - - PROTECTED SECTION. + IMPORTING i_program TYPE programm + i_text_key TYPE ty_text_key. PRIVATE SECTION. DATA: language_priority TYPE REF TO /usi/if_bal_language_priority, @@ -48,13 +41,11 @@ CLASS /usi/cl_bal_tc_report_text_c40 DEFINITION PUBLIC FINAL CREATE PRIVATE. textpool_reader TYPE REF TO /usi/if_bal_textpool_reader. CLASS-METHODS get_name_of_calling_program - RETURNING - VALUE(r_result) TYPE programm. + RETURNING VALUE(r_result) TYPE programm. ENDCLASS. - CLASS /usi/cl_bal_tc_report_text_c40 IMPLEMENTATION. METHOD /usi/if_bal_text_container_c40~deserialize. DATA: exception TYPE REF TO cx_transformation_error, @@ -63,26 +54,23 @@ CLASS /usi/cl_bal_tc_report_text_c40 IMPLEMENTATION. TRY. CALL TRANSFORMATION id - SOURCE XML i_serialized_text_container - RESULT program = program - text_key = text_key. + SOURCE XML i_serialized_text_container + RESULT program = program + text_key = text_key. - r_result = create_for_program( i_program = program - i_text_key = text_key ). + r_result = create_for_program( i_program = program + i_text_key = text_key ). CATCH cx_transformation_error INTO exception. RAISE EXCEPTION TYPE /usi/cx_bal_type_mismatch - EXPORTING - textid = /usi/cx_bal_type_mismatch=>/usi/cx_bal_type_mismatch - previous = exception. + EXPORTING textid = /usi/cx_bal_type_mismatch=>/usi/cx_bal_type_mismatch + previous = exception. ENDTRY. ENDMETHOD. - METHOD /usi/if_bal_text_container_c40~get_classname. r_result = '/USI/CL_BAL_TC_REPORT_TEXT_C40'. ENDMETHOD. - METHOD /usi/if_bal_text_container_c40~get_text. DATA languages TYPE language_priority->ty_languages. @@ -91,9 +79,9 @@ CLASS /usi/cl_bal_tc_report_text_c40 IMPLEMENTATION. languages = language_priority->get_languages( ). LOOP AT languages ASSIGNING . TRY. - r_result = textpool_reader->get_text_symbol( i_program = program - i_language = -language - i_text_symbol_key = text_key ). + r_result = textpool_reader->get_text_symbol( i_program = program + i_language = -language + i_text_symbol_key = text_key ). EXIT. CATCH /usi/cx_bal_not_found. CONTINUE. @@ -101,65 +89,52 @@ CLASS /usi/cl_bal_tc_report_text_c40 IMPLEMENTATION. ENDLOOP. ASSERT ID /usi/bal_log_writer - FIELDS program - text_key - CONDITION r_result IS NOT INITIAL. + FIELDS program + text_key + CONDITION r_result IS NOT INITIAL. ENDMETHOD. - METHOD /usi/if_bal_text_container_c40~serialize. CALL TRANSFORMATION id - SOURCE program = program - text_key = text_key - RESULT XML r_result. + SOURCE program = program + text_key = text_key + RESULT XML r_result. ENDMETHOD. - METHOD constructor. language_priority = /usi/cl_bal_language_priority=>get_instance( ). - CREATE OBJECT textpool_reader TYPE /usi/cl_bal_textpool_reader. + textpool_reader = NEW /usi/cl_bal_textpool_reader( ). - program = i_program. - text_key = i_text_key. + program = i_program. + text_key = i_text_key. SET LOCALE LANGUAGE sy-langu. - TRANSLATE text_key TO UPPER CASE. + text_key = to_upper( text_key ). ENDMETHOD. - METHOD create. - DATA program TYPE programm. - program = get_name_of_calling_program( ). - CREATE OBJECT r_result - EXPORTING - i_program = program - i_text_key = i_text_key. + r_result = NEW #( i_program = get_name_of_calling_program( ) + i_text_key = i_text_key ). ENDMETHOD. - METHOD create_for_program. - CREATE OBJECT r_result - EXPORTING - i_program = i_program - i_text_key = i_text_key. + r_result = NEW #( i_program = i_program + i_text_key = i_text_key ). ENDMETHOD. - METHOD get_name_of_calling_program. DATA callstack TYPE abap_callstack. FIELD-SYMBOLS TYPE abap_callstack_line. CALL FUNCTION 'SYSTEM_CALLSTACK' - EXPORTING - max_level = 0 - IMPORTING - callstack = callstack. + EXPORTING max_level = 0 + IMPORTING callstack = callstack. DELETE ADJACENT DUPLICATES FROM callstack COMPARING mainprogram. - READ TABLE callstack ASSIGNING INDEX 2. - IF sy-subrc NE 0. - READ TABLE callstack ASSIGNING INDEX 1. + ASSIGN callstack[ 2 ] TO . + IF sy-subrc <> 0. + ASSIGN callstack[ 1 ] TO . ENDIF. r_result = -mainprogram. diff --git a/src/#usi#bal_text_containers/#usi#cl_bal_textpool_reader.clas.abap b/src/#usi#bal_text_containers/#usi#cl_bal_textpool_reader.clas.abap index f0f1c07..6bcdc67 100644 --- a/src/#usi#bal_text_containers/#usi#cl_bal_textpool_reader.clas.abap +++ b/src/#usi#bal_text_containers/#usi#cl_bal_textpool_reader.clas.abap @@ -2,8 +2,6 @@ CLASS /usi/cl_bal_textpool_reader DEFINITION PUBLIC FINAL CREATE PUBLIC. PUBLIC SECTION. INTERFACES /usi/if_bal_textpool_reader. - PROTECTED SECTION. - PRIVATE SECTION. CONSTANTS: BEGIN OF text_types, selection_text TYPE textpoolid VALUE 'S', @@ -11,33 +9,29 @@ CLASS /usi/cl_bal_textpool_reader DEFINITION PUBLIC FINAL CREATE PUBLIC. END OF text_types. METHODS get_textpool_line - IMPORTING - i_program TYPE syrepid - i_language TYPE sylangu - i_id TYPE textpoolid - i_key TYPE csequence - RETURNING - VALUE(r_result) TYPE textpooltx - RAISING - /usi/cx_bal_not_found. + IMPORTING i_program TYPE syrepid + i_language TYPE sylangu + i_id TYPE textpoolid + i_key TYPE csequence + RETURNING VALUE(r_result) TYPE textpooltx + RAISING /usi/cx_bal_not_found. ENDCLASS. - CLASS /usi/cl_bal_textpool_reader IMPLEMENTATION. METHOD /usi/if_bal_textpool_reader~get_selection_text. - r_result = get_textpool_line( i_program = i_program - i_language = i_language - i_id = text_types-selection_text - i_key = i_selection_text_key ). + r_result = get_textpool_line( i_program = i_program + i_language = i_language + i_id = text_types-selection_text + i_key = i_selection_text_key ). ENDMETHOD. METHOD /usi/if_bal_textpool_reader~get_text_symbol. - r_result = get_textpool_line( i_program = i_program - i_language = i_language - i_id = text_types-text_symbol - i_key = i_text_symbol_key ). + r_result = get_textpool_line( i_program = i_program + i_language = i_language + i_id = text_types-text_symbol + i_key = i_text_symbol_key ). ENDMETHOD. METHOD /usi/if_bal_textpool_reader~get_textpool. @@ -46,15 +40,14 @@ CLASS /usi/cl_bal_textpool_reader IMPLEMENTATION. READ TEXTPOOL i_program INTO r_result LANGUAGE i_language. - IF sy-subrc NE 0. + IF sy-subrc <> 0. message_variable_1 = i_program. message_variable_2 = i_language. RAISE EXCEPTION TYPE /usi/cx_bal_not_found - EXPORTING - textid = /usi/cx_bal_not_found=>textpool_not_found - param1 = message_variable_1 - param2 = message_variable_2. + EXPORTING textid = /usi/cx_bal_not_found=>textpool_not_found + param1 = message_variable_1 + param2 = message_variable_2. ENDIF. ENDMETHOD. @@ -70,12 +63,10 @@ CLASS /usi/cl_bal_textpool_reader IMPLEMENTATION. textpool = /usi/if_bal_textpool_reader~get_textpool( i_program = i_program i_language = i_language ). - READ TABLE textpool - ASSIGNING - WITH KEY id = i_id - key = i_key. + ASSIGN textpool[ id = i_id + key = i_key ] TO . - IF sy-subrc EQ 0. + IF sy-subrc = 0. r_result = -entry. ELSE. message_variable_1 = i_id. @@ -84,12 +75,11 @@ CLASS /usi/cl_bal_textpool_reader IMPLEMENTATION. message_variable_4 = i_language. RAISE EXCEPTION TYPE /usi/cx_bal_not_found - EXPORTING - textid = /usi/cx_bal_not_found=>text_not_found_in_textpool - param1 = message_variable_1 - param2 = message_variable_2 - param3 = message_variable_3 - param4 = message_variable_4. + EXPORTING textid = /usi/cx_bal_not_found=>text_not_found_in_textpool + param1 = message_variable_1 + param2 = message_variable_2 + param3 = message_variable_3 + param4 = message_variable_4. ENDIF. ENDMETHOD. ENDCLASS. diff --git a/src/#usi#bal_ui/#usi#bal_popups.fugr.#usi#bal_popup_message_details.abap b/src/#usi#bal_ui/#usi#bal_popups.fugr.#usi#bal_popup_message_details.abap index 2279d97..f509f6f 100644 --- a/src/#usi#bal_ui/#usi#bal_popups.fugr.#usi#bal_popup_message_details.abap +++ b/src/#usi#bal_ui/#usi#bal_popups.fugr.#usi#bal_popup_message_details.abap @@ -12,9 +12,7 @@ FUNCTION /usi/bal_popup_message_details. DATA exception TYPE REF TO /usi/cx_bal_root. TRY. - CREATE OBJECT screen_controller TYPE lcl_log_message_detail - EXPORTING - i_message_parameters = i_t_params[]. + screen_controller = NEW lcl_log_message_detail( i_message_parameters = i_t_params[] ). CALL SCREEN 2000 STARTING AT dynpro_start_position-column dynpro_start_position-line. diff --git a/src/#usi#bal_ui/#usi#bal_popups.fugr.#usi#lbal_popupsd02.abap b/src/#usi#bal_ui/#usi#bal_popups.fugr.#usi#lbal_popupsd02.abap index 7fb8d4a..9e8b188 100644 --- a/src/#usi#bal_ui/#usi#bal_popups.fugr.#usi#lbal_popupsd02.abap +++ b/src/#usi#bal_ui/#usi#bal_popups.fugr.#usi#lbal_popupsd02.abap @@ -13,7 +13,7 @@ CLASS lcl_data_container_selector DEFINITION FINAL CREATE PUBLIC. VALUE(container) TYPE REF TO /usi/if_bal_data_container. PRIVATE SECTION. - TYPES: ty_tree_items TYPE STANDARD TABLE OF mtreeitm WITH NON-UNIQUE DEFAULT KEY, + TYPES: ty_tree_items TYPE STANDARD TABLE OF mtreeitm WITH EMPTY KEY, ty_data_container_type TYPE c LENGTH 1. TYPES: BEGIN OF ty_sorted_data_container, diff --git a/src/#usi#bal_ui/#usi#bal_popups.fugr.#usi#lbal_popupsp02.abap b/src/#usi#bal_ui/#usi#bal_popups.fugr.#usi#lbal_popupsp02.abap index 0fbe371..9b83977 100644 --- a/src/#usi#bal_ui/#usi#bal_popups.fugr.#usi#lbal_popupsp02.abap +++ b/src/#usi#bal_ui/#usi#bal_popups.fugr.#usi#lbal_popupsp02.abap @@ -1,6 +1,7 @@ CLASS lcl_data_container_selector IMPLEMENTATION. METHOD constructor. DATA sorted_data_containers TYPE ty_sorted_data_containers. + sorted_data_containers = sort_data_containers( i_data_container_collection ). insert_data_containers( sorted_data_containers ). ENDMETHOD. @@ -13,10 +14,10 @@ CLASS lcl_data_container_selector IMPLEMENTATION. data_containers = i_data_container_collection->get_data_containers( ). LOOP AT data_containers ASSIGNING . - sorted_data_container-type = get_data_container_type( ). - sorted_data_container-classname = ->get_classname( ). - sorted_data_container-description = ->get_description( ). - sorted_data_container-data_container = . + sorted_data_container-type = get_data_container_type( ). + sorted_data_container-classname = ->get_classname( ). + sorted_data_container-description = ->get_description( ). + sorted_data_container-data_container = . INSERT sorted_data_container INTO TABLE r_result. ENDLOOP. ENDMETHOD. @@ -50,17 +51,17 @@ CLASS lcl_data_container_selector IMPLEMENTATION. CASE -type. WHEN data_container_types-renderer. - needed_data_container_groups-renderer = abap_true. - icon = icon_select_detail. - parent_node = node_keys-renderer. + needed_data_container_groups-renderer = abap_true. + icon = icon_select_detail. + parent_node = node_keys-renderer. WHEN data_container_types-navigator. - needed_data_container_groups-navigator = abap_true. - icon = icon_reference_list. - parent_node = node_keys-navigator. + needed_data_container_groups-navigator = abap_true. + icon = icon_reference_list. + parent_node = node_keys-navigator. WHEN OTHERS. - needed_data_container_groups-unknown = abap_true. - icon = icon_failure. - parent_node = node_keys-unknown. + needed_data_container_groups-unknown = abap_true. + icon = icon_failure. + parent_node = node_keys-unknown. ENDCASE. insert_node_and_item_container( i_node_key = node_container-node_key @@ -70,19 +71,19 @@ CLASS lcl_data_container_selector IMPLEMENTATION. ENDLOOP. " Create folders for container types - IF needed_data_container_groups-unknown EQ abap_true. + IF needed_data_container_groups-unknown = abap_true. " Node: Unknown insert_node_and_item_folder( i_node_key = node_keys-unknown i_parent = node_keys-root i_text = TEXT-nuk ). ENDIF. - IF needed_data_container_groups-navigator EQ abap_true. + IF needed_data_container_groups-navigator = abap_true. " Node: Navigator insert_node_and_item_folder( i_node_key = node_keys-navigator i_parent = node_keys-root i_text = TEXT-nnv ). ENDIF. - IF needed_data_container_groups-navigator EQ abap_true. + IF needed_data_container_groups-navigator = abap_true. " Node: Renderer insert_node_and_item_folder( i_node_key = node_keys-renderer i_parent = node_keys-root @@ -119,48 +120,40 @@ CLASS lcl_data_container_selector IMPLEMENTATION. item TYPE mtreeitm. CLEAR node. - node-node_key = i_node_key. - node-relatkey = i_parent. - node-isfolder = abap_true. + node-node_key = i_node_key. + node-relatkey = i_parent. + node-isfolder = abap_true. INSERT node INTO nodes INDEX 1. CLEAR item. - item-node_key = i_node_key. - item-item_name = '1'. - item-class = cl_gui_list_tree=>item_class_text. - item-alignment = cl_gui_list_tree=>align_auto. - item-font = cl_gui_list_tree=>item_font_prop. - item-text = i_text. + item-node_key = i_node_key. + item-item_name = '1'. + item-class = cl_gui_list_tree=>item_class_text. + item-alignment = cl_gui_list_tree=>align_auto. + item-font = cl_gui_list_tree=>item_font_prop. + item-text = i_text. INSERT item INTO items INDEX 1. ENDMETHOD. METHOD render. CREATE OBJECT tree_control - EXPORTING - parent = i_container - node_selection_mode = cl_gui_list_tree=>node_sel_mode_single - item_selection = abap_true - with_headers = abap_false - EXCEPTIONS - OTHERS = 0. + EXPORTING parent = i_container + node_selection_mode = cl_gui_list_tree=>node_sel_mode_single + item_selection = abap_true + with_headers = abap_false + EXCEPTIONS OTHERS = 0. register_events( ). SET HANDLER on_tree_item_double_click FOR tree_control. SET HANDLER on_tree_node_double_click FOR tree_control. - tree_control->add_nodes_and_items( - EXPORTING - node_table = nodes - item_table = items - item_table_structure_name = 'MTREEITM' - EXCEPTIONS - OTHERS = 0 ). - - tree_control->expand_root_nodes( - EXPORTING - expand_subtree = abap_true - EXCEPTIONS - OTHERS = 0 ). + tree_control->add_nodes_and_items( EXPORTING node_table = nodes + item_table = items + item_table_structure_name = 'MTREEITM' + EXCEPTIONS OTHERS = 0 ). + + tree_control->expand_root_nodes( EXPORTING expand_subtree = abap_true + EXCEPTIONS OTHERS = 0 ). ENDMETHOD. METHOD register_events. @@ -175,24 +168,19 @@ CLASS lcl_data_container_selector IMPLEMENTATION. tree_event-appl_event = abap_true. INSERT tree_event INTO TABLE tree_events. - tree_control->set_registered_events( - EXPORTING - events = tree_events - EXCEPTIONS - OTHERS = 0 ). + tree_control->set_registered_events( EXPORTING events = tree_events + EXCEPTIONS OTHERS = 0 ). ENDMETHOD. METHOD on_tree_item_double_click. FIELD-SYMBOLS TYPE ty_node_container. - READ TABLE node_containers - ASSIGNING - WITH TABLE KEY node_key = node_key. + ASSIGN node_containers[ node_key = node_key ] TO . - IF sy-subrc EQ 0. + IF sy-subrc = 0. RAISE EVENT select_container - EXPORTING - container = -data_container. + EXPORTING + container = -data_container. ENDIF. ENDMETHOD. @@ -201,7 +189,9 @@ CLASS lcl_data_container_selector IMPLEMENTATION. ENDMETHOD. METHOD get_data_container_type. + " TODO: variable is assigned but never used (ABAP cleaner) DATA: navigator TYPE REF TO /usi/if_bal_data_container_nav, + " TODO: variable is assigned but never used (ABAP cleaner) renderer TYPE REF TO /usi/if_bal_data_container_rnd. TRY. diff --git a/src/#usi#bal_ui/#usi#bal_popups.fugr.#usi#lbal_popupsp03.abap b/src/#usi#bal_ui/#usi#bal_popups.fugr.#usi#lbal_popupsp03.abap index 31e9c3c..a0fbab1 100644 --- a/src/#usi#bal_ui/#usi#bal_popups.fugr.#usi#lbal_popupsp03.abap +++ b/src/#usi#bal_ui/#usi#bal_popups.fugr.#usi#lbal_popupsp03.abap @@ -6,11 +6,9 @@ CLASS lcl_log_message_detail IMPLEMENTATION. message_parameters = get_message_parameters( i_message_parameters ). serialized_data_cont_coll = get_serialized_data_cont_coll( message_parameters ). data_container_collection = /usi/cl_bal_dc_collection=>/usi/if_bal_data_container_col~deserialize( - serialized_data_cont_coll ). + serialized_data_cont_coll ). - CREATE OBJECT data_container_selector - EXPORTING - i_data_container_collection = data_container_collection. + data_container_selector = NEW #( i_data_container_collection = data_container_collection ). ENDMETHOD. METHOD get_message_parameters. @@ -19,9 +17,9 @@ CLASS lcl_log_message_detail IMPLEMENTATION. LOOP AT i_message_parameters ASSIGNING . CASE -parname. WHEN /usi/cl_bal_enum_message_param=>log_number->value. - r_result-log_number = -parvalue. + r_result-log_number = -parvalue. WHEN /usi/cl_bal_enum_message_param=>message_number->value. - r_result-message_number = -parvalue. + r_result-message_number = -parvalue. ENDCASE. ENDLOOP. ENDMETHOD. @@ -33,8 +31,8 @@ CLASS lcl_log_message_detail IMPLEMENTATION. dao_factory = /usi/cl_bal_logger_dao_factory=>get_instance( ). data_container_collection_dao = dao_factory->get_data_container_collection( ). r_result = data_container_collection_dao->get_collection( - i_log_number = i_message_parameters-log_number - i_message_number = i_message_parameters-message_number ). + i_log_number = i_message_parameters-log_number + i_message_number = i_message_parameters-message_number ). ENDMETHOD. METHOD lif_screen_controller~set_status. @@ -64,18 +62,14 @@ CLASS lcl_log_message_detail IMPLEMENTATION. ENDIF. CREATE OBJECT main_container - EXPORTING - container_name = 'CUSTOM_CONTROL_2000' - EXCEPTIONS - OTHERS = 0. + EXPORTING container_name = 'CUSTOM_CONTROL_2000' + EXCEPTIONS OTHERS = 0. CREATE OBJECT splitter_container - EXPORTING - parent = main_container - rows = 1 - columns = 2 - EXCEPTIONS - OTHERS = 0. + EXPORTING parent = main_container + rows = 1 + columns = 2 + EXCEPTIONS OTHERS = 0. splitter_container->set_column_width( id = 1 width = 25 ). @@ -116,11 +110,11 @@ CLASS lcl_log_message_detail IMPLEMENTATION. " Broken data container - it is neither a navigator, nor a renderer! ASSERT ID /usi/bal_log_writer - CONDITION 1 EQ 0. + CONDITION 1 = 0. ENDMETHOD. METHOD lif_screen_controller~on_exit_command. - IF i_exit_command EQ 'CLOSE'. + IF i_exit_command = 'CLOSE'. LEAVE TO SCREEN 0. ENDIF. ENDMETHOD. @@ -133,9 +127,7 @@ CLASS lcl_log_message_detail IMPLEMENTATION. METHOD free_children. DATA container TYPE REF TO cl_gui_container. - FIELD-SYMBOLS TYPE REF TO cl_gui_control. - - LOOP AT i_parent->children ASSIGNING . + LOOP AT i_parent->children ASSIGNING FIELD-SYMBOL(). TRY. container ?= . free_children( container ). diff --git a/src/#usi#bal_unit_test/#usi#cl_bal_aunit_cut_descr_cl.clas.abap b/src/#usi#bal_unit_test/#usi#cl_bal_aunit_cut_descr_cl.clas.abap index 617e57d..47c984f 100644 --- a/src/#usi#bal_unit_test/#usi#cl_bal_aunit_cut_descr_cl.clas.abap +++ b/src/#usi#bal_unit_test/#usi#cl_bal_aunit_cut_descr_cl.clas.abap @@ -6,22 +6,19 @@ CLASS /usi/cl_bal_aunit_cut_descr_cl DEFINITION PUBLIC FINAL CREATE PRIVATE FOR "! "! @parameter r_result | Helper instance for calling class CLASS-METHODS get_instance - RETURNING - VALUE(r_result) TYPE REF TO /usi/cl_bal_aunit_cut_descr_cl. + RETURNING VALUE(r_result) TYPE REF TO /usi/cl_bal_aunit_cut_descr_cl. "!

Constructor

"! "! @parameter i_classname | Class name of calling class METHODS constructor - IMPORTING - i_classname TYPE classname. + IMPORTING i_classname TYPE classname. "!

Get Class Description

"! "! @parameter r_result | Class Description (RTTI API) METHODS get_rtti_description - RETURNING - VALUE(r_result) TYPE REF TO cl_abap_classdescr. + RETURNING VALUE(r_result) TYPE REF TO cl_abap_classdescr. "!

Reusable unit test: Public attributes must be READ-ONLY!

"! @@ -53,17 +50,11 @@ CLASS /usi/cl_bal_aunit_cut_descr_cl DEFINITION PUBLIC FINAL CREATE PRIVATE FOR "! "! @parameter i_actual_classname | Actual class name METHODS assert_classname_equals - IMPORTING - i_actual_classname TYPE classname. - - PROTECTED SECTION. - - PRIVATE SECTION. + IMPORTING i_actual_classname TYPE classname. ENDCLASS. - CLASS /usi/cl_bal_aunit_cut_descr_cl IMPLEMENTATION. METHOD assert_classname_equals. cl_aunit_assert=>assert_equals( exp = classname @@ -71,7 +62,6 @@ CLASS /usi/cl_bal_aunit_cut_descr_cl IMPLEMENTATION. msg = `Unexpected classname!` ). ENDMETHOD. - METHOD assert_public_attrib_read_only. DATA class_description TYPE REF TO cl_abap_classdescr. @@ -79,17 +69,14 @@ CLASS /usi/cl_bal_aunit_cut_descr_cl IMPLEMENTATION. class_description = get_rtti_description( ). - READ TABLE class_description->attributes - ASSIGNING - WITH KEY visibility = cl_abap_classdescr=>public - is_read_only = abap_false. - IF sy-subrc EQ 0. + ASSIGN class_description->attributes[ visibility = cl_abap_classdescr=>public + is_read_only = abap_false ] TO . + IF sy-subrc = 0. cl_aunit_assert=>fail( msg = `A public attribute is not READ-ONLY!` detail = -name ). ENDIF. ENDMETHOD. - METHOD assert_publ_static_orefs_bound. DATA class_description TYPE REF TO cl_abap_classdescr. FIELD-SYMBOLS: TYPE abap_attrdescr, @@ -97,11 +84,11 @@ CLASS /usi/cl_bal_aunit_cut_descr_cl IMPLEMENTATION. class_description = get_rtti_description( ). - LOOP AT class_description->attributes ASSIGNING WHERE visibility EQ cl_abap_classdescr=>public - AND is_class EQ abap_true - AND type_kind EQ cl_abap_classdescr=>typekind_oref. + LOOP AT class_description->attributes ASSIGNING WHERE visibility = cl_abap_classdescr=>public + AND is_class = abap_true + AND type_kind = cl_abap_classdescr=>typekind_oref. ASSIGN (classname)=>(-name) TO . - IF sy-subrc NE 0. + IF sy-subrc <> 0. cl_aunit_assert=>fail( msg = `Could not access public static oref-attribute` detail = -name ). ELSE. @@ -111,12 +98,10 @@ CLASS /usi/cl_bal_aunit_cut_descr_cl IMPLEMENTATION. ENDLOOP. ENDMETHOD. - METHOD constructor. classname = i_classname. ENDMETHOD. - METHOD get_instance. DATA: callstack TYPE abap_callstack, include_resolver TYPE REF TO if_oo_clif_incl_naming. @@ -124,44 +109,31 @@ CLASS /usi/cl_bal_aunit_cut_descr_cl IMPLEMENTATION. FIELD-SYMBOLS TYPE abap_callstack_line. CALL FUNCTION 'SYSTEM_CALLSTACK' - EXPORTING - max_level = 2 - IMPORTING - callstack = callstack. - READ TABLE callstack ASSIGNING INDEX 2. - - cl_oo_include_naming=>get_instance_by_include( - EXPORTING - progname = -mainprogram - RECEIVING - cifref = include_resolver - EXCEPTIONS - no_objecttype = 1 - internal_error = 2 - OTHERS = 3 ). - IF sy-subrc NE 0. + EXPORTING max_level = 2 + IMPORTING callstack = callstack. + ASSIGN callstack[ 2 ] TO . + + cl_oo_include_naming=>get_instance_by_include( EXPORTING progname = -mainprogram + RECEIVING cifref = include_resolver + EXCEPTIONS no_objecttype = 1 + internal_error = 2 + OTHERS = 3 ). + IF sy-subrc <> 0. cl_aunit_assert=>fail( `Caller is not a class!` ). ENDIF. - CREATE OBJECT r_result - EXPORTING - i_classname = include_resolver->cifkey-clsname. + r_result = NEW #( i_classname = include_resolver->cifkey-clsname ). ENDMETHOD. - METHOD get_rtti_description. DATA: type_description TYPE REF TO cl_abap_typedescr, unexpected_exception TYPE REF TO cx_sy_move_cast_error. - cl_abap_classdescr=>describe_by_name( - EXPORTING - p_name = classname - RECEIVING - p_descr_ref = type_description - EXCEPTIONS - type_not_found = 1 - OTHERS = 2 ). - IF sy-subrc NE 0. + cl_abap_classdescr=>describe_by_name( EXPORTING p_name = classname + RECEIVING p_descr_ref = type_description + EXCEPTIONS type_not_found = 1 + OTHERS = 2 ). + IF sy-subrc <> 0. CLEAR type_description. ENDIF. cl_aunit_assert=>assert_bound( act = type_description diff --git a/src/#usi#bal_unit_test/#usi#cl_bal_aunit_exception.clas.abap b/src/#usi#bal_unit_test/#usi#cl_bal_aunit_exception.clas.abap index 286fac4..c49daf6 100644 --- a/src/#usi#bal_unit_test/#usi#cl_bal_aunit_exception.clas.abap +++ b/src/#usi#bal_unit_test/#usi#cl_bal_aunit_exception.clas.abap @@ -1,47 +1,34 @@ CLASS /usi/cl_bal_aunit_exception DEFINITION PUBLIC FINAL CREATE PUBLIC FOR TESTING. PUBLIC SECTION. - "!

Aborts current test

"! "! @parameter i_exception | Exception (Text will be displayed) - "! @parameter i_quit | Quit what (Test method / class) + "! @parameter i_quit | Quit what (Test method / class) CLASS-METHODS abort_on_unexpected_exception - IMPORTING - i_exception TYPE REF TO cx_root - i_quit TYPE aunit_flowctrl DEFAULT if_aunit_constants=>class. + IMPORTING i_exception TYPE REF TO cx_root + i_quit TYPE aunit_flowctrl DEFAULT if_aunit_constants=>class. "!

Make current test fail

"! "! @parameter i_exception | Exception (Text will be displayed) - "! @parameter i_quit | Quit what (Test method / class) + "! @parameter i_quit | Quit what (Test method / class) CLASS-METHODS fail_on_unexpected_exception - IMPORTING - i_exception TYPE REF TO cx_root - i_quit TYPE aunit_flowctrl DEFAULT if_aunit_constants=>method. - - PROTECTED SECTION. - - PRIVATE SECTION. + IMPORTING i_exception TYPE REF TO cx_root + i_quit TYPE aunit_flowctrl DEFAULT if_aunit_constants=>method. ENDCLASS. - CLASS /usi/cl_bal_aunit_exception IMPLEMENTATION. METHOD abort_on_unexpected_exception. - DATA exception_text TYPE string. - - exception_text = i_exception->get_text( ). + DATA(exception_text) = i_exception->get_text( ). cl_aunit_assert=>abort( msg = `Unexpected exception!` detail = exception_text quit = i_quit ). ENDMETHOD. - METHOD fail_on_unexpected_exception. - DATA exception_text TYPE string. - - exception_text = i_exception->get_text( ). + DATA(exception_text) = i_exception->get_text( ). cl_aunit_assert=>fail( msg = `Unexpected exception!` detail = exception_text quit = i_quit ). diff --git a/src/#usi#bal_unit_test/#usi#cl_bal_aunit_method_call.clas.abap b/src/#usi#bal_unit_test/#usi#cl_bal_aunit_method_call.clas.abap index 8f418dc..3a945e3 100644 --- a/src/#usi#bal_unit_test/#usi#cl_bal_aunit_method_call.clas.abap +++ b/src/#usi#bal_unit_test/#usi#cl_bal_aunit_method_call.clas.abap @@ -16,34 +16,27 @@ CLASS /usi/cl_bal_aunit_method_call DEFINITION PUBLIC FINAL CREATE PUBLIC FOR TE "! "! @parameter i_method_name | Method name METHODS constructor - IMPORTING - i_method_name TYPE ty_method_name. + IMPORTING i_method_name TYPE ty_method_name. "!

Add parameter

"! - "! @parameter i_parameter_name | Name + "! @parameter i_parameter_name | Name "! @parameter i_parameter_value | Value METHODS add_parameter - IMPORTING - i_parameter_name TYPE ty_parameter_name - i_parameter_value TYPE any. + IMPORTING i_parameter_name TYPE ty_parameter_name + i_parameter_value TYPE any. "!

Get parameter

"! - "! @parameter i_parameter_name | Name + "! @parameter i_parameter_name | Name "! @parameter e_parameter_value | Value METHODS get_parameter - IMPORTING - i_parameter_name TYPE ty_parameter_name - EXPORTING - VALUE(e_parameter_value) TYPE any. - - PROTECTED SECTION. - - PRIVATE SECTION. + IMPORTING i_parameter_name TYPE ty_parameter_name + EXPORTING VALUE(e_parameter_value) TYPE any. ENDCLASS. + CLASS /usi/cl_bal_aunit_method_call IMPLEMENTATION. METHOD constructor. method_name = i_method_name. @@ -60,7 +53,7 @@ CLASS /usi/cl_bal_aunit_method_call IMPLEMENTATION. = i_parameter_value. INSERT parameter INTO TABLE parameters. - IF sy-subrc NE 0. + IF sy-subrc <> 0. cl_aunit_assert=>fail( `Duplicate call! Test is broken!` ). ENDIF. ENDMETHOD. @@ -71,10 +64,8 @@ CLASS /usi/cl_bal_aunit_method_call IMPLEMENTATION. CLEAR e_parameter_value. - READ TABLE parameters - ASSIGNING - WITH KEY parameter_name = i_parameter_name. - IF sy-subrc NE 0. + ASSIGN parameters[ parameter_name = i_parameter_name ] TO . + IF sy-subrc <> 0. cl_aunit_assert=>fail( msg = `Parameter not found!` detail = i_parameter_name ). ENDIF. diff --git a/src/#usi#bal_unit_test/#usi#cl_bal_aunit_method_calls.clas.abap b/src/#usi#bal_unit_test/#usi#cl_bal_aunit_method_calls.clas.abap index 7a7aedc..9f1d28e 100644 --- a/src/#usi#bal_unit_test/#usi#cl_bal_aunit_method_calls.clas.abap +++ b/src/#usi#bal_unit_test/#usi#cl_bal_aunit_method_calls.clas.abap @@ -10,72 +10,60 @@ CLASS /usi/cl_bal_aunit_method_calls DEFINITION PUBLIC FINAL CREATE PUBLIC FOR T "!

Makes the current test fail, if the method was not called n times

"! - "! @parameter i_method_name | Method name + "! @parameter i_method_name | Method name "! @parameter i_expected_number_of_calls | Expected number of calls METHODS assert_method_called_n_times - IMPORTING - i_method_name TYPE /usi/cl_bal_aunit_method_call=>ty_method_name - i_expected_number_of_calls TYPE int4. + IMPORTING i_method_name TYPE /usi/cl_bal_aunit_method_call=>ty_method_name + i_expected_number_of_calls TYPE int4. "!

Makes the current test fail, if the method was not called

"! "! @parameter i_method_name | Method name METHODS assert_method_was_called - IMPORTING - i_method_name TYPE /usi/cl_bal_aunit_method_call=>ty_method_name. + IMPORTING i_method_name TYPE /usi/cl_bal_aunit_method_call=>ty_method_name. "!

Makes the current test fail, if the method has been called

"! "! @parameter i_method_name | Method name METHODS assert_method_was_not_called - IMPORTING - i_method_name TYPE /usi/cl_bal_aunit_method_call=>ty_method_name. + IMPORTING i_method_name TYPE /usi/cl_bal_aunit_method_call=>ty_method_name. "!

Returns calls of given method

"! "!

Can be used to analyze indirect output by checking the data passed to the methods.

"! "! @parameter i_method_name | Method name - "! @parameter r_result | Method calls (with parameters) + "! @parameter r_result | Method calls (with parameters) METHODS get_method_calls - IMPORTING - i_method_name TYPE /usi/cl_bal_aunit_method_call=>ty_method_name - RETURNING - VALUE(r_result) TYPE ty_method_calls. + IMPORTING i_method_name TYPE /usi/cl_bal_aunit_method_call=>ty_method_name + RETURNING VALUE(r_result) TYPE ty_method_calls. "!

Insert method call

"! "!

Can be used by test-doubles / spy-objects to log received method calls.

"! "! @parameter i_method_name | Method name - "! @parameter r_result | Method call instance (Accepts parameters) + "! @parameter r_result | Method call instance (Accepts parameters) METHODS insert_method_call - IMPORTING - i_method_name TYPE /usi/cl_bal_aunit_method_call=>ty_method_name - RETURNING - VALUE(r_result) TYPE REF TO /usi/cl_bal_aunit_method_call. + IMPORTING i_method_name TYPE /usi/cl_bal_aunit_method_call=>ty_method_name + RETURNING VALUE(r_result) TYPE REF TO /usi/cl_bal_aunit_method_call. "!

Reset data

METHODS reset_method_calls. - PROTECTED SECTION. - PRIVATE SECTION. METHODS was_method_called - IMPORTING - i_method_name TYPE /usi/cl_bal_aunit_method_call=>ty_method_name - RETURNING - VALUE(r_result) TYPE abap_bool. + IMPORTING i_method_name TYPE /usi/cl_bal_aunit_method_call=>ty_method_name + RETURNING VALUE(r_result) TYPE abap_bool. ENDCLASS. - CLASS /usi/cl_bal_aunit_method_calls IMPLEMENTATION. METHOD assert_method_called_n_times. DATA actual_number_of_calls TYPE int4. - LOOP AT method_calls TRANSPORTING NO FIELDS WHERE method_name EQ i_method_name. + LOOP AT method_calls TRANSPORTING NO FIELDS WHERE method_name = i_method_name. actual_number_of_calls = actual_number_of_calls + 1. ENDLOOP. @@ -84,55 +72,44 @@ CLASS /usi/cl_bal_aunit_method_calls IMPLEMENTATION. msg = `Unexpected number of method calls!` ). ENDMETHOD. - METHOD assert_method_was_called. - IF was_method_called( i_method_name ) EQ abap_false. + IF was_method_called( i_method_name ) = abap_false. cl_aunit_assert=>fail( msg = `Method was not called!` detail = i_method_name ). ENDIF. ENDMETHOD. - METHOD assert_method_was_not_called. - IF was_method_called( i_method_name ) EQ abap_true. + IF was_method_called( i_method_name ) = abap_true. cl_aunit_assert=>fail( msg = `Method was called!` detail = i_method_name ). ENDIF. ENDMETHOD. - METHOD get_method_calls. FIELD-SYMBOLS TYPE ty_method_call. - LOOP AT method_calls ASSIGNING WHERE method_name EQ i_method_name. + LOOP AT method_calls ASSIGNING WHERE method_name = i_method_name. INSERT INTO TABLE r_result. ENDLOOP. ENDMETHOD. - METHOD insert_method_call. DATA method_call TYPE ty_method_call. - CREATE OBJECT r_result - EXPORTING - i_method_name = i_method_name. + r_result = NEW #( i_method_name = i_method_name ). method_call-method_name = r_result->method_name. method_call-method_call = r_result. INSERT method_call INTO TABLE method_calls. ENDMETHOD. - METHOD reset_method_calls. CLEAR method_calls. ENDMETHOD. - METHOD was_method_called. - READ TABLE method_calls - TRANSPORTING NO FIELDS - WITH KEY method_name = i_method_name. - IF sy-subrc EQ 0. + IF line_exists( method_calls[ method_name = i_method_name ] ). r_result = abap_true. ENDIF. ENDMETHOD.