Posted: Tue Jan 19, 2016 5:12 am Post subject: Merge 2 files unconditionally
Hi,
I have 1 input file (A) with 2 dates (1 record) and another file (B) with 2M records.
I just want to copy (merge) A into file B (creating sysout (C))
eg :
JOINKEYS is a resource-hungry way to do it. In the JNFnCNTL files you temporarily extend the records to include a one-byte "key", on both files, all records, with the same value.
You specify the key on both the JOINKEYS (at least you can add SORTED and NOSEQCK) and you get a "cartesian join", each record on F1 is matched to each (which happens to be the only) record on F2, and you can define your final output on the REFORMAT statement.
You could also define separate values on the two files, the lower value on the single-record file, and use JOIN UNPAIRED,ONLY and then identify the unmatched F2 (use the match-marker, a "?" in the REFORMAT statement) with WHEN=GROUP and PUSH the data you need from the reformat record to all records in the position you want.
The resource efficient way to do it is a two-step solution.
First step, use SORT to format the single-record file as a DFSORT symbol, fixed-length of 80 bytes is important.
Second step, include the dataset created above as a SYMNAMES DD. Good to always include a SYMNOUNT DD going to SYSOUT.
Then your SORTIN is the actual data, and you use INREC OVERLAY/BUILD to include the data, by using the symbol-name, on all your records.
where i read the date, and after finding the begin- and end date, i write all the symnames + dates into the file that i use in a second step to select certain records. Works perfect! thanks for the hint on the symnames file.
Cheers, Gerd.
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Tue Jan 19, 2016 10:17 am Post subject:
Gerd Hofmans wrote:
where i read the date, and after finding the begin- and end date, i write all the symnames + dates into the file that i use in a second step to select certain records. Works perfect! thanks for the hint on the symnames file.
Cheers, Gerd.
Glad you got it working. However you do remember that if you ever have more than 1 record in your date file you may need to generate symbols numbering them.
As for 2 steps about finding the begin dates and end dates you probably could everything done in a single step itself.
If you post your detailed Final requirement, I may show you a way to do it. _________________ Kolusu
www.linkedin.com/in/kolusu
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Wed Jan 20, 2016 11:29 am Post subject:
Gerd Hofmans,
You really don't need to do all that calculations to find the begin and end dates. All you need to do is simply subtract the Days from the date and you would automatically get the last month's end date.
So if the input date is January 19th then simply subtract 19 days from January 19th you would get December 31st of last year. All you need to check is if the input date is a valid one or not. This valid date check can be done using any of DFSORT date functions (TOGREG, TOJUL...). This formula works for any date in the calendar. By doing so you don't have to check if the month is january or not.
You also don't need the semicolons after the constants DA1,2,3. You can simply concatenate your fixed symbols instream.
Here is the JCL to calculate the begin and end dates. I also put in additional checks to set a return code if the input date is an invalid date or an empty file and we are only looking at the first record.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum