Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Program to describe The Functionality of merging two files in a single file

Posted By: Lucas Silva     Category: Cobol     Views: 3612

Write a program to describe The Functionality of merging two files in a single file.

Code for Program to describe The Functionality of merging two files in a single file in Cobol

       identification division.
       program-id. mergetest.

       environment division.
       input-output section.
       file-control.
          select onefile assign to disk
          organization is line sequential.
          
          select twofile assign to disk
          organization is line sequential.
          
          select mergefile assign to disk
          
          select masterfile assign to disk
          organization is line sequential.

       data division.
       file section.
       fd onefile
        label records are standard
        value of file-id is"one.txt".
       01 one-rec.
          05 o-no   pic 99.
          05 o-name pic x(20).

       fd onefile.
        label records are standard
        value of file-id is"two.txt".
       01 two-rec.
          05 t-no   pic 99.
          05 t-name pic x(20).
       
       sd mergefile.
       01 merge-rec.
          05 m-no   pic 99.
          05 m-name pic x(20).
       
       fd masterfile.
        label records are standard
        value of file-id is"master.txt".
       01 master-rec pic x(80).

       working-storage section.
       01 eof       pic x value"y".

       procedure division.
       main-para.
           open output onefile.
           open output twofile.
           display "First File Data. . . ".
           perform until eof="n"
           display "Number: " with no advancing
           accept o-no
           display "Name: " with no advancing
           accept o-name
           write one-rec
           display "Continue [Y/N]: " with no advancing
           accept eof
           end-perform.
           close one-file.

           move "y" to eof.
           
           display "Second File Data. . . ".
           
           perform until eof="n"
           display "Number: " with no advancing
           accept t-no
           display "Name: " with no advancing
           accept t-name
           write one-rec
           display "Continue [Y/N]: " with no advancing
           accept eof
           end-perform.
           close two-file.

           merge merge-file
               on ascending key m-no
                   using one-file
                         two-file
                   giving master-file.
           stop run.

/**********************************************************************************************
INPUT FILE One.TXT
**********************************************************************************************/
01PREMKIRAN 02MANISH 10JINAL 15RASHMI /**********************************************************************************************
INPUT FILE Two.TXT
**********************************************************************************************/
11PREMKIRAN1 22MANISH1 13JINAL1 10RASHMI1 /**********************************************************************************************
OUTPUT FILE Master.TXT
**********************************************************************************************/
01PREMKIRAN 02MANISH 10JINAL 15RASHMI 11PREMKIRAN1 22MANISH1 13JINAL1 10RASHMI1
  
Share: 



Lucas  Silva
Lucas Silva author of Program to describe The Functionality of merging two files in a single file 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!