Header Ads

Consuming an External Web Service in SAP CRM, Part Two


In Part One of this article series, we created a consumer proxy to call a web service to display weather data. Now we can use the web service to provide additional functionality in the CRM Web UI by adding weather information to an account’s address view.
Because there can be some work involved in building the request and unpacking the response in the service call, it is a good practice to write another function module to call the proxy object. The input to ourZZGETWEATHER function module will be a zip code string, and the output will be a string containing the current weather details for that zip code.
Using the BSP Workbench (transaction bsp_wd_cmpwb), open the UI component BP_ADDR and the view AccountAddressEF. First we will add a value context node that will be used to display the weather data.
To retrieve the weather data, we can use the zip code of the address. The zip code is in another context node on the view (BUILADDRESS). Enhancing this context node will give you a z-version (ZBUILADDRESS).
In the implementation class of the CURRENTWEATHER context node add a new attribute that refers to the context class implementation. We will use this attribute to access the zip code from the ZBUILADDRESScontext node.
In the CREATE_CURRENTWEATHER method of the context implementation (*_CTXT), we assign a value to the attribute created above.
Now in the GET_CURRENTWEATHER method of theCURRENTWEATHER context node, we can read the value of address zip code and use it to call our function module.
Lastly add the new CURRENTWEATHER context node to the UI configuration.
Now when you display an account address in the CRM Web UI, you will see the current weather for that address.

Powered by Blogger.