1 / 16

Chapter 4 The Identification, Environment, and Data Divisions

Chapter 4 The Identification, Environment, and Data Divisions.

joella
Download Presentation

Chapter 4 The Identification, Environment, and Data Divisions

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 4The Identification,Environment, andData Divisions

  2. GREATER THAN LESS THANEQUAL TO identifier-1 GREATER THAN OR EQUAL TO identifier-2IF literal-1 IS [ NOT ] LESS THAN OR EQUAL TO literal-2 arithmetic expression-1 > arithmetic expression-2 < = >= <= Choice required Programmer supplied Optional entry Optional reserved words Required word Figure 4.1 COBOL Notation

  3. IDENTIFICATION DIVISION. IDENTIFICATION DIVISION. PROGRAM-ID. Program-name. AUTHOR. [Nombre del autor.] INSTALLATION. [Nombre Centro de cómputos.] DATE-WRITTEN. [Fecha se escribio el prog.] DATE-COMPILED. [Fecha compilación.] SECURITY. [Documentación del programa.]

  4. ENVIRONMENT DIVISIONCONFIGURATION SECTION. [CONFIGURATION SECTION. [SOURCE-COMPUTER. Computer-name.] [OBJECT-COMPUTER. Computer-name.]]

  5. ENVIRONMENT DIVISIONINPUT-OUTPUT SECTION. [INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT file-name-1 ASSIGN TO implementor-name.]

  6. FILE SECTION. FD file-name [BLOCK CONTAINS integer-1 RECORDS] [RECORD CONTAINS integer-1 CHARACTERS] LABEL [DATARECORD IS data-name-1]. RECORDS ARE OMITTED RECORD IS STANDARD

  7. | ADAMS | | BAKER | | BROWN | | CHARLES | | DAVIS | | EDISON | | ADAMS | BAKER | |BROWN | CHARLES | | DAVIS | EDISON | | ADAMS | BAKER |BROWN | | CHARLES | DAVIS | EDISON | Figure 4.2 Blocked versus Unblocked Records (a) Unblocked Records(One Logical Record per Physical Record) (b) Blocking Factor of Two(Two Logical Records per Physical Record) (b) Blocking Factor of Three(Three Logical Records per Physical Record)

  8. STUDENT-EXAM-RECORD STUDENT-NAME SS-NUM EXAM-SCORES MATH ENGLISH LASTNAME FIRSTNAME INIT ALG GEO READ VOC LIT 1 15 16 30 31 32 40 41 45 46 50 51 55 56 60 61 65 ALPHANUMERIC NUMERIC Figure 4.3 Student Exam Record

  9. Figure 4.4 Level Numbers and PICTURE Clauses 01 STUDENT-EXAM-RECORD. 05 STUDENT-NAME. 10 LAST-NAME PICTURE IS X(15). 10 FIRST-NAME PICTURE IS X(15). 10 MID-INITIAL PICTURE IS X. 05 SOC-SEC-NUM PICTURE IS 9(9). 05 EXAM-SCORES. 10 MATH. 15 ALGEBRA PICTURE IS 9(5). 15 GEOMETRY PICTURE IS 9(5). 10 ENGLISH. 15 READING PICTURE IS 9(5). 15 VOCABULARY PICTURE IS 9(5). 15 LITERATURE PICTURE IS 9(5). 01 STUDENT-EXAM-RECORD. 04 STUDENT-NAME. 08 LAST-NAME PIC X(15). 08 FIRST-NAME PIC X(15). 08 MID-INITIAL PIC X. 04 SOC-SEC-NUM PIC 9(9). 04 EXAM-SCORES. 08 MATH. 12 ALGEBRA PIC 99999. 12 GEOMETRY PIC 99999.. 08 ENGLISH. 12 READING PIC 99999. 12 VOCABULARY PIC 99999. 12 LITERATURE PIC 99999. (a) Initial Coding (b) Alternative Specification

  10. Figure 4.5 Assumed Decimal Point INCOMING RECORD DATA DIVISION RECORDDESCRIPTION VALUES 01 INCOMING-DATA-RECORD. 05 STUDENT-NAME PIC 9V99. 05 STUDENT-NAME PIC 99V9. 05 STUDENT-NAME PIC 9. 05 STUDENT-NAME PIC V999. 9.87 65.4. 3 .210 vvv9 87|65 4|3 | 210

  11. Figure 4.6 The Working-Storage Section WORKING-STORAGE SECTION. 01 COUNTER-AND-SWITCHES. 05 TOTAL-STUDENTS PIC 9(3) VALUE ZEROES. 05 DATA-REMAINS-SWITCH PIC X(2) VALUE SPACES. 01 PROGRAM-CONSTANTS. 05 REQUIRED-CREDITS PIC 999 VALUE 110. 05 REQUIRED-MAJOR PIC X(10) VALUE ‘ENGINEERING’. 05 REQUIRED-GPA PIC 9V99 VALUE 3.00. 01 HEADING-LINE. 05 FILLER PIC X(10) VALUE SPACES. 05 FILLER PIC X(12) VALUE ‘STUDENT NAME’. 05 FILLER PIC X(110) VALUE SPACES. 01 DETAIL-LINE. 05 FILLER PIC X(8) VALUE SPACES. 05 PRINT-NAME PIC X(25). 05 FILLER PIC X(10) VALUE SPACES. 05 PRINT-MAJOR PIC X(15). 05 FILLER PIC X(74) VALUE SPACES. 01 TOTAL-LINE. 05 PIC X(4) VALUE SPACES. 05 PIC X(14) VALUE ‘TOTAL STUDENTS’. 05 PIC X(2) VALUE SPACES. 05 TOT-STUDENTS PIC 9(3) VALUE ZEROES. 05 PIC X(110) VALUE SPACES. 01 DASHED-LINE. 05 FILLER PIC X(132) VALUE ALL ‘-’. El FILLER es opcional.

  12. FD STUDENT-FILE RECORD CONTAINS 27 CHARACTERS.01 STUDENT-RECORD. 05 STU-NAME. 10 STU-LAST-NAME PIC X(15). 10 STU-INITIALS PIC XX. 05 STU-CREDITS PIC 9(2). 05 STU-UNION-MEMBER PIC X. 05 STU-SCHOLARSHIP PIC 9(4). 05 STU-GPA PIC 9V99. (b) COBOL Entries Figure 4.7 Development of a COBOL Program (File Section) CREDITS UNION MEMBER INITIALS SCHOLARSHIP STUDENT NAME GPA LAST 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 (a) Program Specifications

  13. Figure 4.8 Development of a COBOL Program (Constants and Rates) 1. Calculate tuition due at the rate of $200 per credit.2. The union fee is $25.3. Compute the activity fee based on the number of credits taken; $25 for 6 credits or less, $50 for 7 to 12 credits, and $75 for more than 12 credits.4. Award a scholarship equal to the amount in the incoming record if, and only if, the GPA is greater than 2.5. (a) Excerpt from the Program Specifications WORKING-STORAGE SECTION.01 CONSTANTS-AND-RATES. 05 PRICE-PER-CREDIT PIC 9(3) VALUE 200. 05 UNION-FEE PIC 9(2) VALUE 25. 05 ACTIVITY-FEES. 10 1ST-ACTIVITY-FEE PIC 99 VALUE 25. 10 1ST-CREDIT-LIMIT PIC 99 VALUE 6. 10 2ND-ACTIVITY-FEE PIC 99 VALUE 50. 10 2ND-CREDIT-LIMIT PIC 99 VALUE 12. 10 3RD-ACTIVITY-FEE PIC 99 VALUE 75. 05 MINIMUM-SCHOLARHSIP-GPA PIC 9V9 VALUE 2.5. (b) COBOL Entries

  14. Figure 4.9 Development of a COBOL Program (Print Lines) (a) Report Layout

  15. Figure 4.9 Development of a COBOL Program (Print Lines) 01 HEADING-LINE. 05 FILLER PIC X VALUE SPACES. 05 FILLER PIC X(12) VALUE ‘STUDENT NAME’. 05 FILLER PIC X(10) VALUE SPACES. 05 FILLER PIC X(7) VALUE ‘CREDITS’. 05 FILLER PIC X(2) VALUE SPACES. 05 FILLER PIC X(7) VALUE ‘TUITION’. 05 FILLER PIC X(2) VALUE SPACES. 05 FILLER PIC X(9) VALUE ‘UNION FEE’. 05 FILLER PIC X(2) VALUE SPACES. 05 FILLER PIC X(7) VALUE ‘ACT FEE’. 05 FILLER PIC X(2) VALUE SPACES. 05 FILLER PIC X(11) VALUE ‘SCHOLARSHIP’. 05 FILLER PIC X(2) VALUE SPACES. 05 FILLER PIC X(10) VALUE ‘TOTAL BILL’. 05 FILLER PIC X(48) VALUE SPACES.01 DETAIL-LINE. 05 FILLER PIC X VALUE SPACES. 05 DET-LAST-NAME PIC X(15). 05 FILLER PIC X(2) VALUE SPACES. 05 DET-INITIALS PIC X(2). 05 FILLER PIC X(5) VALUE SPACES. 05 DET-CREDITS PIC 9(2). 05 FILLER PIC X(2) VALUE SPACES. 05 DET-TUITION PIC 9(6). 05 FILLER PIC X(7) VALUE SPACES. 05 DET-UNION-FEE PIC 9(3). 05 FILLER PIC X(8) VALUE SPACES. 05 DET-SCHOLARSHIP PIC 9(5). 05 FILLER PIC X(6) VALUE SPACES. 05 DET-IND-BILL PIC 9(6). 05 FILLER PIC X(49) VALUE SPACES. (b) COBOL Entries

  16. End of Chapter 4

More Related