MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

comparing two files and adding record to new file..

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Anand_R
Intermediate


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Wed Jan 08, 2003 11:25 am    Post subject: comparing two files and adding record to new file.. Reply with quote

Hi,

I have two files(old,new),, which are same FB sequential files and having key at the same column postion(let's assume at 5 chars length starts from 1st column).

My requirement :

I need to compare/find each and every record key(5 chars field) of old file with all new file records key and do the following

1) If find it in new file then nothing needs to be done(I mean no modifications to the new file)
2) If not found, then that old file record should append to the new file..

Will it possible by any utilities... other than Eztrieve/Cobol..


Pls let me know.. if I am not clear

Any help is highly appreciated..

Anand
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jan 08, 2003 11:37 am    Post subject: Reply with quote

Anand_R,

Can there be duplicates in any of the files?? If the records are unique then it is an easy task to do. Please let me know the LRECL,RECFM of the 2 files.

Thanks

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ajeykumar
Beginner


Joined: 29 Nov 2002
Posts: 8
Topics: 1
Location: Calcutta India

PostPosted: Thu Jan 09, 2003 5:19 am    Post subject: Reply with quote

If the files contain unique records, you can perform this task by using series of SORTs.

(1) append old file with the number '1' - OUTREC func in sort
(2) append new file with the number '2' - OUTREC func in sort
(3) do a sumfields on this new field keeping the 5 byte field in the "SORT FIELDS" clause and this new field in the "SUM FIELDS" clause
(4) any records still remaining with '1' can be included into a file - INCLUDE func in sort
(5) append this file with remaining '1's to the new file by concatenation - copy using sort

If you have duplicates, could you just let me know if both have duplicates or only the old can have duplicates or only new can have them.
Back to top
View user's profile Send private message
Anand_R
Intermediate


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Thu Jan 09, 2003 6:51 am    Post subject: Reply with quote

Hi Kolusu,

Thanks for ur prompt response.

No duplicates records and record length is 80..

Could you post the code?

Ajey,

Thanks a lot for your reply,, I am not much familiar with sort and I am learning this sort with mvsformus helpboard, If any of you can provide me code I can better understand ur explanation..

Thanks
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jan 09, 2003 7:07 am    Post subject: Reply with quote

Anand_r,

The following DFSORT/ICETOOL JCL will give you the desired results.If you syncsort at your shop then change the pgm name to synctool.This job is similar to ajeykumar's explanation but slightly different as he forgot to take into consideration the matched records.

A Brief explanation of the Job.

The first copy operator takes in the NEWFILE and creates file T1 while appending a constant '1' at the end.
The second copy operator takes in the OLDFILE and creates file T2 while appending a constant '2' at the end.

Now we concatenate these 2 files together as CON( make sure that new file T1 is the first dsn name as we want the records for the match condition from newfile). we sum sort this con file on the constants added at the end. Any matched record will have a total of 3 in the 81 st byte.so we need that record. And you also want to append the records from the old file which will have '2' in the 81st byte as it does not have a match in the new file.
So we use the substring(SS) option to select the above 2 records.While writting out the records we will strip off the constants we added at the end.

Code:

//STEP100 EXEC  PGM=ICETOOL                             
//TOOLMSG DD SYSOUT=*                                   
//DFSMSG  DD SYSOUT=*                                   
//NEW     DD *                                         
ABCDE NEW                                               
12345                                                   
//OLD     DD *                                         
ABCDE OLD                                               
EFGHI                                                   
//T1      DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//T2      DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//CON     DD DSN=&T1,DISP=(OLD,PASS),VOL=REF=*.T1       
//        DD DSN=&T2,DISP=(OLD,PASS),VOL=REF=*.T2       
//OUT     DD DSN=YOUR OUTPUT DSN,
//           DISP=(NEW,CATLG,DELETE),
//           UNIT=SYSDA,
//           SPACE=(CYL,(X,Y),RLSE)
//TOOLIN  DD *                                         
  COPY FROM(NEW) USING(CTL1)                             
  COPY FROM(OLD) USING(CTL2)                             
  SORT FROM(CON) USING(CTL3)                             
//CTL1CNTL DD *                   
  OUTFIL FNAMES=T1,OUTREC=(1,80,C'1')         
//CTL2CNTL DD *                               
  OUTFIL FNAMES=T2,OUTREC=(1,80,C'2')         
//CTL3CNTL DD *                               
  OPTION EQUALS                               
  SORT FIELDS=(1,5,CH,A)                       
  SUM FIELDS=(81,1,ZD)                         
  OUTFIL FNAMES=OUT,INCLUDE=(81,1,SS,EQ,C'23'),
  OUTREC=(1,80)                       
/*   


The output from this job is

Code:

ABCDE NEW                                               
EFGHI                                                   


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anand_R
Intermediate


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Thu Jan 09, 2003 11:50 am    Post subject: Reply with quote

Hi Kolusu,

Thanks a lot for your reply..

I think I have not explained u my requirement properly.. I will give thru the example

Consider :

Old file (OLDFL) have date:
Code:

|key  || Data                          |

12345 knowledge is power
23456 knowledge is power
76543 knowledge is power

New file (NEWFL) have data:
Code:

|key  || Data                          |

12345 knowledge is more power
63784 knowledge is more power
48602 knowledge is more power

Then I should get the output file as follows :
Code:

12345 knowledge is more power
63784 knowledge is more power
48602 knowledge is more power
23456 knowledge is power
76543 knowledge is power


Hope I am clear now.. (I just used that proverb for example..)..

I am expecting reply from u

anand
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jan 09, 2003 11:55 am    Post subject: Reply with quote

Anand_r,

Change the INCLUDE condition on CTL3CNTL to the following and you will get the desired results.

Code:

INCLUDE=(81,1,SS,EQ,C'123'),


I added "1" also in the condition which will bring all NON matched records of the new file.

Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jan 09, 2003 12:08 pm    Post subject: Reply with quote

Anand_r,

On second thoughts, you can do it in much easier way and in just one pass of data.The following DFSORT/ICETOOL JCL will give you the results.concatenate both files and use the SELECT operator with FIRST option.Make sure that newfile is the first file in concatenation.

Code:

//STEP100 EXEC PGM=ICETOOL               
//TOOLMSG DD SYSOUT=*                     
//DFSMSG  DD SYSOUT=*                     
//CON     DD DSN=YOUR NEWFILE,
//           DISP=SHR
//        DD DSN=YOUR OLDFILE,
//           DISP=SHR
//OUT     DD DSN=YOUR OUTPUT DSN,
//           DISP=(NEW,CATLG,DELETE),
//           UNIT=SYSDA,
//           SPACE=(CYL,(X,Y),RLSE)
//TOOLIN  DD *                             
  SELECT FROM(CON) TO(OUT) ON(1,5,CH) FIRST
/*     


Hope this helps...

Cheers

kolusu

Edited to remove the OPTION EQUALS as it is a default option for select operator


Last edited by kolusu on Sun Mar 02, 2003 11:27 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Anand_R
Intermediate


Joined: 24 Dec 2002
Posts: 189
Topics: 60

PostPosted: Fri Jan 10, 2003 4:05 am    Post subject: Reply with quote

Kolusu,

Thanks alot and u r simply great..
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Feb 28, 2003 6:49 pm    Post subject: Reply with quote

Kolusu,

I just noticed that you have:

Code:

//DFSPARM DD *                             
  OPTION EQUALS
/*     


for your DFSORT/ICETOOL SELECT job. You actually don't need to specify OPTION EQUALS since DFSORT automatically uses EQUALS for SELECT.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Venkata Ramana Reddy
Beginner


Joined: 02 Dec 2002
Posts: 70
Topics: 19
Location: California

PostPosted: Fri Feb 28, 2003 7:01 pm    Post subject: Reply with quote

Anand_R,
Do you have Easytrieve in your shop.
_________________
Venkataramana
-- Good judgement comes from experience, and often experience comes from bad judgement.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Sun Mar 02, 2003 11:26 am    Post subject: Reply with quote

Frank,

I was not aware of the fact that select operator has default otion of equals. I am correcting the job to reflect the change.

Thanks,

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Sun Mar 02, 2003 5:06 pm    Post subject: Reply with quote

Kolusu,

DFSORT's ICETOOL sets many options automatically for different operators to ensure the correct or optimum results. For example: EQUALS for SELECT ensures the correct results for the FIRST, LAST, FIRSTDUP and LASTDUP operands; DYNALLOC for SORT allows dynamic allocation of work data sets; etc. The options and statements that ICETOOL sets up for various operators is no secret given that they appear in the DFSMSG message data set.

Anyway, thanks for correcting your job.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group