bis 1753 introduction to computer programming 1. computer program a set of instructions that enables...
TRANSCRIPT
![Page 1: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/1.jpg)
BIS 1753
• Introduction to Computer Programming
1
![Page 2: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/2.jpg)
Computer Program
• A set of instructions that enables a computer to process data
• Also called software
• Two types of computer software– Systems software - controls overall
operations of computer– Application software - perform specific
tasks
2
![Page 3: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/3.jpg)
Application Software
• Written by application programmers• May provide quick solution to one-time
problem– Generate ad hoc report, summarize data
• Or may be run on regularly scheduled basis– Payroll system, Billing system
3
![Page 4: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/4.jpg)
Customized Application Software
• Written for specific users like retail establishments, manufacturing firms, banks, and more
• Necessary if user has special requirements
4
![Page 5: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/5.jpg)
Programming Languages
Symbolic language (like COBOL)• English-like languages used to write
programs• Easier than writing programs in machine
language• Must be translated or compiled into
machine language to run on computer
5
![Page 6: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/6.jpg)
Programming Languages
Machine language• Only language computer understands• All programs executed on computer
must be in machine language• Machine language programs difficult to
write
6
![Page 7: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/7.jpg)
Programming Languages
Compiler• Translates source code (such as
COBOL) into object code (roughly, executable code)
• Checks for syntax errors in the source code
7
![Page 8: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/8.jpg)
Nature of COBOL
• Business-oriented language
• Standard language
• English-like language
• Relatively easy to understand
8
![Page 9: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/9.jpg)
History of COBOL
• Developed in 1959 as standard language to meet needs of business
• Committee to develop language convened by Department of Defense
• Included representatives from academia, business, computer manufacturers
9
![Page 10: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/10.jpg)
Standard Versions of COBOL• 1960s
• 1968
• 1974
• 1985
wide variations in COBOL compilers
first COBOL standard set by American National Standards Institute (ANSI)
second ANSI standard to make COBOL more efficient, standardized
this ANSI standard incorporated structured programming techniques
10
![Page 11: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/11.jpg)
Current and Future Standards
• 1985 currently the most widely used
• 2008 is next standard – Approval expected in 2008 or so– Information on 2008 COBOL standard at
http://www.ansi.org
11
![Page 12: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/12.jpg)
Future of COBOL
Likely to remain important language
• Older COBOL programs need to be updated
• Still used by many for new program development
12
![Page 13: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/13.jpg)
Use of COBOL
• About 200 billion lines of COBOL source code in use
• 5 billion new lines added each year
• Used by 42.7% of application programmers in medium to large U.S. companies
13
![Page 14: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/14.jpg)
Overview of the Four Divisions
• Every COBOL program contains up to four separate divisions in the following order:
IDENTIFICATION DIVISION
ENVIRONMENT DIVISION
DATA DIVISION
PROCEDURE DIVISION
14
![Page 15: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/15.jpg)
Overview of the Four Divisions
• IDENTIFICATION DIVISION– Identifies program to operating system– Provides documentation about program
• ENVIRONMENT DIVISION– Defines file-names– Describes devices used to store them– Not included in fully interactive programs
15
![Page 16: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/16.jpg)
Overview of the Four Divisions
• DATA DIVISION– Describes input and output format of data
in files– Defines any constants and work areas
• PROCEDURE DIVISION– Contains instructions to read input, process
it and create output
16
![Page 17: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/17.jpg)
17
![Page 18: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/18.jpg)
18
![Page 19: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/19.jpg)
BIS 1753
• Introduction to Structured Program Design in COBOL
19
![Page 20: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/20.jpg)
Basic COBOL Program Structure
• Originally, each COBOL instruction coded on single line of 80 characters
• Positions on line reserved for special purposes
• Rigid column rules dropped in 2008
• OpenCOBOL supports free-format COBOL
20
![Page 21: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/21.jpg)
Coding Rules (fixed format)
• Columns 1-6 and 73-80 optional and rarely used today
• Column 7 for continuation, comment, starting new page
• Columns 8-72 for COBOL program statements
21
![Page 22: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/22.jpg)
Coding Rules (fixed format)
Column 7
* (asterisk) designates entire line as comment
/ (slash) forces page break when printing source listing
- (dash) to indicate continuation of nonnumeric literal
22
![Page 23: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/23.jpg)
Coding Rules (free format)
*> at beginning of line indicates comment
23
![Page 24: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/24.jpg)
Margin Rules
• Columns 8-72 divided into two areas– Area A - columns 8, 9, 10, 11– Area B - columns 12-72
• Division, section and paragraph-names must all begin in Area A– First letter of name must begin in column 8,
9, 10 or 11– Entry may extend into Area B
24
![Page 25: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/25.jpg)
Margin Rules
• All other statements, clauses, and sentences begin anywhere in Area B (column 12, 13, 14, etc.)– Select entries in ENVIRONMENT
DIVISION– Data description entries in DATA DIVISION– All PROCEDURE DIVISION instructions
25
![Page 26: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/26.jpg)
Rules for User-Defined Words
1. 1 to 30 characters
2. Letters, digits, hyphens (-) only
3. No embedded blanks
4. At least one alphabetic character
5. May not begin or end with hyphen
6. May not be COBOL reserved word
26
![Page 27: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/27.jpg)
Coding Guidelines
1. Separate divisions by blank comment line, page eject symbol or blank line
2. Code a single statement per line
3. Code paragraph-names on line by themselves
4. Be liberal in use of comments. Box lengthy comments using asterisks.
27
![Page 28: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/28.jpg)
Coding Guidelines
5. Code SELECT statements in logical order (input files first, then output files) although order not required
6. Use separate lines for SELECT, ASSIGN, ORGANIZATION clauses for readability
7. Avoid use of device-specific file-names
28
![Page 29: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/29.jpg)
COBOL 2008 Changes
• Coding rules for Areas A and B will be recommended not required.
• PROGRAM-ID will be only paragraph in IDENTIFICATION DIVISION. All others can be specified as comments.
• Length of user-defined words will be increased from 30 to 60 characters.
29
![Page 30: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/30.jpg)
30
![Page 31: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/31.jpg)
BIS 1753
• IDENTIFICATION and ENVIRONMENT Divisions
31
![Page 32: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/32.jpg)
IDENTIFICATION DIVISION
• Provides identifying information about program
• Divided into paragraphs
• PROGRAM-ID only required paragraph
• Other paragraphs optional
32
![Page 33: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/33.jpg)
IDENTIFICATION DIVISION
Syntax
IDENTIFICATION DIVISION.
PROGRAM-ID. program-name.
[AUTHOR. [comment-entry] …]
[other optional paragraphs]
33
![Page 34: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/34.jpg)
Syntax Symbology• Uppercase words are COBOL reserved
words• Lowercase words are user-defined entries
IDENTIFICATION DIVISION.
PROGRAM-ID. program-name.
– DIVISION is reserved word– program-name is user-defined data-name
Example
34
![Page 35: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/35.jpg)
Syntax Symbology
• Underlined words are required• Punctuation if specified is required
IDENTIFICATION DIVISION. PROGRAM-ID. program-name.
– IDENTIFICATION, DIVISION required– PROGRAM-ID is required paragraph– Periods required after division header, paragraph
name and program-name
Example
35
![Page 36: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/36.jpg)
Syntax Symbology
• Brackets [ ] mean item is optional, braces { } mean one of enclosed items required
• Ellipses (. . .) mean entry may be repeated
IDENTIFICATION DIVISION.
PROGRAM-ID. program-name.
[AUTHOR. [comment-entry] …]
– AUTHOR paragraph optional– If included it may have any number of comment
entries
Example
36
![Page 37: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/37.jpg)
ENVIRONMENT DIVISION
• Describes files and computer devices used to process them
• Required by programs that process files
• This division is machine-dependent since devices differ from computer to computer
• Only division that may change if program run on different computer
37
![Page 38: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/38.jpg)
Sections of Environment Division
• CONFIGURATION SECTION– Describes computer used to
compile/execute program– Optional and recommended that you omit it
• INPUT-OUTPUT SECTION– Describes input and output files– Required for all programs using files
38
![Page 39: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/39.jpg)
INPUT-OUTPUT SECTION
Format
INPUT-OUTPUT SECTION.FILE-CONTROL.
SELECT internal-file-name-1 ASSIGN TO externale-file-name-1 [ORGANIZATION IS LINE SEQUENTIAL].1
1Use this clause for all PC files so each line treated as separate record.
39
![Page 40: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/40.jpg)
SELECT Statement file-names
• File-names are user-defined words– Words chosen by programmer to represent
some element of program
40
![Page 41: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/41.jpg)
41
![Page 42: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/42.jpg)
42
![Page 43: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/43.jpg)
BIS 1753
• DATA Division
43
![Page 44: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/44.jpg)
Data-Name Guidelines
1.Use meaningful data-names that describe contents of field• Amount-Due-In instead of A1
2.Use prefixes or suffixes in data-names when appropriate• -IN and -OUT for fields (Emp-Salary-IN and
Emp-Salary-OUT)• -FILE and -RECORD for file and record
names (Emp-File and Emp-Record)
44
![Page 45: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/45.jpg)
DATA DIVISION
• Defines, describes storage for all data• Two main sections
– FILE SECTION • Defines all input and output files, records, fields• Required for any program that uses files,
typically batch programs
– WORKING-STORAGE SECTION • Defines constants, end-of-file indicators and
work areas • Defines fields not part of input or output files
45
![Page 46: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/46.jpg)
WORKING-STORAGE SECTION
• Follows FILE SECTION
• Begins with heading on line by itself
• Starts in Area A, ends with period
• All items must be defined at 01 level or in entries subordinate to 01 level entry, or 77 level (independent data item)
46
![Page 47: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/47.jpg)
WORKING-STORAGE SECTION
• Rules for user-defined data-names apply
• Elementary items:– Must include PICTURE clause– May be assigned initial value with VALUE
clause
47
![Page 48: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/48.jpg)
Uses of WORKING-STORAGE
To define fields used for
• Keyed input and displayed output
• Intermediate arithmetic results
• Counters and totals
• End-Of-File Indicators
48
![Page 49: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/49.jpg)
PICTURE (PIC) clauses
• Specify type of data stored in field• Indicate size of field
49
![Page 50: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/50.jpg)
Types of data fields• Alphanumeric (x- prefix)
• Any character - letters, digits, special characters• For an address like 123 N. Main St.
• Numeric (n- prefix)• Only digits• Used for input and calculations
• Numeric edited (ne-prefix)• Digits and special characters • Used for output
50
![Page 51: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/51.jpg)
Data Types in PICTURE clause
• X for alphanumeric• 9 V for numeric• Z , $ . and more for numeric edited
51
![Page 52: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/52.jpg)
Size of Data Fields
Denote size of field by:
• Number of formatting characters used in PICTURE
01 Cust-Rec-In.05 Cust-ID-In Picture XXXX.
05 Amt-In Picture 99999.
52
![Page 53: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/53.jpg)
Size of Data Fields
My also denote size of field by:
• A, X or 9 followed by number in parentheses
01 Cust-Rec-In.05 Cust-ID-In Picture X(4).
05 Amt-In Picture 9(5).
53
![Page 54: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/54.jpg)
Implied Decimal Point
• For fields used in arithmetic operations• Symbol V used in PIC clause to denote
location of implied decimal point• Decimal point itself not stored as part of
number• To store value 26.79 in field AMT-IN,
code entry as
05 Amt-In Pic 99V99.54
![Page 55: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/55.jpg)
VALUE clause
• To define initial value for field• If omitted, field’s value undefined when
program begins execution• May be used only in WORKING-
STORAGE SECTION
55
![Page 56: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/56.jpg)
VALUE vs MOVE
• VALUE clause used in DATA DIVISION– Gives initial value before execution begins
• MOVE used in PROCEDURE DIVISION– Assigns value to field after program begins
• MOVE may change initial value of field
56
![Page 57: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/57.jpg)
VALUE Clause
• Contains literal or figurative constant• Data type must match PICTURE
• Numeric literals or ZEROS used with PIC 9 fields 01 WS-Tax-Rate Pic V99 Value .06. 01 WS-Total Pic 999 Value Zeros.
57
![Page 58: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/58.jpg)
VALUE Clause
• Nonnumeric literals, ZEROS or SPACES used with PIC X fields 01 WS-EOF Pic X(3) Value ‘YES’. 01 WS-Descrip Pic X(8) Value Spaces.
58
![Page 59: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/59.jpg)
Rules for Numeric Literals
1. 1 to 18 digits.2. + or - sign may be included to left of
first digit.3. Decimal point permitted within literal.
May not follow last digit.
Valid numeric literals
23 +2359.4 .125 -68734
59
![Page 60: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/60.jpg)
Rules for Nonnumeric Literals
• Must be enclosed in quotation marks• From 1 to 160 characters, including space• Any character in COBOL character set except
quotation mark
Valid Nonnumeric Literals
'123 Main St.' '$14.99' '12,342' 'Enter a value from 1 to 10'
60
![Page 61: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/61.jpg)
Nonnumeric Literals
• Only characters within quotes are moved or displayed
• May contain all numbers ('125') but not same as numeric literal (125)– Cannot be used in arithmetic operations– Cannot be moved to field with PIC of 9’s
• Are not data-names– 'Amount-In' not same as field defined in
DATA DIVISION called Amount-In
61
![Page 62: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/62.jpg)
Figurative Constants - ZERO
• ZERO, ZEROS or ZEROES means all zeros
Move Zeros To Total-Out
• Fills each position in Total-Out with a zero
• May be used with both numeric and alphanumeric fields
Example
62
![Page 63: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/63.jpg)
Figurative Constants - SPACE
• SPACE or SPACES means all spaces or blanks
Move Spaces To Code-Out
• Fills each position in Code-Out with a space or blank
• Use only with alphanumeric fields since blank is invalid numeric character
Example
63
![Page 64: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/64.jpg)
BIS 1753
• PROCEDURE Division (Interactive I/O)
64
![Page 65: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/65.jpg)
PROCEDURE DIVISION
Contains instructions for
• initialization activities
• processing activities
• termination activities
65
![Page 66: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/66.jpg)
PROCEDURE DIVISION
• Interactive processing instructions
– Accept input from keyboard
– Display output on screen
66
![Page 67: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/67.jpg)
Paragraphs
• PROCEDURE DIVISION divided into
paragraphs
• Each is independent module or routine
• Made up of series of instructions to
perform specific set of operations
67
![Page 68: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/68.jpg)
Rules for Paragraph-Names
• Coded in Area A, followed by period
• Follow rules for forming data-names
except may be all digits
– 1010, 1020, 1030, etc. are valid paragraph
names
• Must be unique
68
![Page 69: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/69.jpg)
Procedure Division Statements
• All statements coded in Area B
• Statement begins with verb (Accept,
Display)
• Last statement in paragraph ends with
period
• Sentence - series of statements ending
with period69
![Page 70: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/70.jpg)
Interactive Program Statements
• DISPLAY to prompt for input
• ACCEPT to store input in WORKING-STORAGE areas
• Various statements to process input
• DISPLAY to show output
70
![Page 71: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/71.jpg)
ACCEPT statement
71
![Page 72: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/72.jpg)
DISPLAY statement
72
![Page 73: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/73.jpg)
COMPUTE statement
73
![Page 74: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/74.jpg)
STOP RUN statement
• Terminates the program
• Usually last instruction in main paragraph
• Execution continues with next paragraph if STOP RUN is omitted
74
![Page 75: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/75.jpg)
Comments in COBOL• Start with asterisk (*) in column 7 (fixed
format)
• Start with *> in column 1 (free format)
• Use as reminders and explanations of processing performed by program
• Use to describe program in IDENTIFICATION DIVISION
• Use to describe each paragraph in PROCEDURE DIVISION
75
![Page 76: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/76.jpg)
BIS 1753
• Move statement
76
![Page 77: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/77.jpg)
Move statement
•
MOVE identifier-1 TO identifier-2 …
literal-1
Move 0 To Total-1, Total-2, Total-3
• Move may have multiple receiving fields
Full Format
77
![Page 78: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/78.jpg)
Numeric MOVE Rules
• Decimal alignment always maintained
• Digits in integer part moved right to left starting at decimal point
• Digits in decimal part moved left to right starting at decimal point
78
![Page 79: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/79.jpg)
Numeric MOVE Rules
• If receiving field has more integer positions than sending field– Unfilled high-order (leftmost) integer
positions filled with zeros
• If receiving field has more decimal positions than sending field– Unfilled low-order (rightmost) decimal
positions filled with zeros
79
![Page 80: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/80.jpg)
Numeric MOVE Rules
• If receiving field has fewer integer positions than sending field– High-order (leftmost) digits truncated
• If receiving field has fewer decimal positions than sending field– Low-order (rightmost) digits truncated
80
![Page 81: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/81.jpg)
Rules for Nonnumeric MOVE
• Characters moved from left to right
• If receiving field longer, low-order (rightmost) positions replaced with spaces
• If receiving field shorter, low-order characters in sending field truncated
81
![Page 82: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/82.jpg)
BIS 1753
• Full-screen interactive I/O
82
![Page 83: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/83.jpg)
Displaying Output Interactively
• No COBOL standard for interactive processing
• Two techniques used by compilers to add interactivity– ACCEPT, DISPLAY enhancements with
options to define appearance of data on screen
– SCREEN SECTION added in DATA DIVISION to define screen’s format
83
![Page 84: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/84.jpg)
ACCEPT, DISPLAY Enhancements
Display "Enter date of birth"At Line 13 Column 1
With Blank ScreenForeground-Color 1Background-Color 7
• Displays prompt at specific position on screen after clearing screen, using one color for characters and another for background
EXAMPLE
84
![Page 85: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/85.jpg)
SCREEN SECTION
• Specify formats, options for screen
• Follows WORKING-STORAGE
• Define each screen with 01 level entry followed by subordinate entries
• DISPLAY screen-name displays all prompts described in entries for screen
• ACCEPT screen-name captures all data typed by user for that screen
85
![Page 86: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/86.jpg)
SCREEN SECTION
01 Screen-1.05 Blank Screen.05 Line 3 Column 1 Value 'City'.05 Column 17 Pic X(13) To City-In.
• Display Screen-1 blanks screen and displays City in first column of line 3
• Accept Screen-1 moves 13 characters user enters starting in line 3, column 17 to City-In
EXAMPLE
86
![Page 87: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/87.jpg)
87
![Page 88: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/88.jpg)
BIS 1753
• File Input/Output (I/O)
88
![Page 89: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/89.jpg)
COBOL Data Organization
• File - group of related records– Customer file made up of customer records
• Record - group of related fields– All fields related to one customer
• Field - group of characters forming a meaningful unit or basic fact– Characters in a name or digits in an
amount
89
![Page 90: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/90.jpg)
DATA DIVISION
• Defines, describes storage for all data• Two main sections
– FILE SECTION • Defines all input and output files, records, fields• Required for any program that uses files,
typically batch programs
– WORKING-STORAGE SECTION • Defines constants, end-of-file indicators and
work areas • Defines fields not part of input or output files
90
![Page 91: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/91.jpg)
Types of Files to Define
• Input files• Master files• Transaction files
• Output files• New Master files• Report files
91
![Page 92: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/92.jpg)
File Description Entries
• Each file must be described with an FD (File Descriptor) entry
• One FD entry for each SELECT statement in ENVIRONMENT DIVISION
• FD followed by• File-name• Optional clauses to describe file and format
of its records
92
![Page 93: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/93.jpg)
File Description Format
FD file-name RECORD IS OMITTED LABEL RECORDS ARE
STANDARD
RECORD CONTAINS integer-1 CHARACTERS
BLOCK CONTAINS integer-2 RECORDS .
93
![Page 94: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/94.jpg)
BIS 1753
• PROCEDURE Division (File I/O)
94
![Page 95: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/95.jpg)
PROCEDURE DIVISION
• Interactive processing instructions
– Accept input from keyboard
– Display output on screen
• Batch processing instructions
– Access files and read them
– Write output to files
95
![Page 96: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/96.jpg)
Batch Processing File I/O
Statements to:
• Initialization activities: open files,
generate headings
• Processing activities: read records,
process, generate detail output
• Termination activities: generate footers,
close files96
![Page 97: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/97.jpg)
Batch Program Instructions
• OPEN - Open files to be processed
• PERFORM UNTIL
– Loop to repeatedly READ and process
input records, and WRITE results to output
file
• CLOSE – Close files when done processing
• STOP RUN – Terminate program execution
97
![Page 98: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/98.jpg)
Environment/Data Divisions
For each input or output file:
• Select statement: binds internal file name to external file name
• fd entry (file description entry)
• associated record
98
![Page 99: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/99.jpg)
OPEN Statement
• Accesses and makes files available for processing
• Identifies whether files will be used for input or output
99
![Page 100: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/100.jpg)
OPEN Statement
INPUT file-name-1 … OPEN OUTPUT file-name-2 …
• File-names used must appear in SELECT statement
• File must be accessed with OPEN before reading from or writing to it
FORMAT
100
![Page 101: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/101.jpg)
PERFORM statement
PERFORM paragraph-name
• To execute instructions in separate paragraph one time
• Control returns to statement following PERFORM
FORMAT
101
![Page 102: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/102.jpg)
PERFORM/UNTIL Statement
PERFORM paragraph-name UNTIL condition
• Step 1: Evaluate condition
• Step 2: If condition evaluates to false, perform paragraph one time
FORMAT
102
![Page 103: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/103.jpg)
In-Line PERFORM
PERFORM UNTIL condition statement(s) END-PERFORM
• Step 1: Evaluate condition• Step 2: If condition evaluates to false,
execute in-line statements one time
FORMAT
103
![Page 104: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/104.jpg)
READ Statement
• Reads record from file opened for input
• Makes one record available at a time, not entire file (the record is the unit of access)
• Makes data available in input file’s associated record
104
![Page 105: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/105.jpg)
READ Statement
• READ file-name-1 AT END statement-1 … [NOT AT END statement-2 …] [END-READ]
• File-name appears in SELECT statement, FD entry and OPEN
• AT END tests if there are more records
FORMAT
105
![Page 106: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/106.jpg)
READ Statement
• If no more records– Executes statement(s) after AT END– Typically statement(s) to cause loop
containing READ to end
• If more records– Reads in next record– Executes statement(s) after NOT AT END– Typically statement(s) to process record
just read
106
![Page 107: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/107.jpg)
WRITE statement
• WRITE record-name-1
• Transmits data from associated record to output file
• record-name-1 must be an associated record of a file opened for output
FORMAT
107
![Page 108: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/108.jpg)
CLOSE statement
• CLOSE file-name-1 ...
• Close specified file(s)
• Indicates files no longer needed for processing
• Releases files and deactivates devices
FORMAT
108
![Page 109: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/109.jpg)
STOP RUN
• Terminates the program
• Usually last instruction in main paragraph
• Execution “falls through” to next paragraph if STOP RUN is omitted
109
![Page 110: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/110.jpg)
110
![Page 111: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/111.jpg)
111
![Page 112: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/112.jpg)
BIS 1753
• Report Design Guidelines
112
![Page 113: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/113.jpg)
Report Design Guidelines
1. Include heading to identify report
2. Include date, page number
3. Include column headings to identify fields printed
4. Place most significant fields where they are most visible
5. Edit numeric fields for readability
113
![Page 114: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/114.jpg)
Report Design Guidelines
6. Include totals at end of page or report
7. Include page footings at end of each page, report footings at end of report
114
![Page 115: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/115.jpg)
WRITE Statement
WRITE record-name-1 [FROM identifier-1]
AFTER integer-1 LINE BEFORE identifier-2 LINES
– integer-1 or identifier-2 must be non-negative integer value
– AFTER ADVANCING prints line after paper is spaced
– BEFORE ADVANCING prints line before spacing occurs
FORMAT
ADVANCING
115
![Page 116: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/116.jpg)
Defining Print Records
• Define each type of output line as separate 01-level record in WORKING-STORAGE
• May include 01-level records for heading, detail, total, footing lines, etc.
• Establishes separate storage area for each record
• All constants and blanks may be preassigned with VALUE clauses
116
![Page 117: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/117.jpg)
WRITE … FROM Statement
• To transfer data from storage to print area and then print
• Replaces MOVE and WRITE
Write Print-Rec From Heading-1
instead of
Move Heading-1 to Print-RecWrite Print-Rec
117
![Page 118: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/118.jpg)
BIS 1753
• Tables
118
![Page 119: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/119.jpg)
Defining a Table with the OCCURS clause
01 xTempTable.
05 nTemp occurs 24 times pic S9(3).
- Indicates repeated occurrence an element with same format- Defines series of related elements with same format as a table
119
![Page 120: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/120.jpg)
Accessing Elements in Table
• Identifier nTemp is table name• Use nTemp along with a subscript to
access fields or elements within array• Subscript indicates which of the 24
elements to access
Statement OutputDisplay nTemp (2) 2 AM valueDisplay nTemp (23) 11 PM value
120
![Page 121: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/121.jpg)
Valid Subscripts• Integer literal, data item, or expression
• Valid values are 1 to number of elements in table
121
![Page 122: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/122.jpg)
Processing Elements in Table
• PERFORM VARYING perfectly suited to process the elements in a table
perform 210-processvarying nSubscript from 1 by 1until nSubscript > 24.
210-process.add nTemp(nSubscript) to nTotalTemp.
122
![Page 123: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/123.jpg)
In-line PERFORM VARYING
perform varying nSubscript
from 1 by 1 until nSubscript > 24
add nTemp (nSubscript) To nTotalTemp
end-perform.
123
![Page 124: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/124.jpg)
Elementary Items with OCCURS
• Occurs clause may be used with elementary data item
01 xTotalsTable.
05 nTotal occurs 12 times pic 9(5)V99.
• Defines xTotalstable as 84-character array (12 x 7) of 12 elementary items
124
![Page 125: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/125.jpg)
Group Items with OCCURS
• OCCURS may be used with group item
01 xTaxTable.
05 xGroup occurs 20 times.
10 xCity pic X(6).
10 nTaxRate pic V999.
• xCity and nTaxRate each occur 20 times in group item xGroup.
125
![Page 126: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/126.jpg)
Initializing Elements
• Two ways to use VALUE clause to initialize all elements to zero
01 xTable-1.
05 nTotal occurs 50 times pic 9(5) value zero.
01 xTable-2 value zero.
05 nTotal occurs 50 times pic 9(5).
126
![Page 127: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/127.jpg)
Initializing Elements
• Can also initialize each element to different value
01 xDayNames
value 'SUNMONTUEWEDTHUFRISAT'.
05 xDay occurs 7 times pic x(3).
• Defines table with 7 three-character elements. xDay(1) = SUN, xDay(2) = MON, etc.
127
![Page 128: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/128.jpg)
SEARCH Statement
SEARCH identifier-1[AT END imperative-statement-1]
WHEN condition-1 imperative-
statement-2 ...
CONTINUE[END-SEARCH]
• Use in place of PERFORM VARYING to search table
Format
128
![Page 129: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/129.jpg)
SEARCH Statement
• Identifier used after SEARCH is table name specified in OCCURS entry
• Condition compares search argument to table argument
• WHEN clause indicates action to take when condition is met
• AT END clause specifies action to take if table searched but no match found
129
![Page 130: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/130.jpg)
INDEXED BY clause
• Special field called index must be used with SEARCH
• Similar to subscript but defined along with table as part of OCCURS
05 xTableEntries occurs 1000 timesindexed By nIndex.
• Compiler automatically supplies appropriate pic clause for nIndex
130
![Page 131: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/131.jpg)
Index with SEARCH
• Must initialize index before SEARCH• SEARCH performs table look-up,
automatically incrementing index• Internally, computer can use faster
method to access table entries with an index than with a subscript, even when SEARCH not used
• Both can have values from 1 to number of table elements
131
![Page 132: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/132.jpg)
Modifying Index
• PERFORM … VARYING can modify subscript or index
• SET is only other statement that can modify index
TOSET index-name-1 UP BY integer-1
DOWN BY
Format
132
![Page 133: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/133.jpg)
Sequential Search
Each entry (usually starting with first) checked in order until
• Condition is met
• Table completely searched
133
![Page 134: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/134.jpg)
Sequential Search
Best used when
• Entries not in order by table argument value (not in numerical or alphabetical order)
• Entries can be organized so first values are ones searched for most frequently, minimizing search time
134
![Page 135: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/135.jpg)
Binary Search
• Most efficient type of look-up when table entries in sequence by some table field
• On average, takes fewer comparisons to find match than serial search
• Called binary search because each comparison eliminates half of entries under consideration
135
![Page 136: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/136.jpg)
Binary Search Statement
SEARCH ALL identifier-1[AT END imperative-statement-1]WHEN data-name-1 = identifier-2
literal-1 condition-1 arithmetic-
expression-1imperative-statement-2CONTINUE
[END-SEARCH]
Format (partial)
136
![Page 137: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/137.jpg)
SEARCH ALL Limitations
• Condition in WHEN can test only for equality between table and search argument
• Condition following WHEN may be compound– Only ANDs permitted, not Ors– Each relational test can test only for
equality
137
![Page 138: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/138.jpg)
SEARCH ALL Limitations
• Only one WHEN clause can be used• VARYING option may not be used• Table argument and its index must
appear to left of equal sign– Valid:
When nCustomerNo (X1) = nCustNoIn– Invalid:
When nCustNoIn = nCustomerNo (X1)
138
![Page 139: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/139.jpg)
Key Field
• Must include clause to indicate which table entry serves as key field
• Must specify whether KEY is– ASCENDING KEY - entries in sequence,
increasing in value– DESCENDING KEY - entries in sequence,
decreasing in value
139
![Page 140: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/140.jpg)
140
![Page 141: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/141.jpg)
141
![Page 142: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/142.jpg)
BIS 1753
• Random access files
142
![Page 143: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/143.jpg)
Disk File Organization
• File is collection of records
• Three major ways records stored or organized on disk
- Sequential File Organization
- Relative File Organization
- Indexed File Organization
143
![Page 144: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/144.jpg)
Sequential File Organization
• Records stored in order they are written to file
• Must be accessed in sequence - to access 50th record in file, must read past first 49
• Typically sorted into sequence by a key field
144
![Page 145: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/145.jpg)
Relative File Organization
• When records created, key field used to compute a disk address where record is written
• To randomly access records– User enters key field– Disk address computed from key field– Record then accessed directly
• No index needed
145
![Page 146: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/146.jpg)
Indexed File Organization
• Consists of two files– Data file - records in sequence– Index file - contains value of
• Each key field• Disk address of record with that corresponding
key field
• For random access, look up key field in index file to find address
• Then access record in data file directly146
![Page 147: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/147.jpg)
Relative Files
• Use the value of the unique identifying key value as the record number
• Records may be accessed either randomly or sequentially
147
![Page 148: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/148.jpg)
SELECT for Relative Files
• RELATIVE KEY clause– Optional if ACCESS is SEQUENTIAL– Otherwise, required
• ACCESS IS DYNAMIC allows both sequential and random access in same program
• FILE STATUS field used same way as with indexed files
148
![Page 149: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/149.jpg)
FD for Relative Files
• RELATIVE KEY not part of record– In separate WORKING-STORAGE entry
• If key is a three digit field and SELECT clause is
Relative Key is R-Key
• Entry in WORKING-STORAGE is
01 R-Key Pic 9(3).
149
![Page 150: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/150.jpg)
Creating Relative Files
• May not use a standard text editor
• Program must be written to create the relative file
• Relative files are platform-dependent; must create file on the platform on which it will be accessed
150
![Page 151: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/151.jpg)
Reading Relative Files
• (Random access) Move desired key value to RELATIVE KEY data item, then execute READ statement
• (Random access) May get invalid key condition
• (Sequential access) READ
• (Sequential access) May get at end condition
151
![Page 152: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/152.jpg)
Relative Keys
• Sometimes key field not feasible to use as relative key
• For example, a five digit Trans-No with values from 00001 to 99999 with only 1000 actual records would be wasteful– 99999 record locations would need to be
allocated but only a small portion used
152
![Page 153: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/153.jpg)
Creating an Indexed File
• Records written in sequence by key field as for sequential disk file
• Once index file created, records can be accessed randomly
153
![Page 154: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/154.jpg)
SELECT Statement
• ORGANIZATION INDEXED– Indicates index file to be created along with
data file– Index file must be established to be able to
randomly access file later
• ACCESS MODE SEQUENTIAL– Records written in sequence by key field– Optional since SEQUENTIAL is default
mode154
![Page 155: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/155.jpg)
SELECT Statement
• RECORD KEY clause– Names key field within disk record used to
form index– Must be in same physical location in each
record (usually first field)– Value must be unique for each record– Best to use numeric field as key
155
![Page 156: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/156.jpg)
WRITE … INVALID KEY
• INVALID KEY clause required when writing indexed records to handle I/O errors– Key field not in sequence– Key field same as one already in file
• If error detected with WRITE– Record not written– Statement(s) following INVALID KEY
executed156
![Page 157: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/157.jpg)
WRITE … INVALID KEY
WRITE record-name-1 [FROM identifier-1]
[INVALID KEY imperative-statement-1]
[NOT INVALID KEY imperative-statement-2]
[END-WRITE]
• Statement(s) following NOT INVALID KEY executed if WRITE is successful
Format
157
![Page 158: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/158.jpg)
READ … INVALID KEY
• To locate record with key field equal to value stored in record key
Move Trans-No To Master-No
Read Indexed-File
Invalid Key Perform 600-Err-Rtn
Not Invalid Key Perform 500-OK-Rtn
End-Read158
![Page 159: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/159.jpg)
Debugging Tips
• Must run program to create indexed file– Cannot be created using text editor
• To test an update program, always run index file creation program first
• May not be able to DISPLAY or print indexed records on your system directly– Move data to standard sequential record
first
159
![Page 160: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/160.jpg)
ALTERNATE RECORD KEY
• Clause to enable file to be accessed randomly using more than one key field– May want to access accounts receivable
records by account number or name
• Add to SELECT statement after RECORD KEY clause to establish multiple key fields for indexing
160
![Page 161: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/161.jpg)
ALTERNATE RECORD KEY
[ALTERNATE RECORD KEY IS
data-name-2 [WITH DUPLICATES] ] …
• Multiple ALTERNATE keys allowed
• Need not be unique
• Access records by RECORD KEY or any ALTERNATE RECORD KEYs
Format
161
![Page 162: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/162.jpg)
START Statement
• To begin processing indexed file sequentially starting from any record location– Print file beginning with customer record
with Acct-No = 025– Print all customers with Cst-Last-Name
beginning with letter 'S'
162
![Page 163: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/163.jpg)
START Statement
START file-name-1 IS =
KEY IS > data-name-1IS NOT <IS >=
[INVALID KEY imperative-statement-1][NOT INVALID KEY
imperative-statement-2][END-START]
Format
163
![Page 164: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/164.jpg)
ACCESS IS DYNAMIC
• Mode used to access indexed file both randomly and sequentially in single program
• For example, update selected records, then print control listing of entire indexed file– Random access used for updating– Sequential access used for printing report
164
![Page 165: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/165.jpg)
ACCESS IS DYNAMIC
• Mode required for reading records in sequence by ALTERNATE RECORD KEY
• Also required when records accessed by both RECORD KEY and ALTERNATE RECORD KEY
165
![Page 166: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/166.jpg)
READ … NEXT RECORD
• To perform sequential read of indexed file when ACCESS MODE IS DYNAMIC
• To sequentially read from file by its ALTERNATE RECORD KEY
• To begin reading sequentially from some point other than beginning of file
166
![Page 167: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/167.jpg)
FILE STATUS Clause
• To determine exact type of input or output error that occurred when accessing a file
• Included in SELECT statement for a file as last clause
SELECT …
[FILE STATUS IS data-name]
• Format
167
![Page 168: BIS 1753 Introduction to Computer Programming 1. Computer Program A set of instructions that enables a computer to process data Also called software Two](https://reader035.vdocuments.mx/reader035/viewer/2022062802/56649ec65503460f94bd21c1/html5/thumbnails/168.jpg)
FILE STATUS Clause
• Data-name must appear in WORKING-STORAGE as two-position alphanumeric field
Select Indexed-Pay-File …
File Status Is WS-Status.…Working-Storage Section.
01 WS-Status Pic X(2).
• Example
168