Page 1 of 1

Sort the records of the dataset except it's first records?

PostPosted: Wed Dec 17, 2008 10:29 am
by vmahaja1
How can I sort the records of the dataset except it's first records? The output file should contain the first record as it is and rest in sorted order.

Thanks in advance.

Re: DFSORT

PostPosted: Wed Dec 17, 2008 10:34 pm
by Frank Yaeger
You can use the new DATASORT operator of DFSORT's ICETOOL, available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) to do that quite easily. If you don't have that PTF, ask your System Programmer to install it (it's free). Here's an example - you didn't give the sort fields you want to use, so I'll assume it's 1,4,CH,A. Change the SORT statement as needed.

//S1   EXEC  PGM=ICETOOL                           
//TOOLMSG   DD  SYSOUT=*                           
//DFSMSG    DD  SYSOUT=*                           
//IN DD *                                           
FIRST                                               
AAAA                                               
CCCC                                               
DDDD                                               
FFFF                                               
GGGG                                               
//OUT DD SYSOUT=*                                   
//TOOLIN DD *                                       
DATASORT FROM(IN) TO(OUT) FIRST USING(CTL1)         
/*                                                 
//CTL1CNTL DD *                                     
  SORT FIELDS=(1,4,CH,A)                           
/*


OUT would have:

FIRST   
AAAA   
CCCC   
DDDD   
FFFF   
GGGG   


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

http://www.ibm.com/systems/support/stor ... /mvs/ugpf/

Re: DFSORT

PostPosted: Thu Dec 18, 2008 10:16 am
by vmahaja1
Frank,
Thank you for ur quick reply. But actully my file is in following format.

1 ---- ---
3 ------------
5---nbr3
5---nbr1
5---nbr5
5---nbr2

7 ------------
3 ------------
5---nbr0
5---nbr4
5---nbr8
5---nbr7
------------
9 ------------------------------

I want to sort only block of records with type 5 on the basis of nbr#. Position of records with typr 1,3, 7 should remain same.

Thanks in advance.

Re: DFSORT

PostPosted: Thu Dec 18, 2008 10:54 pm
by Frank Yaeger
vmahaja1,

Here's a DFSORT job that will work for your new requirement. You'll still need z/OS DFSORT V1R5 PTF UK90013 (July, 2008) to use WHEN=GROUP. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed accordingly. In the future, please describe your "real" requirement in your first post to avoid wasting peoples' time.

//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN DD *
  OPTION EQUALS
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'3'),
    PUSH=(81:ID=8))
  SORT FIELDS=(81,8,ZD,A,1,1,CH,A,5,4,CH,A)
  OUTREC BUILD=(1,80)
/*