From f9746cf19911a330736c7ecde91806c7ca109637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4semann?= <32765685+mkaesemann@users.noreply.github.com> Date: Thu, 2 Aug 2018 06:48:13 +0200 Subject: [PATCH] Optimized ZCL_ABAPGIT_TADIR=>BUILD for better performance (#1725) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Optimized ZCL_ABAPGIT_TADIR=>BUILD for better performance - Using the optimizations in ZCL_ABAPGIT_FOLDER_LOGIC (PR #1723) and ZCL_ABAPGIT_SAP_PACKAGE (PR #1724) to optimize the TADIR build method, by first determining all relevant subpackages and then processing them in one go instead of having to recurse and read information from the DB separately. - Note that the optimization can also be used without the changes in #1723 and #1724, but the effect will be less or worse and the coding requires adaptations. * Fixes coding artifact of #1723 Removed a coding artifact that makes use of importing parameter ÌO_FOLDER_LOGIC`, which is no longer needed in the flat BUILD processing. * Adapted for rework in #1724 After adapting PR #1724 to no longer use buffering, but instead select packages with a level-based selection, the buffering parameter in `ZCL_ABAPGIT_SAP_PACKAGE=>LIST_SUBPACKAGES` no longer exists and should not be used in this PR. * Compressed IF/ELSE construct * Removed whitespaces * Fixed auto-merge issue Removed a double variable declaration resulting from git auto-merge --- src/zcl_abapgit_tadir.clas.abap | 94 +++++++++++++++++---------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/src/zcl_abapgit_tadir.clas.abap b/src/zcl_abapgit_tadir.clas.abap index b97209c5d..f421dd94f 100644 --- a/src/zcl_abapgit_tadir.clas.abap +++ b/src/zcl_abapgit_tadir.clas.abap @@ -52,10 +52,17 @@ CLASS zcl_abapgit_tadir IMPLEMENTATION. ls_srcsystem LIKE LINE OF lt_srcsystem, ls_exclude LIKE LINE OF lt_excludes. DATA: lo_folder_logic TYPE REF TO zcl_abapgit_folder_logic. + DATA: last_package TYPE devclass VALUE cl_abap_char_utilities=>horizontal_tab. FIELD-SYMBOLS: LIKE LINE OF lt_tdevc, LIKE LINE OF rt_tadir. + "Determine Packages to Read + DATA: lt_packages TYPE zif_abapgit_sap_package=>ty_devclass_tt. + IF iv_ignore_subpackages = abap_false. + lt_packages = zcl_abapgit_factory=>get_sap_package( iv_package )->list_subpackages( ). + ENDIF. + INSERT iv_package INTO lt_packages INDEX 1. ls_exclude-sign = 'I'. ls_exclude-option = 'EQ'. @@ -76,44 +83,56 @@ CLASS zcl_abapgit_tadir IMPLEMENTATION. APPEND ls_srcsystem TO lt_srcsystem. ENDIF. - SELECT * FROM tadir - INTO CORRESPONDING FIELDS OF TABLE rt_tadir - WHERE devclass = iv_package - AND pgmid = 'R3TR' - AND object NOT IN lt_excludes - AND delflag = abap_false - AND srcsystem IN lt_srcsystem - ORDER BY PRIMARY KEY. "#EC CI_GENBUFF "#EC CI_SUBRC + IF lt_packages IS NOT INITIAL. + SELECT * FROM tadir + INTO CORRESPONDING FIELDS OF TABLE rt_tadir + FOR ALL ENTRIES IN lt_packages + WHERE devclass = lt_packages-table_line + AND pgmid = 'R3TR' + AND object NOT IN lt_excludes + AND delflag = abap_false + AND srcsystem IN lt_srcsystem + ORDER BY PRIMARY KEY. "#EC CI_GENBUFF "#EC CI_SUBRC + ENDIF. + + SORT rt_tadir BY devclass pgmid object obj_name. CREATE OBJECT lo_skip_objects. rt_tadir = lo_skip_objects->skip_sadl_generated_objects( it_tadir = rt_tadir io_log = io_log ). - " Local packages are not in TADIR, only in TDEVC, act as if they were - IF iv_package CP '$*'. " OR iv_package CP 'T*' ). - APPEND INITIAL LINE TO rt_tadir ASSIGNING . - -pgmid = 'R3TR'. - -object = 'DEVC'. - -obj_name = iv_package. - -devclass = iv_package. - ENDIF. - - IF NOT io_dot IS INITIAL. - "Reuse given Folder Logic Instance - lo_folder_logic = io_folder_logic. - IF lo_folder_logic IS NOT BOUND. - "Get Folder Logic Instance - lo_folder_logic = zcl_abapgit_folder_logic=>get_instance( ). + LOOP AT lt_packages ASSIGNING FIELD-SYMBOL(). + " Local packages are not in TADIR, only in TDEVC, act as if they were + IF CP '$*'. " OR CP 'T*' ). + APPEND INITIAL LINE TO rt_tadir ASSIGNING . + -pgmid = 'R3TR'. + -object = 'DEVC'. + -obj_name = . + -devclass = . ENDIF. - - lv_path = lo_folder_logic->package_to_path( - iv_top = iv_top - io_dot = io_dot - iv_package = iv_package ). - ENDIF. + ENDLOOP. LOOP AT rt_tadir ASSIGNING . + + IF last_package <> -devclass. + "Change in Package + last_package = -devclass. + + IF NOT io_dot IS INITIAL. + "Reuse given Folder Logic Instance + IF lo_folder_logic IS NOT BOUND. + "Get Folder Logic Instance + lo_folder_logic = zcl_abapgit_folder_logic=>get_instance( ). + ENDIF. + + lv_path = lo_folder_logic->package_to_path( + iv_top = iv_top + io_dot = io_dot + iv_package = -devclass ). + ENDIF. + ENDIF. + -path = lv_path. CASE -object. @@ -123,23 +142,6 @@ CLASS zcl_abapgit_tadir IMPLEMENTATION. ENDCASE. ENDLOOP. -* look for subpackages - IF iv_ignore_subpackages = abap_false. - SELECT * FROM tdevc INTO TABLE lt_tdevc - WHERE parentcl = iv_package - ORDER BY PRIMARY KEY. "#EC CI_SUBRC "#EC CI_GENBUFF - ENDIF. - - LOOP AT lt_tdevc ASSIGNING . - lt_tadir = build( iv_package = -devclass - iv_only_local_objects = iv_only_local_objects - iv_top = iv_top - io_dot = io_dot - io_log = io_log - io_folder_logic = lo_folder_logic ). "Hand down existing folder logic instance - APPEND LINES OF lt_tadir TO rt_tadir. - ENDLOOP. - ENDMETHOD. "build