SAP GPS-like tool with Google Map API

We learned how to use the Google Map API to obtain the latitude and longitude of any address. To supplement that knowledge, we would discover how to calculate the distance between two addresses in this post. Additionally, we would examine how to determine the turn-by-turn directions between two provided addresses. We would also launch a SAP browser and plot the path between two locations on a map to increase the pleasure.

Is this fascinating, in your opinion? 🙂

In a nutshell, this tool would work in SAP much like a GPS, allowing you to get coordinates (Latitudes/Longitudes), a route, and a map with comprehensive directions.

The first radio button: Distance & Coordinates

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

II.  Second Radio button: Turn by turn route

You would receive a comprehensive breakdown of the route from the source to the destination address from the tool. If accessible, it would also give you several paths.

II. Let’s select the “Display Map” radio button, which is the third one.

This GPS Tool would show the map and the routes in a web browser as asked. Look into this.

Google Map

Did you find it enjoyable?

You can try it out for yourself by using the code snippet that is provided at the conclusion of this post. This code would function just the way it is.

We must make three API calls in order to get the three output options. As previously mentioned, in order to finish the API URL and obtain the XML data, we concatenate the strings with the source and destination addresses, latitudes, longitudes, etc. We already know the trick: scanning the XML data and identifying the information that is required.

a) Coordinate GeoCode API String:

* Prepare the url of the GeoCode API
  CONCATENATE
    'http://maps.google.com/maps/api/geocode/xml?address='
    lv_address
    INTO lv_http_url .

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

* Prepare the url for the DistanceMatrix API using From Address Coordinates and To Address Coordinates
  CONCATENATE
    'http://maps.googleapis.com/maps/api/distancematrix/xml?origins='
    <fs_dest>-place_f '|' <fs_dest>-lat_f ',' <fs_dest>-lng_f ','
    '&destinations=' <fs_dest>-place_t '|' <fs_dest>-lat_t ',' <fs_dest>-lng_t
    '&alternatives=' 'true'
    INTO lv_http_url .

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

* Prepare the url for Directions API for the From Address Coordinates and To Address Coordinates
  CONCATENATE
    'http://maps.googleapis.com/maps/api/directions/xml?origin='
    <fs_dest>-place_f '|' <fs_dest>-lat_f ',' <fs_dest>-lng_f
    '&destination=' <fs_dest>-place_t '|' <fs_dest>-lat_t ',' <fs_dest>-lng_t
    '&alternatives=' 'true'
    INTO lv_http_url .

where:
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

Use this cl_http_client class and the create_by_url function to obtain the detailed information after you have the relevant API URL.

* Get client from url
  CALL METHOD cl_http_client=>create_by_url
    EXPORTING
      url                = lv_http_url
    IMPORTING
      client             = p_http_client
    EXCEPTIONS
      argument_not_found = 1
      plugin_not_active  = 2
      internal_error     = 3
      OTHERS             = 4.

Please review the detailed code to see how it functions. We merely intended to illustrate the options. There may be more efficient ways to read these APIs and XML data. You can investigate further to determine the best course of action.

Please feel free to contact us or ask a question in the comment section if you need help understanding the code or an idea. Without a doubt, we would react.

Would you kindly click the share buttons if you enjoyed this post?

I sincerely appreciate your time!


you may be interested in this blog here:-

How Many Employees Does Salesforce Have in 2024?

Role of SAP Consultants in Modern Business Transformations

Advanced Code Snippet Techniques : Mastering the Craft

  • Related Posts

    Managing Change During SAP Automation Rollouts

    Implementing SAP automation can transform an organization’s efficiency, accuracy, and speed. But despite the enormous benefits, many teams struggle not with the automation itself but with the change that comes…

    ECC Support End – What SAP Professionals Must Do

    The SAP ecosystem is undergoing one of its biggest transformations in decades. The ECC support end announcement has created urgency for companies and professionals who have relied on SAP ECC…

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You Missed

    Managing Change During SAP Automation Rollouts

    • By Varad
    • May 2, 2026
    • 373 views
    Managing Change During SAP Automation Rollouts

    ECC Support End – What SAP Professionals Must Do

    • By Varad
    • May 1, 2026
    • 374 views
    ECC Support End – What SAP Professionals Must Do

    SAP BTP Architecture for Future Projects – A Beginner’s Guide

    • By Varad
    • April 30, 2026
    • 469 views
    SAP BTP Architecture for Future Projects – A Beginner’s Guide

    Using GraphRAG and Hybrid RAG in Enterprise Applications with SAP

    • By Varad
    • April 29, 2026
    • 776 views
    Using GraphRAG and Hybrid RAG in Enterprise Applications with SAP

    SAP ABAP on HANA: Skills You Must Learn in 2026

    • By Varad
    • April 28, 2026
    • 595 views
    SAP ABAP on HANA: Skills You Must Learn in 2026

    SAP ABAP Best Coding Practices for Freshers

    • By Varad
    • April 27, 2026
    • 416 views
    SAP ABAP Best Coding Practices for Freshers