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 

Compare & Merge Duplicate Records From 2 Files

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


Joined: 17 Dec 2002
Posts: 22
Topics: 10

PostPosted: Sat Jan 22, 2005 1:26 pm    Post subject: Compare & Merge Duplicate Records From 2 Files Reply with quote

I have 2 files with the same layout:

Code:

FLD_A  CHAR(05)
FLD_B  S9(09) COMP
FLD_C  CHAR(04)

TASK A
Compare them and create 2 files with the following information:

1. Same FLD_A & FLD_B but different FLD_C in File A & File B (only 1 matching record from each file)
2. Same FLD_A & FLD_B but different FLD_C in File A & File B (If more than 1 matching record from either of each file)

For example (FLD_B SHOWN AS NUMERIC FOR DISPLAY):
Code:
File A:
A     B    C   
----- ---- ----
AAAAA 1111 ABCD
BBBBB 2222 ABCD
CCCCC 3333 ABCD
DDDDD 4444 ABCD
DDDDD 4444 DCBA
EEEEE 5555 EEEE


File B:
A     B    C
----- ---- ----
AAAAA 1111 DDDD
BBBBB 2222 ABCD
CCCCC 3333 AAAA
CCCCC 3333 BBBB
DDDDD 4444 DDDD     
EEEEE 5555 FFFF


Expected output file A:
A     B    C   
----- ---- ----
AAAAA 1111 ABCD
AAAAA 1111 DDDD
EEEEE 5555 EEEE
EEEEE 5555 FFFF


Expected output file B:
A     B    C   
----- ---- ----
CCCCC 3333 ABCD
CCCCC 3333 AAAA
CCCCC 3333 BBBB
DDDDD 4444 ABCD
DDDDD 4444 DCBA
DDDDD 4444 DDDD


TASK B
Convert output file A into output file C:

1. With records with same FLD_A and FLD_B, append FLD_C from the second record into the first record

Expected output file C:
Code:
A     B    C    C
----- ---- ---- ----
AAAAA 1111 ABCD DDDD
EEEEE 5555 EEEE FFFF

Besides writing a COBOL program, could anyone tell if there is anyway to do the tasks above using SORT?

Thanks,

Wallace
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Mon Jan 24, 2005 2:47 am    Post subject: Reply with quote

Wallace,

Any idea on the maximum number of duplicate records (File A + File B combined) that can occur ? or is that un-predicatable ? Getting output A is easy in sort, but the output B is a bit tricky - atleast for the version of sort that I have.

Thanks,
Phantom
Back to top
View user's profile Send private message
WallaceC
Beginner


Joined: 17 Dec 2002
Posts: 22
Topics: 10

PostPosted: Mon Jan 24, 2005 5:23 am    Post subject: Reply with quote

Hi Phantom,

For every record on File A, the possible range of duplicate records on File B is 0 to 3.

Thanks,

Wallace
Back to top
View user's profile Send private message
vivek
Beginner


Joined: 15 Jul 2004
Posts: 95
Topics: 11
Location: Edison,NJ

PostPosted: Tue Jan 25, 2005 9:59 am    Post subject: Reply with quote

wallace, From what I see in your description.

BBBBB 2222 ABCD is not written to any file. So you want to get rid of row that are unique ?
_________________
Vivek,NJ

Db2,IDMS
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
vivek
Beginner


Joined: 15 Jul 2004
Posts: 95
Topics: 11
Location: Edison,NJ

PostPosted: Tue Jan 25, 2005 10:05 am    Post subject: Reply with quote

Wallace, confirm my previous post.

for your task B to create field D and retain field C in same position along with A,B a similar thread is here.
http://www.mvsforums.com/helpboards/viewtopic.php?t=10

I did a similar job where in you create

field A field B field C and the rest of the bytes are binary.
similar modify second file to
field A Field B Make it binary for rowlength equal to field C and then put field D.
Then sum them with Binary option.

the thread should have all details. Go thru it with patience. let me know if you have Q.
_________________
Vivek,NJ

Db2,IDMS
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
vivek
Beginner


Joined: 15 Jul 2004
Posts: 95
Topics: 11
Location: Edison,NJ

PostPosted: Tue Jan 25, 2005 12:36 pm    Post subject: Reply with quote

Code:

File A:
A     B    C    D
----- ---- ---- -
AAAAA 1111 ABCD 1
BBBBB 2222 ABCD 1
CCCCC 3333 ABCD 1
DDDDD 4444 ABCD 1
DDDDD 4444 DCBA 1
EEEEE 5555 EEEE 1


File B:
A     B    C    D
----- ---- ---- -
AAAAA 1111 DDDD 1
BBBBB 2222 ABCD 1
CCCCC 3333 AAAA 1
DDDDD 4444 DDDD 1   
EEEEE 5555 FFFF 1



FILE X: Concate file A and B and do a sum on column D, don
_________________
Vivek,NJ

Db2,IDMS
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
vivek
Beginner


Joined: 15 Jul 2004
Posts: 95
Topics: 11
Location: Edison,NJ

PostPosted: Tue Jan 25, 2005 12:38 pm    Post subject: Reply with quote

Wallace , dont change the order of files in sort in and dont forget to use the EQUALS clause. This makes sure that the order of SORTIN rows do not change.

Check the actual sort fields, since this is just an example.

Hope this helps and post me any problems you may have.

Thanks,
_________________
Vivek,NJ

Db2,IDMS
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
WallaceC
Beginner


Joined: 17 Dec 2002
Posts: 22
Topics: 10

PostPosted: Tue Jan 25, 2005 7:06 pm    Post subject: Reply with quote

Hi Vivek,

Sorry to reply so late because I just got access to the site. Thanks for catching the missing row of BBBBB 2222 ABCD--it should be put onto output file B because they do not match to Rule # 1. For your suggestions I will try and keep you posted how they go when I get access to the system.

Thanks again,

Wallace
Back to top
View user's profile Send private message
vivek
Beginner


Joined: 15 Jul 2004
Posts: 95
Topics: 11
Location: Edison,NJ

PostPosted: Tue Jan 25, 2005 9:06 pm    Post subject: Reply with quote

Wallace,
then you should create FILE TWo2 using include cond=(sum field eq 2,zd)
and create Multi file using include cond = (sum field ne 2,zd) . So the row BBBB will be in the multi file which has rows that are exactly present once in file A and B.

I am sure this will work. Because of time constraint i have provided only the required jcl steps and briefed other steps in english. do post here incase you may have trouble.

lemme know how it goes if you crack it in first shot.
It is always a good thing to post that your problem got solved.

If you have trouble make sure you post whole jcl or concerned code and i have been thru times where I post something here and have a typo in my code.

thanks,
_________________
Vivek,NJ

Db2,IDMS
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
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