Skip to Content

Disclaimer: All of the below is a personal experience and thoughts of the author. System behavior might be changed by SAP at any time. The author will try to update the document with any major changes SAP provides in the future.

There is quite usual requirement regarding WebUI: Can we open another window and start working in it from the place where we are right now? Can we just get a link to the business partner/activity/lead/campaign/sales order to quickly pass it to our colleagues through an e-mail or IM?

OSS Note 2135300 – Enable nav links to be opened within a new tab/window introduces an option to open SAP CRM links in WebUI in new tab or browser window.

Prerequisites.

Parameter LINK_CONTEXT_MENU has to be set to TRUE in PARAMETERS profile per business role. This feature should never be used in IC roles because they have their own separate options and logic for multi-sessions.

What it looks like.

When mentioned parameter is enabled in business role all links which support such navigation will have a standard context menu (right-click menu) with familiar options “Open in new tab” or “Open in new window” (“Open” menu item doesn’t work in this context). If any of the menu entries are chosen, a corresponding object will be opened in a new tab/window. Restrictions of a number of simultaneously opened tabs/windows may apply (e.g. number of sessions which is set using server profile parameter icm/HTTP/esid_max_ctx). There is also “Copy shortcut” entry and user can share the link to the object through whichever channel he or she wants.

Looks.png

How it works (some technical details and the place to dive in case of any issues).

If above mentioned parameter is in place, system tries to build an external navigation link using method GET_EXT_NAV_LINK of CL_CRM_UI_EXT_NAV_SERVICE class during creation of a link (in CL_THTLMB_LINK->RESOLVE_MODEL_BINDING).

System searches for UI object type, key and name of an object to build appropriate URL. The logic is:

  1. Get UI object type, key and name from current entity (or current line in case of a table)
  2. If this is a link inside an object (not SEARCH event raised) then an evaluation of the title takes place which means: run through passed collection from the model and try to find an entity with any attribute matching the text of the link (using method FIND_MATHCING_OBJECT for passed collection).
  3. If no UI object type found from step 1 OR matched object found from step 2 then an evaluation of relations takes place (using FIND_MATCHING_OBJECT for each relation). If only one related object exists for any relation, it is taken without check of matching text. For each matched object system tries to find UI object type, key and name. If object type is found then the evaluation stops.
  4. Finally if UI object type is known then system builds the URL.

In above algorithm appropriate mapping class is used to determine UI object type. This class is taken from tables CRMC_UI_OBJ_MAP and CRMS_UI_OBJ_MAP.

Some pitfalls and limitations.

1. Search results

Above algorithm is working fine in case of links inside an object.

In business partner search it also works because the result of dynamic query object BuilHeaderAdvancedSearch is a collection of BuilHeader objects. BuilHeader can be easily mapped to UI object type (maintained in tables BSPC_DL_OBJ_TYP and BSP_DLC_OBJ_TYP).

However, in case of business transactions searches it will, most likely, fail. For example, BTQAct (search of activities) and BTQCompl (search of complaints) have result collections as BTQRAct and BTQRCompl objects. For these types there are no direct entries in BSPC_DL_OBJ_TYP nor in BSP_DLC_OBJ_TYP.

Such result objects have relations (BTADVSAct and BTADVSCompl respectively) to BTOrder. Even so this relation won’t be considered by default because there is no relations filled in to consider on step 3 of the algorithm (with, for example, get_related_entities method).

Solution for this pitfall is:

– create a class (for example, ZCL_CRM_UIU_BT_OBJ_MAPPER_QR) as a successor of CL_CRM_UIU_BT_OBJ_MAPPER and redefine its method IF_CRM_UI_OBJ_MAPPER~DETERMINE_UI_OBJECT_OF_ENTITY with following code which will build relations table with objects references:


METHOD if_crm_ui_obj_mapper~determine_ui_object_of_entity.
  DATA: lr_bol_entity TYPE REF TO cl_crm_bol_entity.
" try to determine ui object type based on standard logic
    CALL METHOD super->if_crm_ui_obj_mapper~determine_ui_object_of_entity
      EXPORTING
        iv_entity         = iv_entity
      CHANGING
        cv_ui_object_type = cv_ui_object_type.
    IF cv_ui_object_type IS INITIAL.
      "if it's not possible - read related entities to fill in RELATIONS tab
      lr_bol_entity ?= iv_entity.
      DATA(lt_relations) = lr_bol_entity->retrieve_relations( ).
      IF lt_relations IS INITIAL.
        TRY.
            lr_bol_entity->get_related_entities( ). "fill relations tab, without objects
            lt_relations = lr_bol_entity->retrieve_relations( ).
            LOOP AT lt_relations ASSIGNING FIELD-SYMBOL(<fs_relation>).
               "run through each relation to get OBJECTS tab filled in
              lr_bol_entity->get_related_entities( iv_relation_name = <fs_relation>-relation_name
                                                   iv_mode = cl_crm_bol_entity=>bypassing_buffer ).
            ENDLOOP.
          CATCH cx_crm_genil_model_error.
        ENDTRY.
      ENDIF.
    ENDIF.
  ENDMETHOD.


– maintain appropriate entries in IMG -> CRM -> UI Framework -> Technical Role Definition -> Define Object Mapping (table CRMC_UI_OBJ_MAP).

Settings.PNG

2. Subobject links

Solution above will handle “main” link in result list correctly. For example, in business transaction search “main” link means an attribute rendered as a link which leads to business transaction navigation. However, there might be attributes with links to different objects such as Employee Responsible, Activity Partner, Contact Person etc. They won’t be rendered as expected (menu entries will open “main” object, e.g. business transaction, instead of corresponding business partner). Such situations should be considered separately.

3. Link title which is built dynamically

Due to the fact that FIND_MATCHING_OBJECT method works with link title and compares this title to GenIL attributes to find matching object, links which have title build dynamically (for example, in GET-method) will not provide possibility to open them in new tab/window.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply