Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Program for the SORTING Operation

Posted By: Gabriel Silva     Category: Cobol     Views: 1739

Write a program for the SORTING Operation.

Code for Program for the SORTING Operation in Cobol

*********************
INPUT FILE - SORT.INP
*********************
PREM06
AMIT01
VISHAL46
SANJAY24

*********************                
CODE FILE - SORT.CBL
*********************

       IDENTIFICATION DIVISION.
        PROGRAM-ID. SORT1.

       ENVIRONMENT DIVISION.

        CONFIGURATION SECTION.
         SOURCE-COMPUTER. IBM-PC.
         OBJECT-COMPUTER. IBM-PC.

        INPUT-OUTPUT SECTION.
         FILE-CONTROL.

           SELECT UNSORTED-FILE ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.

           SELECT WORK-FILE ASSIGN TO SYSWORK.

           SELECT SORTED-FILE ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.

       DATA DIVISION.

        FILE SECTION.

         FD UNSORTED-FILE
           VALUE OF FILE-ID IS "SORT.INP".
         01 IN-REC.
            05 IN-NAME PIC X(7).
            05 FILLER PIC XX.
            05 IN-AGE PIC 99.


         SD WORK-FILE.
         01 WORK-REC.
            05 FILLER PIC X(9).
            05 WORK-AGE PIC 99.

         FD SORTED-FILE
           VALUE OF FILE-ID IS "SORT.OUT".

         01 OUT-REC PIC X(80).


        WORKING-STORAGE SECTION.

       PROCEDURE DIVISION.

           SORT WORK-FILE
                ON DESCENDING KEY WORK-AGE
                USING UNSORTED-FILE
                GIVING SORTED-FILE.

           STOP RUN.

*********************
OUPUT FILE - SORT.OUT
*********************
AMIT     01
PREM     06
SANJAY   24
VISHAL     46
  
Share: 


Didn't find what you were looking for? Find more on Program for the SORTING Operation Or get search suggestion and latest updates.

Gabriel  Silva
Gabriel Silva author of Program for the SORTING Operation is from Salvador, Brazil.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!