1 / 20

Chapter 8 - Data Validation

Chapter 8 - Data Validation. Why Validate?. GIGO!. Numeric Alphabetic Reasonableness Consistency Existing Code Sequence. Completeness Date Month Day Range Y2K Subscript. Types Of Validation. Figure 8.1 The Relational Condition.

armen
Download Presentation

Chapter 8 - Data Validation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 8 - Data Validation

  2. Why Validate? GIGO!

  3. Numeric Alphabetic Reasonableness Consistency Existing Code Sequence Completeness Date Month Day Range Y2K Subscript Types Of Validation

  4. Figure 8.1 The Relational Condition IS [NOT] GREATER THAN IS [NOT] > IS [NOT] LESS THAN identifier-1 IS [NOT] < identifier-2IF literal-1 IS [NOT] EQUAL TO literal-2 expression-1 IS [NOT] = expression-2 IS [NOT] GREATER THAN OR EQUAL TO IS [NOT] >= IS [NOT] LESS THAN OR EQUAL TO IS [NOT] <= (a) Syntax 05 NUMERIC-FIELD PIC 9(5).05 ALPHANUMERIC-FIELD PIC X(5).. . .IF NUMERIC-FIELD = 10 . . . (valid entry)IF NUMERIC-FIELD = ‘10’ . . . (invalid entry)IF ALPHANUMERIC-FIELD = 10 (invalid entry)IF ALPHANUMERIC-FIELD = ‘10’ (valid entry) (b) Examples

  5. Compound Conditionals • AND - Both must be TRUE • OR - At least One must be True

  6. AND IF AGE > 21 AND GENDER = ‘M’ THEN Condition-1 Condition-2 Result

  7. OR IF AGE > 21 OR GENDER = ‘M’ THEN Condition-1 Condition-2 Result

  8. NO A>B? A>B? YES NO YES FALSE C>D? C>D? FALSE NO YES NO YES FALSE TRUE FALSE TRUE Figure 8.5 Compound Conditions (a) A > B AND C > D (b) A > B OR C > D

  9. Figure 8.6 Nested IF Statements Find the largest of three numbers A, B, or C IF A > B IF A > C MOVE A TO LARGEST ELSE MOVE C TO LARGEST END-IFELSE IF C > B MOVE C TO LARGEST ELSE MOVE B TO LARGEST END-IFEND-IF. (b) COBOL Statements

  10. A>B? NO YES C>B? A>C? NO YES NO YES MOVE BTO BIG MOVE CTO BIG MOVE CTO BIG MOVE A TO BIG Figure 8.6 Nested IF Statements (a) Flowchart

  11. FALSE TRUE A>B? FALSE TRUE ADD 1TO Y C>D? ADD 1TO X Figure 8.7 Nested IF Statements/II (a) Flowchart IF A > B IF C > D ADD 1 TO X END-IFELSE ADD 1 TO YEND-IF IF A > B IF C > D ADD 1 TO X ELSE NEXT SENTENCE ELSE ADD 1 TO Y. (b) NEXT SENTENCE(COBOL-74) (c) Scope Terminators(COBOL-85)

  12. Figure 8.2 The Class Test NUMERICALPHABETICIF identifier IS [NOT] ALPHABETIC-UPPERALPHABETIC-LOWER (a) Syntax 05 NUMERIC-FIELD PIC 9(5).05 ALPHABETIC-FIELD PIC X(5).. . .IF NUMERIC-FIELD IS NUMERIC PERFORM D0-ARITHMETIC-CALCULATIONSEND-IF. IF NUMERIC-FIELD IS NOT NUMERIC DISPLAY ‘ERROR - NUMERIC FIELD CONTAINS INVALID DATA’END-IF. IF ALPHABETIC-FIELD IS ALPHABETIC DISPLAY ‘ALPHABETIC FIELD CONTAINS UPPER AND/OR LOWER CASE LETTERS’END-IF. IF ALPHABETIC-FIELD IS NOTALPHABETIC DISPLAY ‘ERROR - ALPHABETIC FIELD CONTAINS NON-ALPHABETIC DATA’END-IF. (b) Examples

  13. Figure 8.3 The SignTest identifier POSITIVE IF arithmetic expression IS [NOT] NEGATIVE ZERO (a) Syntax IF NET-PAY IS NOT POSITIVE PERFORM TOO-MUCH-TAXESEND-IF. IF CHECK-BALANCE IS NEGATIVE PERFORM OVERDRAWNEND-IF. (b) Examples

  14. VALUE IS THROUGH 88 data-name VALUES ARE literal-1 THRU literal-2 . . . Figure 8.4 Condition Names (88-level entries) (a) Syntax 05 YEAR-CODE PIC 9. 88 FRESHMAN VALUE 1. 88 SOPHOMORE VALUE 2. 88 JUNIOR VALUE 3. 88 SENIOR VALUE 4. 88 GRAD-STUDENT VALUES ARE 5 THRU 8. 88 UNDER-CLASSMAN VALUES ARE 1, 2 88 UPPER-CLASSMAN VALUES ARE 3, 4.| 88 VALID-CODES VALUES ARE 1 THRU 8. IF FRESHMAN PERFORM WELCOME-NEW-STUDENTSEND-IF IF VALID-CODES PERFORM PROCESS-STUDENT-RECORDELSE DISPLAY ‘INCOMING YEAR CODE IS IN ERROR’END-IF. (b) Examples

  15. Figure 8.8 The ACCEPT Statement WORKING-STORAGE SECTION. 01 EMPLOYEE-RECORD. . . 05 EMP-DATE-OF-BIRTH. 10 EMP-BIRTH-MONTH PIC 99. 10 EMP-BIRTH-YEAR PIC 99. 01 EMPLOYEE-AGE PIC 99V99. 01 DATE-WORK-AREA. 05 TODAYS-YEAR PIC 99. 05 TODAYS-MONTH PIC 99. 05 TODAYS-DAY PIC 99. . .PROCEDURE DIVISION.. . ACCEPT DATE-WORK-AREA FROM DATE.. . COMPUTE EMPLOYEE-AGE = TODAYS-YEAR - EMP-BIRTH-YEAR + (TODAYS-MONTH - EMP-BIRTH-MONTH) / 12.

  16. TRANSACTIONFILE VALIDTRANSACTIONFILE STEP 1EDIT PROGRAM STEP 2REPORTPROGRAM FINAL REPORT ERRORMESSAGES Figure 8.9 The Stand-Alone Edit Program

  17. Figure 8.10 Transaction Files and Error Reports 1 Invalid date 123459BAKER ROBERT G930431F0500670000664025X987651BROWN PETER G930112M1000353000352000N999999JONES TOM J931209E3500450000460005Y987655BROWNING PAULA J93102400700240000252500Y999777ELSINOR TERRY R921126F0500168000159005N655443FITZPATRICK DAN T930532L0701000000987000C987654SMITH PAUL G921213M0300510000500502Y PINNOCK 1931012F10003424OO331000NX93477BUTLER JOHN H930631C0000423000419075N354679KERBEL NORMAN X930331E1000340000324300Y2648405CLARK JANE S921101F0700561500551200N846440 SAM 921231XI500182300169802N233432BEINHORN CATHY B921122M0200123400113402Y556564HUMMER MARGO R920815C0800234500123403y677844MCDONALD JAMES 930123C0500423500402300N886222VOGEL JANICE D930518F1200634500612302Y008632TOWER DARREN R930429L0900700200689300N 2 Inconsistent mileage 3 Nonnumeric mileage 4 Invalid car type (a) Transaction File

  18. Figure 8.10 (continued) ERROR REPORT AS OF 07/03/98 CONTRACT # LAST NAME ERROR MESSAGE & FIELD CONTENTS 123459 BAKER INVALID DAY 04/31 123459 BAKER INSURANCE CODE MUST BE Y OR N X 987651 BROWN MILES DRIVEN UNREASONABLY LOW DAYS: 10 MILES: 000010 999999 JONES MONTH MUST BE BETWEEN 1 AND 12 13 999999 JONES MILEAGE IN LESS THAN MILEAGE OUT IN: 004500 OUT: 004600 999999 JONES NON-NUMERIC MILEAGE RATE O5 987655 BROWNING CAR TYPE MUST BE: E, C, M, F, OR L 0 987655 BROWNING DATE HAS NOT YET OCCURRED 10/24/98 987655 BROWNING NON-NUMERIC MILES IN OO2400 655443 FITZPATRICK INVALID DAY 05/32 655443 FITZPATRICK INSURANCE CODE MUST BE Y OR N C PINNOCK NON-NUMERIC CONTRACT NUMBER PINNOCK MISSING FIRST NAME PINNOCK NON ALPHABETIC INITIAL 1 PINNOCK DATE YAS NOT YET OCCURRED 10/12/98 PINNOCK NON-NUMERIC MILES OUT OO3310 X93477 BUTLER NON-NUMERIC CONTRACT NUMBER X93477 X93477 BUTLER INVALID DAY 06/31 X93477 BUTLER DAYS RENTED MUST BE > ZERO 00 X93477 BUTLER MILEAGE RATE OUT OF RANGE 75 84644O NON-NUMERIC CONTRACT NUMBER 84644O 84644O MISSING LAST NAME 84644O CAR TYPE MUST BE: E, C, M, F, OR L X 84644O DAYS RENTED MUST BE NUMERIC I5 84644O MILES DRIVEN UNREASONABLY LOW DAYS: I5 MILES: 000125 (b) Error Report

  19. Figure 8.10 (continued) 999777ELSINOR TERRY R921126F0500168000159005N987654SMITH PAUL G921213M0300510000500502Y354679KERBEL NORMAN X930331E1000340000324300Y2648405CLARK JANE S921101F0700561500551200N233432BEINHORN CATHY B921122M0200123400113402Y556564HUMMER MARGO R920815C0800234500123403Y677844MCDONALD JAMES 930123C0500423500402300N886222VOGEL JANICE D930518F1200634500612302Y008632TOWER DARREN R930429L0900700200689300N (c) Valid Transaction File

  20. CREATEVALID FILE GETTODAYS DATE WRITEERRORHEADINGS READRENTALRECORD PROCESSRENTALRECORDS VALIDATERENTALRECORD WRITEVALIDRECORD READRENTALRECORD VALIDATECONTRACTNUMBER VALIDATENAME VALIDATECARTYPE VALIDATEDATERETURNED VALIDATEDAYSRENTED VALIDATEMILESDRIVEN VALIDATEMILEAGERATE VALIDATEINSURANCE WRITEERROR LINE WRITEERROR LINE WRITEERROR LINE WRITEERROR LINE WRITEERROR LINE WRITEERROR LINE WRITEERROR LINE WRITEERROR LINE Figure 8.12 Hierarchy Chart for Validation Program

More Related