Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Matching files, retaining original sort order of file 1

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
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    Post subject: Matching files, retaining original sort order of file 1
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue Sep 09, 2014 3:44 pm    Post subject: Reply to: Matching files, retaining original sort order of f
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Tue Sep 09, 2014 4:54 pm    Post subject: Reply to: Matching files, retaining original sort order of f
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    Post subject: Reply to: Matching files, retaining original sort order of f
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Sat Sep 13, 2014 3:05 pm    Post subject: Reply to: Matching files, retaining original sort order of f
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    Post subject: Re: Reply to: Matching files, retaining original sort order
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    IBMMAINFRAMES.com Support Forums -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us