CPSC3111CISM3111 COBOL - PowerPoint PPT Presentation

1 / 34
About This Presentation
Title:

CPSC3111CISM3111 COBOL

Description:

10 FILLER PIC X(80). FD PRINT-FILE. 01 PRINT-REC. 10 FILLER PIC X(132). WORKING-STORAGE. WORKING-STORAGE SECTION. Program's scratchpad' ... – PowerPoint PPT presentation

Number of Views:114
Avg rating:3.0/5.0
Slides: 35
Provided by: neallr
Category:

less

Transcript and Presenter's Notes

Title: CPSC3111CISM3111 COBOL


1
CPSC3111/CISM3111 COBOL
  • Structured COBOL Programming
  • Text murachs structured COBOL
  • Authors Murach, Prince, Menendez

2
What is a Computer?
  • Components of a Computer
  • Input Unit(s) Keyboard, tape, disks
  • Output Unit(s) CRT, tape, disks
  • Memory (Storage) units Addresses
  • Control Unit (Executes Instructions)
  • Arithmetic/Logic Unit (Math and Logic)
  • Only understands machine language

3
Hardware / Software
  • Hardware Physical equipment
  • Software Programs, commands, etc.
  • System O/S, compilers, utilities, etc.
  • Application User or third party supplied.
  • Languages Assembler, Basic(VB), Fortran, RPG,
    Easytrieve, C, C, C, Ada, Java,
  • Compilers job - translate source language to
    machine language (or byte code)

4
Online vs Interactive
  • Off-line batch
  • Local Batch
  • Remote Batch
  • Online Interactive
  • Many users with terminals (PCs)
  • Can be either local or remote
  • Single/Multiple User - Timesharing

5
Data Organization
  • Bit - Binary digIT - on/off or 1/0
  • Character - byte (8 Bits)
  • Field - One or more Bytes (Characters)
  • Record - One or more Fields
  • File - One or more Records
  • Database - One or more Files
  • Usually contains metadata

6
Report Components
  • Page Heading
  • Column Headings
  • Report Body
  • Possibly with subtotals, etc.
  • Summary
  • Final totals, summary totals, etc.

7
Program Design
  • Program
  • Sequence of instructions describing actions to be
    taken by the computer
  • Flowchart
  • Graphical description of program logic
  • Uses rectangles, diamonds, ovals, etc
  • Pseudocode
  • Symbolic representation of program logic
  • More ENGLISH-like

8
Data Information Needed
  • Type and Size
  • Types
  • Alphabetic (Seldom used A)
  • Alphanumeric (X)
  • Numeric (Sign and Decimal)
  • Binary
  • Numeric
  • Packed Numeric
  • Floating Point, etc. (Compatibility)

9
Program Development
  • Define problem
  • Design test data
  • Design program
  • Code program
  • Compile program
  • Test program
  • Document Program

10
Identifier Rules
  • 30 Character Maximum
  • A-Z, a-z, 0-9, - Characters
  • - not first or last character
  • Usually at least 1 alphabetic

11
CARD FORMAT
  • 01 - 06 Line Numbers (XNU)
  • 07 Comment / Debug
  • 08 - 11 Margin A
  • 12 - 72 Margin B
  • 73 - 80 Identification (XNU)

12
COBOL Divisions
  • IDENTIFICATION DIVISION.
  • ENVIRONMENT DIVISION.
  • DATA DIVISION.
  • PROCEDURE DIVISION.
  • Divisions can be divided into SECTIONS
  • Sections can be divided into PARAGRAPHS
  • Paragraphs are composed of SENTENCES

13
IDENTIFICATION
  • IDENTIFICATION DIVISION.
  • PROGRAM-ID. PROG1.
  • All other entries are obsolete
  • An in cc07 can be used (Comment)

14
ENVIRONMENT
  • ENVIRONMENT DIVISION.
  • INPUT-OUTPUT SECTION.
  • FILE-CONTROL.
  • SELECT INPUT-FILE
  • ASSIGN TO MYINFILE.
  • SELECT PRINT-FILE
  • ASSIGN TO MYREPORT.

15
ENVIRONMENT (SELECTS)
  • SELECT PRINT-FILE ASSIGN TO
  • \RMC\DATA\INPUT.DAT.
  • (For PC Files)
  • SELECT PRINT-FILE
  • ASSIGN TO PRINTER-QPRINT.
  • (For AS400 Files)

16
DATA
  • DATA DIVISION.
  • FILE SECTION.
  • FD INPUT-FILE.
  • 01 INPUT-REC.
  • 10 FILLER PIC X(80).
  • FD PRINT-FILE.
  • 01 PRINT-REC.
  • 10 FILLER PIC X(132).

17
WORKING-STORAGE
  • WORKING-STORAGE SECTION.
  • Programs scratchpad
  • LEVEL NUMBERS 01-49
  • 01 STARTS IN COLUMN 8
  • 02-49 COLUMN 12 AND UP
  • Usually use 05, 10, 15, 20,
  • EACH 01 IS A NEW RECORD
  • All fields must be specified

18
PROCEDURE
  • PROCEDURE DIVISION.
  • 010-START-HERE.
  • (INITIALIZATION)
  • (PROCESS CONTROL LOOP)
  • (TERMINATION)

19
OPEN
  • OPEN INPUT file-name
  • OPEN OUTPUT file-name
  • (Gets files ready for processing)

20
ACCEPT
  • ACCEPT identifier FROM DATE
  • identifier will contain YYMMDD
  • ACCEPT identifier FROM TIME
  • identifier will contain HHMMSSMS
  • (Used to get date and time)
  • ACCEPT identifier options
  • Gets data from keyboard

21
MOVE
  • MOVE identifier-1 TO identifier-2
  • (Alpha - Left Just. - Space Filled)
  • (Numeric - decimal aligned)
  • (Edited - follows edit characters)

22
READ
  • READ file-name into WS-name
  • AT END
  • ANY IMPERATIVE STATEMENT(S)
  • END-READ
  • READ INPUT-FILE INTO WS-IN-REC
  • AT END
  • MOVE YES TO EOF-FLAG
  • END-READ

23
WRITE (Generic)
  • WRITE record-name FROM ws-name
  • AFTER ADVANCING identifier LINES
  • END-WRITE
  • WRITE PRINT-REC FROM WS-PRINT-REC
  • AFTER ADVANCING WS-SPACING
  • END-WRITE

24
WRITE (New-Page)
  • MOVE SPACES TO PRINT-REC
  • WRITE PRINT-REC
  • AFTER ADVANCING PAGE
  • END-WRITE
  • (Used to start new page for heading.)

25
PERFORM
  • PERFORM Paragraph-name
  • PERFORM Paragraph-name
  • UNTIL Condition
  • PERFORM 100-READ-INPUT
  • PERFORM 300-PROCESS-DATA
  • UNTIL EOF-FLAG YES

26
ADD
  • ADD literal TO identifier-1
  • ADD 1 TO REC-COUNT
  • ADD identifier-1 TO identifier-2
  • ADD WS-SPACING TO WS-LINES

27
Decisions - Simple
  • IF Condition-1
  • True Statements
  • END-IF

28
Relational Conditions
  • gt GREATER THAN
  • lt LESS THAN
  • EQUAL TO
  • gt GREATER OR EQUAL
  • lt LESS OR EQUAL
  • NOT can be used with all of the above

29
Decisions - ELSE
  • IF condition-1
  • True Statements
  • ELSE
  • False Statements
  • END-IF

30
Decisions - Examples
  • IF HOURS-WORKED gt 40
  • PERFORM 350-CALC-OVERTIME
  • ELSE
  • PERFORM 360-CALC-REGTIME
  • END-IF

31
Decisions - complex
  • IF complex-condition
  • True statements
  • ELSE
  • False statements
  • END-IF

32
Complex - conditions
  • Two or more simple conditions connected with
    AND or OR.
  • IF (DEPARTMENT 234 AND
  • HIRE-DATE lt 96-06-01)
  • ADD 1 TO OVER-5-YEARS
  • END-IF

33
CLOSE
  • CLOSE file-name
  • CLOSE INPUT-FILE
  • (Terminate file processing.)

34
GOBACK / STOP RUN
  • GOBACK.
  • (Returns to calling entity.)
  • STOP RUN.
  • (Returns to Operating System)
Write a Comment
User Comments (0)
About PowerShow.com