1 / 34

Introduction to Structured Program Design in COBOL

Learn about the basics of structured program design in COBOL, including the different types of computer programs, program languages, and the COBOL standard versions. Understand the program development process, coding techniques, and program testing. Discover the benefits of structured programming and top-down programming approaches. Explore the differences between interactive and batch programs, and get a glimpse into creating a report in COBOL.

hoke
Download Presentation

Introduction to Structured Program Design in COBOL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 1 An Introduction to Structured Program Design in COBOL

  2. Computer Program • A set of instructions that enables computer to process data • Also called software • Two types of computer programs • Operating system programs - control overall operations of computer • Applications programs - perform tasks required by users

  3. Applications Programs • Written by applications programmer • May provide quick solution to one-time problem • Displaying average grade for set of exam scores • Or may be run on regularly scheduled basis • Program to print student transcripts each semester

  4. Program Languages Machine language • Only language computer understands • All programs executed on computer must be in machine language • Machine language programs are difficult to write

  5. Program 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

  6. Nature of COBOL • Business-oriented language • Standard language • English-like language • Relatively easy to understand

  7. 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 Standard Versions of COBOL

  8. Program Development Process • Determine Program Specifications • Design Program Using Program Planning Tools • Code and Enter Program • Compile Program • Test Program • Document Program

  9. 1. Program Specifications • Systems analysts, users and programmers develop specifications • Specifications include: • Description of input and output data • Step-by-step processing required to convert input to output

  10. 2. Design the Program Program planning tools used to map out structure and logic of program • Flowcharts use block diagrams to represent logic • Pseudocode uses English-like statements • Hierarchy charts (a.k.a. structure charts) show relationships among sections of program

  11. 3. Code and Enter Program • Programmer writes and enters program into computer • Program written in symbolic language (like COBOL) • Called source program

  12. 4. Compile Source Program Compiler is program that • Checks source program for rule violations • Translates source program into object program Source program in symbolic language Translatedbycompiler Object program in machine language

  13. 5. Test Program • Test or debug program to ensure it contains no errors • Check for two types of errors • Compile-Time Errors • Execution Errors

  14. 6. Document the Program • Documentation - formal set of procedures and instructions to specify how to use program • Written for • Those working with output • Computer operators who run program • Maintenance programmers who make modifications to program

  15. Improving Program Design Two techniques used to develop programs that are easier to understand, test, debug and modify • Structured Programming • Top-Down Programming

  16. Structured Programming • Eliminates use of GO TO statements • Allowed skipping to different sections of program without returning to starting point • Program logic easier to follow with "GO-TO-less" programming

  17. Structured Programming Program divided into paragraphs • Main paragraph or module controls logic flow using PERFORM statements • Main module "performs" other modules when instructions in that module required • Each module can be written and tested independently of others

  18. Top-Down Programming • Another technique to make programs easier to understand, test, debug and modify • Develop program like term paper • Develop outline first • Add details for each of main steps • Add further refinement for more complex steps

  19. Top-Down Programming For COBOL program • Code main modules or routines first • Code intermediate modules next • Details deferred to minor modules and coded last

  20. Interactive vs. Batch Programs • Cobol suited for developing both types of programs Interactive programs • Accept input data from keyboard • Input data processed immediately • Output (results) displayed on screen immediately

  21. Interactive vs Batch Programs Batch programs • Process large volumes of input at periodic intervals • Input data read in from files • Output written to files

  22. Creating a Report • An Input File • Fixed record layout • Data are all “jammed” together • Records are read into the computer’s memory • An Output Report • Report layout • Data are spread out for easy reading • “Hardcopy” report is sent to the printer

  23. The Input File • There are no column headings in the input file. • There are no field definitions. • The data is “all crammed together” in the file. • Your COBOL program must know where on field ends and the next field begins.

  24. Sample Data File Acton Jocelyn 223 Connecticut StSan FranciscoCA9410703500350 Anderson Hazel 1247 Main Street Woodside CA9406202500100 Baker Donald 1532 Bancroft RoadBerkeley CA9470303750300 BroadhurstRyan J Route 3 Big Trees CA9506605000500 Campbell J. H. 4892 Powell StreetEmeryville CA9460802000175 Notice, each row (or record) consists of 64 consecutive bytes. A record is READ into computer memory, for use in your COBOL program.

  25. Input File Layout Field Length Data Class -------------------------------------------- Last Name 10 Alphanumeric First Name 8 Alphanumeric Street Address 18 Alphanumeric City 13 Alphanumeric State 2 Alphanumeric Zip 5 Alphanumeric Target Contribution 4 Numeric Actual Contribution 4 Numeric Total Record 64

  26. The Output Report • How many spaces should there be between columns in a report? • Do these spaces appear automatically? • No, your COBOL program must define the exact report layout, line by line. • Consider the following report layout:

  27. Sample Report Layout Acton, Jocelyn 223 Connecticut St San Francisco CA 94107 Anderson, Hazel 1247 Main Street Woodside CA 94062 Baker, Donald 1532 Bancroft Road Berkeley CA 94703 Broadhurst, Ryan J Route 3 Big Trees CA 95066 Campbell, J. H. 4892 Powell Street Emeryville CA 94608

  28. A COBOL Program • Sample Program (p. 23)Coding Form • Typically, your COBOL code will be typed in ALL UPPERCASE LETTERS. • Periods are very important to all COBOL programs. You will find many errors that are a result of missing periods.

  29. Four Divisions of a COBOL Program • IDENTIFICATION DIVISION.PROGRAM-ID. PROG1. • ENVIRONMENT DIVISION. define the files used by the program • DATA DIVISION. define all the variables • PROCEDURE DIVISION. the logic of the program

  30. IDENTIFICATION DIVISION. • Two required entries • The Division Header • The PROGRAM-ID. • Notice the use of periods in this division. • These periods are required. • Omitting or misplacing periods usually causes problems.

  31. ENVIRONMENT DIVISION. • This is the link between your COBOL program and the actual computer system on which it is running. • All COBOL programs (in this class) will have an INPUT-OUTPUT SECTION. • This section contains the FILE-CONTROL paragraph.

  32. DATA DIVISION. • This division will typically have two sections: • FILE SECTION. • WORKING-STORAGE SECTION. • Each file listed in the ENVIRONMENT DIVISION must also be defined in the FILE SECTION of the DATA DIVISION. • FD – File Description

  33. PROCEDURE DIVISION • Set of instructions to be executed by program • Organization of instructions planned before coding begins • Describes program logic and order in which instructions will be executed

  34. Read/Move/Print Sequence • Data is READ into computer memory • Memory defines the fields of the input file • Data is MOVEd to computer memory bytes that define the output report layout • The report line is written to the output device (i.e., the screen, the printer or a file).

More Related