Posted: Tue Jun 02, 2009 2:46 am Post subject: logic of DO-WHILE
I am reading one record from input file 1 and scanning all the records in the input file 2 with that one record (from input file 1)for matching. If match is found, i am writing to the output file, then the control of input file 2 should come to the initial position (1 st position), so that i can take the second record from input file 1 and read all the records again in input file 2.
is there any way to bring the control back to the initial position after EOF is reached ..(Here in my case , i have to bring the control back to the initial position.)
This is what i tried....
But ia m getting invalid file reference...please help me to solve this issue.
[/quote]INNER-DO-LOOP. PROC
DO UNTIL ( EOF INPUT2 )
PERFORM INP-PROC ----> (have move statements)
IF WS-INP-EOF = 'N'
GET INPUT2
IF EOF INPUT2
WS-INP-EOF = 'Y'
GOTO JOB
END-IF
END-IF
apiyan,
use if MATCHED feature of eazytrieve if the first input file has no duplicate on keys. Otherwise store the second file in an internal table(array). The read the first file and search the record on the table. You can get search logic in any eazytrieve manual. If you didn't find one let me know.
Your logic will work if the volume ..(total no of records) is less in both the input files. But in my case my total number of records is 307578 in input 1 (with duplicates) . 192324 in input 2 without duplicates.
So i tried to do in EZT, its not working...now ia m trying in COBOL...if anyone having COBOL logic for matching two files please share here...
But this is not a normal match....
I have to read one record from input2 and then i have to scan the input1 for matching if match is found i will write in a separate file.. so input 1 para should be in loop. until i scanned/read the whole file....
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
Posted: Wed Jun 03, 2009 12:11 pm Post subject:
If you are using COBOL then close and re-open the file. This will set it back to the first record _________________ Utility and Program control cards are NOT, repeat NOT, JCL.
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Wed Jun 03, 2009 12:19 pm Post subject:
apiyan wrote:
callanand,
Your logic will work if the volume ..(total no of records) is less in both the input files. But in my case my total number of records is 307578 in input 1 (with duplicates) . 192324 in input 2 without duplicates.
So i tried to do in EZT, its not working...now ia m trying in COBOL...if anyone having COBOL logic for matching two files please share here...
But this is not a normal match....
I have to read one record from input2 and then i have to scan the input1 for matching if match is found i will write in a separate file.. so input 1 para should be in loop. until i scanned/read the whole file....
apiyan,
I dont know where you got this info but it is utter BS. Easytrieve filematching can handle any volume of data and it is the simplest of the programs.
1. what is the lrecl /recfm of file 1 with duplicates
2. what is the lrecl/recfm of file 2 without duplicates
3. what is the position and length of the key to be matched in both files.
4. what is the desired output file lrecl and recfm?
5. what do you need to do if you find a match in both files? write all the duplicate keys?
6. What do you need to do if you dont find a match in the files?
Nic,
I know this is a basic file matching logic why push them to a wild goose chase?
1. what is the lrecl /recfm of file 1 with duplicates
File1 : LRECL = 313
2. what is the lrecl/recfm of file 2 without duplicates
File1 : LRECL = 800
3. what is the position and length of the key to be matched in both files.
File 1 : (Matching key positions): INP-KEY1 13 27 A
File 2 : (Matching key positions): INP-KEY2 01 27 A
4. what is the desired output file lrecl and recfm?
oUTPUT1: Matched records from both the files
DCB=(RECFM=FB,LRECL=1131,BLKSIZE=0)
oUTPUT2: Records present only from input1
DCB=(RECFM=FB,LRECL=800,BLKSIZE=0)
5. what do you need to do if you find a match in both files? write all the duplicate keys?
If i find a match, i have to write both the file1 & file2 records in OUTPUT1 with duplicates also.
6. What do you need to do if you dont find a match in the files?
Actually, The logic is ..
I have to read File1 and i need to scan File2 with the File1 first record...if match is found, i need to write in OUTPUT1..same way i need to compare/search all the records in File2 with the first record from File1 for matching...(So this file2 comparison para should be in loop until it reached EOF, after it reaches EOF it has to go to the initial position..).
then again i need to read/take the second record from File1, and i have to read again File2...this will continue, until i read all the record from File1.
So if match is not found on comparison,that means that record is present only in File1. so i have to write that record in OUTPUT2 (which is file1 records only).
Kolusu...i tried this to achieve inj EZT. But i doubt that once the file reached EOF(File2) , I cannot be resetted or bring the control back to the initial position of file2.
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