Advertisement
Nick-O-Rama

BalanceLine

Dec 7th, 2015
2,637
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 8.36 KB | None | 0 0
  1.        identification division.
  2.        program-id. Program1.
  3.  
  4.        environment division.
  5.        input-output section.
  6.        File-Control.
  7.        Select PayRollM assign to "E:\cobol\PayRollM.txt"
  8.            organization is line sequential.  
  9.            
  10.            Select PayRollT assign to
  11.            "E:\cobol\PayRollT.txt"                    
  12.            organization is line sequential.
  13.            
  14.            Select UPayRollM assign to "E:\cobol\UPayRollM.txt"
  15.            organization is line sequential.  
  16.            
  17.            Select ControlL assign to
  18.            "E:\cobol\ControlL.txt"                    
  19.            organization is line sequential.
  20.        
  21.        
  22.        configuration section.
  23.        
  24.        data division.
  25.        fd PayRollM.
  26.        01 Employee.
  27.            05 Emp-No pic 9(5).
  28.            05 pic x(24).
  29.            05 Ann-Sal pic 9(6).
  30.            05 pic x(45).
  31.            
  32.        fd PayRollT.
  33.         01 EmployeeT.
  34.            05 Emp-No-T pic 9(5).
  35.            05 pic x(24).
  36.            05 Ann-Sal-T pic 9(6).
  37.            05 pic x(45).
  38.            
  39.        fd UPayRollM.
  40.         01 EmployeeUP.
  41.            05 Emp-No-UP pic 9(5).
  42.            05 pic x(24).
  43.            05 Ann-Sal-UP pic 9(6).
  44.            05 pic x(45).
  45.            
  46.        fd ControlL.
  47.         01 EmployeeCL.
  48.            05 pic xx.
  49.            05 Emp-No-C pic 9(5).
  50.            05 pic x(13).
  51.            05 Old-Ann-Sal pic $ZZZ,ZZZ.99.
  52.            05 pic x(13).
  53.            05 New-Ann-Sal pic $ZZZ,ZZZ.99.
  54.            05 pic x(8).
  55.            05 Action pic x(16).
  56.            
  57.        
  58.        working-storage section.
  59.        01 activeKey pic xxxxx.
  60.        01 trans-key pic 99999 value 0.
  61.        01 masterkey pic 99999 value 0.
  62.        01 endofilem pic xxx value 'NO'.
  63.        01 endofilet pic xxx value 'NO'.
  64.       * 01 END-OF-FILES pic xxx value 'NO'.
  65.        01 DateOfDoc.
  66.                05 CurrentYear pic 9(4).
  67.                05 CurrentMonth pic 99.
  68.                05 CurrentDate pic 99.
  69.                
  70.        01 LINECOUNT PIC 99 VALUE 0.  
  71.        01 updated pic xxx value 'YES'.
  72.        01 Header.
  73.            05 pic x(18) value spaces.
  74.            05 pic x(34) value 'CONTROL LISTING FOR PAYROLL UPDATE'.
  75.            05 pic x(4) value spaces.
  76.            05 fullDate.
  77.                10 date1 pic 99.
  78.                10 pic x value '/'.
  79.                10 month2 pic 99.
  80.                10 pic x value '/'.
  81.                10 year2 pic 9(4).
  82.            05 pic x(3) value spaces.  
  83.            05 pic xxxx value 'Page'.
  84.            05 pic x value Spaces.
  85.            05 PageNum pic 99 value 1.
  86.            
  87.        01 HEADER2.
  88.            05 PIC X(12) VALUE  "EMPLOYEE NO.".
  89.            05 pic x(8) value spaces.
  90.            05 pic x(22) value "PREVIOUS ANNUAL SALARY".
  91.            05 PIC XX VALUE SPACES.
  92.            05 PIC X(17) VALUE "NEW ANNUAL SALARY".
  93.            05 PIC XXXX VALUE SPACES.
  94.            05 PIC X(12) VALUE "ACTION TAKEN".
  95.  
  96.        procedure division.
  97.         100-main.
  98.            open input PayRollT
  99.                       PayRollM
  100.                output ControlL
  101.                        UPayRollM
  102.  
  103.            PERFORM 600-PRINTHEADER  
  104.            perform 205-ReadPayRollT
  105.            perform 200-ReadPayRollM
  106.          
  107.       *   perform 310-choosekey
  108.          
  109.           perform 500-compare until activeKey = HIGH-values
  110.  
  111.            
  112.            CLOSE PayRollT
  113.                  PayRollM
  114.                  UPayRollM
  115.                  ControlL
  116.            goback.
  117.        
  118.        200-ReadPayRollM.
  119.       * if not endofilem = 'YES' then
  120.        READ PayRollM
  121.            at end
  122.            Display "END M"
  123.            display emp-no
  124.            Move 'YES' to endofilem
  125.            not AT END
  126.                Display "Employee: " Employee
  127.         END-READ
  128.       * end-if
  129.        .      
  130.        
  131.        205-ReadPayRollT.
  132.       * if not endofilet = 'YES'then
  133.        READ PayRollT
  134.            At end
  135.                Display "END T"
  136.                display emp-no-t
  137.                move 'YES' to endofilet
  138.            not AT END
  139.                Display "EmployeeT: " EmployeeT
  140.         END-READ
  141.       * end-if
  142.        .      
  143.        
  144.        300-Update.
  145.       * Display "up"
  146.            Move spaces to EmployeeUP
  147.            Move EMp-No-T to EMp-No-Up
  148.            Move Ann-Sal-T to Ann-Sal-UP
  149.            write EmployeeUP
  150.            perform 400-cont.
  151.        
  152.        305-copy.
  153.        Move spaces to EmployeeUP
  154.            Move EMp-No to EMp-No-Up
  155.            Move Ann-Sal to Ann-Sal-UP
  156.            write EmployeeUP.
  157.            
  158.       * 310-choosekey.
  159.       * if emp-no < emp-no-t then
  160.       *    move emp-no-t to masterkey
  161.       *    move emp-no to trans-key
  162.       *    move emp-no-t to activekey
  163.       * else if emp-no > emp-no-t then  
  164.       *    move emp-no to masterkey
  165.       *    move emp-no-t to trans-key
  166.       *     move emp-no to activekey
  167.       *    end-if
  168.       * end-if
  169.        
  170.        Display trans-key " : " masterkey " : " activekey
  171.        .
  172.        
  173.        400-cont.
  174.       * Display "CL"
  175.            Move spaces to EmployeeCL
  176.            if updated = 'YES' then
  177.                Move "Record UPdated" to Action
  178.                Move Ann-Sal to old-ann-sal
  179.            else
  180.                Move "New Record Added" to action
  181.                move 0 to old-ann-sal
  182.            end-if
  183.            
  184.            Move Emp-No-T to Emp-No-C
  185.            
  186.            Move ann-sal-t to new-ann-sal
  187.       *    Display "Updated: " Updated
  188.            write EmployeeCL
  189.            ADD 1 TO LINECOUNT.
  190.        
  191.        500-compare.
  192.        if endofilet = 'YES' and endofilem = 'YES' then
  193.            move high-values to activekey
  194.        else
  195.        Display "in"
  196.        Display "files: " endofilet " : " endofilem
  197.            if emp-no < emp-no-t then
  198.            Display "Fisrt"
  199.                if endofilem = 'YES' then
  200.                Move 'NO' to updated
  201.                perform until endofilet = 'YES'
  202.                    perform 300-update
  203.                    perform 205-readpayrollt
  204.                end-perform
  205.            else
  206.                perform until emp-no >= emp-no-t
  207.                    perform 305-copy
  208.                    perform 200-readpayrollm
  209.                end-perform
  210.            end-if    
  211.            else
  212.            
  213.            if emp-no > emp-no-t then
  214.            Display "Second"
  215.                if endofilet = 'YES' then
  216.                    perform until endofilem = 'YES'
  217.                        perform 305-copy
  218.                        perform 200-readpayrollm
  219.                    end-perform
  220.                else
  221.                Move 'NO' to updated
  222.                    perform 300-update
  223.                    perform 205-readpayrollt
  224.                end-if
  225.           else
  226.            
  227.            if emp-no = emp-no-t then
  228.       *       if not ann-sal = ann-sal-t then
  229.                 Move 'YES' to updated
  230.                    Display "third"
  231.                  
  232.                    perform 300-update
  233.       *       else
  234.       *       perform 305-copy
  235.       *       end-if
  236.                perform 205-readpayrollt
  237.                    perform 200-readpayrollm
  238.       *   else
  239.            
  240.       *   if emp-no-t > emp-no then
  241.       *       Display "fourth"
  242.       *       Move 'NO' to updated
  243.       *       perform until endofilet = 'YES'
  244.       *           perform 300-update
  245.       *           perform 205-readpayrollt
  246.       *       end-perform
  247.                
  248.       *    else if emp-no > emp-no-t then
  249.       *        Display "fifth"
  250.      
  251.       *        perform until endofilem = 'YES'
  252.       *            perform 305-copy
  253.       *            perform 200-readpayrollm
  254.       *        end-perform
  255.            end-if
  256.  
  257.        end-if.
  258.        
  259.        600-printHeader.
  260.            Move Function Current-Date to DateOfDoc
  261.            
  262.            Move CurrentDate to date1
  263.            Move CurrentMonth to month2
  264.            Move CurrentYear to year2
  265.  
  266.            if linecount >= 30 then
  267.                Add 1 to PageNum
  268.               Move 0 to linecount    
  269.            end-If
  270.        
  271.            if linecount = 0 then
  272.                Move Header to eMPLOYEECL
  273.                write EMPLOYEECL
  274.                After advancing page
  275.                
  276.                 Move spaces to EMPLOYEECL
  277.               write EMPLOYEECL
  278.            end-if
  279.            
  280.            Move Header2 to EMPLOYEECL
  281.            Write EMPLOYEECL
  282.  
  283.        end program Program1.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement