Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

SORT THE FILE

Posted By: Huette Miller     Category: Cobol     Views: 2117

PROGRAM WHICH TAKE THE INPUT FROM FILE SORT THE ACCORDING KEY AND STORE IN ANOTHER FILE.

Code for SORT THE FILE in Cobol

       IDENTIFICATION DIVISION.
        PROGRAM-ID.sort1.

        ENVIRONMENT DIVISION.
         INPUT-OUTPUT SECTION.
          FILE-CONTROL.
           SELECT sortin ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.

           SELECT sortout ASSIGN TO DISK
           ORGANIZATION IS LINE SEQUENTIAL.

           SELECT sortfile ASSIGN TO DISK.


       DATA DIVISION.
        FILE SECTION.
        FD sortin
         VALUE OF FILE-ID IS "sortin.txt".
         01 sortinrec.
          05 ino PIC 99.
          05 filler PIC x.
          05 iname PIC x(10).

        FD sortout
         VALUE OF FILE-ID IS "sortout.txt".
         01 sortoutrec.
          05 ono PIC 99.
          05 filler PIC x.
          05 oname PIC x(10).

        SD sortfile.
         01 sortrec.
          05 sno PIC 99.
          05 filler PIC x.
          05 sname PIC x(10).


       PROCEDURE DIVISION.
         SORT sortFILE ON ASCENDING KEY sno
         USING sortin GIVING sortout.
         STOP RUN.


*********************INPUT*******************************
      *SORTIN.TXT

      *01 JOLLY
      *05 MANALI
      *03 SARITA
      *02 ISHA

*********************OUTPUT******************************
      *SORTOUT.TXT

      *01 JOLLY
      *02 ISHA
      *03 SARITA
      *05 MANALI
  
Share: 


Didn't find what you were looking for? Find more on SORT THE FILE Or get search suggestion and latest updates.

Huette Miller
Huette Miller author of SORT THE FILE is from Frankfurt, Germany.
 
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!