Geocode Business Partner with Google Maps by Gregor Wolf
Geocode Business Partner with Google Maps
|
|
Inspired by Eddy De Clercq’s SDN World Map and the German Podcast Pimp My Brain where they introduced me into Google Maps I’ve tried out to combine this with our SAP CRM People Centric User Interface (PC-UI). The result is this little BSP application which uses ABAP Object Persistence Service and Simple Transformations.
During my research about geocoding in a SAP environment I found Geocoding for BW and Geocoding for Business Partners. You find more information about this topic in the SPRO customizing transaction at SAP NetWeaver -> General Settings -> Set Geocoding. Unfortunately I’ve found no documentation how to implement this standard interface and I implemented my own. External Geocoding solutions can be found in the Partner Directory Solution Search. SAP Notes regarding Geocoding can be found in the OSS Application Area BC-SRV-GEO.
There is also an SDN Article “Using Geo Services with Web Dynpro†which uses the standard interface which calls external providers using the IGS.
But now let’s start to build our solution which will result in:

Preparation
Sign up to the Google Maps API
To use Google Maps you have to Sign up for the Google Maps API. You have to provide the web site URL which must exactly match your WebAS URL including the Port. I. e. http://webas.test.com:8000/. After the sign up you get a sample HTML Source which you can save locally and play around using the API Documentation.
Create Database Table for Geocoding Data
I’ve put all development objects together in the Package ZBPGOOGLEMAP:

Here I’ve created also the DB Table ZBPGEOCODE which will contain the Geocode information for a Business Partner (BP). To detect changes on the BP I also save Street, Street No., Postal Code and City in this table.

Create Persistent class for Geocoding Data
A long time ago I’ve read Thomas Jung’s Weblog on “ABAP Persistent Classes: Coding without SQL†but never tried it on my own. But here I’ve done it and created the Class ZCL_BPGEOCODE which is from Class Type “Persistent classâ€. All the rest is described in detail in the mentioned Blog. Be aware that you have to use the DB Table ZBPGEOCODE.
Transform Google KML to ABAP
I did not attend the ABAP Online Meet-up on Simple Transformations but it inspired me to use this to transform the return of the Geocoding HTTP Request into an ABAP Structure. To test the Transformation I first downloaded the result of this request to my local drive:
http://maps.google.com/maps/geo?q=Neurottstr.+15a,+Walldorf,+DE&output=xml&key=…
Don’t forget to use your key which you’ve got after sign up at Google Maps. The result of the request looks like this:
The main problem for me was the Namespace used by the Google KML Format. To get access to the components I had to add this line to the “xsl:transform†element:
Also be aware that the Values which should be transferred to ABAP Variables, Structures or Tables must be Uppercase. Here is the complete XSLT which I’ve saved as ZGOOGLE_GEOCODE_TO_ABAP:
When you test the Transformation you should get this result:
Implement the BSP
Now we can put the elements together and create the BSP Application ZBPMAP with the Page default.htm. Please maintain this Page Attributes:
| Attribute | Auto | Typing Method | Associated Type |
|---|---|---|---|
| address | Â | TYPE | STRING |
| bp | X | TYPE | BU_PARTNER |
| mapcenter | Â | TYPE | STRING |
Here is the layout:
<% endif. %> Please note that you have to insert your Key. Finally the Event Handler OnInputProcessing:
Also here insert your own key to the generated URL. The result is this little BSP Application which provides a Map with a marker where our Business Partner is located.:

To combine this BSP with the PC-UI of CRM please have a look at my Blog: “Use CRM PCUI HTML viewer to call a custom URLâ€.
Gregor Wolf is the Webmaster of www.siteco.de and owner of Computerservice Wolf
Add comment July 1st, 2006