|
View previous topic :: View next topic
|
| Author |
Message |
norm.flynn
New User
Joined: 08 Jan 2013 Posts: 20 Location: usa
|
|
|
|
I have a file with a name last name, first name, followed by some other data, need to split the name field into 2 fields last name and first name, the name field itself is fixed.
| Code: |
=COLS> ----+----1----+----2----+----3----+----4----+---
000008 0 000003401 ADAMS, MARIA R. CX A
000009 000004440 WADE, MAUREEN YVETTE CX A
000010 000011500 ALFARO, CARMEN MERCEDEZ CX A |
So the name fiels starts at 16, and ends at 43. Just need the parse statement to create the 2 fields last name and first name
Thanks
Norm |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| What output are you expecting from that sample? |
|
| Back to top |
|
 |
norm.flynn
New User
Joined: 08 Jan 2013 Posts: 20 Location: usa
|
|
|
|
I am expecting 2 fixed fields one with the last name and one with the first name. I know how to include the parsed fields in a build statement, just not sure how to construct the 2 parsed fields.
Thanks |
|
| Back to top |
|
 |
norm.flynn
New User
Joined: 08 Jan 2013 Posts: 20 Location: usa
|
|
|
|
| My difficulty is that there is could be an embedded space in the first name, so not sure how to get the parse to stop in the correct place, ideally I could have it search just the positions taken up by the entire name, but that does not seem to be an option. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| OK, can you post some sample data which covers all the things you can think of, and show the actual expected output for that data, please. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Use the following DFSORT JCL which will give you the desired results.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
0 000003401 ADAMS, MARIA R. CX A
000004440 WADE, MAUREEN YVETTE CX A
000011500 ALFARO, CARMEN MERCEDEZ CX A
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC BUILD=(16,28)
OUTREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=20),%02=(FIXLEN=20)),
BUILD=(%01,%02)
//* |
|
|
| Back to top |
|
 |
norm.flynn
New User
Joined: 08 Jan 2013 Posts: 20 Location: usa
|
|
|
|
Thanks, I didn't mention that I needed to create an output file which splits many other fields from a report into a tab-delimited file. You solution gave me the idea to just add the name field at the end of the inrec, and then apply your parse command to the extra field and include them in the outrec, which work fine. The final sort statment is as follows
| Code: |
SORT FIELDS=COPY
INREC BUILD=(1,133,16,28)
OUTREC PARSE=(%01(ABSPOS=134,ENDBEFR=C',',FIXLEN=20),
%02=(FIXLEN=20)),
BUILD=(4,9,X'05',%01,X'05',%02,X'05',44,2,X'05',47,1,X'05',
50,17,X'05',68,8,X'05',78,3,X'05',82,11,X'05',95,3)
|
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|