View previous topic :: View next topic
|
Author |
Message |
jtwohig
New User
Joined: 24 Jul 2006 Posts: 18
|
|
|
|
Hi,
I'm having a brain cramp, my VSAM is a little rusty. How would I go about searching a VSAM file for a non-key field (SSN) from a batch Cobol program ? In most cases, the key field value would be available but in some cases I just have non-key field like SSN or EIN to search for.
Thanks! |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Tell us a little about you VSAM file.
How many records in the file?
For each run, how many "KEY" accesses will you make?
For each run, how many non 'KEY" accesses will you make?
Can you create alternate index based on access fields? (currently non "KEY")
What order is the driver in (i.e. Input file that drives the process)
How many different non "KEY" fields can you be searching on?
How often do you need to run this process?
Dave |
|
Back to top |
|
|
Muthukumar.PLindia
New User
Joined: 03 Jul 2006 Posts: 51 Location: Chennai
|
|
|
|
If you have a non key field, the only way to search the VSAM is sequential access.. U need to read all the records one by one and should check for a match...
If you need it to be dynamic(fetching the exact record) u need the full key of it...
IF you have the partial key(example : if 2 fields constituite a key, and you have the data for one field alone) then u can use Random access method and START statement can be used for searching..
As your scenarios falls under the first case, u can use sequential access alone like a normal PS read.
correct me if i am wrong.
Muthu |
|
Back to top |
|
|
mainframemouli
New User
Joined: 01 Mar 2005 Posts: 52 Location: Mysore
|
|
|
|
Have a sequential read for the file
and check for the non-key field....treat the VSAM file as the simple flat file. |
|
Back to top |
|
|
jtwohig
New User
Joined: 24 Jul 2006 Posts: 18
|
|
|
|
Thanks very much to all !!! Looks like the sequential read is my option here.
J. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
A sequential read of the VSAM file is not necessarily a good option if the non ?KEY? data is not in the same sort order as the VSAM file, and it probably is not, and depending upon how many records are in the VSAM file, and how many access are going to be made to it.
If there are many records in the VSAM file, and there are more than, well, one access to it, a better solution would be to build a temporary VSAM file with the not ?KEY? data and the ?KEY? of the main VSAM file. This way you build a kind of index into the VSAM file. If you do not have the native ?KEY?, read the temporary VSAM file to retrieve it, then go after the main VSAM file.
Dave |
|
Back to top |
|
|
jtwohig
New User
Joined: 24 Jul 2006 Posts: 18
|
|
|
|
Thanks for your response Dave. Had to hop on to another task but can now describe the files, etc. Input file is in EDI format, so order is totally random and data changes, and is processed, on a daily basis. Due to this, the number of key vs. non-key accesses changes daily. I'd be searching on one non-key field only, SSN/EIN. File is a production file accessed by many other processes. I doubt the addition of an alternate index would occur anytime soon. My process would be access via a batch cobol program. The temporary VSAM file option sounds like it could be do-able. A co-worker also suggested creating a flat file with just the non-key field (SNN/EIN) in it, sorted in the non-key field order since all I want to do is determine whether the SSN/EIN on the input/driver file is on the VSAM file (or its flat file extract). If the SSN/EIN is on the VSAM/flat file, it's selected vs. a "non-hit" in which case it's excluded.
Thanks again,
J. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Best of luck with this. Come back and let us know what your final solution was and how it worked.
Dave |
|
Back to top |
|
|
satya123 Warnings : 1 New User
Joined: 18 Aug 2006 Posts: 57
|
|
|
|
Hi all,
please let me know if Vsam file can be accessed by RBA thru COBOL program???I know thru CICS it is possible. |
|
Back to top |
|
|
|