On the product overview screen (component PRD01OV), we are creating a button to create a complaint.
Everything works fine so far, except that when navigating to the complaint, a data loss popup comes up. If I click Yes to save, it saves the complaint even before the user gets to edit it. If I click no, it gives a BSP error with "Access Previously Deleted Entity".
I am creating a new BT and then the navigation descriptor using CL_CRM_UI_DESCRIPTOR_OBJ_SRV=>CREATE_ENTITY_BASED in the outbound plug on the view, then calling the outbound plug on the window, as per the examples I have seen, where I fire the outbound plug, passing the collection containing the navigation descriptor.
When I suppress the data loss popup by deregistering the event handler method, it also gives the error "Access Previously Deleted Entity".
Here is my code for the view outbound plug:
data(lr_core) = cl_crm_bol_core=>get_instance( ).
lr_core->load_component( 'BT' ). "Should already be loaded in our scenario
data(lr_fac) = lr_core->get_entity_factory( iv_entity_name = 'BTOrder' ).
data(lr_complaint) = lr_fac->create( iv_params = value crmt_name_value_pair_tab( ( name = 'PROCESS_TYPE' value = 'ZDCP' ) ) ).
data(lr_nav_descr) = cl_crm_ui_descriptor_obj_srv=>create_entity_based( iv_ui_object_action = 'C' ir_entity = lr_complaint ).
data(lr_navigation) = cl_crm_ui_navigation_service=>get_instance( ).
if lr_navigation->is_dynamic_nav_supported( lr_nav_descr ) ne abap_true.
return. "entity does not support a dynamic navigation
else.
data(lr_col) = new cl_crm_bol_bo_col( ).
lr_col->if_bol_bo_col~add( iv_entity = lr_nav_descr ).
lr_navigation->navigate_dynamically( lr_col ).
data(lr_window) = me->view_manager->get_window_controller( ).
lr_window->call_outbound_plug( iv_outbound_plug = 'TO_NEWREPREQ' iv_data_collection = lr_col ).
endif.