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 

Sorting VSAM Records

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


Joined: 24 Apr 2005
Posts: 8
Topics: 3
Location: Earth

PostPosted: Thu May 05, 2005 5:50 am    Post subject: Sorting VSAM Records Reply with quote

hello sirs and madams,
supposed i have vsam records that has the elements:
Code:
 STUD-NUM    FIRST-NAME    LAST-NAME    SCHOOL   B-DAY


STUD-NUM and LAST-NAME are record keys

i need the records in the VSAM file to be sorted according to B-DAY...
how can this be done?

thanks
Back to top
View user's profile Send private message MSN Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Thu May 05, 2005 5:59 am    Post subject: Reply with quote

tictac,

Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DSN=YOUR VSAM CLUSTER,
//            DISP=SHR
//SORTOUT  DD DSN=YOUR OUTPUT FILE,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *
  SORT FIELDS=(P,M,F,A)
/*

Code:

Here P = starting pos of B-day
     M = Length of B-day
     F = format of B-day(character, packed decimal...)



Hope this helps...

Cheers

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


Joined: 21 Sep 2004
Posts: 140
Topics: 14
Location: Chennai, India

PostPosted: Thu May 05, 2005 6:02 am    Post subject: Reply with quote

tictac,

You need to post the record keys position in the file also.. There are lot of posts available for sorting, you can search that and modify according to your need..
_________________
Cheers
Sivaraj S

'Technical Skill is the Master of complexity, while Creativity is the Master of Simplicity'
Back to top
View user's profile Send private message AIM Address
tictac
Beginner


Joined: 24 Apr 2005
Posts: 8
Topics: 3
Location: Earth

PostPosted: Thu May 05, 2005 9:48 pm    Post subject: Reply with quote

hi kolusu and sivaraj!
thanks for your reply... should i include this in the JCL that defines the VSAM file? also when i insert a record in the file, will this record be placed in the correct location based on the B-DAY?

thanks again! Very Happy
Back to top
View user's profile Send private message MSN Messenger
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Fri May 06, 2005 7:39 am    Post subject: Reply with quote

Tictac,

I think you are confused. The VSAM file will always be in ascending order of the key field. All you can do is to temporarily sort the data in a different order and store it in ANOTHER dataset and use that dataset in your program as input instead of the original VSAM file.

Let us know if you have any questions,

Thanks,
Phantom
Back to top
View user's profile Send private message
tictac
Beginner


Joined: 24 Apr 2005
Posts: 8
Topics: 3
Location: Earth

PostPosted: Sun May 08, 2005 9:20 pm    Post subject: is alternate index an option??? Reply with quote

Phantom wrote:
Tictac,

I think you are confused. The VSAM file will always be in ascending order of the key field. All you can do is to temporarily sort the data in a different order and store it in ANOTHER dataset and use that dataset in your program as input instead of the original VSAM file.

Let us know if you have any questions,

Thanks,
Phantom


thanks phantom, i would like to ask if i can use ALTERNATE INDEX as an option?
Back to top
View user's profile Send private message MSN Messenger
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Mon May 09, 2005 5:21 am    Post subject: Reply with quote

Tictac,

yes, Alternate Index would also be a better option for you. Just create an alternate index on the DOB column (field) and use the alternate index cluster as input to your program. This will provide you the flexibility of using RANDOM READ though the data is not stored in strict ascending order of DOB. No need to sort the file on DOB now.

Let us know if you face any problems,

Thanks,
Phantom
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