commit
stringlengths
40
40
old_file
stringlengths
2
205
new_file
stringlengths
2
205
old_contents
stringlengths
0
32.9k
new_contents
stringlengths
1
38.9k
subject
stringlengths
3
9.4k
message
stringlengths
6
9.84k
lang
stringlengths
3
13
license
stringclasses
13 values
repos
stringlengths
6
115k
2f5d44de3eb51779466def170ded64a4af8bc452
src/objects/zcl_abapgit_object_iwsg.clas.abap
src/objects/zcl_abapgit_object_iwsg.clas.abap
CLASS zcl_abapgit_object_iwsg DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_abapgit_object . PROTECTED SECTION. METHODS get_generic RETURNING VALUE(ro_generic) TYPE REF TO zcl_abapgit_objects_generic RAISING zcx_abapgit_exception . PRIVATE SECTION. METHODS get_field_rules RETURNING VALUE(ro_result) TYPE REF TO zif_abapgit_field_rules. ENDCLASS. CLASS zcl_abapgit_object_iwsg IMPLEMENTATION. METHOD get_generic. CREATE OBJECT ro_generic EXPORTING io_field_rules = get_field_rules( ) is_item = ms_item iv_language = mv_language. ENDMETHOD. METHOD zif_abapgit_object~changed_by. rv_user = zcl_abapgit_objects_super=>c_user_unknown. ENDMETHOD. METHOD zif_abapgit_object~delete. get_generic( )->delete( iv_package ). ENDMETHOD. METHOD zif_abapgit_object~deserialize. get_generic( )->deserialize( iv_package = iv_package io_xml = io_xml ). ENDMETHOD. METHOD zif_abapgit_object~exists. rv_bool = get_generic( )->exists( ). 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. rs_metadata = get_metadata( ). rs_metadata-delete_tadir = abap_true. ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. rv_is_locked = abap_false. ENDMETHOD. METHOD zif_abapgit_object~jump. ENDMETHOD. METHOD zif_abapgit_object~serialize. get_generic( )->serialize( io_xml ). ENDMETHOD. METHOD get_field_rules. ro_result = zcl_abapgit_field_rules=>create( ). ro_result->add( iv_table = '/IWFND/I_MED_SRH' iv_field = 'CREATED_BY' iv_fill_rule = zif_abapgit_field_rules=>c_fill_rule-user )->add( iv_table = '/IWFND/I_MED_SRH' iv_field = 'CREATED_TIMESTMP' iv_fill_rule = zif_abapgit_field_rules=>c_fill_rule-timestamp )->add( iv_table = '/IWFND/I_MED_SRH' iv_field = 'CHANGED_BY' iv_fill_rule = zif_abapgit_field_rules=>c_fill_rule-user )->add( iv_table = '/IWFND/I_MED_SRH' iv_field = 'CHANGED_TIMESTMP' iv_fill_rule = zif_abapgit_field_rules=>c_fill_rule-timestamp ). ENDMETHOD. ENDCLASS.
CLASS zcl_abapgit_object_iwsg DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super CREATE PUBLIC . PUBLIC SECTION. INTERFACES zif_abapgit_object . PROTECTED SECTION. METHODS get_generic RETURNING VALUE(ro_generic) TYPE REF TO zcl_abapgit_objects_generic RAISING zcx_abapgit_exception . PRIVATE SECTION. METHODS get_field_rules RETURNING VALUE(ro_result) TYPE REF TO zif_abapgit_field_rules. ENDCLASS. CLASS ZCL_ABAPGIT_OBJECT_IWSG IMPLEMENTATION. METHOD get_field_rules. ro_result = zcl_abapgit_field_rules=>create( ). ro_result->add( iv_table = '/IWFND/I_MED_SRH' iv_field = 'CREATED_BY' iv_fill_rule = zif_abapgit_field_rules=>c_fill_rule-user )->add( iv_table = '/IWFND/I_MED_SRH' iv_field = 'CREATED_TIMESTMP' iv_fill_rule = zif_abapgit_field_rules=>c_fill_rule-timestamp )->add( iv_table = '/IWFND/I_MED_SRH' iv_field = 'CHANGED_BY' iv_fill_rule = zif_abapgit_field_rules=>c_fill_rule-user )->add( iv_table = '/IWFND/I_MED_SRH' iv_field = 'CHANGED_TIMESTMP' iv_fill_rule = zif_abapgit_field_rules=>c_fill_rule-timestamp ). ENDMETHOD. METHOD get_generic. CREATE OBJECT ro_generic EXPORTING io_field_rules = get_field_rules( ) is_item = ms_item iv_language = mv_language. ENDMETHOD. METHOD zif_abapgit_object~changed_by. SELECT SINGLE changed_by FROM ('/IWFND/I_MED_SRH') INTO rv_user WHERE srv_identifier = ms_item-obj_name. IF sy-subrc <> 0. rv_user = zcl_abapgit_objects_super=>c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~delete. get_generic( )->delete( iv_package ). ENDMETHOD. METHOD zif_abapgit_object~deserialize. get_generic( )->deserialize( iv_package = iv_package io_xml = io_xml ). ENDMETHOD. METHOD zif_abapgit_object~exists. rv_bool = get_generic( )->exists( ). 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. rs_metadata = get_metadata( ). rs_metadata-delete_tadir = abap_true. ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. rv_is_locked = abap_false. ENDMETHOD. METHOD zif_abapgit_object~jump. ENDMETHOD. METHOD zif_abapgit_object~serialize. get_generic( )->serialize( io_xml ). ENDMETHOD. ENDCLASS.
implement CHANGED_BY (#5680)
IWSG: implement CHANGED_BY (#5680)
ABAP
mit
sbcgua/abapGit,sbcgua/abapGit
d51643f02684c293ddae68a4924c4e32c82896b4
src/objects/zcl_abapgit_object_sush.clas.abap
src/objects/zcl_abapgit_object_sush.clas.abap
CLASS zcl_abapgit_object_sush DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super FINAL 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 RAISING zcx_abapgit_exception. PROTECTED SECTION. PRIVATE SECTION. ENDCLASS. CLASS zcl_abapgit_object_sush IMPLEMENTATION. METHOD constructor. DATA: lr_data_head TYPE REF TO data. super->constructor( is_item = is_item iv_language = iv_language ). TRY. CREATE DATA lr_data_head TYPE ('IF_SU22_ADT_OBJECT=>TS_SU2X_HEAD'). CATCH cx_sy_create_data_error. zcx_abapgit_exception=>raise( |SUSH is not supported in your release| ). ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~changed_by. DATA ls_key TYPE usobkey. ls_key = ms_item-obj_name. SELECT SINGLE modifier FROM usob_sm INTO rv_user WHERE name = ls_key-name AND type = ls_key-type. IF sy-subrc <> 0. rv_user = c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~delete. DATA: lo_su22 TYPE REF TO object, ls_key TYPE usobkey, lr_err TYPE REF TO cx_static_check. ASSERT NOT ms_item-obj_name IS INITIAL. ls_key = ms_item-obj_name. TRY. CREATE OBJECT lo_su22 TYPE ('CL_SU22_ADT_OBJECT'). CALL METHOD lo_su22->('IF_SU22_ADT_OBJECT~DELETE') EXPORTING iv_key = ls_key iv_cleanup = abap_true. CATCH cx_static_check INTO lr_err. zcx_abapgit_exception=>raise( iv_text = lr_err->get_text( ) ). ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~deserialize. DATA: ls_key TYPE usobkey, lo_su22 TYPE REF TO object, lo_appl TYPE REF TO object, lt_usobx TYPE usobx_t, lt_usobt TYPE usobt_t, lr_appl_head TYPE REF TO data, lr_data_head TYPE REF TO data, lr_data_usobx_ext TYPE REF TO data, lr_data_usobt_ext TYPE REF TO data, lr_err TYPE REF TO cx_static_check, lv_text TYPE string. FIELD-SYMBOLS: <ls_data_head> TYPE any, <ls_appl_head> TYPE any, <lt_data_usobx_ext> TYPE ANY TABLE, <lt_data_usobt_ext> TYPE ANY TABLE, <ls_devclass> TYPE any. ASSERT NOT ms_item-obj_name IS INITIAL. TRY. CREATE DATA lr_data_head TYPE ('IF_SU22_ADT_OBJECT=>TS_SU2X_HEAD'). ASSIGN lr_data_head->* TO <ls_data_head>. CREATE DATA lr_data_usobx_ext TYPE ('IF_SU22_ADT_OBJECT=>TT_SU2X_X'). ASSIGN lr_data_usobx_ext->* TO <lt_data_usobx_ext>. CREATE DATA lr_data_usobt_ext TYPE ('IF_SU22_ADT_OBJECT=>TT_SU2X_T'). ASSIGN lr_data_usobt_ext->* TO <lt_data_usobt_ext>. "HEAD io_xml->read( EXPORTING iv_name = 'HEAD' CHANGING cg_data = <ls_data_head> ). "USOBX io_xml->read( EXPORTING iv_name = 'USOBX' CHANGING cg_data = lt_usobx ). "USOBT io_xml->read( EXPORTING iv_name = 'USOBT' CHANGING cg_data = lt_usobt ). "USOBX_EXT io_xml->read( EXPORTING iv_name = 'USOBX_EXT' CHANGING cg_data = <lt_data_usobx_ext> ). "USOBT_EXT io_xml->read( EXPORTING iv_name = 'USOBT_EXT' CHANGING cg_data = <lt_data_usobt_ext> ). CREATE OBJECT lo_su22 TYPE ('CL_SU22_ADT_OBJECT'). " check if lead application exists TRY. CALL METHOD lo_su22->('IF_SU22_ADT_OBJECT~CHECK') EXPORTING id_mode = '02' CHANGING cs_head = <ls_data_head>. CATCH cx_static_check INTO lr_err. lv_text = |Lead application of object { ms_item-obj_name } does not exist|. zcx_abapgit_exception=>raise( lv_text ). ENDTRY. MOVE-CORRESPONDING <ls_data_head> TO ls_key. CREATE DATA lr_appl_head TYPE ('CL_SU2X=>TS_HEAD'). ASSIGN lr_appl_head->* TO <ls_appl_head>. CREATE OBJECT lo_appl TYPE ('CL_SU22_APPL'). CALL METHOD lo_appl->('GET_DATA') EXPORTING is_key = ls_key IMPORTING es_head = <ls_appl_head>. ASSIGN COMPONENT 'DEVCLASS' OF STRUCTURE <ls_appl_head> TO <ls_devclass>. IF <ls_devclass> <> iv_package. lv_text = |Lead application of object { ms_item-obj_name } does not exist in package { <ls_devclass> }|. zcx_abapgit_exception=>raise( lv_text ). ENDIF. TRY. CALL METHOD lo_su22->('IF_SU22_ADT_OBJECT~UPDATE') EXPORTING is_head = <ls_data_head> it_usobx = lt_usobx it_usobt = lt_usobt. CATCH cx_static_check INTO lr_err. zcx_abapgit_exception=>raise_with_text( lr_err ). ENDTRY. corr_insert( iv_package ). CATCH cx_static_check INTO lr_err. zcx_abapgit_exception=>raise_with_text( lr_err ). ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~exists. DATA: ls_usobhash TYPE usobhash. SELECT SINGLE * FROM usobhash INTO ls_usobhash "#EC CI_ALL_FIELDS_NEEDED WHERE name = ms_item-obj_name. "#EC CI_SGLSELECT rv_bool = boolc( sy-subrc = 0 ). ENDMETHOD. METHOD zif_abapgit_object~get_comparator. 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. rs_metadata = get_metadata( ). ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. DATA lv_lock_object TYPE string. lv_lock_object = ms_item-obj_name. rv_is_locked = exists_a_lock_entry_for( iv_lock_object = lv_lock_object iv_argument = |{ ms_item-obj_type }{ ms_item-obj_name }| ). ENDMETHOD. METHOD zif_abapgit_object~jump. ENDMETHOD. METHOD zif_abapgit_object~serialize. DATA: ls_key TYPE usobkey, lo_su22 TYPE REF TO object, lt_usobx TYPE usobx_t, lt_usobt TYPE usobt_t, lr_data_head TYPE REF TO data, lr_data_usobx_ext TYPE REF TO data, lr_data_usobt_ext TYPE REF TO data, lr_err TYPE REF TO cx_static_check, lx_error TYPE REF TO cx_root. FIELD-SYMBOLS: <ls_data_head> TYPE any, <lt_data_usobx_ext> TYPE ANY TABLE, <lt_data_usobt_ext> TYPE ANY TABLE. ls_key = ms_item-obj_name. TRY. CREATE DATA lr_data_head TYPE ('IF_SU22_ADT_OBJECT=>TS_SU2X_HEAD'). ASSIGN lr_data_head->* TO <ls_data_head>. CREATE DATA lr_data_usobx_ext TYPE ('IF_SU22_ADT_OBJECT=>TT_SU2X_X'). ASSIGN lr_data_usobx_ext->* TO <lt_data_usobx_ext>. CREATE DATA lr_data_usobt_ext TYPE ('IF_SU22_ADT_OBJECT=>TT_SU2X_T'). ASSIGN lr_data_usobt_ext->* TO <lt_data_usobt_ext>. CREATE OBJECT lo_su22 TYPE ('CL_SU22_ADT_OBJECT'). TRY. CALL METHOD lo_su22->('IF_SU22_ADT_OBJECT~SELECT') EXPORTING iv_key = ls_key IMPORTING es_head = <ls_data_head> et_usobx = lt_usobx et_usobt = lt_usobt et_usobx_ext = <lt_data_usobx_ext> et_usobt_ext = <lt_data_usobt_ext>. CATCH cx_static_check INTO lr_err. zcx_abapgit_exception=>raise_with_text( lr_err ). ENDTRY. "HEAD io_xml->add( iv_name = 'HEAD' ig_data = <ls_data_head> ). "USOBX io_xml->add( iv_name = 'USOBX' ig_data = lt_usobx ). "USOBT io_xml->add( iv_name = 'USOBT' ig_data = lt_usobt ). "USOBX_EXT io_xml->add( iv_name = 'USOBX_EXT' ig_data = <lt_data_usobx_ext> ). "USOBT_EXT io_xml->add( iv_name = 'USOBT_EXT' ig_data = <lt_data_usobt_ext> ). CATCH cx_root INTO lx_error. zcx_abapgit_exception=>raise_with_text( lx_error ). ENDTRY. ENDMETHOD. ENDCLASS.
CLASS zcl_abapgit_object_sush DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super FINAL 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 RAISING zcx_abapgit_exception. PROTECTED SECTION. PRIVATE SECTION. METHODS clear_metadata CHANGING cs_data_head TYPE any ct_usobx TYPE table ct_usobt TYPE table ct_usobx_ext TYPE table ct_usobt_ext TYPE table. ENDCLASS. CLASS zcl_abapgit_object_sush IMPLEMENTATION. METHOD constructor. DATA: lr_data_head TYPE REF TO data. super->constructor( is_item = is_item iv_language = iv_language ). TRY. CREATE DATA lr_data_head TYPE ('IF_SU22_ADT_OBJECT=>TS_SU2X_HEAD'). CATCH cx_sy_create_data_error. zcx_abapgit_exception=>raise( |SUSH is not supported in your release| ). ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~changed_by. DATA ls_key TYPE usobkey. ls_key = ms_item-obj_name. SELECT SINGLE modifier FROM usob_sm INTO rv_user WHERE name = ls_key-name AND type = ls_key-type. IF sy-subrc <> 0. rv_user = c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~delete. DATA: lo_su22 TYPE REF TO object, ls_key TYPE usobkey, lr_err TYPE REF TO cx_static_check. ASSERT NOT ms_item-obj_name IS INITIAL. ls_key = ms_item-obj_name. TRY. CREATE OBJECT lo_su22 TYPE ('CL_SU22_ADT_OBJECT'). CALL METHOD lo_su22->('IF_SU22_ADT_OBJECT~DELETE') EXPORTING iv_key = ls_key iv_cleanup = abap_true. CATCH cx_static_check INTO lr_err. zcx_abapgit_exception=>raise( iv_text = lr_err->get_text( ) ). ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~deserialize. DATA: ls_key TYPE usobkey, lo_su22 TYPE REF TO object, lo_appl TYPE REF TO object, lt_usobx TYPE usobx_t, lt_usobt TYPE usobt_t, lr_appl_head TYPE REF TO data, lr_data_head TYPE REF TO data, lr_data_usobx_ext TYPE REF TO data, lr_data_usobt_ext TYPE REF TO data, lr_err TYPE REF TO cx_static_check, lv_text TYPE string. FIELD-SYMBOLS: <ls_data_head> TYPE any, <ls_appl_head> TYPE any, <lt_data_usobx_ext> TYPE ANY TABLE, <lt_data_usobt_ext> TYPE ANY TABLE, <ls_devclass> TYPE any. ASSERT NOT ms_item-obj_name IS INITIAL. TRY. CREATE DATA lr_data_head TYPE ('IF_SU22_ADT_OBJECT=>TS_SU2X_HEAD'). ASSIGN lr_data_head->* TO <ls_data_head>. CREATE DATA lr_data_usobx_ext TYPE ('IF_SU22_ADT_OBJECT=>TT_SU2X_X'). ASSIGN lr_data_usobx_ext->* TO <lt_data_usobx_ext>. CREATE DATA lr_data_usobt_ext TYPE ('IF_SU22_ADT_OBJECT=>TT_SU2X_T'). ASSIGN lr_data_usobt_ext->* TO <lt_data_usobt_ext>. "HEAD io_xml->read( EXPORTING iv_name = 'HEAD' CHANGING cg_data = <ls_data_head> ). "USOBX io_xml->read( EXPORTING iv_name = 'USOBX' CHANGING cg_data = lt_usobx ). "USOBT io_xml->read( EXPORTING iv_name = 'USOBT' CHANGING cg_data = lt_usobt ). "USOBX_EXT io_xml->read( EXPORTING iv_name = 'USOBX_EXT' CHANGING cg_data = <lt_data_usobx_ext> ). "USOBT_EXT io_xml->read( EXPORTING iv_name = 'USOBT_EXT' CHANGING cg_data = <lt_data_usobt_ext> ). CREATE OBJECT lo_su22 TYPE ('CL_SU22_ADT_OBJECT'). " check if lead application exists TRY. CALL METHOD lo_su22->('IF_SU22_ADT_OBJECT~CHECK') EXPORTING id_mode = '02' CHANGING cs_head = <ls_data_head>. CATCH cx_static_check INTO lr_err. lv_text = |Lead application of object { ms_item-obj_name } does not exist|. zcx_abapgit_exception=>raise( lv_text ). ENDTRY. MOVE-CORRESPONDING <ls_data_head> TO ls_key. CREATE DATA lr_appl_head TYPE ('CL_SU2X=>TS_HEAD'). ASSIGN lr_appl_head->* TO <ls_appl_head>. CREATE OBJECT lo_appl TYPE ('CL_SU22_APPL'). CALL METHOD lo_appl->('GET_DATA') EXPORTING is_key = ls_key IMPORTING es_head = <ls_appl_head>. ASSIGN COMPONENT 'DEVCLASS' OF STRUCTURE <ls_appl_head> TO <ls_devclass>. IF <ls_devclass> <> iv_package. lv_text = |Lead application of object { ms_item-obj_name } does not exist in package { <ls_devclass> }|. zcx_abapgit_exception=>raise( lv_text ). ENDIF. TRY. CALL METHOD lo_su22->('IF_SU22_ADT_OBJECT~UPDATE') EXPORTING is_head = <ls_data_head> it_usobx = lt_usobx it_usobt = lt_usobt. CATCH cx_static_check INTO lr_err. zcx_abapgit_exception=>raise_with_text( lr_err ). ENDTRY. corr_insert( iv_package ). CATCH cx_static_check INTO lr_err. zcx_abapgit_exception=>raise_with_text( lr_err ). ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~exists. DATA: ls_usobhash TYPE usobhash. SELECT SINGLE * FROM usobhash INTO ls_usobhash "#EC CI_ALL_FIELDS_NEEDED WHERE name = ms_item-obj_name. "#EC CI_SGLSELECT rv_bool = boolc( sy-subrc = 0 ). ENDMETHOD. METHOD zif_abapgit_object~get_comparator. 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. rs_metadata = get_metadata( ). ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. DATA lv_lock_object TYPE string. lv_lock_object = ms_item-obj_name. rv_is_locked = exists_a_lock_entry_for( iv_lock_object = lv_lock_object iv_argument = |{ ms_item-obj_type }{ ms_item-obj_name }| ). ENDMETHOD. METHOD zif_abapgit_object~jump. ENDMETHOD. METHOD zif_abapgit_object~serialize. DATA: ls_key TYPE usobkey, lo_su22 TYPE REF TO object, lt_usobx TYPE usobx_t, lt_usobt TYPE usobt_t, lr_head TYPE REF TO data, lr_usobx_ext TYPE REF TO data, lr_usobt_ext TYPE REF TO data, lr_err TYPE REF TO cx_static_check, lx_error TYPE REF TO cx_root. FIELD-SYMBOLS: <ls_head> TYPE any, <lt_usobx_ext> TYPE ANY TABLE, <lt_usobt_ext> TYPE ANY TABLE. ls_key = ms_item-obj_name. TRY. CREATE DATA lr_head TYPE ('IF_SU22_ADT_OBJECT=>TS_SU2X_HEAD'). ASSIGN lr_head->* TO <ls_head>. CREATE DATA lr_usobx_ext TYPE ('IF_SU22_ADT_OBJECT=>TT_SU2X_X'). ASSIGN lr_usobx_ext->* TO <lt_usobx_ext>. CREATE DATA lr_usobt_ext TYPE ('IF_SU22_ADT_OBJECT=>TT_SU2X_T'). ASSIGN lr_usobt_ext->* TO <lt_usobt_ext>. CREATE OBJECT lo_su22 TYPE ('CL_SU22_ADT_OBJECT'). TRY. CALL METHOD lo_su22->('IF_SU22_ADT_OBJECT~SELECT') EXPORTING iv_key = ls_key IMPORTING es_head = <ls_head> et_usobx = lt_usobx et_usobt = lt_usobt et_usobx_ext = <lt_usobx_ext> et_usobt_ext = <lt_usobt_ext>. CATCH cx_static_check INTO lr_err. zcx_abapgit_exception=>raise_with_text( lr_err ). ENDTRY. clear_metadata( CHANGING cs_data_head = <ls_head> ct_usobx = lt_usobx ct_usobt = lt_usobt ct_usobx_ext = <lt_usobx_ext> ct_usobt_ext = <lt_usobt_ext> ). "HEAD io_xml->add( iv_name = 'HEAD' ig_data = <ls_head> ). "USOBX io_xml->add( iv_name = 'USOBX' ig_data = lt_usobx ). "USOBT io_xml->add( iv_name = 'USOBT' ig_data = lt_usobt ). "USOBX_EXT io_xml->add( iv_name = 'USOBX_EXT' ig_data = <lt_usobx_ext> ). "USOBT_EXT io_xml->add( iv_name = 'USOBT_EXT' ig_data = <lt_usobt_ext> ). CATCH cx_root INTO lx_error. zcx_abapgit_exception=>raise_with_text( lx_error ). ENDTRY. ENDMETHOD. METHOD clear_metadata. DATA: BEGIN OF ls_empty_metadata, modifier TYPE c LENGTH 12, " usob_sm-modifier moddate TYPE d, " usob_sm-moddate, modtime TYPE t, " usob_sm-modtime, srcsystem TYPE tadir-srcsystem, author TYPE tadir-author, devclass TYPE tadir-devclass, END OF ls_empty_metadata. FIELD-SYMBOLS: <ls_usobx> TYPE any, <ls_usbot> TYPE any, <ls_usobt_ext> TYPE any, <ls_usobx_ext> TYPE any. MOVE-CORRESPONDING ls_empty_metadata TO cs_data_head. LOOP AT ct_usobx ASSIGNING <ls_usobx>. MOVE-CORRESPONDING ls_empty_metadata TO <ls_usobx>. ENDLOOP. LOOP AT ct_usobt ASSIGNING <ls_usbot>. MOVE-CORRESPONDING ls_empty_metadata TO <ls_usbot>. ENDLOOP. LOOP AT ct_usobt_ext ASSIGNING <ls_usobt_ext>. MOVE-CORRESPONDING ls_empty_metadata TO <ls_usobt_ext>. ENDLOOP. LOOP AT ct_usobx_ext ASSIGNING <ls_usobx_ext>. MOVE-CORRESPONDING ls_empty_metadata TO <ls_usobx_ext>. ENDLOOP. ENDMETHOD. ENDCLASS.
Clear metadata (#4967)
SUSH: Clear metadata (#4967) Co-authored-by: Lars Hvam <721d1b171982cd84b755f6b25130d2b88cd1f696@hotmail.com>
ABAP
mit
larshp/abapGit,sbcgua/abapGit,sbcgua/abapGit,larshp/abapGit
680dbd6b74ce1d4b550c7352e5afa27a8b378b60
src/objects/zcl_abapgit_object_ddls.clas.abap
src/objects/zcl_abapgit_object_ddls.clas.abap
CLASS zcl_abapgit_object_ddls DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super FINAL. PUBLIC SECTION. INTERFACES zif_abapgit_object. ALIASES mo_files FOR zif_abapgit_object~mo_files. PROTECTED SECTION. METHODS open_adt_stob IMPORTING iv_ddls_name TYPE tadir-obj_name RAISING zcx_abapgit_exception. PRIVATE SECTION. ENDCLASS. CLASS ZCL_ABAPGIT_OBJECT_DDLS IMPLEMENTATION. METHOD open_adt_stob. DATA: lr_data TYPE REF TO data, lo_ddl TYPE REF TO object, lx_error TYPE REF TO cx_root. FIELD-SYMBOLS: <lt_ddnames> TYPE STANDARD TABLE. FIELD-SYMBOLS: <lt_entity_view> TYPE STANDARD TABLE. FIELD-SYMBOLS: <lg_ddnames> TYPE any. FIELD-SYMBOLS: <lg_entity_view> TYPE any. FIELD-SYMBOLS: <lg_ddname> TYPE any. FIELD-SYMBOLS: <lg_ddlname> TYPE any. TRY. CREATE DATA lr_data TYPE ('IF_DD_DDL_TYPES=>TY_T_DDOBJ'). ASSIGN lr_data->* TO <lt_ddnames>. CREATE DATA lr_data LIKE LINE OF <lt_ddnames>. ASSIGN lr_data->* TO <lg_ddnames>. CREATE DATA lr_data TYPE ('IF_DD_DDL_TYPES=>TY_T_ENTITY_OF_VIEW'). ASSIGN lr_data->* TO <lt_entity_view>. CREATE DATA lr_data LIKE LINE OF <lt_entity_view>. ASSIGN lr_data->* TO <lg_entity_view>. CLEAR <lt_ddnames>. ASSIGN COMPONENT 'NAME' OF STRUCTURE <lg_ddnames> TO <lg_ddname>. <lg_ddname> = iv_ddls_name. INSERT <lg_ddnames> INTO TABLE <lt_ddnames>. CALL METHOD ('CL_DD_DDL_HANDLER_FACTORY')=>('CREATE') RECEIVING handler = lo_ddl. CALL METHOD lo_ddl->('IF_DD_DDL_HANDLER~GET_VIEWNAME_FROM_ENTITYNAME') EXPORTING ddnames = <lt_ddnames> IMPORTING view_of_entity = <lt_entity_view>. READ TABLE <lt_entity_view> ASSIGNING <lg_entity_view> INDEX 1. IF sy-subrc = 0. ASSIGN COMPONENT 'DDLNAME' OF STRUCTURE <lg_entity_view> TO <lg_ddlname>. jump_adt( iv_obj_name = <lg_ddlname> iv_obj_type = 'DDLS' ). ENDIF. CATCH cx_root INTO lx_error. zcx_abapgit_exception=>raise( iv_text = lx_error->get_text( ) ix_previous = lx_error ). ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~changed_by. DATA: lo_ddl TYPE REF TO object, lr_data TYPE REF TO data, lx_error TYPE REF TO cx_root. FIELD-SYMBOLS: <lg_data> TYPE any, <lg_field> TYPE any. CREATE DATA lr_data TYPE ('DDDDLSRCV'). ASSIGN lr_data->* TO <lg_data>. CALL METHOD ('CL_DD_DDL_HANDLER_FACTORY')=>('CREATE') RECEIVING handler = lo_ddl. TRY. CALL METHOD lo_ddl->('IF_DD_DDL_HANDLER~READ') EXPORTING name = ms_item-obj_name get_state = 'A' IMPORTING ddddlsrcv_wa = <lg_data>. ASSIGN COMPONENT 'AS4USER' OF STRUCTURE <lg_data> TO <lg_field>. IF sy-subrc = 0. rv_user = <lg_field>. ENDIF. CATCH cx_root INTO lx_error. zcx_abapgit_exception=>raise( iv_text = lx_error->get_text( ) ix_previous = lx_error ). ENDTRY. IF rv_user IS INITIAL. rv_user = c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~delete. DATA: lo_ddl TYPE REF TO object, lx_error TYPE REF TO cx_root. CALL METHOD ('CL_DD_DDL_HANDLER_FACTORY')=>('CREATE') RECEIVING handler = lo_ddl. TRY. CALL METHOD lo_ddl->('IF_DD_DDL_HANDLER~DELETE') EXPORTING name = ms_item-obj_name. CATCH cx_root INTO lx_error. zcx_abapgit_exception=>raise( iv_text = |DDLS, { ms_item-obj_name } { lx_error->get_text( ) }| ix_previous = lx_error ). ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~deserialize. DATA: lo_ddl TYPE REF TO object, lr_data TYPE REF TO data, lx_error TYPE REF TO cx_root. FIELD-SYMBOLS: <lg_data> TYPE any, <lg_field> TYPE any. CREATE DATA lr_data TYPE ('DDDDLSRCV'). ASSIGN lr_data->* TO <lg_data>. io_xml->read( EXPORTING iv_name = 'DDLS' CHANGING cg_data = <lg_data> ). ASSIGN COMPONENT 'SOURCE' OF STRUCTURE <lg_data> TO <lg_field>. ASSERT sy-subrc = 0. <lg_field> = mo_files->read_string( 'asddls' ) ##no_text. CALL METHOD ('CL_DD_DDL_HANDLER_FACTORY')=>('CREATE') RECEIVING handler = lo_ddl. TRY. CALL METHOD lo_ddl->('IF_DD_DDL_HANDLER~SAVE') EXPORTING name = ms_item-obj_name put_state = 'N' ddddlsrcv_wa = <lg_data>. CALL METHOD lo_ddl->('IF_DD_DDL_HANDLER~WRITE_TADIR') EXPORTING objectname = ms_item-obj_name devclass = iv_package prid = 0. CATCH cx_root INTO lx_error. zcx_abapgit_exception=>raise( iv_text = lx_error->get_text( ) ix_previous = lx_error ). ENDTRY. zcl_abapgit_objects_activation=>add_item( ms_item ). ENDMETHOD. METHOD zif_abapgit_object~exists. DATA: lv_state TYPE objstate, lo_ddl TYPE REF TO object. CALL METHOD ('CL_DD_DDL_HANDLER_FACTORY')=>('CREATE') RECEIVING handler = lo_ddl. TRY. CALL METHOD lo_ddl->('IF_DD_DDL_HANDLER~READ') EXPORTING name = ms_item-obj_name get_state = 'A' IMPORTING got_state = lv_state. IF lv_state IS INITIAL. rv_bool = abap_false. ELSE. rv_bool = abap_true. ENDIF. CATCH cx_root. rv_bool = abap_false. ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~get_comparator. RETURN. ENDMETHOD. METHOD zif_abapgit_object~get_deserialize_steps. APPEND zif_abapgit_object=>gc_step_id-ddic TO rt_steps. ENDMETHOD. METHOD zif_abapgit_object~get_metadata. rs_metadata = get_metadata( ). rs_metadata-ddic = abap_true. rs_metadata-delete_tadir = abap_true. ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. rv_is_locked = exists_a_lock_entry_for( iv_lock_object = 'ESDICT' iv_argument = |{ ms_item-obj_type }{ ms_item-obj_name }| ). ENDMETHOD. METHOD zif_abapgit_object~jump. DATA: lv_typename TYPE typename. DATA: lv_ddtypekind TYPE ddtypekind. lv_typename = ms_item-obj_name. CALL FUNCTION 'DDIF_TYPEINFO_GET' EXPORTING typename = lv_typename IMPORTING typekind = lv_ddtypekind. CASE lv_ddtypekind. WHEN 'STOB'. me->open_adt_stob( ms_item-obj_name ). WHEN OTHERS. zcx_abapgit_exception=>raise( 'DDLS Jump Error' ). ENDCASE. ENDMETHOD. METHOD zif_abapgit_object~serialize. DATA: lo_ddl TYPE REF TO object, lr_data TYPE REF TO data, lt_clr_comps TYPE STANDARD TABLE OF fieldname WITH DEFAULT KEY, lx_error TYPE REF TO cx_root. FIELD-SYMBOLS: <lg_data> TYPE any, <lg_field> TYPE any, <lv_comp> LIKE LINE OF lt_clr_comps. CREATE DATA lr_data TYPE ('DDDDLSRCV'). ASSIGN lr_data->* TO <lg_data>. CALL METHOD ('CL_DD_DDL_HANDLER_FACTORY')=>('CREATE') RECEIVING handler = lo_ddl. TRY. CALL METHOD lo_ddl->('IF_DD_DDL_HANDLER~READ') EXPORTING name = ms_item-obj_name get_state = 'A' IMPORTING ddddlsrcv_wa = <lg_data>. CATCH cx_root INTO lx_error. zcx_abapgit_exception=>raise( iv_text = lx_error->get_text( ) ix_previous = lx_error ). ENDTRY. APPEND 'AS4USER' TO lt_clr_comps. APPEND 'AS4DATE' TO lt_clr_comps. APPEND 'AS4TIME' TO lt_clr_comps. APPEND 'ACTFLAG' TO lt_clr_comps. APPEND 'CHGFLAG' TO lt_clr_comps. APPEND 'ABAP_LANGUAGE_VERSION' TO lt_clr_comps. LOOP AT lt_clr_comps ASSIGNING <lv_comp>. ASSIGN COMPONENT <lv_comp> OF STRUCTURE <lg_data> TO <lg_field>. IF sy-subrc = 0. CLEAR <lg_field>. ENDIF. ENDLOOP. ASSIGN COMPONENT 'SOURCE' OF STRUCTURE <lg_data> TO <lg_field>. ASSERT sy-subrc = 0. mo_files->add_string( iv_ext = 'asddls' iv_string = <lg_field> ) ##no_text. CLEAR <lg_field>. io_xml->add( iv_name = 'DDLS' ig_data = <lg_data> ). ENDMETHOD. ENDCLASS.
CLASS zcl_abapgit_object_ddls DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super FINAL. PUBLIC SECTION. INTERFACES zif_abapgit_object. ALIASES mo_files FOR zif_abapgit_object~mo_files. PROTECTED SECTION. METHODS open_adt_stob IMPORTING iv_ddls_name TYPE tadir-obj_name RAISING zcx_abapgit_exception. PRIVATE SECTION. ENDCLASS. CLASS ZCL_ABAPGIT_OBJECT_DDLS IMPLEMENTATION. METHOD open_adt_stob. DATA: lr_data TYPE REF TO data, lo_ddl TYPE REF TO object, lx_error TYPE REF TO cx_root. FIELD-SYMBOLS: <lt_ddnames> TYPE STANDARD TABLE. FIELD-SYMBOLS: <lt_entity_view> TYPE STANDARD TABLE. FIELD-SYMBOLS: <lg_ddnames> TYPE any. FIELD-SYMBOLS: <lg_entity_view> TYPE any. FIELD-SYMBOLS: <lg_ddname> TYPE any. FIELD-SYMBOLS: <lg_ddlname> TYPE any. TRY. CREATE DATA lr_data TYPE ('IF_DD_DDL_TYPES=>TY_T_DDOBJ'). ASSIGN lr_data->* TO <lt_ddnames>. CREATE DATA lr_data LIKE LINE OF <lt_ddnames>. ASSIGN lr_data->* TO <lg_ddnames>. CREATE DATA lr_data TYPE ('IF_DD_DDL_TYPES=>TY_T_ENTITY_OF_VIEW'). ASSIGN lr_data->* TO <lt_entity_view>. CREATE DATA lr_data LIKE LINE OF <lt_entity_view>. ASSIGN lr_data->* TO <lg_entity_view>. CLEAR <lt_ddnames>. ASSIGN COMPONENT 'NAME' OF STRUCTURE <lg_ddnames> TO <lg_ddname>. <lg_ddname> = iv_ddls_name. INSERT <lg_ddnames> INTO TABLE <lt_ddnames>. CALL METHOD ('CL_DD_DDL_HANDLER_FACTORY')=>('CREATE') RECEIVING handler = lo_ddl. CALL METHOD lo_ddl->('IF_DD_DDL_HANDLER~GET_VIEWNAME_FROM_ENTITYNAME') EXPORTING ddnames = <lt_ddnames> IMPORTING view_of_entity = <lt_entity_view>. READ TABLE <lt_entity_view> ASSIGNING <lg_entity_view> INDEX 1. IF sy-subrc = 0. ASSIGN COMPONENT 'DDLNAME' OF STRUCTURE <lg_entity_view> TO <lg_ddlname>. jump_adt( iv_obj_name = <lg_ddlname> iv_obj_type = 'DDLS' ). ENDIF. CATCH cx_root INTO lx_error. zcx_abapgit_exception=>raise( iv_text = lx_error->get_text( ) ix_previous = lx_error ). ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~changed_by. DATA: lo_ddl TYPE REF TO object, lr_data TYPE REF TO data, lx_error TYPE REF TO cx_root. FIELD-SYMBOLS: <lg_data> TYPE any, <lg_field> TYPE any. CREATE DATA lr_data TYPE ('DDDDLSRCV'). ASSIGN lr_data->* TO <lg_data>. CALL METHOD ('CL_DD_DDL_HANDLER_FACTORY')=>('CREATE') RECEIVING handler = lo_ddl. TRY. CALL METHOD lo_ddl->('IF_DD_DDL_HANDLER~READ') EXPORTING name = ms_item-obj_name get_state = 'A' IMPORTING ddddlsrcv_wa = <lg_data>. ASSIGN COMPONENT 'AS4USER' OF STRUCTURE <lg_data> TO <lg_field>. IF sy-subrc = 0. rv_user = <lg_field>. ENDIF. CATCH cx_root INTO lx_error. zcx_abapgit_exception=>raise( iv_text = lx_error->get_text( ) ix_previous = lx_error ). ENDTRY. IF rv_user IS INITIAL. rv_user = c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~delete. DATA: lo_ddl TYPE REF TO object, lx_error TYPE REF TO cx_root. CALL METHOD ('CL_DD_DDL_HANDLER_FACTORY')=>('CREATE') RECEIVING handler = lo_ddl. TRY. CALL METHOD lo_ddl->('IF_DD_DDL_HANDLER~DELETE') EXPORTING name = ms_item-obj_name. CATCH cx_root INTO lx_error. zcx_abapgit_exception=>raise( iv_text = |DDLS, { ms_item-obj_name } { lx_error->get_text( ) }| ix_previous = lx_error ). ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~deserialize. DATA: lo_ddl TYPE REF TO object, lr_data TYPE REF TO data, lx_error TYPE REF TO cx_root. FIELD-SYMBOLS: <lg_data> TYPE any, <lg_field> TYPE any. CREATE DATA lr_data TYPE ('DDDDLSRCV'). ASSIGN lr_data->* TO <lg_data>. io_xml->read( EXPORTING iv_name = 'DDLS' CHANGING cg_data = <lg_data> ). ASSIGN COMPONENT 'SOURCE' OF STRUCTURE <lg_data> TO <lg_field>. ASSERT sy-subrc = 0. <lg_field> = mo_files->read_string( 'asddls' ) ##no_text. CALL METHOD ('CL_DD_DDL_HANDLER_FACTORY')=>('CREATE') RECEIVING handler = lo_ddl. TRY. CALL METHOD lo_ddl->('IF_DD_DDL_HANDLER~SAVE') EXPORTING name = ms_item-obj_name put_state = 'N' ddddlsrcv_wa = <lg_data>. CALL METHOD lo_ddl->('IF_DD_DDL_HANDLER~WRITE_TADIR') EXPORTING objectname = ms_item-obj_name devclass = iv_package prid = 0. corr_insert( iv_package ). CATCH cx_root INTO lx_error. zcx_abapgit_exception=>raise( iv_text = lx_error->get_text( ) ix_previous = lx_error ). ENDTRY. zcl_abapgit_objects_activation=>add_item( ms_item ). ENDMETHOD. METHOD zif_abapgit_object~exists. DATA: lv_state TYPE objstate, lo_ddl TYPE REF TO object. CALL METHOD ('CL_DD_DDL_HANDLER_FACTORY')=>('CREATE') RECEIVING handler = lo_ddl. TRY. CALL METHOD lo_ddl->('IF_DD_DDL_HANDLER~READ') EXPORTING name = ms_item-obj_name get_state = 'A' IMPORTING got_state = lv_state. IF lv_state IS INITIAL. rv_bool = abap_false. ELSE. rv_bool = abap_true. ENDIF. CATCH cx_root. rv_bool = abap_false. ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~get_comparator. RETURN. ENDMETHOD. METHOD zif_abapgit_object~get_deserialize_steps. APPEND zif_abapgit_object=>gc_step_id-ddic TO rt_steps. ENDMETHOD. METHOD zif_abapgit_object~get_metadata. rs_metadata = get_metadata( ). rs_metadata-ddic = abap_true. rs_metadata-delete_tadir = abap_true. ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. rv_is_locked = exists_a_lock_entry_for( iv_lock_object = 'ESDICT' iv_argument = |{ ms_item-obj_type }{ ms_item-obj_name }| ). ENDMETHOD. METHOD zif_abapgit_object~jump. DATA: lv_typename TYPE typename. DATA: lv_ddtypekind TYPE ddtypekind. lv_typename = ms_item-obj_name. CALL FUNCTION 'DDIF_TYPEINFO_GET' EXPORTING typename = lv_typename IMPORTING typekind = lv_ddtypekind. CASE lv_ddtypekind. WHEN 'STOB'. me->open_adt_stob( ms_item-obj_name ). WHEN OTHERS. zcx_abapgit_exception=>raise( 'DDLS Jump Error' ). ENDCASE. ENDMETHOD. METHOD zif_abapgit_object~serialize. DATA: lo_ddl TYPE REF TO object, lr_data TYPE REF TO data, lt_clr_comps TYPE STANDARD TABLE OF fieldname WITH DEFAULT KEY, lx_error TYPE REF TO cx_root. FIELD-SYMBOLS: <lg_data> TYPE any, <lg_field> TYPE any, <lv_comp> LIKE LINE OF lt_clr_comps. CREATE DATA lr_data TYPE ('DDDDLSRCV'). ASSIGN lr_data->* TO <lg_data>. CALL METHOD ('CL_DD_DDL_HANDLER_FACTORY')=>('CREATE') RECEIVING handler = lo_ddl. TRY. CALL METHOD lo_ddl->('IF_DD_DDL_HANDLER~READ') EXPORTING name = ms_item-obj_name get_state = 'A' IMPORTING ddddlsrcv_wa = <lg_data>. CATCH cx_root INTO lx_error. zcx_abapgit_exception=>raise( iv_text = lx_error->get_text( ) ix_previous = lx_error ). ENDTRY. APPEND 'AS4USER' TO lt_clr_comps. APPEND 'AS4DATE' TO lt_clr_comps. APPEND 'AS4TIME' TO lt_clr_comps. APPEND 'ACTFLAG' TO lt_clr_comps. APPEND 'CHGFLAG' TO lt_clr_comps. APPEND 'ABAP_LANGUAGE_VERSION' TO lt_clr_comps. LOOP AT lt_clr_comps ASSIGNING <lv_comp>. ASSIGN COMPONENT <lv_comp> OF STRUCTURE <lg_data> TO <lg_field>. IF sy-subrc = 0. CLEAR <lg_field>. ENDIF. ENDLOOP. ASSIGN COMPONENT 'SOURCE' OF STRUCTURE <lg_data> TO <lg_field>. ASSERT sy-subrc = 0. mo_files->add_string( iv_ext = 'asddls' iv_string = <lg_field> ) ##no_text. CLEAR <lg_field>. io_xml->add( iv_name = 'DDLS' ig_data = <lg_data> ). ENDMETHOD. ENDCLASS.
Write transport request entry (#2927)
DDLS-Serialization: Write transport request entry (#2927)
ABAP
mit
larshp/abapGit,larshp/abapGit,EduardoCopat/abapGit,EduardoCopat/abapGit,sbcgua/abapGit,sbcgua/abapGit
1dd5ebcb4277221b84b2f07a8b9e2396c5e0b5c0
src/data/zcl_abapgit_data_serializer.clas.abap
src/data/zcl_abapgit_data_serializer.clas.abap
CLASS zcl_abapgit_data_serializer DEFINITION PUBLIC CREATE PRIVATE GLOBAL FRIENDS zcl_abapgit_data_factory . PUBLIC SECTION. INTERFACES zif_abapgit_data_serializer . PROTECTED SECTION. PRIVATE SECTION. CONSTANTS c_max_records TYPE i VALUE 10000 ##NO_TEXT. METHODS convert_itab_to_json IMPORTING !ir_data TYPE REF TO data RETURNING VALUE(rv_data) TYPE xstring RAISING zcx_abapgit_exception . METHODS read_database_table IMPORTING !iv_name TYPE tadir-obj_name !it_where TYPE string_table RETURNING VALUE(rr_data) TYPE REF TO data RAISING zcx_abapgit_exception . ENDCLASS. CLASS zcl_abapgit_data_serializer IMPLEMENTATION. METHOD convert_itab_to_json. DATA lo_ajson TYPE REF TO zcl_abapgit_ajson. DATA lv_string TYPE string. DATA lx_ajson TYPE REF TO zcx_abapgit_ajson_error. FIELD-SYMBOLS <lg_tab> TYPE ANY TABLE. ASSIGN ir_data->* TO <lg_tab>. TRY. lo_ajson = zcl_abapgit_ajson=>create_empty( ). lo_ajson->keep_item_order( ). lo_ajson->set( iv_path = '/' iv_val = <lg_tab> ). lv_string = lo_ajson->stringify( 2 ). CATCH zcx_abapgit_ajson_error INTO lx_ajson. zcx_abapgit_exception=>raise( lx_ajson->get_text( ) ). ENDTRY. rv_data = zcl_abapgit_convert=>string_to_xstring_utf8( lv_string ). ENDMETHOD. METHOD read_database_table. DATA lv_records TYPE i. DATA lv_where LIKE LINE OF it_where. FIELD-SYMBOLS <lg_tab> TYPE ANY TABLE. rr_data = zcl_abapgit_data_utils=>build_table_itab( iv_name ). ASSIGN rr_data->* TO <lg_tab>. LOOP AT it_where INTO lv_where. SELECT * FROM (iv_name) APPENDING TABLE <lg_tab> WHERE (lv_where). ENDLOOP. IF lines( it_where ) = 0. SELECT * FROM (iv_name) INTO TABLE <lg_tab>. ENDIF. lv_records = lines( <lg_tab> ). IF lv_records > c_max_records. zcx_abapgit_exception=>raise( |Too many records selected from table { iv_name } (selected { lv_records }, max { c_max_records })| ). ENDIF. ENDMETHOD. METHOD zif_abapgit_data_serializer~serialize. DATA lt_configs TYPE zif_abapgit_data_config=>ty_config_tt. DATA ls_config LIKE LINE OF lt_configs. DATA ls_file LIKE LINE OF rt_files. DATA lr_data TYPE REF TO data. ls_file-path = zif_abapgit_data_config=>c_default_path. lt_configs = ii_config->get_configs( ). LOOP AT lt_configs INTO ls_config. ASSERT ls_config-type = zif_abapgit_data_config=>c_data_type-tabu. " todo ASSERT ls_config-name IS NOT INITIAL. lr_data = read_database_table( iv_name = ls_config-name it_where = ls_config-where ). ls_file-filename = zcl_abapgit_data_utils=>build_filename( ls_config ). ls_file-data = convert_itab_to_json( lr_data ). ls_file-sha1 = zcl_abapgit_hash=>sha1_blob( ls_file-data ). APPEND ls_file TO rt_files. ENDLOOP. ENDMETHOD. ENDCLASS.
CLASS zcl_abapgit_data_serializer DEFINITION PUBLIC CREATE PRIVATE GLOBAL FRIENDS zcl_abapgit_data_factory . PUBLIC SECTION. INTERFACES zif_abapgit_data_serializer . PROTECTED SECTION. PRIVATE SECTION. CONSTANTS c_max_records TYPE i VALUE 10000 ##NO_TEXT. METHODS convert_itab_to_json IMPORTING !ir_data TYPE REF TO data RETURNING VALUE(rv_data) TYPE xstring RAISING zcx_abapgit_exception . METHODS read_database_table IMPORTING !iv_name TYPE tadir-obj_name !it_where TYPE string_table RETURNING VALUE(rr_data) TYPE REF TO data RAISING zcx_abapgit_exception . METHODS exists_database_table IMPORTING !iv_name TYPE tadir-obj_name RETURNING VALUE(rv_exists) TYPE abap_bool. ENDCLASS. CLASS zcl_abapgit_data_serializer IMPLEMENTATION. METHOD convert_itab_to_json. DATA lo_ajson TYPE REF TO zcl_abapgit_ajson. DATA lv_string TYPE string. DATA lx_ajson TYPE REF TO zcx_abapgit_ajson_error. FIELD-SYMBOLS <lg_tab> TYPE ANY TABLE. ASSIGN ir_data->* TO <lg_tab>. TRY. lo_ajson = zcl_abapgit_ajson=>create_empty( ). lo_ajson->keep_item_order( ). lo_ajson->set( iv_path = '/' iv_val = <lg_tab> ). lv_string = lo_ajson->stringify( 2 ). CATCH zcx_abapgit_ajson_error INTO lx_ajson. zcx_abapgit_exception=>raise( lx_ajson->get_text( ) ). ENDTRY. rv_data = zcl_abapgit_convert=>string_to_xstring_utf8( lv_string ). ENDMETHOD. METHOD exists_database_table. DATA lv_table TYPE tabname. DATA lv_subrc TYPE sy-subrc. lv_table = iv_name. CALL FUNCTION 'DD_EXIST_TABLE' EXPORTING tabname = lv_table status = 'A' IMPORTING subrc = lv_subrc EXCEPTIONS wrong_status = 1 OTHERS = 2. rv_exists = boolc( sy-subrc = 0 AND lv_subrc = 0 ). ENDMETHOD. METHOD read_database_table. DATA lv_records TYPE i. DATA lv_where LIKE LINE OF it_where. FIELD-SYMBOLS <lg_tab> TYPE ANY TABLE. rr_data = zcl_abapgit_data_utils=>build_table_itab( iv_name ). ASSIGN rr_data->* TO <lg_tab>. LOOP AT it_where INTO lv_where. SELECT * FROM (iv_name) APPENDING TABLE <lg_tab> WHERE (lv_where). ENDLOOP. IF lines( it_where ) = 0. SELECT * FROM (iv_name) INTO TABLE <lg_tab>. ENDIF. lv_records = lines( <lg_tab> ). IF lv_records > c_max_records. zcx_abapgit_exception=>raise( |Too many records selected from table { iv_name } (selected { lv_records }, max { c_max_records })| ). ENDIF. ENDMETHOD. METHOD zif_abapgit_data_serializer~serialize. DATA lt_configs TYPE zif_abapgit_data_config=>ty_config_tt. DATA ls_config LIKE LINE OF lt_configs. DATA ls_file LIKE LINE OF rt_files. DATA lr_data TYPE REF TO data. ls_file-path = zif_abapgit_data_config=>c_default_path. lt_configs = ii_config->get_configs( ). LOOP AT lt_configs INTO ls_config. ASSERT ls_config-type = zif_abapgit_data_config=>c_data_type-tabu. " todo ASSERT ls_config-name IS NOT INITIAL. IF exists_database_table( ls_config-name ) = abap_true. lr_data = read_database_table( iv_name = ls_config-name it_where = ls_config-where ). ls_file-filename = zcl_abapgit_data_utils=>build_filename( ls_config ). ls_file-data = convert_itab_to_json( lr_data ). ls_file-sha1 = zcl_abapgit_hash=>sha1_blob( ls_file-data ). APPEND ls_file TO rt_files. ENDIF. ENDLOOP. ENDMETHOD. ENDCLASS.
Fix dump for repos using data tables (#5581)
Fix dump for repos using data tables (#5581) * Fix dump for repos using data tables Fixes dump in `zcl_abapgit_data_util` in case the data table does not exist yet. * Method Co-authored-by: Lars Hvam <721d1b171982cd84b755f6b25130d2b88cd1f696@hotmail.com>
ABAP
mit
sbcgua/abapGit,sbcgua/abapGit
1ee92803d69e7fbcfc7cbb822474c5779f370a74
src/zabapgit.prog.abap
src/zabapgit.prog.abap
REPORT zabapgit LINE-SIZE 100. * See http://www.abapgit.org CONSTANTS: gc_xml_version TYPE string VALUE 'v1.0.0', "#EC NOTEXT gc_abap_version TYPE string VALUE 'v1.24.5'. "#EC NOTEXT ******************************************************************************** * The MIT License (MIT) * * Copyright (c) 2014 abapGit Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. ******************************************************************************** SELECTION-SCREEN BEGIN OF SCREEN 1001. * dummy for triggering screen on Java SAP GUI SELECTION-SCREEN END OF SCREEN 1001. INCLUDE zabapgit_password_dialog. " !!! Contains SELECTION SCREEN INCLUDE zabapgit_definitions. INCLUDE zabapgit_macros. INCLUDE zabapgit_exceptions. INCLUDE zabapgit_zlib. INCLUDE zabapgit_html. INCLUDE zabapgit_util. INCLUDE zabapgit_xml. INCLUDE zabapgit_app. " Some deferred definitions here INCLUDE zabapgit_persistence_old. INCLUDE zabapgit_persistence. INCLUDE zabapgit_dot_abapgit. INCLUDE zabapgit_sap_package. INCLUDE zabapgit_stage. INCLUDE zabapgit_git_helpers. INCLUDE zabapgit_repo. INCLUDE zabapgit_stage_logic. INCLUDE zabapgit_http. INCLUDE zabapgit_git. INCLUDE zabapgit_objects. INCLUDE zabapgit_tadir. INCLUDE zabapgit_file_status. INCLUDE zabapgit_popups. INCLUDE zabapgit_zip. INCLUDE zabapgit_objects_impl. INCLUDE zabapgit_object_serializing. " All serializing classes here INCLUDE zabapgit_repo_impl. INCLUDE zabapgit_background. INCLUDE zabapgit_transport. INCLUDE zabapgit_services. " All services here INCLUDE zabapgit_gui_asset_manager. INCLUDE zabapgit_gui_pages. " All GUI pages here INCLUDE zabapgit_gui_pages_userexit IF FOUND. INCLUDE zabapgit_gui_router. INCLUDE zabapgit_gui. INCLUDE zabapgit_app_impl. INCLUDE zabapgit_unit_test. INCLUDE zabapgit_migrations. " Data migration routines INCLUDE zabapgit_forms. ********************************************************************** INITIALIZATION. lcl_password_dialog=>on_screen_init( ). START-OF-SELECTION. PERFORM run. * Hide Execute button from screen AT SELECTION-SCREEN OUTPUT. IF sy-dynnr = lcl_password_dialog=>dynnr. lcl_password_dialog=>on_screen_output( ). ELSE. PERFORM output. ENDIF. * SAP back command re-direction AT SELECTION-SCREEN ON EXIT-COMMAND. PERFORM exit. AT SELECTION-SCREEN. IF sy-dynnr = lcl_password_dialog=>dynnr. lcl_password_dialog=>on_screen_event( sscrfields-ucomm ). ENDIF.
REPORT zabapgit LINE-SIZE 100. * See http://www.abapgit.org CONSTANTS: gc_xml_version TYPE string VALUE 'v1.0.0', "#EC NOTEXT gc_abap_version TYPE string VALUE 'v1.24.6'. "#EC NOTEXT ******************************************************************************** * The MIT License (MIT) * * Copyright (c) 2014 abapGit Contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. ******************************************************************************** SELECTION-SCREEN BEGIN OF SCREEN 1001. * dummy for triggering screen on Java SAP GUI SELECTION-SCREEN END OF SCREEN 1001. INCLUDE zabapgit_password_dialog. " !!! Contains SELECTION SCREEN INCLUDE zabapgit_definitions. INCLUDE zabapgit_macros. INCLUDE zabapgit_exceptions. INCLUDE zabapgit_zlib. INCLUDE zabapgit_html. INCLUDE zabapgit_util. INCLUDE zabapgit_xml. INCLUDE zabapgit_app. " Some deferred definitions here INCLUDE zabapgit_persistence_old. INCLUDE zabapgit_persistence. INCLUDE zabapgit_dot_abapgit. INCLUDE zabapgit_sap_package. INCLUDE zabapgit_stage. INCLUDE zabapgit_git_helpers. INCLUDE zabapgit_repo. INCLUDE zabapgit_stage_logic. INCLUDE zabapgit_http. INCLUDE zabapgit_git. INCLUDE zabapgit_objects. INCLUDE zabapgit_tadir. INCLUDE zabapgit_file_status. INCLUDE zabapgit_popups. INCLUDE zabapgit_zip. INCLUDE zabapgit_objects_impl. INCLUDE zabapgit_object_serializing. " All serializing classes here INCLUDE zabapgit_repo_impl. INCLUDE zabapgit_background. INCLUDE zabapgit_transport. INCLUDE zabapgit_services. " All services here INCLUDE zabapgit_gui_asset_manager. INCLUDE zabapgit_gui_pages. " All GUI pages here INCLUDE zabapgit_gui_pages_userexit IF FOUND. INCLUDE zabapgit_gui_router. INCLUDE zabapgit_gui. INCLUDE zabapgit_app_impl. INCLUDE zabapgit_unit_test. INCLUDE zabapgit_migrations. " Data migration routines INCLUDE zabapgit_forms. ********************************************************************** INITIALIZATION. lcl_password_dialog=>on_screen_init( ). START-OF-SELECTION. PERFORM run. * Hide Execute button from screen AT SELECTION-SCREEN OUTPUT. IF sy-dynnr = lcl_password_dialog=>dynnr. lcl_password_dialog=>on_screen_output( ). ELSE. PERFORM output. ENDIF. * SAP back command re-direction AT SELECTION-SCREEN ON EXIT-COMMAND. PERFORM exit. AT SELECTION-SCREEN. IF sy-dynnr = lcl_password_dialog=>dynnr. lcl_password_dialog=>on_screen_event( sscrfields-ucomm ). ENDIF.
bump version to v1.24.6
bump version to v1.24.6
ABAP
mit
EduardoCopat/abapGit,nununo/abapGit,EduardoCopat/abapGit,apex8/abapGit,sbcgua/abapGit,larshp/abapGit,apex8/abapGit,sbcgua/abapGit,larshp/abapGit,nununo/abapGit
7f312f8634bb4538ce50d6853fd4633f9dd352ed
src/ui/zcl_abapgit_html_action_utils.clas.abap
src/ui/zcl_abapgit_html_action_utils.clas.abap
CLASS zcl_abapgit_html_action_utils DEFINITION PUBLIC CREATE PUBLIC . PUBLIC SECTION. CLASS-METHODS field_keys_to_upper CHANGING !ct_fields TYPE tihttpnvp . CLASS-METHODS parse_fields IMPORTING !iv_string TYPE clike RETURNING VALUE(rt_fields) TYPE tihttpnvp . CLASS-METHODS parse_fields_upper_case_name IMPORTING !iv_string TYPE clike RETURNING VALUE(rt_fields) TYPE tihttpnvp . CLASS-METHODS add_field IMPORTING !iv_name TYPE string !ig_field TYPE any CHANGING !ct_field TYPE tihttpnvp . CLASS-METHODS get_field IMPORTING !iv_name TYPE string !it_field TYPE tihttpnvp CHANGING !cg_field TYPE any . CLASS-METHODS jump_encode IMPORTING !iv_obj_type TYPE tadir-object !iv_obj_name TYPE tadir-obj_name RETURNING VALUE(rv_string) TYPE string . CLASS-METHODS jump_decode IMPORTING !iv_string TYPE clike EXPORTING !ev_obj_type TYPE tadir-object !ev_obj_name TYPE tadir-obj_name RAISING zcx_abapgit_exception . CLASS-METHODS dir_encode IMPORTING !iv_path TYPE string RETURNING VALUE(rv_string) TYPE string . CLASS-METHODS dir_decode IMPORTING !iv_string TYPE clike RETURNING VALUE(rv_path) TYPE string RAISING zcx_abapgit_exception . CLASS-METHODS file_encode IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key !ig_file TYPE any "assuming ty_file RETURNING VALUE(rv_string) TYPE string . CLASS-METHODS obj_encode IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key !ig_object TYPE any "assuming ty_item RETURNING VALUE(rv_string) TYPE string . CLASS-METHODS file_obj_decode IMPORTING !iv_string TYPE clike EXPORTING !ev_key TYPE zif_abapgit_persistence=>ty_repo-key !eg_file TYPE any "assuming ty_file !eg_object TYPE any "assuming ty_item RAISING zcx_abapgit_exception . CLASS-METHODS dbkey_encode IMPORTING !is_key TYPE zif_abapgit_persistence=>ty_content RETURNING VALUE(rv_string) TYPE string . CLASS-METHODS dbkey_decode IMPORTING !iv_string TYPE clike RETURNING VALUE(rs_key) TYPE zif_abapgit_persistence=>ty_content . CLASS-METHODS stage_decode IMPORTING !iv_getdata TYPE clike EXPORTING !ev_key TYPE zif_abapgit_persistence=>ty_repo-key !ev_seed TYPE string RAISING zcx_abapgit_exception . PRIVATE SECTION. CLASS-METHODS unescape IMPORTING iv_string TYPE string RETURNING VALUE(rv_string) TYPE string. ENDCLASS. CLASS zcl_abapgit_html_action_utils IMPLEMENTATION. METHOD add_field. DATA ls_field LIKE LINE OF ct_field. FIELD-SYMBOLS <lg_src> TYPE any. ls_field-name = iv_name. CASE cl_abap_typedescr=>describe_by_data( ig_field )->kind. WHEN cl_abap_typedescr=>kind_elem. ls_field-value = ig_field. WHEN cl_abap_typedescr=>kind_struct. ASSIGN COMPONENT iv_name OF STRUCTURE ig_field TO <lg_src>. ASSERT <lg_src> IS ASSIGNED. ls_field-value = <lg_src>. WHEN OTHERS. ASSERT 0 = 1. ENDCASE. APPEND ls_field TO ct_field. ENDMETHOD. METHOD dbkey_decode. DATA: lt_fields TYPE tihttpnvp. lt_fields = parse_fields_upper_case_name( cl_http_utility=>unescape_url( |{ iv_string }| ) ). get_field( EXPORTING iv_name = 'TYPE' it_field = lt_fields CHANGING cg_field = rs_key-type ). get_field( EXPORTING iv_name = 'VALUE' it_field = lt_fields CHANGING cg_field = rs_key-value ). ENDMETHOD. METHOD dbkey_encode. DATA: lt_fields TYPE tihttpnvp. add_field( EXPORTING iv_name = 'TYPE' ig_field = is_key-type CHANGING ct_field = lt_fields ). add_field( EXPORTING iv_name = 'VALUE' ig_field = is_key-value CHANGING ct_field = lt_fields ). rv_string = cl_http_utility=>if_http_utility~fields_to_string( lt_fields ). ENDMETHOD. METHOD dir_decode. DATA: lt_fields TYPE tihttpnvp. lt_fields = parse_fields( iv_string ). get_field( EXPORTING iv_name = 'PATH' it_field = lt_fields CHANGING cg_field = rv_path ). ENDMETHOD. METHOD dir_encode. DATA: lt_fields TYPE tihttpnvp. add_field( EXPORTING iv_name = 'PATH' ig_field = iv_path CHANGING ct_field = lt_fields ). rv_string = cl_http_utility=>if_http_utility~fields_to_string( lt_fields ). ENDMETHOD. METHOD field_keys_to_upper. FIELD-SYMBOLS <ls_field> LIKE LINE OF ct_fields. LOOP AT ct_fields ASSIGNING <ls_field>. <ls_field>-name = to_upper( <ls_field>-name ). ENDLOOP. ENDMETHOD. METHOD file_encode. DATA: lt_fields TYPE tihttpnvp. add_field( EXPORTING iv_name = 'KEY' ig_field = iv_key CHANGING ct_field = lt_fields ). add_field( EXPORTING iv_name = 'PATH' ig_field = ig_file CHANGING ct_field = lt_fields ). add_field( EXPORTING iv_name = 'FILENAME' ig_field = ig_file CHANGING ct_field = lt_fields ). rv_string = cl_http_utility=>if_http_utility~fields_to_string( lt_fields ). ENDMETHOD. METHOD file_obj_decode. DATA: lt_fields TYPE tihttpnvp. ASSERT eg_file IS SUPPLIED OR eg_object IS SUPPLIED. CLEAR: ev_key, eg_file, eg_object. lt_fields = parse_fields_upper_case_name( iv_string ). get_field( EXPORTING iv_name = 'KEY' it_field = lt_fields CHANGING cg_field = ev_key ). IF eg_file IS SUPPLIED. get_field( EXPORTING iv_name = 'PATH' it_field = lt_fields CHANGING cg_field = eg_file ). get_field( EXPORTING iv_name = 'FILENAME' it_field = lt_fields CHANGING cg_field = eg_file ). ENDIF. IF eg_object IS SUPPLIED. get_field( EXPORTING iv_name = 'OBJ_TYPE' it_field = lt_fields CHANGING cg_field = eg_object ). get_field( EXPORTING iv_name = 'OBJ_NAME' it_field = lt_fields CHANGING cg_field = eg_object ). ENDIF. ENDMETHOD. METHOD get_field. FIELD-SYMBOLS: <ls_field> LIKE LINE OF it_field, <lg_dest> TYPE any. READ TABLE it_field ASSIGNING <ls_field> WITH KEY name = iv_name. IF sy-subrc IS NOT INITIAL. RETURN. ENDIF. CASE cl_abap_typedescr=>describe_by_data( cg_field )->kind. WHEN cl_abap_typedescr=>kind_elem. cg_field = <ls_field>-value. WHEN cl_abap_typedescr=>kind_struct. ASSIGN COMPONENT iv_name OF STRUCTURE cg_field TO <lg_dest>. ASSERT <lg_dest> IS ASSIGNED. <lg_dest> = <ls_field>-value. WHEN OTHERS. ASSERT 0 = 1. ENDCASE. ENDMETHOD. METHOD jump_decode. DATA: lt_fields TYPE tihttpnvp. lt_fields = parse_fields( iv_string ). get_field( EXPORTING iv_name = 'TYPE' it_field = lt_fields CHANGING cg_field = ev_obj_type ). get_field( EXPORTING iv_name = 'NAME' it_field = lt_fields CHANGING cg_field = ev_obj_name ). ENDMETHOD. METHOD jump_encode. DATA: lt_fields TYPE tihttpnvp. add_field( EXPORTING iv_name = 'TYPE' ig_field = iv_obj_type CHANGING ct_field = lt_fields ). add_field( EXPORTING iv_name = 'NAME' ig_field = iv_obj_name CHANGING ct_field = lt_fields ). rv_string = cl_http_utility=>if_http_utility~fields_to_string( lt_fields ). ENDMETHOD. METHOD obj_encode. DATA: lt_fields TYPE tihttpnvp. add_field( EXPORTING iv_name = 'KEY' ig_field = iv_key CHANGING ct_field = lt_fields ). add_field( EXPORTING iv_name = 'OBJ_TYPE' ig_field = ig_object CHANGING ct_field = lt_fields ). add_field( EXPORTING iv_name = 'OBJ_NAME' ig_field = ig_object CHANGING ct_field = lt_fields ). rv_string = cl_http_utility=>if_http_utility~fields_to_string( lt_fields ). ENDMETHOD. METHOD parse_fields. DATA: lt_substrings TYPE stringtab, ls_field LIKE LINE OF rt_fields. FIELD-SYMBOLS: <lv_substring> LIKE LINE OF lt_substrings. SPLIT iv_string AT '&' INTO TABLE lt_substrings. LOOP AT lt_substrings ASSIGNING <lv_substring>. CLEAR: ls_field. ls_field-name = substring_before( val = <lv_substring> sub = '=' ). ls_field-name = unescape( ls_field-name ). ls_field-value = substring_after( val = <lv_substring> sub = '=' ). ls_field-value = unescape( ls_field-value ). INSERT ls_field INTO TABLE rt_fields. ENDLOOP. ENDMETHOD. METHOD parse_fields_upper_case_name. rt_fields = parse_fields( iv_string ). field_keys_to_upper( CHANGING ct_fields = rt_fields ). ENDMETHOD. METHOD stage_decode. DATA: lt_fields TYPE tihttpnvp. lt_fields = parse_fields_upper_case_name( iv_getdata ). get_field( EXPORTING iv_name = 'KEY' it_field = lt_fields CHANGING cg_field = ev_key ). get_field( EXPORTING iv_name = 'SEED' it_field = lt_fields CHANGING cg_field = ev_seed ). ASSERT NOT ev_key IS INITIAL. ENDMETHOD. METHOD unescape. * do not use cl_http_utility as it does strange things with the encoding rv_string = iv_string. * todo, more to be added here REPLACE ALL OCCURRENCES OF '%3F' IN rv_string WITH '?'. ENDMETHOD. ENDCLASS.
CLASS zcl_abapgit_html_action_utils DEFINITION PUBLIC CREATE PUBLIC . PUBLIC SECTION. CLASS-METHODS field_keys_to_upper CHANGING !ct_fields TYPE tihttpnvp . CLASS-METHODS parse_fields IMPORTING !iv_string TYPE clike RETURNING VALUE(rt_fields) TYPE tihttpnvp . CLASS-METHODS parse_fields_upper_case_name IMPORTING !iv_string TYPE clike RETURNING VALUE(rt_fields) TYPE tihttpnvp . CLASS-METHODS add_field IMPORTING !iv_name TYPE string !ig_field TYPE any CHANGING !ct_field TYPE tihttpnvp . CLASS-METHODS get_field IMPORTING !iv_name TYPE string !it_field TYPE tihttpnvp CHANGING !cg_field TYPE any . CLASS-METHODS jump_encode IMPORTING !iv_obj_type TYPE tadir-object !iv_obj_name TYPE tadir-obj_name RETURNING VALUE(rv_string) TYPE string . CLASS-METHODS jump_decode IMPORTING !iv_string TYPE clike EXPORTING !ev_obj_type TYPE tadir-object !ev_obj_name TYPE tadir-obj_name RAISING zcx_abapgit_exception . CLASS-METHODS dir_encode IMPORTING !iv_path TYPE string RETURNING VALUE(rv_string) TYPE string . CLASS-METHODS dir_decode IMPORTING !iv_string TYPE clike RETURNING VALUE(rv_path) TYPE string RAISING zcx_abapgit_exception . CLASS-METHODS file_encode IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key !ig_file TYPE any "assuming ty_file RETURNING VALUE(rv_string) TYPE string . CLASS-METHODS obj_encode IMPORTING !iv_key TYPE zif_abapgit_persistence=>ty_repo-key !ig_object TYPE any "assuming ty_item RETURNING VALUE(rv_string) TYPE string . CLASS-METHODS file_obj_decode IMPORTING !iv_string TYPE clike EXPORTING !ev_key TYPE zif_abapgit_persistence=>ty_repo-key !eg_file TYPE any "assuming ty_file !eg_object TYPE any "assuming ty_item RAISING zcx_abapgit_exception . CLASS-METHODS dbkey_encode IMPORTING !is_key TYPE zif_abapgit_persistence=>ty_content RETURNING VALUE(rv_string) TYPE string . CLASS-METHODS dbkey_decode IMPORTING !iv_string TYPE clike RETURNING VALUE(rs_key) TYPE zif_abapgit_persistence=>ty_content . CLASS-METHODS stage_decode IMPORTING !iv_getdata TYPE clike EXPORTING !ev_key TYPE zif_abapgit_persistence=>ty_repo-key !ev_seed TYPE string RAISING zcx_abapgit_exception . PRIVATE SECTION. CLASS-METHODS unescape IMPORTING iv_string TYPE string RETURNING VALUE(rv_string) TYPE string. ENDCLASS. CLASS zcl_abapgit_html_action_utils IMPLEMENTATION. METHOD add_field. DATA ls_field LIKE LINE OF ct_field. FIELD-SYMBOLS <lg_src> TYPE any. ls_field-name = iv_name. CASE cl_abap_typedescr=>describe_by_data( ig_field )->kind. WHEN cl_abap_typedescr=>kind_elem. ls_field-value = ig_field. WHEN cl_abap_typedescr=>kind_struct. ASSIGN COMPONENT iv_name OF STRUCTURE ig_field TO <lg_src>. ASSERT <lg_src> IS ASSIGNED. ls_field-value = <lg_src>. WHEN OTHERS. ASSERT 0 = 1. ENDCASE. APPEND ls_field TO ct_field. ENDMETHOD. METHOD dbkey_decode. DATA: lt_fields TYPE tihttpnvp. lt_fields = parse_fields_upper_case_name( cl_http_utility=>unescape_url( |{ iv_string }| ) ). get_field( EXPORTING iv_name = 'TYPE' it_field = lt_fields CHANGING cg_field = rs_key-type ). get_field( EXPORTING iv_name = 'VALUE' it_field = lt_fields CHANGING cg_field = rs_key-value ). ENDMETHOD. METHOD dbkey_encode. DATA: lt_fields TYPE tihttpnvp. add_field( EXPORTING iv_name = 'TYPE' ig_field = is_key-type CHANGING ct_field = lt_fields ). add_field( EXPORTING iv_name = 'VALUE' ig_field = is_key-value CHANGING ct_field = lt_fields ). rv_string = cl_http_utility=>if_http_utility~fields_to_string( lt_fields ). ENDMETHOD. METHOD dir_decode. DATA: lt_fields TYPE tihttpnvp. lt_fields = parse_fields( iv_string ). get_field( EXPORTING iv_name = 'PATH' it_field = lt_fields CHANGING cg_field = rv_path ). ENDMETHOD. METHOD dir_encode. DATA: lt_fields TYPE tihttpnvp. add_field( EXPORTING iv_name = 'PATH' ig_field = iv_path CHANGING ct_field = lt_fields ). rv_string = cl_http_utility=>if_http_utility~fields_to_string( lt_fields ). ENDMETHOD. METHOD field_keys_to_upper. FIELD-SYMBOLS <ls_field> LIKE LINE OF ct_fields. LOOP AT ct_fields ASSIGNING <ls_field>. <ls_field>-name = to_upper( <ls_field>-name ). ENDLOOP. ENDMETHOD. METHOD file_encode. DATA: lt_fields TYPE tihttpnvp. add_field( EXPORTING iv_name = 'KEY' ig_field = iv_key CHANGING ct_field = lt_fields ). add_field( EXPORTING iv_name = 'PATH' ig_field = ig_file CHANGING ct_field = lt_fields ). add_field( EXPORTING iv_name = 'FILENAME' ig_field = ig_file CHANGING ct_field = lt_fields ). rv_string = cl_http_utility=>if_http_utility~fields_to_string( lt_fields ). ENDMETHOD. METHOD file_obj_decode. DATA: lt_fields TYPE tihttpnvp. ASSERT eg_file IS SUPPLIED OR eg_object IS SUPPLIED OR ev_key IS SUPPLIED. CLEAR: ev_key, eg_file, eg_object. lt_fields = parse_fields_upper_case_name( iv_string ). get_field( EXPORTING iv_name = 'KEY' it_field = lt_fields CHANGING cg_field = ev_key ). IF eg_file IS SUPPLIED. get_field( EXPORTING iv_name = 'PATH' it_field = lt_fields CHANGING cg_field = eg_file ). get_field( EXPORTING iv_name = 'FILENAME' it_field = lt_fields CHANGING cg_field = eg_file ). ENDIF. IF eg_object IS SUPPLIED. get_field( EXPORTING iv_name = 'OBJ_TYPE' it_field = lt_fields CHANGING cg_field = eg_object ). get_field( EXPORTING iv_name = 'OBJ_NAME' it_field = lt_fields CHANGING cg_field = eg_object ). ENDIF. ENDMETHOD. METHOD get_field. FIELD-SYMBOLS: <ls_field> LIKE LINE OF it_field, <lg_dest> TYPE any. READ TABLE it_field ASSIGNING <ls_field> WITH KEY name = iv_name. IF sy-subrc IS NOT INITIAL. RETURN. ENDIF. CASE cl_abap_typedescr=>describe_by_data( cg_field )->kind. WHEN cl_abap_typedescr=>kind_elem. cg_field = <ls_field>-value. WHEN cl_abap_typedescr=>kind_struct. ASSIGN COMPONENT iv_name OF STRUCTURE cg_field TO <lg_dest>. ASSERT <lg_dest> IS ASSIGNED. <lg_dest> = <ls_field>-value. WHEN OTHERS. ASSERT 0 = 1. ENDCASE. ENDMETHOD. METHOD jump_decode. DATA: lt_fields TYPE tihttpnvp. lt_fields = parse_fields( iv_string ). get_field( EXPORTING iv_name = 'TYPE' it_field = lt_fields CHANGING cg_field = ev_obj_type ). get_field( EXPORTING iv_name = 'NAME' it_field = lt_fields CHANGING cg_field = ev_obj_name ). ENDMETHOD. METHOD jump_encode. DATA: lt_fields TYPE tihttpnvp. add_field( EXPORTING iv_name = 'TYPE' ig_field = iv_obj_type CHANGING ct_field = lt_fields ). add_field( EXPORTING iv_name = 'NAME' ig_field = iv_obj_name CHANGING ct_field = lt_fields ). rv_string = cl_http_utility=>if_http_utility~fields_to_string( lt_fields ). ENDMETHOD. METHOD obj_encode. DATA: lt_fields TYPE tihttpnvp. add_field( EXPORTING iv_name = 'KEY' ig_field = iv_key CHANGING ct_field = lt_fields ). add_field( EXPORTING iv_name = 'OBJ_TYPE' ig_field = ig_object CHANGING ct_field = lt_fields ). add_field( EXPORTING iv_name = 'OBJ_NAME' ig_field = ig_object CHANGING ct_field = lt_fields ). rv_string = cl_http_utility=>if_http_utility~fields_to_string( lt_fields ). ENDMETHOD. METHOD parse_fields. DATA: lt_substrings TYPE stringtab, ls_field LIKE LINE OF rt_fields. FIELD-SYMBOLS: <lv_substring> LIKE LINE OF lt_substrings. SPLIT iv_string AT '&' INTO TABLE lt_substrings. LOOP AT lt_substrings ASSIGNING <lv_substring>. CLEAR: ls_field. ls_field-name = substring_before( val = <lv_substring> sub = '=' ). ls_field-name = unescape( ls_field-name ). ls_field-value = substring_after( val = <lv_substring> sub = '=' ). ls_field-value = unescape( ls_field-value ). INSERT ls_field INTO TABLE rt_fields. ENDLOOP. ENDMETHOD. METHOD parse_fields_upper_case_name. rt_fields = parse_fields( iv_string ). field_keys_to_upper( CHANGING ct_fields = rt_fields ). ENDMETHOD. METHOD stage_decode. DATA: lt_fields TYPE tihttpnvp. lt_fields = parse_fields_upper_case_name( iv_getdata ). get_field( EXPORTING iv_name = 'KEY' it_field = lt_fields CHANGING cg_field = ev_key ). get_field( EXPORTING iv_name = 'SEED' it_field = lt_fields CHANGING cg_field = ev_seed ). ASSERT NOT ev_key IS INITIAL. ENDMETHOD. METHOD unescape. * do not use cl_http_utility as it does strange things with the encoding rv_string = iv_string. * todo, more to be added here REPLACE ALL OCCURRENCES OF '%3F' IN rv_string WITH '?'. ENDMETHOD. ENDCLASS.
fix regression
Patch: fix regression
ABAP
mit
EduardoCopat/abapGit,larshp/abapGit,sbcgua/abapGit,larshp/abapGit,sbcgua/abapGit,EduardoCopat/abapGit
16d69e8ab993fd7b1903cf9f0732af964c1306f5
src/objects/zcl_abapgit_object_docv.clas.abap
src/objects/zcl_abapgit_object_docv.clas.abap
CLASS zcl_abapgit_object_docv DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super FINAL. PUBLIC SECTION. INTERFACES zif_abapgit_object. PROTECTED SECTION. PRIVATE SECTION. CONSTANTS: c_typ TYPE dokhl-typ VALUE 'E', c_version TYPE dokhl-dokversion VALUE '0001', c_name TYPE string VALUE 'DOC'. TYPES: BEGIN OF ty_data, doctitle TYPE dsyst-doktitle, head TYPE thead, lines TYPE tline_tab, END OF ty_data. METHODS: read RETURNING VALUE(rs_data) TYPE ty_data. ENDCLASS. CLASS zcl_abapgit_object_docv IMPLEMENTATION. METHOD read. DATA: lv_object TYPE dokhl-object, lv_id TYPE dokhl-id. lv_id = ms_item-obj_name(2). lv_object = ms_item-obj_name+2. CALL FUNCTION 'DOCU_READ' EXPORTING id = lv_id langu = mv_language object = lv_object typ = c_typ version = c_version IMPORTING doktitle = rs_data-doctitle head = rs_data-head TABLES line = rs_data-lines. ENDMETHOD. METHOD zif_abapgit_object~changed_by. rv_user = read( )-head-tdluser. IF rv_user IS INITIAL. rv_user = c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~delete. DATA: lv_id TYPE dokhl-id, lv_object TYPE dokhl-object. lv_id = ms_item-obj_name(2). lv_object = ms_item-obj_name+2. CALL FUNCTION 'DOCU_DEL' EXPORTING id = lv_id langu = mv_language object = lv_object typ = c_typ EXCEPTIONS ret_code = 1 OTHERS = 2. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDMETHOD. METHOD zif_abapgit_object~deserialize. DATA: ls_data TYPE ty_data. io_xml->read( EXPORTING iv_name = c_name CHANGING cg_data = ls_data ). CALL FUNCTION 'DOCU_UPDATE' EXPORTING head = ls_data-head state = 'A' typ = c_typ version = c_version TABLES line = ls_data-lines. ENDMETHOD. METHOD zif_abapgit_object~exists. DATA: lv_id TYPE dokhl-id, lv_object TYPE dokhl-object. lv_id = ms_item-obj_name(2). lv_object = ms_item-obj_name+2. SELECT SINGLE id FROM dokil INTO lv_id WHERE id = lv_id AND object = lv_object. "#EC CI_GENBUFF rv_bool = boolc( sy-subrc = 0 ). 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. rs_metadata = get_metadata( ). rs_metadata-delete_tadir = abap_true. ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. rv_is_locked = abap_false. ENDMETHOD. METHOD zif_abapgit_object~jump. ENDMETHOD. METHOD zif_abapgit_object~serialize. DATA: ls_data TYPE ty_data. ls_data = read( ). CLEAR: ls_data-head-tdfuser, ls_data-head-tdfreles, ls_data-head-tdfdate, ls_data-head-tdftime, ls_data-head-tdluser, ls_data-head-tdlreles, ls_data-head-tdldate, ls_data-head-tdltime. io_xml->add( iv_name = c_name ig_data = ls_data ). ENDMETHOD. ENDCLASS.
CLASS zcl_abapgit_object_docv DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super FINAL CREATE PUBLIC. PUBLIC SECTION. INTERFACES zif_abapgit_object. METHODS constructor IMPORTING !is_item TYPE zif_abapgit_definitions=>ty_item !iv_language TYPE spras. PROTECTED SECTION. PRIVATE SECTION. TYPES: BEGIN OF ty_data, doctitle TYPE dsyst-doktitle, head TYPE thead, lines TYPE tline_tab, END OF ty_data. CONSTANTS c_typ TYPE dokhl-typ VALUE 'E' ##NO_TEXT. CONSTANTS c_version TYPE dokhl-dokversion VALUE '0001' ##NO_TEXT. CONSTANTS c_name TYPE string VALUE 'DOC' ##NO_TEXT. DATA mv_id TYPE dokhl-id. DATA mv_doc_object TYPE dokhl-object. METHODS read RETURNING VALUE(rs_data) TYPE ty_data. ENDCLASS. CLASS zcl_abapgit_object_docv IMPLEMENTATION. METHOD constructor. DATA: lv_prefix TYPE namespace, lv_bare_name TYPE progname. super->constructor( is_item = is_item iv_language = iv_language ). CALL FUNCTION 'RS_NAME_SPLIT_NAMESPACE' EXPORTING name_with_namespace = ms_item-obj_name IMPORTING namespace = lv_prefix name_without_namespace = lv_bare_name. mv_id = lv_bare_name(2). mv_doc_object = |{ lv_prefix }{ lv_bare_name+2(*) }|. ENDMETHOD. METHOD read. CALL FUNCTION 'DOCU_READ' EXPORTING id = mv_id langu = mv_language object = mv_doc_object typ = c_typ version = c_version IMPORTING doktitle = rs_data-doctitle head = rs_data-head TABLES line = rs_data-lines. ENDMETHOD. METHOD zif_abapgit_object~changed_by. rv_user = read( )-head-tdluser. IF rv_user IS INITIAL. rv_user = c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~delete. CALL FUNCTION 'DOCU_DEL' EXPORTING id = mv_id langu = mv_language object = mv_doc_object typ = c_typ EXCEPTIONS ret_code = 1 OTHERS = 2. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDMETHOD. METHOD zif_abapgit_object~deserialize. DATA: ls_data TYPE ty_data. io_xml->read( EXPORTING iv_name = c_name CHANGING cg_data = ls_data ). CALL FUNCTION 'DOCU_UPDATE' EXPORTING head = ls_data-head state = 'A' typ = c_typ version = c_version TABLES line = ls_data-lines. ENDMETHOD. METHOD zif_abapgit_object~exists. SELECT SINGLE id FROM dokil INTO mv_id WHERE id = mv_id AND object = mv_doc_object. "#EC CI_GENBUFF rv_bool = boolc( sy-subrc = 0 ). 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. rs_metadata = get_metadata( ). rs_metadata-delete_tadir = abap_true. ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. rv_is_locked = abap_false. ENDMETHOD. METHOD zif_abapgit_object~jump. ENDMETHOD. METHOD zif_abapgit_object~serialize. DATA: ls_data TYPE ty_data. ls_data = read( ). CLEAR: ls_data-head-tdfuser, ls_data-head-tdfreles, ls_data-head-tdfdate, ls_data-head-tdftime, ls_data-head-tdluser, ls_data-head-tdlreles, ls_data-head-tdldate, ls_data-head-tdltime. io_xml->add( iv_name = c_name ig_data = ls_data ). ENDMETHOD. ENDCLASS.
Handle namespaces (#5756)
DOCV: Handle namespaces (#5756)
ABAP
mit
sbcgua/abapGit,sbcgua/abapGit
a96fed4b26ca3ed833b4c781039b7b5efa55727e
src/objects/zcl_abapgit_object_enhc.clas.abap
src/objects/zcl_abapgit_object_enhc.clas.abap
CLASS zcl_abapgit_object_enhc DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super. 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. DATA: mv_composite_id TYPE enhcompositename. ENDCLASS. CLASS zcl_abapgit_object_enhc IMPLEMENTATION. METHOD constructor. super->constructor( is_item = is_item iv_language = iv_language ). mv_composite_id = ms_item-obj_name. ENDMETHOD. METHOD zif_abapgit_object~changed_by. SELECT SINGLE changedby INTO rv_user FROM enhcompheader WHERE enhcomposite = ms_item-obj_name AND version = 'A'. IF sy-subrc <> 0. rv_user = c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~delete. DATA: lx_enh_root TYPE REF TO cx_enh_root, li_enh_object TYPE REF TO if_enh_object. TRY. li_enh_object = cl_enh_factory=>load_enhancement_composite( name = mv_composite_id lock = abap_true ). li_enh_object->delete( nevertheless_delete = abap_true run_dark = abap_true ). li_enh_object->unlock( ). CATCH cx_enh_root INTO lx_enh_root. zcx_abapgit_exception=>raise_with_text( lx_enh_root ). ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~deserialize. DATA: lx_enh_root TYPE REF TO cx_enh_root, li_enh_composite TYPE REF TO if_enh_composite, lv_package TYPE devclass, lt_composite_childs TYPE enhcompositename_it, lt_enh_childs TYPE enhname_it, lv_longtext_id TYPE enhdocuobject, lv_vers TYPE enhcompheader-version, lv_shorttext TYPE string. FIELD-SYMBOLS: <lv_composite_child> TYPE enhcompositename, <lv_enh_child> LIKE LINE OF lt_enh_childs. lv_package = iv_package. io_xml->read( EXPORTING iv_name = 'SHORTTEXT' CHANGING cg_data = lv_shorttext ). io_xml->read( EXPORTING iv_name = 'COMPOSITE_CHILDS' CHANGING cg_data = lt_composite_childs ). io_xml->read( EXPORTING iv_name = 'ENH_CHILDS' CHANGING cg_data = lt_enh_childs ). io_xml->read( EXPORTING iv_name = 'LONGTEXT_ID' CHANGING cg_data = lv_longtext_id ). SELECT SINGLE version FROM enhcompheader INTO lv_vers WHERE enhcomposite = ms_item-obj_name. IF sy-subrc = 0. " If object exists already, then set TADIR entry to deleted " otherwise create_enhancement_composite will fail CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_test_modus = abap_false wi_tadir_pgmid = 'R3TR' wi_tadir_object = ms_item-obj_type wi_tadir_obj_name = ms_item-obj_name iv_delflag = abap_true EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDIF. TRY. cl_enh_factory=>create_enhancement_composite( EXPORTING name = mv_composite_id run_dark = abap_true IMPORTING composite = li_enh_composite CHANGING devclass = lv_package ). li_enh_composite->if_enh_object_docu~set_shorttext( lv_shorttext ). LOOP AT lt_composite_childs ASSIGNING <lv_composite_child>. li_enh_composite->add_composite_child( <lv_composite_child> ). ENDLOOP. LOOP AT lt_enh_childs ASSIGNING <lv_enh_child>. li_enh_composite->add_enh_child( <lv_enh_child> ). ENDLOOP. li_enh_composite->set_longtext_id( lv_longtext_id ). li_enh_composite->if_enh_object~save( ). li_enh_composite->if_enh_object~activate( ). li_enh_composite->if_enh_object~unlock( ). zcl_abapgit_sotr_handler=>create_sotr( iv_package = iv_package io_xml = io_xml ). CATCH cx_enh_root INTO lx_enh_root. zcx_abapgit_exception=>raise_with_text( lx_enh_root ). ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~exists. TRY. cl_enh_factory=>load_enhancement_composite( name = mv_composite_id lock = abap_false ). rv_bool = abap_true. CATCH cx_enh_root. rv_bool = abap_false. ENDTRY. 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. rs_metadata = get_metadata( ). ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. DATA: lv_argument TYPE seqg3-garg. lv_argument = |{ mv_composite_id }|. OVERLAY lv_argument WITH ' '. lv_argument = |{ lv_argument }*|. rv_is_locked = exists_a_lock_entry_for( iv_lock_object = |E_ENHANCE| iv_argument = lv_argument ). ENDMETHOD. METHOD zif_abapgit_object~jump. " Covered by ZCL_ABAPGIT_OBJECTS=>JUMP ENDMETHOD. METHOD zif_abapgit_object~serialize. DATA: lx_enh_root TYPE REF TO cx_enh_root, li_enh_composite TYPE REF TO if_enh_composite, lt_composite_childs TYPE enhcompositename_it, lt_enh_childs TYPE enhname_it, lv_longtext_id TYPE enhdocuobject, lv_shorttext TYPE string. TRY. li_enh_composite = cl_enh_factory=>load_enhancement_composite( name = mv_composite_id lock = abap_false ). lv_shorttext = li_enh_composite->if_enh_object_docu~get_shorttext( ). lt_composite_childs = li_enh_composite->get_composite_childs( ). lt_enh_childs = li_enh_composite->get_enh_childs( ). lv_longtext_id = li_enh_composite->get_longtext_id( ). io_xml->add( iv_name = 'SHORTTEXT' ig_data = lv_shorttext ). io_xml->add( iv_name = 'COMPOSITE_CHILDS' ig_data = lt_composite_childs ). io_xml->add( iv_name = 'ENH_CHILDS' ig_data = lt_enh_childs ). io_xml->add( iv_name = 'LONGTEXT_ID' ig_data = lv_longtext_id ). zcl_abapgit_sotr_handler=>read_sotr( iv_pgmid = 'R3TR' iv_object = ms_item-obj_type iv_obj_name = ms_item-obj_name io_xml = io_xml ). CATCH cx_enh_root INTO lx_enh_root. zcx_abapgit_exception=>raise_with_text( lx_enh_root ). ENDTRY. ENDMETHOD. ENDCLASS.
CLASS zcl_abapgit_object_enhc DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super. 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. DATA: mv_composite_id TYPE enhcompositename. ENDCLASS. CLASS zcl_abapgit_object_enhc IMPLEMENTATION. METHOD constructor. super->constructor( is_item = is_item iv_language = iv_language ). mv_composite_id = ms_item-obj_name. ENDMETHOD. METHOD zif_abapgit_object~changed_by. SELECT SINGLE changedby INTO rv_user FROM enhcompheader WHERE enhcomposite = ms_item-obj_name AND version = 'A'. IF sy-subrc <> 0. rv_user = c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~delete. DATA: lx_enh_root TYPE REF TO cx_enh_root, li_enh_object TYPE REF TO if_enh_object. TRY. li_enh_object = cl_enh_factory=>load_enhancement_composite( name = mv_composite_id lock = abap_true ). li_enh_object->delete( nevertheless_delete = abap_true run_dark = abap_true ). li_enh_object->unlock( ). CATCH cx_enh_root INTO lx_enh_root. zcx_abapgit_exception=>raise_with_text( lx_enh_root ). ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~deserialize. DATA: lx_enh_root TYPE REF TO cx_enh_root, li_enh_composite TYPE REF TO if_enh_composite, lv_package TYPE devclass, lt_composite_childs TYPE enhcompositename_it, lt_enh_childs TYPE enhname_it, lv_longtext_id TYPE enhdocuobject, lv_vers TYPE enhcompheader-version, lv_shorttext TYPE string. FIELD-SYMBOLS: <lv_composite_child> TYPE enhcompositename, <lv_enh_child> LIKE LINE OF lt_enh_childs. lv_package = iv_package. io_xml->read( EXPORTING iv_name = 'SHORTTEXT' CHANGING cg_data = lv_shorttext ). io_xml->read( EXPORTING iv_name = 'COMPOSITE_CHILDS' CHANGING cg_data = lt_composite_childs ). io_xml->read( EXPORTING iv_name = 'ENH_CHILDS' CHANGING cg_data = lt_enh_childs ). io_xml->read( EXPORTING iv_name = 'LONGTEXT_ID' CHANGING cg_data = lv_longtext_id ). SELECT SINGLE version FROM enhcompheader INTO lv_vers WHERE enhcomposite = ms_item-obj_name. IF sy-subrc = 0. " If object exists already, then set TADIR entry to deleted " otherwise create_enhancement_composite will fail CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_test_modus = abap_false wi_tadir_pgmid = 'R3TR' wi_tadir_object = ms_item-obj_type wi_tadir_obj_name = ms_item-obj_name iv_delflag = abap_true EXCEPTIONS OTHERS = 1. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ENDIF. TRY. cl_enh_factory=>create_enhancement_composite( EXPORTING name = mv_composite_id run_dark = abap_true IMPORTING composite = li_enh_composite CHANGING devclass = lv_package ). li_enh_composite->if_enh_object_docu~set_shorttext( lv_shorttext ). LOOP AT lt_composite_childs ASSIGNING <lv_composite_child>. li_enh_composite->add_composite_child( <lv_composite_child> ). ENDLOOP. LOOP AT lt_enh_childs ASSIGNING <lv_enh_child>. li_enh_composite->add_enh_child( <lv_enh_child> ). ENDLOOP. li_enh_composite->set_longtext_id( lv_longtext_id ). li_enh_composite->if_enh_object~save( ). li_enh_composite->if_enh_object~activate( ). li_enh_composite->if_enh_object~unlock( ). CATCH cx_enh_root INTO lx_enh_root. zcx_abapgit_exception=>raise_with_text( lx_enh_root ). ENDTRY. ENDMETHOD. METHOD zif_abapgit_object~exists. TRY. cl_enh_factory=>load_enhancement_composite( name = mv_composite_id lock = abap_false ). rv_bool = abap_true. CATCH cx_enh_root. rv_bool = abap_false. ENDTRY. 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. rs_metadata = get_metadata( ). ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. DATA: lv_argument TYPE seqg3-garg. lv_argument = |{ mv_composite_id }|. OVERLAY lv_argument WITH ' '. lv_argument = |{ lv_argument }*|. rv_is_locked = exists_a_lock_entry_for( iv_lock_object = |E_ENHANCE| iv_argument = lv_argument ). ENDMETHOD. METHOD zif_abapgit_object~jump. " Covered by ZCL_ABAPGIT_OBJECTS=>JUMP ENDMETHOD. METHOD zif_abapgit_object~serialize. DATA: lx_enh_root TYPE REF TO cx_enh_root, li_enh_composite TYPE REF TO if_enh_composite, lt_composite_childs TYPE enhcompositename_it, lt_enh_childs TYPE enhname_it, lv_longtext_id TYPE enhdocuobject, lv_shorttext TYPE string. TRY. li_enh_composite = cl_enh_factory=>load_enhancement_composite( name = mv_composite_id lock = abap_false ). lv_shorttext = li_enh_composite->if_enh_object_docu~get_shorttext( ). lt_composite_childs = li_enh_composite->get_composite_childs( ). lt_enh_childs = li_enh_composite->get_enh_childs( ). lv_longtext_id = li_enh_composite->get_longtext_id( ). io_xml->add( iv_name = 'SHORTTEXT' ig_data = lv_shorttext ). io_xml->add( iv_name = 'COMPOSITE_CHILDS' ig_data = lt_composite_childs ). io_xml->add( iv_name = 'ENH_CHILDS' ig_data = lt_enh_childs ). io_xml->add( iv_name = 'LONGTEXT_ID' ig_data = lv_longtext_id ). CATCH cx_enh_root INTO lx_enh_root. zcx_abapgit_exception=>raise_with_text( lx_enh_root ). ENDTRY. ENDMETHOD. ENDCLASS.
Fix diffs due to OTR (#5538)
ENHC: Fix diffs due to OTR (#5538) `cl_enh_composite` already handles OTR shorttext and there's no need to use `zcl_abapgit_sotr_handler`. Update test case: https://github.com/abapGit-tests/ENHC Co-authored-by: Lars Hvam <721d1b171982cd84b755f6b25130d2b88cd1f696@hotmail.com>
ABAP
mit
larshp/abapGit,sbcgua/abapGit,larshp/abapGit,sbcgua/abapGit
11a175d467ec374bf8b515001845eddc75c3df51
src/zcl_abapgit_stage_logic.clas.abap
src/zcl_abapgit_stage_logic.clas.abap
CLASS zcl_abapgit_stage_logic DEFINITION PUBLIC CREATE PRIVATE GLOBAL FRIENDS zcl_abapgit_factory . PUBLIC SECTION. INTERFACES zif_abapgit_stage_logic . PRIVATE SECTION. CLASS-METHODS: remove_ignored IMPORTING io_repo TYPE REF TO zcl_abapgit_repo_online CHANGING cs_files TYPE zif_abapgit_definitions=>ty_stage_files, remove_identical CHANGING cs_files TYPE zif_abapgit_definitions=>ty_stage_files. ENDCLASS. CLASS ZCL_ABAPGIT_STAGE_LOGIC IMPLEMENTATION. METHOD remove_identical. DATA: lv_index TYPE i, ls_remote LIKE LINE OF cs_files-remote. FIELD-SYMBOLS: <ls_local> LIKE LINE OF cs_files-local. SORT cs_files-remote BY path filename. LOOP AT cs_files-local ASSIGNING <ls_local>. lv_index = sy-tabix. READ TABLE cs_files-remote INTO ls_remote WITH KEY path = <ls_local>-file-path filename = <ls_local>-file-filename BINARY SEARCH. IF sy-subrc = 0. DELETE cs_files-remote INDEX sy-tabix. IF ls_remote-sha1 = <ls_local>-file-sha1. DELETE cs_files-local INDEX lv_index. ENDIF. ENDIF. ENDLOOP. ENDMETHOD. METHOD remove_ignored. DATA: lv_index TYPE i. FIELD-SYMBOLS: <ls_remote> LIKE LINE OF cs_files-remote. LOOP AT cs_files-remote ASSIGNING <ls_remote>. lv_index = sy-tabix. IF io_repo->get_dot_abapgit( )->is_ignored( iv_path = <ls_remote>-path iv_filename = <ls_remote>-filename ) = abap_true. DELETE cs_files-remote INDEX lv_index. ELSEIF <ls_remote>-path = zif_abapgit_definitions=>c_root_dir AND <ls_remote>-filename = zif_abapgit_definitions=>c_dot_abapgit. " Remove .abapgit from remotes - it cannot be removed or ignored DELETE cs_files-remote INDEX lv_index. ENDIF. ENDLOOP. ENDMETHOD. METHOD zif_abapgit_stage_logic~get. rs_files-local = io_repo->get_files_local( ). rs_files-remote = io_repo->get_files_remote( ). remove_identical( CHANGING cs_files = rs_files ). remove_ignored( EXPORTING io_repo = io_repo CHANGING cs_files = rs_files ). ENDMETHOD. ENDCLASS.
CLASS zcl_abapgit_stage_logic DEFINITION PUBLIC CREATE PRIVATE GLOBAL FRIENDS zcl_abapgit_factory . PUBLIC SECTION. INTERFACES zif_abapgit_stage_logic . PRIVATE SECTION. CLASS-METHODS: remove_ignored IMPORTING io_repo TYPE REF TO zcl_abapgit_repo_online CHANGING cs_files TYPE zif_abapgit_definitions=>ty_stage_files, remove_identical CHANGING cs_files TYPE zif_abapgit_definitions=>ty_stage_files. ENDCLASS. CLASS ZCL_ABAPGIT_STAGE_LOGIC IMPLEMENTATION. METHOD remove_identical. DATA: lv_index TYPE i, ls_remote LIKE LINE OF cs_files-remote. FIELD-SYMBOLS: <ls_local> LIKE LINE OF cs_files-local. SORT cs_files-remote BY path filename. LOOP AT cs_files-local ASSIGNING <ls_local>. lv_index = sy-tabix. READ TABLE cs_files-remote INTO ls_remote WITH KEY path = <ls_local>-file-path filename = <ls_local>-file-filename BINARY SEARCH. IF sy-subrc = 0. DELETE cs_files-remote INDEX sy-tabix. IF ls_remote-sha1 = <ls_local>-file-sha1. DELETE cs_files-local INDEX lv_index. ENDIF. ENDIF. ENDLOOP. ENDMETHOD. METHOD remove_ignored. DATA: lv_index TYPE i. FIELD-SYMBOLS: <ls_remote> LIKE LINE OF cs_files-remote, <ls_local> LIKE LINE OF cs_files-local. LOOP AT cs_files-remote ASSIGNING <ls_remote>. lv_index = sy-tabix. IF io_repo->get_dot_abapgit( )->is_ignored( iv_path = <ls_remote>-path iv_filename = <ls_remote>-filename ) = abap_true. DELETE cs_files-remote INDEX lv_index. ELSEIF <ls_remote>-path = zif_abapgit_definitions=>c_root_dir AND <ls_remote>-filename = zif_abapgit_definitions=>c_dot_abapgit. " Remove .abapgit from remotes - it cannot be removed or ignored DELETE cs_files-remote INDEX lv_index. ENDIF. ENDLOOP. LOOP AT cs_files-local ASSIGNING <ls_local>. lv_index = sy-tabix. IF io_repo->get_dot_abapgit( )->is_ignored( iv_path = <ls_local>-file-path iv_filename = <ls_local>-file-filename ) = abap_true. DELETE cs_files-local INDEX lv_index. ENDIF. ENDLOOP. ENDMETHOD. METHOD zif_abapgit_stage_logic~get. rs_files-local = io_repo->get_files_local( ). rs_files-remote = io_repo->get_files_remote( ). remove_identical( CHANGING cs_files = rs_files ). remove_ignored( EXPORTING io_repo = io_repo CHANGING cs_files = rs_files ). ENDMETHOD. ENDCLASS.
remove also ignored local files
stage: remove also ignored local files Ignored files posses the property that they do not exist in remotes but do exist in local repositories. Before this patch, local ignored files were displayed in the Stage.
ABAP
mit
EduardoCopat/abapGit,sbcgua/abapGit,larshp/abapGit,EduardoCopat/abapGit,larshp/abapGit,sbcgua/abapGit
068cf963d9b5ab66d05dc7f4b0e029867beffd57
src/objects/zcl_abapgit_object_enho.clas.abap
src/objects/zcl_abapgit_object_enho.clas.abap
CLASS zcl_abapgit_object_enho DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super FINAL. PUBLIC SECTION. INTERFACES zif_abapgit_object. ALIASES mo_files FOR zif_abapgit_object~mo_files. PRIVATE SECTION. METHODS: factory IMPORTING iv_tool TYPE enhtooltype RETURNING VALUE(ri_enho) TYPE REF TO zif_abapgit_object_enho RAISING zcx_abapgit_exception. ENDCLASS. CLASS zcl_abapgit_object_enho IMPLEMENTATION. METHOD zif_abapgit_object~has_changed_since. rv_changed = abap_true. ENDMETHOD. "zif_abapgit_object~has_changed_since METHOD zif_abapgit_object~get_metadata. rs_metadata = get_metadata( ). ENDMETHOD. "zif_abapgit_object~get_metadata METHOD zif_abapgit_object~changed_by. rv_user = c_user_unknown. " todo ENDMETHOD. "zif_abapgit_object~changed_by METHOD zif_abapgit_object~exists. DATA: lv_enh_id TYPE enhname. lv_enh_id = ms_item-obj_name. TRY. cl_enh_factory=>get_enhancement( enhancement_id = lv_enh_id bypassing_buffer = abap_true ). rv_bool = abap_true. CATCH cx_enh_root. rv_bool = abap_false. ENDTRY. ENDMETHOD. "zif_abapgit_object~exists METHOD zif_abapgit_object~serialize. DATA: lv_enh_id TYPE enhname, li_enho TYPE REF TO zif_abapgit_object_enho, li_enh_tool TYPE REF TO if_enh_tool. IF zif_abapgit_object~exists( ) = abap_false. RETURN. ENDIF. lv_enh_id = ms_item-obj_name. TRY. li_enh_tool = cl_enh_factory=>get_enhancement( enhancement_id = lv_enh_id bypassing_buffer = abap_true ). CATCH cx_enh_root. zcx_abapgit_exception=>raise( 'Error from CL_ENH_FACTORY' ). ENDTRY. li_enho = factory( li_enh_tool->get_tool( ) ). li_enho->serialize( io_xml = io_xml ii_enh_tool = li_enh_tool ). ENDMETHOD. "serialize METHOD factory. CASE iv_tool. WHEN cl_enh_tool_badi_impl=>tooltype. CREATE OBJECT ri_enho TYPE zcl_abapgit_object_enho_badi EXPORTING is_item = ms_item io_files = mo_files. WHEN cl_enh_tool_hook_impl=>tooltype. CREATE OBJECT ri_enho TYPE zcl_abapgit_object_enho_hook EXPORTING is_item = ms_item io_files = mo_files. WHEN cl_enh_tool_class=>tooltype. CREATE OBJECT ri_enho TYPE zcl_abapgit_object_enho_class EXPORTING is_item = ms_item io_files = mo_files. WHEN cl_enh_tool_intf=>tooltype. CREATE OBJECT ri_enho TYPE zcl_abapgit_object_enho_intf EXPORTING is_item = ms_item io_files = mo_files. WHEN cl_wdr_cfg_enhancement=>tooltype. CREATE OBJECT ri_enho TYPE zcl_abapgit_object_enho_wdyc EXPORTING is_item = ms_item io_files = mo_files. WHEN 'FUGRENH'. CREATE OBJECT ri_enho TYPE zcl_abapgit_object_enho_fugr EXPORTING is_item = ms_item io_files = mo_files. WHEN 'WDYENH'. CREATE OBJECT ri_enho TYPE zcl_abapgit_object_enho_wdyn EXPORTING is_item = ms_item io_files = mo_files. WHEN OTHERS. zcx_abapgit_exception=>raise( |Unsupported ENHO type { iv_tool }| ). ENDCASE. ENDMETHOD. "factory METHOD zif_abapgit_object~deserialize. DATA: lv_tool TYPE enhtooltype, li_enho TYPE REF TO zif_abapgit_object_enho. IF zif_abapgit_object~exists( ) = abap_true. zif_abapgit_object~delete( ). ENDIF. io_xml->read( EXPORTING iv_name = 'TOOL' CHANGING cg_data = lv_tool ). li_enho = factory( lv_tool ). li_enho->deserialize( io_xml = io_xml iv_package = iv_package ). zcl_abapgit_objects_activation=>add_item( ms_item ). ENDMETHOD. "deserialize METHOD zif_abapgit_object~delete. DATA: lv_enh_id TYPE enhname, li_enh_object TYPE REF TO if_enh_object. lv_enh_id = ms_item-obj_name. TRY. li_enh_object = cl_enh_factory=>get_enhancement( enhancement_id = lv_enh_id lock = abap_true ). li_enh_object->delete( ). li_enh_object->save( ). li_enh_object->unlock( ). CATCH cx_enh_root. zcx_abapgit_exception=>raise( 'Error deleting ENHO' ). ENDTRY. ENDMETHOD. "delete METHOD zif_abapgit_object~jump. CALL FUNCTION 'RS_TOOL_ACCESS' EXPORTING operation = 'SHOW' object_name = ms_item-obj_name object_type = 'ENHO' in_new_window = abap_true. ENDMETHOD. "jump METHOD zif_abapgit_object~compare_to_remote_version. CREATE OBJECT ro_comparison_result TYPE zcl_abapgit_comparison_null. ENDMETHOD. "zif_abapgit_object~compare_to_remote_version ENDCLASS. "zcl_abapgit_object_enho IMPLEMENTATION
CLASS zcl_abapgit_object_enho DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super FINAL. PUBLIC SECTION. INTERFACES zif_abapgit_object. ALIASES mo_files FOR zif_abapgit_object~mo_files. PRIVATE SECTION. METHODS: factory IMPORTING iv_tool TYPE enhtooltype RETURNING VALUE(ri_enho) TYPE REF TO zif_abapgit_object_enho RAISING zcx_abapgit_exception. ENDCLASS. CLASS zcl_abapgit_object_enho IMPLEMENTATION. METHOD zif_abapgit_object~has_changed_since. rv_changed = abap_true. ENDMETHOD. "zif_abapgit_object~has_changed_since METHOD zif_abapgit_object~get_metadata. rs_metadata = get_metadata( ). ENDMETHOD. "zif_abapgit_object~get_metadata METHOD zif_abapgit_object~changed_by. DATA: lv_enh_id TYPE enhname, li_enho TYPE REF TO zif_abapgit_object_enho, lt_log TYPE enh_log_it, li_log_obj TYPE REF TO if_enh_log, ls_enhlog TYPE enhlog, lv_lines TYPE i, lt_enhlog TYPE STANDARD TABLE OF enhlog WITH DEFAULT KEY, li_enh_tool TYPE REF TO if_enh_tool. lv_enh_id = ms_item-obj_name. TRY. li_enh_tool = cl_enh_factory=>get_enhancement( enhancement_id = lv_enh_id bypassing_buffer = abap_true ). CATCH cx_enh_root. rv_user = c_user_unknown. RETURN. ENDTRY. lt_log = li_enh_tool->get_log( ). LOOP AT lt_log INTO li_log_obj. ls_enhlog = li_log_obj->get_enhlog( ). APPEND ls_enhlog TO lt_enhlog. ENDLOOP. lv_lines = lines( lt_enhlog ). READ TABLE lt_enhlog INTO ls_enhlog INDEX lv_lines. IF sy-subrc = 0. rv_user = ls_enhlog-loguser. ELSE. rv_user = c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~exists. DATA: lv_enh_id TYPE enhname. lv_enh_id = ms_item-obj_name. TRY. cl_enh_factory=>get_enhancement( enhancement_id = lv_enh_id bypassing_buffer = abap_true ). rv_bool = abap_true. CATCH cx_enh_root. rv_bool = abap_false. ENDTRY. ENDMETHOD. "zif_abapgit_object~exists METHOD zif_abapgit_object~serialize. DATA: lv_enh_id TYPE enhname, li_enho TYPE REF TO zif_abapgit_object_enho, li_enh_tool TYPE REF TO if_enh_tool. IF zif_abapgit_object~exists( ) = abap_false. RETURN. ENDIF. lv_enh_id = ms_item-obj_name. TRY. li_enh_tool = cl_enh_factory=>get_enhancement( enhancement_id = lv_enh_id bypassing_buffer = abap_true ). CATCH cx_enh_root. zcx_abapgit_exception=>raise( 'Error from CL_ENH_FACTORY' ). ENDTRY. li_enho = factory( li_enh_tool->get_tool( ) ). li_enho->serialize( io_xml = io_xml ii_enh_tool = li_enh_tool ). ENDMETHOD. "serialize METHOD factory. CASE iv_tool. WHEN cl_enh_tool_badi_impl=>tooltype. CREATE OBJECT ri_enho TYPE zcl_abapgit_object_enho_badi EXPORTING is_item = ms_item io_files = mo_files. WHEN cl_enh_tool_hook_impl=>tooltype. CREATE OBJECT ri_enho TYPE zcl_abapgit_object_enho_hook EXPORTING is_item = ms_item io_files = mo_files. WHEN cl_enh_tool_class=>tooltype. CREATE OBJECT ri_enho TYPE zcl_abapgit_object_enho_class EXPORTING is_item = ms_item io_files = mo_files. WHEN cl_enh_tool_intf=>tooltype. CREATE OBJECT ri_enho TYPE zcl_abapgit_object_enho_intf EXPORTING is_item = ms_item io_files = mo_files. WHEN cl_wdr_cfg_enhancement=>tooltype. CREATE OBJECT ri_enho TYPE zcl_abapgit_object_enho_wdyc EXPORTING is_item = ms_item io_files = mo_files. WHEN 'FUGRENH'. CREATE OBJECT ri_enho TYPE zcl_abapgit_object_enho_fugr EXPORTING is_item = ms_item io_files = mo_files. WHEN 'WDYENH'. CREATE OBJECT ri_enho TYPE zcl_abapgit_object_enho_wdyn EXPORTING is_item = ms_item io_files = mo_files. WHEN OTHERS. zcx_abapgit_exception=>raise( |Unsupported ENHO type { iv_tool }| ). ENDCASE. ENDMETHOD. "factory METHOD zif_abapgit_object~deserialize. DATA: lv_tool TYPE enhtooltype, li_enho TYPE REF TO zif_abapgit_object_enho. IF zif_abapgit_object~exists( ) = abap_true. zif_abapgit_object~delete( ). ENDIF. io_xml->read( EXPORTING iv_name = 'TOOL' CHANGING cg_data = lv_tool ). li_enho = factory( lv_tool ). li_enho->deserialize( io_xml = io_xml iv_package = iv_package ). zcl_abapgit_objects_activation=>add_item( ms_item ). ENDMETHOD. "deserialize METHOD zif_abapgit_object~delete. DATA: lv_enh_id TYPE enhname, li_enh_object TYPE REF TO if_enh_object. lv_enh_id = ms_item-obj_name. TRY. li_enh_object = cl_enh_factory=>get_enhancement( enhancement_id = lv_enh_id lock = abap_true ). li_enh_object->delete( ). li_enh_object->save( ). li_enh_object->unlock( ). CATCH cx_enh_root. zcx_abapgit_exception=>raise( 'Error deleting ENHO' ). ENDTRY. ENDMETHOD. "delete METHOD zif_abapgit_object~jump. CALL FUNCTION 'RS_TOOL_ACCESS' EXPORTING operation = 'SHOW' object_name = ms_item-obj_name object_type = 'ENHO' in_new_window = abap_true. ENDMETHOD. "jump METHOD zif_abapgit_object~compare_to_remote_version. CREATE OBJECT ro_comparison_result TYPE zcl_abapgit_comparison_null. ENDMETHOD. "zif_abapgit_object~compare_to_remote_version ENDCLASS. "zcl_abapgit_object_enho IMPLEMENTATION
implement changed_by #1417 (#1436)
ENHO: implement changed_by #1417 (#1436)
ABAP
mit
larshp/abapGit,EduardoCopat/abapGit,sbcgua/abapGit,EduardoCopat/abapGit,larshp/abapGit,sbcgua/abapGit
bd7313b4725f036ffcac177b1d43fd64d8abf82b
src/zcl_abapgit_dependencies.clas.abap
src/zcl_abapgit_dependencies.clas.abap
CLASS zcl_abapgit_dependencies DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. TYPES: BEGIN OF ty_tadir, pgmid TYPE tadir-pgmid, object TYPE tadir-object, obj_name TYPE tadir-obj_name, devclass TYPE tadir-devclass, korrnum TYPE tadir-korrnum, path TYPE string, END OF ty_tadir . TYPES: ty_tadir_tt TYPE STANDARD TABLE OF ty_tadir WITH DEFAULT KEY . CLASS-METHODS resolve CHANGING !ct_tadir TYPE ty_tadir_tt RAISING zcx_abapgit_exception . PRIVATE SECTION. TYPES: BEGIN OF ty_dependency, depname TYPE dd02l-tabname, deptyp TYPE c LENGTH 4, deplocal TYPE dd02l-as4local, refname TYPE dd02l-tabname, reftyp TYPE c LENGTH 4, kind TYPE c LENGTH 1, END OF ty_dependency . TYPES: tty_dedenpency TYPE STANDARD TABLE OF ty_dependency WITH NON-UNIQUE DEFAULT KEY . TYPES: BEGIN OF ty_item, obj_type TYPE tadir-object, obj_name TYPE tadir-obj_name, devclass TYPE devclass, END OF ty_item . CLASS-METHODS resolve_ddic CHANGING !ct_tadir TYPE ty_tadir_tt RAISING zcx_abapgit_exception . CLASS-METHODS get_ddls_dependencies IMPORTING !iv_ddls_name TYPE tadir-obj_name RETURNING VALUE(rt_dependency) TYPE tty_dedenpency . ENDCLASS. CLASS ZCL_ABAPGIT_DEPENDENCIES IMPLEMENTATION. METHOD get_ddls_dependencies. TYPES: BEGIN OF ty_ddls_name. INCLUDE TYPE ddsymtab. TYPES: END OF ty_ddls_name. TYPES: tty_ddls_names TYPE STANDARD TABLE OF ty_ddls_name WITH NON-UNIQUE DEFAULT KEY. DATA: lt_ddls_name TYPE tty_ddls_names, ls_ddls_name LIKE LINE OF lt_ddls_name. ls_ddls_name-name = iv_ddls_name. INSERT ls_ddls_name INTO TABLE lt_ddls_name. PERFORM ('DDLS_GET_DEP') IN PROGRAM ('RADMASDL') TABLES lt_ddls_name rt_dependency. ENDMETHOD. METHOD resolve. DATA: lv_tabclass TYPE dd02l-tabclass. FIELD-SYMBOLS: <ls_tadir> LIKE LINE OF ct_tadir. * misuse field KORRNUM to fix deletion sequence LOOP AT ct_tadir ASSIGNING <ls_tadir>. CASE <ls_tadir>-object. WHEN 'IATU'. <ls_tadir>-korrnum = '5500'. WHEN 'IARP'. <ls_tadir>-korrnum = '5510'. WHEN 'IASP'. <ls_tadir>-korrnum = '5520'. WHEN 'SUSC'. <ls_tadir>-korrnum = '5000'. WHEN 'TTYP' OR 'TABL' OR 'VIEW'. SELECT SINGLE tabclass FROM dd02l INTO lv_tabclass WHERE tabname = <ls_tadir>-obj_name AND as4local = 'A' AND as4vers = '0000'. IF sy-subrc = 0 AND lv_tabclass = 'APPEND'. * delete append structures before database tables <ls_tadir>-korrnum = '6500'. ELSE. <ls_tadir>-korrnum = '7000'. ENDIF. WHEN 'DTEL'. <ls_tadir>-korrnum = '8000'. WHEN 'DOMA'. <ls_tadir>-korrnum = '9000'. WHEN 'PROG'. * delete includes after main programs SELECT COUNT(*) FROM reposrc WHERE progname = <ls_tadir>-obj_name AND r3state = 'A' AND subc = 'I'. IF sy-subrc = 0. <ls_tadir>-korrnum = '2000'. ELSE. <ls_tadir>-korrnum = '1000'. ENDIF. WHEN 'IDOC'. <ls_tadir>-korrnum = '2000'. WHEN 'IEXT'. <ls_tadir>-korrnum = '1500'. WHEN OTHERS. <ls_tadir>-korrnum = '1000'. ENDCASE. ENDLOOP. resolve_ddic( CHANGING ct_tadir = ct_tadir ). SORT ct_tadir BY korrnum ASCENDING. ENDMETHOD. METHOD resolve_ddic. * this will make sure the deletion sequence of structures/tables work * in case they have dependencies with .INCLUDE TYPES: BEGIN OF ty_edge, from TYPE ty_item, to TYPE ty_item, END OF ty_edge. DATA: lt_nodes TYPE TABLE OF ty_item, lt_edges TYPE TABLE OF ty_edge, lt_findstrings TYPE TABLE OF rsfind, lv_plus TYPE i VALUE 1, lv_find_obj_cls TYPE euobj-id, lv_index TYPE i, lv_before TYPE i, lt_founds TYPE TABLE OF rsfindlst, lt_scope TYPE STANDARD TABLE OF seu_obj, lt_dependency TYPE tty_dedenpency. FIELD-SYMBOLS: <ls_tadir_ddls> TYPE ty_tadir, <ls_dependency> TYPE ty_dependency, <ls_tadir_dependent> TYPE ty_tadir, <ls_tadir> LIKE LINE OF ct_tadir, <ls_edge> LIKE LINE OF lt_edges, <ls_found> LIKE LINE OF lt_founds, <ls_node> LIKE LINE OF lt_nodes. * build nodes LOOP AT ct_tadir ASSIGNING <ls_tadir> WHERE object = 'TABL' OR object = 'TTYP'. APPEND INITIAL LINE TO lt_nodes ASSIGNING <ls_node>. <ls_node>-obj_name = <ls_tadir>-obj_name. <ls_node>-obj_type = <ls_tadir>-object. ENDLOOP. APPEND 'TABL' TO lt_scope. APPEND 'STRU' TO lt_scope. APPEND 'TTYP' TO lt_scope. * build edges LOOP AT lt_nodes ASSIGNING <ls_node>. CLEAR lt_findstrings. APPEND <ls_node>-obj_name TO lt_findstrings. lv_find_obj_cls = <ls_node>-obj_type. CALL FUNCTION 'RS_EU_CROSSREF' EXPORTING i_find_obj_cls = lv_find_obj_cls TABLES i_findstrings = lt_findstrings o_founds = lt_founds i_scope_object_cls = lt_scope EXCEPTIONS not_executed = 1 not_found = 2 illegal_object = 3 no_cross_for_this_object = 4 batch = 5 batchjob_error = 6 wrong_type = 7 object_not_exist = 8 OTHERS = 9. IF sy-subrc <> 0. CONTINUE. ENDIF. LOOP AT lt_founds ASSIGNING <ls_found>. APPEND INITIAL LINE TO lt_edges ASSIGNING <ls_edge>. <ls_edge>-from = <ls_node>. <ls_edge>-to-obj_name = <ls_found>-object. CASE <ls_found>-object_cls. WHEN 'DS' OR 'DT'. <ls_edge>-to-obj_type = 'TABL'. WHEN 'DA'. <ls_edge>-to-obj_type = 'TTYP'. WHEN OTHERS. zcx_abapgit_exception=>raise( 'resolve_ddic, unknown object_cls' ). ENDCASE. ENDLOOP. ENDLOOP. * build DDLS edges LOOP AT ct_tadir ASSIGNING <ls_tadir_ddls> WHERE object = 'DDLS'. CLEAR: lt_dependency. APPEND INITIAL LINE TO lt_nodes ASSIGNING <ls_node>. <ls_node>-obj_name = <ls_tadir_ddls>-obj_name. <ls_node>-obj_type = <ls_tadir_ddls>-object. lt_dependency = get_ddls_dependencies( <ls_tadir_ddls>-obj_name ). LOOP AT lt_dependency ASSIGNING <ls_dependency> WHERE deptyp = 'DDLS' AND refname = <ls_tadir_ddls>-obj_name. READ TABLE ct_tadir ASSIGNING <ls_tadir_dependent> WITH KEY pgmid = 'R3TR' object = 'DDLS' obj_name = <ls_dependency>-depname BINARY SEARCH. CHECK sy-subrc = 0. APPEND INITIAL LINE TO lt_edges ASSIGNING <ls_edge>. <ls_edge>-from = <ls_node>. <ls_edge>-to-obj_name = <ls_dependency>-depname. <ls_edge>-to-obj_type = 'DDLS'. ENDLOOP. ENDLOOP. DO. lv_before = lines( lt_nodes ). LOOP AT lt_nodes ASSIGNING <ls_node>. lv_index = sy-tabix. READ TABLE lt_edges WITH KEY from-obj_name = <ls_node>-obj_name from-obj_type = <ls_node>-obj_type TRANSPORTING NO FIELDS. IF sy-subrc <> 0. LOOP AT ct_tadir ASSIGNING <ls_tadir> WHERE obj_name = <ls_node>-obj_name AND object = <ls_node>-obj_type. <ls_tadir>-korrnum = <ls_tadir>-korrnum + lv_plus. CONDENSE <ls_tadir>-korrnum. ENDLOOP. DELETE lt_edges WHERE to-obj_name = <ls_node>-obj_name AND to-obj_type = <ls_node>-obj_type. DELETE lt_nodes INDEX lv_index. EXIT. " make sure the sequence is fixed ENDIF. ENDLOOP. IF lv_before = lines( lt_nodes ). EXIT. ENDIF. lv_plus = lv_plus + 1. ENDDO. ENDMETHOD. "resolve_ddic ENDCLASS.
CLASS zcl_abapgit_dependencies DEFINITION PUBLIC FINAL CREATE PUBLIC . PUBLIC SECTION. TYPES: BEGIN OF ty_tadir, pgmid TYPE tadir-pgmid, object TYPE tadir-object, obj_name TYPE tadir-obj_name, devclass TYPE tadir-devclass, korrnum TYPE tadir-korrnum, path TYPE string, END OF ty_tadir . TYPES: ty_tadir_tt TYPE STANDARD TABLE OF ty_tadir WITH DEFAULT KEY . CLASS-METHODS resolve CHANGING !ct_tadir TYPE ty_tadir_tt RAISING zcx_abapgit_exception . PRIVATE SECTION. TYPES: BEGIN OF ty_dependency, depname TYPE dd02l-tabname, deptyp TYPE c LENGTH 4, deplocal TYPE dd02l-as4local, refname TYPE dd02l-tabname, reftyp TYPE c LENGTH 4, kind TYPE c LENGTH 1, END OF ty_dependency . TYPES: tty_dedenpency TYPE STANDARD TABLE OF ty_dependency WITH NON-UNIQUE DEFAULT KEY . TYPES: BEGIN OF ty_item, obj_type TYPE tadir-object, obj_name TYPE tadir-obj_name, devclass TYPE devclass, END OF ty_item . CLASS-METHODS resolve_ddic CHANGING !ct_tadir TYPE ty_tadir_tt RAISING zcx_abapgit_exception . CLASS-METHODS get_ddls_dependencies IMPORTING !iv_ddls_name TYPE tadir-obj_name RETURNING VALUE(rt_dependency) TYPE tty_dedenpency . ENDCLASS. CLASS ZCL_ABAPGIT_DEPENDENCIES IMPLEMENTATION. METHOD get_ddls_dependencies. TYPES: BEGIN OF ty_ddls_name. INCLUDE TYPE ddsymtab. TYPES: END OF ty_ddls_name. TYPES: tty_ddls_names TYPE STANDARD TABLE OF ty_ddls_name WITH NON-UNIQUE DEFAULT KEY. DATA: lt_ddls_name TYPE tty_ddls_names, ls_ddls_name LIKE LINE OF lt_ddls_name. ls_ddls_name-name = iv_ddls_name. INSERT ls_ddls_name INTO TABLE lt_ddls_name. PERFORM ('DDLS_GET_DEP') IN PROGRAM ('RADMASDL') TABLES lt_ddls_name rt_dependency. ENDMETHOD. METHOD resolve. DATA: lv_tabclass TYPE dd02l-tabclass. FIELD-SYMBOLS: <ls_tadir> LIKE LINE OF ct_tadir. * misuse field KORRNUM to fix deletion sequence LOOP AT ct_tadir ASSIGNING <ls_tadir>. CASE <ls_tadir>-object. WHEN 'IATU'. <ls_tadir>-korrnum = '5500'. WHEN 'IARP'. <ls_tadir>-korrnum = '5510'. WHEN 'IASP'. <ls_tadir>-korrnum = '5520'. WHEN 'SUSC'. <ls_tadir>-korrnum = '5000'. WHEN 'TTYP' OR 'TABL' OR 'VIEW'. SELECT SINGLE tabclass FROM dd02l INTO lv_tabclass WHERE tabname = <ls_tadir>-obj_name AND as4local = 'A' AND as4vers = '0000'. IF sy-subrc = 0 AND lv_tabclass = 'APPEND'. * delete append structures before database tables <ls_tadir>-korrnum = '6500'. ELSE. <ls_tadir>-korrnum = '7000'. ENDIF. WHEN 'DTEL'. <ls_tadir>-korrnum = '8000'. WHEN 'PARA'. * PARA after DTEL <ls_tadir>-korrnum = '8100'. WHEN 'DOMA'. <ls_tadir>-korrnum = '9000'. WHEN 'PROG'. * delete includes after main programs SELECT COUNT(*) FROM reposrc WHERE progname = <ls_tadir>-obj_name AND r3state = 'A' AND subc = 'I'. IF sy-subrc = 0. <ls_tadir>-korrnum = '2000'. ELSE. <ls_tadir>-korrnum = '1000'. ENDIF. WHEN 'IDOC'. <ls_tadir>-korrnum = '2000'. WHEN 'IEXT'. <ls_tadir>-korrnum = '1500'. WHEN OTHERS. <ls_tadir>-korrnum = '1000'. ENDCASE. ENDLOOP. resolve_ddic( CHANGING ct_tadir = ct_tadir ). SORT ct_tadir BY korrnum ASCENDING. ENDMETHOD. METHOD resolve_ddic. * this will make sure the deletion sequence of structures/tables work * in case they have dependencies with .INCLUDE TYPES: BEGIN OF ty_edge, from TYPE ty_item, to TYPE ty_item, END OF ty_edge. DATA: lt_nodes TYPE TABLE OF ty_item, lt_edges TYPE TABLE OF ty_edge, lt_findstrings TYPE TABLE OF rsfind, lv_plus TYPE i VALUE 1, lv_find_obj_cls TYPE euobj-id, lv_index TYPE i, lv_before TYPE i, lt_founds TYPE TABLE OF rsfindlst, lt_scope TYPE STANDARD TABLE OF seu_obj, lt_dependency TYPE tty_dedenpency. FIELD-SYMBOLS: <ls_tadir_ddls> TYPE ty_tadir, <ls_dependency> TYPE ty_dependency, <ls_tadir_dependent> TYPE ty_tadir, <ls_tadir> LIKE LINE OF ct_tadir, <ls_edge> LIKE LINE OF lt_edges, <ls_found> LIKE LINE OF lt_founds, <ls_node> LIKE LINE OF lt_nodes. * build nodes LOOP AT ct_tadir ASSIGNING <ls_tadir> WHERE object = 'TABL' OR object = 'TTYP'. APPEND INITIAL LINE TO lt_nodes ASSIGNING <ls_node>. <ls_node>-obj_name = <ls_tadir>-obj_name. <ls_node>-obj_type = <ls_tadir>-object. ENDLOOP. APPEND 'TABL' TO lt_scope. APPEND 'STRU' TO lt_scope. APPEND 'TTYP' TO lt_scope. * build edges LOOP AT lt_nodes ASSIGNING <ls_node>. CLEAR lt_findstrings. APPEND <ls_node>-obj_name TO lt_findstrings. lv_find_obj_cls = <ls_node>-obj_type. CALL FUNCTION 'RS_EU_CROSSREF' EXPORTING i_find_obj_cls = lv_find_obj_cls TABLES i_findstrings = lt_findstrings o_founds = lt_founds i_scope_object_cls = lt_scope EXCEPTIONS not_executed = 1 not_found = 2 illegal_object = 3 no_cross_for_this_object = 4 batch = 5 batchjob_error = 6 wrong_type = 7 object_not_exist = 8 OTHERS = 9. IF sy-subrc <> 0. CONTINUE. ENDIF. LOOP AT lt_founds ASSIGNING <ls_found>. APPEND INITIAL LINE TO lt_edges ASSIGNING <ls_edge>. <ls_edge>-from = <ls_node>. <ls_edge>-to-obj_name = <ls_found>-object. CASE <ls_found>-object_cls. WHEN 'DS' OR 'DT'. <ls_edge>-to-obj_type = 'TABL'. WHEN 'DA'. <ls_edge>-to-obj_type = 'TTYP'. WHEN OTHERS. zcx_abapgit_exception=>raise( 'resolve_ddic, unknown object_cls' ). ENDCASE. ENDLOOP. ENDLOOP. * build DDLS edges LOOP AT ct_tadir ASSIGNING <ls_tadir_ddls> WHERE object = 'DDLS'. CLEAR: lt_dependency. APPEND INITIAL LINE TO lt_nodes ASSIGNING <ls_node>. <ls_node>-obj_name = <ls_tadir_ddls>-obj_name. <ls_node>-obj_type = <ls_tadir_ddls>-object. lt_dependency = get_ddls_dependencies( <ls_tadir_ddls>-obj_name ). LOOP AT lt_dependency ASSIGNING <ls_dependency> WHERE deptyp = 'DDLS' AND refname = <ls_tadir_ddls>-obj_name. READ TABLE ct_tadir ASSIGNING <ls_tadir_dependent> WITH KEY pgmid = 'R3TR' object = 'DDLS' obj_name = <ls_dependency>-depname BINARY SEARCH. CHECK sy-subrc = 0. APPEND INITIAL LINE TO lt_edges ASSIGNING <ls_edge>. <ls_edge>-from = <ls_node>. <ls_edge>-to-obj_name = <ls_dependency>-depname. <ls_edge>-to-obj_type = 'DDLS'. ENDLOOP. ENDLOOP. DO. lv_before = lines( lt_nodes ). LOOP AT lt_nodes ASSIGNING <ls_node>. lv_index = sy-tabix. READ TABLE lt_edges WITH KEY from-obj_name = <ls_node>-obj_name from-obj_type = <ls_node>-obj_type TRANSPORTING NO FIELDS. IF sy-subrc <> 0. LOOP AT ct_tadir ASSIGNING <ls_tadir> WHERE obj_name = <ls_node>-obj_name AND object = <ls_node>-obj_type. <ls_tadir>-korrnum = <ls_tadir>-korrnum + lv_plus. CONDENSE <ls_tadir>-korrnum. ENDLOOP. DELETE lt_edges WHERE to-obj_name = <ls_node>-obj_name AND to-obj_type = <ls_node>-obj_type. DELETE lt_nodes INDEX lv_index. EXIT. " make sure the sequence is fixed ENDIF. ENDLOOP. IF lv_before = lines( lt_nodes ). EXIT. ENDIF. lv_plus = lv_plus + 1. ENDDO. ENDMETHOD. "resolve_ddic ENDCLASS.
Delete PARA after DTEL, #1539
Delete PARA after DTEL, #1539
ABAP
mit
EduardoCopat/abapGit,sbcgua/abapGit,larshp/abapGit,sbcgua/abapGit,EduardoCopat/abapGit,larshp/abapGit
5c65f3411d5fc52ea41c98ae0ac4faa029579bb4
src/objects/zcl_abapgit_object_chdo.clas.abap
src/objects/zcl_abapgit_object_chdo.clas.abap
CLASS zcl_abapgit_object_chdo DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super FINAL 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. METHODS get_generic RETURNING VALUE(ro_generic) TYPE REF TO zcl_abapgit_objects_generic RAISING zcx_abapgit_exception. METHODS after_import RAISING zcx_abapgit_exception. METHODS delete_tadir_cdnames IMPORTING !is_cdnames TYPE cdnames RAISING zcx_abapgit_exception. METHODS delete_tadir_tabl IMPORTING !is_tcdrs TYPE tcdrs RAISING zcx_abapgit_exception. PRIVATE SECTION. TYPES: BEGIN OF ty_change_document, reports_generated TYPE SORTED TABLE OF tcdrps WITH UNIQUE KEY object reportname, objects TYPE SORTED TABLE OF tcdobs WITH UNIQUE KEY object tabname, objects_text TYPE SORTED TABLE OF tcdobts WITH UNIQUE KEY spras object, END OF ty_change_document, tt_change_document TYPE STANDARD TABLE OF ty_change_document. DATA: mv_object TYPE cdobjectcl. ENDCLASS. CLASS zcl_abapgit_object_chdo IMPLEMENTATION. METHOD constructor. super->constructor( is_item = is_item iv_language = iv_language ). mv_object = is_item-obj_name. ENDMETHOD. METHOD zif_abapgit_object~changed_by. SELECT SINGLE updname INTO rv_user FROM tcdrp WHERE object = mv_object. IF sy-subrc <> 0. rv_user = c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~delete. DATA: lt_cdnames TYPE STANDARD TABLE OF cdnames, ls_cdnames TYPE cdnames, lt_tcdrs TYPE STANDARD TABLE OF tcdrs, ls_tcdrs TYPE tcdrs, lv_msg TYPE symsgv. CALL FUNCTION 'CDNAMES_GET' EXPORTING iv_object = mv_object TABLES it_tcdrs = lt_tcdrs it_names = lt_cdnames EXCEPTIONS object_space = 1 object_not_found = 2 OTHERS = 3. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. CALL FUNCTION 'CHDO_DELETE' EXPORTING iv_object = mv_object iv_with_tadir = abap_true EXCEPTIONS object_is_space = 1 object_not_found = 2 other_error = 3 OTHERS = 4. IF sy-subrc <> 0. lv_msg = mv_object. zcx_abapgit_exception=>raise_t100( iv_msgid = 'CD' iv_msgno = '869' iv_msgv1 = lv_msg ). ENDIF. LOOP AT lt_cdnames INTO ls_cdnames. delete_tadir_cdnames( ls_cdnames ). ENDLOOP. LOOP AT lt_tcdrs INTO ls_tcdrs. delete_tadir_tabl( ls_tcdrs ). ENDLOOP. ENDMETHOD. METHOD zif_abapgit_object~deserialize. DATA: ls_change_object TYPE ty_change_document. FIELD-SYMBOLS: <ls_report_generated> LIKE LINE OF ls_change_object-reports_generated. io_xml->read( EXPORTING iv_name = 'CHDO' CHANGING cg_data = ls_change_object ). DELETE FROM tcdobs WHERE object = mv_object. DELETE FROM tcdobts WHERE object = mv_object. DELETE FROM tcdrps WHERE object = mv_object. LOOP AT ls_change_object-reports_generated ASSIGNING <ls_report_generated>. <ls_report_generated>-devclass = iv_package. ENDLOOP. INSERT tcdobs FROM TABLE ls_change_object-objects. INSERT tcdobts FROM TABLE ls_change_object-objects_text. INSERT tcdrps FROM TABLE ls_change_object-reports_generated. after_import( ). corr_insert( iv_package ). ENDMETHOD. METHOD zif_abapgit_object~exists. SELECT COUNT(*) FROM tcdrp WHERE object = mv_object. rv_bool = boolc( sy-subrc = 0 ). 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. rs_metadata = get_metadata( ). ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. rv_is_locked = abap_false. ENDMETHOD. METHOD zif_abapgit_object~jump. DATA: lt_bdcdata TYPE STANDARD TABLE OF bdcdata, ls_bdcdata LIKE LINE OF lt_bdcdata. CLEAR: ls_bdcdata. ls_bdcdata-program = 'SAPMSCDO_NEW'. ls_bdcdata-dynpro = '0100'. ls_bdcdata-dynbegin = abap_true. APPEND ls_bdcdata TO lt_bdcdata. CLEAR: ls_bdcdata. ls_bdcdata-fnam = 'TCDOB-OBJECT'. ls_bdcdata-fval = mv_object. APPEND ls_bdcdata TO lt_bdcdata. CLEAR: ls_bdcdata. ls_bdcdata-fnam = 'BDC_OKCODE'. ls_bdcdata-fval = '=DISP'. APPEND ls_bdcdata TO lt_bdcdata. CALL FUNCTION 'ABAP4_CALL_TRANSACTION' STARTING NEW TASK 'GIT' EXPORTING tcode = 'SCDO' mode_val = 'E' TABLES using_tab = lt_bdcdata EXCEPTIONS system_failure = 1 communication_failure = 2 resource_failure = 3 OTHERS = 4. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |ERROR: Jump { mv_object }| ). ENDIF. ENDMETHOD. METHOD zif_abapgit_object~serialize. DATA: ls_change_object TYPE ty_change_document, lt_tcdrp TYPE STANDARD TABLE OF tcdrp, lt_tcdob TYPE STANDARD TABLE OF tcdob, lt_tcdobt TYPE STANDARD TABLE OF tcdobt. FIELD-SYMBOLS: <ls_reports_generated> LIKE LINE OF ls_change_object-reports_generated, <ls_objects> LIKE LINE OF ls_change_object-objects, <ls_objects_text> LIKE LINE OF ls_change_object-objects_text. CALL FUNCTION 'CDNAMES_GET' EXPORTING iv_object = mv_object TABLES it_tcdrp = lt_tcdrp it_tcdob = lt_tcdob it_tcdobt = lt_tcdobt EXCEPTIONS object_space = 1 object_not_found = 2 OTHERS = 3. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ls_change_object-reports_generated = lt_tcdrp. ls_change_object-objects = lt_tcdob. ls_change_object-objects_text = lt_tcdobt. " At import, when CHDO is generated date & time change, so always detects changes for this fields LOOP AT ls_change_object-reports_generated ASSIGNING <ls_reports_generated>. CLEAR: <ls_reports_generated>-datum, <ls_reports_generated>-uzeit, <ls_reports_generated>-author, <ls_reports_generated>-updname, <ls_reports_generated>-devclass. ENDLOOP. LOOP AT ls_change_object-objects ASSIGNING <ls_objects>. CLEAR: <ls_objects>-udate, <ls_objects>-utime. ENDLOOP. LOOP AT ls_change_object-objects_text ASSIGNING <ls_objects_text>. CLEAR: <ls_objects_text>-udate, <ls_objects_text>-utime. ENDLOOP. io_xml->add( iv_name = 'CHDO' ig_data = ls_change_object ). ENDMETHOD. METHOD get_generic. CREATE OBJECT ro_generic EXPORTING is_item = ms_item. ENDMETHOD. METHOD after_import. DATA: lt_cts_object_entry TYPE STANDARD TABLE OF e071 WITH DEFAULT KEY, ls_cts_object_entry LIKE LINE OF lt_cts_object_entry, lt_errormsg TYPE STANDARD TABLE OF sprot_u WITH DEFAULT KEY. ls_cts_object_entry-pgmid = seok_pgmid_r3tr. ls_cts_object_entry-object = ms_item-obj_type. ls_cts_object_entry-obj_name = ms_item-obj_name. INSERT ls_cts_object_entry INTO TABLE lt_cts_object_entry. CALL FUNCTION 'AFTER_IMP_CHDO' EXPORTING iv_tarclient = sy-mandt iv_is_upgrade = abap_false TABLES tt_e071 = lt_cts_object_entry tt_errormsg = lt_errormsg. LOOP AT lt_errormsg TRANSPORTING NO FIELDS WHERE severity = 'E' OR severity = 'A'. EXIT. ENDLOOP. IF sy-subrc = 0. zcx_abapgit_exception=>raise( 'Error from AFTER_IMP_CHDO' ). ENDIF. ENDMETHOD. METHOD delete_tadir_cdnames. DATA: lv_obj_name TYPE sobj_name. IF is_cdnames-repnamec IS NOT INITIAL. lv_obj_name = is_cdnames-repnamec. CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_delete_tadir_entry = abap_true wi_tadir_pgmid = 'R3TR' wi_tadir_object = 'PROG' wi_tadir_obj_name = lv_obj_name EXCEPTIONS tadir_entry_not_existing = 1 OTHERS = 2. IF sy-subrc > 1. zcx_abapgit_exception=>raise( |Error from TR_TADIR_INTERFACE (subrc={ sy-subrc } ).| ). ENDIF. ENDIF. IF is_cdnames-repnamet IS NOT INITIAL. lv_obj_name = is_cdnames-repnamet. CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_delete_tadir_entry = abap_true wi_tadir_pgmid = 'R3TR' wi_tadir_object = 'PROG' wi_tadir_obj_name = lv_obj_name EXCEPTIONS tadir_entry_not_existing = 1 OTHERS = 2. IF sy-subrc > 1. zcx_abapgit_exception=>raise( |Error from TR_TADIR_INTERFACE (subrc={ sy-subrc } ).| ). ENDIF. ENDIF. IF is_cdnames-repnamefix IS NOT INITIAL. lv_obj_name = is_cdnames-repnamefix. CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_delete_tadir_entry = abap_true wi_tadir_pgmid = 'R3TR' wi_tadir_object = 'PROG' wi_tadir_obj_name = lv_obj_name EXCEPTIONS tadir_entry_not_existing = 1 OTHERS = 2. IF sy-subrc > 1. zcx_abapgit_exception=>raise( |Error from TR_TADIR_INTERFACE (subrc={ sy-subrc } ).| ). ENDIF. ENDIF. IF is_cdnames-repnamevar IS NOT INITIAL. lv_obj_name = is_cdnames-repnamevar. CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_delete_tadir_entry = abap_true wi_tadir_pgmid = 'R3TR' wi_tadir_object = 'PROG' wi_tadir_obj_name = lv_obj_name EXCEPTIONS tadir_entry_not_existing = 1 OTHERS = 2. IF sy-subrc > 1. zcx_abapgit_exception=>raise( |Error from TR_TADIR_INTERFACE (subrc={ sy-subrc } ).| ). ENDIF. ENDIF. IF is_cdnames-fgrp IS NOT INITIAL. lv_obj_name = is_cdnames-fgrp. CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_delete_tadir_entry = abap_true wi_tadir_pgmid = 'R3TR' wi_tadir_object = 'FUGR' wi_tadir_obj_name = lv_obj_name EXCEPTIONS tadir_entry_not_existing = 1 OTHERS = 2. IF sy-subrc > 1. zcx_abapgit_exception=>raise( |Error from TR_TADIR_INTERFACE (subrc={ sy-subrc } ).| ). ENDIF. ENDIF. ENDMETHOD. METHOD delete_tadir_tabl. DATA: lv_obj_name TYPE sobj_name. IF is_tcdrs-tabname IS NOT INITIAL. lv_obj_name = is_tcdrs-tabname. CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_delete_tadir_entry = abap_true wi_tadir_pgmid = 'R3TR' wi_tadir_object = 'FUGR' wi_tadir_obj_name = lv_obj_name EXCEPTIONS tadir_entry_not_existing = 1 OTHERS = 2. IF sy-subrc > 1. zcx_abapgit_exception=>raise( |Error from TR_TADIR_INTERFACE (subrc={ sy-subrc } ).| ). ENDIF. ENDIF. ENDMETHOD. ENDCLASS.
CLASS zcl_abapgit_object_chdo DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super FINAL 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. METHODS get_generic RETURNING VALUE(ro_generic) TYPE REF TO zcl_abapgit_objects_generic RAISING zcx_abapgit_exception. METHODS after_import RAISING zcx_abapgit_exception. METHODS delete_tadir_cdnames IMPORTING !is_cdnames TYPE cdnames RAISING zcx_abapgit_exception. METHODS delete_tadir_tabl IMPORTING !is_tcdrs TYPE tcdrs RAISING zcx_abapgit_exception. PRIVATE SECTION. TYPES: BEGIN OF ty_change_document, reports_generated TYPE SORTED TABLE OF tcdrps WITH UNIQUE KEY object reportname, objects TYPE SORTED TABLE OF tcdobs WITH UNIQUE KEY object tabname, objects_text TYPE SORTED TABLE OF tcdobts WITH UNIQUE KEY spras object, END OF ty_change_document, tt_change_document TYPE STANDARD TABLE OF ty_change_document. DATA: mv_object TYPE cdobjectcl. METHODS: clear_field IMPORTING iv_fieldname TYPE string CHANGING cs_structure TYPE any. ENDCLASS. CLASS zcl_abapgit_object_chdo IMPLEMENTATION. METHOD constructor. super->constructor( is_item = is_item iv_language = iv_language ). mv_object = is_item-obj_name. ENDMETHOD. METHOD zif_abapgit_object~changed_by. SELECT SINGLE updname INTO rv_user FROM tcdrp WHERE object = mv_object. IF sy-subrc <> 0. rv_user = c_user_unknown. ENDIF. ENDMETHOD. METHOD zif_abapgit_object~delete. DATA: lt_cdnames TYPE STANDARD TABLE OF cdnames, ls_cdnames TYPE cdnames, lt_tcdrs TYPE STANDARD TABLE OF tcdrs, ls_tcdrs TYPE tcdrs, lv_msg TYPE symsgv. CALL FUNCTION 'CDNAMES_GET' EXPORTING iv_object = mv_object TABLES it_tcdrs = lt_tcdrs it_names = lt_cdnames EXCEPTIONS object_space = 1 object_not_found = 2 OTHERS = 3. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. CALL FUNCTION 'CHDO_DELETE' EXPORTING iv_object = mv_object iv_with_tadir = abap_true EXCEPTIONS object_is_space = 1 object_not_found = 2 other_error = 3 OTHERS = 4. IF sy-subrc <> 0. lv_msg = mv_object. zcx_abapgit_exception=>raise_t100( iv_msgid = 'CD' iv_msgno = '869' iv_msgv1 = lv_msg ). ENDIF. LOOP AT lt_cdnames INTO ls_cdnames. delete_tadir_cdnames( ls_cdnames ). ENDLOOP. LOOP AT lt_tcdrs INTO ls_tcdrs. delete_tadir_tabl( ls_tcdrs ). ENDLOOP. ENDMETHOD. METHOD zif_abapgit_object~deserialize. DATA: ls_change_object TYPE ty_change_document. FIELD-SYMBOLS: <ls_report_generated> LIKE LINE OF ls_change_object-reports_generated. io_xml->read( EXPORTING iv_name = 'CHDO' CHANGING cg_data = ls_change_object ). DELETE FROM tcdobs WHERE object = mv_object. DELETE FROM tcdobts WHERE object = mv_object. DELETE FROM tcdrps WHERE object = mv_object. LOOP AT ls_change_object-reports_generated ASSIGNING <ls_report_generated>. <ls_report_generated>-devclass = iv_package. ENDLOOP. INSERT tcdobs FROM TABLE ls_change_object-objects. INSERT tcdobts FROM TABLE ls_change_object-objects_text. INSERT tcdrps FROM TABLE ls_change_object-reports_generated. after_import( ). corr_insert( iv_package ). ENDMETHOD. METHOD zif_abapgit_object~exists. SELECT COUNT(*) FROM tcdrp WHERE object = mv_object. rv_bool = boolc( sy-subrc = 0 ). 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. rs_metadata = get_metadata( ). ENDMETHOD. METHOD zif_abapgit_object~is_active. rv_active = is_active( ). ENDMETHOD. METHOD zif_abapgit_object~is_locked. rv_is_locked = abap_false. ENDMETHOD. METHOD zif_abapgit_object~jump. DATA: lt_bdcdata TYPE STANDARD TABLE OF bdcdata, ls_bdcdata LIKE LINE OF lt_bdcdata. CLEAR: ls_bdcdata. ls_bdcdata-program = 'SAPMSCDO_NEW'. ls_bdcdata-dynpro = '0100'. ls_bdcdata-dynbegin = abap_true. APPEND ls_bdcdata TO lt_bdcdata. CLEAR: ls_bdcdata. ls_bdcdata-fnam = 'TCDOB-OBJECT'. ls_bdcdata-fval = mv_object. APPEND ls_bdcdata TO lt_bdcdata. CLEAR: ls_bdcdata. ls_bdcdata-fnam = 'BDC_OKCODE'. ls_bdcdata-fval = '=DISP'. APPEND ls_bdcdata TO lt_bdcdata. CALL FUNCTION 'ABAP4_CALL_TRANSACTION' STARTING NEW TASK 'GIT' EXPORTING tcode = 'SCDO' mode_val = 'E' TABLES using_tab = lt_bdcdata EXCEPTIONS system_failure = 1 communication_failure = 2 resource_failure = 3 OTHERS = 4. IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |ERROR: Jump { mv_object }| ). ENDIF. ENDMETHOD. METHOD zif_abapgit_object~serialize. DATA: ls_change_object TYPE ty_change_document, lt_tcdrp TYPE STANDARD TABLE OF tcdrp, lt_tcdob TYPE STANDARD TABLE OF tcdob, lt_tcdobt TYPE STANDARD TABLE OF tcdobt. FIELD-SYMBOLS: <ls_reports_generated> LIKE LINE OF ls_change_object-reports_generated, <ls_objects> LIKE LINE OF ls_change_object-objects, <ls_objects_text> LIKE LINE OF ls_change_object-objects_text. CALL FUNCTION 'CDNAMES_GET' EXPORTING iv_object = mv_object TABLES it_tcdrp = lt_tcdrp it_tcdob = lt_tcdob it_tcdobt = lt_tcdobt EXCEPTIONS object_space = 1 object_not_found = 2 OTHERS = 3. IF sy-subrc <> 0. zcx_abapgit_exception=>raise_t100( ). ENDIF. ls_change_object-reports_generated = lt_tcdrp. ls_change_object-objects = lt_tcdob. ls_change_object-objects_text = lt_tcdobt. " At import, when CHDO is generated date & time change, so always detects changes for this fields LOOP AT ls_change_object-reports_generated ASSIGNING <ls_reports_generated>. CLEAR: <ls_reports_generated>-datum, <ls_reports_generated>-uzeit, <ls_reports_generated>-author, <ls_reports_generated>-updname, <ls_reports_generated>-devclass. ENDLOOP. LOOP AT ls_change_object-objects ASSIGNING <ls_objects>. clear_field( EXPORTING iv_fieldname = |UDATE| CHANGING cs_structure = <ls_objects> ). clear_field( EXPORTING iv_fieldname = |UTIME| CHANGING cs_structure = <ls_objects> ). ENDLOOP. LOOP AT ls_change_object-objects_text ASSIGNING <ls_objects_text>. clear_field( EXPORTING iv_fieldname = |UDATE| CHANGING cs_structure = <ls_objects_text> ). clear_field( EXPORTING iv_fieldname = |UTIME| CHANGING cs_structure = <ls_objects_text> ). ENDLOOP. io_xml->add( iv_name = 'CHDO' ig_data = ls_change_object ). ENDMETHOD. METHOD get_generic. CREATE OBJECT ro_generic EXPORTING is_item = ms_item. ENDMETHOD. METHOD after_import. DATA: lt_cts_object_entry TYPE STANDARD TABLE OF e071 WITH DEFAULT KEY, ls_cts_object_entry LIKE LINE OF lt_cts_object_entry, lt_errormsg TYPE STANDARD TABLE OF sprot_u WITH DEFAULT KEY. ls_cts_object_entry-pgmid = seok_pgmid_r3tr. ls_cts_object_entry-object = ms_item-obj_type. ls_cts_object_entry-obj_name = ms_item-obj_name. INSERT ls_cts_object_entry INTO TABLE lt_cts_object_entry. CALL FUNCTION 'AFTER_IMP_CHDO' EXPORTING iv_tarclient = sy-mandt iv_is_upgrade = abap_false TABLES tt_e071 = lt_cts_object_entry tt_errormsg = lt_errormsg. LOOP AT lt_errormsg TRANSPORTING NO FIELDS WHERE severity = 'E' OR severity = 'A'. EXIT. ENDLOOP. IF sy-subrc = 0. zcx_abapgit_exception=>raise( 'Error from AFTER_IMP_CHDO' ). ENDIF. ENDMETHOD. METHOD delete_tadir_cdnames. DATA: lv_obj_name TYPE sobj_name. IF is_cdnames-repnamec IS NOT INITIAL. lv_obj_name = is_cdnames-repnamec. CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_delete_tadir_entry = abap_true wi_tadir_pgmid = 'R3TR' wi_tadir_object = 'PROG' wi_tadir_obj_name = lv_obj_name EXCEPTIONS tadir_entry_not_existing = 1 OTHERS = 2. IF sy-subrc > 1. zcx_abapgit_exception=>raise( |Error from TR_TADIR_INTERFACE (subrc={ sy-subrc } ).| ). ENDIF. ENDIF. IF is_cdnames-repnamet IS NOT INITIAL. lv_obj_name = is_cdnames-repnamet. CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_delete_tadir_entry = abap_true wi_tadir_pgmid = 'R3TR' wi_tadir_object = 'PROG' wi_tadir_obj_name = lv_obj_name EXCEPTIONS tadir_entry_not_existing = 1 OTHERS = 2. IF sy-subrc > 1. zcx_abapgit_exception=>raise( |Error from TR_TADIR_INTERFACE (subrc={ sy-subrc } ).| ). ENDIF. ENDIF. IF is_cdnames-repnamefix IS NOT INITIAL. lv_obj_name = is_cdnames-repnamefix. CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_delete_tadir_entry = abap_true wi_tadir_pgmid = 'R3TR' wi_tadir_object = 'PROG' wi_tadir_obj_name = lv_obj_name EXCEPTIONS tadir_entry_not_existing = 1 OTHERS = 2. IF sy-subrc > 1. zcx_abapgit_exception=>raise( |Error from TR_TADIR_INTERFACE (subrc={ sy-subrc } ).| ). ENDIF. ENDIF. IF is_cdnames-repnamevar IS NOT INITIAL. lv_obj_name = is_cdnames-repnamevar. CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_delete_tadir_entry = abap_true wi_tadir_pgmid = 'R3TR' wi_tadir_object = 'PROG' wi_tadir_obj_name = lv_obj_name EXCEPTIONS tadir_entry_not_existing = 1 OTHERS = 2. IF sy-subrc > 1. zcx_abapgit_exception=>raise( |Error from TR_TADIR_INTERFACE (subrc={ sy-subrc } ).| ). ENDIF. ENDIF. IF is_cdnames-fgrp IS NOT INITIAL. lv_obj_name = is_cdnames-fgrp. CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_delete_tadir_entry = abap_true wi_tadir_pgmid = 'R3TR' wi_tadir_object = 'FUGR' wi_tadir_obj_name = lv_obj_name EXCEPTIONS tadir_entry_not_existing = 1 OTHERS = 2. IF sy-subrc > 1. zcx_abapgit_exception=>raise( |Error from TR_TADIR_INTERFACE (subrc={ sy-subrc } ).| ). ENDIF. ENDIF. ENDMETHOD. METHOD delete_tadir_tabl. DATA: lv_obj_name TYPE sobj_name. IF is_tcdrs-tabname IS NOT INITIAL. lv_obj_name = is_tcdrs-tabname. CALL FUNCTION 'TR_TADIR_INTERFACE' EXPORTING wi_delete_tadir_entry = abap_true wi_tadir_pgmid = 'R3TR' wi_tadir_object = 'FUGR' wi_tadir_obj_name = lv_obj_name EXCEPTIONS tadir_entry_not_existing = 1 OTHERS = 2. IF sy-subrc > 1. zcx_abapgit_exception=>raise( |Error from TR_TADIR_INTERFACE (subrc={ sy-subrc } ).| ). ENDIF. ENDIF. ENDMETHOD. METHOD clear_field. FIELD-SYMBOLS: <lv_field> TYPE data. ASSIGN COMPONENT iv_fieldname OF STRUCTURE cs_structure TO <lv_field>. IF sy-subrc <> 0. RETURN. " Field is not available in lower NW versions ENDIF. CLEAR: <lv_field>. ENDMETHOD. ENDCLASS.
clear UZEIT and UTIME dynamically (#3256)
CHDO: clear UZEIT and UTIME dynamically (#3256) Co-authored-by: Lars Hvam <721d1b171982cd84b755f6b25130d2b88cd1f696@hotmail.com>
ABAP
mit
sbcgua/abapGit,larshp/abapGit,larshp/abapGit,EduardoCopat/abapGit,EduardoCopat/abapGit,sbcgua/abapGit
690527a771142a3a64d5a88e4036ece6f92b9c96
src/zcl_abapgit_folder_logic.clas.abap
src/zcl_abapgit_folder_logic.clas.abap
CLASS zcl_abapgit_folder_logic DEFINITION PUBLIC CREATE PUBLIC . PUBLIC SECTION. CLASS-METHODS package_to_path IMPORTING !iv_top TYPE devclass !io_dot TYPE REF TO zcl_abapgit_dot_abapgit !iv_package TYPE devclass RETURNING VALUE(rv_path) TYPE string RAISING zcx_abapgit_exception . CLASS-METHODS path_to_package IMPORTING !iv_top TYPE devclass !io_dot TYPE REF TO zcl_abapgit_dot_abapgit !iv_path TYPE string !iv_create_if_not_exists TYPE abap_bool DEFAULT abap_true RETURNING VALUE(rv_package) TYPE devclass RAISING zcx_abapgit_exception . ENDCLASS. CLASS ZCL_ABAPGIT_FOLDER_LOGIC IMPLEMENTATION. METHOD package_to_path. DATA: lv_len TYPE i, lv_path TYPE string, lv_message TYPE string, lv_parentcl TYPE tdevc-parentcl. IF iv_top = iv_package. rv_path = io_dot->get_starting_folder( ). ELSE. lv_parentcl = zcl_abapgit_sap_package=>get( iv_package )->read_parent( ). IF lv_parentcl IS INITIAL. zcx_abapgit_exception=>raise( |error, expected parent package, { iv_package }| ). ELSE. CASE io_dot->get_folder_logic( ). WHEN zif_abapgit_dot_abapgit=>c_folder_logic-full. lv_len = 0. IF iv_package(1) = '$'. lv_len = 1. ENDIF. WHEN zif_abapgit_dot_abapgit=>c_folder_logic-prefix. lv_len = strlen( lv_parentcl ). IF iv_package(lv_len) <> lv_parentcl. * if abapGit project is installed in package ZZZ, all subpackages should be named * ZZZ_something. This will define the folder name in the zip file to be "something", * similarily with online projects. Alternatively change to FULL folder logic lv_message = 'PREFIX: Unexpected package naming(' && iv_package && ')' ##no_text. zcx_abapgit_exception=>raise( lv_message ). ENDIF. WHEN OTHERS. ASSERT 0 = 1. ENDCASE. lv_path = iv_package+lv_len. IF strlen( lv_path ) = 0. zcx_abapgit_exception=>raise( |Folder logic: length = 0, parent: { lv_parentcl }, child: { iv_package }| ). ENDIF. IF lv_path(1) = '_'. lv_path = lv_path+1. ENDIF. IF strlen( lv_path ) = 0. zcx_abapgit_exception=>raise( |Folder logic: length = 0, parent: { lv_parentcl }, child: { iv_package }| ). ENDIF. TRANSLATE lv_path USING '/#'. TRANSLATE lv_path TO LOWER CASE. CONCATENATE lv_path '/' INTO lv_path. rv_path = package_to_path( iv_top = iv_top io_dot = io_dot iv_package = lv_parentcl ). CONCATENATE rv_path lv_path INTO rv_path. ENDIF. ENDIF. ENDMETHOD. "class_to_path METHOD path_to_package. DATA: lv_length TYPE i, lv_parent TYPE devclass, lv_new TYPE string, lv_path TYPE string, lv_top TYPE devclass. lv_top = iv_top. lv_length = strlen( io_dot->get_starting_folder( ) ). IF lv_length > strlen( iv_path ). zcx_abapgit_exception=>raise( 'unexpected folder structure' ). ENDIF. lv_path = iv_path+lv_length. lv_parent = lv_top. rv_package = lv_top. WHILE lv_path CA '/'. SPLIT lv_path AT '/' INTO lv_new lv_path. CASE io_dot->get_folder_logic( ). WHEN zif_abapgit_dot_abapgit=>c_folder_logic-full. rv_package = lv_new. TRANSLATE rv_package USING '#/'. IF iv_top(1) = '$'. CONCATENATE '$' rv_package INTO rv_package. ENDIF. WHEN zif_abapgit_dot_abapgit=>c_folder_logic-prefix. CONCATENATE rv_package '_' lv_new INTO rv_package. WHEN OTHERS. ASSERT 0 = 1. ENDCASE. TRANSLATE rv_package TO UPPER CASE. IF zcl_abapgit_sap_package=>get( rv_package )->exists( ) = abap_false AND iv_create_if_not_exists = abap_true. zcl_abapgit_sap_package=>get( lv_parent )->create_child( rv_package ). ENDIF. lv_parent = rv_package. ENDWHILE. ENDMETHOD. ENDCLASS.
CLASS zcl_abapgit_folder_logic DEFINITION PUBLIC CREATE PUBLIC . PUBLIC SECTION. CLASS-METHODS package_to_path IMPORTING !iv_top TYPE devclass !io_dot TYPE REF TO zcl_abapgit_dot_abapgit !iv_package TYPE devclass RETURNING VALUE(rv_path) TYPE string RAISING zcx_abapgit_exception . CLASS-METHODS path_to_package IMPORTING !iv_top TYPE devclass !io_dot TYPE REF TO zcl_abapgit_dot_abapgit !iv_path TYPE string !iv_create_if_not_exists TYPE abap_bool DEFAULT abap_true RETURNING VALUE(rv_package) TYPE devclass RAISING zcx_abapgit_exception . ENDCLASS. CLASS ZCL_ABAPGIT_FOLDER_LOGIC IMPLEMENTATION. METHOD package_to_path. DATA: lv_len TYPE i, lv_path TYPE string, lv_message TYPE string, lv_parentcl TYPE tdevc-parentcl. IF iv_top = iv_package. rv_path = io_dot->get_starting_folder( ). ELSE. lv_parentcl = zcl_abapgit_sap_package=>get( iv_package )->read_parent( ). IF lv_parentcl IS INITIAL. zcx_abapgit_exception=>raise( |error, expected parent package, { iv_package }| ). ELSE. CASE io_dot->get_folder_logic( ). WHEN zif_abapgit_dot_abapgit=>c_folder_logic-full. lv_len = 0. IF iv_package(1) = '$'. lv_len = 1. ENDIF. WHEN zif_abapgit_dot_abapgit=>c_folder_logic-prefix. lv_len = strlen( lv_parentcl ). IF iv_package(lv_len) <> lv_parentcl. * if abapGit project is installed in package ZZZ, all subpackages should be named * ZZZ_something. This will define the folder name in the zip file to be "something", * similarily with online projects. Alternatively change to FULL folder logic lv_message = 'PREFIX: Unexpected package naming (' && iv_package && ') you might switch to FULL folder logic' ##no_text. zcx_abapgit_exception=>raise( lv_message ). ENDIF. WHEN OTHERS. ASSERT 0 = 1. ENDCASE. lv_path = iv_package+lv_len. IF strlen( lv_path ) = 0. zcx_abapgit_exception=>raise( |Folder logic: length = 0, parent: { lv_parentcl }, child: { iv_package }| ). ENDIF. IF lv_path(1) = '_'. lv_path = lv_path+1. ENDIF. IF strlen( lv_path ) = 0. zcx_abapgit_exception=>raise( |Folder logic: length = 0, parent: { lv_parentcl }, child: { iv_package }| ). ENDIF. TRANSLATE lv_path USING '/#'. TRANSLATE lv_path TO LOWER CASE. CONCATENATE lv_path '/' INTO lv_path. rv_path = package_to_path( iv_top = iv_top io_dot = io_dot iv_package = lv_parentcl ). CONCATENATE rv_path lv_path INTO rv_path. ENDIF. ENDIF. ENDMETHOD. "class_to_path METHOD path_to_package. DATA: lv_length TYPE i, lv_parent TYPE devclass, lv_new TYPE string, lv_path TYPE string, lv_top TYPE devclass. lv_top = iv_top. lv_length = strlen( io_dot->get_starting_folder( ) ). IF lv_length > strlen( iv_path ). zcx_abapgit_exception=>raise( 'unexpected folder structure' ). ENDIF. lv_path = iv_path+lv_length. lv_parent = lv_top. rv_package = lv_top. WHILE lv_path CA '/'. SPLIT lv_path AT '/' INTO lv_new lv_path. CASE io_dot->get_folder_logic( ). WHEN zif_abapgit_dot_abapgit=>c_folder_logic-full. rv_package = lv_new. TRANSLATE rv_package USING '#/'. IF iv_top(1) = '$'. CONCATENATE '$' rv_package INTO rv_package. ENDIF. WHEN zif_abapgit_dot_abapgit=>c_folder_logic-prefix. CONCATENATE rv_package '_' lv_new INTO rv_package. WHEN OTHERS. ASSERT 0 = 1. ENDCASE. TRANSLATE rv_package TO UPPER CASE. IF zcl_abapgit_sap_package=>get( rv_package )->exists( ) = abap_false AND iv_create_if_not_exists = abap_true. zcl_abapgit_sap_package=>get( lv_parent )->create_child( rv_package ). ENDIF. lv_parent = rv_package. ENDWHILE. ENDMETHOD. ENDCLASS.
Add you might switch to FULL folder logic to error message
Add you might switch to FULL folder logic to error message
ABAP
mit
larshp/abapGit,EduardoCopat/abapGit,sbcgua/abapGit,sbcgua/abapGit,EduardoCopat/abapGit,larshp/abapGit
f2a801ad1a5676b442e6b49fa3af2de030d56d9c
src/zabapgit_password_dialog.prog.abap
src/zabapgit_password_dialog.prog.abap
*&---------------------------------------------------------------------* *& Include ZABAPGIT_PASSWORD_DIALOG *&---------------------------------------------------------------------* SELECTION-SCREEN BEGIN OF SCREEN 1002 TITLE s_title. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(18) s_url FOR FIELD p_url. PARAMETERS: p_url TYPE string LOWER CASE VISIBLE LENGTH 60 ##SEL_WRONG. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(18) s_user FOR FIELD p_user. PARAMETERS: p_user TYPE string LOWER CASE VISIBLE LENGTH 60 ##SEL_WRONG. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(18) s_pass FOR FIELD p_pass. PARAMETERS: p_pass TYPE c LENGTH 255 LOWER CASE VISIBLE LENGTH 60 ##SEL_WRONG. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN END OF SCREEN 1002. *----------------------------------------------------------------------- * LCL_PASSWORD_DIALOG *----------------------------------------------------------------------- CLASS lcl_password_dialog DEFINITION FINAL. ************** * This class will remain local in the report ************** PUBLIC SECTION. CONSTANTS c_dynnr TYPE c LENGTH 4 VALUE '1002'. CLASS-METHODS popup IMPORTING iv_repo_url TYPE string CHANGING cv_user TYPE string cv_pass TYPE string. CLASS-METHODS on_screen_init. CLASS-METHODS on_screen_output. CLASS-METHODS on_screen_event IMPORTING iv_ucomm TYPE sy-ucomm. PRIVATE SECTION. CLASS-DATA gv_confirm TYPE abap_bool. CLASS-METHODS enrich_title_by_hostname IMPORTING iv_repo_url TYPE string. ENDCLASS. CLASS lcl_password_dialog IMPLEMENTATION. METHOD popup. CLEAR p_pass. p_url = iv_repo_url. p_user = cv_user. gv_confirm = abap_false. enrich_title_by_hostname( iv_repo_url ). CALL SELECTION-SCREEN c_dynnr STARTING AT 5 5 ENDING AT 80 8. IF gv_confirm = abap_true. cv_user = p_user. cv_pass = p_pass. ELSE. CLEAR: cv_user, cv_pass. ENDIF. CLEAR: p_url, p_user, p_pass. ENDMETHOD. METHOD on_screen_init. s_title = 'Login'. s_url = 'Repo URL'. s_user = 'User'. s_pass = 'Password or Token'. ENDMETHOD. METHOD on_screen_output. DATA lt_ucomm TYPE TABLE OF sy-ucomm. ASSERT sy-dynnr = c_dynnr. LOOP AT SCREEN. IF screen-name = 'P_URL'. screen-input = '0'. screen-intensified = '1'. screen-display_3d = '0'. MODIFY SCREEN. ENDIF. IF screen-name = 'P_PASS'. screen-invisible = '1'. MODIFY SCREEN. ENDIF. ENDLOOP. " Program RSSYSTDB, GUI Status %_CSP PERFORM set_pf_status IN PROGRAM rsdbrunt IF FOUND. APPEND 'NONE' TO lt_ucomm. "Button Check APPEND 'SPOS' TO lt_ucomm. "Save as Variant CALL FUNCTION 'RS_SET_SELSCREEN_STATUS' EXPORTING p_status = sy-pfkey TABLES p_exclude = lt_ucomm. IF p_user IS NOT INITIAL. SET CURSOR FIELD 'P_PASS'. ENDIF. ENDMETHOD. METHOD on_screen_event. ASSERT sy-dynnr = c_dynnr. " CRET - F8 " OTHERS - simulate Enter press CASE iv_ucomm. WHEN 'CRET'. gv_confirm = abap_true. WHEN OTHERS. "TODO REFACTOR !!! A CLUTCH ! " This will work unless any new specific logic appear " for other commands. The problem is that the password dialog " does not have Enter event (or I don't know how to activate it ;) " so Enter issues previous command from previous screen " But for now this works :) Fortunately Esc produces another flow gv_confirm = abap_true. LEAVE TO SCREEN 0. ENDCASE. ENDMETHOD. METHOD enrich_title_by_hostname. DATA lv_host TYPE string. FIND REGEX 'https?://([^/^:]*)' IN iv_repo_url SUBMATCHES lv_host. IF lv_host IS NOT INITIAL AND lv_host <> space. CLEAR s_title. CONCATENATE 'Login:' lv_host INTO s_title IN CHARACTER MODE SEPARATED BY space. ENDIF. ENDMETHOD. ENDCLASS.
*&---------------------------------------------------------------------* *& Include ZABAPGIT_PASSWORD_DIALOG *&---------------------------------------------------------------------* * Todo, remove comment about Github token usage by 2021-12-31 SELECTION-SCREEN BEGIN OF SCREEN 1002 TITLE s_title. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(18) s_url FOR FIELD p_url. PARAMETERS: p_url TYPE string LOWER CASE VISIBLE LENGTH 60 ##SEL_WRONG. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(18) s_user FOR FIELD p_user. PARAMETERS: p_user TYPE string LOWER CASE VISIBLE LENGTH 60 ##SEL_WRONG. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(18) s_pass FOR FIELD p_pass. PARAMETERS: p_pass TYPE c LENGTH 255 LOWER CASE VISIBLE LENGTH 60 ##SEL_WRONG. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN SKIP. SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(18) s_cmnt FOR FIELD p_cmnt. PARAMETERS: p_cmnt TYPE c LENGTH 255 LOWER CASE VISIBLE LENGTH 60 ##SEL_WRONG. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN END OF SCREEN 1002. *----------------------------------------------------------------------- * LCL_PASSWORD_DIALOG *----------------------------------------------------------------------- CLASS lcl_password_dialog DEFINITION FINAL. ************** * This class will remain local in the report ************** PUBLIC SECTION. CONSTANTS c_dynnr TYPE c LENGTH 4 VALUE '1002'. CLASS-METHODS popup IMPORTING iv_repo_url TYPE string CHANGING cv_user TYPE string cv_pass TYPE string. CLASS-METHODS on_screen_init. CLASS-METHODS on_screen_output. CLASS-METHODS on_screen_event IMPORTING iv_ucomm TYPE sy-ucomm. PRIVATE SECTION. CLASS-DATA gv_confirm TYPE abap_bool. CLASS-METHODS enrich_title_by_hostname IMPORTING iv_repo_url TYPE string. ENDCLASS. CLASS lcl_password_dialog IMPLEMENTATION. METHOD popup. CLEAR p_pass. p_url = iv_repo_url. p_user = cv_user. p_cmnt = 'GitHub requires using tokens (since August 2021)'. gv_confirm = abap_false. enrich_title_by_hostname( iv_repo_url ). CALL SELECTION-SCREEN c_dynnr STARTING AT 5 5 ENDING AT 80 8. IF gv_confirm = abap_true. cv_user = p_user. cv_pass = p_pass. ELSE. CLEAR: cv_user, cv_pass. ENDIF. CLEAR: p_url, p_user, p_pass. ENDMETHOD. METHOD on_screen_init. s_title = 'Login'. s_url = 'Repo URL'. s_user = 'User'. s_pass = 'Password or Token'. s_cmnt = 'Note'. ENDMETHOD. METHOD on_screen_output. DATA lt_ucomm TYPE TABLE OF sy-ucomm. ASSERT sy-dynnr = c_dynnr. LOOP AT SCREEN. IF screen-name = 'P_URL' OR screen-name = 'P_CMNT'. screen-input = '0'. screen-intensified = '1'. screen-display_3d = '0'. MODIFY SCREEN. ENDIF. IF screen-name = 'P_PASS'. screen-invisible = '1'. MODIFY SCREEN. ENDIF. ENDLOOP. " Program RSSYSTDB, GUI Status %_CSP PERFORM set_pf_status IN PROGRAM rsdbrunt IF FOUND. APPEND 'NONE' TO lt_ucomm. "Button Check APPEND 'SPOS' TO lt_ucomm. "Save as Variant CALL FUNCTION 'RS_SET_SELSCREEN_STATUS' EXPORTING p_status = sy-pfkey TABLES p_exclude = lt_ucomm. IF p_user IS NOT INITIAL. SET CURSOR FIELD 'P_PASS'. ENDIF. ENDMETHOD. METHOD on_screen_event. ASSERT sy-dynnr = c_dynnr. " CRET - F8 " OTHERS - simulate Enter press CASE iv_ucomm. WHEN 'CRET'. gv_confirm = abap_true. WHEN OTHERS. "TODO REFACTOR !!! A CLUTCH ! " This will work unless any new specific logic appear " for other commands. The problem is that the password dialog " does not have Enter event (or I don't know how to activate it ;) " so Enter issues previous command from previous screen " But for now this works :) Fortunately Esc produces another flow gv_confirm = abap_true. LEAVE TO SCREEN 0. ENDCASE. ENDMETHOD. METHOD enrich_title_by_hostname. DATA lv_host TYPE string. FIND REGEX 'https?://([^/^:]*)' IN iv_repo_url SUBMATCHES lv_host. IF lv_host IS NOT INITIAL AND lv_host <> space. CLEAR s_title. CONCATENATE 'Login:' lv_host INTO s_title IN CHARACTER MODE SEPARATED BY space. ENDIF. ENDMETHOD. ENDCLASS.
Add comment to password popup (#4910)
Dialogs: Add comment to password popup (#4910) Temporarily, adding a comment to the password popup regarding Github login. To be removed end of 2021 https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ Closes #4909
ABAP
mit
sbcgua/abapGit,sbcgua/abapGit,larshp/abapGit,larshp/abapGit
38353bfac6437509951e25cfcf1b66086cd1c374
src/frontend/zags_start.prog.abap
src/frontend/zags_start.prog.abap
REPORT zags_start. START-OF-SELECTION. PERFORM run. FORM run. DATA: lv_url TYPE string. * misuse the BSP runtime to construct SICF url cl_bsp_runtime=>construct_bsp_url( EXPORTING in_application = 'foobar' IMPORTING out_abs_url = lv_url ). REPLACE FIRST OCCURRENCE OF 'sap/bc/bsp/sap/foobar' IN lv_url WITH 'sap/zabapgitserver'. cl_gui_frontend_services=>execute( EXPORTING document = lv_url EXCEPTIONS cntl_error = 1 error_no_gui = 2 bad_parameter = 3 file_not_found = 4 path_not_found = 5 file_extension_unknown = 6 error_execute_failed = 7 synchronous_failed = 8 not_supported_by_gui = 9 OTHERS = 10 ). IF sy-subrc <> 0. WRITE: / 'Error when calling frontend services:', sy-subrc. ENDIF. ENDFORM.
REPORT zags_start. START-OF-SELECTION. PERFORM run. FORM run. DATA: lv_url TYPE string, lv_urlc TYPE c LENGTH 2048, lo_viewer TYPE REF TO cl_gui_html_viewer, lo_empty TYPE REF TO cl_gui_container. * misuse the BSP runtime to construct SICF url cl_bsp_runtime=>construct_bsp_url( EXPORTING in_application = 'foobar' IMPORTING out_abs_url = lv_url ). REPLACE FIRST OCCURRENCE OF 'sap/bc/bsp/sap/foobar' IN lv_url WITH 'sap/zabapgitserver'. CREATE OBJECT lo_viewer EXPORTING parent = lo_empty. lv_urlc = lv_url. lo_viewer->detach_url_in_browser( lv_urlc ). cl_gui_cfw=>flush( ). ENDFORM.
fix for SSO
fix for SSO
ABAP
mit
larshp/abapGitServer,larshp/abapGitServer

No dataset card yet

New: Create and edit this dataset card directly on the website!

Contribute a Dataset Card
Downloads last month
2
Add dataset card