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

Records inserted in KSDS is not in sorted order


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
raviprabhu

New User


Joined: 20 Oct 2006
Posts: 29

PostPosted: Thu Jan 02, 2014 9:25 pm
Reply with quote

Hi,

I have written a program to read from flat file and write to KSDS file and I see the records in KSDS file is not in sorted order.
Any reason for this ?

Regards,
Ravi
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1787
Location: Bloomington, IL

PostPosted: Thu Jan 02, 2014 9:39 pm
Reply with quote

Why would you expect them to be? They are accessed through the index.
Back to top
View user's profile Send private message
raviprabhu

New User


Joined: 20 Oct 2006
Posts: 29

PostPosted: Thu Jan 02, 2014 9:52 pm
Reply with quote

I want the records in KSDS to be in sorted order.

After writing every record it should be in sorted order
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jan 02, 2014 9:57 pm
Reply with quote

The records on a KSDS are in the order established by the primary key.

If they are not, then you are not looking at the primary key, or you are not looking at a KSDS.

Any other data outside the primary key is irrelevant to the order of the records.

This doesn't relate to your earlier questions does it?
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1787
Location: Bloomington, IL

PostPosted: Thu Jan 02, 2014 9:57 pm
Reply with quote

What do you intend to do that requires the data to be in a certain order?
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Jan 02, 2014 10:22 pm
Reply with quote

To guarantee a proper sorted-order, SORT the flat file by the designated primary-key (which you have defined in the VSAM Base Cluster), then REPRO directly into the KSDS.

Is this an option?
Back to top
View user's profile Send private message
raviprabhu

New User


Joined: 20 Oct 2006
Posts: 29

PostPosted: Thu Jan 02, 2014 10:23 pm
Reply with quote

The records in flat file is as below

Key length is 65
Code:

02 XXXXXXXXXXX20200201304012014040101201481293930     
03 PX        XX 2013040100               XXXX XXXXXX XXXXXXXXXXX:
03 TY        XXX2013011400               XX47 YY XXX >15 < YYYK 
12AC0000          Jen:                      XXX XXXXX       
12AS0000          98                                             
12SI0000          01110                         YYYYY40           
45  0001                    0320120130401120130401          0000


After writing to KSDS its like

Code:
02 XXXXXXXXXXX20200201304012014040101201481293930               
45  0001                    0320120130401120130401          0000
12AC0000          Jen:                      XXX XXXXX       
12AS0000          98                                             
03 PX        XX 2013040100               XXXX XXXXXX XXXXXXXXXXX:
12SI0000          01110                         YYYYY40           
03 TY        XXX2013011400               XX47 YY XXX >15 < 100K


Code'd
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Jan 02, 2014 10:23 pm
Reply with quote

Hello,

Quote:
I want the records in KSDS to be in sorted order.
Then sort them before writing them to the vsam file . . .

As Akatsukami asked - what requires them be physically "in order"?
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Jan 02, 2014 10:27 pm
Reply with quote

What's the record-position in the flat-file where the primary-key can be found? This is the sorted order you need and invoking SORT to sort these records, allows you to REPRO the records directly into the VSAM KSDS in the proper order.

Am I missing something?
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1248
Location: Richfield, MN, USA

PostPosted: Thu Jan 02, 2014 10:40 pm
Reply with quote

Please use Code tags when posting your records and show us the IDCAMS listcat showing the Relative Key Position (RKP) and key length. Remember that the RKP is relative to zero, not one.
Back to top
View user's profile Send private message
raviprabhu

New User


Joined: 20 Oct 2006
Posts: 29

PostPosted: Thu Jan 02, 2014 11:17 pm
Reply with quote

Ok let me ask this way..

After writing records to KSDS file does the records will be in sorted order ?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Jan 02, 2014 11:20 pm
Reply with quote

Hello,

Not if you do not sort them before writing/loading them into the file.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Jan 02, 2014 11:21 pm
Reply with quote

Addon . . .

You still have not explained WHY you think this is needed . . . icon_confused.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jan 02, 2014 11:26 pm
Reply with quote

It is a KSDS. It will be in primary key order. It is always best when adding records to a KSDS to have them sorted in key order, but it will make no difference.

A KSDS, assuming successfully written, will be in key order, no matter the order of the input.

You must show a LISTCAT for your (alleged) KSDS.

It is beginning to smell of Troll.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Jan 03, 2014 1:18 am
Reply with quote

Hi Bill,

Quote:
It is beginning to smell of Troll.
Or TS must hear "it" in his terms - even thought they are not the proper terms . . .

And Still will not post Why this is "needed" . . .

Quite disappointing start for a new year icon_rolleyes.gif

d
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Fri Jan 03, 2014 2:30 am
Reply with quote

raviprabhu,

Somewhere, there is a 'DEFINE' for that KSDS to which you are writing. In that DEFINE, there is a KEYS parameter.

Can you tell us what that KEYS parameter looks like?

I'm asking because when you load a KSDS, the records will get sorted based on the contents of the record that is pointed to by the KEYS parameter.

It sounds a lot like you have two different definitions of the 'key' for this file. One is your SORT key, and one is your KSDS key.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts To Omit records based n SORT condition DFSORT/ICETOOL 6
No new posts To fetch records that has Ttamp value... DFSORT/ICETOOL 5
No new posts ICETOOL returns no records JCL & VSAM 1
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
Search our Forums:

Back to Top