Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Sat Apr 17, 2004 12:23 am Post subject: Copy a file depending on the contents of two other files
I have 3 input files each of LRECL=80 and RECFM=FB. File 1 and 2 are control files which will have only one record as shown below. File 3 is the actual data file (Its very huge !!!).
My requirement is to copy File 3 to File 4 (ouput file) if the contents of File 1 and 2 match. Else File 4 should be created empty. This needs to accomplished using SORT in one step. (Our installation has only SYNCSORT 1999 version)...TOOO OLD !!!
Code:
File 1: LRECL=80, RECFM=FB
TRAILER RECORD (TOTAL RECORDS: 000000001)
File 2: LRECL=80, RECFM=FB
TRAILER RECORD (TOTAL RECORDS: 000000002)
As shown above I should check whether the count in File 1 and 2 match. In the above case it does not. So the output file must be empty. If they match, File 4 should have all the records in File 3.
Code:
File 3: LRECL=80, RECFM=FB
AAAAAAA
BBBBBBB
CCCCCC
For this I have written a small synctool code. Could someone review my code and let me know if this could be improved. (I'm a novice in sort..and just wanted to learn new things....).
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Sat Apr 17, 2004 8:45 am Post subject:
Phantom,
Couple of minor changes. You will be creating 2 records in the control cards when the counts do not match. Even though it does not matter, it can be solved by coding ENDREC on the outfil statement in the first sort step.
Code:
OUTFIL FNAMES=CTL2CNTL,ENDREC=1,
Always remember that with sort you do not have to hardcode the LRECL & RECFM. They will be automatically calculated.so remove AVGREC & DCB parms.
Also change the DISP of the CTL2CNTL file to DISP=(NEW,PASS) instead of cataloging the dataset, so that the dataset will be deleted at the end of the Job. You can catalog that dataset if you want to verify( but that can be done just by browing the count files).
Other than that the solution looks good and a clever
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Sun Apr 18, 2004 11:19 pm Post subject:
Thanks for your advice kolusu,
First I tried STOPAFT=1 in the sort command. In that case the SUM FIELDS did not work since it took only one record from the input. I thought ENDREC will do the same....and didn't try it...So I decided to go for NOMATCH=(C' ') which will just create a blank record. Now, I learnt the use of ENDREC with ur help.
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