| View previous topic :: View next topic |
| Author |
Message |
deepeshk79 Beginner
Joined: 20 Jun 2003 Posts: 112 Topics: 48 Location: Bangalore
|
Posted: Sat Aug 16, 2003 1:34 am Post subject: Read sequential file |
|
|
Hi all,
Iam reading a sequential file and my pointer is say in the 10th record. How can i reset the pointer to 1st record...
Please suggest...
I cannot close and open the file again
Thanks,
Deep |
|
| Back to top |
|
 |
deepeshk79 Beginner
Joined: 20 Jun 2003 Posts: 112 Topics: 48 Location: Bangalore
|
Posted: Sat Aug 16, 2003 2:04 am Post subject: |
|
|
Just now i saw a post by Prayank .....he too had the same requirement...
Prayank can u tell me how you solved your problem....
I have two sorted seq files say F1 and F2. I need to take out the matched records
F1 , LRECL = 15 (the file is sorted with first 3 char)
123ABCDEFGHNNNN
345FDFDSFSDNNNH
567FDSFDFDSFJUIK
678FDFDFDFDSFDS
F2, LRECL = 10 (the file is sorted with first 3 char)
123YTUYFGR
222TRYUIOP
300FDFDFDF
345LKJLK45
678RRER78
I need to match the first 3 characters only and then fetch only them into a file F3
O/P SHUD BE LIKE
F3
123
345
678
I have to do this in cobol and not using SORT or any other utility(its a requirement).....
Any thoughts....
Thanks,
Deep |
|
| Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12401 Topics: 75 Location: San Jose
|
|
| Back to top |
|
 |
vkrishna2001 Beginner

Joined: 07 Aug 2003 Posts: 46 Topics: 18 Location: Danbury
|
Posted: Fri Aug 22, 2003 10:33 am Post subject: |
|
|
Here is a simple solution. This makes the assumption that both files are sorted on the same key in ascending order irrespective of the position of the key in both the files.
Read file1 and file2
Compare the key of file1 with key of file2. Assume that key of file1 is key1 and key of file2 is key2
If key1 is = key2 then write the key to output file and read file1 and file2
If key1 is > key2 then read file2 until key1 = key2 or key1 < key2
If key1 < key2 then read file1 until key1 = key2 or key1 > key2
This needs to be done until end of file1 or end of file2.
Thanks,
Vijayakrishna |
|
| Back to top |
|
 |
hari_uss Beginner
Joined: 19 Dec 2002 Posts: 78 Topics: 6 Location: Trivandrum, India
|
Posted: Sun Aug 24, 2003 6:09 pm Post subject: |
|
|
Or,
If you have a relatively small file, which can be pushed to Working storage,
Read FILE1(smaller) sequentially and store it in a working storage table.
Read FILE2,
For each read, SEARCH the key value in WS table.
If found match, write it out,
Continue till end of FILE2.
Hari. |
|
| Back to top |
|
 |
|
|
|