mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-02 04:36:49 +08:00
Merge pull request #1122 from larshp/lcl_sap_package
lcl_sap_package to global
This commit is contained in:
commit
fc6737fdf2
|
@ -65,10 +65,10 @@ CLASS lcl_folder_logic IMPLEMENTATION.
|
||||||
|
|
||||||
TRANSLATE rv_package TO UPPER CASE.
|
TRANSLATE rv_package TO UPPER CASE.
|
||||||
|
|
||||||
IF lcl_sap_package=>get( rv_package )->exists( ) = abap_false AND
|
IF zcl_abapgit_sap_package=>get( rv_package )->exists( ) = abap_false AND
|
||||||
iv_create_if_not_exists = abap_true.
|
iv_create_if_not_exists = abap_true.
|
||||||
|
|
||||||
lcl_sap_package=>get( lv_parent )->create_child( rv_package ).
|
zcl_abapgit_sap_package=>get( lv_parent )->create_child( rv_package ).
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
lv_parent = rv_package.
|
lv_parent = rv_package.
|
||||||
|
@ -86,7 +86,7 @@ CLASS lcl_folder_logic IMPLEMENTATION.
|
||||||
IF iv_top = iv_package.
|
IF iv_top = iv_package.
|
||||||
rv_path = io_dot->get_starting_folder( ).
|
rv_path = io_dot->get_starting_folder( ).
|
||||||
ELSE.
|
ELSE.
|
||||||
lv_parentcl = lcl_sap_package=>get( iv_package )->read_parent( ).
|
lv_parentcl = zcl_abapgit_sap_package=>get( iv_package )->read_parent( ).
|
||||||
|
|
||||||
IF lv_parentcl IS INITIAL.
|
IF lv_parentcl IS INITIAL.
|
||||||
zcx_abapgit_exception=>raise( |error, expected parent package, { iv_package }| ).
|
zcx_abapgit_exception=>raise( |error, expected parent package, { iv_package }| ).
|
||||||
|
@ -193,7 +193,7 @@ ENDCLASS.
|
||||||
CLASS ltcl_folder_logic DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL.
|
CLASS ltcl_folder_logic DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL.
|
||||||
|
|
||||||
PUBLIC SECTION.
|
PUBLIC SECTION.
|
||||||
INTERFACES: lif_sap_package.
|
INTERFACES: zif_abapgit_sap_package.
|
||||||
|
|
||||||
PRIVATE SECTION.
|
PRIVATE SECTION.
|
||||||
CONSTANTS: lc_top TYPE devclass VALUE '$TOP',
|
CONSTANTS: lc_top TYPE devclass VALUE '$TOP',
|
||||||
|
@ -212,46 +212,46 @@ ENDCLASS. "ltcl_convert DEFINITION
|
||||||
|
|
||||||
CLASS ltcl_folder_logic IMPLEMENTATION.
|
CLASS ltcl_folder_logic IMPLEMENTATION.
|
||||||
|
|
||||||
METHOD lif_sap_package~list_subpackages.
|
METHOD zif_abapgit_sap_package~list_subpackages.
|
||||||
RETURN.
|
RETURN.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD lif_sap_package~list_superpackages.
|
METHOD zif_abapgit_sap_package~list_superpackages.
|
||||||
RETURN.
|
RETURN.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD lif_sap_package~read_parent.
|
METHOD zif_abapgit_sap_package~read_parent.
|
||||||
rv_parentcl = '$TOP'.
|
rv_parentcl = '$TOP'.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD lif_sap_package~create_child.
|
METHOD zif_abapgit_sap_package~create_child.
|
||||||
RETURN.
|
RETURN.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD lif_sap_package~exists.
|
METHOD zif_abapgit_sap_package~exists.
|
||||||
rv_bool = abap_true.
|
rv_bool = abap_true.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD setup.
|
METHOD setup.
|
||||||
FIELD-SYMBOLS: <ls_inject> LIKE LINE OF lcl_sap_package=>gt_injected.
|
FIELD-SYMBOLS: <ls_inject> LIKE LINE OF zcl_abapgit_sap_package=>gt_injected.
|
||||||
|
|
||||||
CLEAR lcl_sap_package=>gt_injected.
|
CLEAR zcl_abapgit_sap_package=>gt_injected.
|
||||||
|
|
||||||
APPEND INITIAL LINE TO lcl_sap_package=>gt_injected ASSIGNING <ls_inject>.
|
APPEND INITIAL LINE TO zcl_abapgit_sap_package=>gt_injected ASSIGNING <ls_inject>.
|
||||||
<ls_inject>-package = '$TOP'.
|
<ls_inject>-package = '$TOP'.
|
||||||
<ls_inject>-object = me.
|
<ls_inject>-object = me.
|
||||||
|
|
||||||
APPEND INITIAL LINE TO lcl_sap_package=>gt_injected ASSIGNING <ls_inject>.
|
APPEND INITIAL LINE TO zcl_abapgit_sap_package=>gt_injected ASSIGNING <ls_inject>.
|
||||||
<ls_inject>-package = '$TOP_FOO'.
|
<ls_inject>-package = '$TOP_FOO'.
|
||||||
<ls_inject>-object = me.
|
<ls_inject>-object = me.
|
||||||
|
|
||||||
APPEND INITIAL LINE TO lcl_sap_package=>gt_injected ASSIGNING <ls_inject>.
|
APPEND INITIAL LINE TO zcl_abapgit_sap_package=>gt_injected ASSIGNING <ls_inject>.
|
||||||
<ls_inject>-package = '$FOOBAR'.
|
<ls_inject>-package = '$FOOBAR'.
|
||||||
<ls_inject>-object = me.
|
<ls_inject>-object = me.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD teardown.
|
METHOD teardown.
|
||||||
CLEAR lcl_sap_package=>gt_injected.
|
CLEAR zcl_abapgit_sap_package=>gt_injected.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD prefix1.
|
METHOD prefix1.
|
||||||
|
@ -309,7 +309,7 @@ ENDCLASS.
|
||||||
CLASS ltcl_folder_logic_namespaces DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL.
|
CLASS ltcl_folder_logic_namespaces DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT FINAL.
|
||||||
|
|
||||||
PUBLIC SECTION.
|
PUBLIC SECTION.
|
||||||
INTERFACES: lif_sap_package.
|
INTERFACES: zif_abapgit_sap_package.
|
||||||
|
|
||||||
PRIVATE SECTION.
|
PRIVATE SECTION.
|
||||||
CONSTANTS: lc_top TYPE devclass VALUE '/TEST/TOOLS',
|
CONSTANTS: lc_top TYPE devclass VALUE '/TEST/TOOLS',
|
||||||
|
@ -327,46 +327,46 @@ ENDCLASS. "ltcl_convert DEFINITION
|
||||||
|
|
||||||
CLASS ltcl_folder_logic_namespaces IMPLEMENTATION.
|
CLASS ltcl_folder_logic_namespaces IMPLEMENTATION.
|
||||||
|
|
||||||
METHOD lif_sap_package~list_subpackages.
|
METHOD zif_abapgit_sap_package~list_subpackages.
|
||||||
RETURN.
|
RETURN.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD lif_sap_package~list_superpackages.
|
METHOD zif_abapgit_sap_package~list_superpackages.
|
||||||
RETURN.
|
RETURN.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD lif_sap_package~read_parent.
|
METHOD zif_abapgit_sap_package~read_parent.
|
||||||
rv_parentcl = lc_top.
|
rv_parentcl = lc_top.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD lif_sap_package~create_child.
|
METHOD zif_abapgit_sap_package~create_child.
|
||||||
RETURN.
|
RETURN.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD lif_sap_package~exists.
|
METHOD zif_abapgit_sap_package~exists.
|
||||||
rv_bool = abap_true.
|
rv_bool = abap_true.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD setup.
|
METHOD setup.
|
||||||
FIELD-SYMBOLS: <ls_inject> LIKE LINE OF lcl_sap_package=>gt_injected.
|
FIELD-SYMBOLS: <ls_inject> LIKE LINE OF zcl_abapgit_sap_package=>gt_injected.
|
||||||
|
|
||||||
CLEAR lcl_sap_package=>gt_injected.
|
CLEAR zcl_abapgit_sap_package=>gt_injected.
|
||||||
|
|
||||||
APPEND INITIAL LINE TO lcl_sap_package=>gt_injected ASSIGNING <ls_inject>.
|
APPEND INITIAL LINE TO zcl_abapgit_sap_package=>gt_injected ASSIGNING <ls_inject>.
|
||||||
<ls_inject>-package = '/TEST/TOOLS'.
|
<ls_inject>-package = '/TEST/TOOLS'.
|
||||||
<ls_inject>-object = me.
|
<ls_inject>-object = me.
|
||||||
|
|
||||||
APPEND INITIAL LINE TO lcl_sap_package=>gt_injected ASSIGNING <ls_inject>.
|
APPEND INITIAL LINE TO zcl_abapgit_sap_package=>gt_injected ASSIGNING <ls_inject>.
|
||||||
<ls_inject>-package = '/TEST/T1'.
|
<ls_inject>-package = '/TEST/T1'.
|
||||||
<ls_inject>-object = me.
|
<ls_inject>-object = me.
|
||||||
|
|
||||||
APPEND INITIAL LINE TO lcl_sap_package=>gt_injected ASSIGNING <ls_inject>.
|
APPEND INITIAL LINE TO zcl_abapgit_sap_package=>gt_injected ASSIGNING <ls_inject>.
|
||||||
<ls_inject>-package = '/TEST/TOOLS_T1'.
|
<ls_inject>-package = '/TEST/TOOLS_T1'.
|
||||||
<ls_inject>-object = me.
|
<ls_inject>-object = me.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD teardown.
|
METHOD teardown.
|
||||||
CLEAR lcl_sap_package=>gt_injected.
|
CLEAR zcl_abapgit_sap_package=>gt_injected.
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD prefix1.
|
METHOD prefix1.
|
||||||
|
|
|
@ -110,7 +110,7 @@ FORM branch_popup TABLES tt_fields TYPE zif_abapgit_definitions=>ty_sval_tt
|
||||||
RETURN.
|
RETURN.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
lcl_sap_package=>create( ls_package_data ).
|
zcl_abapgit_sap_package=>create( ls_package_data ).
|
||||||
COMMIT WORK.
|
COMMIT WORK.
|
||||||
|
|
||||||
<ls_fpackage>-value = ls_package_data-devclass.
|
<ls_fpackage>-value = ls_package_data-devclass.
|
||||||
|
@ -145,7 +145,7 @@ FORM package_popup TABLES tt_fields TYPE zif_abapgit_definitions=>ty_sval_tt
|
||||||
RETURN.
|
RETURN.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
lcl_sap_package=>create( ls_package_data ).
|
zcl_abapgit_sap_package=>create( ls_package_data ).
|
||||||
COMMIT WORK.
|
COMMIT WORK.
|
||||||
|
|
||||||
<ls_fpackage>-value = ls_package_data-devclass.
|
<ls_fpackage>-value = ls_package_data-devclass.
|
||||||
|
|
|
@ -93,12 +93,12 @@ CLASS lcl_objects IMPLEMENTATION.
|
||||||
|
|
||||||
METHOD update_package_tree.
|
METHOD update_package_tree.
|
||||||
|
|
||||||
DATA: lt_packages TYPE lif_sap_package=>ty_devclass_tt,
|
DATA: lt_packages TYPE zif_abapgit_sap_package=>ty_devclass_tt,
|
||||||
lv_package LIKE LINE OF lt_packages,
|
lv_package LIKE LINE OF lt_packages,
|
||||||
lv_tree TYPE dirtree-tname.
|
lv_tree TYPE dirtree-tname.
|
||||||
|
|
||||||
|
|
||||||
lt_packages = lcl_sap_package=>get( iv_package )->list_subpackages( ).
|
lt_packages = zcl_abapgit_sap_package=>get( iv_package )->list_subpackages( ).
|
||||||
APPEND iv_package TO lt_packages.
|
APPEND iv_package TO lt_packages.
|
||||||
|
|
||||||
LOOP AT lt_packages INTO lv_package.
|
LOOP AT lt_packages INTO lv_package.
|
||||||
|
|
|
@ -2,287 +2,4 @@
|
||||||
*& Include ZABAPGIT_SAP_PACKAGE
|
*& Include ZABAPGIT_SAP_PACKAGE
|
||||||
*&---------------------------------------------------------------------*
|
*&---------------------------------------------------------------------*
|
||||||
|
|
||||||
INTERFACE lif_sap_package.
|
* todo, include to be deleted
|
||||||
|
|
||||||
TYPES: ty_devclass_tt TYPE STANDARD TABLE OF devclass WITH DEFAULT KEY.
|
|
||||||
|
|
||||||
METHODS:
|
|
||||||
list_subpackages
|
|
||||||
RETURNING VALUE(rt_list) TYPE ty_devclass_tt,
|
|
||||||
list_superpackages
|
|
||||||
RETURNING VALUE(rt_list) TYPE ty_devclass_tt,
|
|
||||||
read_parent
|
|
||||||
RETURNING VALUE(rv_parentcl) TYPE tdevc-parentcl,
|
|
||||||
create_child
|
|
||||||
IMPORTING iv_child TYPE devclass
|
|
||||||
RAISING zcx_abapgit_exception,
|
|
||||||
exists
|
|
||||||
RETURNING VALUE(rv_bool) TYPE abap_bool.
|
|
||||||
|
|
||||||
ENDINTERFACE.
|
|
||||||
|
|
||||||
CLASS ltcl_folder_logic DEFINITION DEFERRED.
|
|
||||||
CLASS ltcl_folder_logic_namespaces DEFINITION DEFERRED.
|
|
||||||
|
|
||||||
*----------------------------------------------------------------------*
|
|
||||||
* CLASS lcl_package DEFINITION
|
|
||||||
*----------------------------------------------------------------------*
|
|
||||||
*
|
|
||||||
*----------------------------------------------------------------------*
|
|
||||||
CLASS lcl_sap_package DEFINITION FINAL CREATE PRIVATE
|
|
||||||
FRIENDS
|
|
||||||
ltcl_folder_logic
|
|
||||||
ltcl_folder_logic_namespaces.
|
|
||||||
|
|
||||||
PUBLIC SECTION.
|
|
||||||
CLASS-METHODS:
|
|
||||||
get
|
|
||||||
IMPORTING iv_package TYPE devclass
|
|
||||||
RETURNING VALUE(ri_package) TYPE REF TO lif_sap_package,
|
|
||||||
create
|
|
||||||
IMPORTING is_package TYPE scompkdtln
|
|
||||||
RAISING zcx_abapgit_exception,
|
|
||||||
create_local
|
|
||||||
IMPORTING iv_package TYPE devclass
|
|
||||||
RAISING zcx_abapgit_exception.
|
|
||||||
|
|
||||||
METHODS:
|
|
||||||
constructor
|
|
||||||
IMPORTING iv_package TYPE devclass.
|
|
||||||
|
|
||||||
INTERFACES: lif_sap_package.
|
|
||||||
|
|
||||||
PRIVATE SECTION.
|
|
||||||
TYPES: BEGIN OF ty_injected,
|
|
||||||
package TYPE devclass,
|
|
||||||
object TYPE REF TO lif_sap_package,
|
|
||||||
END OF ty_injected.
|
|
||||||
|
|
||||||
CLASS-DATA: gt_injected TYPE STANDARD TABLE OF ty_injected.
|
|
||||||
|
|
||||||
DATA: mv_package TYPE devclass.
|
|
||||||
|
|
||||||
ENDCLASS. "lcl_package DEFINITION
|
|
||||||
|
|
||||||
*----------------------------------------------------------------------*
|
|
||||||
* CLASS lcl_package IMPLEMENTATION
|
|
||||||
*----------------------------------------------------------------------*
|
|
||||||
*
|
|
||||||
*----------------------------------------------------------------------*
|
|
||||||
CLASS lcl_sap_package IMPLEMENTATION.
|
|
||||||
|
|
||||||
METHOD get.
|
|
||||||
|
|
||||||
FIELD-SYMBOLS: <ls_injected> LIKE LINE OF gt_injected.
|
|
||||||
|
|
||||||
IF lines( gt_injected ) > 0.
|
|
||||||
READ TABLE gt_injected ASSIGNING <ls_injected> WITH KEY package = iv_package.
|
|
||||||
ASSERT sy-subrc = 0. " unit test should be in control
|
|
||||||
ri_package = <ls_injected>-object.
|
|
||||||
ELSE.
|
|
||||||
CREATE OBJECT ri_package TYPE lcl_sap_package
|
|
||||||
EXPORTING
|
|
||||||
iv_package = iv_package.
|
|
||||||
ENDIF.
|
|
||||||
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD constructor.
|
|
||||||
mv_package = iv_package.
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD lif_sap_package~exists.
|
|
||||||
|
|
||||||
cl_package_factory=>load_package(
|
|
||||||
EXPORTING
|
|
||||||
i_package_name = mv_package
|
|
||||||
EXCEPTIONS
|
|
||||||
object_not_existing = 1
|
|
||||||
unexpected_error = 2
|
|
||||||
intern_err = 3
|
|
||||||
no_access = 4
|
|
||||||
object_locked_and_modified = 5 ).
|
|
||||||
rv_bool = boolc( sy-subrc <> 1 ).
|
|
||||||
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD lif_sap_package~create_child.
|
|
||||||
|
|
||||||
DATA: li_parent TYPE REF TO if_package,
|
|
||||||
ls_child TYPE scompkdtln.
|
|
||||||
|
|
||||||
|
|
||||||
cl_package_factory=>load_package(
|
|
||||||
EXPORTING
|
|
||||||
i_package_name = mv_package
|
|
||||||
IMPORTING
|
|
||||||
e_package = li_parent
|
|
||||||
EXCEPTIONS
|
|
||||||
object_not_existing = 1
|
|
||||||
unexpected_error = 2
|
|
||||||
intern_err = 3
|
|
||||||
no_access = 4
|
|
||||||
object_locked_and_modified = 5 ).
|
|
||||||
IF sy-subrc <> 0.
|
|
||||||
zcx_abapgit_exception=>raise( 'error reading parent package' ).
|
|
||||||
ENDIF.
|
|
||||||
|
|
||||||
ls_child-devclass = iv_child.
|
|
||||||
ls_child-dlvunit = li_parent->software_component.
|
|
||||||
ls_child-ctext = iv_child.
|
|
||||||
ls_child-parentcl = mv_package.
|
|
||||||
ls_child-pdevclass = li_parent->transport_layer.
|
|
||||||
ls_child-as4user = sy-uname.
|
|
||||||
|
|
||||||
create( ls_child ).
|
|
||||||
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD create.
|
|
||||||
|
|
||||||
DATA: lv_err TYPE string,
|
|
||||||
li_package TYPE REF TO if_package,
|
|
||||||
ls_package LIKE is_package.
|
|
||||||
|
|
||||||
|
|
||||||
ASSERT NOT is_package-devclass IS INITIAL.
|
|
||||||
|
|
||||||
cl_package_factory=>load_package(
|
|
||||||
EXPORTING
|
|
||||||
i_package_name = is_package-devclass
|
|
||||||
EXCEPTIONS
|
|
||||||
object_not_existing = 1
|
|
||||||
unexpected_error = 2
|
|
||||||
intern_err = 3
|
|
||||||
no_access = 4
|
|
||||||
object_locked_and_modified = 5 ).
|
|
||||||
IF sy-subrc = 0.
|
|
||||||
" Package already exists. We assume this is fine. Its properties might be changed later at
|
|
||||||
" DEVC deserialization.
|
|
||||||
RETURN.
|
|
||||||
ENDIF.
|
|
||||||
|
|
||||||
ls_package = is_package.
|
|
||||||
|
|
||||||
" Set software component to 'HOME' if none is set at this point.
|
|
||||||
" Otherwise SOFTWARE_COMPONENT_INVALID will be raised.
|
|
||||||
IF ls_package-dlvunit IS INITIAL.
|
|
||||||
ls_package-dlvunit = 'HOME'.
|
|
||||||
ENDIF.
|
|
||||||
|
|
||||||
cl_package_factory=>create_new_package(
|
|
||||||
EXPORTING
|
|
||||||
i_reuse_deleted_object = abap_true
|
|
||||||
* i_suppress_dialog = abap_true " does not exist in 730
|
|
||||||
IMPORTING
|
|
||||||
e_package = li_package
|
|
||||||
CHANGING
|
|
||||||
c_package_data = ls_package
|
|
||||||
EXCEPTIONS
|
|
||||||
object_already_existing = 1
|
|
||||||
object_just_created = 2
|
|
||||||
not_authorized = 3
|
|
||||||
wrong_name_prefix = 4
|
|
||||||
undefined_name = 5
|
|
||||||
reserved_local_name = 6
|
|
||||||
invalid_package_name = 7
|
|
||||||
short_text_missing = 8
|
|
||||||
software_component_invalid = 9
|
|
||||||
layer_invalid = 10
|
|
||||||
author_not_existing = 11
|
|
||||||
component_not_existing = 12
|
|
||||||
component_missing = 13
|
|
||||||
prefix_in_use = 14
|
|
||||||
unexpected_error = 15
|
|
||||||
intern_err = 16
|
|
||||||
no_access = 17
|
|
||||||
* invalid_translation_depth = 18
|
|
||||||
* wrong_mainpack_value = 19
|
|
||||||
* superpackage_invalid = 20
|
|
||||||
* error_in_cts_checks = 21
|
|
||||||
OTHERS = 18 ).
|
|
||||||
IF sy-subrc <> 0.
|
|
||||||
zcx_abapgit_exception=>raise( |Package { is_package-devclass } could not be created| ).
|
|
||||||
ENDIF.
|
|
||||||
|
|
||||||
li_package->save(
|
|
||||||
* EXPORTING
|
|
||||||
* i_suppress_dialog = abap_true " Controls whether popups can be transmitted
|
|
||||||
EXCEPTIONS
|
|
||||||
object_invalid = 1
|
|
||||||
object_not_changeable = 2
|
|
||||||
cancelled_in_corr = 3
|
|
||||||
permission_failure = 4
|
|
||||||
unexpected_error = 5
|
|
||||||
intern_err = 6
|
|
||||||
OTHERS = 7 ).
|
|
||||||
IF sy-subrc <> 0.
|
|
||||||
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
|
|
||||||
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO lv_err.
|
|
||||||
zcx_abapgit_exception=>raise( lv_err ).
|
|
||||||
ENDIF.
|
|
||||||
|
|
||||||
li_package->set_changeable( abap_false ).
|
|
||||||
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD lif_sap_package~read_parent.
|
|
||||||
|
|
||||||
SELECT SINGLE parentcl FROM tdevc INTO rv_parentcl
|
|
||||||
WHERE devclass = mv_package. "#EC CI_SUBRC "#EC CI_GENBUFF
|
|
||||||
ASSERT sy-subrc = 0.
|
|
||||||
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD lif_sap_package~list_superpackages.
|
|
||||||
|
|
||||||
DATA: lt_list LIKE rt_list,
|
|
||||||
lv_parent TYPE tdevc-parentcl.
|
|
||||||
|
|
||||||
|
|
||||||
APPEND mv_package TO rt_list.
|
|
||||||
|
|
||||||
SELECT SINGLE parentcl INTO lv_parent
|
|
||||||
FROM tdevc WHERE devclass = mv_package. "#EC CI_GENBUFF
|
|
||||||
|
|
||||||
IF sy-subrc = 0 AND NOT lv_parent IS INITIAL.
|
|
||||||
APPEND lv_parent TO rt_list.
|
|
||||||
lt_list = get( lv_parent )->list_superpackages( ).
|
|
||||||
APPEND LINES OF lt_list TO rt_list.
|
|
||||||
ENDIF.
|
|
||||||
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD lif_sap_package~list_subpackages.
|
|
||||||
|
|
||||||
DATA: lt_list LIKE rt_list,
|
|
||||||
lv_devclass LIKE LINE OF rt_list.
|
|
||||||
|
|
||||||
|
|
||||||
SELECT devclass INTO TABLE rt_list
|
|
||||||
FROM tdevc WHERE parentcl = mv_package. "#EC CI_GENBUFF "#EC CI_SUBRC
|
|
||||||
|
|
||||||
* note the recursion, since packages are added to the list
|
|
||||||
LOOP AT rt_list INTO lv_devclass.
|
|
||||||
lt_list = get( lv_devclass )->list_subpackages( ).
|
|
||||||
APPEND LINES OF lt_list TO rt_list.
|
|
||||||
ENDLOOP.
|
|
||||||
|
|
||||||
ENDMETHOD.
|
|
||||||
|
|
||||||
METHOD create_local.
|
|
||||||
|
|
||||||
DATA: ls_package TYPE scompkdtln.
|
|
||||||
|
|
||||||
|
|
||||||
ls_package-devclass = iv_package.
|
|
||||||
ls_package-ctext = iv_package.
|
|
||||||
ls_package-parentcl = '$TMP'.
|
|
||||||
ls_package-dlvunit = 'LOCAL'.
|
|
||||||
ls_package-as4user = sy-uname.
|
|
||||||
|
|
||||||
create( ls_package ).
|
|
||||||
|
|
||||||
ENDMETHOD. "create
|
|
||||||
|
|
||||||
ENDCLASS. "lcl_package IMPLEMENTATION
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ CLASS lcl_services_abapgit IMPLEMENTATION.
|
||||||
iv_url = iv_url
|
iv_url = iv_url
|
||||||
iv_target_package = iv_package ).
|
iv_target_package = iv_package ).
|
||||||
|
|
||||||
lcl_sap_package=>create_local( iv_package ).
|
zcl_abapgit_sap_package=>create_local( iv_package ).
|
||||||
|
|
||||||
lo_repo = lcl_app=>repo_srv( )->new_online(
|
lo_repo = lcl_app=>repo_srv( )->new_online(
|
||||||
iv_url = iv_url
|
iv_url = iv_url
|
||||||
|
|
|
@ -80,8 +80,8 @@ CLASS lcl_transport IMPLEMENTATION.
|
||||||
METHOD find_top_package.
|
METHOD find_top_package.
|
||||||
* assumption: all objects in transport share a common super package
|
* assumption: all objects in transport share a common super package
|
||||||
|
|
||||||
DATA: lt_obj TYPE lif_sap_package=>ty_devclass_tt,
|
DATA: lt_obj TYPE zif_abapgit_sap_package=>ty_devclass_tt,
|
||||||
lt_super TYPE lif_sap_package=>ty_devclass_tt,
|
lt_super TYPE zif_abapgit_sap_package=>ty_devclass_tt,
|
||||||
lv_super LIKE LINE OF lt_super,
|
lv_super LIKE LINE OF lt_super,
|
||||||
lv_index TYPE i.
|
lv_index TYPE i.
|
||||||
|
|
||||||
|
@ -90,10 +90,10 @@ CLASS lcl_transport IMPLEMENTATION.
|
||||||
|
|
||||||
READ TABLE it_tadir INDEX 1 ASSIGNING <ls_tadir>.
|
READ TABLE it_tadir INDEX 1 ASSIGNING <ls_tadir>.
|
||||||
ASSERT sy-subrc = 0.
|
ASSERT sy-subrc = 0.
|
||||||
lt_super = lcl_sap_package=>get( <ls_tadir>-devclass )->list_superpackages( ).
|
lt_super = zcl_abapgit_sap_package=>get( <ls_tadir>-devclass )->list_superpackages( ).
|
||||||
|
|
||||||
LOOP AT it_tadir ASSIGNING <ls_tadir>.
|
LOOP AT it_tadir ASSIGNING <ls_tadir>.
|
||||||
lt_obj = lcl_sap_package=>get( <ls_tadir>-devclass )->list_superpackages( ).
|
lt_obj = zcl_abapgit_sap_package=>get( <ls_tadir>-devclass )->list_superpackages( ).
|
||||||
|
|
||||||
* filter out possibilities from lt_super
|
* filter out possibilities from lt_super
|
||||||
LOOP AT lt_super INTO lv_super.
|
LOOP AT lt_super INTO lv_super.
|
||||||
|
|
|
@ -112,7 +112,7 @@ CLASS ltcl_dangerous IMPLEMENTATION.
|
||||||
<lv_type> LIKE LINE OF lt_types.
|
<lv_type> LIKE LINE OF lt_types.
|
||||||
|
|
||||||
|
|
||||||
lcl_sap_package=>create_local( c_package ).
|
zcl_abapgit_sap_package=>create_local( c_package ).
|
||||||
|
|
||||||
lt_types = lcl_objects=>supported_list( ).
|
lt_types = lcl_objects=>supported_list( ).
|
||||||
|
|
||||||
|
|
260
src/zcl_abapgit_sap_package.clas.abap
Normal file
260
src/zcl_abapgit_sap_package.clas.abap
Normal file
|
@ -0,0 +1,260 @@
|
||||||
|
CLASS zcl_abapgit_sap_package DEFINITION PUBLIC CREATE PUBLIC.
|
||||||
|
|
||||||
|
PUBLIC SECTION.
|
||||||
|
CLASS-METHODS:
|
||||||
|
get
|
||||||
|
IMPORTING iv_package TYPE devclass
|
||||||
|
RETURNING VALUE(ri_package) TYPE REF TO zif_abapgit_sap_package,
|
||||||
|
create
|
||||||
|
IMPORTING is_package TYPE scompkdtln
|
||||||
|
RAISING zcx_abapgit_exception,
|
||||||
|
create_local
|
||||||
|
IMPORTING iv_package TYPE devclass
|
||||||
|
RAISING zcx_abapgit_exception.
|
||||||
|
|
||||||
|
METHODS:
|
||||||
|
constructor
|
||||||
|
IMPORTING iv_package TYPE devclass.
|
||||||
|
|
||||||
|
INTERFACES: zif_abapgit_sap_package.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_injected,
|
||||||
|
package TYPE devclass,
|
||||||
|
object TYPE REF TO zif_abapgit_sap_package,
|
||||||
|
END OF ty_injected.
|
||||||
|
|
||||||
|
* TODO, isolate this variable?
|
||||||
|
CLASS-DATA: gt_injected TYPE STANDARD TABLE OF ty_injected.
|
||||||
|
|
||||||
|
PRIVATE SECTION.
|
||||||
|
DATA: mv_package TYPE devclass.
|
||||||
|
|
||||||
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CLASS ZCL_ABAPGIT_SAP_PACKAGE IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
|
METHOD constructor.
|
||||||
|
mv_package = iv_package.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
|
METHOD create.
|
||||||
|
|
||||||
|
DATA: lv_err TYPE string,
|
||||||
|
li_package TYPE REF TO if_package,
|
||||||
|
ls_package LIKE is_package.
|
||||||
|
|
||||||
|
|
||||||
|
ASSERT NOT is_package-devclass IS INITIAL.
|
||||||
|
|
||||||
|
cl_package_factory=>load_package(
|
||||||
|
EXPORTING
|
||||||
|
i_package_name = is_package-devclass
|
||||||
|
EXCEPTIONS
|
||||||
|
object_not_existing = 1
|
||||||
|
unexpected_error = 2
|
||||||
|
intern_err = 3
|
||||||
|
no_access = 4
|
||||||
|
object_locked_and_modified = 5 ).
|
||||||
|
IF sy-subrc = 0.
|
||||||
|
" Package already exists. We assume this is fine. Its properties might be changed later at
|
||||||
|
" DEVC deserialization.
|
||||||
|
RETURN.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
ls_package = is_package.
|
||||||
|
|
||||||
|
" Set software component to 'HOME' if none is set at this point.
|
||||||
|
" Otherwise SOFTWARE_COMPONENT_INVALID will be raised.
|
||||||
|
IF ls_package-dlvunit IS INITIAL.
|
||||||
|
ls_package-dlvunit = 'HOME'.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
cl_package_factory=>create_new_package(
|
||||||
|
EXPORTING
|
||||||
|
i_reuse_deleted_object = abap_true
|
||||||
|
* i_suppress_dialog = abap_true " does not exist in 730
|
||||||
|
IMPORTING
|
||||||
|
e_package = li_package
|
||||||
|
CHANGING
|
||||||
|
c_package_data = ls_package
|
||||||
|
EXCEPTIONS
|
||||||
|
object_already_existing = 1
|
||||||
|
object_just_created = 2
|
||||||
|
not_authorized = 3
|
||||||
|
wrong_name_prefix = 4
|
||||||
|
undefined_name = 5
|
||||||
|
reserved_local_name = 6
|
||||||
|
invalid_package_name = 7
|
||||||
|
short_text_missing = 8
|
||||||
|
software_component_invalid = 9
|
||||||
|
layer_invalid = 10
|
||||||
|
author_not_existing = 11
|
||||||
|
component_not_existing = 12
|
||||||
|
component_missing = 13
|
||||||
|
prefix_in_use = 14
|
||||||
|
unexpected_error = 15
|
||||||
|
intern_err = 16
|
||||||
|
no_access = 17
|
||||||
|
* invalid_translation_depth = 18
|
||||||
|
* wrong_mainpack_value = 19
|
||||||
|
* superpackage_invalid = 20
|
||||||
|
* error_in_cts_checks = 21
|
||||||
|
OTHERS = 18 ).
|
||||||
|
IF sy-subrc <> 0.
|
||||||
|
zcx_abapgit_exception=>raise( |Package { is_package-devclass } could not be created| ).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
li_package->save(
|
||||||
|
* EXPORTING
|
||||||
|
* i_suppress_dialog = abap_true " Controls whether popups can be transmitted
|
||||||
|
EXCEPTIONS
|
||||||
|
object_invalid = 1
|
||||||
|
object_not_changeable = 2
|
||||||
|
cancelled_in_corr = 3
|
||||||
|
permission_failure = 4
|
||||||
|
unexpected_error = 5
|
||||||
|
intern_err = 6
|
||||||
|
OTHERS = 7 ).
|
||||||
|
IF sy-subrc <> 0.
|
||||||
|
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
|
||||||
|
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 INTO lv_err.
|
||||||
|
zcx_abapgit_exception=>raise( lv_err ).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
li_package->set_changeable( abap_false ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
|
METHOD create_local.
|
||||||
|
|
||||||
|
DATA: ls_package TYPE scompkdtln.
|
||||||
|
|
||||||
|
|
||||||
|
ls_package-devclass = iv_package.
|
||||||
|
ls_package-ctext = iv_package.
|
||||||
|
ls_package-parentcl = '$TMP'.
|
||||||
|
ls_package-dlvunit = 'LOCAL'.
|
||||||
|
ls_package-as4user = sy-uname.
|
||||||
|
|
||||||
|
create( ls_package ).
|
||||||
|
|
||||||
|
ENDMETHOD. "create
|
||||||
|
|
||||||
|
|
||||||
|
METHOD get.
|
||||||
|
|
||||||
|
FIELD-SYMBOLS: <ls_injected> LIKE LINE OF gt_injected.
|
||||||
|
|
||||||
|
IF lines( gt_injected ) > 0.
|
||||||
|
READ TABLE gt_injected ASSIGNING <ls_injected> WITH KEY package = iv_package.
|
||||||
|
ASSERT sy-subrc = 0. " unit test should be in control
|
||||||
|
ri_package = <ls_injected>-object.
|
||||||
|
ELSE.
|
||||||
|
CREATE OBJECT ri_package TYPE zcl_abapgit_sap_package
|
||||||
|
EXPORTING
|
||||||
|
iv_package = iv_package.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
|
METHOD zif_abapgit_sap_package~create_child.
|
||||||
|
|
||||||
|
DATA: li_parent TYPE REF TO if_package,
|
||||||
|
ls_child TYPE scompkdtln.
|
||||||
|
|
||||||
|
|
||||||
|
cl_package_factory=>load_package(
|
||||||
|
EXPORTING
|
||||||
|
i_package_name = mv_package
|
||||||
|
IMPORTING
|
||||||
|
e_package = li_parent
|
||||||
|
EXCEPTIONS
|
||||||
|
object_not_existing = 1
|
||||||
|
unexpected_error = 2
|
||||||
|
intern_err = 3
|
||||||
|
no_access = 4
|
||||||
|
object_locked_and_modified = 5 ).
|
||||||
|
IF sy-subrc <> 0.
|
||||||
|
zcx_abapgit_exception=>raise( 'error reading parent package' ).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
ls_child-devclass = iv_child.
|
||||||
|
ls_child-dlvunit = li_parent->software_component.
|
||||||
|
ls_child-ctext = iv_child.
|
||||||
|
ls_child-parentcl = mv_package.
|
||||||
|
ls_child-pdevclass = li_parent->transport_layer.
|
||||||
|
ls_child-as4user = sy-uname.
|
||||||
|
|
||||||
|
create( ls_child ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
|
METHOD zif_abapgit_sap_package~exists.
|
||||||
|
|
||||||
|
cl_package_factory=>load_package(
|
||||||
|
EXPORTING
|
||||||
|
i_package_name = mv_package
|
||||||
|
EXCEPTIONS
|
||||||
|
object_not_existing = 1
|
||||||
|
unexpected_error = 2
|
||||||
|
intern_err = 3
|
||||||
|
no_access = 4
|
||||||
|
object_locked_and_modified = 5 ).
|
||||||
|
rv_bool = boolc( sy-subrc <> 1 ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
|
METHOD zif_abapgit_sap_package~list_subpackages.
|
||||||
|
|
||||||
|
DATA: lt_list LIKE rt_list,
|
||||||
|
lv_devclass LIKE LINE OF rt_list.
|
||||||
|
|
||||||
|
|
||||||
|
SELECT devclass INTO TABLE rt_list
|
||||||
|
FROM tdevc WHERE parentcl = mv_package. "#EC CI_GENBUFF "#EC CI_SUBRC
|
||||||
|
|
||||||
|
* note the recursion, since packages are added to the list
|
||||||
|
LOOP AT rt_list INTO lv_devclass.
|
||||||
|
lt_list = get( lv_devclass )->list_subpackages( ).
|
||||||
|
APPEND LINES OF lt_list TO rt_list.
|
||||||
|
ENDLOOP.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
|
METHOD zif_abapgit_sap_package~list_superpackages.
|
||||||
|
|
||||||
|
DATA: lt_list LIKE rt_list,
|
||||||
|
lv_parent TYPE tdevc-parentcl.
|
||||||
|
|
||||||
|
|
||||||
|
APPEND mv_package TO rt_list.
|
||||||
|
|
||||||
|
SELECT SINGLE parentcl INTO lv_parent
|
||||||
|
FROM tdevc WHERE devclass = mv_package. "#EC CI_GENBUFF
|
||||||
|
|
||||||
|
IF sy-subrc = 0 AND NOT lv_parent IS INITIAL.
|
||||||
|
APPEND lv_parent TO rt_list.
|
||||||
|
lt_list = get( lv_parent )->list_superpackages( ).
|
||||||
|
APPEND LINES OF lt_list TO rt_list.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
|
METHOD zif_abapgit_sap_package~read_parent.
|
||||||
|
|
||||||
|
SELECT SINGLE parentcl FROM tdevc INTO rv_parentcl
|
||||||
|
WHERE devclass = mv_package. "#EC CI_SUBRC "#EC CI_GENBUFF
|
||||||
|
ASSERT sy-subrc = 0.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
ENDCLASS.
|
18
src/zcl_abapgit_sap_package.clas.xml
Normal file
18
src/zcl_abapgit_sap_package.clas.xml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
|
||||||
|
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||||
|
<asx:values>
|
||||||
|
<VSEOCLASS>
|
||||||
|
<CLSNAME>ZCL_ABAPGIT_SAP_PACKAGE</CLSNAME>
|
||||||
|
<VERSION>1</VERSION>
|
||||||
|
<LANGU>E</LANGU>
|
||||||
|
<DESCRIPT>SAP package</DESCRIPT>
|
||||||
|
<EXPOSURE>2</EXPOSURE>
|
||||||
|
<STATE>1</STATE>
|
||||||
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
|
<FIXPT>X</FIXPT>
|
||||||
|
<UNICODE>X</UNICODE>
|
||||||
|
</VSEOCLASS>
|
||||||
|
</asx:values>
|
||||||
|
</asx:abap>
|
||||||
|
</abapGit>
|
18
src/zif_abapgit_sap_package.intf.abap
Normal file
18
src/zif_abapgit_sap_package.intf.abap
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
INTERFACE zif_abapgit_sap_package PUBLIC.
|
||||||
|
|
||||||
|
TYPES: ty_devclass_tt TYPE STANDARD TABLE OF devclass WITH DEFAULT KEY.
|
||||||
|
|
||||||
|
METHODS:
|
||||||
|
list_subpackages
|
||||||
|
RETURNING VALUE(rt_list) TYPE ty_devclass_tt,
|
||||||
|
list_superpackages
|
||||||
|
RETURNING VALUE(rt_list) TYPE ty_devclass_tt,
|
||||||
|
read_parent
|
||||||
|
RETURNING VALUE(rv_parentcl) TYPE tdevc-parentcl,
|
||||||
|
create_child
|
||||||
|
IMPORTING iv_child TYPE devclass
|
||||||
|
RAISING zcx_abapgit_exception,
|
||||||
|
exists
|
||||||
|
RETURNING VALUE(rv_bool) TYPE abap_bool.
|
||||||
|
|
||||||
|
ENDINTERFACE.
|
16
src/zif_abapgit_sap_package.intf.xml
Normal file
16
src/zif_abapgit_sap_package.intf.xml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<abapGit version="v1.0.0" serializer="LCL_OBJECT_INTF" serializer_version="v1.0.0">
|
||||||
|
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||||
|
<asx:values>
|
||||||
|
<VSEOINTERF>
|
||||||
|
<CLSNAME>ZIF_ABAPGIT_SAP_PACKAGE</CLSNAME>
|
||||||
|
<VERSION>1</VERSION>
|
||||||
|
<LANGU>E</LANGU>
|
||||||
|
<DESCRIPT>SAP package</DESCRIPT>
|
||||||
|
<EXPOSURE>2</EXPOSURE>
|
||||||
|
<STATE>1</STATE>
|
||||||
|
<UNICODE>X</UNICODE>
|
||||||
|
</VSEOINTERF>
|
||||||
|
</asx:values>
|
||||||
|
</asx:abap>
|
||||||
|
</abapGit>
|
Loading…
Reference in New Issue
Block a user