110 likes | 213 Views
Indexed Files continued. OLD MASTER. TRANSACTION. NEW MASTER. UPDATE PROGRAM. ERROR MESSAGES. Figure 17.1 Sequential Update. Figure 17.2 Sequential Update with Data Files. OLD MASTER FILE:
E N D
OLD MASTER TRANSACTION NEWMASTER UPDATEPROGRAM ERRORMESSAGES Figure 17.1 Sequential Update
Figure 17.2 Sequential Update with Data Files OLD MASTER FILE: 111111111ADAMS 015000 NEW YORK222222222BAKER 025000 NEW YORK333333333ZIDROW 008000 NEW YORK444444444MILGROM 040000 BOSTON555555555BENJAMIN 100000 CHICAGO666666666SHERRY 007500 CHICAGO777777777BOROW 017500 BOSTON888888888JAMES 050000 NEW YORK 999999999RENAZEV 030000 NEW YORK NEW MASTER FILE: 111111111ADAMS 015000 NEW YORK222222222BAKER 025000 NEW YORK333333333ZIDROW 008000 NEW YORK444444444MILGROM 040000 BOSTON 400000000NEW EMPLOYEE 016000 BOSTON 555555555BENJAMIN 100000 CHICAGO 610000000NEW EMPLOYEE II 018000 NEW YORK666666666SHERRY 007500 CHICAGO777777777BOROW 017500 NEW YORK888888888JAMES 050000 NEW YORK999999999RENAZEV 030000 NEW YORK SEQUENTIALUPDATE TRANSACTION FILE: 222222222 028000 C222222222 BOSTON C400000000NEW EMPLOYEE 016000 BOSTON A500000000 020000 C610000000NEW EMPLOYEE II 018000 CHICAGO A610000000 NEW YORK C 666666666SHERRY D777777777 055000 C888888888JAMES 017500 NEW YORK A ERROR MESSAGES: NO MATCH 500000000 DUPLICATE ADDITION 888888888
TRANSACTIONFILE OLD MASTER NEW MASTER VALIDTRANSACTIONS STEP 1: EDIT STEP 2: UPDATE ERRORMESSAGES ERRORMESSAGES Figure 17.4 Sequential Update with Data Validation
MASTERAS OF 1/1 JANUARYTRANSACTIONS MASTERAS OF 2/1 MASTERAS OF 3/1 FEBRUARYTRANSACTIONS Figure 17.3 Two-period Sequential Update UPDATEPROGRAM UPDATEPROGRAM Processing done March 1 Processing done February 1
Open filesDO 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 ENDREADENDDOClose filesStop run Figure 17.7 Pseudocode for Data Validation Program
Figure 18.4 Pseudocode for Creating Indexed File Open filesDO 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 ENDREADENDDOClose filesStop run
Figure 18.8 Hierarchy Chart for Nonsequential Update Program
Figure 18.9 Pseudocode for Nonsequential Update Program Open filesDO 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 READEND DOClose FilesStop 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 484 - 485)