GPS like tool in SAP using Google Map API

GPS like tool in SAP

In the earlier article, we saw how we can get the latitude and longitude of any address using Google Map API. Adding to that learning, in this post, we would learn how to get the distance between two addresses. We would also see how we can derive turn by turn directions between two given addresses. To add more to the fun, we would also open a browser from SAP and display the route between two points on the map.

Do you think, this is interesting? 🙂

In short, this tool would act like a GPS in SAP, which would help you get the Coordinates (Latitudes/Longitudes), Route and Map with complete direction.

Before we check, how it can be done, let us first see, what we are talking about.

I.  First radio button: Coordinates & Distance

Latitude and Longitude

We get the Coordinates of two addresses and also the distance between them.

Latitudes and Longitudes in ABAP

II.  Second Radio button: Turn by turn route

GPS Route in SAP

The tool would provide you the complete break-up of the route from the source to the destination address. It would also provide you with multiple routes if available.

Turn by turn direction and route

II.  Let’s check the third radio button which says ‘Display Map‘.

Display Map

As requested, this GPS Tool would display the map along with the routes in a Web Browser. Check this out.

Google Map


Also Read: SAP ABAP on HANA. Part I : Create your first program in HANA Studio.

Did you like it?

You can use the  code snippet provided at the end of this article and try it yourself. The code provided here would work as it is. The concept was already explained in our earlier post ‘Get Latitude and Longitude of any place using Google Map API in SAP’.

For the three output options, we need to call three APIs. As explained in the earlier article, we concatenate the strings with source and destination address, Latitudes and Longitudes etc to complete the API URL and get the XML data. Reading through the XML data and pinpointing the needed information is the trick which we have already learned.

a) GeoCode API String for Coordinates:

b) Distance Matrix API String for retrieving the distance between Coordinates:

c) Directions API String to trace the route on the Map:

lv_address               = From/To address
<fs_dest>-place_f = From address
<fs_dest>-lat_f      = From address latitude
<fs_dest>-lng_f     = From address longitude
<fs_dest>-place_t = To address
<fs_dest>-lat_t      = To address latitude
<fs_dest>-lng_t      = To address longitude

Once you have the correct API URL, use this cl_http_client class and create_by_url method to get the detailed information.

Please go through the detailed code to check how it works. There might be better ways to read these APIs and XML data but we just wanted to show the possibilities. You can explore more and figure out the best way for you.

If you find any difficulty in understanding the code or concept, please do write to us or leave your question in the comment section. We would surely respond.

If you have doubt whether this tool would work for Non-India address. Be rest assured, it works for any address. Check the output for the address in the USA. 🙂


Also Check: SAP HANA from Space Level.

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 Experts.

    The p_http_client->receive method is returning error 1 (http_communication_failure). What could be happening? Does this functionality not work in the development environment? Thanks!

  2. HI Experts,
    When i execute the program am getting the response ‘Application Server Error’.Can you please let me know the required system setup before executing this program.

  3. Hi,

    i have create same program in ecc-6.0 0 patch level. Its not work, did i need to install or used any odata or hana services for the same or not.

    • Dear Sonu – We are in the most recent patch. So may be some structures/types may not be there in your version? What is the error you are getting?

      One reader reported error: Type “HRPAYFR_T_SMUM_XMLTB” is unknown.

      If you are also getting the same error, then please create a custom (Z) Table Type of structure “smum_xmltb” and replace it where TYPE HRPAYFR_T_SMUM_XMLTB is being used.

      Please let us know what error you are getting. We would try to help you out.

      Team SAPYard

  4. Thank you Kuldeep.
    Thanks you SAP YARD too, you guys done great job, it helps me lot. Yesterday only i raised request for this in other blog of yours. Today i got the solutions..simply awesome job.

    Venubabu Divvi

    • YOUR WELCOME 🙂 also thanks to raju he appriciated and make this code published in sapyard .com, we can use this code to integrate other google api .

      • Dear Kuldeep – On behalf of SAPYard and our readers, we would like to thank you for this wonderful share. Our readers are loving it. Do keep on sharing interesting and new findings and help our readers.

        Team SAPYard.

    • You are welcome Divvi. Thanks to Kuldeep who is the brain behind this post.

      We are so happy to learn that you got solution so quickly.

      Happy learning!!

      Team SAPYard.

  5. Thanks, Team SAPYard.

    Issue has been resolved! As suggested, I created a custom table type of structure “smum_xmltb” and replaced it with HRPAYFR_T_SMUM_XMLTB.

    • Dear ZSK – Thank you so much for taking some time off and writing to us.

      No, you do not need to install any additional thing.

      * The below line is giving error for you.
      CHANGING p_li_xml_table TYPE hrpayfr_t_smum_xmltb.

      Seems table type HRPAYFR_T_SMUM_XMLTB, is not there in your SAP system. You can create a custom (Z) Table Type of structure “smum_xmltb”. And use it in place of HRPAYFR_T_SMUM_XMLTB.

      Or else, for testing, define li_xml_table TYPE TABLE OF smum_xmltb as global internal table. And remove it from CHANGING parameters. In that case, you do not need the table type HRPAYFR_T_SMUM_XMLTB.

      Let us know, if you still face issue.

      Team SAPYard.

Leave a Reply to ZSK Cancel reply

Please enter your comment!
Please enter your name here