Skip to Content
0
Former Member
Jul 18, 2013 at 06:25 AM

OCA button is not deleting the record from list

35 Views

Hi,

I am working on issue which is when i am clicking on OCA button in Contact History, item is not deleting, below code i have written, can you please help me on this.

CALL METHOD cl_thtmlb_util=>get_event_info
EXPORTING
iv_event = htmlb_event_ex
IMPORTING
ev_index = lv_index.
CHECK lv_index IS NOT INITIAL.

me->typed_context->builinteracthist->collection_wrapper->find( iv_index = lv_index ).
lr_current ?= typed_context->builinteracthist->collection_wrapper->get_current( ).
lr_entity ?= lr_current.


SPLIT htmlb_event_ex->event_defined AT '.' INTO lv_event lv_indx.
CASE lv_event.
WHEN 'DELETE' .
DATA: ls_inthist TYPE CRMT_BUPA_IL_INT_HISTORY ,
lr_inthist TYPE REF TO cl_crm_bol_entity.
lr_core = cl_crm_bol_core=>get_instance( ).

lr_current->get_properties( IMPORTING es_attributes = ls_inthist ).
lr_inthist = lr_core->get_root_entity( iv_object_name = 'BTOrder'
iv_object_guid = ls_inthist-guid ).

* Lock the activity. if locking fails nothing happens
TRY.
IF lr_inthist->is_locked( ) = abap_false.
CALL METHOD lock_dependent_entity
EXPORTING
ir_entity = lr_inthist
RECEIVING
rv_success = lv_success
EXCEPTIONS
entity_deleted = 1
OTHERS = 2.

IF sy-subrc NE 0 OR lv_success = abap_false.
EXIT.
ENDIF.
ENDIF.
CATCH cx_bol_exception cx_sy_ref_is_initial cx_sy_no_handler.
ENDTRY.


** Lock the entity if locking fails nothing happens
IF lr_entity->is_locked( ) = abap_false.
CALL METHOD lock_dependent_entity
EXPORTING
ir_entity = lr_entity
RECEIVING
rv_success = lv_success
EXCEPTIONS
entity_deleted = 1
OTHERS = 2.

IF sy-subrc NE 0 OR lv_success = abap_false.
EXIT.
ENDIF.
ENDIF.

if lr_entity->lock( ) = abap_true.
lr_customer_h_coll ?= lr_inthist->get_related_entities_by_bpath( iv_bpath_statement = './BTOrderHeader/BTHeaderCustExt/*' ).
lr_customer_h_ent ?= lr_customer_h_coll->get_current( ).
if lr_customer_h_ent is bound.

lr_core = cl_crm_bol_core=>get_instance( ).

if lr_core is bound.
lr_tx = lr_inthist->get_transaction( ).
lr_core->modify( ).
if lr_tx->save( ) = abap_true.
lr_tx->commit( ).
else.
lr_tx->rollback( ).
endif.
endif.

* lr_entity->reread( ). "exvneela change on 17-7-2013
me->typed_context->builinteracthist->collection_wrapper->remove( lr_current ). "exvneela change on 17-7-2013
me->typed_context->builinteracthist->collection_wrapper->publish_current( ).

endif.

Regards,

Neelam