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 VSAM - Accessing beyond record size Benchwarmer JCL & VSAM 6 Wed Apr 11, 2018 9:20 pm
No new posts Query to compare 2 values of 1 column... Poha Eater DB2 13 Fri Mar 09, 2018 10:45 am
No new posts load and delete table through JCL wit... ram_vizag JCL & VSAM 9 Thu Feb 01, 2018 12:47 am
No new posts Copying only first and last word from... chandan.inst SYNCSORT 4 Wed Jan 31, 2018 4:19 pm
No new posts How to select record x+7 or x+2 based... JoAnn Kulcyk SYNCSORT 6 Tue Jan 16, 2018 10:49 pm

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