Skip to Content
0
Nov 06, 2012 at 08:36 AM

Delete the opportunity not working

29 Views

Hi all,

I have added the Custom view in Account page where I am displaying the opportunity data.

I have added the actions also in that , like Change and Delete here Change is working good. But When I delete the opportunity after save, again that is displaying in the list.

When I save it is going to ON_NEW_FOCUS where My data is coming and sit into the custom view.

Here is the code I wrote for DELETE.

WHEN 'DELETE'.

DATA: ls_opportunity TYPE crmt_bsp_opportunity_bp,

lr_opportunity TYPE REF TO cl_crm_bol_entity.

lr_core = cl_crm_bol_core=>get_instance( ).

lr_current->get_properties( IMPORTING es_attributes = ls_opportunity ).

lr_opportunity = lr_core->get_root_entity( iv_object_name = 'BTOrder'

iv_object_guid = ls_opportunity-guid ).

* Lock the opportunity if locking fails nothing happens

IF lr_opportunity->is_locked( ) = abap_false.

IF lr_opportunity->lock( ) = abap_false.

RETURN.

ENDIF.

ENDIF.

* Lock the entity if locking fails nothing happens

IF lr_entity->is_locked( ) = abap_false.

IF lr_entity->lock( ) = abap_false.

RETURN.

ENDIF.

ENDIF.

lr_entity->delete( ).

lr_core->modify( ).

* IF deletion is not possible error message should be shown on UI or overview page

IF lr_entity->alive( ) = abap_true.

DATA: lr_msg_srv TYPE REF TO cl_bsp_wd_message_service,

lv_msg_v1 TYPE sy-msgv1.

lv_msg_v1 = ls_opportunity-object_id.

lr_msg_srv = me->view_manager->get_message_service( ).

lr_msg_srv->add_message( iv_msg_type = 'E'

iv_msg_id = 'CRM_UIU_BT'

iv_msg_number = '008'

iv_msg_v1 = lv_msg_v1 ).

IF 1 = 2. MESSAGE e008(crm_uiu_bt). ENDIF.

ELSE.

* Remove entity from collection wrapper

me->typed_context->zoppt->collection_wrapper->remove( lr_current ).

ENDIF.

Regards,

Ajay Ram

I