mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 12:20:51 +08:00
Web DynPro Component Configuration Support (#3665)
* Web DynPro Component Configuration Support Web DynPro Component Configuration Support Class * WDCC Support - Syntax Corrections Web DynPro Component Configuration Support Syntax Corrrections * TADIR Object Name Concatenation Change/Removal TADIR Object Name Concatenation Change/Removal As ms_item-obj_name hold complete TADIR name, concatenation with ..00 is not necessary. * WDCC Support - Syntax Corrections Web DynPro Component Configuration Support -Remove dynamic coding -Remove explicit commit/roll back -Use Tadir functionality of base class * WDCC Support - Syntax Corrections Web DynPro Component Configuration Support -The EXPORTING keyword can be omitted (exporting)) * WDCC Support - Syntax Corrections Web DynPro Component Configuration Support -Removal of HJA comments -Removal of me-> * Removal of Component Config XML in main object fil Removal of Component Config XML in main object file -Component Configuration raw XML added to additional comp_conf.xml file * Additional xml file pretty printed as string Additional file contents now pretty printed and added as string for easy diff. Serialisation / Derialisation now working with pretty printing and un-pretty printing. Co-authored-by: Lars Hvam <larshp@hotmail.com>
This commit is contained in:
parent
e3c1623275
commit
32ec5430a7
371
src/objects/zcl_abapgit_object_wdcc.clas.abap
Normal file
371
src/objects/zcl_abapgit_object_wdcc.clas.abap
Normal file
|
@ -0,0 +1,371 @@
|
||||||
|
CLASS zcl_abapgit_object_wdcc DEFINITION
|
||||||
|
PUBLIC
|
||||||
|
INHERITING FROM zcl_abapgit_objects_super
|
||||||
|
CREATE PUBLIC .
|
||||||
|
PUBLIC SECTION.
|
||||||
|
INTERFACES zif_abapgit_object.
|
||||||
|
ALIASES mo_files FOR zif_abapgit_object~mo_files.
|
||||||
|
|
||||||
|
METHODS constructor
|
||||||
|
IMPORTING
|
||||||
|
!is_item TYPE zif_abapgit_definitions=>ty_item
|
||||||
|
!iv_language TYPE spras.
|
||||||
|
|
||||||
|
PROTECTED SECTION.
|
||||||
|
PRIVATE SECTION.
|
||||||
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CLASS zcl_abapgit_object_wdcc IMPLEMENTATION.
|
||||||
|
METHOD zif_abapgit_object~changed_by.
|
||||||
|
|
||||||
|
DATA: ls_outline TYPE wdy_cfg_outline_data,
|
||||||
|
ls_config_key TYPE wdy_config_key.
|
||||||
|
|
||||||
|
ls_config_key-config_id = ms_item-obj_name+0(32).
|
||||||
|
ls_config_key-config_type = '00'.
|
||||||
|
|
||||||
|
TRY.
|
||||||
|
cl_wdr_cfg_persistence_utils=>read_comp_config_from_db(
|
||||||
|
EXPORTING
|
||||||
|
config_key = ls_config_key
|
||||||
|
IMPORTING
|
||||||
|
outline_data = ls_outline ).
|
||||||
|
CATCH cx_static_check.
|
||||||
|
zcx_abapgit_exception=>raise( 'Error Reading Component Config from DB: ' && ms_item-obj_name ).
|
||||||
|
ENDTRY.
|
||||||
|
|
||||||
|
rv_user = ls_outline-changedby.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD zif_abapgit_object~delete.
|
||||||
|
DATA: ls_config_key TYPE wdy_config_key,
|
||||||
|
lv_subrc TYPE sysubrc.
|
||||||
|
|
||||||
|
ls_config_key-config_id = ms_item-obj_name+0(32).
|
||||||
|
ls_config_key-config_type = '00'.
|
||||||
|
|
||||||
|
cl_wdr_cfg_persistence_utils=>delete_configuration(
|
||||||
|
EXPORTING
|
||||||
|
config_key = ls_config_key
|
||||||
|
RECEIVING
|
||||||
|
subrc = lv_subrc ).
|
||||||
|
IF lv_subrc <> 0.
|
||||||
|
zcx_abapgit_exception=>raise( 'Error deleting WDCC: ' && ms_item-obj_name ).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD zif_abapgit_object~exists.
|
||||||
|
|
||||||
|
DATA: ls_outline TYPE wdy_cfg_outline_data,
|
||||||
|
ls_config_key TYPE wdy_config_key.
|
||||||
|
|
||||||
|
ls_config_key-config_id = ms_item-obj_name+0(32).
|
||||||
|
ls_config_key-config_type = '00'.
|
||||||
|
|
||||||
|
TRY.
|
||||||
|
cl_wdr_cfg_persistence_utils=>read_comp_config_from_db(
|
||||||
|
EXPORTING
|
||||||
|
config_key = ls_config_key
|
||||||
|
IMPORTING
|
||||||
|
outline_data = ls_outline ).
|
||||||
|
CATCH cx_static_check.
|
||||||
|
rv_bool = abap_false.
|
||||||
|
RETURN.
|
||||||
|
ENDTRY.
|
||||||
|
|
||||||
|
rv_bool = abap_true.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD zif_abapgit_object~get_comparator.
|
||||||
|
RETURN.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD zif_abapgit_object~get_deserialize_steps.
|
||||||
|
APPEND zif_abapgit_object=>gc_step_id-abap TO rt_steps.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD zif_abapgit_object~get_metadata.
|
||||||
|
|
||||||
|
DATA ls_meta_data TYPE zif_abapgit_definitions=>ty_metadata.
|
||||||
|
|
||||||
|
ls_meta_data = get_metadata( ).
|
||||||
|
ls_meta_data-delete_tadir = abap_true.
|
||||||
|
|
||||||
|
rs_metadata = ls_meta_data.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD zif_abapgit_object~is_active.
|
||||||
|
rv_active = abap_true.
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD zif_abapgit_object~is_locked.
|
||||||
|
|
||||||
|
DATA: lt_enq TYPE STANDARD TABLE OF seqg3,
|
||||||
|
lv_subrc TYPE sysubrc,
|
||||||
|
lv_garg TYPE eqegraarg,
|
||||||
|
lv_lines TYPE i.
|
||||||
|
|
||||||
|
lv_garg = ms_item-obj_name.
|
||||||
|
|
||||||
|
CALL FUNCTION 'ENQUEUE_READ'
|
||||||
|
EXPORTING
|
||||||
|
gclient = sy-mandt
|
||||||
|
gname = 'WDY_CONFIG_DATA'
|
||||||
|
garg = lv_garg
|
||||||
|
IMPORTING
|
||||||
|
subrc = lv_subrc
|
||||||
|
TABLES
|
||||||
|
enq = lt_enq
|
||||||
|
EXCEPTIONS
|
||||||
|
communication_failure = 2
|
||||||
|
OTHERS = 1.
|
||||||
|
IF sy-subrc <> 0.
|
||||||
|
zcx_abapgit_exception=>raise( 'Error check object lock WDCC: ' && ms_item-obj_name ).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
DESCRIBE TABLE lt_enq LINES lv_lines.
|
||||||
|
IF lv_lines > 0.
|
||||||
|
rv_is_locked = abap_true.
|
||||||
|
ELSE.
|
||||||
|
rv_is_locked = abap_false.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD zif_abapgit_object~jump.
|
||||||
|
|
||||||
|
CALL FUNCTION 'RS_TOOL_ACCESS'
|
||||||
|
EXPORTING
|
||||||
|
operation = 'SHOW'
|
||||||
|
object_name = ms_item-obj_name
|
||||||
|
object_type = 'WDCC'
|
||||||
|
in_new_window = abap_true.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD zif_abapgit_object~serialize.
|
||||||
|
|
||||||
|
DATA: lv_xml_xstring TYPE xstring,
|
||||||
|
lt_otr_texts TYPE TABLE OF wdy_config_compt,
|
||||||
|
lt_cc_text TYPE TABLE OF wdy_config_datt,
|
||||||
|
ls_orig_config TYPE wdy_config_data,
|
||||||
|
ls_outline TYPE wdy_cfg_outline_data,
|
||||||
|
ls_config_key TYPE wdy_config_key,
|
||||||
|
lv_xml_string TYPE string.
|
||||||
|
|
||||||
|
io_xml->add( iv_name = 'OBJECT_NAME'
|
||||||
|
ig_data = ms_item-obj_name ).
|
||||||
|
|
||||||
|
ls_config_key-config_id = ms_item-obj_name+0(32).
|
||||||
|
ls_config_key-config_type = '00'.
|
||||||
|
|
||||||
|
TRY.
|
||||||
|
cl_wdr_cfg_persistence_utils=>read_comp_config_from_db(
|
||||||
|
EXPORTING
|
||||||
|
config_key = ls_config_key
|
||||||
|
IMPORTING
|
||||||
|
xml_xcontent = lv_xml_xstring
|
||||||
|
original_config_data = ls_orig_config
|
||||||
|
outline_data = ls_outline ).
|
||||||
|
|
||||||
|
CATCH cx_static_check.
|
||||||
|
zcx_abapgit_exception=>raise( 'Error Reading Component Config from DB: ' && ms_item-obj_name ).
|
||||||
|
ENDTRY.
|
||||||
|
|
||||||
|
io_xml->add( iv_name = 'CONFIG_ID'
|
||||||
|
ig_data = ls_orig_config-config_id ).
|
||||||
|
|
||||||
|
io_xml->add( iv_name = 'CONFIG_TYPE'
|
||||||
|
ig_data = ls_orig_config-config_type ).
|
||||||
|
|
||||||
|
io_xml->add( iv_name = 'CONFIG_VAR'
|
||||||
|
ig_data = ls_orig_config-config_var ).
|
||||||
|
|
||||||
|
io_xml->add( iv_name = 'WDA_COMPONENT'
|
||||||
|
ig_data = ls_orig_config-component ).
|
||||||
|
|
||||||
|
io_xml->add( iv_name = 'CONFIG_IDPAR'
|
||||||
|
ig_data = ls_orig_config-config_idpar ).
|
||||||
|
|
||||||
|
io_xml->add( iv_name = 'CONFIG_TYPEPAR'
|
||||||
|
ig_data = ls_orig_config-config_typepar ).
|
||||||
|
|
||||||
|
io_xml->add( iv_name = 'CONFIG_VARPAR'
|
||||||
|
ig_data = ls_orig_config-config_varpar ).
|
||||||
|
|
||||||
|
io_xml->add( iv_name = 'PARENT'
|
||||||
|
ig_data = ls_orig_config-parent ).
|
||||||
|
|
||||||
|
io_xml->add( iv_name = 'RELID'
|
||||||
|
ig_data = ls_orig_config-relid ).
|
||||||
|
|
||||||
|
lv_xml_string = zcl_abapgit_convert=>xstring_to_string_utf8( iv_data = lv_xml_xstring ).
|
||||||
|
TRY.
|
||||||
|
lv_xml_string = zcl_abapgit_xml_pretty=>print( iv_xml = lv_xml_string
|
||||||
|
iv_ignore_errors = abap_false ).
|
||||||
|
CATCH zcx_abapgit_exception. "
|
||||||
|
zcx_abapgit_exception=>raise( 'Error Pretty Printing WDCC XML Content: ' && ms_item-obj_name ).
|
||||||
|
ENDTRY.
|
||||||
|
|
||||||
|
REPLACE FIRST OCCURRENCE
|
||||||
|
OF REGEX '<\?xml version="1\.0" encoding="[\w-]+"\?>'
|
||||||
|
IN lv_xml_string
|
||||||
|
WITH '<?xml version="1.0" encoding="utf-8"?>'.
|
||||||
|
ASSERT sy-subrc = 0.
|
||||||
|
|
||||||
|
mo_files->add_string( iv_extra = 'comp_config'
|
||||||
|
iv_ext = 'xml'
|
||||||
|
iv_string = lv_xml_string ).
|
||||||
|
|
||||||
|
SELECT * FROM wdy_config_compt INTO TABLE lt_otr_texts WHERE config_id = ls_orig_config-config_id
|
||||||
|
AND config_type = ls_orig_config-config_type
|
||||||
|
AND config_var = ls_orig_config-config_var.
|
||||||
|
|
||||||
|
IF lt_otr_texts IS NOT INITIAL.
|
||||||
|
io_xml->add( iv_name = 'OTR_TEXT'
|
||||||
|
ig_data = lt_otr_texts ).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
SELECT * FROM wdy_config_datt INTO TABLE lt_cc_text WHERE config_id = ls_orig_config-config_id
|
||||||
|
AND config_type = ls_orig_config-config_type
|
||||||
|
AND config_var = ls_orig_config-config_var.
|
||||||
|
IF lt_cc_text IS NOT INITIAL.
|
||||||
|
io_xml->add( iv_name = 'DESCR_LANG'
|
||||||
|
ig_data = lt_cc_text ).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD zif_abapgit_object~deserialize.
|
||||||
|
|
||||||
|
DATA: lo_translator TYPE REF TO if_wdr_config_otr,
|
||||||
|
lv_config_id TYPE c LENGTH 32,
|
||||||
|
lv_config_type TYPE n LENGTH 2,
|
||||||
|
lv_config_var TYPE c LENGTH 6,
|
||||||
|
lt_otr_texts TYPE TABLE OF wdy_config_compt,
|
||||||
|
ls_orig_config TYPE wdy_config_data,
|
||||||
|
lt_config_datt TYPE TABLE OF wdy_config_datt,
|
||||||
|
lv_xml_string TYPE string,
|
||||||
|
lv_xml_xstring TYPE xstring.
|
||||||
|
|
||||||
|
io_xml->read( EXPORTING iv_name = 'CONFIG_ID'
|
||||||
|
CHANGING cg_data = ls_orig_config-config_id ).
|
||||||
|
|
||||||
|
io_xml->read( EXPORTING iv_name = 'CONFIG_TYPE'
|
||||||
|
CHANGING cg_data = ls_orig_config-config_type ).
|
||||||
|
|
||||||
|
io_xml->read( EXPORTING iv_name = 'CONFIG_VAR'
|
||||||
|
CHANGING cg_data = ls_orig_config-config_var ).
|
||||||
|
|
||||||
|
io_xml->read( EXPORTING iv_name = 'CONFIG_IDPAR'
|
||||||
|
CHANGING cg_data = ls_orig_config-config_idpar ).
|
||||||
|
|
||||||
|
io_xml->read( EXPORTING iv_name = 'CONFIG_TYPEPAR'
|
||||||
|
CHANGING cg_data = ls_orig_config-config_typepar ).
|
||||||
|
|
||||||
|
io_xml->read( EXPORTING iv_name = 'CONFIG_VARPAR'
|
||||||
|
CHANGING cg_data = ls_orig_config-config_varpar ).
|
||||||
|
|
||||||
|
io_xml->read( EXPORTING iv_name = 'WDA_COMPONENT'
|
||||||
|
CHANGING cg_data = ls_orig_config-component ).
|
||||||
|
|
||||||
|
lv_xml_string = mo_files->read_string( iv_extra = 'comp_config'
|
||||||
|
iv_ext = 'xml' ).
|
||||||
|
TRY.
|
||||||
|
lv_xml_string = zcl_abapgit_xml_pretty=>print( iv_xml = lv_xml_string
|
||||||
|
iv_ignore_errors = abap_false
|
||||||
|
iv_unpretty = abap_true ).
|
||||||
|
CATCH zcx_abapgit_exception.
|
||||||
|
zcx_abapgit_exception=>raise( 'Error Un-Pretty Printing WDCC XML Content: ' && ms_item-obj_name ).
|
||||||
|
ENDTRY.
|
||||||
|
|
||||||
|
REPLACE FIRST OCCURRENCE
|
||||||
|
OF REGEX '<\?xml version="1\.0" encoding="[\w-]+"\?>'
|
||||||
|
IN lv_xml_string
|
||||||
|
WITH '<?xml version="1.0"?>'.
|
||||||
|
ASSERT sy-subrc = 0.
|
||||||
|
|
||||||
|
lv_xml_xstring = zcl_abapgit_convert=>string_to_xstring( iv_str = lv_xml_string ).
|
||||||
|
ls_orig_config-xcontent = lv_xml_xstring.
|
||||||
|
|
||||||
|
io_xml->read( EXPORTING iv_name = 'PARENT'
|
||||||
|
CHANGING cg_data = ls_orig_config-parent ).
|
||||||
|
|
||||||
|
io_xml->read( EXPORTING iv_name = 'RELID'
|
||||||
|
CHANGING cg_data = ls_orig_config-relid ).
|
||||||
|
|
||||||
|
ls_orig_config-author = sy-uname.
|
||||||
|
ls_orig_config-changedby = sy-uname.
|
||||||
|
ls_orig_config-changedon = sy-datum.
|
||||||
|
ls_orig_config-createdon = sy-datum.
|
||||||
|
|
||||||
|
CALL FUNCTION 'ENQUEUE_E_WDY_CONFCOMP'
|
||||||
|
EXPORTING
|
||||||
|
mode_wdy_config_data = if_wdr_cfg_constants=>c_lock_mode_exclusive
|
||||||
|
config_id = lv_config_id
|
||||||
|
config_type = lv_config_type
|
||||||
|
config_var = lv_config_var
|
||||||
|
x_config_id = 'X'
|
||||||
|
x_config_type = 'X'
|
||||||
|
x_config_var = 'X'
|
||||||
|
EXCEPTIONS
|
||||||
|
foreign_lock = 1
|
||||||
|
system_failure = 2
|
||||||
|
OTHERS = 3.
|
||||||
|
IF sy-subrc <> 0.
|
||||||
|
zcx_abapgit_exception=>raise( 'Error Enqueueing Component Config: ' && ms_item-obj_name ).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
io_xml->read( EXPORTING iv_name = 'OTR_TEXT'
|
||||||
|
CHANGING cg_data = lt_otr_texts ).
|
||||||
|
|
||||||
|
IF lt_otr_texts IS NOT INITIAL.
|
||||||
|
DELETE FROM wdy_config_compt WHERE config_id = ls_orig_config-config_id.
|
||||||
|
MODIFY wdy_config_compt FROM TABLE lt_otr_texts.
|
||||||
|
IF sy-subrc <> 0.
|
||||||
|
zcx_abapgit_exception=>raise( 'Error Updating WDY_CONFIG_COMPT for Component Config ' && ms_item-obj_name ).
|
||||||
|
ENDIF.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
io_xml->read( EXPORTING iv_name = 'DESCR_LANG'
|
||||||
|
CHANGING cg_data = lt_config_datt ).
|
||||||
|
|
||||||
|
IF lt_config_datt IS NOT INITIAL.
|
||||||
|
DELETE FROM wdy_config_datt WHERE config_id = ls_orig_config-config_id.
|
||||||
|
MODIFY wdy_config_datt FROM TABLE lt_config_datt.
|
||||||
|
IF sy-subrc <> 0.
|
||||||
|
zcx_abapgit_exception=>raise( 'Error Updating WDY_CONFIG_DATT for Component Config ' && ms_item-obj_name ).
|
||||||
|
ENDIF.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
|
cl_wdr_cfg_persistence_utils=>save_comp_config_to_db( config_data = ls_orig_config
|
||||||
|
translator = lo_translator ).
|
||||||
|
|
||||||
|
CALL FUNCTION 'DEQUEUE_E_WDY_CONFCOMP'
|
||||||
|
EXPORTING
|
||||||
|
mode_wdy_config_data = if_wdr_cfg_constants=>c_lock_mode_exclusive
|
||||||
|
config_id = lv_config_id
|
||||||
|
config_type = lv_config_type
|
||||||
|
config_var = lv_config_var
|
||||||
|
x_config_id = 'X'
|
||||||
|
x_config_type = 'X'
|
||||||
|
x_config_var = 'X'.
|
||||||
|
|
||||||
|
tadir_insert( iv_package = iv_package ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD constructor.
|
||||||
|
|
||||||
|
super->constructor( is_item = is_item
|
||||||
|
iv_language = iv_language ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
ENDCLASS.
|
16
src/objects/zcl_abapgit_object_wdcc.clas.xml
Normal file
16
src/objects/zcl_abapgit_object_wdcc.clas.xml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<?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_OBJECT_WDCC</CLSNAME>
|
||||||
|
<LANGU>E</LANGU>
|
||||||
|
<DESCRIPT>WDA Component Configuration</DESCRIPT>
|
||||||
|
<STATE>1</STATE>
|
||||||
|
<CLSCCINCL>X</CLSCCINCL>
|
||||||
|
<FIXPT>X</FIXPT>
|
||||||
|
<UNICODE>X</UNICODE>
|
||||||
|
</VSEOCLASS>
|
||||||
|
</asx:values>
|
||||||
|
</asx:abap>
|
||||||
|
</abapGit>
|
Loading…
Reference in New Issue
Block a user