Week 4 iLab Instructions

iLab4 of 7: Data Validation and Error Report

50 points

Scenario/Summary:

This week focuses on TCOs 1 and 4. TCO1, in some ways, fits with every week, since the basics of every programming language have several commonalities– even if their syntax rules do vary. This week focuses on data validation, decision logic (which all languages utilize), and using subprograms (which is also quite similar to how calling a function or procedure is done in other languages). TCO4 is about coding and testing a program that validates the data, using exception handling, and giving meaningful feedback to the user in a report.

Data are not always ready-to-use without doing some pretesting or validation first. We all know that GIGO (garbage in, garbage out) holds true in the world of information systems! To prevent data that do not meet a program's requirements from being used, a validation program will first "test" the data based on the specifications for those particular fields and the types of values that they should contain.

The purpose of this iLab assignment is to validate a transaction file. The transaction file consists of Adds, Changes, and Deletes. The output of this iLab consists of a report, which will list all of the transactions, including asterisks, below each field in which an error was found (exceptions). At the end of the report,thequantity of total valid records and total invalid records will be printed.

As part of this program, another file named Type-Table.dat will be read in to create an input-loaded table. There are several tables used in this program, but they are already coded for you. Even though you do not have to write that code, please be observant of how the tables are coded and processed, because that will help you next week when we study tables and table lookups in depth.

As something else new, this program will use string processing,which was introduced in Week 3 (on pages 237–240 in Chapter 9), as another way to format the report heading line.

Yet primarily, this program will test for data errors/exceptions and create the validation detail report, and it will also write the good records to another separate file. This file will be the “valid transaction file.”The last iLab in this class will take avalid transaction file as input and will use its records to update the Zoo master file.

For this iLab, you will be provided with a program shell. This means that this program compiles and runs, except it doesn’t validate anything yet. Your job will be to add the validation paragraphs. These will be the paragraphs that use decision structures, and condition-names, to validate the input data. Also part of this program is a subprogram (Chapter 16) that is called from the main program to do a "check-digit" Modulus-11 test.

You will see a COPY statement (Chapter 16, pages 479–480) for the first time in this program, too, so that you can learn the ease and effectiveness of this technique!

You will be provided with a transaction file to test your program with, as well as the subprogram, copybook file, and more. Your job will be to add the decision logic to test the dataas described in the provided iLab instructions.The other steps have been coded for you in advance so that you can focus on coding the IF and EVALUATE statements.

Files Needed:

From Doc Sharing, in the Week 4 iLab Files category, download

  • Type-Table.dat (required – the input-loaded table's source-data file);
  • CkDigit.cbl (required– the subprogram that does a check-digit validation);
  • HeadingLine2.cpy (required – the library file for the COPY statement);
  • Trans.dat (required – the transaction data that is being validated);
  • Lab4_Validation.cbl (required – the starter program 'shell' filethat you will update); and
  • Week4_iLab_Instructions.docx (this document).

Download and save each file to the name_CIS355B_Lab4 folder that you will use to do your work for this iLab assignment.

You must follow the instructions in this Week4_iLab_Instructions.docx to complete this iLab assignment.

Deliverables:

Zip file containing the contents of your name_CIS355B_Lab4folder:

  • Type-Table.dat
  • Trans.dat
  • VTrans.dat
  • CkDigit.cbl
  • HeadingLine2.cpy
  • Lab4_Validation.cbl (final COBOL program file - correctly updated)
  • Lab4-ValidationReport.Doc

Note: If you have questions for your professor as you are working on this assignment, please include all of the files contained in your work folder in a zip file and load it in the Dropbox, and then email your professor to let him or her know you have a question and where to locate your zip file to review it.

GradingRubric:

Note:Deductions will be taken for missing files or incomplete/late submissions.

Item / Points
Zipped file (contains the files listed in the "Deliverables" above) submitted to the Dropbox on time. / 5
Paragraph 210-EDIT-TRANS-CODE / 5
Paragraph 220-EDIT-ID-NO / 5
Paragraph 230-EDIT-GROUP / 5
Paragraph 240-EDIT-SPECIES / 5
Paragraph 260-EDIT-SEX / 5
Paragraph 270-EDIT-QOH / 5
Paragraph 280-EDIT-VALUE / 5
Use of condition name(s) in one or more IF statements / 5
Use of condition name(s) in one or more EVALUATE statements / 5
TOTAL POINTS(with deductions for noncompile or not working correctly) / 50

COBOL Class [Shop] Standardsfor Week 4

Note:Most programming departments have "shop standards." These help to ensure consistency across programs and programmers – it is a type of naming convention for the programmer-supplied identifiers.

  1. Use descriptive field (variable) names with prefixes.
  2. T –Transaction record field name
  3. WS – working storage
  4. H1 – heading line-one variables – the group name will be HEADING-LINE1
  5. H2 – heading line-two variables – the group name will be HEADING-LINE2
  6. DL – detail print-line variables – the group name will be DETAIL-LINE
  7. TL1 – firsttotal-line print-record variables – the group name will be TOTAL-LINE1
  8. TL2 – second total-lineprint-record variables – the group name will be TOTAL-LINE2
  9. Use the following record names in the Working-Storage Section:
  10. HEADING-LINE1 – heading-line 1
  11. HEADING-LINE2 – heading-line 2
  12. DETAIL-LINE – detail print record
  13. TOTAL-LINE1 – last print record 1
  14. TOTAL-LINE2 – last print record 2
  15. Paragraph names are already coded in the "starter" program code.
  1. Statements must be in their proper place (Area A and Area B).
  1. Statements must be indented properly for good readability. Note that comments are optional, but encouraged.

File Submission Standard:

Use a folder named with the following naming convention where name is your last name and # is the number of the week for that iLab: name_CIS355B_Lab#.Submit your completed COBOL program (.cbl file), all data files, subprogram and .cpyfiles, and all output files in a zipped file created by zipping (compressing) the folder in which you did your work. Additional files are fine to just leave in that folder that you are zipping, such as the .int file that the compiler creates.

Attach the name_CIS355B_Lab#.zip zipped file to the Dropbox basket for this week's iLab.

Note that you cannot upload a file from Citrix directly into an eCollege Dropbox. The zip file that you wish to submit for grading must physically be on your own computer before you can locate it using the eCollege interface that allows you to browse to a file's location, so that you can select it for attachment to the Dropbox.

Important Success Tip!

Do notattempt to code all of the paragraphs first and then test your program.

Rather, you should code one validation paragraph at a time and test each one as you go along.

You don’t have to code the paragraphs in order. Pick the easy ones first.

Steps

Step 1: Become familiar with the Transaction input data file's structure.

Below is an input record layout for the Trans.dat input data file showing the fields' column locations within the data record and the data type of each one. It is just about the same layout as the zoo.dat file in the Week 2 and Week 3 iLabs, except for its first field, which is added – for the “A,”“C,” or “D” transaction code.A stands for Add, C stands for Change, and Dstands for Delete.

Another new COBOL verb, REDEFINES, is demonstrated by the input record's code. In order to test for invalid numeric data, sometimes we need to redefine that field's storage location with another name and data type so that it can be read in and validated as an alphanumeric when the data value contained in the input recordis not a valid, numeric value.

Input Record Layout:

Field / Column Location / Data Type
Code / 01–01 / Alphanumeric
ID Number / 02–07 / Numeric/Alphanumeric
Species Code / 08–09 / Alphanumeric
Type Code / 10–11 / Alphanumeric
Group Code / 12–13 / Alphanumeric
Sex Code / 14–14 / Alphanumeric
Quantity on Hand / 15–17 / Numeric/Alphanumeric
Species Value / 18–25 / Numeric (two decimal places)/Alphanumeric

01 TRANS-RECORD.

05 T-CODE PIC X.

05 T-ID-NO PIC 9(6).

05 T-ID-NO-X REDEFINES T-ID-NO PIC X(6).

05 T-SPECIES PIC X(2).

05 T-TYPE PIC X(2).

05 T-GROUP PIC X(2).

05 T-SEX PIC X.

05 T-QOH PIC 999.

05 T-QOH-X REDEFINES T-QOH PIC XXX.

05 T-VALUE PIC 9(6)V99.

05 T-VALUE-X REDEFINES T-VALUE PIC X(8).

Report Layout:

The report headings, detail line, and total lines are already defined in the program shell that you are being given, and an example of some pages of the report itself will be provided within this instructions document.

Step 2: Download the files that you need from Doc Sharing: Week 4 iLab files.

If you have not already done so, create a folder using the naming convention of name_CIS355B_Lab4. Download and save the Week 4 iLab files to that folder.

From Doc Sharing, in the Week 4 iLab Files category, download

  • the files listed in the "Files Needed:" section of this document.

Step 3: Open CkDigit.cbl in Net Express and compile it.

You must open CkDigit.cbl and compile this program. Then you can close it. You will not animate it.The calling program will do that later. This is a subprogram.

The most common cause of errors in this iLab assignment is due to missing very simple steps like this one of precompiling that file. CkDigit.cbl is the subprogram that is being called by your main program, so if it is not compiled before you try to compile and run your main program, you will receive an error in your main program.

Once you have compiled CkDigit.cbl, you can close that file, but leave Net Express open.

Step 4: Load the provided Lab4_Validation.cblprogram file into Net Express.

Step 5: Code the 88-Level Condition names and the IF and EVALUATE statements.

Read the following sections. Think through the logic required to test and validate the data types and fields per the logic described in the table below.

Suggestion: You may want to also save incremental copies of this program as you edit it one paragraph at a time; such as, Lab4_Validation210.cblafter you have filled in the 210-EDIT-TRANS-CODE paragraph, for example, and as Lab4_Validation270.cblafter you have filled in the 270-EDIT-QOH paragraph.

Please do not attempt to write all of these paragraphs before testing your program. Since it already compiles "as written," it is fine to complete a paragraph, then compile, and then another, and so forth. The report will not be accurate and will not look quite like the solution until you are finished with all of the paragraphs, but these intermediate tests let you know if you have a logic or syntax error right away, making it easier to correct.

If you have your .cbl files, .cpyfile, your .dat file, and your .DOC files all in the same folder as each other, no path is needed when you assign them in the FILE-CONTROL paragraph or in the COPY statement.

You can also include your last name as a prefix on the filename for the output file such as '’Smith_Lab4-ValidationReport.Doc,” though that is not required. If you want to do that, edit the appropriate line of code in the COBOL program where this file is assigned. Even though this is not required, it does make the grading process a bit easier for your instructor.

Rather than typing or even copy/pasting any of this code, the "starter" file has already been provided to you in Doc Sharing. You will open it with Net Express and then start editing it.

However, for your convenience, or in case you need to reference this program because you accidentally changed some code and want to retype it, there is a listing of that starter file's code at the end of this document.

Required Validations

FIELD / VALIDATIONS
T-CODE / Code must be A, C, or D.
T-ID / Must be numeric
If numeric, the number must be valid using Modulus 11 to check for transposition errors.
[Call a subprogram named CkDigitand pass by content T-ID-NO and pass by reference CHECK-DIGIT-FLAG].
NOTE:Most of the validation logic has been coded for you in 220-EDIT-ID-NO, but the CALL 'CKDIGIT' USING… statement must still be coded where shown in this paragraph's comments.
T-SPECIES / Must be one of the valid species listed in the table on the following two pages.
If Species passes the above validation, then do a correspondence check with Group.
T-TYPE / Must be one of the valid types in the input-loaded type table.
If type passes the above validations, then do a correspondence check with species. [Note:Typetable.dat includes the corresponding species.]
Note: This logic has already been coded for you since it uses information that you have not studied yet: input-loaded tables, PERFORM VARYING with subscripts, and SEARCH lookups. You may want to study this code though, for future reference.
T-GROUP / Must be one of the valid Groups
T-SEX / Must be either M or F
T-QOH / Must be numeric
If numeric, it must not be greater than 50.
T-VALUE / Must be numeric
If numeric and group is BIRD, maximum is $80,000.
If numeric and group is FISH, maximum is $210,000.
If numeric and group is MAMMAL, maximum is $950,000.
If numeric and group is REPTILE, maximum is $25,000.

The table below and on the following page is a way to keep track of available (a) Groups, (b) Species of animals within each Group, and (c) Types of animals within each Species.

GROUP / SPECIES / TYPE
10 = MAMMAL / BE = BEAR
------
BO = BOVIDAE
------
CE = CERVIDAE
------
EL = ELEPHANT
------
FE = FELIDAE
------
GI = GIRAFFIDAE
------
HY = HYLOBATIDAE
------
MA = MACROPODIDAE
------
MU = MUSTELIDAE
------
OR = ORYCTEROPIDAE
------
PO = PONGIDAE
------
SC = SCIURIDAE
------
TI = TIGER
------
WH = WHALE / BB = BLACK BEAR
GR = GRIZZLY
------
BI = BISON
ZE = ZEBRA
------
AD = AXIS DEER
MO = MOOSE
------
AF = AFRICAN
AS = ASIAN
------
CH = CHEETAH
PU = PUMA
LI = LION
------
GI = GIRAFFE
------
GB = GIBBON
------
KA = KANGAROO
WA = WALLABY
------
FE = FERRET
OT = OTTER
WO = WOLVERINE
------
AA = AARDVARK
------
OR = ORANGUTAN
------
PD = PRAIRIE DOG
------
BE = BENGAL
WI = WHITE
------
HB = HUMPBACK
KI = KILLER
20 = BIRD / AC = ACCIPITRIDAE
------
AR = ARDEIDAE
------
DR = DROMAIDAE
------
PA = PARROT
------
PE = PHASIANIDAE
------
PH = PHOENICOPTERIDAE
------
PL = PELECANIDAE
------
SA = SAGITTARIIDAE
------
SP = SPHENISCIDAE / BA = BALD EAGLE
------
WE = WHITE EGRET
------
EM = EMU
------
CO = COCKATOO
MA = MACAW
------
PE = PEACOCK
------
FL = FLAMINGO
------
PL = PELICAN
------
SB = SECRETARY
------
PN = PENGUIN
30 = FISH / AG = ANGUILLIDAE
------
AN = ANABLEPIDAE
------
CH = CHARACIDAE
------
GY = GYMNOTIDAE
------
HI = HIPPOGLOSSIDAE
------
NA = NAUTILIDAE
------
OC = OCULINIDAE
------
RA = RAY
------
SH = SHARK
------
SY = SYNGATHIDAE / FI = 4-EYED FISH
------
GE = GARDEN EEL
------
PI = PIRANHA
------
EL= EEL
------
FO = FLOUNDER
------
NA = NAUTILUS
------
CR = CORAL
------
MN = MANTA
------
GW = GREAT WHITE
MK = MAKO
------
SH = SEA HORSE
40 = REPTILE / AL = ALLIGATORIDAE
------
LI = LIZARD
------
SN = SNAKE
------
TE = TESTUDINIDAE
------
TU = TURTLE / AL = ALLIGATOR
------
CI = CHINESE
ME = MEXICAN
------
AB = AMAZON BOA
PY = PYTHON
RA = RATTLE
------
TO = TORTOISE
------
RF = REDFOOT
ST = STAR

In general, whenever you find an error, you need to move “Y” to an error flag called ERRORS and the proper error message's T-ERROR-CODE, which are each defined in the Working-Storage Section. You will also move asterisks to the proper field in a print-record line called ASTERISKS. Later, when printing to the validation report, the T-ERROR-CODE##fields that contain a “Y” will have their corresponding error message printed.

The error messageshave been coded for you. Note that there are 16 different error messages. In each of your validation paragraphs, you will move a “Y” to the appropriate T-ERROR-CODE so that paragraph 600-MOVE-AND-PRINT will know which error message(s)out of the 16 available to print.

01 ERROR-MESSAGES.

#1 05 01MSG-INVALID-TRANS-CODE PIC X(50)VALUE 'TRANS CODE - INVALID'.

#2 05 02MSG-NON-NUMERID-ID PIC X(50)VALUE 'ID # - NOT NUMERIC'.

#3 05 03MSG-CKDIGIT-ERROR-ID PIC X(50) VALUE

'ID # - WRONG CHECK DIGIT'.

#4 05 04MSG-INVALID-GROUP PIC X(50)VALUE 'GROUP - INVALID'.

#5 05 05MSG-INVALID-SPECIES PIC X(50) VALUE 'SPECIES – INVALID’.

#6 05 06MSG-INVALID-SPECIES2GROUP PIC X(50)VALUE

'SPECIES - DOES NOT CORRESPOND TO PROPER GROUP'.

#7 05 07MSG-INVALID-TYPE PIC X(50)VALUE 'TYPE - INVALID'.

#8 05 08MSG-INVALID-TYPE2SPECIES PIC X(50) VALUE

'TYPE - DOES NOT CORRESPOND TO PROPER SPECIES'.

#9 05 09MSG-INVALID-SEX PIC X(50)VALUE 'SEX - INVALID'.

#10 05 10MSG-NON-NUMERIC-QOH PIC X(50) VALUE 'QOH - NOT NUMERIC'.

#11 05 11MSG-OUTOFRANGE-QOH PIC X(50)VALUE 'QOH - EXCEEDS 50'.

#12 05 12MSG-NON-NUMERIC-VALUE PIC X(50)VALUE 'VALUE - NOT NUMERIC'.

#13 05 13MSG-VALUE-GT-BIRD-MAX PIC X(50) VALUE

'VALUE - EXCEEDS MAX FOR BIRD'.

#14 05 14MSG-VALUE-GT-FISH-MAX PIC X(50) VALUE

'VALUE - EXCEEDS MAX FOR FISH'.

#15 05 15MSG-VALUE-GT-MAMMAL-MAX PIC X(50)VALUE

'VALUE - EXCEEDS MAX FOR MAMMAL'.

#16 05 16MSG-VALUE-GT-REPTILE-MAX PIC X(50)VALUE

‘VALUE – EXCEEDS MAX FOR REPTILE’.

Other requirements:

  1. In at least one of your validation paragraphs, you must use a condition name in an IF statement. [5 points]
  2. In at least one of your validation paragraphs, you must use a condition name in an EVALUATE statement. [5 points]

This means that 88-Level condition names must be coded in your program. And then they must also be used correctly in at least one IF statement and at least one EVALUATE statement that you have coded [not added to the existing code, but used in paragraphs that you coded to validate the data fields].