Advertisement
Nick-O-Rama

IndexingFiles

Dec 7th, 2015
2,697
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 1.81 KB | None | 0 0
  1.        identification division.
  2.        program-id. Program1.
  3.  
  4.        environment division.
  5.         input-output Section.
  6.        File-Control.
  7.            Select PayRoll-Master assign to
  8.                "E:\cobol\masterPay.txt"
  9.                 Organization is line sequential.
  10.                
  11.            Select Ind-File assign to
  12.            "E:\cobol\indexedFile.txt"
  13.                 Organization is indexed
  14.                ACCESS IS SEQUENTIAL
  15.               RECORD KEY IS emp-num-out.
  16.                
  17.        configuration section.
  18.  
  19.        data division.
  20.        file section.
  21.        FD  PayRoll-Master.
  22.        01  Emp-Rec.
  23.            05 numE pic 9(5).
  24.            05 cusname pic x(20).
  25.            05 DOP pic x(8).
  26.            05 amt-due pic 9999v99.
  27.            
  28.        fd Ind-File.
  29.        01 emp-Out.
  30.            05 emp-num-out pic 99999.
  31.            05 cus-name-out pic x(20).
  32.            05 DOP-out pic x(8).
  33.            05 amt-due-out pic 9999v99.
  34.          
  35.        working-storage section.
  36.        01 eof pic xxx value 'NO'.
  37.        
  38.        procedure division.
  39.        100-main.
  40.          OPEN INPUT PayRoll-Master
  41.          OUTPUT ind-file
  42.  
  43.          Perform until eof = 'YES'
  44.              read PayRoll-Master
  45.              at end
  46.                 move 'YES' to eof
  47.              not at end
  48.                  perform 200-ReadFile
  49.              end-read
  50.         end-perform
  51.  
  52.           close PayRoll-Master
  53.                 ind-file
  54.            goback.
  55.  
  56.        200-ReadFile.
  57.        Display numE
  58.        Display cusname
  59.        Display DOP
  60.        Display amt-due
  61.        
  62.        Move numE to emp-num-out
  63.        Move cusname to cus-name-out
  64.        Move DOP to DOP-out
  65.        Move amt-due to amt-due-out
  66.        
  67.        write emp-out
  68.            invalid key Display "Nope"
  69.            not invalid key Display "Yes"
  70.        end-write    
  71.        end program Program1.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement