From 3a51dd23b5ff886754da9bbe50a1a9c439492cb2 Mon Sep 17 00:00:00 2001 From: Marc Bernard <59966492+mbtools@users.noreply.github.com> Date: Mon, 27 Feb 2023 09:44:02 +0100 Subject: [PATCH] CLAS: Fix error when changing redefinitions (#6102) Co-authored-by: Lars Hvam --- src/objects/oo/zcl_abapgit_oo_class.clas.abap | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/src/objects/oo/zcl_abapgit_oo_class.clas.abap b/src/objects/oo/zcl_abapgit_oo_class.clas.abap index 9cb5f22c5..262a380f1 100644 --- a/src/objects/oo/zcl_abapgit_oo_class.clas.abap +++ b/src/objects/oo/zcl_abapgit_oo_class.clas.abap @@ -104,6 +104,11 @@ CLASS zcl_abapgit_oo_class DEFINITION !is_key TYPE seoclskey RAISING zcx_abapgit_exception . + CLASS-METHODS repair_redefinitions + IMPORTING + !is_key TYPE seoclskey + RAISING + zcx_abapgit_exception . ENDCLASS. @@ -256,6 +261,105 @@ CLASS zcl_abapgit_oo_class IMPLEMENTATION. ENDMETHOD. + METHOD repair_redefinitions. + + " Same logic as SE24 > Utilities > Clean-up > lt_redefinitions (LSEODCCO) + + DATA: + lt_inheritance TYPE vseoextend, + lt_redefinitions TYPE seor_redefinitions_r, + ls_cpdkey TYPE seocpdkey, + lv_tabix TYPE sy-tabix, + lv_exposure TYPE n LENGTH 1, + lv_update TYPE abap_bool, + lv_local_component TYPE abap_bool. + + FIELD-SYMBOLS TYPE seoredef. + + CALL FUNCTION 'SEO_CLASS_TYPEINFO_GET' + EXPORTING + clskey = is_key + version = seoc_version_active + IMPORTING + inheritance = lt_inheritance + redefinitions = lt_redefinitions + EXCEPTIONS + not_existing = 1 + is_interface = 2 + model_only = 3 + OTHERS = 4. + IF sy-subrc <> 0. + RETURN. + ENDIF. + + " check redefinitions validity + LOOP AT lt_redefinitions ASSIGNING . + lv_tabix = sy-tabix. + + ls_cpdkey-clsname = is_key-clsname. + ls_cpdkey-cpdname = -mtdname. + + CALL FUNCTION 'SEO_COMPONENT_BY_INHERITANCE' + EXPORTING + cpdkey = ls_cpdkey + version = seoc_version_active + IMPORTING + exposure = lv_exposure + is_local_component = lv_local_component + EXCEPTIONS + not_existing = 1 + model_only = 2 + OTHERS = 3. + IF sy-subrc <> 0. + DELETE lt_redefinitions INDEX lv_tabix. + lv_update = abap_true. + ELSEIF -exposure <> lv_exposure. + -exposure = lv_exposure. + lv_update = abap_true. + ELSEIF lv_local_component = abap_true AND -attvalue IS INITIAL AND + -mtdabstrct IS INITIAL AND -mtdfinal IS INITIAL. + DELETE lt_redefinitions INDEX lv_tabix. + lv_update = abap_true. + ENDIF. + ENDLOOP. + + IF lv_update = abap_true. + CALL FUNCTION 'SEO_INHERITANC_CHANGE_F_DATA' + EXPORTING + save = abap_false + CHANGING + inheritance = lt_inheritance + redefinitions = lt_redefinitions + EXCEPTIONS + not_existing = 1 + deleted = 2 + is_comprising = 3 + is_implementing = 4 + not_changed = 5 + db_error = 6 + OTHERS = 7. + IF sy-subrc <> 0. + zcx_abapgit_exception=>raise( |Error repairing redefinitions for { is_key-clsname }| ). + ENDIF. + + CALL FUNCTION 'SEO_CLIF_SAVE_ALL' + EXPORTING + cifkey = is_key + EXCEPTIONS + not_existing = 1 + nothing_to_do = 2 + access_error = 3 + db_error = 4 + error_in_code_generation = 5 + OTHERS = 6. + IF sy-subrc <> 0. + zcx_abapgit_exception=>raise( |Error repairing redefinitions for { is_key-clsname }| ). + ENDIF. + ENDIF. + + ENDMETHOD. + + METHOD update_cs_number_of_methods. " Indirect access to keep downward compatibility @@ -634,6 +738,7 @@ CLASS zcl_abapgit_oo_class IMPLEMENTATION. " which will delete the obsolete includes IF lt_incls IS NOT INITIAL. repair_classpool( is_key ). + repair_redefinitions( is_key ). ENDIF. update_source_index(