Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4 The Identification, Environment, and Data Divisions.

Similar presentations


Presentation on theme: "Chapter 4 The Identification, Environment, and Data Divisions."— Presentation transcript:

1 Chapter 4 The Identification, Environment, and Data Divisions

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

3 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 DIVISION CONFIGURATION SECTION. [CONFIGURATION SECTION. [SOURCE-COMPUTER. Computer-name.] [OBJECT-COMPUTER. Computer-name.]]

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

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

7 Figure 4.2Blocked 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 Figure 4.3Student Exam Record STUDENT-EXAM-RECORD STUDENT-NAMEEXAM-SCORESSS-NUM LAST NAME FIRST NAME INIT MATHENGLISH ALGGEOREADVOCLIT ALPHANUMERICNUMERIC

9 Figure 4.4Level Numbers and PICTURE Clauses 01 STUDENT-EXAM-RECORD. 05 STUDENT-NAME. 10 LAST-NAMEPICTURE IS X(15). 10 FIRST-NAMEPICTURE IS X(15). 10 MID-INITIALPICTURE IS X. 05 SOC-SEC-NUMPICTURE IS 9(9). 05 EXAM-SCORES. 10 MATH. 15 ALGEBRAPICTURE IS 9(5). 15 GEOMETRYPICTURE IS 9(5). 10 ENGLISH. 15 READINGPICTURE IS 9(5). 15 VOCABULARYPICTURE IS 9(5). 15 LITERATUREPICTURE IS 9(5). 01 STUDENT-EXAM-RECORD. 04 STUDENT-NAME. 08 LAST-NAMEPIC X(15). 08 FIRST-NAMEPIC X(15). 08 MID-INITIALPIC X. 04 SOC-SEC-NUMPIC 9(9). 04 EXAM-SCORES. 08 MATH. 12 ALGEBRAPIC GEOMETRYPIC ENGLISH. 12 READINGPIC VOCABULARYPIC LITERATUREPIC (a) Initial Coding (b) Alternative Specification

10 Figure 4.5Assumed Decimal Point INCOMING RECORDDATA DIVISION RECORD DESCRIPTION VALUES v v v 9 87|65 4|3 | INCOMING-DATA-RECORD. 05 STUDENT-NAME PIC 9V STUDENT-NAMEPIC 99V9. 05 STUDENT-NAMEPIC STUDENT-NAMEPIC V

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 REQUIRED-MAJOR PIC X(10) VALUE ‘ENGINEERING’. 05 REQUIRED-GPA PIC 9V99 VALUE 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 Figure 4.7Development of a COBOL Program (File Section) (b) COBOL Entries 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-CREDITSPIC 9(2). 05 STU-UNION-MEMBER PIC X. 05 STU-SCHOLARSHIP PIC 9(4). 05 STU-GPAPIC 9V99. STUDENT NAME LAST GPA INITIALS CREDITSUNION MEMBER SCHOLARSHIP (a) Program Specifications

13 Figure 4.8Development of a COBOL Program (Constants and Rates) (b) COBOL Entries WORKING-STORAGE SECTION. 01 CONSTANTS-AND-RATES. 05 PRICE-PER-CREDIT PIC 9(3) VALUE UNION-FEEPIC 9(2) VALUE ACTIVITY-FEES. 10 1ST-ACTIVITY-FEEPIC 99 VALUE ST-CREDIT-LIMITPIC 99 VALUE ND-ACTIVITY-FEEPIC 99 VALUE ND-CREDIT-LIMITPIC 99 VALUE RD-ACTIVITY-FEEPIC 99 VALUE MINIMUM-SCHOLARHSIP-GPA PIC 9V9 VALUE 2.5. (a) Excerpt from the Program Specifications 1. Calculate tuition due at the rate of $200 per credit. 2. The union fee is $ 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.

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

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

16 End of Chapter 4


Download ppt "Chapter 4 The Identification, Environment, and Data Divisions."

Similar presentations


Ads by Google