Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Help Moving Records which not presents in file1

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Help Moving Records which not presents in file1
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: 130
Location: Guntur

PostPosted: Tue Aug 07, 2007 10:21 am    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Fri Aug 10, 2007 8:39 pm    Post subject:
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    Post subject: Thank U very much. One more to be cleared
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us