mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-04 05:47:17 +08:00

* Serialize additional class component metadata Fixes #1872 * Improve update_attributes performance * Update WF attribute handling to use API
297 lines
9.9 KiB
ABAP
297 lines
9.9 KiB
ABAP
CLASS zcl_abapgit_oo_class DEFINITION PUBLIC INHERITING FROM zcl_abapgit_oo_base.
|
|
|
|
PUBLIC SECTION.
|
|
METHODS:
|
|
zif_abapgit_oo_object_fnc~create REDEFINITION,
|
|
zif_abapgit_oo_object_fnc~generate_locals REDEFINITION,
|
|
zif_abapgit_oo_object_fnc~insert_text_pool REDEFINITION,
|
|
zif_abapgit_oo_object_fnc~create_sotr REDEFINITION,
|
|
zif_abapgit_oo_object_fnc~get_includes REDEFINITION,
|
|
zif_abapgit_oo_object_fnc~get_class_properties REDEFINITION,
|
|
zif_abapgit_oo_object_fnc~read_text_pool REDEFINITION,
|
|
zif_abapgit_oo_object_fnc~read_sotr REDEFINITION,
|
|
zif_abapgit_oo_object_fnc~delete REDEFINITION.
|
|
|
|
ENDCLASS.
|
|
|
|
CLASS zcl_abapgit_oo_class IMPLEMENTATION.
|
|
METHOD zif_abapgit_oo_object_fnc~create.
|
|
DATA: lt_vseoattrib TYPE seoo_attributes_r.
|
|
FIELD-SYMBOLS: <lv_clsname> TYPE seoclsname.
|
|
|
|
ASSIGN COMPONENT 'CLSNAME' OF STRUCTURE cg_properties TO <lv_clsname>.
|
|
ASSERT sy-subrc = 0.
|
|
|
|
lt_vseoattrib = convert_attrib_to_vseoattrib(
|
|
iv_clsname = <lv_clsname>
|
|
it_attributes = it_attributes ).
|
|
|
|
CALL FUNCTION 'SEO_CLASS_CREATE_COMPLETE'
|
|
EXPORTING
|
|
devclass = iv_package
|
|
overwrite = iv_overwrite
|
|
CHANGING
|
|
class = cg_properties
|
|
attributes = lt_vseoattrib
|
|
EXCEPTIONS
|
|
existing = 1
|
|
is_interface = 2
|
|
db_error = 3
|
|
component_error = 4
|
|
no_access = 5
|
|
other = 6
|
|
OTHERS = 7.
|
|
IF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise( 'error from SEO_CLASS_CREATE_COMPLETE' ).
|
|
ENDIF.
|
|
ENDMETHOD.
|
|
|
|
METHOD zif_abapgit_oo_object_fnc~generate_locals.
|
|
CALL FUNCTION 'SEO_CLASS_GENERATE_LOCALS'
|
|
EXPORTING
|
|
clskey = is_key
|
|
force = iv_force
|
|
locals_def = it_local_definitions
|
|
locals_imp = it_local_implementations
|
|
locals_mac = it_local_macros
|
|
locals_testclasses = it_local_test_classes
|
|
EXCEPTIONS
|
|
not_existing = 1
|
|
model_only = 2
|
|
locals_not_generated = 3
|
|
locals_not_initialised = 4
|
|
OTHERS = 5.
|
|
IF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise( 'error from generate_locals' ).
|
|
ENDIF.
|
|
ENDMETHOD.
|
|
|
|
METHOD zif_abapgit_oo_object_fnc~insert_text_pool.
|
|
DATA: lv_cp TYPE program.
|
|
|
|
lv_cp = cl_oo_classname_service=>get_classpool_name( iv_class_name ).
|
|
|
|
INSERT TEXTPOOL lv_cp
|
|
FROM it_text_pool
|
|
LANGUAGE iv_language
|
|
STATE 'I'.
|
|
IF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise( 'error from INSERT TEXTPOOL' ).
|
|
ENDIF.
|
|
|
|
zcl_abapgit_objects_activation=>add( iv_type = 'REPT'
|
|
iv_name = lv_cp ).
|
|
ENDMETHOD.
|
|
|
|
METHOD zif_abapgit_oo_object_fnc~create_sotr.
|
|
DATA: lt_sotr TYPE zif_abapgit_definitions=>ty_sotr_tt,
|
|
lt_objects TYPE sotr_objects,
|
|
ls_paket TYPE sotr_pack,
|
|
lv_object LIKE LINE OF lt_objects.
|
|
|
|
FIELD-SYMBOLS: <ls_sotr> LIKE LINE OF lt_sotr.
|
|
|
|
LOOP AT it_sotr ASSIGNING <ls_sotr>.
|
|
CALL FUNCTION 'SOTR_OBJECT_GET_OBJECTS'
|
|
EXPORTING
|
|
object_vector = <ls_sotr>-header-objid_vec
|
|
IMPORTING
|
|
objects = lt_objects
|
|
EXCEPTIONS
|
|
object_not_found = 1
|
|
OTHERS = 2.
|
|
IF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise( 'error from SOTR_OBJECT_GET_OBJECTS' ).
|
|
ENDIF.
|
|
|
|
READ TABLE lt_objects INDEX 1 INTO lv_object.
|
|
ASSERT sy-subrc = 0.
|
|
|
|
ls_paket-paket = iv_package.
|
|
|
|
CALL FUNCTION 'SOTR_CREATE_CONCEPT'
|
|
EXPORTING
|
|
paket = ls_paket
|
|
crea_lan = <ls_sotr>-header-crea_lan
|
|
alias_name = <ls_sotr>-header-alias_name
|
|
object = lv_object
|
|
entries = <ls_sotr>-entries
|
|
concept_default = <ls_sotr>-header-concept
|
|
EXCEPTIONS
|
|
package_missing = 1
|
|
crea_lan_missing = 2
|
|
object_missing = 3
|
|
paket_does_not_exist = 4
|
|
alias_already_exist = 5
|
|
object_type_not_found = 6
|
|
langu_missing = 7
|
|
identical_context_not_allowed = 8
|
|
text_too_long = 9
|
|
error_in_update = 10
|
|
no_master_langu = 11
|
|
error_in_concept_id = 12
|
|
alias_not_allowed = 13
|
|
tadir_entry_creation_failed = 14
|
|
internal_error = 15
|
|
error_in_correction = 16
|
|
user_cancelled = 17
|
|
no_entry_found = 18
|
|
OTHERS = 19.
|
|
IF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise( 'error from SOTR_CREATE_CONCEPT' ).
|
|
ENDIF.
|
|
ENDLOOP.
|
|
ENDMETHOD.
|
|
|
|
METHOD zif_abapgit_oo_object_fnc~get_includes.
|
|
* note: includes returned might not exist
|
|
* method cl_oo_classname_service=>GET_ALL_CLASS_INCLUDES does not exist in 702
|
|
|
|
DATA: lv_class_name TYPE seoclsname,
|
|
lt_methods TYPE seop_methods_w_include.
|
|
|
|
FIELD-SYMBOLS: <ls_method> LIKE LINE OF lt_methods.
|
|
|
|
lv_class_name = iv_object_name.
|
|
|
|
APPEND cl_oo_classname_service=>get_ccdef_name( lv_class_name ) TO rt_includes.
|
|
APPEND cl_oo_classname_service=>get_ccmac_name( lv_class_name ) TO rt_includes.
|
|
APPEND cl_oo_classname_service=>get_ccimp_name( lv_class_name ) TO rt_includes.
|
|
APPEND cl_oo_classname_service=>get_cl_name( lv_class_name ) TO rt_includes.
|
|
APPEND cl_oo_classname_service=>get_ccau_name( lv_class_name ) TO rt_includes.
|
|
APPEND cl_oo_classname_service=>get_pubsec_name( lv_class_name ) TO rt_includes.
|
|
APPEND cl_oo_classname_service=>get_prosec_name( lv_class_name ) TO rt_includes.
|
|
APPEND cl_oo_classname_service=>get_prisec_name( lv_class_name ) TO rt_includes.
|
|
APPEND cl_oo_classname_service=>get_classpool_name( lv_class_name ) TO rt_includes.
|
|
APPEND cl_oo_classname_service=>get_ct_name( lv_class_name ) TO rt_includes.
|
|
|
|
* skip the CS include, as it is sometimes generated on the fly instead of
|
|
* when the methods are changed
|
|
* APPEND cl_oo_classname_service=>get_cs_name( lv_class_name ) TO rt_includes.
|
|
|
|
cl_oo_classname_service=>get_all_method_includes(
|
|
EXPORTING
|
|
clsname = lv_class_name
|
|
RECEIVING
|
|
result = lt_methods
|
|
EXCEPTIONS
|
|
class_not_existing = 1 ).
|
|
|
|
IF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise( |Class { lv_class_name } not existing| ).
|
|
ENDIF.
|
|
|
|
LOOP AT lt_methods ASSIGNING <ls_method>.
|
|
APPEND <ls_method>-incname TO rt_includes.
|
|
ENDLOOP.
|
|
|
|
ENDMETHOD.
|
|
|
|
METHOD zif_abapgit_oo_object_fnc~get_class_properties.
|
|
CALL FUNCTION 'SEO_CLIF_GET'
|
|
EXPORTING
|
|
cifkey = is_class_key
|
|
version = seoc_version_active
|
|
IMPORTING
|
|
class = rs_class_properties
|
|
EXCEPTIONS
|
|
not_existing = 1
|
|
deleted = 2
|
|
model_only = 3
|
|
OTHERS = 4.
|
|
IF sy-subrc = 1.
|
|
RETURN. " in case only inactive version exists
|
|
ELSEIF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise( 'error from seo_clif_get' ).
|
|
ENDIF.
|
|
ENDMETHOD.
|
|
|
|
METHOD zif_abapgit_oo_object_fnc~read_text_pool.
|
|
DATA:
|
|
lv_cp TYPE program.
|
|
|
|
lv_cp = cl_oo_classname_service=>get_classpool_name( iv_class_name ).
|
|
READ TEXTPOOL lv_cp INTO rt_text_pool LANGUAGE iv_language. "#EC CI_READ_REP
|
|
ENDMETHOD.
|
|
|
|
METHOD zif_abapgit_oo_object_fnc~read_sotr.
|
|
DATA: lv_concept TYPE sotr_head-concept,
|
|
lt_seocompodf TYPE STANDARD TABLE OF seocompodf WITH DEFAULT KEY,
|
|
ls_header TYPE sotr_head,
|
|
lt_entries TYPE sotr_text_tt.
|
|
|
|
FIELD-SYMBOLS: <ls_sotr> LIKE LINE OF rt_sotr,
|
|
<ls_seocompodf> LIKE LINE OF lt_seocompodf,
|
|
<ls_entry> LIKE LINE OF lt_entries.
|
|
|
|
|
|
SELECT * FROM seocompodf
|
|
INTO TABLE lt_seocompodf
|
|
WHERE clsname = iv_object_name
|
|
AND version = '1'
|
|
AND exposure = '2'
|
|
AND attdecltyp = '2'
|
|
AND type = 'SOTR_CONC'
|
|
ORDER BY PRIMARY KEY. "#EC CI_SUBRC
|
|
|
|
LOOP AT lt_seocompodf ASSIGNING <ls_seocompodf>.
|
|
|
|
lv_concept = translate( val = <ls_seocompodf>-attvalue from = '''' to = '' ).
|
|
|
|
CALL FUNCTION 'SOTR_GET_CONCEPT'
|
|
EXPORTING
|
|
concept = lv_concept
|
|
IMPORTING
|
|
header = ls_header
|
|
TABLES
|
|
entries = lt_entries
|
|
EXCEPTIONS
|
|
no_entry_found = 1
|
|
OTHERS = 2.
|
|
IF sy-subrc <> 0.
|
|
CONTINUE.
|
|
ENDIF.
|
|
|
|
CLEAR: ls_header-paket,
|
|
ls_header-crea_name,
|
|
ls_header-crea_tstut,
|
|
ls_header-chan_name,
|
|
ls_header-chan_tstut.
|
|
|
|
LOOP AT lt_entries ASSIGNING <ls_entry>.
|
|
CLEAR: <ls_entry>-version,
|
|
<ls_entry>-crea_name,
|
|
<ls_entry>-crea_tstut,
|
|
<ls_entry>-chan_name,
|
|
<ls_entry>-chan_tstut.
|
|
ENDLOOP.
|
|
|
|
APPEND INITIAL LINE TO rt_sotr ASSIGNING <ls_sotr>.
|
|
<ls_sotr>-header = ls_header.
|
|
<ls_sotr>-entries = lt_entries.
|
|
|
|
ENDLOOP.
|
|
ENDMETHOD.
|
|
|
|
METHOD zif_abapgit_oo_object_fnc~delete.
|
|
CALL FUNCTION 'SEO_CLASS_DELETE_COMPLETE'
|
|
EXPORTING
|
|
clskey = is_deletion_key
|
|
EXCEPTIONS
|
|
not_existing = 1
|
|
is_interface = 2
|
|
db_error = 3
|
|
no_access = 4
|
|
other = 5
|
|
OTHERS = 6.
|
|
IF sy-subrc = 1.
|
|
* ignore deletion of objects that does not exist
|
|
* this can happen when the SXCI object is deleted before the implementing CLAS
|
|
RETURN.
|
|
ELSEIF sy-subrc <> 0.
|
|
zcx_abapgit_exception=>raise( |Error from SEO_CLASS_DELETE_COMPLETE: { sy-subrc }| ).
|
|
ENDIF.
|
|
ENDMETHOD.
|
|
|
|
ENDCLASS.
|