View previous topic :: View next topic
|
Author |
Message |
maki_psg
New User
Joined: 28 Jan 2010 Posts: 47 Location: India
|
|
|
|
Hi,
I have a requirement to get unmatched and mached recs with a specific condition using JCL (SYNCSORT). Sample data is given below. Could anyone please help me to get the solution in 1 step ?
File 1
Code: |
123 20140101 ALBERT
456 20130101 MARTIN
789 20130701 LUTHER
|
File 2
Code: |
111 20110101 20120101 TEST1
456 20140101 20141231 TEST2
789 20130101 20131231 TEST3
|
Requirement is:
1) Get the unmatached recs from F1 using the Key (column 1-3) of F1/F2
2) Get the matched recs from F1, however, the date(column 5-12) of F1 should not fall in the range of F2 dates(5-12 and 14-21).
Expected output:
Code: |
123 20140101 ALBERT
456 20130101 MARTIN
|
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
REFM and LRECL please. Can there be duplicates on either file? |
|
Back to top |
|
|
maki_psg
New User
Joined: 28 Jan 2010 Posts: 47 Location: India
|
|
|
|
Hi Bill,
LRECL (F1 = 100; F2 = 1000).
Yes, there can be duplicates on either file. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You need a JOINKEYS with UNPAIRED,F1
You need a REFORMAT statement, and for SyncSort you need a FILL (or to use the default fill of space) and choose a byte somewhere on F2 which can never contain that fill value.
FIELDS=(F1:1,100,F2:1,1000) on your REFORMAT.
I will assume you want two output files.
For the first, use OUTFIL with INCLUDE=(startoffilltest,1,CH,EQ,C'the single byte fill character')
That, along with the name for OUTFIL, will get you all your unmatched F1s.
A second OUTFIL for the matches.
Needs INCLUDE= with reverse of above condition (NE) and the test the date as being within the range on the F2. The date from F1 on the REFORMAT record is at the same position as the F1, and the date from F2 is offset by 100 bytes.
From the JOIN you will get multiple records for duplicates on the match.
If you only want a single record in this case, you need to decide what you want. |
|
Back to top |
|
|
|