Page 1 of 1

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

PostPosted: Thu Dec 01, 2022 12:58 pm
by k_ekam
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

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

PostPosted: Thu Dec 01, 2022 3:03 pm
by prino
And the advantage of doing this is?

Clueless in Calcutta, I guess...

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

PostPosted: Thu Dec 01, 2022 6:24 pm
by sergeyken
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.

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

PostPosted: Wed Dec 07, 2022 7:32 am
by Robert Sample
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.