From 8022eafdabf05dc32f169de03d37f0cd9b127aea Mon Sep 17 00:00:00 2001 From: Marc Bernard <59966492+mbtools@users.noreply.github.com> Date: Tue, 29 Aug 2023 16:29:53 -0400 Subject: [PATCH] generic object handler: fix special cases (#6444) --- .../zcl_abapgit_objects_generic.clas.abap | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/objects/zcl_abapgit_objects_generic.clas.abap b/src/objects/zcl_abapgit_objects_generic.clas.abap index 0fd358ada..d8a3eabc3 100644 --- a/src/objects/zcl_abapgit_objects_generic.clas.abap +++ b/src/objects/zcl_abapgit_objects_generic.clas.abap @@ -125,7 +125,7 @@ ENDCLASS. -CLASS ZCL_ABAPGIT_OBJECTS_GENERIC IMPLEMENTATION. +CLASS zcl_abapgit_objects_generic IMPLEMENTATION. METHOD after_import. @@ -228,7 +228,7 @@ CLASS ZCL_ABAPGIT_OBJECTS_GENERIC IMPLEMENTATION. zcx_abapgit_exception=>raise( 'Not found in OBJH, or not supported' ). ENDIF. -* object tables + " object tables SELECT * FROM objsl INTO CORRESPONDING FIELDS OF TABLE mt_object_table WHERE objectname = is_item-obj_type AND objecttype = lc_logical_transport_object @@ -237,14 +237,13 @@ CLASS ZCL_ABAPGIT_OBJECTS_GENERIC IMPLEMENTATION. IF mt_object_table IS INITIAL. zcx_abapgit_exception=>raise( |Obviously corrupted object-type { is_item-obj_type }: No tables defined| ). ENDIF. -* only unique tables - SORT mt_object_table BY tobj_name ASCENDING. - DELETE ADJACENT DUPLICATES FROM mt_object_table COMPARING tobj_name. -* back to primary key table sorting, - SORT mt_object_table BY objectname objecttype trwcount. + " remove duplicate table/table-key entries + " same table with different keys is ok + SORT mt_object_table BY tobj_name tobjkey. + DELETE ADJACENT DUPLICATES FROM mt_object_table COMPARING tobj_name tobjkey. -* object methods + " object methods SELECT * FROM objm INTO TABLE mt_object_method WHERE objectname = is_item-obj_type AND objecttype = lc_logical_transport_object @@ -455,13 +454,18 @@ CLASS ZCL_ABAPGIT_OBJECTS_GENERIC IMPLEMENTATION. METHOD get_primary_table. DATA: ls_object_table LIKE LINE OF mt_object_table. + DATA: lt_object_table LIKE mt_object_table. + " There might be several tables marked as "primary" + " Sort by DB key so we get first one in the list + lt_object_table = mt_object_table. + SORT lt_object_table. - READ TABLE mt_object_table INTO ls_object_table WITH KEY prim_table = abap_true. + READ TABLE lt_object_table INTO ls_object_table WITH KEY prim_table = abap_true. IF sy-subrc <> 0. -* Fallback. For some objects, no primary table is explicitly flagged -* The, the one with only one key field shall be chosen - READ TABLE mt_object_table INTO ls_object_table WITH KEY tobjkey = '/&'. "#EC CI_SUBRC + " Fallback. For some objects, no primary table is explicitly flagged + " Then, the one with only one key field shall be chosen + READ TABLE lt_object_table INTO ls_object_table WITH KEY tobjkey = '/&'. "#EC CI_SUBRC ENDIF. IF ls_object_table IS INITIAL. zcx_abapgit_exception=>raise( |Object { ms_item-obj_type } has got no defined primary table| ). @@ -533,7 +537,6 @@ CLASS ZCL_ABAPGIT_OBJECTS_GENERIC IMPLEMENTATION. lv_objkey_pos = lv_objkey_pos + 1. * object name ELSEIF -tobjkey+lv_next_objkey_pos(1) = '&'. - "TODO ls_objkey-value = ms_item-obj_name. * The object name might comprise multiple key components (e. g. WDCC) * This string needs to be split