cancel
Showing results for 
Search instead for 
Did you mean: 

Data-loss popup when navigating to new BT from Product display

Former Member
0 Kudos
451

On the product overview screen (component PRD01OV), we are creating a button to create a complaint.

The problem is that it is coming up with a data loss popup for the newly created BT. (The product is being displayed only).

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.

Accepted Solutions (1)

Accepted Solutions (1)

kapilpatil
Active Contributor
0 Kudos

Hello Martin,

If i understand your design expectation correctly, when you click on 'create complaint' button from product overview screen, you want to navigate to complaint creation overview screen. Then user should be able to save the complaint.

If above is true, then you can have a look at the way standard SAP does.

Component - BT120S_CPL

View - BT120S_CPL/AdvSearchComplRL

event handler - EH_ONNEW

You may no longer get data loss pop up.

Hope above helps.

Thanks,

Kapil

Former Member
0 Kudos

Hello Kapil,

Thanks for the suggestion. I had a look at how the navigation works there.

The difference is that the BT only gets created in an inbound plug in the window of the target component (BT120H_CPL/MainWindow), whereas I would like to create the BT before the time so I can prepopulate certain values (like the product) before passing it on to BT120H_CPL. (I looked at EH_ONSELECT as well, where you select an existing complaint from the search results, but I suppose because it is displayed, and there is no value loss popup, maybe it is different?)

What I am trying to achieve is more like the appointment creation from the CRM_CALENDAR component, where the BT is pre-populated with values before passing it on to the editing component. I have been looking at this, but cannot figure out what is different.

I have also looked at some similar scenarios where the entity is created before navigation, and the navigation takes place without an outbound plug, or so it seems.

I cannot figure out why my implementation is different.

Thanks,

Martin

Former Member
0 Kudos

I managed to resolve my issue, and I think it is particular to the product overview component (PRD01OV).

The only way to switch off the data loss popup is to call DO_CLEANUP_CONTEXT to deregister the method ON_BEFORE_WA_CONTENT_CHANGE as the change handler for event BEFORE_WORKAREA_CONTENT_CHANGE, because it is private.

Because DO_CLEANUP_CONTEXT, however, is also protected, the creation of the BT can happen only after calling DO_CLEANUP_CONTEXT, because it ends the GenIL transaction (which I think is what deletes the BT reference if you create it before).


Thus I have put the creation of the BT and navigation after a call to DO_CLEANUP_CONTEXT in an outbound plug on the window or alternatively create a public method that calls DO_CLEANUP_CONTEXT (which is preferable). This resolves the issue, although it complicates things unnecessarily.

Answers (0)