Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
faisal_pc
Active Contributor

Hi All,

I saw a couple of posts related to dynamic navigation already. However, I felt of writing this since there are still many questions arise on the same.

Let us try a simple dynamic navigation where I will be taken to an opportunity details when I click on the number/name(In my case I give number) of the opportunity.

Step 1: Create a custom field in the opportunity header by AET with name Reference oppt. Here, user is going to give a reference opportunity ID. It's an independent reference opportunity ID and not created as a followup.

GET_P of the field:

CASE iv_property.
     WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
       IF iv_display_mode EQ abap_true.
         rv_value = cl_bsp_dlc_view_descriptor=>field_type_event_link.
       ELSE.
         rv_value = cl_bsp_dlc_view_descriptor=>field_type_input.
       ENDIF.
     WHEN if_bsp_wd_model_setter_getter=>fp_onclick.
       rv_value = 'toref'.
   ENDCASE.

Step 2: Now the field is available in the opportunity as a hyperlink when in display mode.

Step 3: Next step is to create an event handler for this. Create an event called 'TOREF'.

Step 4: Write following code in event handler.

DATA: lr_entity      TYPE REF TO cl_crm_bol_entity,
           lr_col         TYPE REF TO cl_crm_bol_bo_col,
           ls_attributes  TYPE crmt_bsp_opportunity_bp ,
           lv_object_guid TYPE crmt_genil_object_guid,
           lr_core        TYPE REF TO cl_crm_bol_core,
           lr_entity_bt   TYPE REF TO cl_crm_bol_entity,
           lr_nav_serv    TYPE REF TO if_crm_ui_navigation_service,
           lr_nav_descr   TYPE REF TO if_bol_bo_property_access,
           lv_opportid    TYPE CRMT_DOC_FLOW_ID_WRK.

     CONSTANTS:
         lc_ui_action   TYPE crmt_ui_actions VALUE 'B'. "Display

     lr_entity ?= me->typed_context->btopporth->collection_wrapper->get_current( ).

     CHECK lr_entity IS BOUND.
     lr_entity->get_property_as_value( EXPORTING iv_attr_name = 'Z_FIELD'
                                       IMPORTING ev_result    lv_opportid ).

     lr_core = cl_crm_bol_core=>get_instance( ).

* Get the corresponding GUID of the ID with your code and assign to lv_object_guid.

     lr_entity_bt = lr_core->get_root_entity( iv_object_name = 'BTOrder'
                                              iv_object_guid lv_object_guid ).
     IF lr_entity_bt IS BOUND.
       CREATE OBJECT lr_col.
       lr_col->if_bol_bo_col~add( lr_entity_bt ).
     ENDIF.

* Depends on the view, give the right object id.

     cl_crm_ui_descriptor_obj_srv=>create_ui_object_based(
              EXPORTING iv_component        = 'BT111H_OPPT'
                        iv_ui_object_type   = 'BT111_OPPT'
                        iv_ui_object_action = 'B'               "Display mode.
              RECEIVING rr_result           = lr_nav_descr ).

     lr_nav_serv = cl_crm_ui_navigation_service=>get_instance( ).

* check if navigation is possible
     IF lr_nav_serv->is_dynamic_nav_supported( ir_descriptor_object = lr_nav_descr ) = abap_true.
       lr_col->if_bol_bo_col~insert( iv_bo    = lr_nav_descr
                                       iv_index = 1 ).
*   start the navigation
       lr_nav_serv->navigate_dynamically( iv_data_collection = lr_col ).
     ENDIF.


Step 5: By this much, the main part is done. Only thing left is to maintain the navigation bar profile values in SPRO.

Go to tcode:CRMS_UI_TLINK to get the target ID. Take the opportunity details and get the right target ID.

In our case we are taking the display. Hence choose TBT111MOV.

Step 6: Maintain SPRO values.

Take define navigation bar profile.

Take the navigation bar profile of you and maintain the values.

You are done with all the steps now. Go to your opportunity and see it's navigating to the correpsonding opportunity. Please let me know if in case of any doubts.

Thanks,

Faisal

1 Comment
Labels in this area