Get Latitude and Longitude of any place using Google Map API in SAP


SAP surprises us every day. Even after working for more than a decade, a new project or client will have some requirements which are unique and you need out of the box thinking and solution. The below post is a similar requirement where a client wanted to know the Geo Coordinates of any given place. There are many ways to get the Latitudes and Longitudes but Kuldeep Joshi (who contributed this post), found a very convenient way by using Google Map API. He thought Google Map is free and readily available, so why not use it in SAP with ease.

Check below, if the user enters any address, he should get the latitude and longitude of that place.

Geo Coordinates in SAP

Isn’t it a cool requirement?

How can we achieve this?

Simple, connect to Google Map Service (read API), scan through its content string and find your data. It needs some reading through the string, but this is really effective and easy solution.

Check this steps (detailed code is available at the end of the article below)


Concatenate your input address with the Google Maps API web address to get the client data.

Generate Google Map API path

You might like to read the next related article: GPS like Tool in SAP.

Request the data. Check your cases (lower/upper) of the methods (they might be case sensitive).

Get Method

Send the request.

Request service

Receive the response from Google API.

Receive the request

Now, you have the string content. Just look through the string at the right place and get the latitude/longitude information.

Geo Code from Google Map API

<location> </location> are the opening and closing tag. We need to find the latitudes and longitudes in between these two tags.

Check API code

Similarly <lat> </lat> and <lng> </lng> are the opening and closing tags for Latitude and Longitude respectively.

This is one example of the content file received from Google API. Looking at the data, it is very clear, where we can find the coordinates.

Google API

Hopefully, this post would help you to find the required coordinates. In the next post, Kuldeep would show how to find the distance between two addresses using Google API in SAP. Also, he would show, how to open the two addresses in Google Map and show the distance in the browser. Please stay tuned.

And our code not only works for India address, it works for any address in the world. Let’s check an address in USA. 🙂

Coordinates in SAP ABAP

You can validate the coordinates in Google Map manually.

Also Read: Unix file in SAP.

Here is the code snippet used for this post.

If you want to get such practical issues and resolutions straight to your inbox, please SUBSCRIBE. We respect your privacy and take protecting it seriously.

If you liked this post, please hit the share buttons.

Thank you very much for your time!!


  1. Hi Team,

    Very nice blog and Great piece of information. I tried the same in my system, but I am getting the following error in xml output..Application Server Error, I am nt sure what i am missing here…Would appreciate if you can help me..

    • Thank you Thiru. It might be issue of SAP patch. We are in 7.4+ . Try to check the error message. There might be other methods/fms for you to use.

      Please let us know, how it goes.

      Team SAPYard.

    • Thank you Ravi. We are happy, you like our work. Please keep visiting for more tutorials. Please share our link on your social media pages (linkedin, fb, twitter) and help us reach more people.

      Team SAPYard.

  2. Hi Kuldeep,

    I am getting exception “http_communication_failure” for below lines of code, what could be the reason?

    * Reterive the result
    CALL METHOD p_http_client->receive
    http_communication_failure = 1
    http_invalid_state = 2
    http_processing_failed = 3
    OTHERS = 4.

    Swapnil Joshi

    • Dear Swapnil – We doubt some service is not active in your system or it is authorization issue.

      Can you check with your Basis/Security team and ask if they have some answer.

      Did you use our code or did you write your own code? If you have different code, please share with us and we would be happy to check it in our system.

      Team SAPYard.

  3. Good Blog Indeed, it would be nice if we get lat long with out entering Address.
    Like in Google maps, Just click any spot and get coordinates.

  4. This is great Kuldeep.I am sure you must be developing many more for making the work simpler.
    Congratulation and keep it up.

    • Dear Satish – On behalf of Kuldeep, SAPYard Team would like to thank you for taking some time off and providing your feedback.

      We are glad that it made your work simpler.


    • Thank you Benedict. Can you please show how to use it? We and our readers would be benefitted with this info. I tried the link you provided, but could not understand the output.

      Team SAPYard.

  5. Great Job, This program helps me a lot, now i need to understand how this will get the data.


    • Dear Venu – We are happy to know that our post helped you. To understand how data is being pulled, put a break point after the string is retrieved from API.

      Do let us know if you face any issue.

      Team SAPYard.

      • Yes I did that, i got the logic how it works..i think we can use this program to get multiple places also.
        Now i am looking for calculate miles between two different places in ABAP.
        Please suggest me if you have any logic to find miles between two places using Maps.

        Venubabu Divvi

Leave a Reply to SAP Yard Cancel reply

Please enter your comment!
Please enter your name here