View previous topic :: View next topic
|
Author |
Message |
sambasivarao
New User
Joined: 10 Jul 2006 Posts: 47 Location: Bangalore
|
|
|
|
Hi All,
Iam having NAME - 30 characters of length. I need to sort this name like First name, Last Name and Middle Name but i don't know from where middle and last names will start. For sure there is a space will come after first name, middle name and last name. Kindly help me how to sort this NAME separately as FIRSTNAME, MIDDLE NAME, LAST NAME ?
Thanks,
Sambasiva. |
|
Back to top |
|
|
kratos86
Active User
Joined: 17 Mar 2008 Posts: 148 Location: Anna NGR
|
|
|
|
sambasivarao wrote: |
I need to sort this name like First name, Last Name and Middle Name |
You want to sort the file based on names or split the 30 byte name as first name, last name and middle name. If you want to split it, you will find lot of examples right here in this forum. Try it and let us know what issues you are facing.
Also provide more details like what should be maximum length of each field and if in case there is no middle name how to find it. It will be better if you give us some sample input records. |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
Back to top |
|
|
sambasivarao
New User
Joined: 10 Jul 2006 Posts: 47 Location: Bangalore
|
|
|
|
The length of the FIRSTNAME, MIDDLE NAME, LAST NAME is not constant. But space will separate among these.
EX: Find the below names how the length is varying of each. But for sure we are seeing space among all the three.
SAMBASIVA REDDY RAVURI
SRINIVASA RAO RAVURI
MAHENDRA BABU KOTA
PAVAN KUMAR KOTA
Kindly help me how to sort ?
Regards,
Sambasiva. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
sambasivarao,
Assuming you want to sort the input on FIRSTNAME, the following DFSORT JCL will give you the desired results.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
SAMBASIVA REDDY RAVURI
SRINIVASA RAO RAVURI
MAHENDRA BABU KOTA
PAVAN KUMAR KOTA
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC PARSE=(%01=(ENDBEFR=C' ',FIXLEN=30),
%02=(ENDBEFR=C' ',FIXLEN=30),
%03=(ENDBEFR=C' ',FIXLEN=30)),
BUILD=(%01,%02,%03)
SORT FIELDS=(1,30,CH,A)
//* |
The output of this is
Code: |
MAHENDRA BABU KOTA
PAVAN KUMAR KOTA
SAMBASIVA REDDY RAVURI
SRINIVASA RAO RAVURI
|
|
|
Back to top |
|
|
|