View previous topic :: View next topic
|
Author |
Message |
goalchi27
New User
Joined: 31 May 2007 Posts: 4 Location: India
|
|
|
|
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 |
|
|
Raphael Bacay
New User
Joined: 04 May 2007 Posts: 58 Location: Manila, Philippines
|
|
|
|
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 |
|
|
Devzee
Active Member
Joined: 20 Jan 2007 Posts: 684 Location: Hollywood
|
|
|
|
Quote: |
delete the record from the first |
Are you using VSAM file? |
|
Back to top |
|
|
goalchi27
New User
Joined: 31 May 2007 Posts: 4 Location: India
|
|
|
|
Devzee wrote: |
Quote: |
delete the record from the first |
Are you using VSAM file? |
No.... its a flat file |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi,
Would you like do this with JCL as well !? |
|
Back to top |
|
|
Raphael Bacay
New User
Joined: 04 May 2007 Posts: 58 Location: Manila, Philippines
|
|
|
|
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 |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Raphael,
Quote: |
IF TRANSCODE NOT= 72
WRITE RECORD1
END-IF |
Write record1????? |
|
Back to top |
|
|
Raphael Bacay
New User
Joined: 04 May 2007 Posts: 58 Location: Manila, Philippines
|
|
|
|
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 |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
Why write the cobol when a sort can do this for you? |
|
Back to top |
|
|
|