IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Matching files, retaining original sort order of file 1


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Andy N

New User


Joined: 08 Sep 2014
Posts: 2
Location: UK

PostPosted: Tue Sep 09, 2014 3:19 pm
Reply with quote

Hi

Apologies if this is a common question. If it is, I can't find it anywhere!

I have two files as follows

File 1
GGGGGGGGACC
GGGGGGGGAAA
GGGGGGGGABC
GGGGGGGGIAC

File2
AAA140905
ABC140905
ACC140905


I want to sort File 2 into the same order as File 1 so we get output as follows (there are no duplicates on either file)

ACC140905
AAA140905
ABC140905

So far I have been playing about with JOINKEYS and SPLICE, but I always end up with an output file in sorted order. Is there anyway to do this ?

Many Thanks
Andy
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Sep 09, 2014 3:44 pm
Reply with quote

well ...
the steps should be

assign a sequence number to the records of the first file

joinkeys or splice to <add> the first file sequence numbers to the records of the second file

sort the second file on the sequence number
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Sep 09, 2014 4:54 pm
Reply with quote

Using the JNF1CNTL file to add the sequence number and OUTREC or OUTFIL to strip it off later.

Don't use SPLICE :-)
Back to top
View user's profile Send private message
Andy N

New User


Joined: 08 Sep 2014
Posts: 2
Location: UK

PostPosted: Tue Sep 09, 2014 6:30 pm
Reply with quote

Thanks

I was sort of hoping that ICETOOLS could match and retain in a single step, but using the sequence number wasn't too onerous. I DID use splice though - for others that might be interested, this was what I used. There's probably a better way of doing it, but for the one-off that I needed it for, this worked just fine.

Code:
//TOOLIN   DD *                                                     
COPY FROM(IN2) TO(TMP) USING(CTL2)                                   
COPY FROM(IN1) TO(TMP) USING(CTL1)                                   
SPLICE FROM(TMP) TO(TM2) ON(1,3,CH) WITH(20,8)                       
COPY FROM(TM2) TO(OUT) USING(CTL3)                                   
//CTL1CNTL DD *                                                     
  INREC OVERLAY=(20:SEQNUM,8,ZD)                                     
  OUTREC FIELDS=(1:9,3,20:20,8)                                     
//CTL2CNTL DD *                                                     
  OUTREC FIELDS=(1:1,11)                                             
//CTL3CNTL DD *                                                     
  SORT FIELDS=(20,8,ZD,A)                                           
  OUTREC FIELDS=(1:1,11)                                             



Thanks all.
Back to top
View user's profile Send private message
Gabriel Araujo Alves

New User


Joined: 20 Jul 2010
Posts: 38
Location: Brazil

PostPosted: Fri Sep 12, 2014 9:04 pm
Reply with quote

Hello,
i only can do this using two steps.
Code:

//*********************************************************************
//STEP1       EXEC PGM=SORT                                           
//SYSOUT      DD SYSOUT=*                                             
//SYSPRINT    DD SYSOUT=*                                             
//SORTIN      DD *                                                     
GGGGGGGGACC                                                           
GGGGGGGGAAA                                                           
GGGGGGGGABC                                                           
GGGGGGGGIAC4                                                           
//SORTOUT     DD DSN=&&EXIT1,UNIT=(VIO),DISP=(,CATLG)                 
//SYSIN       DD *                                                     
 SORT FIELDS=COPY                                                     
 INREC OVERLAY=(13:SEQNUM,02,ZD)                                       
//*********************************************************************
//STEP2       EXEC PGM=SORT                                           
//SYSOUT      DD SYSOUT=*                                             
//SYSPRINT    DD SYSOUT=*                                             
//SORTJNF1    DD DSN=*.STEP1.SORTOUT,DISP=SHR                         
//SORTJNF2    DD *                                                     
AAA140905                                                             
ABC140905                                                             
ACC140905                                                             
//*                                                                   
//SORTOUT     DD SYSOUT=*                                             
//SYSIN       DD *                                                     
 SORT FIELDS=(10,02,ZD,A)                                             
 JOINKEYS FILE=F1,FIELDS=(09,03,A)                                     
 JOINKEYS FILE=F2,FIELDS=(01,03,A)                                     
 REFORMAT FIELDS=(F2:01,09,F1:13,02)                                   
 OUTFIL BUILD=(01,09)                                                 
/*                                                                     


and the sortout

Code:

ACC140905
AAA140905
ABC140905


regards.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Sep 13, 2014 3:05 pm
Reply with quote

If using DFSORT, you have JNFnCNTL files for control cards to pre-process the data for JOINKEYS, and their use is documented.

Do you only have SyncSORT available?
Back to top
View user's profile Send private message
Gabriel Araujo Alves

New User


Joined: 20 Jul 2010
Posts: 38
Location: Brazil

PostPosted: Tue Sep 16, 2014 7:12 pm
Reply with quote

Bill Woodger wrote:
If using DFSORT, you have JNFnCNTL files for control cards to pre-process the data for JOINKEYS, and their use is documented.

Do you only have SyncSORT available?


Yes! I'm looking forward to using DFsort, but it is not available.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top