Custom FM to directly Get the Attachment URL value from SAP CRM Web UI
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, ** Get URL link DATA : l_tab_skwg TYPE STANDARD TABLE OF skwg_brel, FIELD-SYMBOLS : TYPE l_typ_instid, LOOP AT it_object_guid ASSIGNING . SELECT * SORT l_tab_skwg BY instid_a typeid_a catid_a. LOOP AT l_tab_skwg INTO l_wa_skwg. l_wa_busobject-instid = l_wa_skwg-instid_a. CALL METHOD cl_crm_documents=>get_info_url LOOP AT l_tab_loios INTO l_wa_loios. CALL FUNCTION ‘SDOK_LOIO_GET_URI’ MOVE l_wa_skwg-instid_a TO l_wa_url-component. APPEND l_wa_url TO et_urls. 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