From 24436879b6e34752cbeaca375fae77f0e083a68d Mon Sep 17 00:00:00 2001 From: Marc Bernard <59966492+mbtools@users.noreply.github.com> Date: Sat, 3 Oct 2020 03:17:11 -0400 Subject: [PATCH] Improvements for uninstall (#3959) * Improvements for uninstall Uninstall now catches exceptions and tries up to 3 times to remove an object. Exceptions are only raised if after 3 tries some objects still remain. Tested with https://github.com/larshp/abapPGP Closes https://github.com/abapGit/abapGit/issues/379 and https://github.com/abapGit/abapGit/issues/3949, and probably #3228 * Add SHLP also ordered when by priority * Conflict * Move counter Co-authored-by: Lars Hvam --- src/objects/zcl_abapgit_objects.clas.abap | 47 +++++++++++++++-------- src/zcl_abapgit_dependencies.clas.abap | 30 ++++++++------- 2 files changed, 49 insertions(+), 28 deletions(-) diff --git a/src/objects/zcl_abapgit_objects.clas.abap b/src/objects/zcl_abapgit_objects.clas.abap index 9f97495a2..f9fdbb17b 100644 --- a/src/objects/zcl_abapgit_objects.clas.abap +++ b/src/objects/zcl_abapgit_objects.clas.abap @@ -475,6 +475,7 @@ CLASS ZCL_ABAPGIT_OBJECTS IMPLEMENTATION. lt_tadir LIKE it_tadir, lt_items TYPE zif_abapgit_definitions=>ty_items_tt, lx_error TYPE REF TO zcx_abapgit_exception, + lv_count TYPE i, lv_text TYPE string. FIELD-SYMBOLS: LIKE LINE OF it_tadir. @@ -495,28 +496,44 @@ CLASS ZCL_ABAPGIT_OBJECTS IMPLEMENTATION. check_objects_locked( iv_language = zif_abapgit_definitions=>c_english it_items = lt_items ). - LOOP AT lt_tadir ASSIGNING . - li_progress->show( iv_current = sy-tabix - iv_text = |Delete { -obj_name }| ). - - CLEAR ls_item. - ls_item-obj_type = -object. - ls_item-obj_name = -obj_name. - delete_obj( - iv_package = -devclass - is_item = ls_item ). - -* make sure to save object deletions - COMMIT WORK. - ENDLOOP. - CATCH zcx_abapgit_exception INTO lx_error. zcl_abapgit_default_transport=>get_instance( )->reset( ). RAISE EXCEPTION lx_error. ENDTRY. + lv_count = 1. + DO 3 TIMES. + LOOP AT lt_tadir ASSIGNING . + li_progress->show( iv_current = lv_count + iv_text = |Delete { -obj_name }| ). + + CLEAR ls_item. + ls_item-obj_type = -object. + ls_item-obj_name = -obj_name. + + TRY. + delete_obj( + iv_package = -devclass + is_item = ls_item ). + + DELETE lt_tadir. + lv_count = lv_count + 1. + + " make sure to save object deletions + COMMIT WORK. + CATCH zcx_abapgit_exception INTO lx_error ##NO_HANDLER. + " ignore errors inside the loops and raise it later + ENDTRY. + + ENDLOOP. + ENDDO. + zcl_abapgit_default_transport=>get_instance( )->reset( ). + IF lx_error IS BOUND AND lines( lt_tadir ) > 0. + RAISE EXCEPTION lx_error. + ENDIF. + ENDMETHOD. diff --git a/src/zcl_abapgit_dependencies.clas.abap b/src/zcl_abapgit_dependencies.clas.abap index d50c78e6f..7829bddcb 100644 --- a/src/zcl_abapgit_dependencies.clas.abap +++ b/src/zcl_abapgit_dependencies.clas.abap @@ -73,6 +73,7 @@ CLASS ZCL_ABAPGIT_DEPENDENCIES IMPLEMENTATION. FIELD-SYMBOLS: LIKE LINE OF ct_tadir. " misuse field KORRNUM to fix deletion sequence + " higher value means later deletion LOOP AT ct_tadir ASSIGNING . CASE -object. @@ -86,18 +87,9 @@ CLASS ZCL_ABAPGIT_DEPENDENCIES IMPLEMENTATION. -korrnum = '810000'. WHEN 'DTEL'. -korrnum = '800000'. - WHEN 'DCLS'. - " AUTH and SUSO after DCLS - -korrnum = '705000'. - WHEN 'SUSO'. - " SUSO after DCLS - -korrnum = '710000'. - WHEN 'AUTH'. - " AUTH after DCLS - -korrnum = '715000'. - WHEN 'DDLS'. - " DDLS after DCLS but before other DDIC - -korrnum = '720000'. + WHEN 'SHLP'. + " SHLP after TABL + -korrnum = '760000'. WHEN 'TTYP' OR 'TABL' OR 'VIEW'. SELECT SINGLE tabclass FROM dd02l INTO lv_tabclass @@ -110,6 +102,18 @@ CLASS ZCL_ABAPGIT_DEPENDENCIES IMPLEMENTATION. ELSE. -korrnum = '750000'. ENDIF. + WHEN 'DDLS'. + " DDLS after DCLS but before other DDIC + -korrnum = '720000'. + WHEN 'AUTH'. + " AUTH after DCLS + -korrnum = '715000'. + WHEN 'SUSO'. + " SUSO after DCLS + -korrnum = '710000'. + WHEN 'DCLS'. + " AUTH and SUSO after DCLS + -korrnum = '705000'. WHEN 'IASP'. -korrnum = '552000'. WHEN 'IARP'. @@ -130,7 +134,7 @@ CLASS ZCL_ABAPGIT_DEPENDENCIES IMPLEMENTATION. IF sy-subrc = 0. -korrnum = '200000'. ELSE. - -korrnum = '100000'. + -korrnum = '180000'. ENDIF. WHEN 'IDOC'. -korrnum = '200000'.