MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

key generation in VSAM (KSDS) file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Data Management
View previous topic :: View next topic  
Author Message
computer
Beginner


Joined: 12 Jun 2007
Posts: 64
Topics: 17
Location: Hyderabad

PostPosted: Wed Feb 04, 2009 2:25 am    Post subject: key generation in VSAM (KSDS) file Reply with quote

Hi,

My requirement is that, on daily basis we receive some records which we need to add into our master file.(KSDS)

The present method we are following is....we Read the master file till the EOF and then from last record key value we generate new key. This is very tedious and time consuming.

So, is there any way to go directly to last record of a vsam KSDS file.
Key layput - KEY 12 A
I used the following logic,
KEY = ' 9999999999'
(Since this the maximum value that i can have for this key. The first 2 bytes are mandatorly spaces)

Then issued the following command,
POINT file LE KEY status
but it throws error as 'PARAMETER IS INVALID - LT '

Note:
1. Its a VSE environment.
2. It should be done in EasyTrieve language

Thanks in advance for any help....
Manoj
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Wed Feb 04, 2009 7:00 am    Post subject: Reply with quote

you could keep an all 99999999999999 or high-value record,
that you could read directly,
would maintain the last/highest customeer number used.
you could implement RESTART with the data portion of this record.

Does not matter what you add/insert,
KSDS will always build the data portion adding the new records after the last.
The keys will be ordered in the Index.
Only a reorg can reorder the data portion.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
jsharon1248
Intermediate


Joined: 08 Aug 2007
Posts: 291
Topics: 2
Location: Chicago

PostPosted: Wed Feb 04, 2009 4:12 pm    Post subject: Reply with quote

Follow the dinosaur's advice for storing the last used key. You might consider adding it on a record with the lowest key value rather than the highest. Adding it as the highest might increase CI/CA splits because VSAM would always want to insert records into the last CI with the highest key.

dbz, I'm thinking that your response isn't entirely accurate. VSAM will attempt to insert records into the appropriate CI for KSDS. If KSDS only added at the end, we wouldn't have CI/CA splits. It's been a while, so forgive me if I'm blowing smoke...
Back to top
View user's profile Send private message
expat
Intermediate


Joined: 01 Mar 2007
Posts: 475
Topics: 9
Location: Welsh Wales

PostPosted: Thu Feb 05, 2009 2:01 am    Post subject: Reply with quote

Inserting records with a higher key value than the highest available would not cause any CI/CA splits.

It sounds to me that the application logic is somewhat lacking when you have to manually generate KSDS keys for data. Not being a programmer maybe someone could explain how would a user retrieve data by key if he has no idea of what the key is bonk
_________________
If it's true that we are here to help others,
then what exactly are the others here for ?
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Thu Feb 05, 2009 4:13 am    Post subject: Reply with quote

jsharon1248,

your idea of a low-value 'control record' is much better than a high-value key.

and you are correct of course about splits for inserts.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
computer
Beginner


Joined: 12 Jun 2007
Posts: 64
Topics: 17
Location: Hyderabad

PostPosted: Thu Feb 12, 2009 5:50 am    Post subject: Reply with quote

Hi,
I followed the concept of storing the 'last key used' in another file. And each time take the refrence of this file for key generation at the start and updating the last key generated at the end of operation.

But i did not get this one 'your idea of a low-value 'control record' is much better than a high-value key'.

Can anybody please explain me what was about this "low-value 'control record' " method.

Thanks,
Manoj
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Thu Feb 12, 2009 8:49 am    Post subject: Reply with quote

instead of a separate file to control your vsam, use the first record of your vsam file as a control - using low-values as the key.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Data Management All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group