READ FILE1
READ FILE2
perform MATCH PROCESS of files until end of file1 and file2
Match process:
EVALUATE TRUE
WHEN KEY1 = KEY2
O-KEY = KEY1
O-REMARK = 'THIS RECORD IS A MATCH'
WRITE OUTPUT FILE
READ FILE1
READ FILE2
WHEN KEY1 > KEY2
O-KEY = KEY1
O-REMARK = 'THIS RECORD IS NOT FOUND IN FILE2'
WRITE OUTPUT FILE
READ FILE2
WHEN KEY1 < KEY2
O-KEY = KEY2
O-REMARK = 'THIS RECORD IS NOT FOUND IN FILE1'
WRITE OUTPUT FILE
READ FILE1
END-EVALUATE
1st file
Code:
record 1 - 10
record 2 - 20
record 3 - 35
record 4 - 45
2nd file
Code:
record 1 - 10
record 2 - 20
record 3 - 30
record 4 - 35
record 5 - 45
In your case the first 2 records will fall in the first when condition as both the keys are equal.so you will write a matched record. At this point you will read both file1 and file2
For your 3rd record you will fall into second when condition(since 35 is greater than 30)
Now you will write an output record and you will read ONLY file2. At this point your file1 is at 3rd record and file2 is at 4th record.
Now you will again come into match process and you will fall into the first when condition (since 35 is equal to 35). so you will write a matched record. At this point you will read both file1 and file2. At this point your file1 is at 4th record and file2 is at 5th record.
Now you will again come into match process and you will fall into the first when condition (since 45 is equal to 45). so you will write a matched record.
This process continues till the end of both files.
All times are GMT - 5 Hours Goto page Previous1, 2, 3, 4
Page 4 of 4
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum