Deeplinking to SAP CRM Objects

download Deeplinking to SAP CRM Objects

of 3

description

link in alert

Transcript of Deeplinking to SAP CRM Objects

Deeplinking to SAP CRM ObjectsHave you ever come across something inSAP CRMthat 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 takecrm-object-type=BT126_CALL&crm-object-action=Bas an example.

Generic OP MappingIn the navigation bar customizing, there is a node calledDefine Generic OP Mapping.OP here stands for Outbound Plug. The generic OP mapping is used tomapa UI object type to a TargetID or a LogicalLinkID.

As this is mapped in theNavBarcustomizing, this means that the screen that will be determined by the deeplink, depends on thebusinessrole 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'.

CRMC_UI_COMP_IPIn 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 ismoreto find out. For instance, how does SAP find the right object using thecrm-object-valueparameter?

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

BSP_DLC_OBJ_TYPEIn table BSP_DLC_OBJ_TYPE, there is a mapping from the object type (for instanceBT126_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.

CRMS_UI_OBJ_MAPEach 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 ClassThis class (in our example CL_CRM_UIU_BT_OBJ_MAPPER) contains aninterfaceto 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: IV_UI_OBJECT_TYPE IV_OBJECT_NAME IV_ENTITY_KEY_VALUE IV_ENTITY_KEY_NAMEIn 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 ParametersSo, 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 inBSP_DLC_OBJ_TYPE, and the query object as stated in the mapping class you found inCRMS_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 passedcrm-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.Alert notification email with deeplink to a CRM objectAs you probably already know you can use theactionframework to send alerts to users when certain defined events occur. For example to notify the person responsible one week before the validitydateof a quotation is reached, or when a new task is assigned to a user by someone else.

By default the user who receives thealertalso receives a notification email. If, after reading it, he wants to take action, he needs to open his web browser, startSAP CRM, log in, search for the alert in the open alert list, open it andclickon thelinkto navigate to the CRM object. Many steps areneededhere and many users dont see much added value from this notification email and turn it off via Worklist > Personalize Alerts.

But what if we can add a url link to the notificationemailso that the user can directly jump to the CRM object the alert is about and he only needs to enter his username and pass to login?

Lets see how we can do this.

Step 1 - Customize action and alertFirst, you do all the necessary customizing in the action profile and define an alertcategoryto successfully send the alert. You have also maintained a long text as demonstrated in the example below.

Step 2 Define urlSecond, we go to the tab Optional Subseq. Activities. Here we define the url todeeplinkto our CRM object. It consists of a part to start the CRM webUI followed by several startup parameters. I will not discuss these parameters in detail here. Please refer to our previous blogDeeplinking to SAP CRM Objectsformoreinformation.

Some of these parameter values are fixed, but others are dynamic. There are of course different SAP CRM environments to navigate to and each object is uniquely identified by a GUID. We fill these variables later, but for now we need to define placeholders for them.Makesure the placeholders are at least as long as the values that are filled later, otherwise wecloud lose some text fragments.

In our example we link to a task so therefore the value BT125_TASK for crm-object-type. We added placeholders for the CRM hostname, crm object value (GUID), sap client and language.

Step 3 Implement BAdIWe now need to create an implementation for BAdI ALERT_MODIFY_TEXT. In this BAdI we can replace our placeholders with the real values. Go to SE19, create the BAdI implementation and use the code below as a starting point for your own implementation. Dont forget to add the alert class and category as filter value.

METHOD if_ex_alert_modify_text~modify_long_text. DATA: lv_str TYPE string. CONCATENATE 'http://' sy-host '.company.com:8000' INTO lv_str. REPLACE ALL OCCURRENCES OF 'http://XXXXXXXXX.company.com:8000' IN TABLE ct_long_text WITH lv_str. CONCATENATE 'crm-object-value=' ip_appl_guid INTO lv_str. REPLACE ALL OCCURRENCES OF 'crm-object-value=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' IN TABLE ct_long_text WITH lv_str. IF ip_langu = 'E'. lv_str = 'sap-language=en'. ELSE. lv_str = 'sap-language=nl'. ENDIF. REPLACE ALL OCCURRENCES OF 'sap-language=XX' IN TABLE ct_long_text WITH lv_str. CONCATENATE 'sap-client=' sy-mandt INTO lv_str. REPLACE ALL OCCURRENCES OF 'sap-client=XXX' IN TABLE ct_long_text WITH lv_str.ENDMETHOD.End resultLets check the end result. The email notification now contains the url that deeplinks to the task the alert refers to.