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
k_ekam
Posts: 2
Joined: Thu Jul 29, 2021 1:26 pm
Skillset: Mainframe,COBOL,REXX, DB2
Referer: google

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

User avatar
prino
Posts: 641
Joined: Wed Mar 11, 2009 12:22 am
Skillset: PL/I - CICS - DB2 - IDMS - REXX - JCL, most in excess of three decades
Referer: Google
Location: Vilnius, Lithuania
Contact:

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
sergeyken
Posts: 458
Joined: Wed Jul 24, 2019 10:12 pm
Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
Referer: Internet search

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.

Robert Sample
Global moderator
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Skillset: Systems programming, SAS, COBOL, CICS, JCL, SMS, VSAM, etc.
Referer: other forum
Location: Dubuque, Iowa, USA

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.


  • Similar Topics
    Replies
    Views
    Last post