Page 1 of 1

Sort record without disturbing Trailer record

PostPosted: Mon Apr 18, 2011 10:48 am
by vishnusrini
Hi,

I want to sort a file without disturbing Trailer record. I used below code, but it is not working.

OPTION COPY
INCLUDE COND=(1,1,CH,NE’T')
OUTREC IFTHEN=(27,8,CH,A,
37,7,CH,A)

In trailer record first character is ‘T’, so I used above code, but unsuccessful.

Re: Sort record without disturbing Trailer record.

PostPosted: Mon Apr 18, 2011 3:42 pm
by NicC
What is not working? I believe that is you want to SORT then you should not be doing a COPY.

Re: Sort record without disturbing Trailer record.

PostPosted: Mon Apr 18, 2011 7:59 pm
by BillyBoyo
If you sort on the position of the trailer indicator first - and assuming you have logical values for header and data records - your trailer will be "undisturbed", as far as the order of the file is concerned.

As NicC has pointed out, if you want to sort the file, you will have to use the sort package to do a SORT not a COPY. And not OMIT the trailer (exclude it) which is what you seem to have coded so far.

Re: Sort record without disturbing Trailer record.

PostPosted: Mon Apr 18, 2011 10:14 pm
by skolusu
vishnusrini,


The syntax you show is not a valid syntax. As billy mentioned you are performing copy operation rather than sorting. If your intention is to sort the values at pos 27 for a length of 8 and pos 37 for a length of 7 you can use DFSORT's DATASORT operator like shown below

//STEP0100 EXEC PGM=ICETOOL   
//TOOLMSG  DD SYSOUT=*       
//DFSMSG   DD SYSOUT=*       
//IN       DD DSN=your input file,DISP=SHR
//OUT      DD SYSOUT=*                           
//TOOLIN   DD *                                   
  DATASORT FROM(IN) TO(OUT) TRAILER USING(CTL1)     
//CTL1CNTL  DD *                                   
  SORT FIELDS=(27,8,CH,A,37,7,CH,A)
//*


Check this link for complete description of the datasort operator

http://publibz.boulder.ibm.com/cgi-bin/ ... E1CA50/7.6?

Re: Sort record without disturbing Trailer record.

PostPosted: Fri Apr 22, 2011 11:40 am
by vishnusrini
ok thanks, it is working fine.