Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random Access 4

Status
Not open for further replies.

claudeb

Programmer
Nov 23, 2000
140
CA
Hello,
My vsam file has a random access. I realized that for the same person i have different information.
Person-A Code-A Status-1
Person-A Code-B Status-2.
Right now, my key is Person-A.
Every time a do a read , I end up with Status-1, even if i move Code-B in the second field. (the first one found)
Is there a way to get the information without changing the access to dynamic and introducing a "read-next" statement ?
Thanks a lot.
 
Hi,

ACCESS DYNAMIC seems a logical solution.

Regards,

Crox
 
Claude,

VSAM with duplicates - and by your example Person-A, does not sound like a relative record key - so that rules out VSAM RRDS. RANDOM access also eliminates VSAM ESDS. I am simply trying to clarify your scenario. VSAM, duplicates, RANDOM access... VSAM KSDS... you should have alternate keys then, right?

You see, to access your file randomly you should have at least one path that allows no duplicates; otherwise you have to specify DYNAMIC and use READ NEXT. What is wrong with that?

Regards.
 
Thanks for your answers. I suggested to add Code-? (second field) as part of the key and keep the random access, but it seems that we have to go thru the database administrator to do that. we are reading an Ideal table.in fact Code-B never changes.
My access is random and i don't have an alternate key. i am trying to do a dynamic access with a browse and a read-next. for some reason it is not working yet
thanks again.
 
It seems like, if "Person-A" is your key, then when you do a dynamic access, and you hit the first "Person-A," then you'll get the first record with "Person-A." Which will be the one with "Code-A."

Though if you do a READ-NEXT after that, you should eventually hit the record with "Code-B."

I wonder if your processing is calling for the program to do the random access browse for each record. So it would get "Code-A," then do another random access and browse, and would land on "Code-A" again.

Because if you do a READ-NEXT immediately after you get the "Person-A" with "Code-A", you should hit the record with "Person-A" and "Code-B."

Check your coding very carefully.

Hope this helps, Nina Too
 
Just thought of something else.

If you hit "Person-A" with "Code-A" and "Status-1". And read the record into a WS field.

If you were to then move "Code-B" into the field previously occupied by "Code-A," you will still have "Status-1" in the WS field in which you read the record.

Just wondering. Again, check coding VERY closely. Use whatever de-bugging tools you might have i.e. Xpeditor or Inter-Test (if it's CICS/Online). Or use test displays if you're running a batch program and don't have Xpeditor for batch.

Nina Too
 
Claude & NinaToo,

With RANDOM access there is no READ NEXT! That is the reason why there is DYNAMIC access - so you can do what others refer to as random-sequential or skip-sequential processing.

With DYNAMIC access you perform a START then a READ NEXT or START BROWSE - READ NEXT if the program is online.

And I must say, if you have duplicate keys, there is NO WAY you can process RANDOMly and intend it the way you are describing.

DURA LEX, SED LEX.
 
Hi,
i solved my problem by doing something like this.

1- move "aaa' to Person-A
2- browse file
3- red-next file.
4- if Code-B not = 'bb'
perform read-next
until (Code-B = 'bb' and
Person-A = 'aaa').
I thought the program would read all the file once it would find the first 'aaa'. It reads only those records with 'aaa' in Person-A. In my case, it is 2 times at maximum, whitch is not too bad.
Winzip, i get a compile error when the access is random and i try to do a read-next. I tried it ! (not very proud of it but i did).
Thanks a lot.
 
claudeb,

You have just discovered dynamic processing! Like I said others call it random-sequential or skip-sequential... Do you know why skip-sequential? That's right- you jump (skip, get it?) to where you want to start reading, and then you go ahead and read sequentially from there. To illustrate further...

fill up the key to where you want to jump, start the browse
your subsequent READ NEXT's will read sequentially, that is one at a time!
fill up the key again and you can jump to any other area in the file, even backwards!
and again, subsequent READ NEXT's will read sequentially from the last skip you did!

Beautiful isn't it? That's why I asked earlier, what is wrong with DYNAMIC access? With your intended manner of processing and the kind of records you have, that was the most logical (the only) alternative you had.
 
Hi Claude,

Some rules for VSAM KSDS files:

Each record must contain a unique key value. That is, using your example, you cannot have a an index of Person, because it does not uniquely define each rec in the file. Person/Code may work provided there is no
person-A/Code-B/Status-1 rec in the file.

Your VSAM file, if it's key was defined by the Person field, is not a valid VSAM file. How were you able to load it w/that data?

Regards, Jack.
 
hello Jack,
I am not sure i understand the question.
in the select statement,
SELECT DATA-FILE ASSIGN TO SYS000-DATA-FILE
in the jcl
// DLBL DATA-FILE .....
Someone else defined in Vsam Tranparency DATA-FILE with its keys , key position and other characteristics. We are reading a table in fact.
in my program (cobol I) i open the file and do the processing. we didn't expect to find 2 entries for Person-A.
did i answer your question ?
Thanks for taking the time to read the posts.
ps: sometimes i can't connect to this forum for a whole day. i wonder what is the source of the problem.


 
Don't worry, WinZip, I was thinking of Dynamic Access when doing a READ-NEXT. I'm not always very schooled in writing English (just got through taking an agency Technical Writing course) so I jumped into saying "Random Access" and then forgot to clarify it when I suggested some code; it's supposed to be Dynamic Access.

Claude's right in that it won't even compile if you specify a READ-NEXT in a Random Access defined file.

Nina Too
 
At one point, claudeb says he is using an "Ideal table". Are you using an IDEAL file, claudeb, and not a true VSAM file? IDEAL is a nearly obsolete proprietary file structure, usually used with the DATACOMM product. If it's not true VSAM, the rules will not be the same.

Stephen J Spiro
 
That's a good point Stephen. I am actually reading a DataCom table. with Vsam Transparency utility, it is read as a vsam file with cobol programs.
from the answers i got, the rules should be the same.
Why do you say the opposite ? (i am positive that you are right, but just give us a hint)
thanks
 
With the Vsam Transparency utility, they SHOULD behave the same; I meant native Datacom would not necessarily act the same as VSAM. Does Datacom allow duplicate primary keys? You SEEM to indicate that it does ... in any event, you got duplicate keys here. On the other hand, Could be the data was created incorrectly.

Stephen J Spiro
 
Thanks a lot Stephen. Yes, Datacom may allow duplicate primary key.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top