View previous topic :: View next topic
|
Author |
Message |
kumar9930
New User
Joined: 16 Jul 2008 Posts: 2 Location: india
|
|
|
|
Hi,
I have a requirement where i need to compare records in 1 file with records in other file(2nd file). If match found records from 2nd file should be written to New file(3rd file) with the same sequence as in 2nd file.
I applied Join keys function to match files it is working fine but it is not following the sequence correctly. Can any one advise me on this to get Correct SEQUENCE as in the 2nd file to new file.
Thanks in advance
Kumar. |
|
Back to top |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
could you post an example of what's happening? |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Kumar,
Can you give some sample input and output records.......
Thanks,
Arun |
|
Back to top |
|
|
Prasanthhere
Active User
Joined: 03 Aug 2005 Posts: 306
|
|
|
|
Whats the LRECL RECFM and Key length of file1 and file2 |
|
Back to top |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
kumar9930 wrote: |
Can any one advise me on this to get Correct SEQUENCE as in the 2nd file to new file. |
Code a SORT statement after your JOINKEYS and/or REFORMAT statements to include the desired sort order.
Code: |
SORT FIELDS=(p,l,f,o...) |
(Without seeing your JCL or sample data, there is not much more information we can provide you with). |
|
Back to top |
|
|
kumar9930
New User
Joined: 16 Jul 2008 Posts: 2 Location: india
|
|
|
|
Hi,
Here i am giving an example.
File 1:
12345
22222
33333
File 2:
22222 matching
22222 records
12345 sort
12345 order
12345 sequence
33333 syncsort
33333 joinkeys
33333 function
i am expecting the same Output in File3 as it is in File2. Sequence must be same.
Output i am getting in File3 differs some times as shown.
File3:
12345 order
12345 sort
12345 sequence
22222 records
22222 matching
33333 syncsort
33333 joinkeys
33333 function
Kumar. |
|
Back to top |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
Off-hand, I know this can be done in 2 steps:
Code: |
//STEP1 EXEC PGM=SORT
//SORTIN DD *
22222 MATCHING
22222 RECORDS
12345 SORT
12345 ORDER
12345 SEQUENCE
33333 SYNCSORT
33333 JOINKEYS
33333 FUNCTION
//SORTOUT DD DSN=&&TEMP,DISP=(NEW,PASS)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC BUILD=(1,15,16:SEQNUM,4,ZD)
//SORT2 EXEC PGM=SORT
//SORTJNF1 DD DSN=&&TEMP,DISP=(OLD,DELETE)
//SORTJNF2 DD *
12345
22222
33333
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(1,5,A)
JOINKEYS FILES=F2,FIELDS=(1,5,A)
REFORMAT FIELDS=(F1:1,19)
SORT FIELDS=(16,4,CH,A)
OUTREC FIELDS=(1,15)
/* |
I'll have to see if I can get this down to a single pass of the data. |
|
Back to top |
|
|
|