Skip to Content
Technical Articles
Author's profile photo Gregor Wolf

Community Project ZGEOCODE

During SAP Inside Track Bonn 2010 Renald Wittwer held a presentation on how to integrate WebDynpro ABAP Flash Islands with OpenStreetMap. As I do contribute to OpenStreetMap (OSM) already for more than a year now it made me think if OSM is ready to be used for Geocoding. Four years ago I’ve did that using the Geocode Business Partner with Google Maps and Geocoding – the next step: Routing with Map24 AJAX API. Pascal Neis pointed me to the Nominatim service that can be used for Geocoding. So I started investigating and today you can try out the ZGEOCODE project.

How it works

The Nominatim service provides an XML interface that can be called via HTTP submitting an address that should be geocoded. This service is used in the ZCL_GEOCODE_NOMINATIM class that implements the IF_GEOCODING_TOOL interface. This interface has to be defined to allow customer or partner solutions to be used for geocoding i.e. business partners. When the class is activated via the customizing the found geographic informaition is saved in the GEOLOC table. To access this data you can use the class ZCL_GEOCODE_HELPER.

Usage

Demo Program ZGEOCODE_NOMINATIM_READ_BP

To do a quick test of the Geocoding result without any additional customizing you can use the ZGEOCODE_NOMINATIM_READ_BP program. It will allows you to search for all existing business partners and display them in a list. Then just click on the partner id like here 101:

image

Then you will be directed to the map showing the Business Partner location:

image

Extend BP Transaction with map display

Thorsten Franz who is an expert on the Business Data Toolset (BDT) helped me to get the map integrated in the transaction BP. Together with Tobias Trapp he had written the Book “ABAP Objects: Application Development from Scratch” which is covering BDT in detail.

As you can see from the screen shot below OpenStreetMap can me nicely integrated in the BP transaction:

image

PC-UI People Centric User Interface

Unfortunately I don’t have a CRM 6.0 or 7.0 system available where I can integrate the map into the CRM WebUI. But the SAP NetWeaver 7.01 SR1 SP3 ABAP Developer Edition (NSP) comes with the PC-UI framework which is shown in the next screenshot:

image

So if you like to use that in your own system check out the SCN Wiki Page on ZGEOCODE.

Assigned Tags

      18 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Renald Wittwer
      Renald Wittwer
      Hello Gregor,
      Great Project! It works very well.

      Best regards
      Renald

      Author's profile photo Graham Robinson
      Graham Robinson
      Hi Gregor,

      this is really great work.

      It works well for me with German addresses - but not Australian ones. I have done the same customising for country AU as for DE. Any ideas?

      Cheers
      Graham Robbo

      p.s. One small issue is that I found some of the objects required for the test program ZGEOCODE_NOMINATIM_READ_BP are missing from the SAPLink nugget.

      Author's profile photo Gregor Wolf
      Gregor Wolf
      Blog Post Author
      Hi Graham,

      great that you give it a try. Yes, you have to add AU in the customizing step "Assign Geocoding Program to Countries".

      Can you tell me what Object is missing in the Nugget?

      Best regards
      Gregor

      Author's profile photo Graham Robinson
      Graham Robinson
      The programs LL and ZGEOCODE_NOMINATIM_ZAKE_SVN wont compile because the type "ZAKE" is missing.

      Cheers
      Graham Robbo

      Author's profile photo Gregor Wolf
      Gregor Wolf
      Blog Post Author
      Hi Graham,

      for the functionality of the geocoding this program is not needed. But if you want to contribute, then you should download the current ZAKE Version from SAPlink. A description of my extension to ZAKE which is called ZAKE_SVN can be found in the Google Wave Enhance SAPLink to support source control checkin. If you don't have a wave account yet please send me a mail and I will send an invite.

      Best regards
      Gregor

      Author's profile photo Former Member
      Former Member
      Hi Gregor,

      just installed the tool on our server and I learned a lot this evening. Sadly I could not test it, as our server does not have internet access 🙁 I am going to ask our admins to allow internet connection, but I doubt my success.

      From what I have seen until now: Well done! This does look very cool!

      Anyhow, there is always a small point for nagging. As you state in the code "borrowed by SAP" and it looks just like it. Probably a small makeover would do 😉

      cheers Carsten

      Author's profile photo Gregor Wolf
      Gregor Wolf
      Blog Post Author
      Hi Carsten,

      thank you for your comment. Hope you've got web access for your ABAP System now. Haven't you authorizations to SICF to configure a proxy server?

      Would love to get a SAPlink patch file how you would refractor the coding.

      Best regards
      Gregor

      Author's profile photo Former Member
      Former Member
      Hi Gregor,

      yep, I had to use a proxy. Bad thing: I did not know which one. Now it is all up and running.

      After some testing, I did the first enhancement:
      - Use a RFC destination to get all server data(including proxy) instead of hardcoding the URL
      - Add the postal code to the query

      While snooping around in the code, I stumbled accross some other things:
      - the GeoCoder is rather weak. I tried to encode the street "Hauptstr." and it came back with an empty result. "Hauptstrasse" is encoded correctly. Seems to be an issue for only some addresses.
      - Sometimes there is more than one address returned... Do you know if there is the possibility to bring up a user dialog with all addresses. A cool thing would be to do some data adjustments to the address as well, when the GeoCoder returns more information than inserted.
      - If no address is returned, you just skip the coding. I would go about an iterative approach. Like try with the full address, then without street, without city, etc.

      As soon as I figure out how to use SAPLink correctly for export and have done some of the things I mentioned above, I am going to pack up a file.

      cheers Carsten

      Author's profile photo Gregor Wolf
      Gregor Wolf
      Blog Post Author
      Hi Carsten,

      an easy way to find the proxy settings when Automatic Proxy Configuration is used to open the URL http://wpad/wpad.dat. That brings up a JavaScript file with all the Proxy Servers. But then you must hope that they don't need Windows Authentication. The ABAP Stack only support Basic Authentication to proxies AFAIK.

      Thank you for the great suggestions here are some comments:

      - I've avoided the requirement of a RFC destination for the moment to make it easier to try the package. But you're right it gives more flexibility.
      - Have you tested if adding the postal code gives better geocoding results?
      - Nominatim is not like the Google Maps API Geocoding service and does currently not provide any linguistic search
      - It's absolutely possible to provide a dialog where the user can select the correct address. I wanted to release early to get that feedback.

      Regarding SAPlink please check out the Google Wave for ZAKE_SVN. It will send you a Wave invite if you don't have an account yet. Just send me a mail. ZAKE_SVN is a package that allows you to checkout/checkin ABAP Code using SAPlink into a Subversion repository. Coming with ZGEOCODE is the program ZGEOCODE_NOMINATIM_ZAKE_SVN which does that for the ZGEOCODE package. Also it's building ZIP files for distribution.

      Best regards
      Gregor

      Author's profile photo Former Member
      Former Member
      Hi Gregor,

      I used your geocoding sample for learning and was succesful in adopting it for ESRI's online geocoders.  Thanks very much for that.

      I am also interested in implementing the BDT screen for BP. So far I have not been succesful with getting access to the partner number in the PBO of my custom screen.  Are you able to provide hints or share the code/configuration of your BP demo?

      Regards,

      Enrique Yaptenco

      Author's profile photo Karl Müller
      Karl Müller

      Hi Gregor,

      we have implemented the modules and it works fine so far we use only one function. My problem is the view V_FLEX_MAPS who could not be activated. If i change to the tab Layout it will generate following dump. This is the reason why i could not transport the Program to the productiv system. I think we don't need this view but how can i transport it to prod?

      can anyone help me  to avoid this error and transport it.

      kind regards

      Karl Mueller

      Runtime Errors     OBJECTS_OBJREF_NOT_ASSIGNED_NO
      Except.            CX_SY_REF_IS_INITIAL
      Date and Time      24.10.2014 08:19:03

      Short Text

      Access via 'NULL' object reference not possible.

      What happened?

      Error in the ABAP Application Program
      The current ABAP program "CL_WDY_MD_UI_ELEMENT_LIBRARY==CP" had to be
        terminated because it has
      come across a statement that unfortunately cannot be executed.

      Error analysis

      An exception occurred that is explained in detail below.
      The exception, which is assigned to class 'CX_SY_REF_IS_INITIAL', was not
        caught in
      procedure "GET_PROPERTY_DEFAULT_VALUES" "(METHOD)", nor was it propagated by a
        RAISING clause.
      Since the caller of the procedure could not have anticipated that the
      exception would occur, the current program is terminated.
      The reason for the exception is:
      You attempted to use a 'NULL' object reference (points to 'nothing')
      access a component.
      An object reference must point to an object (an instance of a class)
      before it can be used to access components.
      Either the reference was never set or it was set to 'NULL' using the
      CLEAR statement.

      Missing RAISING Clause in Interface

      Program                             CL_WDY_MD_UI_ELEMENT_LIBRARY==CP
      Include                             CL_WDY_MD_UI_ELEMENT_LIBRARY==CM024
      Row                                 1
      Module type                         (METHOD)
      Module Name                         GET_PROPERTY_DEFAULT_VALUES

      Trigger Location of Exception

      Program                             CL_WDY_MD_UI_ELEMENT_LIBRARY==CP
      Include                             CL_WDY_MD_UI_ELEMENT_LIBRARY==CM024
      Row                                 14
      Author's profile photo Gregor Wolf
      Gregor Wolf
      Blog Post Author

      Dear Karl,

      if you don't need the WebDynpro Component I would simply suggest that you try to delete it in SE80.

      Best regards

      Gregor

      Author's profile photo Karl Müller
      Karl Müller

      Dear Gregor,

      many thanks for your fast support. I've deleted this webdynpro and it coult be transported.

      best regards Karl

      Author's profile photo Karl Müller
      Karl Müller

      Dear Gregor,

      we have implemented the GEOCODE tool and it seem to be a Little difficult to get the right Geocodes.

      We want to get coordinates from a small city and it Looks like that the postcode wasn´t regard. For example we have a citty with a Name where  exists many times, the geocode delivers a code that is not from the right citty with the given postcode

      .I can't imagine that this is a error of the tool,and nobody notice this. I think this is a wrong call of the method.

      we fill the address Parameters like this

      Author's profile photo Karl Müller
      Karl Müller

      Dear Gregor,

      this Editor works a Little bit difficult with copy and paste.

      i would say

      we fill the address Parameters correct (here only examples)

      city1 = 'cittyname'

      post_code1 = '99999'

      street = 'streetname'

      house_num1 = '11'

      Country = 'DE'
      time_Zone = 'CET'
      langu_crea = 'EN'

      any hint

      thanks Karl

      Author's profile photo Gregor Wolf
      Gregor Wolf
      Blog Post Author

      Dear Karl,

      could you provide me some real data? I haven't got problems with the addresses that I've used so far.

      Best regards

      Gregor

      Author's profile photo Former Member
      Former Member

      Hi Gregor

      I am trying to get the ZGEOCODE up and running, bu I keep having the problem, that the tables are not being created, although ther installation indicates otherwise:
       

      Start import of nugget C:/Projects/ZGEOCODE/build/ZGEOCODE.nugg

      Installed: TABL - ZCOMT_BSP_BP_OSM
      Installed: TABL - ZGEOCODE_BP_DIST
      Installed: TTYP - ZGEOCODE_BP_DIST_TABLE
      Installed: CLAS - ZCL_GEOCODE_NOMINATIM
      Installed: CLAS - ZCL_GEOCODE_HELPER
      Installed: CLAS - ZCL_BSP_BP_OSM
      Installed: CLAS - ZCL_GIS_ROUTE_YOURS
      Installed: WAPA - ZGEOCODE_OSM
      Installed: WAPA - ZGEOCODE_MOBILE
      Installed: PROG - ZGEOCODE_NOMINATIM_ZAKE_SVN
      Installed: PROG - ZGEOCODE_NOMINATIM_READ_BP
      Installed: PROG - ZGEOCODE_NOMINATIM_TEST
      Installed: PROG - ZGEOCODE_NOMINATIM_TEST_SURR
      Installed: PROG - ZTEST_GIS_ROUTE_YOURS
      Installed: WDYN - ZGC_BP_OSM
      Installed: SMIM - /SAP/BC/WEBDYNPRO/SAP/ZGC_BP_OSM/OSMAP.SWF
      Installed: INTF - ZIF_GEOCODE_YANDEX_CONST
      Installed: CLAS - ZCL_GEOCODE_YANDEX
      Installed: WDYA - ZGC_BP_OSM

      If possible, could you guide me in the the right direction

      Regards

      Bent

      Author's profile photo Gregor Wolf
      Gregor Wolf
      Blog Post Author

      Dear Bent,

      have you activated all the DDIC objects and then tried to activate the Programms / Classes?

      Best regards

      Gregor