Wednesday, October 12, 2011

Deeplinking to SAP CRM Objects

Have you ever come across something in SAP CRM that calls an object using a deeplink?

A deeplink that looks something like the normal SAP CRM webclient URL, followed by some parameters like crm-object-type, crm-object-action and crm-object-value?

Have you ever wondered if this is something that could be useful?

Have you ever tried to find out how SAP knows that crm-object-type=BT126_CALL&crm-object-action=B should go to a certain screen?

Well, I have, and I will try to explain.

The first part is easy. Let's take crm-object-type=BT126_CALL&crm-object-action=B as an example.

Generic OP Mapping
In the navigation bar customizing, there is a node called Define Generic OP Mapping.
OP here stands for Outbound Plug. The generic OP mapping is used to map a UI object type to a TargetID or a Logical Link ID.

As this is mapped in the NavBar customizing, this means that the screen that will be determined by the deeplink, depends on the business role that is used.

So, in our example, in the navbar customizing, we look for an object named BT126_CALL and object action 'B', which apparently is 'Display'.

In this example, BT126_CALL:B is mapped to TargetID TBT110CALO.
So now, we need to find something that is called TBT110CALO.
We find this in table CRMC_UI_COMP_IP. Here, the target ID is mapped to a component, a window and an inbound plug.

So now we know how the object 'BT126_CALL:B' is mapped to an actual window, but there is more to find out. For instance, how does SAP find the right object using the crm-object-value parameter?

How the crm-object-value parameter is interpreted differs per object.

In table BSP_DLC_OBJ_TYPE, there is a mapping from the object type (for instance BT126_CALL) to a GENIL component (i.e. BT), a GENIL Object (BTOrder for instance) and a BOR object type (like BUS2000126).
If you want to add objects in this table, you should use bspc_dlc_obj_typ.

Each GENIL object is assigned a so called 'mapping class' in table CRMS_UI_OBJ_MAP.
If you want to add objects in this table, you should use CRMC_UI_OBJ_MAP.

Mapping Class
This class (in our example CL_CRM_UIU_BT_OBJ_MAPPER) contains an interface to CL_CRM_UIU_BT_OBJ_MAPPER, which hands us 5 classes.
The most important one of them in our context is GET_ENTITY_FROM_UI_OBJECT. This method is used to identify exactly one object.

The method has 4 importing parameters:
In our example, the class first tries to find the object assuming the key-value is the GUID of the order. If no object is found, it checks if key-name is supplied. If so, it uses the key-name together with the key-value to find the object using a dynamic query.
If successful, the object has been determined, and it can be passed to the window.

URL Parameters
So, how do we get the key-name into the equation?
During the intro, we missed one URL parameter that can also be used, called the 'crm-object-keyname'. This URL specifies the field that should be used in the GENIL dynamic query object to determine the right object.

If you want to know which fields are available in the search query, check the GENIL MODEL BROWSER for the object you have found in BSP_DLC_OBJ_TYPE, and the query object as stated in the mapping class you found in CRMS_UI_OBJ_MAP.

So, in the end, you can use the following parameters to deeplink:
  • crm-object-type: Determines the screen and the object
  • crm-object-action: Determines the screen
  • crm-object-value: Search criteria.
  • crm-object-keyname: Determines to which search criteria the value is passed
crm-object-keyname is in most cases optional, as the mapping class will most likely always determine a default in case the keyname it is not supplied.