Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Program to print bill report

Posted By: Lurline Fischer     Category: Cobol     Views: 5511

Write a program to print bill report.

Code for Program to print bill report in Cobol

       IDENTIFICATION DIVISION.
        PROGRAM-ID. Table1.

       ENVIRONMENT DIVISION.

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

        INPUT-OUTPUT SECTION.
         FILE-CONTROL.

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

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

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

       DATA DIVISION.

        FILE SECTION.

         FD TABLE-FILE
           VALUE OF FILE-ID IS "TABLE.IND".
         01 TABLE-REC.
            05 ZIPCODE PIC 9(6).
            05 FILLER PIC XX.
            05 TAX-RATE PIC 99.

         FD CUST-FILE
           VALUE OF FILE-ID IS "CUST.DAT".
         01 SAL-REC.
            05 C-ID PIC 9(4).
            05 FILLER PIC XX.
            05 C-ZIPCODE PIC 9(6).
            05 FILLER PIC XX.
            05 C-SALE PIC 9(6).

         FD BILL-FILE
           VALUE OF FILE-ID IS "BILL.RPT".
         01 BILL-REC PIC X(80).

        WORKING-STORAGE SECTION.
        01 TAB.
            05 TABLE-ENTRIES OCCURS 5 TIMES.
                07 TEMP-ZIPCODE PIC 9(6).
                07 FILLER PIC XX.
                07 TEMP-TAX-RATE PIC 99.

        01 OUT-REC.
           05 OUT-C-ID PIC 9(4).
           05       PIC XX VALUE SPACES.
           05 OUT-C-ZIPCODE PIC 9(6).
           05       PIC XX VALUE SPACES.
           05 OUT-C-SALE PIC 9(6).
           05       PIC XX VALUE SPACES.
           05 OUT-C-TAX-RATE PIC 9(2).
           05       PIC XX VALUE SPACES.
           05 OUT-C-TAX PIC 9(6).

        77 EOF PIC X VALUE 'N'.
        77 IND PIC 9 VALUE 1.

       PROCEDURE DIVISION.

         BEGIN.
           OPEN INPUT TABLE-FILE
                      CUST-FILE
               OUTPUT BILL-FILE.

           PERFORM GET-TABLE-ENTRIES.
           PERFORM GET-SAL-ENTRIES.

           CLOSE TABLE-FILE
                 CUST-FILE
                 BILL-FILE.

           STOP RUN.

         GET-TABLE-ENTRIES.
           MOVE 1 TO IND
           PERFORM VARYING IND FROM 1 BY 1
                   UNTIL IND > 5
            READ TABLE-FILE
             AT END CONTINUE
             NOT AT END PERFORM MOVE-TABLE-ENTRIES
            END-READ
           END-PERFORM.

         MOVE-TABLE-ENTRIES.
           MOVE ZIPCODE TO TEMP-ZIPCODE (IND)
           MOVE TAX-RATE TO TEMP-TAX-RATE (IND).

         GET-SAL-ENTRIES.
           PERFORM UNTIL EOF = 'Y'
            READ CUST-FILE
             AT END MOVE 'Y' TO EOF
             NOT AT END PERFORM MOVE-CUST-ENTRIES
            END-READ
           END-PERFORM.

         MOVE-CUST-ENTRIES.
           MOVE C-ID TO OUT-C-ID
           MOVE C-ZIPCODE TO OUT-C-ZIPCODE
           MOVE C-SALE TO OUT-C-SALE

           MOVE 1 TO IND
           PERFORM VARYING IND FROM 1 BY 1
                   UNTIL IND > 6 OR C-ZIPCODE = TEMP-ZIPCODE (IND)
           END-PERFORM

           IF IND < 6
              MOVE TEMP-TAX-RATE (IND) TO OUT-C-TAX-RATE
              COMPUTE OUT-C-TAX = (OUT-C-SALE * OUT-C-TAX-RATE) /100
           ELSE
              MOVE 0 TO OUT-C-TAX-RATE OUT-C-TAX
           END-IF

           WRITE BILL-REC FROM OUT-REC.


***********************
INPUT FILE 1 - CUST.DAT
***********************

0001  380001  100000
0002  380002  100000
0003  380003  100000
0004  380004  100000
0005  380005  100000

************************
INPUT FILE 2 - TABLE.IND
************************            

380001  05
380002  10
380003  15
380004  20
380005  25

************************
OUTPUT FILE - BILL.RPT
************************            
           
0001  380001  100000  05  005000
0002  380002  100000  10  010000
0003  380003  100000  15  015000
0004  380004  100000  20  020000
0005  380005  100000  25  025000
  
Share: 


Didn't find what you were looking for? Find more on Program to print bill report Or get search suggestion and latest updates.

Lurline Fischer
Lurline Fischer author of Program to print bill report 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!