Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Records inserted in KSDS is not in sorted order

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Records inserted in KSDS is not in sorted order
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: 1738
Location: Bloomington, IL

PostPosted: Thu Jan 02, 2014 9:39 pm    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Jan 02, 2014 9:57 pm    Post subject: Reply to: Records inserted in KSDS is not in sorted order
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: 1738
Location: Bloomington, IL

PostPosted: Thu Jan 02, 2014 9:57 pm    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Jan 02, 2014 10:22 pm    Post subject: Reply to: Records inserted in KSDS is not in sorted order
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    Post subject:
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

Site Director


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

PostPosted: Thu Jan 02, 2014 10:23 pm    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Jan 02, 2014 10:27 pm    Post subject: Reply to: Records inserted in KSDS is not in sorted order
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: 1238
Location: Richfield, MN, USA

PostPosted: Thu Jan 02, 2014 10:40 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Thu Jan 02, 2014 11:20 pm    Post subject:
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

Site Director


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

PostPosted: Thu Jan 02, 2014 11:21 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Jan 02, 2014 11:26 pm    Post subject: Reply to: Records inserted in KSDS is not in sorted order
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

Site Director


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

PostPosted: Fri Jan 03, 2014 1:18 am    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
No new posts how to split records based on specifi... Venkata Ramayya DFSORT/ICETOOL 6 Wed Sep 28, 2016 3:20 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us