Cobol sort key of the input file is same for more than one



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Cobol sort key of the input file is same for more than one

Postby swaroopag » Tue Apr 14, 2009 11:21 pm

Hey,

Im using cobol sort in one program and came across a scenario - where the sort key of the input file is same for more than one records..
in such case, the records should be just written to output file in the order of their occurance in the input file.
But, they are being sorted based on the field right next to the sort-key.. even though Im sorting my records based on only sort key.

The same functionality when done thru Eztrieve program, the input records for duplicate sort key are just being written in the out put file in the order they are read..
Have any of you come across similar situation.. any guess what might be wrong with my cobol porgram..?

really appreciate your response.. thanks a lot
swaroopag
 
Posts: 2
Joined: Tue Apr 14, 2009 11:15 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Cobol sort key of the input file is same for more than one

Postby dick scherrer » Wed Apr 15, 2009 3:18 am

Hello and welceom to the forum,

Suggest you add a "seqnum" field after the sort key. When you issue the sort, sort on both the sort key and this new field.

When a sort is run on the mainframe, the data is sorted by only the sort key. The sequence of the data within an individual key is unpredicatble (unless EQUALS is specified or a sequence number is used).
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post