External
Sort is used to sort the file externally, like through JCL.
Internal
sort is used to sort the file inside COBOL program using SORT verb.
Three
files are used in the sort process in COBOL:
Input
file – The file which needs to be sorted either in ascending or descending
order.
Work
file – The file which is used to hold the records during sort process. Input
file records are transferred to this file for the sorting process. This file
needs to be defined in File section under SD entry.
Output
file – Final file which contains the records in the desired sorted order.
Syntax:
SORT work-file ON ASCENDING-KEY/DESCENDING-KEY
USING input-file GIVING output-file
Once
the sorted records are moved to output file, the sort file will be deleted.
//INFILE
DD DSN=input-file
//OUTFILE
DD DSN=output-file
//SORTWK
DD DSN=&&TEMP
Work
file should be opened in I-O mode.
No comments:
Post a Comment