Cobol application using ODBC or File processing Vandana Janeja CIS 365 With COBOL OR PowerCobol.

Slides:



Advertisements
Similar presentations
Creating Data Entry Screens in Epi Info
Advertisements

DT266/2 Information Systems COBOL Revision. Chapters 1 & 2 Hutty & Spence Divisions of a Cobol Program Identification Division Program-ID. Environment.
Database Basics. What is Access? Database management system Computer-based equivalent of a manual database Makes it easy to organize and update information.
MS-Access XP Lesson 1. Introduction to MS-Access Database Management System Software (DBMS) Store data in databases Database is a collection of table.
2-1 Chapter 2.  Coding Requirements of IDENTIFICATION DIVISION  Sections of ENVIRONMENT DIVISION  Assigning Files to Devices in ENVIRONMENT DIVISION.
Accounts Payable–1099 Processing 1Freedom Systems – Accounts Payable – 1099 Processing WELCOME TO THE ACCOUNTS PAYABLE – 1099 PROCESSING WEBINAR WE WILL.
Chapter 15 Indexed Sequential Files. Disk File Organization File is collection of records Three major ways records stored or organized on disk - Sequential.
Access - Project 1 l What Is a Database? –A Collection of Data –Organized in a manner to allow: »Access »Retrieval »Use of That Data.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
A Guide to Oracle9i1 Advanced SQL And PL/SQL Topics Chapter 9.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
Introduction To Form Builder
1 of 5 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2006 Microsoft Corporation.
Figure 1. Hit analysis in 2002 of database-driven web applications Hits by Category in 2002 N = 73,873 Results Reporting 27% GME 26% Research 20% Bed Availability.
Microsoft Office Word 2013 Expert Microsoft Office Word 2013 Expert Courseware # 3251 Lesson 4: Working with Forms.
Label production Solution with Label Gallery programs Label Gallery is used for general label design and print GalleryData is used to create small database.
Advanced Tables Lesson 9. Objectives Creating a Custom Table When a table template doesn’t suit your needs, you can create a custom table in Design view.
Chapter 8 Printing 1. In COBOL you send data to the printer by writing data to a file. In COBOL, the printer is defined as a file, and it is opened, closed,
Advanced Sequential Files 1.. Single Record Type Files  In a file which contains only one record type (the kind we have examined so far) the record structure.
Recruitment Office Procedures Job Posting Requests Creating a Search Committee –Adding Search Committee MembersAdding Search Committee Members –Designating.
Copyright © 2001 by Wiley. All rights reserved. Chapter 10: Advanced Database Operations Revising Vintage Videos Setting RecordSource at run time DBGrid.
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.
Advanced Report and Form Techniques – Project 7. 2 Project 7 Overview This project shows how to create queries for reports, add command buttons to forms,
Copyright © 2007, Oracle. All rights reserved. Managing Concurrent Requests.
Programming Examples to Accompany Structure Topic Please use speaker notes for additional information!
Programming in COBOL-85 For IBM Mainframe System 390 Jyothi Sridhar Kini E&R, Infosys Mail-id: Phone:
TxEIS Security A role-based solution October 2010.
Microsoft Office 2007 Access Chapter 6 Using Macros, Switchboards, PivotTables, and PivotCharts.
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.
Printing on power systems Program/ Command Data Report Layout (Printer File) Job Output Queue *FILE Spooled File.
Basic & Advanced Reporting in TIMSNT ** Part Two **
Chapter 17 Creating a Database.
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.
Indexed and Relative File Processing
Create Lists in Millennium Jenny Schmidt SWITCH Library Consortium.
1 The Procedure Division Chapter 4. 2 Main Two Sections File Section –Used to define files and record formats –Field names within records Working Storage.
CPSC3111/CISM3111 COBOL Structured COBOL Programming Text: murach’s structured COBOL Authors: Murach, Prince, Menendez.
Microsoft Access 2010 Chapter 10 Administering a Database System.
Advanced samples Printing two types of labels from two different custom forms We have two different labels that contain the same data. One is suitable.
Microsoft Access 2013 ®® Tutorial 10 Automating Tasks with Macros.
Explanation of SAMPLEIF (if88in1.cbl or if88in1.html) Please use speaker notes for additional information!
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 3 BACKNEXTEND 3-1 LINKS TO OBJECTIVES Modify a Table – Add, Delete, Move Fields Modify a Table.
Any Questions!. Test Coming Up! Agenda Printing with Externally Described Printer Files Arrays.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
1 Chapter 5 – The Procedure Division File handling statements –OPEN statement Initiates processing for a file Input Output Each file opened must have been.
Chapter 9: Advanced SQL and PL/SQL Guide to Oracle 10g.
Gold – Crystal Reports Introductory Course Cortex User Group Meeting New Orleans – 2011.
1.  Introduction  The Benefits of the Report Writer Module ◦ For Detail and Summary Printing ◦ For Control Break Processing ◦ For Printing Headings.
Any Questions? Week 1 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Analysis of SAMPLE1.CBL Please check speaker notes for additional information!
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 1 ® Database & Table.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
Chapter 5 Introduction To Form Builder. Lesson C Objectives  Use sequences to automatically generate primary key values in a form  Create lists of values.
Week 2/3 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
Random update Please use speaker notes for additional information!
Introduction to Sequential Files. COBOL's forte  COBOL is generally used in situations where the volume of data to be processed is large.  These systems.
Creating Data Base & Sql Data Source
Submitting Instructions on web site CS 1024 students Read guide
Practical Office 2007 Chapter 10
Any Questions?.
Chapter 3 The DATA DIVISION.
An Introduction to Structured Program Design in COBOL
Programming in COBOL-85 For IBM Mainframe System 390
Creating Data Base & Sql Data Source
CHAPTER 17 The Report Writer Module
Word: References & Workflow Participation Project
Chapter 8 - Visual Basic Schneider
Presentation transcript:

Cobol application using ODBC or File processing Vandana Janeja CIS 365 With COBOL OR PowerCobol

ODBC from Control panel\administrative tools ODBC from control panel\administrative tools When you create a database in MS.Access be careful not to use COBOL keywords as you will need to access the fields by their name and COBOL will give you an error if it’s a reserved word.

Creating an ODBC DSN name

Creating a form in Power Cobol Bringing out the control box from power Cobol

Selecting controls to place on the form Pulling out properties by double clicking the control

Changing properties of the DBAccess control; specifically the DSN name specification

Pulling out the procedure for a control; currently no control is selected so the procedure of the sheet/form will be opened so that we can add global variables Data Control with the specifications of ODBC(DSN name)

Trapping the click event of the button

Adding the relevant code for database connection button Similarly other code can be added to other buttons.

DBAccess Control OPENDB Opens a data source. CLOSEDB Closes a data source. SELECTRECORDS Select the record group you want to process. READNEXTRECORD Reads records one by one from the record group selected by SELECTRECORDS. WRITERECORD Adds one record to the table. REWRITERECORD Updates a record in the table. DELETERECORD Deletes a record in the table. COMMITDB Performs commit processing in manual commit mode. ROLLBACKDB Performs roll-back processing in manual commit mode.

PUSH1 CLICK event procedure is: DATA DIVISION. WORKING-STORAGE SECTION. PROCEDURE DIVISION. CALL OPENDB OF ODBC1. CALL SELECTRECORDS OF ODBC1.. CALL CLOSEDB OF ODBC1.

PUSH1 CLICK event procedure for writing a record DATA DIVISION. WORKING-STORAGE SECTION. 77 WORKNOPIC 9(4). 77 WORKNAMEPIC X(32). 77 WORKPHONENOPIC X(64). PROCEDURE DIVISION.. MOVE WORKNO TO EMPLOYNO OF ODBC1.(OR Move POW-TEXT of Edit1 to Empno of ODBC1) MOVE WORKNAMETO EMPLOYNAME OF ODBC1. MOVE WORKPHONENOTO PHONENOOF ODBC1. CALL WRITERECORD OF ODBC1. Insert Record Button

For insert the ODBC should not be readOnly: check this in the DBAccess as ff: V.IMPORTANT ReadOnly option should be unchecked if you have to insert records

PUSH1 CLICK event procedure is: DATA DIVISION. WORKING-STORAGE SECTION. 77 WORKNO PIC 9(4). 77 TEMPNO PIC 9(4) PROCEDURE DIVISION. PERFORM LOOP…………CALL READNEXTRECORD OF ODBC1. MOVE POW-TEXT OF EDIT1 TO TEMPNO. MOVE EMPLOYNO OF ODBC1 TO WORKNO. IF WORKNO = TEMPNO THEN MOVE "Smith"TO EMPLOYNAME OF ODBC1 MOVE " " TO PHONENO OF ODBC1 END-IF. CALL REWRITERECORD OF ODBC1. Update Record Button

PUSH1 CLICK event procedure is: DATA DIVISION. PROCEDURE DIVISION.. IF PHONENO OF ODBC1 = " " THEN MOVE 1234TO EMPLOYNO OF ODBC1 MOVE "Brown"TO EMPLOYNAME OF ODBC1 END-IF. CALL DELETERECORD OF ODBC1. All records having EMPLOYNO "1234" and EMPLOYNAME "Brown" are deleted. Delete Record button

Click on run and it will automatically compile and build and link and basically create an exe for you

Click ok to all messages and if there are no errors you should see the output application

Cobol pseudocode / Flowchart for Cobol application Accept choice from User Insert/Update/Delete Update Process Insert Process Delete Process Accept choice from User Insert/Update/Delete While Choice Not Exit

IF choice =“I” INSERTION IF choice=“D” DELETION IF choice=“U” UPDATING IF choice=“P” PRINTMODULE Else Exit.

INSERTION Accept Working or temporary variables Check If record exists If not Insert File opening mode I-O, Read file first for searching the record. Once not found use the “ Write “ verb Else display a message that record already exists

Accept Working or temporary variables Check If record exists If yes Update Old record with New Record Use REWRITE EMPLOYEE-RECORD UPDATING

Accept Working or temporary variables Check If record exists If yes Delete Create a New file without the deleted record Have an additional field which can be set to “D” for a deleted record, and this file can be periodically renewed. DELETION

PRINTMODULE

Printing a Report. A report is made up of groups of printed lines of different types. What types of line are required for the Student Details Report?  The report, will be based on the Data File  The report will show the details of the records of students

Report Print Lines. Page Heading. –UL Student Details Report Page Footing. – Page : PageNum Column Headings. –Student Id. Student Name Gender Course Student Detail Line. –StudentId. StudentName Gender CourseCode Report Footing. –*** End of Student Details Report ***

Describing Print Lines. 01 PageHeading. 02 FILLER PIC X(7) VALUE SPACES. 02 FILLER PIC X(25) VALUE "UL Student Details Report". 01 PageFooting. 02 FILLER PIC X(19) VALUE SPACES. 02 FILLER PIC X(7) VALUE "Page : ". 02 FILLER PIC ColumnHeadings PIC X(36) VALUE " StudentId StudentName Gender Course". 01 StudentDetailLine. 02 PrnStudId PIC BB9(7). 02 PrnStudName PIC BBX(10). 02 PrnGender PIC BBBBX. 02 PrnCourse PIC BBBBX(4). 01 ReportFooting PIC X(38) VALUE "*** End of Student Details Report ***". The Print Lines are all different record types!

The File Buffer All data coming from, or going to, the peripherals must pass through a file buffer declared in the File Section. The file buffer is associated with the physical device by means of a Select and Assign clause. In previous lectures we saw that the file buffer is represented by a record description (01 level). But the different types of line that must appear on our report are declared as different record types. How can we declare these different record types in the File Section? ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT Printer ASSIGN TO “LPT1”. DATA DIVISION. FILE SECTION. FD Printer. 01 PrintLine. ????????????????

No VALUE clause in the FILE SECTION. Defining a file buffer which is used by different record types is easy (as we have seen). But !! These record types all map on to the same area of storage and print line records cannot share the same area of storage. Why? Because most of the print line record values are assigned using the VALUE clause and these values are assigned as soon as the program starts. To prevent us trying to use the VALUE clause to assign values to a File buffer COBOL has a rule which states that; In the FILE SECTION, the VALUE clause must be used in condition-name entries only (i.e. it cannot be used to give an initial value to an item).

A Solution We define the print records in the WORKING- STORAGE SECTION. We create a file buffer in the FILE SECTION which is the size of the largest print record. We print a line by moving the appropriate print record to the file buffer and then WRITE ing the contents of the file buffer to the device. We get round the problem as follows;

ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT ReportFile ASSIGN TO “STUDENTS.RPT”. DATA DIVISION. FILE SECTION. FD ReportFile. 01 PrintLine PIC X(38). WORKING-STORAGE SECTION. 01 PageHeading. 02 FILLER PIC X(7) VALUE SPACES. 02 FILLER PIC X(25) VALUE "UL Student Details Report". 01 PageFooting. 02 FILLER PIC X(19) VALUE SPACES. 02 FILLER PIC X(7) VALUE "Page : ". 02 FILLER PIC ColumnHeadings PIC X(36) VALUE " StudentId StudentName Gender Course". 01 StudentDetailLine. 02 PrnStudId PIC BB9(7). 02 PrnStudName PIC BBX(10). 02 PrnGender PIC BBBBX. 02 PrnCourse PIC BBBBX(4). 01 ReportFooting PIC X(38) VALUE "*** End of Student Details Report ***". STUDENTS.RPT DISK

WRITE Syntax revisited. When we are writing to a printer or a print file we use a form of the WRITE command different from that we use when writing to a sequential file.

ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT ReportFile ASSIGN TO "STUDENTS.RPT" ORGANIZATION IS LINE SEQUENTIAL. DATA DIVISION. FILE SECTION. FD ReportFile. 01 PrintLine PIC X(40). WORKING-STORAGE SECTION. 01 HeadingLine PIC X(21) VALUE " Record Count Report". 01 StudentTotalLine. 02 FILLER PIC X(17) VALUE "Total Students = ". 02 PrnStudentCount PIC Z,ZZ9. 01 MaleTotalLine. 02 FILLER PIC X(17) VALUE "Total Males = ". 02 PrnMaleCount PIC Z,ZZ9. 01 FemaleTotalLine. 02 FILLER PIC X(17) VALUE "Total Females = ". 02 PrnFemaleCount PIC Z,ZZ9. MOVE StudentCount TO PrnStudentCount MOVE MaleCount TO PrnMaleCount MOVE FemaleCount TO PrnFemaleCount WRITE PrintLine FROM HeadingLine AFTER ADVANCING PAGE WRITE PrintLine FROM StudentTotalLine AFTER ADVANCING 2 LINES WRITE PrintLine FROM MaleTotalLine AFTER ADVANCING 2 LINES WRITE PrintLine FROM FemaleTotalLine AFTER ADVANCING 2 LINES. STUDENTS.RPT DISK