Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Compare and then delete the record which is common in both

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
goalchi27

New User


Joined: 31 May 2007
Posts: 4
Location: India

PostPosted: Wed Jun 13, 2007 10:52 am    Post subject: Compare and then delete the record which is common in both
Reply with quote

i have 2 files, i have to compare the records in both and delete the record from the first for which SRNO is same in both files and TRANSCODE =72
Back to top
View user's profile Send private message

Raphael Bacay

New User


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

PostPosted: Wed Jun 13, 2007 11:09 am    Post subject:
Reply with quote

Try to use the following logic:

Sort both files in JCL using SRNO as sort key.

In COBOL:

READ FILE1
READ FILE2
PERFORM UNTIL FILE1 IS END OF FILE
EVALUATE TRUE
WHEN RECORD1-SRNO = RECORD2-SRNO
IF TRANSCODE = 72
DELETE RECORD1
END-IF
READNEXT FILE1
READNEXT FILE2
WHEN RECORD1 < RECORD2
READNEXT FILE1
WHEN RECORD1 > RECORD2
READNEXT FILE2
END-EVALUATE
END-PERFORM


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

Active Member


Joined: 20 Jan 2007
Posts: 684
Location: Hollywood

PostPosted: Wed Jun 13, 2007 11:24 am    Post subject:
Reply with quote

Quote:
delete the record from the first


Are you using VSAM file?
Back to top
View user's profile Send private message
goalchi27

New User


Joined: 31 May 2007
Posts: 4
Location: India

PostPosted: Wed Jun 13, 2007 2:31 pm    Post subject:
Reply with quote

Devzee wrote:
Quote:
delete the record from the first


Are you using VSAM file?


No.... its a flat file
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Jun 13, 2007 2:37 pm    Post subject:
Reply with quote

Hi,

Would you like do this with JCL as well !? icon_smile.gif
Back to top
View user's profile Send private message
Raphael Bacay

New User


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

PostPosted: Wed Jun 13, 2007 2:57 pm    Post subject:
Reply with quote

Oh... I thought it was VSAM. Well if you still want to use COBOL you can try the following:

READ FILE1
READ FILE2
PERFORM UNTIL FILE1 IS END OF FILE
EVALUATE TRUE
WHEN RECORD1-SRNO = RECORD2-SRNO
IF TRANSCODE NOT= 72
WRITE RECORD1
END-IF
READ FILE1
READ FILE2

WHEN RECORD1 < RECORD2
WRITE RECORD1
READ FILE1
WHEN RECORD1 > RECORD2
READ FILE2
END-EVALUATE
END-PERFORM
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Wed Jun 13, 2007 3:18 pm    Post subject:
Reply with quote

Raphael,

Quote:
IF TRANSCODE NOT= 72
WRITE RECORD1
END-IF


Write record1?????
Back to top
View user's profile Send private message
Raphael Bacay

New User


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

PostPosted: Thu Jun 14, 2007 9:15 am    Post subject:
Reply with quote

To explain:

All writes need to be done on a THIRD file which will contain
records excluding records with SRNO of file1 equals SRNO of file2 and TRANSCODE = 72. This approach mimics deleting the record from the FILE1. The final output is the THIRD file.

READ FILE1
READ FILE2
PERFORM UNTIL FILE1 IS END OF FILE
EVALUATE TRUE
WHEN RECORD1-SRNO = RECORD2-SRNO
IF TRANSCODE NOT= 72
WRITE RECORD1 (to file3)
END-IF
READ FILE1
READ FILE2

WHEN RECORD1 < RECORD2
WRITE RECORD1 (to file3)
READ FILE1

WHEN RECORD1 > RECORD2
READ FILE2
END-EVALUATE
END-PERFORM
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Sat Jun 16, 2007 3:36 am    Post subject:
Reply with quote

Why write the cobol when a sort can do this for you?
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 Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am
No new posts Compare yesterday's date to the one o... migusd SYNCSORT 11 Fri Sep 22, 2017 11:35 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Skip file from delete pema_yozer All Other Mainframe Topics 3 Tue Aug 29, 2017 3:19 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us