Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How DFSORT able to to work in the scenerion by PARSE

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
adrianlmk

New User


Joined: 02 Jan 2008
Posts: 11
Location: Malaysia

PostPosted: Tue Feb 28, 2012 10:20 pm    Post subject: How DFSORT able to to work in the scenerion by PARSE
Reply with quote

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
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Tue Feb 28, 2012 10:26 pm    Post subject: Reply to: How DFSORT able to to work in the scenerion by PAR
Reply with quote

did You notice that Your previous topic was edited to use for the data the code tags ? icon_evil.gif

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
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Tue Feb 28, 2012 11:10 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1722
Location: UK

PostPosted: Wed Feb 29, 2012 2:45 am    Post subject:
Reply with quote

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
View user's profile Send private message
adrianlmk

New User


Joined: 02 Jan 2008
Posts: 11
Location: Malaysia

PostPosted: Wed Feb 29, 2012 4:47 am    Post subject: Re: Reply to: How DFSORT able to to work in the scenerion by
Reply with quote

enrico-sorichetti wrote:
did You notice that Your previous topic was edited to use for the data the code tags ? icon_evil.gif

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
View user's profile Send private message
adrianlmk

New User


Joined: 02 Jan 2008
Posts: 11
Location: Malaysia

PostPosted: Wed Feb 29, 2012 4:49 am    Post subject:
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7251

PostPosted: Wed Feb 29, 2012 5:41 am    Post subject: Reply to: How DFSORT able to to work in the scenerion by PAR
Reply with quote

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
View user's profile Send private message
adrianlmk

New User


Joined: 02 Jan 2008
Posts: 11
Location: Malaysia

PostPosted: Wed Feb 29, 2012 8:21 am    Post subject:
Reply with quote

sqlcode1,

Thanks. It working fine and really appreciate that.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts DFSORT sorting only specific records akodakka DFSORT/ICETOOL 4 Thu Aug 04, 2016 11:24 am
No new posts Symbolic Parameters in SYSIN DD state... madishpa DFSORT/ICETOOL 3 Mon Jun 27, 2016 6:23 pm
No new posts DFSORT to match two files and write John F Dutcher DFSORT/ICETOOL 6 Thu May 12, 2016 5:17 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us