diff --git a/src/background/zcl_abapgit_background.clas.abap b/src/background/zcl_abapgit_background.clas.abap index e3f3c0aef..5812f2aed 100644 --- a/src/background/zcl_abapgit_background.clas.abap +++ b/src/background/zcl_abapgit_background.clas.abap @@ -26,11 +26,12 @@ CLASS zcl_abapgit_background DEFINITION PROTECTED SECTION. PRIVATE SECTION. CONSTANTS c_enq_type TYPE c LENGTH 12 VALUE 'BACKGROUND'. + CONSTANTS c_interface TYPE seoclskey VALUE 'ZIF_ABAPGIT_BACKGROUND'. ENDCLASS. -CLASS zcl_abapgit_background IMPLEMENTATION. +CLASS ZCL_ABAPGIT_BACKGROUND IMPLEMENTATION. METHOD dequeue. @@ -59,36 +60,69 @@ CLASS zcl_abapgit_background IMPLEMENTATION. METHOD list_methods. - DATA: ls_method LIKE LINE OF rt_methods, - ls_key TYPE seoclskey, - lt_implementing TYPE seor_implementing_keys, - ls_implementing LIKE LINE OF lt_implementing. + DATA: ls_method LIKE LINE OF rt_methods, + lt_implementing TYPE seor_implementing_keys, + ls_implementing LIKE LINE OF lt_implementing, + lt_interf TYPE abap_intfdescr_tab, + lt_local_classes TYPE STANDARD TABLE OF scompo, + lv_classname TYPE string, + lr_typedescr TYPE REF TO cl_abap_typedescr, + lr_typedescr_class TYPE REF TO cl_abap_classdescr. - FIELD-SYMBOLS: LIKE LINE OF rt_methods. + FIELD-SYMBOLS: LIKE LINE OF lt_local_classes, + LIKE LINE OF rt_methods. + IF zcl_abapgit_factory=>get_environment( )->is_merged( ) = abap_true. + " Assume the standalone version runs. + CALL FUNCTION 'WB_TREE_GET_OBJECTS' + EXPORTING + include = ' ' + otype = 'L' + program = sy-repid + TABLES + olist = lt_local_classes. -* in order to handle local classes in the compiled report - ls_method-class = 'ZCL_ABAPGIT_BACKGROUND_PULL'. - INSERT ls_method INTO TABLE rt_methods. - ls_method-class = 'ZCL_ABAPGIT_BACKGROUND_PUSH_AU'. - INSERT ls_method INTO TABLE rt_methods. - ls_method-class = 'ZCL_ABAPGIT_BACKGROUND_PUSH_FI'. - INSERT ls_method INTO TABLE rt_methods. + LOOP AT lt_local_classes ASSIGNING . + lv_classname = |\\PROGRAM={ sy-repid }\\CLASS={ -name }|. + cl_abap_typedescr=>describe_by_name( + EXPORTING + p_name = lv_classname + RECEIVING + p_descr_ref = lr_typedescr + EXCEPTIONS + type_not_found = 1 + OTHERS = 2 ). - ls_key-clsname = 'ZIF_ABAPGIT_BACKGROUND'. + IF sy-subrc = 0 AND lr_typedescr IS BOUND. + lr_typedescr_class ?= lr_typedescr. + IF lr_typedescr_class IS BOUND. + lt_interf = lr_typedescr_class->interfaces. + READ TABLE lt_interf WITH TABLE KEY name = c_interface TRANSPORTING NO FIELDS. + IF sy-subrc = 0. + ls_method-class = -name. + INSERT ls_method INTO TABLE rt_methods. + ENDIF. + ENDIF. + ENDIF. + ENDLOOP. - CALL FUNCTION 'SEO_INTERFACE_IMPLEM_GET_ALL' - EXPORTING - intkey = ls_key - IMPORTING - impkeys = lt_implementing - EXCEPTIONS - not_existing = 1 - OTHERS = 2 ##FM_SUBRC_OK. - LOOP AT lt_implementing INTO ls_implementing. - ls_method-class = ls_implementing-clsname. - INSERT ls_method INTO TABLE rt_methods. - ENDLOOP. + ELSE. + " Assume the developer version runs. + CALL FUNCTION 'SEO_INTERFACE_IMPLEM_GET_ALL' + EXPORTING + intkey = c_interface + IMPORTING + impkeys = lt_implementing + EXCEPTIONS + not_existing = 1 + OTHERS = 2. + IF sy-subrc = 0. + LOOP AT lt_implementing INTO ls_implementing. + ls_method-class = ls_implementing-clsname. + INSERT ls_method INTO TABLE rt_methods. + ENDLOOP. + ENDIF. + ENDIF. LOOP AT rt_methods ASSIGNING . CALL METHOD (-class)=>zif_abapgit_background~get_description @@ -136,12 +170,17 @@ CLASS zcl_abapgit_background IMPLEMENTATION. iv_username = -username iv_password = -password ). - CREATE OBJECT li_background TYPE (-method). + TRY. + CREATE OBJECT li_background TYPE (-method). - li_background->run( - io_repo = lo_repo - ii_log = li_log - it_settings = -settings ). + li_background->run( + io_repo = lo_repo + ii_log = li_log + it_settings = -settings ). + CATCH cx_sy_create_object_error. + li_log->add_warning( |{ -method } could not be executed,| + & | as it is not accessible (local/global class).| ). + ENDTRY. " Decrease memory usage for repository already processed (but keep log) lo_repo->refresh( diff --git a/src/ui/pages/sett/zcl_abapgit_gui_page_sett_bckg.clas.abap b/src/ui/pages/sett/zcl_abapgit_gui_page_sett_bckg.clas.abap index f186af21b..9fe9ea9bf 100644 --- a/src/ui/pages/sett/zcl_abapgit_gui_page_sett_bckg.clas.abap +++ b/src/ui/pages/sett/zcl_abapgit_gui_page_sett_bckg.clas.abap @@ -66,7 +66,7 @@ ENDCLASS. -CLASS zcl_abapgit_gui_page_sett_bckg IMPLEMENTATION. +CLASS ZCL_ABAPGIT_GUI_PAGE_SETT_BCKG IMPLEMENTATION. METHOD constructor. @@ -210,9 +210,13 @@ CLASS zcl_abapgit_gui_page_sett_bckg IMPLEMENTATION. " skip invalid values, from old background logic IF ls_per-method <> 'push' AND ls_per-method <> 'pull' AND ls_per-method <> 'nothing'. - CALL METHOD (ls_per-method)=>zif_abapgit_background~get_settings - CHANGING - ct_settings = lt_settings. + TRY. + CALL METHOD (ls_per-method)=>zif_abapgit_background~get_settings + CHANGING + ct_settings = lt_settings. + CATCH cx_sy_dyn_call_illegal_class. + CLEAR lt_settings. + ENDTRY. ENDIF. LOOP AT lt_settings INTO ls_settings. diff --git a/src/zabapgit.prog.abap b/src/zabapgit.prog.abap index ca7da119f..83c7edae9 100644 --- a/src/zabapgit.prog.abap +++ b/src/zabapgit.prog.abap @@ -44,6 +44,11 @@ INCLUDE zabapgit_authorizations_exit IF FOUND. * place the object in a different package than ZABAPGIT INCLUDE zabapgit_user_exit IF FOUND. +* place all implementations of ZIF_ABAPGIT_BACKGROUND in following include, +* if using the development version of abapGit create a global classes instead +* place the object in a different package than ZABAPGIT +INCLUDE zabapgit_background_user_exit IF FOUND. + INCLUDE zabapgit_gui_pages_userexit IF FOUND. INCLUDE zabapgit_forms.