|
View previous topic :: View next topic
|
| Author |
Message |
adrianlmk
New User
Joined: 02 Jan 2008 Posts: 11 Location: Malaysia
|
|
|
|
Hi All,
I'm having a issue with my recent code to split my record into respective copybook field.
Here is my sample input
Sample Input:
| Code: |
1) abcd,,cdef,"New York, US","New business",Jason
2) abcd,,cdef,"New York, New Jersey,US",,Jason
3) abcd,,cdef,,"New Business",Jason
|
Expected output is
| Code: |
Record 1
field 1 = abcd
field 2 = spaces
field 3 = cdef
field 4 = New York, US
field 5 = New business
field 6 = Jason
|
| Code: |
Record 2
field 1 = abcd
field 2 = spaces
field 3 = cdef
field 4 = New York, New Jersey,US
field 5 = Spaces
field 6 = Jason
|
| Code: |
Record 3
field 1 = abcd
field 2 = spaces
field 3 = cdef
field 4 = Spaces
field 5 = New business
field 6 = Jason |
My concern will be more on field 4 because if i use Parse stopaft comma, it will split the field New York, US into 2 different field.
At the same time I want to remove the " from the field4 and field5 in record 1 & 2
Is it possible to use a direct Parse to get the output as shown above?
Appreciate for the input from you. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
did You notice that Your previous topic was edited to use for the data the code tags ?
and the same has been done with this one!
code tags use a fixed pitch font an make data more understandable
doing so from the beginning shows good manners
and saves the moderators time to edit poorly formatted posts |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
adrianlmk,
Refer to PAIR=QUOTE
See if below works...Field lengths assumed....
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
abcd,,cdef,"New York, US","New business",Jason
abcd,,cdef,"New York, New Jersey,US",,Jason
abcd,,cdef,,"New Business",Jason
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,
PARSE=(%01=(ENDBEFR=C',',FIXLEN=04),
%02=(ENDBEFR=C',',FIXLEN=04),
%03=(ENDBEFR=C',',FIXLEN=04),
%04=(ENDBEFR=C',',FIXLEN=27,PAIR=QUOTE),
%05=(ENDBEFR=C',',FIXLEN=27,PAIR=QUOTE),
%06=(ENDBEFR=C',',FIXLEN=20)),
BUILD=(%01,
%02,
%03,
%04,
%05,
%06)),
IFTHEN=(WHEN=INIT,
FINDREP=(IN=C'"',OUT=C' '))
OPTION COPY
/*
//*
|
OUTPUT
| Code: |
abcd cdef New York, US New business Jason
abcd cdef New York, New Jersey,US Jason
abcd cdef New Business Jason |
Thanks, |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| Please do not post in more than one forum at a time - it wastes your time and everyone else's. Apart from being considered rude. |
|
| Back to top |
|
 |
adrianlmk
New User
Joined: 02 Jan 2008 Posts: 11 Location: Malaysia
|
|
|
|
| enrico-sorichetti wrote: |
did You notice that Your previous topic was edited to use for the data the code tags ?
and the same has been done with this one!
code tags use a fixed pitch font an make data more understandable
doing so from the beginning shows good manners
and saves the moderators time to edit poorly formatted posts |
Thanks Enrico for pointing out. I was searching for this code function to make it more easy to read but can't find it. I will be more careful next time. |
|
| Back to top |
|
 |
adrianlmk
New User
Joined: 02 Jan 2008 Posts: 11 Location: Malaysia
|
|
|
|
| Nic Clouston wrote: |
| Please do not post in more than one forum at a time - it wastes your time and everyone else's. Apart from being considered rude. |
Hi Nic, apologies as I do not have the intention to post twice because I thought I should post at the other topic since I looking for different type of solution. Will be more aware next time. Thanks |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Ee did encourage adrianlmk to ask again in a a forum appropriate to his Sort, as that would provide a better solution than writing a thing in Cobol. |
|
| Back to top |
|
 |
adrianlmk
New User
Joined: 02 Jan 2008 Posts: 11 Location: Malaysia
|
|
|
|
sqlcode1,
Thanks. It working fine and really appreciate that. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|