APACK: Replace interface name with constant (#4684)

* APACK: Replace interface name with constant

Closes #4248

* Lint

Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
Marc Bernard 2021-04-03 08:59:44 +02:00 committed by GitHub
parent de6f8b9bbc
commit bf5199b8d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 93 additions and 72 deletions

View File

@ -63,7 +63,7 @@ ENDCLASS.
CLASS ZCL_ABAPGIT_APACK_HELPER IMPLEMENTATION. CLASS zcl_abapgit_apack_helper IMPLEMENTATION.
METHOD are_dependencies_met. METHOD are_dependencies_met.
@ -155,7 +155,8 @@ CLASS ZCL_ABAPGIT_APACK_HELPER IMPLEMENTATION.
WHERE tadir~pgmid = 'R3TR' WHERE tadir~pgmid = 'R3TR'
AND tadir~object = 'CLAS' AND tadir~object = 'CLAS'
AND seometarel~version = '1' AND seometarel~version = '1'
AND ( seometarel~refclsname = 'ZIF_APACK_MANIFEST' OR seometarel~refclsname = 'IF_APACK_MANIFEST' ). AND ( seometarel~refclsname = zif_abapgit_apack_definitions=>c_apack_interface_cust
OR seometarel~refclsname = zif_abapgit_apack_definitions=>c_apack_interface_sap ).
LOOP AT lt_manifest_implementation INTO ls_manifest_implementation. LOOP AT lt_manifest_implementation INTO ls_manifest_implementation.
CLEAR: lo_manifest_provider, lo_apack_reader. CLEAR: lo_manifest_provider, lo_apack_reader.

View File

@ -10,18 +10,31 @@ CLASS zcl_abapgit_apack_migration DEFINITION
PROTECTED SECTION. PROTECTED SECTION.
PRIVATE SECTION. PRIVATE SECTION.
CONSTANTS: c_interface_name TYPE seoclsname VALUE 'ZIF_APACK_MANIFEST' ##NO_TEXT. METHODS interface_exists
RETURNING
METHODS: VALUE(rv_interface_exists) TYPE abap_bool .
interface_exists RETURNING VALUE(rv_interface_exists) TYPE abap_bool, METHODS interface_valid
interface_valid RETURNING VALUE(rv_interface_valid) TYPE abap_bool, RETURNING
create_interface RAISING zcx_abapgit_exception, VALUE(rv_interface_valid) TYPE abap_bool .
add_interface_source_classic IMPORTING is_clskey TYPE seoclskey METHODS create_interface
RAISING zcx_abapgit_exception, RAISING
add_interface_source IMPORTING is_clskey TYPE seoclskey zcx_abapgit_exception .
RAISING zcx_abapgit_exception, METHODS add_interface_source_classic
get_interface_source RETURNING VALUE(rt_source) TYPE zif_abapgit_definitions=>ty_string_tt, IMPORTING
add_intf_source_and_activate RAISING zcx_abapgit_exception. !is_clskey TYPE seoclskey
RAISING
zcx_abapgit_exception .
METHODS add_interface_source
IMPORTING
!is_clskey TYPE seoclskey
RAISING
zcx_abapgit_exception .
METHODS get_interface_source
RETURNING
VALUE(rt_source) TYPE zif_abapgit_definitions=>ty_string_tt .
METHODS add_intf_source_and_activate
RAISING
zcx_abapgit_exception .
ENDCLASS. ENDCLASS.
@ -103,11 +116,41 @@ CLASS zcl_abapgit_apack_migration IMPLEMENTATION.
ENDMETHOD. ENDMETHOD.
METHOD add_intf_source_and_activate.
DATA: ls_clskey TYPE seoclskey,
ls_inactive_object TYPE dwinactiv,
lt_inactive_objects TYPE TABLE OF dwinactiv.
ls_clskey-clsname = zif_abapgit_apack_definitions=>c_apack_interface_cust.
add_interface_source( ls_clskey ).
ls_inactive_object-object = 'INTF'.
ls_inactive_object-obj_name = zif_abapgit_apack_definitions=>c_apack_interface_cust.
INSERT ls_inactive_object INTO TABLE lt_inactive_objects.
CALL FUNCTION 'RS_WORKING_OBJECTS_ACTIVATE'
TABLES
objects = lt_inactive_objects
EXCEPTIONS
excecution_error = 1
cancelled = 2
insert_into_corr_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
zcx_abapgit_exception=>raise_t100( ).
ENDIF.
ENDMETHOD.
METHOD create_interface. METHOD create_interface.
DATA: ls_interface_properties TYPE vseointerf. DATA: ls_interface_properties TYPE vseointerf.
ls_interface_properties-clsname = c_interface_name. ls_interface_properties-clsname = zif_abapgit_apack_definitions=>c_apack_interface_cust.
ls_interface_properties-version = '1'. ls_interface_properties-version = '1'.
ls_interface_properties-langu = 'E'. ls_interface_properties-langu = 'E'.
ls_interface_properties-descript = 'APACK: Manifest interface'. ls_interface_properties-descript = 'APACK: Manifest interface'.
@ -193,12 +236,24 @@ CLASS zcl_abapgit_apack_migration IMPLEMENTATION.
DATA: lv_interface_name TYPE seoclsname. DATA: lv_interface_name TYPE seoclsname.
SELECT SINGLE clsname FROM seoclass INTO lv_interface_name WHERE clsname = c_interface_name. SELECT SINGLE clsname FROM seoclass INTO lv_interface_name
WHERE clsname = zif_abapgit_apack_definitions=>c_apack_interface_cust.
rv_interface_exists = boolc( sy-subrc = 0 ). rv_interface_exists = boolc( sy-subrc = 0 ).
ENDMETHOD. ENDMETHOD.
METHOD interface_valid.
FIELD-SYMBOLS: <lv_interface_vers> TYPE i.
ASSIGN (zif_abapgit_apack_definitions=>c_apack_interface_cust)=>('CO_INTERFACE_VERSION') TO <lv_interface_vers>.
rv_interface_valid = boolc( <lv_interface_vers> IS ASSIGNED
AND <lv_interface_vers> >= c_apack_interface_version ).
ENDMETHOD.
METHOD perform_migration. METHOD perform_migration.
IF interface_exists( ) = abap_false. IF interface_exists( ) = abap_false.
@ -218,45 +273,4 @@ CLASS zcl_abapgit_apack_migration IMPLEMENTATION.
lo_apack_migration->perform_migration( ). lo_apack_migration->perform_migration( ).
ENDMETHOD. ENDMETHOD.
METHOD interface_valid.
FIELD-SYMBOLS: <lv_interface_version> TYPE i.
ASSIGN ('ZIF_APACK_MANIFEST')=>('CO_INTERFACE_VERSION') TO <lv_interface_version>.
rv_interface_valid = boolc( <lv_interface_version> IS ASSIGNED
AND <lv_interface_version> >= c_apack_interface_version ).
ENDMETHOD.
METHOD add_intf_source_and_activate.
DATA: ls_clskey TYPE seoclskey,
ls_inactive_object TYPE dwinactiv,
lt_inactive_objects TYPE TABLE OF dwinactiv.
ls_clskey-clsname = c_interface_name.
add_interface_source( ls_clskey ).
ls_inactive_object-object = 'INTF'.
ls_inactive_object-obj_name = c_interface_name.
INSERT ls_inactive_object INTO TABLE lt_inactive_objects.
CALL FUNCTION 'RS_WORKING_OBJECTS_ACTIVATE'
TABLES
objects = lt_inactive_objects
EXCEPTIONS
excecution_error = 1
cancelled = 2
insert_into_corr_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
zcx_abapgit_exception=>raise_t100( ).
ENDIF.
ENDMETHOD.
ENDCLASS. ENDCLASS.

View File

@ -70,7 +70,7 @@ ENDCLASS.
CLASS ZCL_ABAPGIT_APACK_READER IMPLEMENTATION. CLASS zcl_abapgit_apack_reader IMPLEMENTATION.
METHOD constructor. METHOD constructor.
@ -82,15 +82,20 @@ CLASS ZCL_ABAPGIT_APACK_READER IMPLEMENTATION.
DATA: ls_my_manifest_wo_deps TYPE zif_abapgit_apack_definitions=>ty_descriptor_wo_dependencies, DATA: ls_my_manifest_wo_deps TYPE zif_abapgit_apack_definitions=>ty_descriptor_wo_dependencies,
ls_my_dependency TYPE zif_abapgit_apack_definitions=>ty_dependency, ls_my_dependency TYPE zif_abapgit_apack_definitions=>ty_dependency,
ls_descriptor TYPE zif_abapgit_apack_definitions=>ty_descriptor. ls_descriptor TYPE zif_abapgit_apack_definitions=>ty_descriptor,
lv_descriptor_cust TYPE string,
lv_descriptor_sap TYPE string.
FIELD-SYMBOLS: <lg_descriptor> TYPE any, FIELD-SYMBOLS: <lg_descriptor> TYPE any,
<lt_dependencies> TYPE ANY TABLE, <lt_dependencies> TYPE ANY TABLE,
<lg_dependency> TYPE any. <lg_dependency> TYPE any.
ASSIGN io_manifest_provider->('ZIF_APACK_MANIFEST~DESCRIPTOR') TO <lg_descriptor>. lv_descriptor_cust = zif_abapgit_apack_definitions=>c_apack_interface_cust && '~DESCRIPTOR'.
lv_descriptor_sap = zif_abapgit_apack_definitions=>c_apack_interface_sap && '~DESCRIPTOR'.
ASSIGN io_manifest_provider->(lv_descriptor_cust) TO <lg_descriptor>.
IF <lg_descriptor> IS NOT ASSIGNED. IF <lg_descriptor> IS NOT ASSIGNED.
ASSIGN io_manifest_provider->('IF_APACK_MANIFEST~DESCRIPTOR') TO <lg_descriptor>. ASSIGN io_manifest_provider->(lv_descriptor_sap) TO <lg_descriptor>.
ENDIF. ENDIF.
IF <lg_descriptor> IS ASSIGNED. IF <lg_descriptor> IS ASSIGNED.
" A little more complex than a normal MOVE-CORRSPONDING " A little more complex than a normal MOVE-CORRSPONDING
@ -175,7 +180,7 @@ CLASS ZCL_ABAPGIT_APACK_READER IMPLEMENTATION.
WHERE tadir~pgmid = 'R3TR' AND WHERE tadir~pgmid = 'R3TR' AND
tadir~object = 'CLAS' AND tadir~object = 'CLAS' AND
seometarel~version = '1' AND seometarel~version = '1' AND
seometarel~refclsname = 'ZIF_APACK_MANIFEST' AND seometarel~refclsname = zif_abapgit_apack_definitions=>c_apack_interface_cust AND
tadir~devclass = mv_package_name. tadir~devclass = mv_package_name.
IF ls_manifest_implementation IS INITIAL. IF ls_manifest_implementation IS INITIAL.
SELECT SINGLE seometarel~clsname tadir~devclass FROM seometarel "#EC CI_NOORDER SELECT SINGLE seometarel~clsname tadir~devclass FROM seometarel "#EC CI_NOORDER
@ -184,7 +189,7 @@ CLASS ZCL_ABAPGIT_APACK_READER IMPLEMENTATION.
WHERE tadir~pgmid = 'R3TR' AND WHERE tadir~pgmid = 'R3TR' AND
tadir~object = 'CLAS' AND tadir~object = 'CLAS' AND
seometarel~version = '1' AND seometarel~version = '1' AND
seometarel~refclsname = 'IF_APACK_MANIFEST' AND seometarel~refclsname = zif_abapgit_apack_definitions=>c_apack_interface_sap AND
tadir~devclass = mv_package_name. tadir~devclass = mv_package_name.
ENDIF. ENDIF.
IF ls_manifest_implementation IS NOT INITIAL. IF ls_manifest_implementation IS NOT INITIAL.

View File

@ -1,4 +1,5 @@
INTERFACE zif_abapgit_apack_definitions PUBLIC. INTERFACE zif_abapgit_apack_definitions PUBLIC .
TYPES: TYPES:
BEGIN OF ty_dependency, BEGIN OF ty_dependency,
@ -9,7 +10,6 @@ INTERFACE zif_abapgit_apack_definitions PUBLIC.
git_url TYPE string, git_url TYPE string,
target_package TYPE devclass, target_package TYPE devclass,
END OF ty_dependency, END OF ty_dependency,
ty_dependencies TYPE STANDARD TABLE OF ty_dependency ty_dependencies TYPE STANDARD TABLE OF ty_dependency
WITH NON-UNIQUE DEFAULT KEY, WITH NON-UNIQUE DEFAULT KEY,
@ -34,5 +34,6 @@ INTERFACE zif_abapgit_apack_definitions PUBLIC.
CONSTANTS c_dot_apack_manifest TYPE string VALUE '.apack-manifest.xml' ##NO_TEXT. CONSTANTS c_dot_apack_manifest TYPE string VALUE '.apack-manifest.xml' ##NO_TEXT.
CONSTANTS c_repository_type_abapgit TYPE ty_repository_type VALUE 'abapGit' ##NO_TEXT. CONSTANTS c_repository_type_abapgit TYPE ty_repository_type VALUE 'abapGit' ##NO_TEXT.
CONSTANTS c_apack_interface_sap TYPE seoclsname VALUE 'IF_APACK_MANIFEST' ##NO_TEXT.
CONSTANTS c_apack_interface_cust TYPE seoclsname VALUE 'ZIF_APACK_MANIFEST' ##NO_TEXT.
ENDINTERFACE. ENDINTERFACE.

View File

@ -303,7 +303,7 @@ CLASS zcl_abapgit_object_clas IMPLEMENTATION.
" Check if SAP-version of APACK manifest exists " Check if SAP-version of APACK manifest exists
SELECT SINGLE clsname INTO lv_apack SELECT SINGLE clsname INTO lv_apack
FROM seoclass FROM seoclass
WHERE clsname = 'IF_APACK_MANIFEST'. WHERE clsname = zif_abapgit_apack_definitions=>c_apack_interface_sap.
IF sy-subrc = 0. IF sy-subrc = 0.
RETURN. RETURN.
ENDIF. ENDIF.
@ -311,8 +311,8 @@ CLASS zcl_abapgit_object_clas IMPLEMENTATION.
" If not, replace with abapGit version " If not, replace with abapGit version
interface_replacement( interface_replacement(
EXPORTING EXPORTING
iv_from_interface = 'if_apack_manifest' iv_from_interface = to_lower( zif_abapgit_apack_definitions=>c_apack_interface_sap )
iv_to_interface = 'zif_apack_manifest' iv_to_interface = to_lower( zif_abapgit_apack_definitions=>c_apack_interface_cust )
CHANGING CHANGING
ct_source = ct_source ). ct_source = ct_source ).
@ -524,7 +524,7 @@ CLASS zcl_abapgit_object_clas IMPLEMENTATION.
SELECT SINGLE clsname INTO lv_clsname SELECT SINGLE clsname INTO lv_clsname
FROM seometarel FROM seometarel
WHERE clsname = ms_item-obj_name WHERE clsname = ms_item-obj_name
AND refclsname = 'ZIF_APACK_MANIFEST' AND refclsname = zif_abapgit_apack_definitions=>c_apack_interface_cust
AND version = '1'. AND version = '1'.
IF sy-subrc <> 0. IF sy-subrc <> 0.
RETURN. RETURN.
@ -533,8 +533,8 @@ CLASS zcl_abapgit_object_clas IMPLEMENTATION.
" If yes, replace with SAP-version " If yes, replace with SAP-version
interface_replacement( interface_replacement(
EXPORTING EXPORTING
iv_from_interface = 'zif_apack_manifest' iv_from_interface = to_lower( zif_abapgit_apack_definitions=>c_apack_interface_cust )
iv_to_interface = 'if_apack_manifest' iv_to_interface = to_lower( zif_abapgit_apack_definitions=>c_apack_interface_sap )
CHANGING CHANGING
ct_source = ct_source ). ct_source = ct_source ).