week4 ilab instructions web view · 2013-08-042013-08-04 ·...

35
Week 4 iLab Instructions iLab 4 of 7: Data Validation and Error Report 50 points Scenario/Summary: This week focuses on TCOs 1 and 4. TCO 1, 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). TCO 4 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, the quantity 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 document.docx CIS355B Page 1

Upload: phungliem

Post on 06-Mar-2018

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions

iLab 4 of 7: Data Validation and Error Report

50 points

Scenario/Summary:

This week focuses on TCOs 1 and 4. TCO 1, 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). TCO 4 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, the quantity 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 a valid 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 data as 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.

document.docx CIS355B Page 1

Page 2: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions

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' file that 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_Lab4 folder:

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.

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

Item PointsZipped file (contains the files listed in the "Deliverables" above) submitted to the Dropbox on time.

5

Paragraph 210-EDIT-TRANS-CODE 5Paragraph 220-EDIT-ID-NO 5Paragraph 230-EDIT-GROUP 5Paragraph 240-EDIT-SPECIES 5Paragraph 260-EDIT-SEX 5Paragraph 270-EDIT-QOH 5Paragraph 280-EDIT-VALUE 5Use of condition name(s) in one or more IF statements 5Use of condition name(s) in one or more EVALUATE statements 5TOTAL POINTS (with deductions for noncompile or not working correctly) 50

document.docx CIS355B Page 2

Page 3: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions

COBOL Class [Shop] Standards for 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. T – Transaction record field name WS – working storage H1 – heading line-one variables – the group name will be HEADING-LINE1 H2 – heading line-two variables – the group name will be HEADING-LINE2 DL – detail print-line variables – the group name will be DETAIL-LINE TL1 – first total-line print-record variables – the group name will be TOTAL-LINE1 TL2 – second total-line print-record variables – the group name will be TOTAL-LINE2

2. Use the following record names in the Working-Storage Section: HEADING-LINE1 – heading-line 1 HEADING-LINE2 – heading-line 2 DETAIL-LINE – detail print record TOTAL-LINE1 – last print record 1 TOTAL-LINE2 – last print record 2

3. Paragraph names are already coded in the "starter" program code.

4. Statements must be in their proper place (Area A and Area B).

5. 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 .cpy files, 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 not attempt 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.

document.docx CIS355B Page 3

Page 4: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions

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 D stands 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 record is not a valid, numeric value.

Input Record Layout:

Field Column Location Data TypeCode 01–01 AlphanumericID Number 02–07 Numeric/AlphanumericSpecies Code 08–09 AlphanumericType Code 10–11 AlphanumericGroup Code 12–13 AlphanumericSex Code 14–14 AlphanumericQuantity on Hand 15–17 Numeric/AlphanumericSpecies 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.

document.docx CIS355B Page 4

Page 5: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions

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.cbl program 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.cbl after you have filled in the 210-EDIT-TRANS-CODE paragraph, for example, and as Lab4_Validation270.cbl after 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, .cpy file, 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.

document.docx CIS355B Page 5

Page 6: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions

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 CkDigit and 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.

document.docx CIS355B Page 6

Page 7: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions

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 TYPE10 = 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 BEARGR = GRIZZLY-------------------------------------------------BI = BISONZE = ZEBRA--------------------------------------------------AD = AXIS DEERMO = MOOSE--------------------------------------------------AF = AFRICANAS = ASIAN--------------------------------------------------CH = CHEETAHPU = PUMALI = LION--------------------------------------------------GI = GIRAFFE--------------------------------------------------GB = GIBBON--------------------------------------------------KA = KANGAROOWA = WALLABY--------------------------------------------------FE = FERRETOT = OTTERWO = WOLVERINE--------------------------------------------------AA = AARDVARK--------------------------------------------------OR = ORANGUTAN--------------------------------------------------PD = PRAIRIE DOG--------------------------------------------------BE = BENGALWI = WHITE--------------------------------------------------HB = HUMPBACKKI = KILLER

document.docx CIS355B Page 7

Page 8: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions

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 = COCKATOOMA = 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 WHITEMK = MAKO--------------------------------------------------SH = SEA HORSE

40 = REPTILE AL = ALLIGATORIDAE---------------------------------------------------------------LI = LIZARD

---------------------------------------------------------------SN = SNAKE

---------------------------------------------------------------TE = TESTUDINIDAE---------------------------------------------------------------TU = TURTLE

AL = ALLIGATOR--------------------------------------------------CI = CHINESEME = MEXICAN--------------------------------------------------AB = AMAZON BOAPY = PYTHONRA = RATTLE--------------------------------------------------TO = TORTOISE--------------------------------------------------RF = REDFOOTST = STAR

document.docx CIS355B Page 8

Page 9: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab InstructionsIn 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 messages have 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].

This means that as you fill in the missing paragraphs in the PROCEDURE DIVISION, there must be at least one of each of these types of statements coded as well: an IF statement and an EVALUATE statement.

There will be more than one of at least one of these statement types in order to accomplish the necessary logic, but be sure to have at least one of the other statements as well (with a condition-name used in it) so you don’t miss 5 points for one of the last two graded items shown in the grading rubric.

Not required, but there are two places in the code with comments offering a challenge to change an existing 05 level condition to an existing 88 level condition name. Try it, if you like, after everything else is completed.

document.docx CIS355B Page 9

Page 10: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions

TRANS.DAT – This is the transaction file that is to be validated.

D115002SNGW30XXXXXXXXXXXXXXXXXXXXXXXX

A227005PACO20M01004500000C111007WHHB10 00312400000D118001WHHB10ACDA447005SNRT40M00102500000C117005TIBE10 05110000001A123455ELAF10F00110000000C111007WHHB10SC111007WHHB10C111007WHHB10C111007WHHB10C 20 008000001C 30 021000001C 10 095000001C123455ELAF10F00195000000C115002 BED115002BEBB10D115002THTITOC123456D246890A543212AAAAAAACCCCCCCDDDDDDDA120006BEBB10F00302330503A114006BEBB10M00002330502A119008BEGR10F00390000002A121002BEGR10M00491010003A131008FECH10M00105000000A132004FELI10F00206000000A133001FEPU10F00104500000A117005TIBE10M00240209002A122009TIBE10F01020508008A112003TIWI10F00566008508A113000TIWI10M00756008505A111007WHHB10F00112509001A118001WHHB10M00017509001A116009WHKI10M00142005001A115002WHKI10F00245005002A222003PACO20F04503050430A221007PAMA20M00506600005A225002PAMA20F01207509915A331007RAMN20F00404004002A339008RAMA30M00204500504A332003SHGW30F00120120004A334006SHGW30M00413000004A333010SHMK30M00609500508

document.docx CIS355B Page 10

Page 11: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab InstructionsA340006SHMK30F00208990002

document.docx CIS355B Page 11

Page 12: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions

VTRANS.DAT – This is the valid transaction file that will be created when the Lab is finished (these records might be in a different sequence than yours . . . that's fine as long as your VTRANS.DAT file contains the same records that this list does, and no others).

A111007WHHB10F00112509001C111007WHHB10C111007WHHB10C111007WHHB10 00312400000C111007WHHB10A112003TIWI10F00566008508A113000TIWI10M00756008505A114006BEBB10M00002330502A115002WHKI10F00245005002D115002BEBB10A116009WHKI10M00142005001A117005TIBE10M00240209002A118001WHHB10M00017509001D118001WHHB10A119008BEGR10F00390000002A120006BEBB10F00302330503A121002BEGR10M00491010003A122009TIBE10F01020508008A123455ELAF10F00110000000C123455ELAF10F00195000000A131008FECH10M00105000000A132004FELI10F00206000000A133001FEPU10F00104500000A221007PAMA20M00506600005A222003PACO20F04503050430A225002PAMA20F01207509915A227005PACO20M01004500000A332003SHGW30F00120120004A334006SHGW30M00413000004A340006SHMK30F00208990002

document.docx CIS355B Page 12

Page 13: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions

Type-Table.dat – This is the table file used for the Type input-loaded table.AAAARDVARK ORABAMAZON BOA SNADAXIS DEER CEAFAFRICAN ELALALLIGATOR ALASASIAN ELBABALD EAGLE ACBBBLACK BEAR BEBEBENGAL TIBIBISON BOCHCHEETAH FECICHINESE LICOCOCKATOO PACRCORAL OCELEEL GYEMEMU DRFEFERRET MUFI4-EYED FISHANFLFLAMINGO PHFOFLOUNDER HIGBGIBBON HYGEGARDEN EEL AGGIGIRAFFE GIGRGRIZZLY BEGWGREAT WHITESHHBHUMPBACK WHKAKANGAROO MAKIKILLER WHLILION FEMAMACAW PAMEMEXICAN LIMKMAKO SHMNMANTA RAMOMOOSE CENANAUTILUS NAORORANGATAN POOTOTTER MUPDPRAIRIE DOGSCPEPEACOCK PEPIPIRANHA CHPLPELICAN PLPNPENGUIN SPPUPUMA FEPYPHTHON SNRARATTLE SNRFRED FOOT TUSBSECRETARY SASHSEA HORSE SYSTSTAR TUTOTORTOISE TEWAWALLABY MAWEWHITE EGRETARWIWHITE TIWOWOLVERINE MUZEZEBRA BO

document.docx CIS355B Page 13

Page 14: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions

Smith_Lab4-ValidationReport.Doc [example file name]

SEPTEMBER 20, 2010 ZOO TRANSACTIONS PAGE- 1

CODE ID # GROUP SPECIES TYPE SEX QOH VALUE ERROR MESSAGES

D 115002 30 SN GW ** ** **ERRORS** SPECIES - DOES NOT CORRESPOND TO PROPER GROUP TYPE - DOES NOT CORRESPOND TO PROPER SPECIES---------------------------------------------------------------------------------------------------------------------------------- X XXXXXX XX XX XX X XXX XXXXXXX * **ERRORS** TRANS CODE - INVALID----------------------------------------------------------------------------------------------------------------------------------

* **ERRORS** TRANS CODE - INVALID---------------------------------------------------------------------------------------------------------------------------------- A 227005 20 PA CO M 10 45,000.00---------------------------------------------------------------------------------------------------------------------------------- C 111007 10 WH HB 3 124,000.00---------------------------------------------------------------------------------------------------------------------------------- D 118001 10 WH HB---------------------------------------------------------------------------------------------------------------------------------- A ****** ** ** ** * *** ********** **ERRORS** ID # - NOT NUMERIC GROUP - INVALID SPECIES - INVALID TYPE - INVALID SEX - INVALID QOH - NOT NUMERIC VALUE - NOT NUMERIC---------------------------------------------------------------------------------------------------------------------------------- C ****** ** ** ** **ERRORS** ID # - NOT NUMERIC GROUP - INVALID SPECIES - INVALID TYPE - INVALID---------------------------------------------------------------------------------------------------------------------------------- D ****** ** ** ** **ERRORS** ID # - NOT NUMERIC GROUP - INVALID SPECIES - INVALID TYPE - INVALID

document.docx CIS355B Page 14

When you finish your Week 4 iLab, your output should look like the following pages (you may have to zoom to a larger percentage in Word to better see the details).

When you open the Word document created by your COBOL program, you may have to(a) change your Word document to Landscape Orientation;(b) use CTRL+A to Select All, and then reduce the font size to 9 or smaller; and/or (c) choose Narrow for the page-layout margins.

Otherwise, the print lines may "wrap" – making your report look quite different than the report shown below.

Page 15: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions SEPTEMBER 20, 2010 ZOO TRANSACTIONS PAGE- 2

CODE ID # GROUP SPECIES TYPE SEX QOH VALUE ERROR MESSAGES

----------------------------------------------------------------------------------------------------------------------------------

A 447005 40 SN RT M 1 25,000.00 ** **ERRORS** TYPE - INVALID---------------------------------------------------------------------------------------------------------------------------------- C 117005 10 TI BE 51 100,000.01 *** **ERRORS** QOH - EXCEEDS 50---------------------------------------------------------------------------------------------------------------------------------- A 123455 10 EL AF F 1 100,000.00---------------------------------------------------------------------------------------------------------------------------------- C 111007 10 WH HB S * **ERRORS** SEX - INVALID---------------------------------------------------------------------------------------------------------------------------------- C 111007 10 WH HB---------------------------------------------------------------------------------------------------------------------------------- C 111007 10 WH HB---------------------------------------------------------------------------------------------------------------------------------- C 111007 10 WH HB---------------------------------------------------------------------------------------------------------------------------------- C 20 0 80,000.01 ****** ** ** *** ********** **ERRORS** ID # - NOT NUMERIC SPECIES - INVALID TYPE - INVALID QOH - NOT NUMERIC VALUE - EXCEEDS MAX FOR BIRD---------------------------------------------------------------------------------------------------------------------------------- C 30 0 210,000.01 ****** ** ** *** ********** **ERRORS** ID # - NOT NUMERIC SPECIES - INVALID TYPE - INVALID QOH - NOT NUMERIC VALUE - EXCEEDS MAX FOR FISH---------------------------------------------------------------------------------------------------------------------------------- C 10 0 950,000.01 ****** ** ** *** ********** **ERRORS** ID # - NOT NUMERIC SPECIES - INVALID TYPE - INVALID

document.docx CIS355B Page 15

Page 16: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions SEPTEMBER 20, 2010 ZOO TRANSACTIONS PAGE- 3

CODE ID # GROUP SPECIES TYPE SEX QOH VALUE ERROR MESSAGES

QOH - NOT NUMERIC

VALUE - EXCEEDS MAX FOR MAMMAL

----------------------------------------------------------------------------------------------------------------------------------

C 123455 10 EL AF F 1 950,000.00---------------------------------------------------------------------------------------------------------------------------------- C 115002 BE ** ** ** **ERRORS** GROUP - INVALID SPECIES - INVALID TYPE - INVALID---------------------------------------------------------------------------------------------------------------------------------- D 115002 10 BE BB---------------------------------------------------------------------------------------------------------------------------------- D 115002 TO TH TI ** ** ** **ERRORS** GROUP - INVALID SPECIES - INVALID TYPE - INVALID---------------------------------------------------------------------------------------------------------------------------------- C 123456 ****** ** ** ** **ERRORS** ID # - WRONG CHECK DIGIT GROUP - INVALID SPECIES - INVALID TYPE - INVALID---------------------------------------------------------------------------------------------------------------------------------- D 246890 ****** ** ** ** **ERRORS** ID # - WRONG CHECK DIGIT GROUP - INVALID SPECIES - INVALID TYPE - INVALID---------------------------------------------------------------------------------------------------------------------------------- A 543212 ****** ** ** ** * *** ********** **ERRORS** ID # - WRONG CHECK DIGIT GROUP - INVALID SPECIES - INVALID TYPE - INVALID SEX - INVALID QOH - NOT NUMERIC VALUE - NOT NUMERIC

document.docx CIS355B Page 16

Page 17: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions SEPTEMBER 20, 2010 ZOO TRANSACTIONS PAGE- 4

CODE ID # GROUP SPECIES TYPE SEX QOH VALUE ERROR MESSAGES

----------------------------------------------------------------------------------------------------------------------------------

A AAAAAA ****** ** ** ** * *** ********** **ERRORS** ID # - NOT NUMERIC GROUP - INVALID SPECIES - INVALID TYPE - INVALID SEX - INVALID QOH - NOT NUMERIC VALUE - NOT NUMERIC---------------------------------------------------------------------------------------------------------------------------------- C CCCCCC ****** ** ** ** **ERRORS** ID # - NOT NUMERIC GROUP - INVALID SPECIES - INVALID TYPE - INVALID---------------------------------------------------------------------------------------------------------------------------------- D DDDDDD ****** ** ** ** **ERRORS** ID # - NOT NUMERIC GROUP - INVALID SPECIES - INVALID TYPE - INVALID---------------------------------------------------------------------------------------------------------------------------------- A 120006 10 BE BB F 3 23,305.03---------------------------------------------------------------------------------------------------------------------------------- A 114006 10 BE BB M 0 23,305.02---------------------------------------------------------------------------------------------------------------------------------- A 119008 10 BE GR F 3 900,000.02---------------------------------------------------------------------------------------------------------------------------------- A 121002 10 BE GR M 4 910,100.03---------------------------------------------------------------------------------------------------------------------------------- A 131008 10 FE CH M 1 50,000.00---------------------------------------------------------------------------------------------------------------------------------- A 132004 10 FE LI F 2 60,000.00---------------------------------------------------------------------------------------------------------------------------------- A 133001 10 FE PU F 1 45,000.00---------------------------------------------------------------------------------------------------------------------------------- A 117005 10 TI BE M 2 402,090.02---------------------------------------------------------------------------------------------------------------------------------- A 122009 10 TI BE F 10 205,080.08----------------------------------------------------------------------------------------------------------------------------------

document.docx CIS355B Page 17

Page 18: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions SEPTEMBER 20, 2010 ZOO TRANSACTIONS PAGE- 5

CODE ID # GROUP SPECIES TYPE SEX QOH VALUE ERROR MESSAGES

A 112003 10 TI WI F 5 660,085.08---------------------------------------------------------------------------------------------------------------------------------- A 113000 10 TI WI M 7 560,085.05---------------------------------------------------------------------------------------------------------------------------------- A 111007 10 WH HB F 1 125,090.01---------------------------------------------------------------------------------------------------------------------------------- A 118001 10 WH HB M 0 175,090.01---------------------------------------------------------------------------------------------------------------------------------- A 116009 10 WH KI M 1 420,050.01---------------------------------------------------------------------------------------------------------------------------------- A 115002 10 WH KI F 2 450,050.02---------------------------------------------------------------------------------------------------------------------------------- A 222003 20 PA CO F 45 30,504.30---------------------------------------------------------------------------------------------------------------------------------- A 221007 20 PA MA M 5 66,000.05---------------------------------------------------------------------------------------------------------------------------------- A 225002 20 PA MA F 12 75,099.15---------------------------------------------------------------------------------------------------------------------------------- A 331007 20 RA MN F 4 40,040.02 ** **ERRORS** SPECIES - DOES NOT CORRESPOND TO PROPER GROUP---------------------------------------------------------------------------------------------------------------------------------- A 339008 30 RA MA M 2 45,005.04 ** **ERRORS** TYPE - DOES NOT CORRESPOND TO PROPER SPECIES---------------------------------------------------------------------------------------------------------------------------------- A 332003 30 SH GW F 1 201,200.04---------------------------------------------------------------------------------------------------------------------------------- A 334006 30 SH GW M 4 130,000.04---------------------------------------------------------------------------------------------------------------------------------- A 333010 30 SH MK M 6 95,005.08 ****** **ERRORS** ID # - WRONG CHECK DIGIT---------------------------------------------------------------------------------------------------------------------------------- A 340006 30 SH MK F 2 89,900.02----------------------------------------------------------------------------------------------------------------------------------

TOTAL VALID RECORDS = 30TOTAL INVALID RECORDS = 23

Step 6: After compiling and running the program successfully, it's time to test your final results!

First, save the file as Lab3B . . . so you can experiment freely without affecting your finished work in the completed Lab3_ZooInventory.cbl program file.

1. Compare your output to the report pages shown above.2. If something does not appear that should, or appears too many times, double-check the logic in that

paragraph. You can also try commenting out the statements in a certain paragraph and then retest your output.

3. Try these steps as many times as necessary to isolate the issue, and you can also ask questions during the week, and watch the iConnect Recording for tips.

4. After you have reviewed the grading rubric, and double-checked your program, you are ready to submit your assignment.

Step 7: Prepare Files for Dropbox

Close any program files that you might still have open and close Net Express.

Then, open the Citrix application for Windows Explorer (i.e., not from your local computer's operating system) and browse to the folder in which you did your work.

Right-click on the folder name and select "Send To" from the context menu and then select "Compressed (zipped) Folder."

Save it with the same name as your Lab folder plus the .zip file extension, noting where you saved this zipped file.

document.docx CIS355B Page 18

Page 19: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions

In closing . . .

Partial credit is possible. Remember that some points are always preferable to zero points! Learning comes with doing, so please try each iLab assignment and do your best!

Watch the iConnect Live Recording!

Check the Late Policy in the Syllabus if you are planning to be late with any assignment.

For your convenience, this is a listing of your program shell. Read the comment lines and all of the callouts before you start editing the code.

IDENTIFICATION DIVISION. PROGRAM-ID. LAB4. *AUTHOR. ___________________

ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT TRANS-FILE ASSIGN TO DISK 'Trans.dat' ORGANIZATION IS LINE SEQUENTIAL. SELECT PRINT-FILE ASSIGN TO PRINTER 'LAB4-ValidationReport.Doc'. SELECT VALID-TRANS-FILE ASSIGN TO DISK 'VTrans.dat' ORGANIZATION IS LINE SEQUENTIAL. SELECT TABLE-FILE ASSIGN TO DISK 'Type-Table.dat' ORGANIZATION IS LINE SEQUENTIAL.

DATA DIVISION. FILE SECTION. FD TRANS-FILE. 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).

FD PRINT-FILE. 01 PRINT-RECORD PIC X(130).

FD VALID-TRANS-FILE. 01 VALID-TRANS-RECORD PIC X(34).

FD TABLE-FILE. 01 TABLE-RECORD PIC X(15).

WORKING-STORAGE SECTION. 01 HEADING-LINE1. 05 FILLER PIC X(8). 05 H1-DATE PIC X(31). 05 FILLER PIC X(80) VALUE 'ZOO TRANSACTIONS'. 05 FILLER PIC X(5) VALUE 'PAGE-'.

document.docx CIS355B Page 19

88-Level condition names will be defined here as needed, below the 05 levels, for the fields that are going to be validated using condition-names in the IF or EVALUATE selection/decision structure logic in the PROCEDURE DIVISION.

Page 20: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions 05 H1-PAGE PIC Z9.

* Below is the COPY statement in the format of COPY 'filename.cpy' 01 HEADING-LINE2. COPY 'HeadingLine2.cpy'.

01 DETAIL-LINE. 05 FILLER PIC X. 05 DL-CODE PIC X. 05 FILLER PIC X(5). 05 DL-ID PIC 9(6). 05 DL-ID-X REDEFINES DL-ID PIC X(6). 05 FILLER PIC X(5). 05 DL-GROUP PIC X(2). 05 FILLER PIC X(8). 05 DL-SPECIES PIC X(2). 05 FILLER PIC X(10). 05 DL-TYPE PIC X(2). 05 FILLER PIC X(7). 05 DL-SEX PIC X. 05 FILLER PIC X(7). 05 DL-QOH PIC ZZ9. 05 DL-QOH-X REDEFINES DL-QOH PIC XXX. 05 FILLER PIC X(5). 05 DL-VALUE PIC ZZZ,ZZ9.99. 05 DL-VALUE-X REDEFINES DL-VALUE PIC X(10).

01 ASTERISKS. 05 FILLER PIC X. 05 E1-CODE PIC X. 05 FILLER PIC X(5). 05 E2-ID-NO PIC X(6). 05 FILLER PIC X(5). 05 E3-GROUP PIC X(2). 05 FILLER PIC X(8). 05 E4-SPECIES PIC X(2). 05 FILLER PIC X(10). 05 E5-TYPE PIC X(2). 05 FILLER PIC X(7). 05 E6-SEX PIC X. 05 FILLER PIC X(7). 05 E7-QOH PIC XXX. 05 FILLER PIC X(5). 05 E9-VALUE PIC X(10). 05 FILLER PIC X(5). 05 ERROR-MESSAGE PIC X(50).

01 TOTAL-LINE1. 05 FILLER PIC X(25) VALUE 'TOTAL VALID RECORDS = '. 05 TL1-TOT-VALID PIC ZZ9.

01 TOTAL-LINE2. 05 FILLER PIC X(25) VALUE 'TOTAL INVALID RECORDS = '. 05 TL2-TOT-INVALID PIC ZZ9.

01 WS-PROGRAM-ACCUMULATORS. 05 WS-TOT-GOOD PIC 999 VALUE 0. 05 WS-TOT-BAD PIC 999 VALUE 0.

01 WS-SWTICHES-MISC. 05 X PIC 99. 05 EOF-SWITCH PIC X VALUE 'N'. 88 EOF VALUE 'Y'. 05 ERRORS PIC X VALUE 'N'. 05 CHECK-DIGIT-FLAG PIC X.

document.docx CIS355B Page 20

The COPY statement is used to "include" the 05 level entries that are used to define HEADING-LINE2. That is why the .cpy file must be in the same folder as your COBOL program.

Page 21: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions 01 DATE-WORK-AREA. 05 WS-DATE. 10 WS-YYYY PIC 9999. 10 WS-MM PIC 99. 10 WS-DD PIC 99.

01 PRINTER-CONTROL. 05 WS-LINE-CT PIC 99 VALUE 0. 05 WS-PAGE-CT PIC 99 VALUE 0. 05 SPACE-CONTROL PIC 9 VALUE 0.

01 PROGRAM-TABLES. 05 TYPE-TABLE OCCURS 1 TO 100 TIMES DEPENDING ON WS-NO-OF-RECORDS ASCENDING KEY TAB-TYPE-CODE INDEXED BY T-INDX. 10 TAB-TYPE-CODE PIC XX. 10 TAB-TYPE-NAME PIC X(11). 10 TAB-SPECIES PIC XX.

05 WS-NO-OF-RECORDS PIC 999 VALUE 0.

05 MONTH-DATA. 10 FILLER PIC X(9) VALUE 'JANUARY'. 10 FILLER PIC X(9) VALUE 'FEBRUARY'. 10 FILLER PIC X(9) VALUE 'MARCH'. 10 FILLER PIC X(9) VALUE 'APRIL'. 10 FILLER PIC X(9) VALUE 'MAY'. 10 FILLER PIC X(9) VALUE 'JUNE'. 10 FILLER PIC X(9) VALUE 'JULY'. 10 FILLER PIC X(9) VALUE 'AUGUST'. 10 FILLER PIC X(9) VALUE 'SEPTEMBER'. 10 FILLER PIC X(9) VALUE 'OCTOBER'. 10 FILLER PIC X(9) VALUE 'NOVEMBER'. 10 FILLER PIC X(9) VALUE 'DECEMBER'. 05 TAB-MONTH REDEFINES MONTH-DATA OCCURS 12 TIMES PIC X(9).

01 ERROR-MESSAGES. 05 01MSG-INVALID-TRANS-CODE PIC X(50) VALUE 'TRANS CODE - INVALID'. 05 02MSG-NON-NUMERID-ID PIC X(50) VALUE 'ID # - NOT NUMERIC'. 05 03MSG-CKDIGIT-ERROR-ID PIC X(50) VALUE 'ID # - WRONG CHECK DIGIT'. 05 04MSG-INVALID-GROUP PIC X(50) VALUE 'GROUP - INVALID'. 05 05MSG-INVALID-SPECIES PIC X(50) VALUE 'SPECIES - INVALID'. 05 06MSG-INVALID-SPECIES2GROUP PIC X(50) VALUE 'SPECIES - DOES NOT CORRESPOND TO PROPER GROUP'. 05 07MSG-INVALID-TYPE PIC X(50) VALUE 'TYPE - INVALID'. 05 08MSG-INVALID-TYPE2SPECIES PIC X(50) VALUE 'TYPE - DOES NOT CORRESPOND TO PROPER SPECIES'. 05 09MSG-INVALID-SEX PIC X(50) VALUE 'SEX - INVALID'. 05 10MSG-NON-NUMERIC-QOH PIC X(50) VALUE 'QOH - NOT NUMERIC'. 05 11MSG-OUTOFRANGE-QOH PIC X(50) VALUE 'QOH - EXCEEDS 50'. 05 12MSG-NON-NUMERIC-VALUE PIC X(50) VALUE 'VALUE - NOT NUMERIC'. 05 13MSG-VALUE-GT-BIRD-MAX PIC X(50) VALUE 'VALUE - EXCEEDS MAX FOR BIRD'. 05 14MSG-VALUE-GT-FISH-MAX PIC X(50) VALUE 'VALUE - EXCEEDS MAX FOR FISH'. 05 15MSG-VALUE-GT-MAMMAL-MAX PIC X(50)

document.docx CIS355B Page 21

Example of a "hard-coded" table

Example of how the area that an "input-loaded" table will be read into is coded. An index is also defined for the subsequent SEARCH ALL statement to use.

There will be a lot more focus on tables in Week 5, so for now, these are already coded for you in this iLab assignment's program shell.

Page 22: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions VALUE 'VALUE - EXCEEDS MAX FOR MAMMAL'. 05 16MSG-VALUE-GT-REPTILE-MAX PIC X(50) VALUE 'VALUE - EXCEEDS MAX FOR REPTILE'.

01 ERROR-FLAGS. 05 T-ERROR-CODE01 PIC X VALUE 'N'. 05 T-ERROR-CODE02 PIC X VALUE 'N'. 05 T-ERROR-CODE03 PIC X VALUE 'N'. 05 T-ERROR-CODE04 PIC X VALUE 'N'. 05 T-ERROR-CODE05 PIC X VALUE 'N'. 05 T-ERROR-CODE06 PIC X VALUE 'N'. 05 T-ERROR-CODE07 PIC X VALUE 'N'. 05 T-ERROR-CODE08 PIC X VALUE 'N'. 05 T-ERROR-CODE09 PIC X VALUE 'N'. 05 T-ERROR-CODE10 PIC X VALUE 'N'. 05 T-ERROR-CODE11 PIC X VALUE 'N'. 05 T-ERROR-CODE12 PIC X VALUE 'N'. 05 T-ERROR-CODE13 PIC X VALUE 'N'. 05 T-ERROR-CODE14 PIC X VALUE 'N'. 05 T-ERROR-CODE15 PIC X VALUE 'N'. 05 T-ERROR-CODE16 PIC X VALUE 'N'.

********************* Procedure Division Lab 4 ****************** PROCEDURE DIVISION. *****************************************************************

000-MAIN-DRIVER. *Challenge opportunity (optional): * Change the UNTIL clause below to use an 88 level condition-name PERFORM 050-LOAD-TABLE. PERFORM 100-INIT. PERFORM 200-PROCESS UNTIL EOF-SWITCH = 'Y'. PERFORM 900-TERM. STOP RUN.

050-LOAD-TABLE. OPEN INPUT TABLE-FILE. *Challenge opportunity (optional): * Change the UNTIL clause below to use an 88 level condition-name PERFORM VARYING T-INDX FROM 1 BY 1 UNTIL EOF-SWITCH = 'Y' READ TABLE-FILE AT END MOVE 'Y' TO EOF-SWITCH NOT AT END ADD 1 TO WS-NO-OF-RECORDS MOVE TABLE-RECORD TO TYPE-TABLE (T-INDX) END-READ END-PERFORM CLOSE TABLE-FILE. MOVE 'N' TO EOF-SWITCH.

100-INIT. OPEN INPUT TRANS-FILE OUTPUT PRINT-FILE OUTPUT VALID-TRANS-FILE. MOVE FUNCTION CURRENT-DATE TO WS-DATE. STRING TAB-MONTH(WS-MM) DELIMITED BY SPACE ' ' DELIMITED BY SIZE WS-DD DELIMITED BY SIZE ', ' DELIMITED BY SIZE WS-YYYY DELIMITED BY SIZE INTO H1-DATE END-STRING PERFORM 700-READ. PERFORM 950-HEADINGS.

200-PROCESS. PERFORM 210-EDIT-TRANS-CODE.

document.docx CIS355B Page 22

Example of how the "input-loaded" table is read into the storage area defined in the Working-Storage Section.

Example of using the FUNCTION CURRENT-DATE.

Example of using the String function, covered on pages 238–240, Chapter 9. This takes the current-date from WS-DATE and formats it using the WS-MM as the subscript to point to the correct month's name in the hard-coded month table, and concatenates that with the day number, a comma, and the four-digit year.

Page 23: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions

IF T-CODE = 'A' PERFORM 220-EDIT-ID-NO THRU 280-EDIT-VALUE END-IF

IF T-CODE = 'C' PERFORM 220-EDIT-ID-NO THRU 250-EDIT-TYPE IF T-SEX <> SPACES PERFORM 260-EDIT-SEX END-IF IF T-QOH-X <> SPACES PERFORM 270-EDIT-QOH END-IF IF T-VALUE-X <> SPACES PERFORM 280-EDIT-VALUE END-IF END-IF

IF T-CODE = 'D' PERFORM 220-EDIT-ID-NO THRU 250-EDIT-TYPE END-IF

IF ERRORS = 'N' ADD 1 TO WS-TOT-GOOD WRITE VALID-TRANS-RECORD FROM TRANS-RECORD ELSE ADD 1 TO WS-TOT-BAD END-IF

PERFORM 600-MOVE-AND-PRINT. PERFORM 700-READ.

*** Complete the validation code for the following paragraph. ** 210-EDIT-TRANS-CODE.

*** Complete the validation code for the following paragraph. ** 210-EDIT-ID-NO. IF T-ID-NO NOT NUMERIC MOVE ALL '*' TO E2-ID-NO MOVE 'Y' TO ERRORS, T-ERROR-CODE02 ELSE * Code the CALL * statement with the USING * BY CONTENT and * BY REFERENCE clauses IF CHECK-DIGIT-FLAG = 'Y' MOVE ALL '*' TO E2-ID-NO MOVE 'Y' TO ERRORS, T-ERROR-CODE03 END-IF END-IF.

*** Complete the validation code for the following paragraph. ** 220-EDIT-ID-NO.

*** Complete the validation code for the following paragraph. ** 230-EDIT-GROUP.

*** Complete the validation code for the following paragraph. ** 240-EDIT-SPECIES.

250-EDIT-TYPE. SEARCH ALL TYPE-TABLE AT END MOVE ALL '*' TO E5-TYPE MOVE 'Y' TO ERRORS, T-ERROR-CODE07 WHEN TAB-TYPE-CODE(T-INDX) = T-TYPE IF TAB-SPECIES(T-INDX) <> T-SPECIES MOVE ALL '*' TO E5-TYPE MOVE 'Y' TO ERRORS, T-ERROR-CODE08

document.docx CIS355B Page 23

Fill in the logic needed for each of the seven paragraphs shown here, to meet the assignment/program specifications.

Use 88-level names (defined under the corresponding elementary item fields in the trans-record), IF statements, and EVALUATE statements.

Finish this paragraph by coding the CALL statement to the subprogram, as noted in the Requirements section.

Page 24: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions END-IF END-SEARCH.

*** Complete the validation code for the following paragraph. ** 260-EDIT-SEX.

*** Complete the validation code for the following paragraph. ** 270-EDIT-QOH.

*** Complete the validation code for the following paragraph. ** 280-EDIT-VALUE.

600-MOVE-AND-PRINT. MOVE T-CODE TO DL-CODE. IF T-ID-NO IS NUMERIC MOVE T-ID-NO TO DL-ID ELSE MOVE T-ID-NO-X TO DL-ID-X END-IF

MOVE T-GROUP TO DL-GROUP. MOVE T-SPECIES TO DL-SPECIES MOVE T-TYPE TO DL-TYPE MOVE T-SEX TO DL-SEX.

IF T-QOH IS NUMERIC MOVE T-QOH TO DL-QOH ELSE MOVE T-QOH-X TO DL-QOH-X END-IF

IF T-VALUE IS NUMERIC MOVE T-VALUE TO DL-VALUE ELSE MOVE T-VALUE-X TO DL-VALUE-X END-IF

WRITE PRINT-RECORD FROM DETAIL-LINE AFTER SPACE-CONTROL. ADD 1 TO WS-LINE-CT. MOVE 1 TO SPACE-CONTROL.

IF ERRORS = 'Y' MOVE '**ERRORS**' TO ERROR-MESSAGE WRITE PRINT-RECORD FROM ASTERISKS AFTER SPACE-CONTROL ADD 1 TO WS-LINE-CT MOVE 'N' TO ERRORS MOVE SPACES TO ASTERISKS IF T-ERROR-CODE01='Y' MOVE 'N' TO T-ERROR-CODE01 MOVE 01MSG-INVALID-TRANS-CODE TO ERROR-MESSAGE PERFORM 650-PRINT-ERRORS END-IF IF T-ERROR-CODE02='Y' MOVE 'N' TO T-ERROR-CODE02 MOVE 02MSG-NON-NUMERID-ID TO ERROR-MESSAGE PERFORM 650-PRINT-ERRORS END-IF IF T-ERROR-CODE03='Y' MOVE 'N' TO T-ERROR-CODE03 MOVE 03MSG-CKDIGIT-ERROR-ID TO ERROR-MESSAGE PERFORM 650-PRINT-ERRORS END-IF IF T-ERROR-CODE04='Y' MOVE 'N' TO T-ERROR-CODE04 MOVE 04MSG-INVALID-GROUP TO ERROR-MESSAGE PERFORM 650-PRINT-ERRORS END-IF IF T-ERROR-CODE05='Y' MOVE 'N' TO T-ERROR-CODE05

document.docx CIS355B Page 24

Page 25: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions MOVE 05MSG-INVALID-SPECIES TO ERROR-MESSAGE PERFORM 650-PRINT-ERRORS END-IF IF T-ERROR-CODE06='Y' MOVE 'N' TO T-ERROR-CODE06 MOVE 06MSG-INVALID-SPECIES2GROUP TO ERROR-MESSAGE PERFORM 650-PRINT-ERRORS END-IF IF T-ERROR-CODE07='Y' MOVE 'N' TO T-ERROR-CODE07 MOVE 07MSG-INVALID-TYPE TO ERROR-MESSAGE PERFORM 650-PRINT-ERRORS END-IF IF T-ERROR-CODE08='Y' MOVE 'N' TO T-ERROR-CODE08 MOVE 08MSG-INVALID-TYPE2SPECIES TO ERROR-MESSAGE PERFORM 650-PRINT-ERRORS END-IF IF T-ERROR-CODE09='Y' MOVE 'N' TO T-ERROR-CODE09 MOVE 09MSG-INVALID-SEX TO ERROR-MESSAGE PERFORM 650-PRINT-ERRORS END-IF IF T-ERROR-CODE10='Y' MOVE 'N' TO T-ERROR-CODE10 MOVE 10MSG-NON-NUMERIC-QOH TO ERROR-MESSAGE PERFORM 650-PRINT-ERRORS END-IF IF T-ERROR-CODE11='Y' MOVE 'N' TO T-ERROR-CODE11 MOVE 11MSG-OUTOFRANGE-QOH TO ERROR-MESSAGE PERFORM 650-PRINT-ERRORS END-IF IF T-ERROR-CODE12='Y' MOVE 'N' TO T-ERROR-CODE12 MOVE 12MSG-NON-NUMERIC-VALUE TO ERROR-MESSAGE PERFORM 650-PRINT-ERRORS END-IF IF T-ERROR-CODE13='Y' MOVE 'N' TO T-ERROR-CODE13 MOVE 13MSG-VALUE-GT-BIRD-MAX TO ERROR-MESSAGE PERFORM 650-PRINT-ERRORS END-IF IF T-ERROR-CODE14='Y' MOVE 'N' TO T-ERROR-CODE14 MOVE 14MSG-VALUE-GT-FISH-MAX TO ERROR-MESSAGE PERFORM 650-PRINT-ERRORS END-IF IF T-ERROR-CODE15='Y' MOVE 'N' TO T-ERROR-CODE15 MOVE 15MSG-VALUE-GT-MAMMAL-MAX TO ERROR-MESSAGE PERFORM 650-PRINT-ERRORS END-IF IF T-ERROR-CODE16='Y' MOVE 'N' TO T-ERROR-CODE16 MOVE 16MSG-VALUE-GT-REPTILE-MAX TO ERROR-MESSAGE PERFORM 650-PRINT-ERRORS END-IF END-IF

MOVE ALL '-' TO PRINT-RECORD. WRITE PRINT-RECORD AFTER SPACE-CONTROL. ADD 1 TO WS-LINE-CT.

IF WS-LINE-CT > 45 PERFORM 950-HEADINGS END-IF

MOVE SPACES TO DETAIL-LINE, ASTERISKS, PRINT-RECORD.

document.docx CIS355B Page 25

Page 26: Week4 iLab Instructions Web view · 2013-08-042013-08-04 · Week4_iLab_Instructions.docx CIS355BPage 22. iLab 4 of 7: Data Validation and ... When you open the Word document created

Week 4 iLab Instructions

650-PRINT-ERRORS. WRITE PRINT-RECORD FROM ASTERISKS AFTER SPACE-CONTROL MOVE SPACES TO ASTERISKS ADD 1 TO WS-LINE-CT IF WS-LINE-CT > 45 PERFORM 950-HEADINGS END-IF.

700-READ. READ TRANS-FILE AT END MOVE 'Y' TO EOF-SWITCH.

900-TERM. MOVE WS-TOT-GOOD TO TL1-TOT-VALID. MOVE WS-TOT-BAD TO TL2-TOT-INVALID.

WRITE PRINT-RECORD FROM TOTAL-LINE1 AFTER 2. WRITE PRINT-RECORD FROM TOTAL-LINE2 AFTER 1. CLOSE TRANS-FILE, PRINT-FILE, VALID-TRANS-FILE.

950-HEADINGS. ADD 1 TO WS-PAGE-CT. MOVE WS-PAGE-CT TO H1-PAGE. IF WS-PAGE-CT = 1 THEN

WRITE PRINT-RECORD FROM HEADING-LINE1 ELSE

WRITE PRINT-RECORD FROM HEADING-LINE1 AFTER PAGE END-IF. WRITE PRINT-RECORD FROM HEADING-LINE2 AFTER 2 LINES. WRITE PRINT-RECORD FROM SPACES AFTER 1 LINE. MOVE 2 TO SPACE-CONTROL. MOVE 4 TO WS-LINE-CT.

document.docx CIS355B Page 26