Chapter 8 Data Validation - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Chapter 8 Data Validation

Description:

123459BAKER ROBERT G930431F0500670000664025X. 987651BROWN PETER G930112M1000353000352000N ... 123459 BAKER INVALID DAY 04/31. 123459 BAKER INSURANCE CODE MUST ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 18
Provided by: Robe464
Category:

less

Transcript and Presenter's Notes

Title: Chapter 8 Data Validation


1
Chapter 8 - Data Validation
2
Figure 8.1 The Relational Condition
IS NOT GREATER THAN IS NOT gt IS NOT
LESS THAN identifier-1 IS NOT
lt 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 gt IS NOT LESS THAN OR
EQUAL TO IS NOT lt
(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
3
Figure 8.2 The Class Test
NUMERIC ALPHABETIC IF identifier
IS NOT ALPHABETIC-UPPER ALPHABETIC-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
DATAEND-IF. IF ALPHABETIC-FIELD IS
ALPHABETIC DISPLAY ALPHABETIC FIELD
CONTAINS UPPER AND/OR LOWER CASE
LETTERSEND-IF. IF ALPHABETIC-FIELD IS
NOTALPHABETIC DISPLAY ERROR - ALPHABETIC
FIELD CONTAINS NON-ALPHABETIC DATAEND-IF.
(b) Examples
4
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
5
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-RECORDEL
SE DISPLAY INCOMING YEAR CODE IS IN
ERROREND-IF.
(b) Examples
6
Figure 8.5 Compound Conditions
(a) A gt B AND C gt D
(b) A gt B OR C gt D
7
Figure 8.6 Nested IF Statements
(a) Flowchart
8
Figure 8.6 Nested IF Statements
IF A gt B IF A gt C MOVE A TO BIG
ELSE MOVE C TO BIG
END-IFELSE IF C gt B MOVE C TO
BIG ELSE MOVE B TO BIG
END-IFEND-IF.
(b) COBOL Statements
9
Figure 8.7 Nested IF Statements/II
IF A gt B IF C gt D ADD 1 TO X
END-IFELSE ADD 1 TO YEND-IF
(a) Flowchart
IF A gt B IF C gt D ADD 1 TO X
ELSE NEXT SENTENCEELSE ADD 1 TO Y.
(b) NEXT SENTENCE(COBOL-74)
(c) Scope Terminators(COBOL-85)
10
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.
11
Figure 8.9 The Stand-Alone Edit Program
12
Figure 8.10 Transaction Files and Error Reports
1 Invalid date
123459BAKER ROBERT G930431F05006700006640
25X987651BROWN PETER
G930112M1000353000352000N999999JONES TOM
J931209E3500450000460005Y987655BROWNING
PAULA J93102400700240000252500Y999777ELSINOR
TERRY R921126F0500168000159005N655443F
ITZPATRICK DAN T930532L070100000098700
0C987654SMITH PAUL G921213M03005100005
00502Y PINNOCK
1931012F10003424OO331000NX93477BUTLER JOHN
H930631C0000423000419075N354679KERBEL
NORMAN X930331E1000340000324300Y2648405CLARK
JANE S921101F0700561500551200N8464
40 SAM 921231XI500182300169
802N233432BEINHORN CATHY
B921122M0200123400113402Y556564HUMMER
MARGO R920815C0800234500123403y677844MCDONAL
D JAMES 930123C0500423500402300N8862
22VOGEL JANICE D930518F1200634500612
302Y008632TOWER DARREN
R930429L0900700200689300N
2 Inconsistent mileage
3 Nonnumeric mileage
4 Invalid car type
(a) Transaction File
13
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 gt 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
14
Figure 8.10 (continued)
999777ELSINOR TERRY R921126F050016800015
9005N987654SMITH PAUL
G921213M0300510000500502Y354679KERBEL
NORMAN X930331E1000340000324300Y2648405CLARK
JANE S921101F0700561500551200N2334
32BEINHORN CATHY B921122M0200123400113
402Y556564HUMMER MARGO
R920815C0800234500123403Y677844MCDONALD
JAMES 930123C0500423500402300N886222VOGEL
JANICE D930518F1200634500612302Y0086
32TOWER DARREN R930429L0900700200689
300N
(c) Valid Transaction File
15
Figure 8.11 Pseudeocode
Open filesGet todays dateWrite error
headingsDO WHILE data remains Move YES to
valid record switch Validate contract
number Validate last name, first name, and
initial Validate car type Validate month, day,
and non-future date Validate days
rented Validate mileage in, mileage out, and
computed miles Validate mileage rate Validate
insurance code IF valid record switch YES
Write valid record ELSE Write blank line in
error report ENDIF Read next recordENDDOClose
filesStop run
16
Figure 8.12 Hierarchy Chart for Validation Program
17
Figure 8.14 Limitations of COBOL-74
IF VALID-RECORD-SW Y IF SEX M ADD 1
TO MALE COUNTER END-IF IF INCOME gt
50000 ADD 1 TO HIGH-INCOME-COUNTER
END-IFEND-IF.
(b) COBOL-85
IF VALID-RECORD-SW Y PERFORM
DO-MORE-TESTS. DO-MORE-TESTS. IF SEX M
ADD 1 TO MALE-COUNTER. IF INCOME gt 50000
ADD 1 TO HIGH-INCOME-COUNTER.
(c) COBOL-74
(a) Flowchart
Write a Comment
User Comments (0)
About PowerShow.com