View previous topic :: View next topic
|
Author |
Message |
Andy N
New User
Joined: 08 Sep 2014 Posts: 2 Location: UK
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Andy N
New User
Joined: 08 Sep 2014 Posts: 2 Location: UK
|
|
|
|
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 |
|
|
Gabriel Araujo Alves
New User
Joined: 20 Jul 2010 Posts: 38 Location: Brazil
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Gabriel Araujo Alves
New User
Joined: 20 Jul 2010 Posts: 38 Location: Brazil
|
|
|
|
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 |
|
|
|