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

Compare and then delete the record which is common in both


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
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

Superior Member


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

PostPosted: Wed Jun 13, 2007 2:37 pm
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
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: 1436
Location: Bangalore,India

PostPosted: Wed Jun 13, 2007 3:18 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts DELETE SPUFI DB2 1
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts DSNTIAUL driven delete IBM Tools 0
Search our Forums:

Back to Top