IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

VSAM file indexing query


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
aakar

New User


Joined: 08 Apr 2008
Posts: 36
Location: mumbai

PostPosted: Wed Oct 15, 2008 3:52 pm
Reply with quote

I have a VSAM file indexed on 3 fields and these 3 fields constitute the primary key....If i have values to only 2 of the 3 fields in my code and the third field is unknown then can i access the VSAM using only these two keys....Please the VSAM file below:

Code:
  Primary key               Related data
-------+-----------    -------------------------------------------------
00000001ABETA     ...............................* 
00000003BBETA     ............................... 
00000004BBETA     ...............................     
00000005CBETA     ...............................
00000006CBETA     ...............................
00000009ABETA     ...............................*
00000011ABETB     ............................... 
00000013BBETB     ............................... 
00000014BBETB     ...............................     
00000015CBETB     ...............................
00000016CBETB     ...............................
00000019ABETB     ...............................

key1 : first 8 bytes (00000001)
key2 : 9th byte (A/B/C)
key3 : 10th onwards 4 bytes (BETA)


If i have only key2 & key3,
key2 = A
key3 = BETA,combined as ABETA.
Is there any technique wherein i can access all rows in the VSAM using only,
key2 = A
key3 = BETA
that is code should read only the ones i have marked with a star (*) and
it should not read sequentially till it reaches the required record.

Restrictions:
I cannot change primary key, it has to be a combination of the three keys to remain unique.
Nothing else in the data area can be defined as a Alternate index.

I am contemplating the below two approaches:
1. Creating an alternate index out of the primary key
2. Using SHORT KEY method(i.e START with GTEQ option and doing a READ NEXT.) mentioned in this topic:
www.ibmmainframes.com/viewtopic.php?t=34910
(please provide reference on this option.

Sorry for this long post....

Edited: Please use BBcode when You post some code, that's rather readable...Anuj
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Oct 15, 2008 4:59 pm
Reply with quote

Alternate index is probably the better way to go; if you don't know the first part of the key value then you basically have to read the entire file sequentially to find the matches. Reading generic keys with GTEQ only works when you shorten the key from the right, not from the left.
Back to top
View user's profile Send private message
aakar

New User


Joined: 08 Apr 2008
Posts: 36
Location: mumbai

PostPosted: Wed Oct 15, 2008 5:26 pm
Reply with quote

Hi Robert,

Can i then create an AIX such that it consists of key2,key3 even if key2,key3 are a part of primary key. Actually have seen that most programs use AIX's present in the data area. If i define an AIX from the primary key, i shouldn't face any problem accessing it right?

Thanks for the reply..

Can u give some reference link for the GTEQ function, feel that it can be useful to me in some other reference.....
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Oct 15, 2008 5:38 pm
Reply with quote

As far as your first question, from the manual on defining alternate indexes:
Quote:
KEYS(length offset]64 0)
describes the alternate-key field in the base cluster's data record.


The key field of an alternate index is called an alternate key. The data record's alternate key can overlap or be contained entirely within another (alternate or prime) key field.


The manuals link at the top of the page includes the COBOL Language Reference manual, which describes START KEY >= <value>. Usually when I see GTEQ and generic key it is in reference to CICS, and these manuals are also found at the manuals link.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Oct 16, 2008 1:29 pm
Reply with quote

Hi Aakar,
aakar wrote:
Can u give some reference link for the GTEQ function, feel that it can be useful to me in some other reference.....
As suggested, reference is in relation with CICS, here is a reference:

publib.boulder.ibm.com/infocenter/cicsts/v3r1/index.jsp?topic=/com.ibm.cics.ts31.doc/dfhp3/dfhp3mn.htm

Search for GTEQ there.
Back to top
View user's profile Send private message
aakar

New User


Joined: 08 Apr 2008
Posts: 36
Location: mumbai

PostPosted: Thu Oct 16, 2008 1:32 pm
Reply with quote

thanks anuj
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Oct 16, 2008 1:34 pm
Reply with quote

Hi,

Chek this one also,

publib.boulder.ibm.com/infocenter/txformp/v6r0m0/index.jsp?topic=/com.ibm.cics.te.doc/erziai0098.htm

Search for GTEQ there.


Please notice in your very first post, that's been edited to add the BBcode.
Back to top
View user's profile Send private message
aakar

New User


Joined: 08 Apr 2008
Posts: 36
Location: mumbai

PostPosted: Thu Oct 16, 2008 1:47 pm
Reply with quote

yeah i did notice that, how was it done, it looks better now.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Oct 16, 2008 2:36 pm
Reply with quote

aakar wrote:
how was it done.
Using BBcode tags.

May be you didn't notice the embedded link in the previous post, hover your mouse on the text "BBcode", it'll be hilighted with a underline, it's a link, click on that. It will tell what is BBcode.
Quote:
Edited: Please use BBcode when You post some code, that's rather readable...Anuj
Back to top
View user's profile Send private message
aakar

New User


Joined: 08 Apr 2008
Posts: 36
Location: mumbai

PostPosted: Thu Oct 16, 2008 2:45 pm
Reply with quote

thanks that will help me make my posts look better.....
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Oct 20, 2008 8:17 am
Reply with quote

You're welcome.. icon_smile.gif

-Ad
Back to top
View user's profile Send private message
aakar

New User


Joined: 08 Apr 2008
Posts: 36
Location: mumbai

PostPosted: Mon Oct 20, 2008 9:08 am
Reply with quote

Hey anuj,
In the same file above, Can we give a short key like this, in the start command,
key1= Low values (or first position)
key2 = A
key3 = BETA

and perform READ-NEXT command. Will this ensure that only the records with these two keys get read and that other records are skipped. so only,
00000001ABETA ......
00000009ABETA ......
gets read. It becomes a performance problem if i do sequential reads searching for records with these two values till end of file.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Oct 20, 2008 9:16 am
Reply with quote

Hello,

No, that will not do what you want.

How many records are in the file?
Back to top
View user's profile Send private message
aakar

New User


Joined: 08 Apr 2008
Posts: 36
Location: mumbai

PostPosted: Mon Oct 20, 2008 9:22 am
Reply with quote

Very large number of records(>10000) are there in the file with the same key.
if i use an AIX made out of key2 & key3 and make key1(8 byte) as primary key, then the aix runs out of length.
refer my other post in this reference:
ibmmainframes.com/viewtopic.php?t=35264
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Oct 20, 2008 9:25 am
Reply with quote

Hello,

Not what i asked - how many total records are in the file?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top