Presentation on theme: "Chris Twirbutt & Forrest Horner"— Presentation transcript:
1Chris Twirbutt & Forrest Horner Address CleansingIntegration of REST web servicesChris Twirbutt & Forrest Horner2010 November
2Melissadata REST & SAP Integration Background of Sacramento CountyAddress cleansing choicesArchitecture to facilitate REST web servicesExample SAP screens
3Background Sacramento County CA Sacramento County, CaliforniaAbout 1.3 million citizensMultiple jurisdictions, Cities, Districts, etcSAP IS-U/CCS Utility Billing System (aka: “FOCUS”)Implemented in July 1999 (on v1.1b)…now vECC6Bill for ~300K customers, ~$300m revenueWaste Water, Solid Waste, Drainage, Potable Water…have a SAP tech support staff of: ~8
4Address Cleansing Choices #1 – Load Postal CD’s to SAP Regional Structure…but alas, it doesn’t fix “bad” addresses…only flags address is not good.#2 – Periodic Batch CleansingIs re-active management…and bad addresses percolate through downstream data systems.#3 – Web Service Address CleansingIs pro-active,but must put in a technical architecture.
5Postal CD Data – Does Not “Fix” Postal CD comes from the Post MasterThe USPS web siteThe web site has the postal AIS technical guide in PDF formatand order forms for ordering the postal CD.Note: RSADRLSM02 is the program that loads the dataConnection ObjectNote: SAP function module ADDR_CHECK is what SAP uses for verifying if an BP or CO address is valid against the postal structuresBusiness Partner
6Periodic Batch Cleanse (Monthly) SAP ProductionDataExtractADRC tableFile dumpCleansing ServiceAddressCorrectionsFileData Upload and updateThis fixes after the fact…after bad mail has already gone out…and after other downstream data systems have already consumed the bad address
7Melissadata – Web Service Has many different address cleansing productsMeldata provides back a ‘corrected’ address.SAP Production / SYSID:“PPW”WebServiceFOCUSDev / TestSystemsWeb HitCounterRFCAddressCacheAn “architecture” had to be built in SAP. The SAP production system acts as a “service buss”.
8Overview of MelData Web Services Mellisadata (Henceforth referred to as “Meldata”) offers numerousservices and Suites of Services.Sac County procured the “Data Quality Web Services Suite” , which is a“Multiplatform toolkit to verify, correct and standardize address, phone, and names at point-of-entry.”This Suite consists of 7 services, 5 of which we have enabled ( )And two of which we are currently using ( ) :Address CheckRBDI (Residential/Business Delivery Indicator)GeoCodeIP LocationName CheckPhone Check
9Usage allowanceWe subscribed to 600K hits per year for each enabled service.The following is a screen-print from MelData’s side which tracks our usage:
10Technical Implementation SOAP vs. RESTOverall, more companies such as Google and Amazon are using REST-based Web Services.REST stands for “Representational State Transfer”.We won’t go into fine detail of SOAP vs. REST but rather, why we chose REST.A nice robust link on the technical differences between SOAP and REST:We utilize the REST-based Web Service Interface because:SOAP required more JAVA skills than were available in-house, for example:SOAP had many data-type binding issues which had to be worked out by contacting MelData tech support and having them make changes to the WSDL, etc.REST was 10 times easier to code for in ABAP as it didn’t have to deal with Proxy generation (data binding issues), and other JAVA-related issues.Developers who simply understand HTTP and XML can start building Web services right away, without needing any toolkits beyond what they normally use for Internet application development.
11BASIS/Config. Requirement (for SAP to communicate with the Web Service) Using SSL (https) to access external web site recommended.- Public web servers have SSL certificates signed by known public Certificate Authority- Web browsers come with built-in store of known public CA’s to verify certificate server is presenting.The SAP Web Application Server (Web AS) ships with very few CAs, so it won’t know the CA the remote site had its SSL cert signed by. For example, Melissadata uses “GoDaddy”.-Navigate to the secure URL using a web browser, not SAP initially.-While there, click the “lock” icon and download the security certificates in base 64 format. This incl. both the root and class 2 certificates. -There may be multiple cert’s, called a chain. Download cert for each part of chain.-Load the security certificate into SAP (STRUST)-Import certificates into SAP anonymous &client standard PSE’s (Personal Security Environment)-Still In STRUST, export the certificates (to load them into the db).-Restart ICM.-Set up a “hosts file” entry, if needed (i.e. DNS is turned off, which it is in PPW) to Melissadata so the SAP server “knows” who Melissadata is.
12Architecture Overview Custom(‘Z’) Naming ConventionBegin all Web-Service-related Z-table names with “ZWS_”
13Architecture Overview (cont’d) All requests for address scrubs are done thru PPW (Production), regardless of source system. This is done by RFC and ensures that all hits are tracked in one place (Production).PPW architected with several control & tracking tables:A master table(ZWS_MELDATA) which stores/caches all detailed request historyA table to configure how many hits allowed per day (ZWS_HITS_MAX)A table to store actual hits per day counts (ZWS_HITS_DAILY)
14Architecture (Cont’d) PPW contains (cont’d):table (ZWS_MELDATACODES) stores all possible return codes (and descriptions)Note on Return Codes:1st Char:Address Scrub return Codes begin with “A”and GeoCoding Return Codes begin with “G”.2nd Char:“S” (Success – Corrected address returned)or “E” (Error – Not able to return a fully corrected address)
15Architecture (Cont’d) Communication to PPW from all systems:-An RFC interface was added (By BASIS) to all the systems that "points to" PPW. This interface is named "PPW_SCRUB".-A user and role was created in PPW to perform the scrub function. The user is "adrscrub", and the role is "z_address_scrub".Communication to Web Service from SAP/ABAP:A user-friendly wrapper/RFC/FM was developed called:ZMELISSADATA_ADDRESS_CLEANSEThis FM/RFC currently performs both Address Check and Geocoding.This FM uses SAP’s OO methods contained in Class/Interface “IF_HTTP_CLIENT”,For example:CALL METHOD http_client=>create_by_url (sets up the URL to be called)CALL METHOD http_client->send (makes a call to the URL)CALL METHOD http_client->receive (receives data back from URL)The result comes back in XML format and is parsed by the FM (could have been done using XLST Transformation, but in our case using custom code to parse the XML result into Z-Table fields (this was prior to our knowledge of XLST Transformations).
16Example of how to call the RFC OUTINNote: Input has incorrect Street name(“AVE” vs. “RD”) and incorrect zip (95826Instead of 95827)Output has corrected Street NameAnd Zip Code (+4).“Address Key” required for GeoCoding (see next slide)
18Table Entry Created (in ZWS_MELDATA) MANDTCOUNTER ALL TIMESOURCE SYSTEM PPWSOURCE USER TWIRBUTTCCALLING PROGRAM SAPLSEUJCALLING TXN SE37CALLED ON DATE /14/2010CALLED ON TIME :06:45CALLED BY ADRSCRUBURL CALLED https://addresscheck.melissadata.net/v2/REST/Service.svc/doAddressCheck?id= &a1=9700%20GOETHE%20AVE&ctry=US&opt=true&a2=&ste=C&city=SACRAMENTO&state=CA&zip=95826RETURN CODE AS01,AS12BACKGROUND FLAGIN HOUSE NUMIN STREET GOETHE AVEIN SUITE CIN CITY SACRAMENTOIN STATE CAIN ZIPOUT PARSED HOUSEOUT PARSED STR GoetheOUT PARSED STSUF RdOUT PARSED SUIT1 SteOUT PARSED SUIT2 COUT ADDRESS Goethe RdOUT ADDRESS2OUT SUITE Ste COUT CITY SacramentoOUT STATE CAOUT ZIPOUT PLUSOUT RESULT CODES AS01,AS12HOUSESTREETMATCHCITY MATCH XSTATE MATCH XZIP MATCHADRC NUMOUT ADDRESSKEYGEO RESULT CODES GS01GEO LATGEO LONG
19ZWS_MELDATA: Field Definitions MANDTCOUNTER_ALL_TIME # of hits made to the Web Service (all-time)SOURCE_SYSTEM PPW Calling SystemSOURCE_USER TWIRBUTTC Self-explanatoryCALLING_PROGRAM SAPLSEUJ “CALLING_TXN SE “CALLED_ON_DATE /14/ “CALLED_ON_TIME :06: “CALLED_BY ADRSCRUB RFC User id (set up by BASIS)URL_CALLED https://addresscheck.melissadata.net/v2/REST/Service.svc/doAddressCheck?id= &a1=0970%20GOETHE%20AVE&ctry=US&opt=true&a2=&ste=C&city=SACRAMENTO&state=CA&zip=95826RETURN_CODE AS01,AS MelData Return CodesBACKGROUND_FLAG Background/Foreground indicatorIN_HOUSE_NUM Input House #IN_STREET GOETHE AVE Input StreetIN_SUITE C Input Suite (opt’l)IN_CITY SACRAMENTO Input CityIN_STATE CA Input StateIN_ZIP Input ZipNote:Key fields are MANDT & COUNTER_ALL_TIMEIndex exists on URL_CALLED since we CACHE based on this one field (each unique URL represents a unique Address-Check).Continued on next Slide…
20Field Definitions (cont’d) OUT PARSED HOUSE Parsed Address fields returned from MelDataOUT PARSED STR Goethe “OUT PARSED STSUF Rd “OUT PARSED SUIT1 Ste “OUT PARSED SUIT2 C “OUT ADDRESS Goethe Rd “OUT ADDRESS “OUT SUITE Ste C “OUT CITY Sacramento “OUT STATE CA “OUT ZIP “OUT PLUS “OUT RESULT CODES AS01,AS MelData Return Code(s)HOUSESTREETMATCH Did INPUT House # and Street match the OUTPUT House # and Street ?CITY MATCH X Did INPUT City match the OUTPUT City ?STATE MATCH X Did INPUT State match the OUTPUT State?ZIP MATCH Did INPUT Zip match the OUTPUT Zip ?ADRC NUM ADRC Record # scrubbed (if applicable)OUT ADDRESSKEY Meldata address key returned (needed to GeoCode)GEO RESULT CODES GS GeoCode Return Code(s)GEO LAT GeoCode Lat ResultGEO LONG GeoCode Long Result
21Find Billing Account by Address lookup Via GeoCoding Step 1 – Meldata address check-- Cache result in table ZWS_MELDATAStep 2- Update sap address if necessary and possible (if address scrub was successful)Step 3 – Using MelData Address key (from Successful scrub only), get lat longStep 4 – Using haversine formula, get nearest parcel (ZPSD_APN) and VKONT (ZGIS_APN_DATA)(Using FM “Z_RFC_LAT_LONG_IN_PARCEL_OUT”)INOUTSince Geo-Coding is not always down to the rooftop level, enter As much info of theAddress as possible (in this case House # and 1st letter of Street)
22Secret Sauce: HAVERSINE Formula SAP ABAP program code:Assume that U = North Pole, and V and W are our pair of X,Y coordinates (note the variable names above do not match that of the program code in this presentation)a,b, and c are the “Great Circle”* distances between U,V and W.* A great circle of a sphere is a circle that runs along the surface of that sphere so as to cut it into two equal halves. The great circle therefore has both the same circumference and the same center as the sphere. It is the largest circle that can be drawn on a given sphere.Great circles serve as the analogue of "straight lines" in spherical geometry.
23Other FOCUS Applications: This stand alone screen demonstrates the architecture.Link to Youtube demo of this screen:Link to SAP Developer Network (SDN):
24Other FOCUS Applications: E.g. Lifeline Entry (for Non-FOCUS Accts.) New ButtonNew Sub-screenFor scrubbed addressResults.
25Future IntegrationManaged update, with clerical review of suggested Address fixes.Fully Automated update of our Address from Mel-Data.Business Partner mailing address updatePhysical location addressesTo be continued……A myriad of other opportunities will present themselves:Finding duplicate customers, locations.Finding missing locations: address exists, but we aren’t billing.Geocoding & Work Order proximity based routing.Regional MADD (Master Address Database)Effort by Cities, and public safety, police, fire, etc to standardize addresses.Lessons Learned:Must have an architecture to facilitate & manage the web service “hits”Must involve your BASIS team to “open up” the interfaceMass cleansing (thousands at a time) needs “404” error handlingMelissadata tech team were great to collaborate with!...an essential aspect.