Need to compare the Keys in the FILE-1 and FILE-2 and created the 3rd file which will have all non matching records and if we have matching key records then copy the record from FILE-B to the output file.
If I understand your requirement
You need matching records from file 2 and non matched from both files correct?
Also do you expect the output in the order given above?
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Well, there are lots of examples here, and there are some good manuals (link in the forum, and at the top of the page).
It is a JOINKEYS you need, you'll need the ? (which tells you whether the current REFORMAT record has data from File "1" or File "2" or "B"oth files) on a REFORMAT statement (along with the data you need from the two files).
It is a simple JOINKEYS process.
The only "complicated" thing is that both inputs are VB. So, leave that aside for the moment, and do your processing with "DD *" for your input (Fixed, LRECL 80). Get the process working, if you get stuck post back here with what you have tried, and the problem you have encountered.
Once working with Fixed Length Records, sort it out for Variable Length. Here it is more likely to be problematic, but if you get stuck, there'll be someone here to assist.
1. This card gives me only matching keys from F2
2. When I try to add the entire records from F1 and F2 in reformat (both are 133 byte VB) then the REFORMAT goes out of bounds.
3. How to add Non matching records from F1 and F2 in the same output ?
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
That was a SyncSort manual, wasn't it? SyncSort questions live in the JCL forum.
If 16,1 (in your example) is $, you want to BUILD the data from F1. Otherwise, you want to build the data from F2 (which will be for F2 only or for a match, where you want the F2 record only).
Then you need to make a variable-length REFORMAT record, with F1 temporarily fixed-length and F2 variable, then when you BUILD the output records, use the RDW from the REFORMAT record, and the fixed F1 data, variable F2 data, and try VLTRIM for the OUTFIL dataset.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Code:
REFORMAT FIELDS=(F1:1,4,5,129,F2,1,4,5)
OK, there's your variable-length REFORMAT statement.
You have to make one of the records "fixed" (since they are the same LRECL, I have arbitrarily chosen to do it with F1).
The REFORMAT record needs an RDW, either from F1 or F2. The correct length will appear there once the REFORMAT record is complete.
Now, I've guessed you have SyncSort, so continue to the "character which can't appear" approach. I'd suggest in bytes 5 for absence of 136 for absence of F2.
You'll need two OUTFILs, and one one you'll need VLTRIM to get rid of the trailing characters for unmatched records which have come from F1.
WER276B SYSDIAG= 1083168, 1636367, 1636367, 3515100
WER164B 102,444K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,
WER164B 40K BYTES RESERVE REQUESTED, 1,004K BYTES USED
WER146B 20K BYTES OF EMERGENCY SPACE ALLOCATED
WER230A REFORMAT FIELD OUTSIDE RANGE
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Please use the Code tags. Please also respond fully to requests. Post the full sysout from the step please, as you have missed some of the Control Cards.
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
Syncsort manual wrote:
Binary zeros will be used instead of the FILL character for the first four bytes of a variable-length record requiring FILL processing
Looks like it is enough to check the first 4 bytes of the Variable length records(RDW) of each file to know if there is a matching record or not.
I just ran a test for the OPs requirement and it works well!
Now the question is, why FILL=C'$' did not fill the F2 rec with '$' ? Is there any other parameter missing in the card ?
I ran a test and noticed that, as the OP suggests the FILL option does not actually 'FILL' the missing F2 fields in case no match exists in file2, where as it does 'FILL' the F1 fields if file1 has no matching key record.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Arun, I think testing the record-length (or the whole RDW) is the best way with SyncSort. I suggested it here, but difficult to know from that particular TS whether it worked :-)
I don't know why the FILL should not apply to both records. If it is documented differently and the problem is repeatable, then it should be passed on to SyncSort.
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
Quote:
testing the record-length (or the whole RDW) is the best way with SyncSort
Yes Bill, I have checked the RDW in my test above and looks like that is the only way out for Syncsort (at least for now until the '?' function gets included).
As for the 'FILL' the manual says two things.
- It will FILL the unused bytes of a variable length record.
- It will FILL the missing fields in a REFORMAT when there is no matching key.
But it does not mention anything about a variable length file JOIN when both the scenarios can occur simultaneously, but our tests show that it does not FILL the missing file2 fields for VB JOINs. May be Alissa could have a look at this or someone can send a note to Syncsort to bring this to their attention.
The difference is that the full length is specified on the REFORMAT for both files, rather than just one. Maybe with the "start-position-only" it does not "qualify" for the FILL?