COBOL - Invoice Generation using Table

Given the Product Names, Sold Quantity and Unit Price of 5 products sold by a Company. Write a COBOL program to display an Invoice for the above sales in a neat format.


       IDENTIFICATION DIVISION.
       PROGRAM-ID. INVOICE.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER.
       OBJECT-COMPUTER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  INVOICE.
           02 PRODUCT OCCURS 5 TIMES.
              03 P-NAME   PIC X(20).
              03 U-PRICE  PIC 999V99.
              03 QTY      PIC 99.
              03 AMOUNT   PIC 9999V99.
       01  C-NAME         PIC X(30).
       01  I              PIC 9.
       01  INV-AMOUNT     PIC 9999V99 VALUE IS 0.
       01  DISP-REC.
           02 PN     PIC X(20).
           02 PU     PIC ZZ9.99.
           02 FILLER PIC X(5).
           02 PQ     PIC Z9.
           02 FILLER PIC X(5).
           02 PA     PIC ZZZ9.99.
       01  DISP-AMT  PIC ZZZ9.99.
       PROCEDURE DIVISION.
       MAIN-PARA.
           DISPLAY "Enter the Customer Name".
           ACCEPT C-NAME.
           PERFORM DATA-READ VARYING I FROM 1 BY 1 UNTIL I > 5.
           DISPLAY(01 01) ERASE.
           DISPLAY "                   X Y Z CO. LTD.".
           DISPLAY "=============================================".
           DISPLAY " Inv. No   : 25".
           DISPLAY " Inv. Date : 04/06/2015".
           DISPLAY " Customer  : " C-NAME.
           DISPLAY "---------------------------------------------".
           DISPLAY "Product Name         Price    Qty      Amount".
           DISPLAY "---------------------------------------------".
           PERFORM DISP-PARA VARYING I FROM 1 BY 1 UNTIL I > 5.
           DISPLAY "---------------------------------------------".
           MOVE INV-AMOUNT TO DISP-AMT.
           DISPLAY "                        BILL AMOUNT : " DISP-AMT.
           DISPLAY "=============================================".
           DISPLAY " ".
           STOP RUN.
       DATA-READ.
           DISPLAY "Enter the " I " Product Name".
           ACCEPT P-NAME(I).
           DISPLAY "Enter the Unit Price".
           ACCEPT U-PRICE(I).
           DISPLAY "Enter the Quantity Sold".
           ACCEPT QTY(I).
           COMPUTE AMOUNT(I) = U-PRICE(I) * QTY(I).
           COMPUTE INV-AMOUNT = INV-AMOUNT + AMOUNT(I).
       DISP-PARA.
           MOVE P-NAME(I) TO PN.
           MOVE U-PRICE(I) TO PU.
           MOVE QTY(I) TO PQ.
           MOVE AMOUNT(I) TO PA.
           DISPLAY DISP-REC.

4 comments:

  1. thanks for sharing.for more information : click here

    ReplyDelete
  2. Looking very informative and useful content, Thanks for sharing please do keep on...
    Best Online Software Training Institute | Advanced Java Training

    ReplyDelete
  3. You have touched good quality points here. In whatever way continue writing.
    user experience companies

    ReplyDelete