COBOL SORT - How to sort entire file first & sort by Key



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

COBOL SORT - How to sort entire file first & sort by Key

Postby k_ekam » Thu Dec 01, 2022 12:58 pm

Hi,
In COBOL is there a compiler option within the internal program sort to the entire file first and then sort by the key supplied?
Or is there an option to do the same at programming level

Thanks in advance
k_ekam
 
Posts: 2
Joined: Thu Jul 29, 2021 1:26 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COBOL SORT - How to sort entire file first & sort by Key

Postby prino » Thu Dec 01, 2022 3:03 pm

And the advantage of doing this is?

Clueless in Calcutta, I guess...
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 635
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 28 times

Re: COBOL SORT - How to sort entire file first & sort by Key

Postby sergeyken » Thu Dec 01, 2022 6:24 pm

k_ekam wrote:Hi,
In COBOL is there a compiler option within the internal program sort to the entire file first and then sort by the key supplied?
Or is there an option to do the same at programming level

Thanks in advance

In the latest version of COBOL, there is a new option:
PARM='DOMYJOBFORMEINFULL'

Try to specify it, and you'll get everything you want.
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 409
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 6 times
Been thanked: 40 times

Re: COBOL SORT - How to sort entire file first & sort by Key

Postby Robert Sample » Wed Dec 07, 2022 7:32 am

If you look in the Language Reference manual for your version of COBOL, you will discover that the syntax for the SORT verb requires a key be specified. Hence, unless you define a key for the entire record and sort on that key, you cannot "sort the entire file".

Furthermore, wanting to sort the entire file followed by a key sort makes no sense. The sort of the entire file will be negated by the key sort since the end result will be the file will be in key sequence.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post