COBOL/400 Language Help


SORT Statement

Description
The SORT statement accepts records from one or more files, sorts them according to the specified keys, and makes the sorted records available either through an OUTPUT PROCEDURE or in an output file. The SORT statement may appear anywhere in the Procedure Division except in the declarative portion.
                         *-------------------------------------<-1
                         +
                         V
  ->->---SORT file-name-1--*----*--*-ASCENDING--*-*-----*--------->2
                         *-ON-*  *-DESCENDING-* *-KEY-*
 
 1<--------------------------*
        *------------*      +
        V            +      +
 2->----data-name-1---*------*----------------------------------->
 
 
  ->----*--------------------------------------*----------------->
       *-*------*---DUPLICATES---*----------*-*
         *-WITH-*                *-IN ORDER-*
 
  ->----*---------------------------------------------*---------->
       *-*-----------*-SEQUENCE-*--*-alphabet-name-1-*
         *-COLLATING-*          *IS*
 
               *-----------*
               V           +
  ->----*-USING file-name-2-*------------------------------------> 3
       *-INPUT PROCEDURE--*----*--procedure-name-1--------------> 4
                          *-IS-*
 
3 ->------------------------------------*------------------------>
4 ->----*------------------------------**
       *-*-THROUGH-*-procedure-name-2-*
         *-THRU----*
                *-----------*
                V           +
  ->----*-GIVING file-name-3-*-----------------------------------> 5
       *-OUTPUT PROCEDURE-*----*-procedure-name-3---------------> 6
                          *-IS-*
5 ->------------------------------------*------------------------><-
6 ->----*------------------------------**
       *-*-THROUGH-*-procedure-name-4-*
         *-THRU----*


[ Top of Page | Previous Page | Next Page | Table of Contents ]