MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to sort an input file by section?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Dragon_Lee
Beginner


Joined: 13 Feb 2006
Posts: 31
Topics: 17

PostPosted: Tue Jul 03, 2007 8:41 am    Post subject: How to sort an input file by section? Reply with quote

Hello,

I want to sort an input file by section? Can anybody help me to achieve it?

The input file is as below

Code:

77777
55555
66666
22222
33333
*****
11111
22222
44444
33333
*****
88888
77777
*****
44444


The stars are dividing lines. I want to sort each section divided by the lines, i.e. the output file should be -

Code:

22222
33333
55555
66666
77777
*****
11111
22222
33333
44444
*****
77777
88888
*****
44444


Can this be done by DFSORT? Thanks in advance!!
_________________
Dragon
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12380
Topics: 75
Location: San Jose

PostPosted: Tue Jul 03, 2007 8:43 am    Post subject: Reply with quote

Dragon_Lee,

Please SEARCH before posting. Treat the Astericks as header Check this link

http://www.mvsforums.com/helpboards/viewtopic.php?t=5398

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12380
Topics: 75
Location: San Jose

PostPosted: Tue Jul 03, 2007 9:10 am    Post subject: Reply with quote

Dragon_Lee,

Just realized that all the tricks mentioned in the above links are kinda of complicated. here are the sort cards for this task.

I assumed that your input is FB recfm and 80 bytes length

Code:

//SYSIN       DD *                                               
  OPTION EQUALS                                               
                                                             
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),           
        IFTHEN=(WHEN=(1,5,CH,NE,C'*****'),                       
                OVERLAY=(89:SEQNUM,8,ZD,                       
                         81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8)),
        IFTHEN=(WHEN=NONE,                                     
                OVERLAY=(81:SEQNUM,8,ZD)) 

  SORT FIELDS=(81,08,CH,A,                                     
               01,05,CH,A)                 
                                                               
  OUTREC BUILD=(01,80)                                       
/*                                                             


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Dragon_Lee
Beginner


Joined: 13 Feb 2006
Posts: 31
Topics: 17

PostPosted: Tue Jul 03, 2007 8:44 pm    Post subject: Reply with quote

kolusu - Thanks a lot!
_________________
Dragon
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Sep 05, 2008 11:54 am    Post subject: Reply with quote

You can now do this kind of thing more easily with the new WHEN=GROUP function of DFSORT available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) like this:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
77777
55555
66666
22222
33333
*****
11111
22222
44444
33333
*****
88888
77777
*****
44444
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'*****'),
    PUSH=(81:ID=8))
  SORT FIELDS=(81,8,ZD,A,1,5,CH,A)
  OUTREC BUILD=(1,80)
/*


For complete details on the WHEN=GROUP function and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group