Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Program to print presence report based on provided data

Posted By: Addie Fischer     Category: Cobol     Views: 1831

Program to print presence report based on provided data.

Code for Program to print presence report based on provided data in Cobol

       IDENTIFICATION DIVISION.
        PROGRAM-ID. PRESENCE-RPT.

       ENVIRONMENT DIVISION.

        INPUT-OUTPUT SECTION.
         FILE-CONTROL.
           SELECT FILE-READ ASSIGN TO DISK
            ORGANIZATION IS LINE SEQUENTIAL.
           SELECT FILE-WRITE ASSIGN TO DISK
            ORGANIZATION IS LINE SEQUENTIAL.

       DATA DIVISION.
        FILE SECTION.

         FD FILE-READ
            VALUE OF FILE-ID "ATENDNCE.DAT".
         01 F-REC-IN.
            02 F-SRNO PIC 999.
            02 F-DATE PIC 999999.
            02 F-STATUS PIC X OCCURS 60 TIMES.

         FD FILE-WRITE
            VALUE OF FILE-ID "ATENDNCE.RPT".
         01 F-REC-OUT PIC X(78).

        WORKING-STORAGE SECTION.
         77 L-COUNT PIC 99 VALUE 08.
         77 EOF PIC X VALUE 'N'.
         
         77 PRE-COUNTER PIC 999 VALUE ZEROS OCCURS 60 TIMES.
         77 IND PIC 99 VALUE 1.
         77 TEMP-PER PIC 99V99.
      *12345678901234567890123456789012345678901234567890123456789012345678901234567890        
      *<-----------------------------PRESENCE REPORT-------------------------------->
      *                                           DATE     : MM/DD/YY
      *                                           PAGE     : 99
      *                                           LACTURES : 999
      *<---------------------------------------------------------------------------->
      *          ROLL NO.     TOTAL ATTENDENCE        PERCENTAGE
      * -----------------------------------------------------------------------------
      *            99              999                 99.99

         77 HEAD-LINE1 PIC X(78)
            VALUE"<-----------------------------PRESENCE REPORT---------
      -          "----------------------->".
         01 HEAD-LINE2.
            05 S1 PIC X(56)
             VALUE"                                                 DATE
      -           " :".
            05 DATE-OUT.
                10 DD2 PIC 99.
                10     PIC X VALUE '/'.
                10 MM2 PIC 99.
                10     PIC X VALUE '/'.
                10 YY2 PIC 99.

         01 HEAD-LINE3.
            05 S2 PIC X(56)
            VALUE"                                                 PAGE
      -          ": ".
            05 PAGE-COUNT PIC 99 VALUE 1.
      *   01 HEAD-LINE4.
      *     05 S1 PIC X(60)
      *      VALUE"                                                 LACTU
      *-          "RES : ".
         77  COUNTER PIC 99 VALUE ZERO.

         77 HEAD-LINE5 PIC X(78)
            VALUE"<-----------------------------------------------------
      -          "----------------------->".
         77 HEAD-LINE6 PIC X(78)
            VALUE"                ROLL NO.     TOTAL ATTENDENCE        P
      -          "ERCENTAGE".
         77 DASH-LINE PIC X(78) VALUE ALL "-".

         01 DATE-IN.
            05 YY1 PIC 99.
            05 MM1 PIC 99.
            05 DD1 PIC 99.
         01 REC-OUT.
            02        PIC X(19).
            02 ROLLNO PIC Z9.
            02        PIC X(13).
            02 TOTAL-ATTEN PIC ZZZ9.
            02        PIC X(17).
            02 PER-ATTEN PIC Z9.99.

       PROCEDURE DIVISION.
         BEGIN.
           OPEN INPUT FILE-READ.
           OPEN OUTPUT FILE-WRITE.

           PERFORM DATE-PARA.
           PERFORM HEADING-PARA.

           PERFORM UNTIL EOF = 'Y'
                READ FILE-READ
                    AT END MOVE 'Y' TO EOF
                    NOT AT END
                        ADD 1 TO COUNTER
                        PERFORM PROCESS-PARA
                END-READ
           END-PERFORM.
           PERFORM MOVE-PARA.
           CLOSE FILE-READ.
           CLOSE FILE-WRITE.
           STOP RUN.

        DATE-PARA.
            ACCEPT DATE-IN FROM DATE.
            MOVE DD1 TO DD2.
            MOVE MM1 TO MM2.
            MOVE YY1 TO YY2.
            
        HEADING-PARA.
            WRITE F-REC-OUT FROM HEAD-LINE1.
            WRITE F-REC-OUT FROM HEAD-LINE2.
            WRITE F-REC-OUT FROM HEAD-LINE3.
      *      WRITE F-REC-OUT FROM HEAD-LINE4.
            WRITE F-REC-OUT FROM HEAD-LINE5.
            WRITE F-REC-OUT FROM HEAD-LINE6.
            WRITE F-REC-OUT FROM DASH-LINE.
        PROCESS-PARA.
           MOVE 1 TO IND 
           PERFORM 60 TIMES
                IF F-STATUS (IND) = 'P'
                        ADD 1 TO PRE-COUNTER (IND)
                        ADD 1 TO IND
                ELSE
                        ADD 1 TO IND
                END-IF
           END-PERFORM.

        MOVE-PARA.
           MOVE 1 TO IND
           PERFORM 60 TIMES
                MOVE IND TO ROLLNO
                MOVE PRE-COUNTER (IND) TO TOTAL-ATTEN
                COMPUTE TEMP-PER = (100 * PRE-COUNTER (IND) ) / COUNTER
                MOVE TEMP-PER TO PER-ATTEN
                WRITE F-REC-OUT FROM REC-OUT
                ADD 1 TO L-COUNT
                IF L-COUNT > 23
                    ADD 1 TO PAGE-COUNT
                    MOVE 8 TO L-COUNT
                    PERFORM HEADING-PARA
                END-IF
                ADD 1 TO IND
           END-PERFORM.
  
Share: 


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

Addie Fischer
Addie Fischer author of Program to print presence report based on provided data 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!