View previous topic :: View next topic |
Author |
Message |
nbdtrjk1 Beginner
Joined: 12 Apr 2007 Posts: 76 Topics: 41
|
Posted: Mon Nov 17, 2008 7:34 am Post subject: easytrieve compare |
|
|
Both filein1 and filein2 are having same data.Records are sorted order. After ran below code i am getting 8 match records and 7 non match records. i am not understanding why i am getting 7 unmatch records.
[code:1:a7f9721e84]
//JS00100 EXEC PGM=EZTPA00,REGION=3000K
//FILEIN1 DD *
Key01 to Compare |
|
Back to top |
|
|
callanand Beginner
Joined: 12 Jun 2007 Posts: 23 Topics: 2
|
Posted: Mon Nov 17, 2008 9:36 am Post subject: |
|
|
nbdtrjk1,
I think matching in Easytrieve works like this.
You read the first record of your Filein2. Based on that first record you start reading the records of filein1 till the key of filein2 <= filein1. In your above case all the keys in filein2 and filein1 are same. Thus the matching read the first record of filein2 and found 8 matches in filein1 and reached the end of file(filein1). All these records had a successful match. Once the end of file of filein1 reached, the program read the 2nd record of filein2 and didn't find any match in filein1(as already end of file). Thus there were seven records notmatching from filein2. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Mon Nov 17, 2008 11:03 am Post subject: |
|
|
nbdtrjk1,
You have many issues with your program.
1. Both files have duplicates for the key, which would make it a many to many match and the coded program can NOT handle it. The many to many matching is always a tricky one.
2. Use of GOTO should be avoided like plague.
3. Callanand explained the reason as to why you got unmatched records.
Ideally the file matching logic should be as follows
Code: |
IF MATCHED
PUT MATCH FROM IN1
ELSE-IF IN1
PUT OUT1 FROM IN1
ELSE-IF IN2
PUT OUT2 FROM IN2
END-IF
|
One single IF statement to cover all the scenarios and no GOTO's
Hope this helps...
Cheers
Kolusu |
|
Back to top |
|
|
|
|