Thank you, this worked pretty darn good. I did have a few commas in the data. But this is a onetime 'conversion' into another system... I can manually fix the comma records.
tim
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Dennis Lovelady
Sent: Sunday, July 17, 2011 8:55 AM
To: 'RPG programming on the IBM i / System i'
Subject: RE: First / Last name Parsing... routines.
Are there commas in this field? Any rules that you'd like to share, so we
have an idea of what data you're expecting in this field?
This is off the top of my head and untested. Here, name(x) could be first,
middle, last ... depending upon how you use them within the program...
Given that:
incomingName is the name to be parsed
fullName is a varying length character field, local or otherwise unused
name is an array of (optionally varying length) character fields with
more than one (3?) elements.
On exit
i will contain the number of name elements that are populated + 1
name array will have the portions of the name broken out where separated
by
any number of spaces
Names like Julio de Vegas et cetera may give you fits.
fullName = %Trim(incomingName) ;
For I = 1 to %Elem(name) ;
Clear name(I) ;
EndFOR ;
I = 1 ;
DoW I < %Elem(name) and %Len(fullName) > 0 ;
P = %Scan(' ': fullName) ;
If (p > 0) ;
Name(i) = %Trim(%Subst(fullName: 1: p)) ;
fullName = %Trim(%Subst(fullName: p)) ;
I += 1 ;
EndIF ;
EndDO ;
If name(I) = '' ;
name(I) = fullName ;
Else ;
Name(I) += ' ' + fullName ;
EndIF
Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"The Yankees, as I told you later, are in a slump."
-- baseball great Dizzy Dean
Does anybody have a link or procedure they are willing to share?
I have a field that contains a name (ie: first mi last or first last or
a
ton of every variation you can think of) But I need it broken out in 3
fields
first mi lastname.
Any help would be appreciated.
Thanks, Tim
This e-mail message, including any attachments, is for the
sole use of the intended recipient(s) and may contain
confidential or privileged information. Any unauthorized
review, use, disclosure or distribution is prohibited. If
you are not the intended recipient, please contact the
sender by reply e-mail and destroy the message.
Think Green! Please do not print this e-mail unless you need to. Thank
you.
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
http://archive.midrange.com/rpg400-l.
This e-mail message, including any attachments, is for the
sole use of the intended recipient(s) and may contain
confidential or privileged information. Any unauthorized
review, use, disclosure or distribution is prohibited. If
you are not the intended recipient, please contact the
sender by reply e-mail and destroy the message.
Think Green! Please do not print this e-mail unless you need to. Thank you.
As an Amazon Associate we earn from qualifying purchases.