abapGit/src/objects/zcl_abapgit_object_pers.clas.abap
Marc Bernard 20c1dc0bda
Remove obsolete late_deser from metadata (#4116)
The field `late_deser` in `ZIF_ABAPGIT_DEFINITIONS=>ty_metadata` is obsolete:

```abap
  TYPES:
    BEGIN OF ty_metadata,
      class        TYPE string,
      version      TYPE string,
      late_deser   TYPE abap_bool, " refactor: can be removed later. replaced by steps
      delete_tadir TYPE abap_bool,
      ddic         TYPE abap_bool,
    END OF ty_metadata .
```

The PR removes the remaining usage with one exception: `ZCL_ABAPGIT_OBJECTS_BRIDGE->GET_DESERIALIZE_STEPS` still depends on the field. In order to remove it completely, the plug-in interface `zif_abapgitp_plugin` (https://github.com/abapGit/abapGit-Plugins/blob/master/src/zif_abapgitp_plugin.intf.abap) will have to be changed.

Co-authored-by: Lars Hvam <larshp@hotmail.com>
2020-11-02 09:30:55 +01:00

239 lines
5.7 KiB
ABAP

CLASS zcl_abapgit_object_pers DEFINITION PUBLIC INHERITING FROM zcl_abapgit_objects_super FINAL.
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.
TYPES:
BEGIN OF ty_personalization_object,
pers_reg TYPE spers_reg,
pers_reg_text TYPE spers_regt,
END OF ty_personalization_object.
DATA:
mv_pers_key TYPE spers_key.
METHODS:
get_personalization_object
IMPORTING
iv_create TYPE abap_bool OPTIONAL
iv_view_only TYPE abap_bool OPTIONAL
RETURNING
VALUE(ro_personalization_object) TYPE REF TO cl_pers_reg
RAISING
zcx_abapgit_exception.
ENDCLASS.
CLASS zcl_abapgit_object_pers IMPLEMENTATION.
METHOD constructor.
super->constructor( is_item = is_item
iv_language = iv_language ).
mv_pers_key = ms_item-obj_name.
ENDMETHOD.
METHOD get_personalization_object.
CREATE OBJECT ro_personalization_object
EXPORTING
p_create = iv_create
p_pers_key = mv_pers_key
p_view_only = iv_view_only
EXCEPTIONS
pers_key_already_exists = 1
pers_key_does_not_exist = 2
transport_view_only = 3
transport_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
zcx_abapgit_exception=>raise_t100( ).
ENDIF.
ENDMETHOD.
METHOD zif_abapgit_object~changed_by.
rv_user = c_user_unknown.
ENDMETHOD.
METHOD zif_abapgit_object~delete.
DATA: lo_personalization_object TYPE REF TO cl_pers_reg.
lo_personalization_object = get_personalization_object( ).
lo_personalization_object->delete(
EXPORTING
p_no_confirm = abap_true
EXCEPTIONS
deletion_canceled = 1
deletion_failed = 2
transport_canceled = 3
OTHERS = 4 ).
IF sy-subrc <> 0.
zcx_abapgit_exception=>raise_t100( ).
ENDIF.
ENDMETHOD.
METHOD zif_abapgit_object~deserialize.
DATA:
ls_personalization_object TYPE ty_personalization_object,
lo_personalization_object TYPE REF TO cl_pers_reg.
io_xml->read(
EXPORTING
iv_name = 'PERS'
CHANGING
cg_data = ls_personalization_object ).
tadir_insert( iv_package ).
lo_personalization_object = get_personalization_object( iv_create = abap_true ).
lo_personalization_object->set_reg_data(
p_pers_reg = ls_personalization_object-pers_reg
p_pers_reg_text = ls_personalization_object-pers_reg_text ).
lo_personalization_object->save(
EXPORTING
no_check = abap_true
EXCEPTIONS
data_not_saved = 1
transport_canceled = 2
OTHERS = 3 ).
IF sy-subrc <> 0.
zcx_abapgit_exception=>raise_t100( ).
ENDIF.
ENDMETHOD.
METHOD zif_abapgit_object~exists.
cl_pers_reg=>exists(
EXPORTING
p_pers_key = mv_pers_key
EXCEPTIONS
pers_key_does_not_exist = 1
OTHERS = 2 ).
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-late 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.
" There's no object specific locking. Just a global one.
rv_is_locked = exists_a_lock_entry_for( iv_lock_object = 'E_SPERSREG' ).
ENDMETHOD.
METHOD zif_abapgit_object~jump.
DATA: ls_bcdata TYPE bdcdata,
lt_bcdata TYPE STANDARD TABLE OF bdcdata.
ls_bcdata-program = 'SAPLSPERS_REG_DIALOG'.
ls_bcdata-dynpro = '0100'.
ls_bcdata-dynbegin = 'X'.
APPEND ls_bcdata TO lt_bcdata.
CLEAR ls_bcdata.
ls_bcdata-fnam = 'SPERS_REG-PERS_KEY'.
ls_bcdata-fval = ms_item-obj_name.
APPEND ls_bcdata TO lt_bcdata.
CLEAR ls_bcdata.
ls_bcdata-fnam = 'BDC_OKCODE'.
ls_bcdata-fval = '=PERSDISPLAY'.
APPEND ls_bcdata TO lt_bcdata.
CALL FUNCTION 'ABAP4_CALL_TRANSACTION'
STARTING NEW TASK 'GIT'
EXPORTING
tcode = 'PERSREG'
mode_val = 'E'
TABLES
using_tab = lt_bcdata
EXCEPTIONS
call_transaction_denied = 1
tcode_invalid = 2
OTHERS = 3.
IF sy-subrc <> 0.
zcx_abapgit_exception=>raise( |error from ABAP4_CALL_TRANSACTION, PERSREG. SUBRC= { sy-subrc }| ).
ENDIF.
ENDMETHOD.
METHOD zif_abapgit_object~serialize.
DATA:
lo_personalization_object TYPE REF TO cl_pers_reg,
ls_personalization_object TYPE ty_personalization_object.
lo_personalization_object = get_personalization_object( iv_view_only = abap_true ).
lo_personalization_object->get_reg_data(
IMPORTING
p_pers_reg = ls_personalization_object-pers_reg
p_pers_reg_text = ls_personalization_object-pers_reg_text ).
CLEAR:
ls_personalization_object-pers_reg-author,
ls_personalization_object-pers_reg-fdate,
ls_personalization_object-pers_reg-ftime.
io_xml->add( iv_name = 'PERS'
ig_data = ls_personalization_object ).
ENDMETHOD.
ENDCLASS.