View previous topic :: View next topic
|
Author |
Message |
samimaktar
New User
Joined: 03 Aug 2009 Posts: 25 Location: Singapore
|
|
|
|
Hi All
Is it possible to reposition the control once end-of-file is reached while reading a VSAM file sequentially thru COBOL program?
(We can do it using working storage variable as the file will be loaded into WS variable).
As per my knowledge, I have to close the file and then OPEN the file to reposition the control. Is there any other way except this?
Regards,
Samim |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Why do you want to do this? If you tell us, we might be able to suggest other ways to achieve your object.
Why type of VSAM file is it?
Yes, CLOSE/OPEN would do it, but if you are thinking of reading the whole file again, usually it means the design of your program is not so hot. |
|
Back to top |
|
|
samimaktar
New User
Joined: 03 Aug 2009 Posts: 25 Location: Singapore
|
|
|
|
Thanks Bill for reply.
Actually I was exploring whether there is (are) any option(s) available to reposition the control if EOF is reached for both KSDS and ESDS. I did not
find any answer/option to reposition the control except using WS variable.
And..reading the whole file sequentially again is no a good idea.
Regards,
Samim |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
For KSDS, look at START.
For RRDS (look it up) it is obvious.
For ESDS maybe best would be to define an alterate-index. You also have the option of an assemble routine to do RBA access.
Can you explain a bit about the WS variable method. |
|
Back to top |
|
|
samimaktar
New User
Joined: 03 Aug 2009 Posts: 25 Location: Singapore
|
|
|
|
Hi Bill
Using WS variable means...
If I want to read a file sequentially multiple times, the best option is to load the file (required fields) into ws variable (table) and performing Binary search.
What will be case of Flat File (PS file) if end of file is reached, I mean, is repositioning of control possible?
Regards,
Samim |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Hi Samim,
The best way to read a file sequentially multiple times is to not do it.
If you have data which you want to use for "lookup", then a KSDS with an appropriate key, or putting the data in WS as you say, and if feasible (depending on size of file).
With a flat file, and you had to read it more than once (like the Earth would explode if you didn't, that sort of scale of "had") then CLOSE/OPEN is about it, I think. You could jigger it in Assembler, but why would you bother to complicate the already stupid.
I feel there must be some actual requirement that is lurking behind the questions. Do you want to let us know? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
1. it is not control - proper terminology would include Current Record Indicator
had you used proper terminology, you could have found this stuff in the manual.
2. It is bad enough to skip around with direct access reads.
SORT YOUR INPUT TO MATCH THAT OF THE FILE
there is never, never a good reason to perform multiple passes on a file...... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
It is extremely rare when it is proper to bounce around in files that are being processed sequentially. I suspect this is NOT one of them.
All this approach does is to waste lots of resources and add complexity. It it almost always a sign that whoever did the design has extremely limited experience.
If you post your actual requirement, someone will have an alternate suggestion that will serve you and your organization much better. |
|
Back to top |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
And another potential new user slinks away after the public flogging! |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Ed,
Samim has been here since 2009.
What do you feel about this was a "public flogging"?
If you have what you feel are genuine points to make about things here, take those points to the appropriate forum, not tag them on to the end of other people's topics, please. |
|
Back to top |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
Yes sir. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
This TS (as many others) may simply disappear when the "thing" they have proposed is shot down by multiple "senior" folks. They and their organizations (imho) would be much better served if they contnued to participate and come away with a more supportable approach. For most requirements, there are very good alternatives available here.
If this is considered "flogging" - well ok but I believe the flogging reference was more of a humorous comment ?
What many inexperienced posters do not realize is that a bad approach is still a bad approach and there is usually nothing personal meant by the replies. Care should be taken to "attack" the idea not the person. Some people will take the reply personally because it simply disagreed with what that want to do. . .
Also, one of the worst "defenses" of a bad approach is calling it "the requirement". What nonsense. . . |
|
Back to top |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
Too late for me to claim anything, after having insulted someone accidentally. My mistake was that my previous comment on "flogging" was on the Fresher site, not this site. So without that context, I can easily see why it reads worse than intended.
Hopefully, that's enough said. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
It is never too late, Ed.
As the person who has, twice, responded to you, I can assure you that I am far from insulted.
Your previous comment was here, althoughl I think the topic is now in the recycle bin (it was in FAQ when I commented). I remember at least two of the participants in addition to you, at least one of whom is not on the "freshers" site.
I do wonder about you calling yourself a "refugee". It doesn't insult me, or anything like that, but I suspect you are a million miles from being a refugee.
I wondered why someone who obviously knows a thing or two was embarking on such comments as the "public flogging". Hence my invitation. If you have a point, take it to a more appropriate forum on this site. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Bill Woodger wrote: |
I do wonder about you calling yourself a "refugee". |
IMHO, the MVS Help site is moribund; the last post was last October. |
|
Back to top |
|
|
|