How to get a Lastname from a field that contains the Full Name? (RPG-ILE)

5 pts.
Tags:
AS/400 development
AS/400 Query
RPG ILE
RPG/400
Hi Guys, I need your suggestions.... I have to extract data from our AS400 box and convert it into text file. For a client's name we have 3 particular fields. 1. FirstName, 2. LastName and 3. FullName. The problem is there are records where First Name and LastName fields are empty. Thats why I have to look on the 3rd Field which is the Full Name, but the data on this field are not on same format. Here are the particular formats: ROD Y. JACKSON (there are names that have middle initial on it) MARK LESTER JOHNSON (there are names that have two names before the lastname) JUAN DELA CRUZ (there are two-string last names) RUDY ATKINS JR. (there are names that have JR. II, III, etc, on the last part of the string) ABC Company Inc. (There are names that had been named under a company) What would be tha best approach for these scenarios? Im using an RPG-ILE language Thanks in advance....
ASKED: January 13, 2009  6:55 AM
UPDATED: January 16, 2009  8:50 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hi,

This is probably going to get tricky whatever you do and is likely to need some manual intervention.

First take a backup copy of your file – always good practice.

I would suggest that you get something to pick out the last name only to start with by locating the last string in the field – you can ignore certain strings like JR and look for the string that precedes them. Use the string you found as the lastname field and remove this string from the fullname field.

You should now have a last name filled for all your records. Now you can create a list of records which still contain more than one string in the fullname field. These records will probably need manual intervention as it’s almost impossible to code for whether the person has two first names or two last names. The company names will most likely appear on the list as well.

I know this isn’t marvellous, but in this situation you can only code for so many combinations.

Regards,

Martin Gilbert.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

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
  • philpl1jb
    Niel How many are in error?As Martin said this will be tricky and you'll never get it 100% right programmatically. It might be quicker to create an interactive RPG program and have a clerk fill in the missing fields. Phil
    48,565 pointsBadges:
    report
  • Brenger
    If I were doing it, I would move it into an array. Set up a file of suffixes (jr sr, etc). start from the end, count backwards to the first blank. Check to see if that is a suffix. If not, move it into last name. Start from the first and count forward to first blank for the first name. etc, etc set up an error print or file of ones that are undeterminable. etc, etc hopefully, your file is not too big.
    170 pointsBadges:
    report

Forgot Password

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

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

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

Thanks! We'll email you when relevant content is added and updated.

Following