Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Program to generate a sales register

Posted By: Rachel Fischer     Category: Cobol     Views: 2329

Write a program to generate a sales register.

Code for Program to generate a sales register in Cobol

        IDENTIFICATION DIVISION.
        PROGRAM-ID. SALARY.
        ENVIRONMENT DIVISION.
        INPUT-OUTPUT SECTION.
        FILE-CONTROL.

                SELECT PAY-IN-FILE ASSIGN TO DISK
                ORGANIZATION IS LINE SEQUENTIAL.

                SELECT REG-OUT-FILE ASSIGN TO DISK
                ORGANIZATION IS LINE SEQUENTIAL.

        DATA DIVISION.
        FILE SECTION.

      *   Structure of the input file.  
        FD PAY-IN-FILE VALUE OF FILE-ID IS FILE-NAME
                    LABEL RECORDS ARE STANDARD.
        01 PAY-REC.
                05 MMYY         PIC 9999.
                05 ENO          PIC 9999.  
                05 ENAME        PIC X(22).
                05 DESIG        PIC X(10).
                05 DNO          PIC 99.
                05 CATOGRY      PIC X.
                05 GROSS        PIC 9(5)V99.
                05 PF-AMT       PIC 9(5)V99.
                05 PROF-TAX     PIC 9(5)V99.
                05 LIC-DED      PIC 9(5)V99.
                05 OTHER-DED    PIC 9(5)V99.

      *   Output file which has a variable name.  
        FD REG-OUT-FILE VALUE OF FILE-ID IS 'PRAC12.RPT'
                     LABEL RECORDS ARE STANDARD.
        01 SLIP-REC  PIC X(130).

        WORKING-STORAGE SECTION.

      *    Structure of the Heading of the output file.
        01 HEAD1.
                05 FILLER       PIC X(25) VALUE SPACES.
                05 TITLE1       PIC X(30)
                        VALUE 'FOLLWALA INFO TECH LTD.'.

      *    Structure of the column heads.
        01 HEAD2.
                05 FILLER       PIC X(3)          VALUE SPACES.       
                05 COL1         PIC X(5)          VALUE 'EMP.'.
                05 FILLER       PIC X(2)          VALUE SPACES.
                05 COL2         PIC X(22)         VALUE 'EMP.'.
                05 FILLER       PIC X(2)          VALUE SPACES.
                05 COL3         PIC X(5)          VALUE 'DEPT.'.
                05 FILLER       PIC X(2)          VALUE SPACES.
                05 COL4         PIC X(5)          VALUE 'EMPL'.
                05 FILLER       PIC X(2)          VALUE SPACES.
                05 COL5         PIC X(10)         VALUE 'GROSS'.
                05 FILLER       PIC X(2)          VALUE SPACES.
                05 COL6         PIC X(10)         VALUE 'PF'.
                05 FILLER       PIC X(2)          VALUE SPACES.
                05 COL7         PIC X(10)         VALUE 'PROF'.
                05 FILLER       PIC X(2)          VALUE SPACES.
                05 COL8         PIC X(10)         VALUE 'LIC'.
                05 FILLER       PIC X(2)          VALUE SPACES.
                05 COL9         PIC X(10)         VALUE 'OTHER'.
                05 FILLER       PIC X(2)          VALUE SPACES.
                05 COL10        PIC X(10)         VALUE 'TOTAL'.
                05 FILLER       PIC X(2)          VALUE SPACES.
                05 COL11        PIC X(10)         VALUE 'NET'.


      *    Output record Structure.
        01 REG-REC.
                05 FILLER       PIC X(2) VALUE SPACES.
                05 ENO          PIC ZZ99.
                05 FILLER       PIC X(2) VALUE SPACES.
                05 ENAME        PIC X(22).
                05 FILLER       PIC X(4) VALUE SPACES.
                05 DNO          PIC Z9.
                05 FILLER       PIC X(6) VALUE SPACES.
                05 CATOGRY      PIC X.
                05 FILLER       PIC X(2) VALUE SPACES.
                05 GROSS        PIC ZZ,ZZ9.99.
                05 FILLER       PIC X(2) VALUE SPACES.
                05 PF-AMT       PIC ZZ,ZZ9.99.
                05 FILLER       PIC X(2) VALUE SPACES.
                05 PROF-TAX     PIC ZZ,ZZ9.99.
                05 FILLER       PIC X(2) VALUE SPACES.
                05 LIC-DED      PIC ZZ,ZZ9.99.
                05 FILLER       PIC X(3) VALUE SPACES.
                05 OTHER-DED    PIC ZZ,ZZ9.99.
                05 FILLER       PIC X(1) VALUE SPACES.
                05 NET-DED      PIC ZZ,ZZ,ZZ9.99.
                05 FILLER       PIC X(2) VALUE SPACES.
                05 NET-SAL      PIC ZZ,ZZ,ZZ9.99.

      *   Unedited totals to calculate total salaries.
        01 TOTALS.
                05 TOTAL-GROSS          PIC 9(9)V99 VALUE ZERO.
                05 TOTAL-DED            PIC 9(9)V99 VALUE ZERO.
                05 TOTAL-NET            PIC 9(9)V99 VALUE ZERO.

        77 FILE-NAME    PIC X(12) VALUE SPACES.
        77 EOF          PIC X VALUE 'N'.
        01 USER-MMYY.
                05 U-MM PIC 99.
                05 U-YY PIC 99.
        77 TEMP-TOTAL   PIC 9(9)V99.
        77 D-LINE       PIC X(130) VALUE ALL '-'.

        PROCEDURE DIVISION.

      *    Main para to open the input file and process it.
        MAIN-PARA.
                DISPLAY "ENTER THE MONTH AND YEAR :- ".
                ACCEPT USER-MMYY.
                PERFORM FIND-FILE.

                OPEN INPUT PAY-IN-FILE
                     OUTPUT REG-OUT-FILE.

                PERFORM HEAD-PARA.

                READ PAY-IN-FILE.
                PERFORM WRITE-PARA UNTIL EOF = 'Y'.

                PERFORM FOOTER-PARA.
                CLOSE PAY-IN-FILE REG-OUT-FILE.
                STOP RUN.

      *    Depending upon input record generate the file-name.  
        FIND-FILE.
                STRING "SLIP" DELIMITED BY ' '
                       USER-MMYY DELIMITED BY ' '".DAT" DELIMITED BY ' ' 
                       INTO FILE-NAME.

      *    Para to write the headings and col. titles in output file.
        HEAD-PARA.
                WRITE SLIP-REC FROM HEAD1.

                STRING 'SALARY REGISTER FOR :- '
                DELIMITED BY '/'
                U-MM DELIMITED BY ' ''/20' DELIMITED BY ' '
                U-YY DELIMITED BY ' '
                INTO TITLE1.
                
                WRITE SLIP-REC FROM HEAD1.

                WRITE SLIP-REC FROM D-LINE.
                WRITE SLIP-REC FROM HEAD2.

                MOVE ' NO.'   TO COL1.
                MOVE 'NAME'   TO COL2.
                MOVE 'NO'     TO COL3.
                MOVE 'CATG'   TO COL4.
                MOVE 'SALARY' TO COL5.
                MOVE 'AMT.'   TO COL6.
                MOVE 'TAX'    TO COL7.
                MOVE 'DEDN'   TO COL8, COL9, COL10.
                MOVE 'SALARY' TO COL11.

                WRITE SLIP-REC FROM HEAD2.
                WRITE SLIP-REC FROM D-LINE.

      *    Output the record to appropriate file depending upon mmyy.
        WRITE-PARA.
                MOVE CORR PAY-REC TO REG-REC.
                PERFORM CALC-PARA.
                WRITE SLIP-REC FROM REG-REC.
                READ PAY-IN-FILE AT END MOVE 'Y' TO EOF.


      *    Add current record to the totals.
        CALC-PARA.
                MOVE ZERO TO TEMP-TOTAL.
                ADD GROSS OF PAY-REC      TO TOTAL-GROSS.
                ADD PF-AMT OF PAY-REC     TO TEMP-TOTAL.
                ADD PROF-TAX OF PAY-REC   TO TEMP-TOTAL.
                ADD LIC-DED OF PAY-REC    TO TEMP-TOTAL.
                ADD OTHER-DED OF PAY-REC  TO TEMP-TOTAL.

                MOVE TEMP-TOTAL TO NET-DED.
                ADD TEMP-TOTAL TO TOTAL-DED.
                COMPUTE TOTAL-NET = TOTAL-NET +
                        ( GROSS OF PAY-REC - TEMP-TOTAL).

                COMPUTE NET-SAL = GROSS OF PAY-REC - TEMP-TOTAL.

      *    Para to print the footer report.  
        FOOTER-PARA.
                WRITE SLIP-REC FROM D-LINE.
                MOVE SPACES TO REG-REC.
                MOVE 'TOTAL  : ' TO ENAME OF REG-REC.
                MOVE TOTAL-GROSS TO GROSS OF REG-REC.
                MOVE TOTAL-DED TO NET-DED OF REG-REC.
                MOVE TOTAL-NET TO NET-SAL OF REG-REC.
                WRITE SLIP-REC FROM REG-REC.
                WRITE SLIP-REC FROM D-LINE.



/***********************************************************************************************    
OUTPUT
***********************************************************************************************/
FOLLWALA INFO TECH LTD. SALARY REGISTER FOR :- 02/2003 ---------------------------------------------------------------------------------------------------------------------------------- EMP. EMP. DEPT. EMPL GROSS PF PROF LIC OTHER TOTAL NET NO. NAME NO CATG SALARY AMT. TAX DEDN DEDN DEDN SALARY ---------------------------------------------------------------------------------------------------------------------------------- 01 VD 1 M 1,000.00 110.00 20.00 10.00 10.00 150.00 850.00 02 KHALAS KAPIL 1 S 5,000.00 10.00 30.00 10.00 10.00 60.00 4,940.00 03 MODI VISHAL 1 D 2,000.00 100.00 50.00 10.00 10.00 170.00 1,830.00 04 HARSH CHAUHAN 2 O 100.00 5.00 40.00 10.00 10.00 65.00 35.00 05 ANISHA CHAUHAN 2 C 500.00 8.00 30.00 10.00 10.00 58.00 442.00 06 PATEL TAPAN 2 W 2,000.00 7.00 20.00 10.00 10.00 47.00 1,953.00 ---------------------------------------------------------------------------------------------------------------------------------- TOTAL : 10,600.00 550.00 10,050.00 ----------------------------------------------------------------------------------------------------------------------------------
  
Share: 


Didn't find what you were looking for? Find more on Program to generate a sales register Or get search suggestion and latest updates.

Rachel Fischer
Rachel Fischer author of Program to generate a sales register 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!