Any Questions!. Agenda Fun with Functions –how to get the system date Condition Names INDARA and SI Iteration Logical Files Positioning the file pointer.

Slides:



Advertisements
Similar presentations
DT266/2 Information Systems COBOL Revision. Chapters 1 & 2 Hutty & Spence Divisions of a Cobol Program Identification Division Program-ID. Environment.
Advertisements

Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
2-1 Chapter 2.  Coding Requirements of IDENTIFICATION DIVISION  Sections of ENVIRONMENT DIVISION  Assigning Files to Devices in ENVIRONMENT DIVISION.
CL Programming with Database Files Updated Fall 2010.
Chapter 15 Indexed Sequential Files. Disk File Organization File is collection of records Three major ways records stored or organized on disk - Sequential.
Processing with VSAM Files Please use speaker notes for additional information!
Chapter 5: Loops and Files.
VSAM KSDS and COBOL Department of Computer Science Northern Illinois University August 2005 Some of the illustrations are from VSAM: Access Method Services.
15-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Relative Files.. Creating a Relative File $ SET SOURCEFORMAT"FREE" IDENTIFICATION DIVISION. PROGRAM-ID. CreateRelativeFromSeq. * Creates a Relative file.
4-1 Coding Complete COBOL Programs: The PROCEDURE DIVISION Chapter 4.
4-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
4-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
1 Chapter 4. To familiarize you with methods used to 1. Access input and output files 2. Read data from an input file 3. Perform simple move operations.
Chapter To familiarize you with  Why COBOL is a popular business-oriented language.  Programming practices and techniques  History of COBOL.
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
History COBOL (Common Business Oriented Language) was one of the earliest high-level programming languages. COBOL was first proposed in 1959 by the Conference.
Programming Examples to Accompany Structure Topic Please use speaker notes for additional information!
COBOL Cobol is one of the most robust language in the software field, so far Cobol turned 50, in 2009 Cobol has stood the test of time Common Business.
Programming in COBOL-85 For IBM Mainframe System 390 Jyothi Sridhar Kini E&R, Infosys Mail-id: Phone:
Logic Structure - focus on looping Please use speaker notes for additional information!
Lecture 31 Numeric Edited Alphabetic (A) AlphaNumeric (X) Numeric (9, V, S) Numeric Edited (9, Z, comma, decimal point, minus sign) –Z = zero suppressed.
The DATA DIVISION Chapter 3. COBOL Data Organization Field - group of characters forming a meaningful unit or basic fact –Characters in a name or digits.
3-1 Chapter 3. To familiarize you with  Ways in which data is organized in COBOL  Rules for forming data-names  Defining input and output files in.
1 Interactive vs Batch Programs Cobol suited for developing both types of programs Interactive programs Accept input data from keyboard Input data processed.
Printing on power systems Program/ Command Data Report Layout (Printer File) Job Output Queue *FILE Spooled File.
Chapter 7 File I/O 1. File, Record & Field 2 The file is just a chunk of disk space set aside for data and given a name. The computer has no idea what.
Set path vs current schema. Set Current Schema ‘The CURRENT SCHEMA special register specifies a VARCHAR(128) value that identifies the schema name used.
Indexed and Relative File Processing
Statement Syntax1 THE SELECT STATEMENT Purpose: designates a file and points to its physical location Syntax Definition : SELECT file-name-1 ASSIGN TO.
CPSC3111/CISM3111 COBOL Structured COBOL Programming Text: murach’s structured COBOL Authors: Murach, Prince, Menendez.
9-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout.
More Syntax in COBOL  Moving Data  Selection Statements  System Date  Indicators in Display files.
IBC233 Lecture 2 Updated Winter 2008 Agenda Test next Week – Jan 23 ISeries Architecture CL (Control Language) Library Lists Operations Navigator.
11- 1 Chapter 11.  Avoiding Logic Errors by Validating Input  What to Do If Input Errors Occur  Global Considerations in COBOL  When Data Should Be.
Any Questions!. Test Coming Up! Agenda Printing with Externally Described Printer Files Arrays.
COBOL Screens Please use speaker notes for additional information!
Week 4 presentation! This week we will cover editing and the use of the on-board tools provided, SEU and PDM.
1 Chapter 5 – The Procedure Division File handling statements –OPEN statement Initiates processing for a file Input Output Each file opened must have been.
1 Chapter 9. To familiarize you with  Simple PERFORM  How PERFORM statements are used for iteration  Options available with PERFORM 2.
13-1 Sequential File Processing Chapter Chapter Contents Overview of Sequential File Processing Sequential File Updating - Creating a New Master.
2-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Any Questions!. Agenda Fun with Functions –how to get the system date –How to get the next service date INDARA and SI Condition Names Iteration Logical.
13- 1 Chapter 13.  Overview of Sequential File Processing  Sequential File Updating - Creating a New Master File  Validity Checking in Update Procedures.
Loops and Files. 5.1 The Increment and Decrement Operators.
1 Standard Version of Starting Out with C++, 4th Brief Edition Chapter 5 Looping.
Any Questions? Week 1 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
This is It! It’s been a pleasure! Final Exam – format True / false 5 Multiple choice 5 Short answers10 Data manipulation10 SQL 3 Array’s12 File processing25.
Analysis of SAMPLE1.CBL Please check speaker notes for additional information!
11- 1 Chapter 11.  Avoiding Logic Errors by Validating Input  What to Do If Input Errors Occur  Global Considerations in COBOL  When Data Should Be.
Chapter 4 PROCEDURE DIVISION. Paragraphs PROCEDURE DIVISION divided into paragraphs Each is independent module or routine Made up of series of instructions.
Any Questions!. Agenda Fun with Functions Externally Described Files Condition Names Iteration Logical Files Random Reads.
Week 2/3 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
Random update Please use speaker notes for additional information!
How’s assignment 1 coming? Winter 2007
IBC233 Week 6.
Programming in COBOL.
Keyboard Input and Screen Display ––––––––––– Interactive Programming
Designing and Debugging Batch and Interactive COBOL Programs
Any Questions?.
Chapter 3 The DATA DIVISION.
Agenda Test next Week! SI or no SI? File Update Techniques – Review.
Chapter 14 Sorting and Merging.
Programming in COBOL-85 For IBM Mainframe System 390
Agenda Collating sequence / Sorting data
Data Groupings: File File: a group of related records
Any Questions?.
IBC233 Week 5.
Presentation transcript:

Any Questions!

Agenda Fun with Functions –how to get the system date Condition Names INDARA and SI Iteration Logical Files Positioning the file pointer

IBM Library COBOL reference links IBM Boulder, Colorado library COBOL Programmers Manual

Fun with Functions Refer to COBOL Intrinsic functions handout Move FUNCTION CURRENT DATE (1:8) to …

Condition Names Used with Code Fields –Eg. ARE-THERE-MORE-RECORDS –Eg. FINAL-GRADE –Eg. Indicators

Condition Names 01 ARE-THERE-MORE-RECORDS PIC X(3) VALUE ‘YES’. 88 THERE-ARE-MORE-RECORDS VALUE ‘YES’. 88 END-OF-FILEVALUE ‘NO’. IF THERE-ARE-MORE-RECORDS READ EMPLOYEE-FILE. IF END-OF-FILE PERFORM TERMINATION-RTN.

Set Verb Used to initialize fields to a Condition- Name. 01 ARE-THERE-MORE-RECORDS PIC X(3). 88 THERE-ARE-MORE-RECORDS VALUE ‘YES’. 88 END-OF-FILEVALUE ‘NO’. SET END-OF-FILE TO TRUE.

Conditions Cont’d 01 WORK-DAYS PIC X(3). 88 MONDAY VALUE ‘MON’. 88 TUESDAY VALUE ‘TUE’. 88 WEDNESDAY VALUE ‘WED’. 88 THURSDAY VALUE ‘THU’ 88 FRIDAY VALUE ‘FRI’. SET MONDAY TO TRUE. IF FRIDAY DISPLAY ‘GO HOME EARLY’.

Conditions Cont’d 01 FALL-MONTHS PIC X(3). 88 SEPTEMBER VALUE ‘SEP’. 88 OCTOBER VALUE ‘OCT’. 88 NOVEMBERVALUE ‘NOV’. 88 DECEMBER VALUE ‘DEC’. IF OCTOBER DISPLAY ‘HAPPY HALLOWEEN!!’ SET DECEMBER TO TRUE.

INDARA and SI The relation ship between the externally declared (DDS) interactive screen file and the COBOL internally declared indicator usage area

As externally defined and created in DDS A DSPSIZ(24 80 *DS3) A INDARA In file area (GLOBAL) A CA03(03 'Function Key 03 = A CA12(12 'Function Key 12 = A R SCREEN A 1 9'ENTER' in RECORD area (LOCAL) A 1 26'PAYROLL DEPARTMENT' A 1 59'C1401.1' A 3 2'Type choice, press Enter.' A 5 4'Employee number..' A EEMPNO 5D 0I 5 24ALIAS(SCR1_EMPLOYEE_NUMBER) A 99 ERRMSG('Employee number not A Re-enter valid number.' A 23 2'F3=Exit'

SI special indicators - send to the screen for screen behavior / action Control-area - keyed response received form the “screen” FILE-CONTROL SELECT DISPLAY-FILE ASSIGN TO WORKSTATION-HM100DSP-SI ORGANIZATION IS TRANSACTION CONTROL-AREA IS WS-CONTROL DATA DIVISION FILE SECTION *File Definition for a Program Described File FD DISPLAY-FILE DISPLAY-RECORD COPY DD-ALL-FORMATS OF HM100DSP WORKING-STORAGE SECTION.

indicators RESPONSE and RESULTING WS-CONTROL WS-FUNCTION-KEY PIC X(2) WS-FUNCTION-KEY-03 VALUE '03' NO-FUNCTION-KEY-WAS-PRESSED VALUE '00' WS-DEVICE-NAME PIC X(10) WS-RECORD-FORMAT PIC X(10) WS-INDICATOR-LIST IN99 INDICATOR 99 PIC 1 VALUE B'0' INCORRECT-ACTION-CODE VALUE B'1' CORRECT-ACTION-CODE VALUE B'0' IN98 INDICATOR 98 PIC 1 VALUE B'0' INVALID-HORSE VALUE B'1' VALID-HORSE VALUE B'0' IN97 INDICATOR 97 PIC 1 VALUE B'0' REPORT-PRINTED VALUE B'1' REPORT-NOT-PRINTED VALUE B'0'.

Program check and response logic EVALUATE TRUE screen variable WHEN SCR1-ACTION-CODE OF PROMPT-I = 'P' PERFORM 210-print-rtn WHEN OTHER SET INCORRECT-ACTION-CODE TO TRUE END-EVALUATE if not ws-function-key move save-action to scr1-action-code of prompt-o move save-horse to scr1-horse-code of prompt-o * Write the prompt screen to the screen WRITE DISPLAY-RECORD FORMAT IS 'PROMPT ' INDICATORS ARE WS-INDICATOR-LIST end-write * Wait for input READ DISPLAY FILE RECORD

Option Indicators and Conditions 01 WS-indicators. 05 IN90 INDICATOR 90 PIC display-message value B’1’. 88 dont-display-message value B’0’. Set display-message to true. Set dont-display-message to true. If display-message If don’t-display-message If not display-message

Response Indicators and Conditions 01 WS-Control. 05 ws-function-key pic x(2). 88 F3 value ’03’ 88 F12 value ’12’. 88 Enter value ’00’ 05 ws-device-name pic x(10). 05 ws-record-format pic x(10). If F3 If not F3

Iteration Looping

BASIC Perform Statement PERFORM (paragraph-name)

Basic PERFORM READ Emp-File PERFORM DSP-Rtn STOP RUN DSP-RTN move emp-in to emp- out. write dsp-record format is ‘SCREEN’. read dsp-file record.

PERFORM Until PERFORM paragraph-name UNTIL Condition

PERFORM Until Condition Met? Execute Program Statements NO YES

PERFORM Until READ Emp-File AT END Move ‘YES’ TO EOF. PERFORM Dsp-Rtn UNTIL EOF = ‘Y’ STOP RUN DSP-RTN move emp-in to emp-out. write dsp-record format is ‘SCREEN’. read dsp-file RECORD. read emp-file at end move ‘YES’ to EOF.

PERFORM X Times PERFORM (paragraph-name) THROUGH/THRU (paragraph-name) (integer/variable) TIMES

PERFORM X Times Number of Times Met? Execute Program Statements NO YES

PERFORM X Times READ Emp-File AT END Move ‘YES’ TO EOF. PERFORM Dsp-Rtn 5 TIMES STOP RUN DSP-RTN move emp-in to emp- out. write dsp-record format is ‘SCREEN’. read dsp-file record.

PERFORM With Test After PERFORM (paragraph-name) THROUGH/THRU (paragraph-name) WITH TEST AFTER UNTIL Condition

PERFORM With Test After Condition Met? Execute Program Statements NO YES

PERFORM With Test After READ Emp-File AT END Move ‘YES’ TO EOF. PERFORM Dsp-Rtn WITH TEST AFTER UNTIL EOF = ‘Y’ STOP RUN DSP-RTN move emp-in to emp-out. write dsp-record format is ‘SCREEN’. read dsp-file record. read emp-file AT END MOVE ‘YES’ TO EOF.

PERFORMs within PERFORMs READ Emp-File AT END Move ‘YES’ TO EOF. PERFORM DSP-Rtn UNTIL 5 TIMES STOP RUN DSP-RTN MOVE EMP-IN TO EMP-OUT. PERFORM Write-Rtn

Iteration Statement to Use? Perform Until –Tests for the condition first –Statements are executed only if the condition is true Perform With Test After –tests for the condition last –Statements are always executed at least once

Iteration Statement to Use? Perform X Times –Use this when you know the number of times the paragraph(s) are to be executed.

Sorting Data Using Access Paths

Physical Files vs Logical Files EMPLOYEEPF *FILE EMPLOYEE *FILE Physical Files or Logical Files?

Externally Described Files Select Statement when physical/logical file has a key. SELECT Cobol-file-name ASSIGN TO database-actual-file-name [ORGANIZATION IS INDEXED] [ACCESS MODE IS SEQUENTIAL] RECORD KEY is data-element. (data-element could be EXTERNaLLY-DESCRIBED-KEY)

Externally Described Files Copying the record layout. FD Cobol-file-name. 01 Cobol-Record-Name. COPY DD-actualrecordname OF actualfilename. (DD can be replaced by DDS if you require the 10 char field names instead of the aliases)

Handy Physical File Commands DSPPFM – Display Physical File Member Displays the contents of a Physical File in arrival sequence. DSPFD – Display File Description Information about the file – eg access path. DSPFFD – Display File Field Description Displays the fields in the file.

Positioning the File Pointer Start Verb

Used only with Sequentially defined files. Initialize the record key START file-name Key Condition INVALID KEY Perform Invalid-Logic NOT INVALID KEY Perform valid-logic END-START.