COBOL - Internal SortSequential files are used very commonly in data processing applications. The records in these files usually need to be put in ascending or descending order for proper, easy, and fast accessing. Sorting data in a file or combining two or more files is a common requirement in nearly all applications. Sorting is a technique used to arrange the records in either ascending or descending order to be able to perform the sequential processing. There are two techniques available in COBOL to sort the files: External Sort: This is used to sort files with the help of SORT utility in JCL. Internal Sort: This method sorts files within a COBOL program. COBOL provides the SORT verb to sort a file. SORT VerbSort verb accepts input from a non-sequential file or internal procedure and produces output in a requested sequence to a file or internal procedure. Before or after they are sorted, you can add, update, or delete the records. Three files are used by the SORT verb to perform the sorting in COBOL:
Syntax:SORT verb performs the following operations:
Merge VerbMerge verb is used to compare the records from two or more sequenced files and combine them in order. You can add, update, or delete the records after they are merged. Four files are used by the SORT verb to perform the sorting in COBOL:
Syntax:Merge Verb performs the following operations:
Next TopicCOBOL Database Interface |