IBASE component deletion
Created by Jerry Wang, last modified on Oct 18, 2014
在使用FM CRM_IBASE_COMP_DELETE刪除一個IBASE component時(使用下列report 測試),
?
?
?
通過ST05 trace能發現component deletion不包含物理的Database 刪除動作,僅僅是把相關的IBASE數據的valid to time stamp設置成deletion時的time stamp。
?
?
?
刪除后在tcode IB52里無法再找到component 110059:
?
?
?
只有在tcode IB53里將valid on的時間設置成deletion之前的時間,
?
?
?
才能看到被刪除的component 信息:
?
?
?
?
?
PARAMETERS: txt TYPE char40 OBLIGATORY DEFAULT 'description test',
?
? ? ? ? ? ? eid TYPE char30 OBLIGATORY DEFAULT 'PROGRAM',
?
? ? ? ? ? ? oid TYPE comm_product-product_id OBLIGATORY DEFAULT 'CHILDOB8',
?
? ? ? ? ? ? fam TYPE comm_product-object_family OBLIGATORY DEFAULT '0401',
?
? ? ? ? ? ? cat TYPE comt_category_id OBLIGATORY DEFAULT 'OBJ_0401'.
?
?
DATA: lt_param ? ? ? ?TYPE crmt_name_value_pair_tab,
?
? ? ? ls_param ? ? ? ?TYPE crmt_name_value_pair,
?
? ? ? lr_core ? ? ? ? TYPE REF TO cl_crm_bol_core,
?
? ? ? ls_object ? ? ? TYPE comm_product,
?
? ? ? lr_root ? ? ? ? TYPE REF TO if_bol_entity_col,
?
? ? ? ls_comp_det ? ? TYPE ibap_comp2,
?
? ? ? ls_comp_det_upd TYPE ibap_comp3,
?
? ? ? entity ? ? ? ? ?TYPE REF TO cl_crm_bol_entity.
?
?
CHECK zcl_object_generator=>create_object( iv_id = oid iv_family = fam iv_catid = cat ) = abap_true.
?
?
ls_param-name ?= cl_crm_ibase_il_constant=>createparam.
?
ls_param-value = '01'.
?
APPEND ls_param TO lt_param.
?
?
lr_core = cl_crm_bol_core=>get_instance( ).
?
lr_core->load_component_set('IBASE_ONLY').
?
?
CALL METHOD lr_core->root_create
?
? EXPORTING
?
? ? iv_object_name ?= cl_crm_ibase_il_constant=>root_object
?
? ? iv_create_param = lt_param
?
? ? iv_number ? ? ? = 1
?
? RECEIVING
?
? ? rv_result ? ? ? = lr_root.
?
?
CHECK lr_root IS BOUND.
?
entity ?= lr_root->get_current( ).
?
?
CHECK entity IS BOUND.
?
IF entity->lock( ) = abap_true.
?
? entity->switch_to_change_mode( ).
?
ENDIF.
?
?
entity->set_property_as_string( iv_attr_name = 'DESCR' iv_value = CONV #( txt ) ).
?
entity->set_property_as_string( iv_attr_name = 'EXTID' iv_value = CONV #( eid ) ).
?
?
lr_core->modify( ).
?
DATA(lv_ibase_id) = entity->get_property_as_string( 'IBASE' ).
?
?
DATA(component) = entity->create_related_entity( 'FirstLevelComponent' ).
?
?
CHECK component IS NOT INITIAL.
?
?
DATA(obj_comp) = component->create_related_entity( 'IBCompObj').
?
?
CHECK obj_comp IS NOT INITIAL.
?
?
obj_comp->set_property_as_string( iv_attr_name = 'OBJECT_ID' iv_value = CONV #( oid ) ).
?
?
SELECT SINGLE * INTO ls_object FROM comm_product WHERE product_id = oid.
?
ASSERT sy-subrc = 0.
?
?
obj_comp->set_property_as_string( iv_attr_name = 'OBJECT_GUID' iv_value = CONV #( ls_object-product_guid ) ).
?
obj_comp->set_property_as_string( iv_attr_name = 'OBJECT_FAMILY' iv_value = CONV #( ls_object-product_guid ) ).
?
obj_comp->set_property_as_string( iv_attr_name = 'DESCR_EXT' iv_value = 'Jerry12345' ).
?
lr_core->modify( ).
?
?
DATA(lo_message_container) = entity->get_message_container( ).
?
CALL METHOD lo_message_container->get_messages
?
? EXPORTING
?
? ? iv_message_type = if_genil_message_container=>mt_all
?
? IMPORTING
?
? ? et_messages ? ? = DATA(lt_msg1).
?
LOOP AT lt_msg1 ASSIGNING FIELD-SYMBOL(<msg1>).
?
? WRITE:/ <msg1>-message COLOR COL_NEGATIVE.
?
ENDLOOP.
?
?
CHECK lt_msg1 IS INITIAL.
?
?
DATA(lo_transaction) = lr_core->get_transaction( ).
?
DATA(lv_changed) = lo_transaction->check_save_needed( ).
?
?
CHECK lv_changed EQ abap_true.
?
?
DATA: ls_header ? ?TYPE ibap_head1,
?
? ? ? lt_struc_tab TYPE ibap_struc1_tab,
?
? ? ? ls_comp ? ? ?TYPE ibap_dat1.
?
?
ls_header-ibase = lv_ibase_id.
?
CALL FUNCTION 'CRM_IBASE_GET_DETAIL'
?
? EXPORTING
?
? ? i_ibase_head ? ? ?= ls_header
?
? IMPORTING
?
? ? e_struc_ibase_tab = lt_struc_tab
?
? EXCEPTIONS
?
? ? not_specified ? ? = 1
?
? ? doesnt_exist ? ? ?= 2
?
? ? no_authority ? ? ?= 3.
?
?
CHECK sy-subrc = 0.
?
?
READ TABLE lt_struc_tab ASSIGNING FIELD-SYMBOL(<line>) INDEX 1.
?
ls_comp-instance = <line>-instance.
?
?
CALL FUNCTION 'CRM_IBASE_COMP_GET_DETAIL'
?
? EXPORTING
?
? ? i_comp ? ? ? ? ? = ls_comp
?
? ? i_date ? ? ? ? ? = sy-datlo
?
? ? i_time ? ? ? ? ? = sy-timlo
?
? ? iv_do_auth_check = 'X'
?
? IMPORTING
?
? ? e_comp_det ? ? ? = ls_comp_det
?
? EXCEPTIONS
?
? ? not_specified ? ?= 1
?
? ? doesnt_exist ? ? = 2
?
? ? no_authority ? ? = 3
?
? ? OTHERS ? ? ? ? ? = 4.
?
?
MOVE-CORRESPONDING ls_comp_det TO ls_comp_det_upd.
?
ls_comp_det_upd-deviceid ? ?= '1'.
?
ls_comp_det_upd-descr ? ? ? = '2'.
?
?
CALL FUNCTION 'CRM_IBASE_COMP_CHANGE'
?
? EXPORTING
?
? ? i_comp ? ? ? ? ? ? ?= ls_comp
?
? ? i_comp_det ? ? ? ? ?= ls_comp_det_upd
?
? EXCEPTIONS
?
? ? data_not_consistent = 1
?
? ? ibase_locked ? ? ? ?= 2
?
? ? not_succesful ? ? ? = 3
?
? ? no_authority ? ? ? ?= 4
?
? ? OTHERS ? ? ? ? ? ? ?= 5.
?
ASSERT sy-subrc = 0.
?
?
DATA(lv_success) = lo_transaction->save( ).
?
?
DATA(lo_glb_msg_cont) = lr_core->get_global_message_cont( ).
?
CALL METHOD lo_glb_msg_cont->if_genil_message_container~get_messages
?
? EXPORTING
?
? ? iv_message_type = if_genil_message_container=>mt_all
?
? IMPORTING
?
? ? et_messages ? ? = DATA(lt_msg).
?
LOOP AT lt_msg ASSIGNING FIELD-SYMBOL(<msg>).
?
? WRITE:/ <msg>-message.
?
ENDLOOP.
?
?
IF lv_success = abap_true.
?
? lo_transaction->commit( ).
?
? WRITE:/ 'IBASE Created Successfully: ', lv_ibase_id COLOR COL_NEGATIVE.
?
ELSE.
?
? lo_transaction->rollback( ).
?
ENDIF.
?
?
?
CALL FUNCTION 'CRM_IBASE_COMP_DELETE'
?
? EXPORTING
?
? ? i_comp ? ? ? ? ? ? ?= ls_comp
?
? EXCEPTIONS
?
? ? data_not_consistent = 1
?
? ? ibase_locked ? ? ? ?= 2
?
? ? not_succesful ? ? ? = 3
?
? ? no_authority ? ? ? ?= 4.
?
?
ASSERT sy-subrc = 0.
?
?
CALL FUNCTION 'CRM_IBASE_SAVE'.
?
?
COMMIT WORK AND WAIT.
?
?
CALL FUNCTION 'CRM_IBASE_COMP_GET_DETAIL'
?
? EXPORTING
?
? ? i_comp ? ? ? ? ? = ls_comp
?
? ? i_date ? ? ? ? ? = sy-datlo
?
? ? i_time ? ? ? ? ? = sy-timlo
?
? ? iv_do_auth_check = 'X'
?
? IMPORTING
?
? ? e_comp_det ? ? ? = ls_comp_det
?
? EXCEPTIONS
?
? ? not_specified ? ?= 1
?
? ? doesnt_exist ? ? = 2
?
? ? no_authority ? ? = 3
?
? ? OTHERS ? ? ? ? ? = 4.
?
?
IF sy-subrc = 2.
?
? WRITE: / 'Component does not exist:' , ls_comp-instance COLOR COL_NEGATIVE.
?
ELSE.
?
? WRITE: / 'Detail returned:' , ls_comp_det-instance COLOR COL_POSITIVE.
?
ENDIF.
?
總結
以上是生活随笔為你收集整理的IBASE component deletion的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: IBASE change related
- 下一篇: 【IT之家开箱】耕升RTX4070踏雪开