Indexed Files continued
Figure 17.1 Sequential Update OLD MASTER TRANSACTION NEW MASTER ERROR MESSAGES UPDATE PROGRAM
Figure 17.2 Sequential Update with Data Files ERROR MESSAGES: NO MATCH DUPLICATE ADDITION SEQUENTIAL UPDATE OLD MASTER FILE: ADAMS NEW YORK BAKER NEW YORK ZIDROW NEW YORK MILGROM BOSTON BENJAMIN CHICAGO SHERRY CHICAGO BOROW BOSTON JAMES NEW YORK RENAZEV NEW YORK TRANSACTION FILE: C BOSTON C NEW EMPLOYEE BOSTON A C NEW EMPLOYEE II CHICAGO A NEW YORK C SHERRY D C JAMES NEW YORK A NEW MASTER FILE: ADAMS NEW YORK BAKER NEW YORK ZIDROW NEW YORK MILGROM BOSTON NEW EMPLOYEE BOSTON BENJAMIN CHICAGO NEW EMPLOYEE II NEW YORK SHERRY CHICAGO BOROW NEW YORK JAMES NEW YORK RENAZEV NEW YORK
Figure 17.4 Sequential Update with Data Validation TRANSACTION FILE OLD MASTER STEP 1: EDIT NEW MASTER STEP 2: UPDATE VALID TRANSACTIONS ERROR MESSAGES
Figure 17.3 Two-period Sequential Update MASTER AS OF 1/1 JANUARY TRANSACTIONS MASTER AS OF 2/1 UPDATE PROGRAM MASTER AS OF 3/1 UPDATE PROGRAM FEBRUARY TRANSACTIONS Processing done February 1 Processing done March 1
Figure 17.7 Pseudocode for Data Validation Program Open files DO while data remains READ transaction file AT END Indicate no more data NOT AT END Move ‘YES’ to valid-record-switch IF trans-social-security < previous-social-security Move ‘NO’ to valid-record-switch Write error message ENDIF Move trans-social-security to previous-social-security IF transaction-code is not valid Move ‘NO’ to valid-record-switch Write error message ENDIF IF addition IF transactions fails addition-check(s) Move ‘NO’ to valid-record-switch Write error message(s) ENDIF ELSE IF correction IF sales-amount not numeric Move ‘NO’ to valid-record-switch Write error message ENDIF ENDIF ENDIF IF valid-record-switch = ‘YES’ Write valid-transaction-record ENDIF ENDREAD ENDDO Close files Stop run
Figure 18.4 Pseudocode for Creating Indexed File Open files DO WHILE data remains READ record from sequential file AT END Indicate no more data NOT AT END Move sequential record to indexed record Write indexed record IF sequence error Display error - record out of sequence ENDIF IF duplicate record Display error - record already exists ENDIF ENDREAD ENDDO Close files Stop run
Figure 18.8 Hierarchy Chart for Nonsequential Update Program
Figure 18.9 Pseudocode for Nonsequential Update Program Open files DO WHILE data remains READ transaction file AT END Indicate no more data NOT AT END Move transaction social security number to record key READ INDEXEC-FILE INVALID KEY Move ‘NO’ TO record-key-allocated-switch NOT INVALID KEY Move ‘YES’ TO record-key-allocated-switch END-READ EVALUATE WHEN addition IF record-key-allocated-switch = ‘YES’ Write ‘error - duplicate addition’ ELSE (transaction is not in indexed file) Move transaction-record to new-master-record Write indexed-record ENDIF WHEN correction IF record-key-allocated-switch = ‘YES’ Process correction Rewrite indexed record ELSE (transaction is not in indexed file) Write ‘error - no matching record’ ENDIF WHEN deletion IF record-key-allocated-switch = ‘YES’ Delete indexed record ELSE (transaction is not in indexed file) Write ‘error - no matching record’ ENDIF WHEN other Write ‘error - invalid transaction’ END EVALUATE END READ END DO Close Files Stop Run
The START Statement –Start Filename Key Relational Operator – Invalid Key Statement – Not Invalid Key Statement –End-Start
Read Next –Read Filename Next Record – At End Statement –End-Read File Status (Select Filename File Status is WS-STATUS) –Refer to pages )