MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

easytrieve compare

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
nbdtrjk1
Beginner


Joined: 12 Apr 2007
Posts: 76
Topics: 41

PostPosted: Mon Nov 17, 2008 7:34 am    Post subject: easytrieve compare Reply with quote

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
View user's profile Send private message
callanand
Beginner


Joined: 12 Jun 2007
Posts: 23
Topics: 2

PostPosted: Mon Nov 17, 2008 9:36 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Mon Nov 17, 2008 11:03 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group