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 

Loading records sorted on DECENDING order on KSDS.

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


Joined: 03 Apr 2006
Posts: 3
Topics: 2

PostPosted: Mon Aug 20, 2007 11:29 pm    Post subject: Loading records sorted on DECENDING order on KSDS. Reply with quote

Hi,

Can we load VSAM - KSDS with the records sorted on DECENDING order on key.

If yes please let me know how to do it.

Thanks
Naveen.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Aug 21, 2007 7:27 am    Post subject: Reply with quote

Naveen_jr777,

You canNOT. The Key is always in ascending sequence

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jsharon1248
Intermediate


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

PostPosted: Tue Aug 21, 2007 7:51 am    Post subject: Reply with quote

I know one way to accomplish the same thing if you have a numeric key. Subtact the key from all 9's when you load/retrieve it. Say you have 2 keys, 157 and 314. You would use 842 in place of the 157 value, and 685 in place of the 314 value. To convert it back, just subtract from all 9's again. 999-842 becomes 157 and 999-685 becomes 314. Things would get a lot more complicated trying to do this with alpha data, but I suppose it could be done.
Back to top
View user's profile Send private message
expat
Intermediate


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

PostPosted: Wed Aug 22, 2007 11:32 am    Post subject: Reply with quote

But why would you want to do that ???

Just sort the data from where ever straight into the VSAM file
_________________
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
jsharon1248
Intermediate


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

PostPosted: Wed Aug 22, 2007 11:53 am    Post subject: Reply with quote

Since you can't load records with a descending key, using this 9's complement technique will accomplish the same thing for numeric keys. I worked at a shop that utilized this technique with dates so that when they used skip sequential processing, the first record returned had the most recent date. The last record had the oldest. I don't know what the op was trying to accomplish.
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


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

PostPosted: Wed Aug 22, 2007 12:04 pm    Post subject: Reply with quote

jsharon1248,

you are still loading the vsam ksds with ascending keys. bonk
_________________
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 Aug 22, 2007 12:21 pm    Post subject: Reply with quote

Right. The 9's complement technique still loads the physical keys in ascending order, but the logical keys are descending. If we have customer, ABC, and they have 3 orders with dates 20070810, 20070821, and 20070822, just loading them as is will result in the following physical order:
ABC20070810
ABC20070821
ABC20070822

Apply the 9's complement technique to the dates and you get the following physical order:
ABC79929177 (99999999 - 20070822 = 79929177)
ABC79929178 (99999999 - 20070821 = 79929178)
ABC79929189 (99999999 - 20070810 = 79929189)

You're loading the 9's complement key in ascending order, but the actual dates they represent are in descending order. When you retrieve the dates, just apply the technique again; 99999999 - 79929177 = 20070822 and so forth,.
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


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

PostPosted: Wed Aug 22, 2007 12:43 pm    Post subject: Reply with quote

jsharon1248,

not even bothering to address the idiot issues of all input sorts being changed, all match merge compare logic being reversed, you missed the question:
Quote:

Can we load VSAM - KSDS with the records sorted on DECENDING order on key.


and you can't.

now, your methodology will allow for a logical descending key. but the whole world needs to change to deal with it. unless you re-sort all you posting input, skip sequential logic is out the window.

and thanks for the lecture on 9's complement.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Aug 22, 2007 12:55 pm    Post subject: Reply with quote

jsharon1248,

I think the 9's complement with dates is a little dangerous. for ex if for some reason the following numbers are stored in the file

Code:

79959769
79959768
79959767
79959766
79959765
79959764
79959763
79959762


now if we use the 9's complement then you will get a invalid date

Code:

20040230
20040231
20040232
20040233
20040234
20040235
20040236
20040237


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jsharon1248
Intermediate


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

PostPosted: Wed Aug 22, 2007 1:56 pm    Post subject: Reply with quote

dbzTHEdinosaur

I didn't miss the original question. It was quite clear and the answer is no. You missed the point of my first post. I was presenting an option that might be suitable in some cases. The op didn't say what they were trying to do, so I was presenting a technique that I've seen used effectively. I don't know if it would work for them, but I thought maybe they'd find it useful.

To address the 'idiot' issue of sorting, you're still sorting the key in ascending sequence so I'm not sure how that changes. For the 'idiot' issue of matching and merging, as long as your files are consistent, both 9's complement or both original, you can still match and merge. And yes, any application that wants to access the VSAM file would need to be aware of the conversion.


kolusu
As long as you start with a valid date, you'll wind up with a valid date. The only way you'd get an invalid date on the conversion from 9's complement would be to convert an invalid date to 9's complement.
Back to top
View user's profile Send private message
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Wed Aug 22, 2007 3:10 pm    Post subject: Reply with quote

The 1st time I ran into storing keys in 9s complement was in the case of storing the effective date of a price list file. This was many years ago and was used for an ISAM file (the precursor to VSAM). It was a very effective way, for its time, of accessing the most recent price list date, but of course nowdays there are better techniques.
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
jsharon1248
Intermediate


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

PostPosted: Thu Aug 23, 2007 9:41 am    Post subject: Reply with quote

Terry

Agreed. I wouldn't advocate 9's complement as a first choice. There are better options. But if the op has a VSAM requirement and no other choice, this might be a good fit.
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