Skip to Content
Author's profile photo Robert Witt

Implementing a Geocoder for Google Maps in SAP CRM

One important aspect and target of a good Customer Relationship Management system is to manage acurate customer address and contact information. SAP integrates a framework in SAP CRM to gather and store geolocation information about a customer’s location, i. e. the latitude and longitude of an address. This is especially critical in scenarios where the exact customer location is required (i. e. for weather information services).

You as a customer can enhance the framework and hook your own geocoding service into it. By standard the geocoding service in SAP CRM determines the geocoordinates based on country and region when an address is saved. Of course for most of the use cases, this is much too unprecise.

In this blog I describe how to use Google Maps as geocoding service in SAP CRM.

The Geocoding API in Google Maps is an HTTP based API where you can pass in an address and get geographical coordinates in return:,+Mountain+View,+CA&key=YOUR_API_KEY

Check out the API documentation for more details.

To integrate the Google Maps API in SAP CRM, start by creating a Geocoder class. That is a generic ABAP class implementing interface IF_GEOCODING_TOOL. Activate the class only now, it will be implemented later.


This class must be registered in customizing (SPRO: SAP NetWeaver -> General settings -> Set Geocoding) as geocoder source.


Next step is to assign the relevant address field to the new geocoder source.


As the quality of geocoding solutions might vary between countries, you can define a geocoder per country. Here I defined the Google API for German addresses only.


Now let’s implement the geocoder class and method GEOCODE of interface IF_GEOCODING_TOOL. It is called everytime an address is updated in CRM.

The methods gets a table with addresses and some other information. It should geocode each of the addresses and put the results (latitude and longitude) in the CONTAINERS parameter.


The custom submethod GEOCODE_ADDRESS invokes another custom class that calls the Google Maps Geocoding API.


The Geocoding API is an HTTP-based web service API where this class sends GET requests to and consums the result.


The request URL is created by simply concatenating the base URL and the current address. Please note that a response in XML is requested.


SAP offers an XML library called iXML to read and parse XML content (see SAP help here). I haven’t found a similar version for JSON with the same capabilities.


Now if you’re create an account and maintain a German address, our Google Maps geocoder is called and the Geocoding API is asked for the coordinates.


The geograhical coordinates are stored in table GEOLOC.


Please share your comments and thoughts. I would really appreciate your feedback.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Anandh Kannusamy
      Anandh Kannusamy

      Dear Robert,

      Thanks for writing this article.

      Please inform us with your experience about Google Geo-coding API license implications.

      Is it commercially free for Production environment?



      Author's profile photo Robert Witt
      Robert Witt
      Blog Post Author

      Hi K Anandh,

      In my experience you need a business account in order to use the API commercially. The standard version works for non-commercial and development scenarios. However, in the usage limits I cannot see any restrictions on that, only the number of service requests per day is restricted.

      Please check Google's Terms of Service.



      Author's profile photo Dietmar Schmidt
      Dietmar Schmidt

      Hi Robert,

      looks great to me. Thanks for the article.

      The link does not work any more:



      Author's profile photo Robert Witt
      Robert Witt
      Blog Post Author

      Hi Dietmar,

      Thanks for your feedback.

      The base URL for requests is

      You need to replace AN_ADDRESS with the address you're want the geocoordinates for and YOUR_API_KEY with your API key. You get a key after you have registered. For demo cases you could also send requests without the key parameter.

      Hope this solves your issue.



      Author's profile photo Dietmar Schmidt
      Dietmar Schmidt

      Yep, thanks a lot....  🙂

      Author's profile photo Amit Hiremath
      Amit Hiremath

      Hello Robert,

      thanks a lot for this post, we have a similar requirement to determine geocodes while creating BP in ERP and in S/4. I tried to read through your code lines and see if this help, i am missing some information on the declaration for es_geolocation and few methods. Possible to help me out with the complete dump