Page 1 of 1

need to SORT a file which having 2 types of records

PostPosted: Fri Dec 30, 2011 1:47 pm
by jyothp12
Hi,

I have a file like this.

1 jim124
4xrampun876
2xtomkol756
3 ken456

I need to sort this file which is having 2 types of records - one with space in 2nd position and another with 'x' in 2nd position.
The field from 6-8 pos in first rec is same as 9-11 in 2nd type ( suppose it is marks)

need to sort file with first filed ( which is roll num) and marks.

Please suggest a method

Thanks in advance

Re: need to SORT a file which having 2 types of records

PostPosted: Fri Dec 30, 2011 2:20 pm
by BillyBoyo
It can be done, but can you please give fuller information. RECFM, LRECL and start/length of the fields to be sorted on.

To sort on data that is in different positions, you need to get them into the same position. So, in the sort, you extend your record (at the end if fixed-length, at the beginning if variable) to define a field which is sourced from two different locations depending on type. You do this with INREC (which is before the data are sorted) and then specify that field (plus whatever else) on the SORT itself.

If you want to have a go at this yourself, please do and let us know how it goes. Otherwise I expect a solution will appear once you provide full information.

Re: need to SORT a file which having 2 types of records

PostPosted: Fri Dec 30, 2011 3:26 pm
by jyothp12
Hi Bill

Thanks for ur reply..Im also planning to do the same, to PUSH the marks field to end and sort..hope it will work..

Re: need to SORT a file which having 2 types of records

PostPosted: Fri Dec 30, 2011 3:59 pm
by BillyBoyo
Good for you. Let us know if you have any problems, or show your solution when you get it working, it can help others with the same sort of question later.

Re: need to SORT a file which having 2 types of records

PostPosted: Fri Dec 30, 2011 4:27 pm
by enrico-sorichetti
in IT terminology is crucial to good communication...

PUSH has a precise meaning in DFSORT literature and control statements

I guess that You really meant IFTHEN and OVERLAY

Re: need to SORT a file which having 2 types of records

PostPosted: Fri Dec 30, 2011 11:48 pm
by Frank Yaeger
You didn't give the positions of your first field or the RECFM and LRECL of your input file, so I can't give you a complete solution. But here's a DFSORT job to sort on your marks field for an input data set with RECFM=FB and LRECL=80. Hopefully you can work out the rest yourself. If not, supply the missing information.

//S1 EXEC PGM=SORT                                           
//SYSOUT DD SYSOUT=*                                         
//SORTIN DD *                                               
1 jim124                                                     
4xrampun876                                                 
2xtomkol756                                                 
3 ken456                                                     
//SORTOUT DD SYSOUT=*                                       
//SYSIN DD *                                                 
  INREC IFTHEN=(WHEN=(2,1,CH,EQ,C' '),OVERLAY=(81:6,3)),     
        IFTHEN=(WHEN=NONE,OVERLAY=(81:9,3))                 
  SORT FIELDS=(81,3,CH,A)                                   
  OUTREC BUILD=(1,80)                                       


SORTOUT would have:

1 jim124         
3 ken456         
2xtomkol756       
4xrampun876