Header Ads

Creation of Hyperlinks to navigate dynamically on Web UI


If there is a requirement of creating hyperlinks to navigate to a particular business object like Contact, Product using a hyperlink on the Web UI, it can be achieved this way.

Creation of Hyperlink

Create the 'Hyperlink' for the screen attribute that needs to be used for navigation by implementing following code snippet in the GET_P method
  CASE iv_property.
    WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
      rv_value = cl_bsp_dlc_view_descriptor=>field_type_event_link.
    WHEN if_bsp_wd_model_setter_getter=>fp_onclick.
      rv_value = 'NAVIGATE_TO_TARGET'.
  ENDCASE.

Navigation to Target Object

Create an event handler(EH_ONNAVIGATE_TO_TARGET) with the same name as specified in the GET_P method.
In the event handler implement the following code to navigate dynamically.
 DATA:     lr_desc_object         TYPE REF TO if_bol_bo_property_access,
                  lr_data_collection  TYPE REF TO if_bol_bo_col,
                  lr_nav                       TYPE REF TO if_crm_ui_navigation_service,
                  lr_entity                    TYPE REF TO cl_crm_bol_entity,
                  lr_core                     TYPE REF TO cl_crm_bol_core,
                  lv_guid                     TYPE crm_mktgs_guid.
 *   Pass the GUID of the Object to be navigated
      lv_guid = '467185D10C2E1E58E10000000A42145A'.
*     Get the BOL Core Instance
      lr_core ?= cl_crm_bol_core=>get_instance( ).
*     Get the Root entity
      lr_entity ?= lr_core->get_root_entity( iv_object_name =  'Trade'
                                                                        iv_object_guid = lv_guid  ).
      CHECK lr_entity IS BOUND.
*    Create UI based Entity
      CALL METHOD cl_crm_ui_descriptor_obj_srv=>CREATE_entity_BASED
        EXPORTING
          ir_entity           = lr_entity
          iv_ui_object_type   = 'TPM_TRADEPROMOTION'
          iv_ui_object_action = 'B'            "display
        RECEIVING
          rr_result           = lr_desc_object.
*      Create a BOL collection to be passed to the inbound plug of
*      the Called component
      CREATE OBJECT lr_data_collection
        TYPE
          cl_crm_bol_bo_col.
*    Add the UI Descriptor the BOL Collection
      lr_data_collection->add( lr_desc_object ).
*    Get Instance of Navigation Service
      lr_nav = cl_crm_ui_navigation_service=>get_instance( ).
*    Navigate to Target Component
      IF lr_nav->is_dynamic_nav_supported( lr_desc_object ) = abap_true.
        lr_nav->navigate_dynamically( lr_data_collection ).
      ENDIF.
The BOL entity name for the Target name to be navigated can be retrieved from 
 TCODE GENIL_MODEL_BROWSER. For example 'BTOrder' is the Order entity name.The UI Object name can be identified using TCODE BSP_DLC_SDESIGN.
Powered by Blogger.