Hello Guys,

I have seen many posts where associates struggle to find the way to get the URL value attached any BP/Order/Transaction in SAP CRM

In my last post  https://scn.sap.com/docs/DOC-65885, I explained the process to Create the URL in CRM Object which can be seen in web UI.

In this post, I’ll explains the logic to & sample code of  function module to get the URl value of any CRM object (Say  BP/Ativity/Lead/Opportunity/Contract etc,)

Below is how a URL Block looks like in SAP CRM Web UI.

If we open the properties of this URL, we can see the URl value there. But getting the same value outside the WebUI as in a custom program/report is very tricky,

The relation of URL entity with the CRM object (Say Business Partner) is stored in the Table : SKWG_BREL.

This is a very important table to start with the URL search logic.

The URL is stored in binary format & the URL GUID entries can be found in this Table.

Below are the details of some the fields of this table :

RELTYPE   – Contains the relation Type (WCM_LINK for the URL)

INSTID_A   – Contains the BP GUID

TYPEID_A  – Contains the Business Object Type

INSTID_B   – Contains Pattern L/CRM_L_URL/* for the URLs

Now, the SAP has given a Global Class CL_CRM_DOCUMENTS containing all the Methods related to Attachement/Document/URLs etc.

In SAP CRM The URL object is stored in the form of Logical Object (LOIO) & Physical Object (PHIO)

To get the value of LOIO & PHIO we need to use method : CL_CRM_DOCUMENTS=>GET_INFO_URL.

Here we need to pass the fields : INSTID_A + TYPEID_A + CATID_A from table SKWG_BRELas input.

Then FM :  SDOK_LOIO_GET_URI will give the absolute value of the URL

Below is the sample code of a FM which just takes the object GUIDs as Input & in return it will populate the respective URLs:

Sample Code for FM
FUNCTION zget_url_value_multi.
*”———————————————————————-
*”*”Local Interface:
*”  IMPORTING
*”     VALUE(IT_OBJECT_GUID) TYPE  BCSY_GUID
*”  EXPORTING
*”     VALUE(ET_MESSAGE) TYPE  BAPIRET2_T
*”  TABLES
*”      ET_URLS STRUCTURE  SDOKCOMURL OPTIONAL
*”———————————————————————-

TYPES : BEGIN OF l_typ_instid,
instid_a LIKE skwg_brel-instid_a,
END OF   l_typ_instid.

**  Get URL link
DATA : l_tab_loios    TYPE skwf_ios,
l_tab_phios    TYPE skwf_ios,
l_wa_loios     TYPE skwf_io,
l_wa_phios     TYPE skwf_io,
l_wa_busobject TYPE sibflporb,
l_wa_object    TYPE sdokobject,
l_wa_skwg      TYPE skwg_brel,
l_wa_url       TYPE sdokcomurl,
l_var_url      TYPE saeuri.

DATA : l_tab_skwg     TYPE STANDARD TABLE OF skwg_brel,
l_tab_instid   TYPE STANDARD TABLE OF l_typ_instid.

FIELD-SYMBOLS :   TYPE l_typ_instid,
TYPE os_guid.

LOOP AT it_object_guid ASSIGNING .
APPEND INITIAL LINE TO l_tab_instid ASSIGNING .
-instid_a = .
ENDLOOP.

SELECT *
FROM skwg_brel
INTO TABLE l_tab_skwg
FOR ALL ENTRIES IN l_tab_instid
WHERE instid_a = l_tab_instid-instid_a
AND instid_b LIKE ‘L/CRM_L_URL%’.

SORT l_tab_skwg BY instid_a typeid_a catid_a.
DELETE ADJACENT DUPLICATES FROM l_tab_skwg
COMPARING instid_a typeid_a catid_a.

LOOP AT l_tab_skwg INTO l_wa_skwg.
CLEAR   : l_wa_busobject.
REFRESH : l_tab_loios, l_tab_phios.

l_wa_busobject-instid = l_wa_skwg-instid_a.
l_wa_busobject-typeid = l_wa_skwg-typeid_a.
l_wa_busobject-catid  = l_wa_skwg-catid_a .

CALL METHOD cl_crm_documents=>get_info_url
EXPORTING
business_object = l_wa_busobject
IMPORTING
loios_url       = l_tab_loios
phios_url       = l_tab_phios.

LOOP AT l_tab_loios INTO l_wa_loios.
CLEAR : l_wa_object, l_var_url, l_wa_url.
MOVE-CORRESPONDING l_wa_loios TO l_wa_object.

CALL FUNCTION ‘SDOK_LOIO_GET_URI’
EXPORTING
object_id = l_wa_object
IMPORTING
uri       = l_var_url.

MOVE l_wa_skwg-instid_a  TO l_wa_url-component.
MOVE l_var_url           TO l_wa_url-url.

APPEND l_wa_url TO et_urls.
ENDLOOP.
ENDLOOP.

ENDFUNCTION.

Once you create this FM, you just need to pass the object GUIDs (can be multiple) & rest will be taken by this FM.

for Eg: if you want to get the URL attached to a Business Partner, just get the BP_GUID from BUT000 & pass the same to this FM.

I hope this would be helpful for you.

Please add comments if you need any further help or inputs.

Cheers,

Bharat Bajaj

New NetWeaver Information at SAP.com

Very Helpfull

 

 

User Rating: Be the first one !