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
 

 

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 compare 2 rows within the same file ram_vizag SYNCSORT 7 Wed Jun 14, 2017 12:34 am
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am
No new posts member list compare jzhardy TSO/ISPF 6 Fri May 12, 2017 3:18 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm


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