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 

FILE I/O ERROR
Goto page Previous  1, 2, 3, 4
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed Mar 03, 2004 2:22 pm    Post subject: Reply with quote

Sk,

please understand the file matching logic. I will explain it in simple terms.

Code:

INPUT FILE1 LAYOUT
KEY1      PIC X(10).

INPUT FILE2 LAYOUT
KEY2      PIC X(10).

OUTPUT FILE LAYOUT
O-KEY     PIC X(10).
O-REMARK  PIC X(30)


Main PROCESS:

  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.

Hope this is clear and understandable.

Kolusu

Btw what is your background in programming?
_________________
Kolusu
www.linkedin.com/in/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
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
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