How to match customer addresses during order entry

John Kohan, Search400 expert

John Kohan

Recently, I was given the task of matching customer addresses during order entry. Order entry at my company is achieved via EDI, Web site and traditional hand keying. What made this a challenge was the different ways people enter addresses. Some enter abbreviations, while others spell out the word. In addition, because there are multiple lines for the address, the first line may contain the street number or a comment.

As I began to review some addresses we had already received, it became apparent that matching a name was also impossible. There are so many deviations in name spelling; it really did not impact on the fact if two addresses were the same physical address.

The first step I took was to make sure the address lines were what I expected. Therefore, I removed all leading blanks. Once this was complete, I converted the address lines from lower case to upper case.

C           1         DO   4         X       30            
C           ' '       CHECK@ADD,X:1  N       20           
C                     SUBSTADD,X:N   ADD,X     P           
C                     ENDDO                                

C           LC:UC     XLATE@ADD,X     @WORK  

Next, I looked at which line of the address contained the street address. I needed this because some customers may place purchase order numbers, comments or other non-location reference information in the multiple lines of the address. I did this by searching for a number in the first position.

C           1         DO   4         X       30    
C                     MOVELADD,X     @FRST    1     
C           NBRCON    CHECK@FRST                    70     
C           *IN70     IFEQ *OFF                       
C                     LEAVE                        
C                     ENDIF                        
C                     ENDDO    

Now that I have located the address line within the four lines of available address, I needed to extract the words and normalize them if possible. First, I found each of the words in the line. Then I needed to search a database that stores substitute phrases, such as "ST" for "STREET".

C** Start from the first char                   
C                     Z-ADD1         S       30 
C                     Z-ADD1         E       30 
C                     Z-ADD1         L       30 
C** Extract each of the words out
C           *IN70     DOUEQ*OFF                           
C           ' '       SCAN ADD,Z:S   E              70    
C           *IN70     IFEQ *ON                            
C           E         SUB  S         L                    
C** If we are all done, get out                           
C           L         IFEQ *ZEROS                         
C                     LEAVE                               
C                     ENDIF                               
C** Extract a part of the Address
C           L         SUBSTADD,Z:S   @PARSE 20            
C** Setup the spacing in the name field          
C           S         IFEQ 1                     
C                     Z-ADD0         X       30  
C                     ELSE                       
C                     Z-ADD1         X           
C                     ENDIF                      
C** See if a substitution exists                       
C           @PARSE    IFNE *BLANKS                     
C           @PARSE    CHAINRSUBSTUT             80     
C           *IN80     IFEQ *OFF                        
C                     CAT  SSTO:X    @ADDR  60           
C                     ELSE                             
C                     CAT  @PARSE:X  @ADDR             
C                     ENDIF                            
C                     ENDIF                            
C** Start the next search at the next char             
C           E         ADD  1         S                 
C                     ENDIF                            
C                     ENDDO      

This now has the address that is normalized so I can check to see if I have another just like it so that special processing may occur. One could argue that removing all the spaces from the address now would produce a better comparison. I chose not to do that because it would make little difference in my needs.

In my address file, the city-state and zip code fields are segregated from the lines of address. The extraction of these was not needed, but it could be easily achieved using the technique above.

The code above came from three programs I created. The example is in RPG/400, since that is the "Shop Standard". These three programs use array processing so they can be used a modular fashion. I load the new address into the array and format it. Next, I load the address I wish to compare to and format it. Then the only part left is the actual "IF" statement to test if they are the same.

Although your address needs may be different, my intention is to offer a solution that will foster thought and ultimately help you find the solution you need.

About the author: John Kohan is a senior programmer analyst at CT Codeworks.


There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.