Library View Topics Framed Contents Revised Topics Previous Topic Next Topic Search Search ResultsPrevious Topic MatchNext Topic Match Notes List Notes Print Download No PDF Handheld DisconnectedHandheld ConnectedHelp

6.2.34 SORT Statement



The SORT statement accepts records from one or more files, sorts them according to the specified key(s), and makes the sorted records available either through an OUTPUT PROCEDURE or in an output file. See also "MERGE Statement" in topic 6.2.23. The SORT statement can appear anywhere in the Procedure Division except in the declarative portion.


    ___ Format __________________________________________________________________________________ 
   |                                                                                             |
   |                        <__________________________________________________                  |
   |                                                           <_____________  |                 |
   | >>__SORT__file-name-1____ ____ __ _ASCENDING__ __ _____ ____data-name-1_|_|_______________> |
   |                          |_ON_|  |_DESCENDING_|  |_KEY_|                                    |
   |                                                                                             |
   | >__ _________________________________________ ____________________________________________> |
   |    |_ ______ __DUPLICATES__ ____ __ _______ _|                                              |
   |      |_WITH_|              |_IN_|  |_ORDER_|                                                |
   |                                                                                             |
   | >__ __________________________________________________ ___________________________________> |
   |    |_ ___________ __SEQUENCE__ ____ __alphabet-name-1_|                                     |
   |      |_COLLATING_|            |_IS_|                                                        |
   |                                                                                             |
   |             <_____________                                                                  |
   | >__ _USING____file-name-2_|_______________________________________________________ _______> |
   |    |_INPUT PROCEDURE__ ____ __procedure-name-1__ _______________________________ _|         |
   |                       |_IS_|                    |_ _THROUGH_ __procedure-name-2_|           |
   |                                                   |_THRU____|                               |
   |                                                                                             |
   |              <_____________                                                                 |
   | >__ _GIVING____file-name-3_|_______________________________________________________ _____>< |
   |    |_OUTPUT PROCEDURE__ ____ __procedure-name-3__ _______________________________ _|        |
   |                        |_IS_|                    |_ _THROUGH_ __procedure-name-4_|          |
   |                                                    |_THRU____|                              |
   |                                                                                             |
   |_____________________________________________________________________________________________|
file-name-1
The name given in the SD entry that describes the records to be sorted.

No pair of file-names in a SORT statement can be specified in the same SAME SORT AREA, or SAME SORT-MERGE AREA clause. File-names associated with the GIVING clause (file-name-3...) cannot be specified in the SAME AREA clause.


X File-names associated with the GIVING clause (file-name-3...) can be
X specified in the SAME AREA clause.

Subtopics:



Previous Topic Next Topic Copyright IBM Corp. 1991, 1998

IBM Library Server Copyright 1989, 2005 IBM Corporation. All rights reserved.





Return to library:   z/OS | z/OS.e | TPF | z/VSE | z/VM | IBM Hardware | IBM System z Redbooks
Glossary:   IBM terminology
Publications:   How to order publications
Readers:   Download IBM Library Reader | Download IBM Softcopy Reader | Download Adobe® Acrobat® Reader®
Library management:   Download IBM Softcopy Librarian
Contacts:   Contact z/OS


Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks of Adobe Systems incorporated.