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 

Sort using delimiter space

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


Joined: 24 Mar 2004
Posts: 13
Topics: 3

PostPosted: Wed Mar 23, 2005 3:20 pm    Post subject: Sort using delimiter space Reply with quote

Hi,

My input file has only 2 columns as follows. Reg len is 80. The lengthof first column will be 1 to 9, length of 2nd key is 2. The keys are delimited by single space.
Code:

1 12
1 56
111 11             
2222 11
2222 68
3333 11
4444 15
4444 67
999999999 11
999999999 68

The records have to sorted as per first column value, but whenever the duplicate exists, then it has to consider only the duplicates(not the first record in duplicates). The value of 2nd column will be in ascending order for duplicates(for ex: The record 4444 has high value 67 in duplicate record and 11 in first record).
The key can have only 2 rows at the most. For ex, there will not be any other new row for 4444.

The output of above input should be,
Code:

1 56
111 11             
2222 68
3333 11
4444 67
999999999 68

Any help is appreciated.
Thanks.
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: Wed Mar 23, 2005 4:28 pm    Post subject: Reply with quote

Here's a DFSORT job that uses the the new IFTHEN and OVERLAY parameters available with z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004) to do what you want. I assumed that your input file has RECFM=FB and LRECL=80, although the job can be changed appropriately for other attributes.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=(5,8,CH,EQ,C' '),OVERLAY=(81:1,1,90:3,2)),
        IFTHEN=(WHEN=(6,7,CH,EQ,C' '),OVERLAY=(81:1,2,90:4,2)),
        IFTHEN=(WHEN=(7,6,CH,EQ,C' '),OVERLAY=(81:1,3,90:5,2)),
        IFTHEN=(WHEN=(8,5,CH,EQ,C' '),OVERLAY=(81:1,4,90:6,2)),
        IFTHEN=(WHEN=(9,4,CH,EQ,C' '),OVERLAY=(81:1,5,90:7,2)),
        IFTHEN=(WHEN=(10,3,CH,EQ,C' '),OVERLAY=(81:1,6,90:8,2)),
        IFTHEN=(WHEN=(11,2,CH,EQ,C' '),OVERLAY=(81:1,7,90:9,2)),
        IFTHEN=(WHEN=(12,1,CH,EQ,C' '),OVERLAY=(81:1,8,90:10,2)),
        IFTHEN=(WHEN=(12,1,CH,NE,C' '),OVERLAY=(81:1,9,90:11,2))
  OPTION EQUALS
  SORT FIELDS=(81,9,CH,A,90,2,CH,A)
  OUTFIL REMOVECC,NODETAIL,
    SECTIONS=(81,9,
      TRAILER3=(1,80)),
    OUTREC=(1,80)
/*


It wasn't clear from your example if you want to sort the column 1 values in 1-9 as character values or numeric values. For example, if you have:

1 99
02 99

Sorting the 1 and 02 as character values ('1 ' and '02') gives you '02' and then '1 ', whereas sorting the 1 and 02 as normalized numeric values (01 and 02) gives you 1 and then 02. I chose character sorting in the example below, but if you want to use numeric sorting, just change the SORT statement to:

Code:

  SORT FIELDS=(81,9,UFF,A,90,2,CH,A)     


UFF is a new DFSORT format that will extract the digits (0-9) from any value, thus normalizing them for sorting.
_________________
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
Sumathi
Beginner


Joined: 24 Mar 2004
Posts: 13
Topics: 3

PostPosted: Wed Mar 23, 2005 6:44 pm    Post subject: Reply with quote

Frank,

We have syncsort in our shop and when I tried with your sysin, it says the following syntax error.
Code:

SYSIN :                                                         
  INREC IFTHEN=(WHEN=(5,8,CH,EQ,C' '),OVERLAY=(81:1,1,90:3,2)), 
        *                                                       
        IFTHEN=(WHEN=(6,7,CH,EQ,C' '),OVERLAY=(81:1,2,90:4,2)), 
        IFTHEN=(WHEN=(7,6,CH,EQ,C' '),OVERLAY=(81:1,3,90:5,2)), 
        IFTHEN=(WHEN=(8,5,CH,EQ,C' '),OVERLAY=(81:1,4,90:6,2)), 
        IFTHEN=(WHEN=(9,4,CH,EQ,C' '),OVERLAY=(81:1,5,90:7,2)), 
        IFTHEN=(WHEN=(10,3,CH,EQ,C' '),OVERLAY=(81:1,6,90:8,2)),
        IFTHEN=(WHEN=(11,2,CH,EQ,C' '),OVERLAY=(81:1,7,90:9,2)),
        IFTHEN=(WHEN=(12,1,CH,EQ,C' '),OVERLAY=(81:1,8,90:10,2)),
        IFTHEN=(WHEN=(12,1,CH,NE,C' '),OVERLAY=(81:1,9,90:11,2))
   OPTION EQUALS                                                 
   SORT FIELDS=(81,9,UFF,A,90,2,CH,A)                           
                *                                               
   OUTFIL REMOVECC,NODETAIL,                                     
     SECTIONS=(81,9,                                             
       TRAILER3=(1,80)),                                         
     OUTREC=(1,80)                             
WER268A  INREC STATEMENT   : SYNTAX ERROR     
WER268A  SORT STATEMENT    : SYNTAX ERROR     
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000 

Is that something I have to change?
Thanks,
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: Wed Mar 23, 2005 7:45 pm    Post subject: Reply with quote

Syncsort does NOT support the IFTHEN, OVERLAY or UFF parameters. These are all exclusive features of DFSORT. So there's nothing you can change - other than getting your shop to switch from Syncsort to DFSORT.
_________________
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
mithun466
Beginner


Joined: 14 Apr 2004
Posts: 3
Topics: 0

PostPosted: Thu Mar 24, 2005 10:34 am    Post subject: Reply with quote

Sumathi,

You can try the following JCL. OFILE will contain the desired o/p. This JCL is very similar to the one posted by Frank, except that I have used OUTFIL along with INCLUDE and OUTREC instead of IFTHEN and OVERLAY parameters used by Frank. And as Frank mentioned earlier, the UFF parameter is not available with SYNCSORT, so you will have to use CH in the CTL2CNTL control card Sad

Code:


//**********************************************************************
//JSTEP010 EXEC PGM=ICETOOL                                             
//**********************************************************************
//TOOLMSG  DD  SYSOUT=*                                                 
//DFSMSG   DD  SYSOUT=*                                                 
//SYSUDUMP DD  SYSOUT=*                                                 
//SYSOUT   DD  SYSOUT=*                                                 
//TOOLIN   DD *                                                         
   SORT FROM(INFILE)  USING(CTL1)             
   SORT FROM(CONCAT)  USING(CTL2)             
//INFILE   DD *                                                         
1 12                                                                   
1 56                                                                   
111 11                                                                 
2222 11                                                                 
2222 68                                                                 
3333 11                                                                 
4444 15                                                                 
4444 67                                                                 
999999999 11                                                         
999999999 68                                                         
//CTL1CNTL DD *                                                       
  SORT   FIELDS=COPY                                                 
  OUTFIL FNAMES=TEMP1,INCLUDE=(1,1,CH,NE,C' ',AND,2,1,CH,EQ,C' ',AND,
                      3,2,CH,NE,C' ',AND,5,8,CH,EQ,C' '),             
                      OUTREC=(1,80,1,1,8C' ',3,2)                     
  OUTFIL FNAMES=TEMP2,INCLUDE=(1,2,CH,NE,C' ',AND,3,1,CH,EQ,C' ',AND,
                      4,2,CH,NE,C' ',AND,6,7,CH,EQ,C' '),             
                      OUTREC=(1,80,1,2,7C' ',4,2)                     
  OUTFIL FNAMES=TEMP3,INCLUDE=(1,3,CH,NE,C' ',AND,4,1,CH,EQ,C' ',AND,
                      5,2,CH,NE,C' ',AND,7,6,CH,EQ,C' '),             
                      OUTREC=(1,80,1,3,6C' ',5,2)                     
  OUTFIL FNAMES=TEMP4,INCLUDE=(1,4,CH,NE,C' ',AND,5,1,CH,EQ,C' ',AND,
                      6,2,CH,NE,C' ',AND,8,5,CH,EQ,C' '),             
                      OUTREC=(1,80,1,4,5C' ',6,2)                     
  OUTFIL FNAMES=TEMP5,INCLUDE=(9,4,CH,EQ,C' ',AND,6,1,CH,EQ,C' ',AND,
                      7,2,CH,NE,C' ',AND,9,4,CH,EQ,C' '),             
                      OUTREC=(1,80,1,5,4C' ',7,2)                     
  OUTFIL FNAMES=TEMP6,INCLUDE=(10,3,CH,EQ,C' ',AND,7,1,CH,EQ,C' ',AND,
                      8,2,CH,NE,C' ',AND,10,3,CH,EQ,C' '),             
                      OUTREC=(1,80,1,6,3C' ',8,2)                     
  OUTFIL FNAMES=TEMP7,INCLUDE=(11,2,CH,EQ,C' ',AND,8,1,CH,EQ,C' ',AND,
                      9,2,CH,NE,C' ',AND,11,2,CH,EQ,C' '),             
                      OUTREC=(1,80,1,7,2C' ',9,2)                     
  OUTFIL FNAMES=TEMP8,INCLUDE=(12,1,CH,EQ,C' ',AND,9,1,CH,EQ,C' ',AND,
                      10,2,CH,NE,C' ',AND,12,1,CH,EQ,C' '),           
                      OUTREC=(1,80,1,8,1C' ',10,2)                     
  OUTFIL FNAMES=TEMP9,INCLUDE=(12,1,CH,NE,C' ',AND,10,1,CH,EQ,C' ',AND,
                      11,2,CH,NE,C' ',AND,12,1,CH,NE,C' '),           
                      OUTREC=(1,80,1,9,11,2)                           
//CTL2CNTL DD *                                                       
   SORT FIELDS=(81,9,CH,A,90,2,CH,A)                                   
   OUTFIL FNAMES=OFILE,REMOVECC,NODETAIL,                                           
   SECTIONS=(81,9,TRAILER3=(1,80)),                                   
   OUTREC=(1,80)                                                       
//TEMP1    DD DSN=&&TEMP1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)         
//TEMP2    DD DSN=&&TEMP2,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)         
//TEMP3    DD DSN=&&TEMP3,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)         
//TEMP4    DD DSN=&&TEMP4,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)         
//TEMP5    DD DSN=&&TEMP5,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)       
//TEMP6    DD DSN=&&TEMP6,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)       
//TEMP7    DD DSN=&&TEMP7,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)       
//TEMP8    DD DSN=&&TEMP8,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)       
//TEMP9    DD DSN=&&TEMP9,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)       
//CONCAT   DD DSN=*.TEMP1,VOL=REF=*.TEMP1,DISP=(OLD,PASS)           
//         DD DSN=*.TEMP2,VOL=REF=*.TEMP2,DISP=(OLD,PASS)           
//         DD DSN=*.TEMP3,VOL=REF=*.TEMP3,DISP=(OLD,PASS)           
//         DD DSN=*.TEMP4,VOL=REF=*.TEMP4,DISP=(OLD,PASS)           
//         DD DSN=*.TEMP5,VOL=REF=*.TEMP5,DISP=(OLD,PASS)           
//         DD DSN=*.TEMP6,VOL=REF=*.TEMP6,DISP=(OLD,PASS)           
//         DD DSN=*.TEMP7,VOL=REF=*.TEMP7,DISP=(OLD,PASS)           
//         DD DSN=*.TEMP8,VOL=REF=*.TEMP8,DISP=(OLD,PASS)           
//         DD DSN=*.TEMP9,VOL=REF=*.TEMP9,DISP=(OLD,PASS)           
//OFILE    DD SYSOUT=*                                             


Thanks,
Mithun
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Mar 24, 2005 11:38 am    Post subject: Reply with quote

Frank,

I was wondering if SELECT would make any difference instead of using report features in the second pass.

Code:

 SELECT FROM(CONCAT) TO(OFILE) USING(CTL2) ON(81,9,CH) FIRST


Code:

//CTL2CNTL DD *           
  SORT FIELDS=(81,9,CH,A, 
               90,2,CH,D) 
/* 


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Thu Mar 24, 2005 11:51 am    Post subject: Reply with quote

Quote:
And as Frank mentioned earlier, the UFF parameter is not available with SYNCSORT, so you will have to use CH in the CTL2CNTL control card


As I explained above, CH will NOT give you the same results as UFF. For example,
if the input is:

1 12
1 56
02 77
02 85
111 11
2222 11
2222 68
3333 11
4444 15
4444 67
999999999 11
999999999 68

The DFSORT job with UFF will give the correct output with 1 before 02 as:

1 56
02 85
111 11
2222 68
3333 11
4444 67
999999999 68

Mithun's job using CH will give incorrect results with 02 before 1:

02 85
1 56
111 11
2222 68
3333 11
4444 67
999999999 68

You really do need DFSORT's new UFF format for this kind of thing.
_________________
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
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Thu Mar 24, 2005 12:00 pm    Post subject: Reply with quote

Kolusu,

Yes, you could use SELECT that way for the second pass with Mithun's example. But you still have the UFF vs CH problem.

Note that with DFSORT, you could use UFF instead of CH for the 81,9 field in the SELECT ON parameter and SORT statement. But, of course, with DFSORT, you could use the one pass solution with UFF I suggested instead.
_________________
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
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Mon May 08, 2006 6:45 pm    Post subject: Reply with quote

Here's an easier way to do this kind of thing using the new PARSE function available with z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006):

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  INREC PARSE=(%00=(FIXLEN=9,ENDBEFR=C' '),
               %01=(FIXLEN=2,ENDBEFR=C' ')),
        OVERLAY=(81:%00,90:%01)
  OPTION EQUALS
  SORT FIELDS=(81,9,CH,A,90,2,CH,A)
  OUTFIL REMOVECC,NODETAIL,
    SECTIONS=(81,9,
      TRAILER3=(1,80)),
    OUTREC=(1,80)
/*


For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTFs, see:

www.ibm.com/servers/storage/support/software/sort/mvs/peug/
_________________
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