Technical Articles
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:
Then you will be directed to the map showing the Business Partner location:
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:
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:
So if you like to use that in your own system check out the SCN Wiki Page on ZGEOCODE.
Great Project! It works very well.
Best regards
Renald
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.
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
Cheers
Graham Robbo
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
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
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
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
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
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
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
Short Text
What happened?
Error analysis
Missing RAISING Clause in Interface
Trigger Location of Exception
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
Dear Gregor,
many thanks for your fast support. I've deleted this webdynpro and it coult be transported.
best regards Karl
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
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
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
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
Dear Bent,
have you activated all the DDIC objects and then tried to activate the Programms / Classes?
Best regards
Gregor