Created by Jerry Wang, last modified on Oct 10, 2014
假设需要删除第二个line item IP拥有的四个right scope:
执行report:
删除成功:
REPORT zassign_ip2.
PARAMETERS:
order TYPE crmd_orderadm_h-object_id OBLIGATORY DEFAULT '5600000010'.
DATA: lo_core TYPE REF TO cl_crm_bol_core,
lo_collection TYPE REF TO if_bol_entity_col,
lv_query_name TYPE crmt_ext_obj_name,
lt_selection_parameter TYPE genilt_selection_parameter_tab,
ls_selection_parameter TYPE genilt_selection_parameter,
lr_del_handler TYPE REF TO cl_crm_ipm_item_delete_handler,
ls_query_parameters TYPE genilt_query_parameters.
ls_selection_parameter-attr_name = 'OBJECTID'.
ls_selection_parameter-option = 'EQ'.
ls_selection_parameter-sign = 'I'.
ls_selection_parameter-low = order.
APPEND ls_selection_parameter TO lt_selection_parameter.
ls_query_parameters-max_hits = 1.
lv_query_name = 'BTAdvQueryAUI'.
lo_core = cl_crm_bol_core=>get_instance( ).
lo_core->load_component_set( 'BT' ).
lo_core->load_component_set( 'IPMRM' ).
lo_collection = lo_core->dquery(
iv_query_name = lv_query_name
it_selection_parameters = lt_selection_parameter
is_query_parameters = ls_query_parameters ).
DATA(lo_contract) = lo_collection->get_current( ).
CHECK lo_contract IS NOT INITIAL.
DATA: lr_item_handler TYPE REF TO cl_crm_ipm_item_handler.
CREATE OBJECT lr_item_handler EXPORTING iv_header_bol_entity = lo_contract.
DATA(ips) = lr_item_handler->get_all_ips( ).
DATA(second_ip) = ips->find( iv_index = 2 ).
CHECK second_ip IS NOT INITIAL.
DATA(ip_handler) = cl_crm_ipm_item_handler_provid=>get_instance( second_ip ).
DATA(scope_collection) = ip_handler->get_rights_scopes( second_ip ).
CHECK scope_collection IS NOT INITIAL.
DATA(ip) = cl_crm_ipm_order_item_entity=>get_instance( io_original = second_ip iv_ipm_admini_type = 'IP' ).
DATA(scope) = scope_collection->get_first( ).
WHILE scope IS NOT INITIAL.
DATA(wrapped) = cl_crm_ipm_order_item_entity=>get_instance( io_original = scope iv_ipm_admini_type = 'RIGHTSCOPE' ).
DATA(scope_handler) = cl_crm_ipm_item_handler_provid=>get_instance( wrapped ).
CREATE OBJECT lr_del_handler
EXPORTING
ir_item_handler = scope_handler.
lr_del_handler->delete_scope( ir_ip = ip
ir_item = wrapped ).
ip = cl_crm_ipm_order_item_entity=>get_instance( io_original = second_ip iv_ipm_admini_type = 'IP' ).
scope = scope_collection->get_next( ).
ENDWHILE.
lo_core->modify( ).
DATA(lo_transaction) = lo_core->get_transaction( ).
CHECK lo_transaction->check_save_possible( ) = abap_true.
CHECK lo_transaction->save( ) = abap_true.
lo_transaction->commit( ).
WRITE: / 'IP Right scope deleted successfully!'.