Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

PROGRAM FOR READ SALES DATA FROM INPUT-FILE AND MOVE INTO OUTPUT-FILE

Posted By: Huette Miller     Category: Cobol     Views: 3225

PROGRAM FOR READ SALES DATA FROM INPUT-FILE AND MOVE INTO OUTPUT-FILE.

Code for PROGRAM FOR READ SALES DATA FROM INPUT-FILE AND MOVE INTO OUTPUT-FILE in Cobol

       identification division.
       program-id. test.
       environment division.
       configuration section.
       input-output section.
       file-control.
       select in-file assign to disk
       organization is line sequential.

       select out-file assign to disk
       organization is line sequential.

       data division.

       file section.

       fd in-file
       label records are standard
       value of file-id is"ex13in.txt".
       01 in-rec.
       03 ident-in pic xxxxx.
       03 sales-in pic 99999.

       fd out-file
       label records are standard
       value of file-id is"ex13out.txt".
       01 out-rec pic x(80).

       working-storage section.

       77 eof pic x value'n'.

       01 h0.
       03 F PIC X(25) VALUE ALL SPACES.
       03 f pic x(12) value"SALES RECORD".
       01 h1.
       03 f pic x(80) value all "~".
       01 h2.
       03 f pic x(5) value spaces.
       03 f pic x(6) value"IDENTI".
       03 f pic x(5) value spaces.
       03 f pic x(9) value"SALES-AMT".
       03 f pic x(5) value spaces.
       03 f pic x(9) value"DISC-PERC".
       03 f pic x(5) value spaces.
       03 f pic x(7) value"NET-OUT".

       01 h3.
       03 f pic x(5) value spaces.
       03 s1 pic xxxxx.
       03 f pic x(8) value spaces.
       03 s2 pic 9(5).
       03 f pic x(7) value spaces.
       03 s3 pic 99999.
       03 f pic x(9) value spaces.
       03 s4 pic 999999.
       77 disc pic 99999.
       77 disc-amt pic 99999.
       77 new1-amt pic 99999.
       77 total pic 9(6).
       procedure division.
       main-para.
       open input in-file.
       open output out-file.

       write out-rec from h1.
       write out-rec from h0.
       write out-rec from h1.
       write out-rec from h2.
       write out-rec from h1.

       read in-file at end move 'y' to eof.
       perform p-para until eof = 'y'.

       close in-file out-file.
       stop run.
       p-para.
       if sales-in > 100
       compute disc = sales-in * 3
       else
       compute disc = sales-in * 2.

       compute disc-amt = sales-in * disc.
       compute new1-amt = sales-in - disc-amt.

       move ident-in to s1.
       move  sales-in to s2.
       move disc-amt to s3.
       move new1-amt to s4.

       write out-rec from h3.

       read in-file at end move 'y' to eof.
  
Share: 



Huette Miller
Huette Miller author of PROGRAM FOR READ SALES DATA FROM INPUT-FILE AND MOVE INTO OUTPUT-FILE is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 
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!