View previous topic :: View next topic |
Author |
Message |
tictac Beginner
Joined: 24 Apr 2005 Posts: 8 Topics: 3 Location: Earth
|
Posted: Thu May 05, 2005 5:50 am Post subject: Sorting VSAM Records |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu May 05, 2005 5:59 am Post subject: |
|
|
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 |
|
 |
s_shivaraj Beginner

Joined: 21 Sep 2004 Posts: 140 Topics: 14 Location: Chennai, India
|
Posted: Thu May 05, 2005 6:02 am Post subject: |
|
|
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 |
|
 |
tictac Beginner
Joined: 24 Apr 2005 Posts: 8 Topics: 3 Location: Earth
|
Posted: Thu May 05, 2005 9:48 pm Post subject: |
|
|
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!  |
|
Back to top |
|
 |
Phantom Data Mgmt Moderator

Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Fri May 06, 2005 7:39 am Post subject: |
|
|
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 |
|
 |
tictac Beginner
Joined: 24 Apr 2005 Posts: 8 Topics: 3 Location: Earth
|
Posted: Sun May 08, 2005 9:20 pm Post subject: is alternate index an option??? |
|
|
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 |
|
 |
Phantom Data Mgmt Moderator

Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Mon May 09, 2005 5:21 am Post subject: |
|
|
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 |
|
 |
|
|