mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-02 04:36:49 +08:00
Refactoring
This commit is contained in:
parent
762f663c00
commit
6458708a05
|
@ -52,16 +52,15 @@ CLASS lcl_object_enhs IMPLEMENTATION.
|
||||||
lv_package LIKE iv_package,
|
lv_package LIKE iv_package,
|
||||||
li_spot_ref TYPE REF TO if_enh_spot_tool,
|
li_spot_ref TYPE REF TO if_enh_spot_tool,
|
||||||
lo_badidef_tool TYPE REF TO cl_enh_tool_badi_def,
|
lo_badidef_tool TYPE REF TO cl_enh_tool_badi_def,
|
||||||
lo_badi_hook TYPE REF TO cl_enh_tool_hook_def,
|
lo_hookdef_tool TYPE REF TO cl_enh_tool_hook_def,
|
||||||
lt_hook_defs TYPE enh_hook_def_ext_it.
|
lt_hook_definitions TYPE enh_hook_def_ext_it,
|
||||||
|
li_enh_object TYPE REF TO if_enh_object,
|
||||||
|
li_enh_object_docu TYPE REF TO if_enh_object_docu.
|
||||||
|
|
||||||
lv_spot_name = ms_item-obj_name.
|
lv_spot_name = ms_item-obj_name.
|
||||||
|
|
||||||
io_xml->read( EXPORTING iv_name = 'TOOL'
|
io_xml->read( EXPORTING iv_name = 'TOOL'
|
||||||
CHANGING cg_data = lv_tool ).
|
CHANGING cg_data = lv_tool ).
|
||||||
io_xml->read( EXPORTING iv_name = 'PARENT_COMP'
|
|
||||||
CHANGING cg_data = lv_parent ).
|
|
||||||
io_xml->read( EXPORTING iv_name = 'SHORTTEXT'
|
io_xml->read( EXPORTING iv_name = 'SHORTTEXT'
|
||||||
CHANGING cg_data = lv_enh_shtext ).
|
CHANGING cg_data = lv_enh_shtext ).
|
||||||
|
|
||||||
|
@ -83,43 +82,43 @@ CLASS lcl_object_enhs IMPLEMENTATION.
|
||||||
CHANGING
|
CHANGING
|
||||||
devclass = lv_package ).
|
devclass = lv_package ).
|
||||||
|
|
||||||
|
li_enh_object ?= li_spot_ref.
|
||||||
|
li_enh_object_docu ?= li_spot_ref.
|
||||||
|
|
||||||
|
li_enh_object_docu->set_shorttext( lv_enh_shtext ).
|
||||||
|
|
||||||
CASE lv_tool.
|
CASE lv_tool.
|
||||||
WHEN cl_enh_tool_badi_def=>tooltype..
|
WHEN cl_enh_tool_badi_def=>tooltype..
|
||||||
|
|
||||||
|
io_xml->read( EXPORTING iv_name = 'PARENT_COMP'
|
||||||
|
CHANGING cg_data = lv_parent ).
|
||||||
|
|
||||||
io_xml->read( EXPORTING iv_name = 'BADI_DATA'
|
io_xml->read( EXPORTING iv_name = 'BADI_DATA'
|
||||||
CHANGING cg_data = lt_enh_badi ).
|
CHANGING cg_data = lt_enh_badi ).
|
||||||
|
|
||||||
lo_badidef_tool ?= li_spot_ref.
|
lo_badidef_tool ?= li_spot_ref.
|
||||||
|
|
||||||
lo_badidef_tool->if_enh_object_docu~set_shorttext( lv_enh_shtext ).
|
|
||||||
|
|
||||||
LOOP AT lt_enh_badi INTO ls_enh_badi.
|
LOOP AT lt_enh_badi INTO ls_enh_badi.
|
||||||
lo_badidef_tool->add_badi_def( ls_enh_badi ).
|
lo_badidef_tool->add_badi_def( ls_enh_badi ).
|
||||||
ENDLOOP.
|
ENDLOOP.
|
||||||
|
|
||||||
lo_badidef_tool->if_enh_object~save( ).
|
|
||||||
lo_badidef_tool->if_enh_object~activate( ).
|
|
||||||
lo_badidef_tool->if_enh_object~unlock( ).
|
|
||||||
|
|
||||||
WHEN cl_enh_tool_hook_def=>tool_type.
|
WHEN cl_enh_tool_hook_def=>tool_type.
|
||||||
|
|
||||||
io_xml->read( EXPORTING iv_name = 'BADI_DATA'
|
io_xml->read( EXPORTING iv_name = 'BADI_DATA'
|
||||||
CHANGING cg_data = lt_hook_defs ).
|
CHANGING cg_data = lt_hook_definitions ).
|
||||||
|
|
||||||
lo_badi_hook ?= li_spot_ref.
|
lo_hookdef_tool ?= li_spot_ref.
|
||||||
|
|
||||||
lo_badi_hook->if_enh_object_docu~set_shorttext( lv_enh_shtext ).
|
LOOP AT lt_hook_definitions ASSIGNING FIELD-SYMBOL(<ls_hook_def>).
|
||||||
|
lo_hookdef_tool->add_hook_def( CORRESPONDING #( <ls_hook_def> ) ).
|
||||||
LOOP AT lt_hook_defs ASSIGNING FIELD-SYMBOL(<ls_hook_def>).
|
|
||||||
lo_badi_hook->add_hook_def( CORRESPONDING #( <ls_hook_def> ) ).
|
|
||||||
ENDLOOP.
|
ENDLOOP.
|
||||||
|
|
||||||
lo_badi_hook->if_enh_object~save( ).
|
|
||||||
lo_badi_hook->if_enh_object~activate( ).
|
|
||||||
lo_badi_hook->if_enh_object~unlock( ).
|
|
||||||
|
|
||||||
ENDCASE.
|
ENDCASE.
|
||||||
|
|
||||||
|
li_enh_object->save( ).
|
||||||
|
li_enh_object->activate( ).
|
||||||
|
li_enh_object->unlock( ).
|
||||||
|
|
||||||
CATCH cx_enh_root INTO lx_root.
|
CATCH cx_enh_root INTO lx_root.
|
||||||
lv_message = `Error occured while deserializing EHNS: `
|
lv_message = `Error occured while deserializing EHNS: `
|
||||||
&& lx_root->get_text( ) ##NO_TEXT.
|
&& lx_root->get_text( ) ##NO_TEXT.
|
||||||
|
@ -138,9 +137,9 @@ CLASS lcl_object_enhs IMPLEMENTATION.
|
||||||
lx_root TYPE REF TO cx_root,
|
lx_root TYPE REF TO cx_root,
|
||||||
li_spot_ref TYPE REF TO if_enh_spot_tool,
|
li_spot_ref TYPE REF TO if_enh_spot_tool,
|
||||||
lo_badidef_tool TYPE REF TO cl_enh_tool_badi_def,
|
lo_badidef_tool TYPE REF TO cl_enh_tool_badi_def,
|
||||||
lo_badi_hook TYPE REF TO cl_enh_tool_hook_def,
|
lo_hookdef_tool TYPE REF TO cl_enh_tool_hook_def,
|
||||||
lt_hook_defs TYPE enh_hook_def_ext_it.
|
lt_hook_definitions TYPE enh_hook_def_ext_it,
|
||||||
|
li_enh_object_docu TYPE REF TO if_enh_object_docu.
|
||||||
|
|
||||||
lv_spot_name = ms_item-obj_name.
|
lv_spot_name = ms_item-obj_name.
|
||||||
|
|
||||||
|
@ -148,41 +147,42 @@ CLASS lcl_object_enhs IMPLEMENTATION.
|
||||||
li_spot_ref = cl_enh_factory=>get_enhancement_spot( lv_spot_name ).
|
li_spot_ref = cl_enh_factory=>get_enhancement_spot( lv_spot_name ).
|
||||||
lv_tool = li_spot_ref->get_tool( ).
|
lv_tool = li_spot_ref->get_tool( ).
|
||||||
|
|
||||||
|
li_enh_object_docu ?= li_spot_ref.
|
||||||
|
lv_enh_shtext = li_enh_object_docu->get_shorttext( ).
|
||||||
|
|
||||||
|
io_xml->add( ig_data = lv_tool
|
||||||
|
iv_name = 'TOOL' ).
|
||||||
|
io_xml->add( ig_data = lv_enh_shtext
|
||||||
|
iv_name = 'SHORTTEXT' ).
|
||||||
|
|
||||||
CASE lv_tool.
|
CASE lv_tool.
|
||||||
WHEN cl_enh_tool_badi_def=>tooltype.
|
WHEN cl_enh_tool_badi_def=>tooltype.
|
||||||
|
|
||||||
lo_badidef_tool ?= li_spot_ref.
|
lo_badidef_tool ?= li_spot_ref.
|
||||||
lv_enh_shtext = lo_badidef_tool->if_enh_object_docu~get_shorttext( ).
|
|
||||||
|
|
||||||
"get parent = composite enhs (ENHC)
|
"get parent = composite enhs (ENHC)
|
||||||
lv_parent = cl_r3standard_persistence=>enh_find_parent_composite( lv_spot_name ).
|
lv_parent = cl_r3standard_persistence=>enh_find_parent_composite( lv_spot_name ).
|
||||||
"get subsequent BADI definitions
|
"get subsequent BADI definitions
|
||||||
lt_enh_badi = lo_badidef_tool->get_badi_defs( ).
|
lt_enh_badi = lo_badidef_tool->get_badi_defs( ).
|
||||||
|
|
||||||
|
io_xml->add( ig_data = lv_parent
|
||||||
|
iv_name = 'PARENT_COMP' ).
|
||||||
io_xml->add( ig_data = lt_enh_badi
|
io_xml->add( ig_data = lt_enh_badi
|
||||||
iv_name = 'BADI_DATA' ).
|
iv_name = 'BADI_DATA' ).
|
||||||
|
|
||||||
WHEN cl_enh_tool_hook_def=>tool_type.
|
WHEN cl_enh_tool_hook_def=>tool_type.
|
||||||
|
|
||||||
lo_badi_hook ?= li_spot_ref.
|
lo_hookdef_tool ?= li_spot_ref.
|
||||||
lv_enh_shtext = lo_badi_hook->if_enh_object_docu~get_shorttext( ).
|
|
||||||
|
|
||||||
"get parent = composite enhs (ENHC)
|
lt_hook_definitions = lo_hookdef_tool->get_hook_defs( ).
|
||||||
lv_parent = cl_r3standard_persistence=>enh_find_parent_composite( lv_spot_name ).
|
|
||||||
lt_hook_defs = lo_badi_hook->get_hook_defs( ).
|
|
||||||
|
|
||||||
io_xml->add( ig_data = lt_hook_defs
|
io_xml->add( ig_data = lt_hook_definitions
|
||||||
iv_name = 'BADI_DATA' ).
|
iv_name = 'BADI_DATA' ).
|
||||||
|
|
||||||
|
WHEN OTHERS.
|
||||||
|
zcx_abapgit_exception=>raise( |ENHS: Unsupported tool { lv_tool }| ).
|
||||||
ENDCASE.
|
ENDCASE.
|
||||||
|
|
||||||
io_xml->add( ig_data = lv_tool
|
|
||||||
iv_name = 'TOOL' ).
|
|
||||||
io_xml->add( ig_data = lv_parent
|
|
||||||
iv_name = 'PARENT_COMP' ).
|
|
||||||
io_xml->add( ig_data = lv_enh_shtext
|
|
||||||
iv_name = 'SHORTTEXT' ).
|
|
||||||
|
|
||||||
CATCH cx_enh_root INTO lx_root.
|
CATCH cx_enh_root INTO lx_root.
|
||||||
zcx_abapgit_exception=>raise( `Error occured while serializing EHNS: `
|
zcx_abapgit_exception=>raise( `Error occured while serializing EHNS: `
|
||||||
&& lx_root->get_text( ) ) ##NO_TEXT.
|
&& lx_root->get_text( ) ) ##NO_TEXT.
|
||||||
|
@ -203,15 +203,9 @@ CLASS lcl_object_enhs IMPLEMENTATION.
|
||||||
li_spot_ref = cl_enh_factory=>get_enhancement_spot( lv_spot_name ).
|
li_spot_ref = cl_enh_factory=>get_enhancement_spot( lv_spot_name ).
|
||||||
|
|
||||||
lv_tool = li_spot_ref->get_tool( ).
|
lv_tool = li_spot_ref->get_tool( ).
|
||||||
CASE lv_tool.
|
|
||||||
WHEN cl_enh_tool_badi_def=>tooltype.
|
|
||||||
rv_bool = abap_true.
|
rv_bool = abap_true.
|
||||||
WHEN cl_enh_tool_hook_def=>tool_type.
|
|
||||||
rv_bool = abap_true.
|
|
||||||
WHEN OTHERS.
|
|
||||||
* todo: implement additional tool types
|
|
||||||
rv_bool = abap_false.
|
|
||||||
ENDCASE.
|
|
||||||
CATCH cx_enh_root.
|
CATCH cx_enh_root.
|
||||||
rv_bool = abap_false.
|
rv_bool = abap_false.
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
@ -222,29 +216,19 @@ CLASS lcl_object_enhs IMPLEMENTATION.
|
||||||
|
|
||||||
DATA: lv_spot_name TYPE enhspotname,
|
DATA: lv_spot_name TYPE enhspotname,
|
||||||
lx_root TYPE REF TO cx_root,
|
lx_root TYPE REF TO cx_root,
|
||||||
li_spot_ref TYPE REF TO if_enh_spot_tool,
|
|
||||||
lo_badidef_tool TYPE REF TO cl_enh_tool_badi_def,
|
|
||||||
li_enh_object TYPE REF TO if_enh_object.
|
li_enh_object TYPE REF TO if_enh_object.
|
||||||
|
|
||||||
lv_spot_name = ms_item-obj_name.
|
lv_spot_name = ms_item-obj_name.
|
||||||
|
|
||||||
TRY.
|
TRY.
|
||||||
li_spot_ref = cl_enh_factory=>get_enhancement_spot(
|
li_enh_object ?= cl_enh_factory=>get_enhancement_spot(
|
||||||
spot_name = lv_spot_name
|
spot_name = lv_spot_name
|
||||||
lock = abap_true ).
|
lock = abap_true ).
|
||||||
|
|
||||||
IF li_spot_ref IS BOUND.
|
li_enh_object->delete( nevertheless_delete = abap_true
|
||||||
li_enh_object ?= li_spot_ref.
|
|
||||||
li_enh_object->delete(
|
|
||||||
nevertheless_delete = abap_true
|
|
||||||
run_dark = abap_true ).
|
run_dark = abap_true ).
|
||||||
|
|
||||||
li_enh_object->unlock( ).
|
li_enh_object->unlock( ).
|
||||||
* lo_badidef_tool ?= li_spot_ref.
|
|
||||||
* lo_badidef_tool->if_enh_object~delete(
|
|
||||||
* nevertheless_delete = abap_true
|
|
||||||
* run_dark = abap_true ).
|
|
||||||
* lo_badidef_tool->if_enh_object~unlock( ).
|
|
||||||
ENDIF.
|
|
||||||
|
|
||||||
CATCH cx_enh_root INTO lx_root.
|
CATCH cx_enh_root INTO lx_root.
|
||||||
zcx_abapgit_exception=>raise( `Error occured while deleting EHNS: `
|
zcx_abapgit_exception=>raise( `Error occured while deleting EHNS: `
|
||||||
|
|
Loading…
Reference in New Issue
Block a user