Real Time Data Exchange using URL based Transaction Launcher
This document is for demonstrating how to create an URL based transaction launcher in CRM UI to exchange data between SAP and an external URL in real time.
- Declare URL and the Parameters [SPRO->Customer Relationship Management->UI Framework->Technical Role Definition->Define URLs and Parameters]
- Declare URL Parameters. For this we must remember the meaning of import and Export parameters. For example, here, I’m creating 3 parameters: name (Import), xpos (Export) and ypos (Export).
Parameter Type |
Meaning |
---|---|
Import | Data to be transferred from SAP CRM UI to external URL |
Export | Data to be transferred from external URL to SAP CRM UI |
- Now launch the Transaction Launcher wizard.[SPRO->Customer Relationship Management->UI Framework->Technical Role Definition->Configure Transaction launcher]
- Now assign the transaction launcher in CRM UI as Workcenter link following usual process. I’m not detailing them here.[SPRO->Customer Relationship Management->UI Framework->Technical Role Definition->Define Navigation Bar Profile]
- The class ZCL_LAUNCH_URL was created by the wizard. We need to make certain changes for data exchange to work.[Transaction:SE24]
- Save the class under a transport as it gets created under local object by default.
- Go to redefined CLASS_CONSTRUCTOR method to change the following code, it is required as we want data to flow back to SAP CRM.
- Go to the redefined method IF_CRM_IC_ACTION_HANDLER~PREPARE_DATA_FLOW to add the following code. This super class method has the code to add the return URL information. The return URL is the SAP CRM URL which the external webpage will send the information to.
- Go to redefined method IF_CRM_IC_ACTION_HANDLER~PROCESS_RETURN to add the code to handle return data. For example here I’m giving a message.
- For demonstration purpose I’ve built a HTML webpage and hosted it using Apache in my local machine. Similarly any webpage can be used to exchange data with SAP CRM. This webpage displays the sent information from SAP i.e Name and has 2 input fields XPos and YPos. When “Go” button is clicked on the webpage the data is sent back to SAP CRM UI and displayed.
- The source code of the webpage using some JavaScript functions.
<html>
<head>
<title>My Page</title>
<script type="text/javascript">
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
function decode(str) {
return unescape(str.replace(/\+/g, " "));
}
var fullname = getUrlVars()["name"];
var returl = getUrlVars()["ICRETURNADDRESS"];
var client = getUrlVars()["ICRETURNCLIENT"];
var comid = getUrlVars()["COMPONENT_ID"];
var guid = getUrlVars()["GUID"];
var returl1 = decode(returl);
function submitform(){
this.action=returl1;
}
window.onload = function(){
document.details.onsubmit=submitform;
}
</script>
</head>
<body>
<form id="name" name="name" >
Name : <input type="text" name="fullname" readonly="readonly"/><br />
</form>
<form id="details" name="details" method="post" action="" >
COMPONENT ID : <input type="text" name="component_id" readonly="readonly"/><br />
Return address : <input type="text" name="value3" readonly="readonly"/><br />
Return Client : <input type="text" name="client" readonly="readonly"/><br />
GUID : <input type="text" name="guid" readonly="readonly"/><br />
XPOS : <input type="text" name="xpos" value="" />
YPOS : <input type="text" name="ypos" value="" />
<input type="submit" value="go!" />
</form>
<script LANGUAGE="javascript">
document.name.fullname.value = decode(fullname)
document.details.component_id.value = comid
document.details.value3.value = returl1
document.details.guid.value = guid
document.details.client.value = client
</script>
</body>
</html>
- Now the Apache has to be running for testing this.
-
Now if we can test our application.
- Log-in to SAP CRM UI and confirm a Business Partner.
- Click on “Launch URL” Workcenter link to launch the external URL. You can notice the Fullname of the Business Partner has been transferred to the external webpage.
- Now enter some data in the input fields XPOS and YPOS and click the “Go” button.
- It can be seen that data is passed back to in SAP CRM. For demonstration purpose I’m displaying them as message but it can be easily stored in database or it can be used to trigger any business process.
Good job Sourav Bhaduri much appreciated.
Regards
Ani
Thanks Ani
Very good illustration to achieve a simple exchange of data.
Thanks Parveen...Yes its very simple from user point-of-view.....but there are no SAP documents on this.
Sourav,
Thanks for your detailed document.
For a BOR based transaction, is there any additional code to be added for the process_return i.e return data flow method to get triggered.
Thanks.
Hi Sourav,
Nice job but I am having trouble trying to make it work.
I did everything like you did but the method "process_return" of my transaction launcher is never called.
I am using CRM 7.0 EHP3.
Do you have an idea ?
Regards
Hi Benoit
I am facing the same issue, the method "process_return" is ot getting called, did u find a solution?
Thanks and regards
Did u redefine the CLASS CONTRUCTOR Method and added the marked the variable gv_is_return_df_requested = "X" ?
Thanks for your reply.
Yes, I had marked the variable GV_IS_RETURN_DF_REQUESTED as X.
I can see that the control comes to UICMP_LTX page GenericLTXReturn.htm but then i do not see the code where the handler class gets called within the code for this page.
Does this code need to be modified or do we need to create a new BSP application and do some custom coding to call the handler class on return?
Thanks & Regards
Hello Reecha,
I created a ZUICMP_LTX, there was an error in the standard one.
You can cherck my blog Transaction Launcher - Call an Url and retrieve form data in CRM
And in addition I get the whole http request and not just the parameters.
Regards
Thanks. I had referred this code as well, but the problem is that the control is not coming back to the handler class sub class of super class (CL_CRM_UI_LTX_ABSTRACT_URL) method PROCESS_RETURN
Hi Reecha,
Check the method OnRequest in your BSP application for return (my ZUICMP_LTX), you need the component id sent by the called URL.
Regards