Skip to Content

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  http://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.

/wp-content/uploads/2015/08/image_png_765400.png

 

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 : <l_wa_instid>  TYPE l_typ_instid,
<l_wa_guid>    TYPE os_guid.

LOOP AT it_object_guid ASSIGNING <l_wa_guid> .
APPEND INITIAL LINE TO l_tab_instid ASSIGNING <l_wa_instid>.
<l_wa_instid>-instid_a = <l_wa_guid>.
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

To report this post you need to login first.

3 Comments

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

  1. Raj Mani

    We are migrating the documents from IXOS to Documentum so wondering whether there is any way to repoint/replace the URL to the migrated document in the new archive server?

    We have the mapping of old to new URL so is there any way to update the new URL in specific tables (e.g SKWG_BREL) to achieve this?

     

    Thanks

    Raj

    (0) 

Leave a Reply