IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Help Moving Records which not presents in file1


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
itsdipu
Currently Banned

New User


Joined: 18 Mar 2006
Posts: 3
Location: Hyderabad

PostPosted: Tue Aug 07, 2007 9:59 am
Reply with quote

Two tables EmpA and EmpB.

EmpA -- 100,000 Records,
EmpB -- 300,000 Records,


Question :
How to move the Records , which are existed in both , to EmpC table ?
How to move the records which are in EmpA and not in EmpB ?
How to move the records which are in EmpB and not in EmpA ?


Very thankful to you...
Thanks&Regards,
Dileep
Back to top
View user's profile Send private message
balakrishna reddy

Active User


Joined: 13 Jul 2007
Posts: 128
Location: Guntur

PostPosted: Tue Aug 07, 2007 10:21 am
Reply with quote

hi dileep,

the last two questions where seems to be incomplete

Quote:

How to move the records which are in EmpA and not in EmpB ?
How to move the records which are in EmpB and not in EmpA ?


you didn't mentioned where to move the records if records of EMPA doesn't match EMPB and viceversa..

please provide the above information.
Back to top
View user's profile Send private message
Raphael Bacay

New User


Joined: 04 May 2007
Posts: 58
Location: Manila, Philippines

PostPosted: Fri Aug 10, 2007 1:07 pm
Reply with quote

Hello,

I would like to try to answer your question. I did it in COBOL.

FILE-A = FILE A
FILE-B = FILE B
FILE-C = FILE CONTAINING RECORDS IN BOTH A AND B
FILE-D = FILE CONTAINING RECORDS ONLY IN FILE A AND NOT IN B
FILE-E = FILE CONTAINING RECORDS ONLY IN FILE B AND NOT IN A


READ A
READ B

PERFORM UNTIL END-OF-FILE-A OR END-OF-FILE-B
EVALUATE TRUE
* RECS COMMON TO BOTH GET PUT TO FILE-C
WHEN REC-A = REC-B
WRITE REC-A TO FILE-C
READ A
READ B
WHEN REC-A < REC-B
* RECS ONLY IN FILE-A GET WRITTEN TO FILE-D
WRITE REC-A TO FILE-D
READ A
WHEN REC-A > REC-B
* RECS ONLY IN FILE B GET WRITTEN TO FILE-E
WRITE REC-B TO FILE-E
READ B
END-EVALUATE
END-PERFORM

* IF B IS EMPTY FROM LOOP ABOVE AND A IS NOT
PERFORM UNTIL END-OF-FILE-A
READ A
WRITE REC-A TO FILE-D
END-PERFORM

* IF A IS EMPTY FROM FIRST LOOP AND B IS NOT
PERFORM UNTIL END-OF-FILE-B
READ B
WRITE REC-B TO FILE-E
END-PERFORM

Regards.
Back to top
View user's profile Send private message
Raphael Bacay

New User


Joined: 04 May 2007
Posts: 58
Location: Manila, Philippines

PostPosted: Fri Aug 10, 2007 1:10 pm
Reply with quote

I forgot to say to please sort both input files before using the code above.

Regards.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Aug 10, 2007 8:39 pm
Reply with quote

Hello itsdipu and welcome to the forums,

To to what you want you will implement something known as a 2-file match/merge.

There is a "sticky" at the top of "Mainframe COBOL " that is sample code for your requirement.

Please download the code, review it, and post any questions you have as a reply here.
Back to top
View user's profile Send private message
itsdipu
Currently Banned

New User


Joined: 18 Mar 2006
Posts: 3
Location: Hyderabad

PostPosted: Wed Aug 15, 2007 4:40 pm
Reply with quote

Hi Bacay,

Yes , the scenario what u mentioned here is exactly my scenario. thanks for understanding correctly.. I really feeling good to see this code. One more question on this..

Say, its taking one unit of time to check for one condition.

How many times it has to perform the same condition check. and hence is it not decreasing the performance of mainframe computer. ??

plz let me know. if my question is not clear.

Thanks
Dileep



Raphael Bacay wrote:
Hello,

I would like to try to answer your question. I did it in COBOL.

FILE-A = FILE A
FILE-B = FILE B
FILE-C = FILE CONTAINING RECORDS IN BOTH A AND B
FILE-D = FILE CONTAINING RECORDS ONLY IN FILE A AND NOT IN B
FILE-E = FILE CONTAINING RECORDS ONLY IN FILE B AND NOT IN A


READ A
READ B

PERFORM UNTIL END-OF-FILE-A OR END-OF-FILE-B
EVALUATE TRUE
* RECS COMMON TO BOTH GET PUT TO FILE-C
WHEN REC-A = REC-B
WRITE REC-A TO FILE-C
READ A
READ B
WHEN REC-A < REC-B
* RECS ONLY IN FILE-A GET WRITTEN TO FILE-D
WRITE REC-A TO FILE-D
READ A
WHEN REC-A > REC-B
* RECS ONLY IN FILE B GET WRITTEN TO FILE-E
WRITE REC-B TO FILE-E
READ B
END-EVALUATE
END-PERFORM

* IF B IS EMPTY FROM LOOP ABOVE AND A IS NOT
PERFORM UNTIL END-OF-FILE-A
READ A
WRITE REC-A TO FILE-D
END-PERFORM

* IF A IS EMPTY FROM FIRST LOOP AND B IS NOT
PERFORM UNTIL END-OF-FILE-B
READ B
WRITE REC-B TO FILE-E
END-PERFORM

Regards.
Back to top
View user's profile Send private message
Raphael Bacay

New User


Joined: 04 May 2007
Posts: 58
Location: Manila, Philippines

PostPosted: Fri Sep 28, 2007 5:34 pm
Reply with quote

Hello,

Yes it is taking one unit at a time. I don't think it will hurt
mainframe processing much because it is only fair to do it
this way since this is in COBOL and COBOL usually processes one recored at a time. Also the forum is COBOL oriented anyway.


Regards.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 2
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top