CST8283_Week 3_File Handling and Basic Procedures (Session 5).ppt

CST8283_Week 3_File Handling and Basic Procedures (Session 5).ppt

Info icon This preview shows pages 1–16. Sign up to view the full content.

View Full Document Right Arrow Icon
Week 3 File Handing and Basic Procedures CST8283 BUSINESS PROGRAMMING
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Session 5 -- References COBOL Micro to Mainframe pages 98-105 Appendix C and D (commands covered in this session) Session slides
Image of page 2
Session 5 Objectives Participant should be able to: Code PROCEDURE DIVISION basic entries to open and close files read data from opened files write data to opened files execute procedure division modules (paragraphs) move data within fields Predict the result of these instructions and describe the rules associated with each.
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
PROCEDURE DIVISION PROCEDURE DIVISION contains all executable instructions for Input Output Data manipulation Arithmetic operations Conditional operations Stop Run
Image of page 4
PROCEDURE DIVISION COBOL commands (RESERVED WORDS) covered in this session MOVE PERFORM READ WRITE OPEN CLOSE STOP RUN
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
PROCEDURE DIVISION Procedure Division requires the division Header (margin A – column 8) PROCEDURE DIVISION. As with other divisions, the Procedure Division can have sections and paragraphs.
Image of page 6
PROCEDURE DIVISION Paragraphs in the Procedure Division would equate to modules or routines as detailed on a structure or hierarchy chart Each paragraph would either carry out a specific task or control the execution of other paragraphs (modules) – not both
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
200 Compute Pay 300 Compute Gross Pay 302 Compute Net Pay 301 Compute Tax Payable Consider this simple hierarchy chart
Image of page 8
PROCEDURE DIVISION The module 200 COMPUTE PAY controls the execution of three subordinate modules – 300 Compute Gross Pay, 301 Compute Tax Payable, 302 Compute Net Pay Each of these three modules carry out one specific task. Each of these four modules would be coded as separate paragraphs in the COBOL Procedure Division.
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
File Handling All files have to be “open” before they can be read from or written to. Sequential files can either be input or output -- not both. OPEN INPUT filename OPEN OUTPUT filename
Image of page 10
Files and Data Hierarchy Files sequential or random records ( fixed or length ) fields ( fixed or variable length ) bytes ( one value or character ) bits
Image of page 11

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
File Handling – Sequential files Sequential File Records are physically ordered one after the other Inter-record gap between each record Blocks of records have an inter-block gap Records are usually ordered by a primary key field Can be stored on disk, CD or tape
Image of page 12
File Handling – Sequential files R1 R2 R3 R4 Rn-1 Rn eof In this example, R1 is the first record of a series of records on a sequential file. The last actual record, Rn , is followed by the End of File record (EOF). This EOF record is not a data record but indicates the end of the file
Image of page 13

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
File Handling (continued) File name referenced in OPEN and CLOSE statements has already been coded in the FD statement (DATA DIVISION) SELECT clause (FILE CONTROL paragraph).
Image of page 14
File Handling (continued) NOTE -- LINE SEQUENTIAL FILES can be either input or output ( not both ) specify whether the file is
Image of page 15

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 16
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern