1 / 19

Efficient Batch and Interactive COBOL Program Development

Learn about the PROCEDURE DIVISION in COBOL, its structure, and essential instructions for data processing and file handling using verbs like OPEN, READ, WRITE, CLOSE. Discover the distinction between batch and interactive programs.

ofish
Download Presentation

Efficient Batch and Interactive COBOL Program Development

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 4 PROCEDURE DIVISION

  2. Paragraphs • PROCEDURE DIVISION divided into paragraphs • Each is independent module or routine • Made up of series of instructions to perform specific set of operations

  3. Structure of the PROCEDURE Division • Paragraph names • Statements • All statements begin with a verb • PERFORM Statement • Stopping execution of the program

  4. Structure of the PROCEDURE Division • Zone A • PROCEDURE DIVISION. • All paragraph names. • Zone B • All statements • The last statement in a paragraph is followed by a period

  5. PROCEDURE DIVISION Contains instructions to • Read data • Process data • Produce output • Perform end-of-job operations

  6. OPEN READ AT END NOT AT END WRITE CLOSE MOVE PERFORM PERFORM UNTIL STOP RUN Verbs

  7. INPUT file-name-1 … OPEN OUTPUT file-name-2 … File-names used must appear in SELECT statement (ENVIRONMENT DIVISION) File must be accessed with OPEN before reading from or writing to it OPEN Statement FORMAT

  8. READ Statement • READ file-name-1 AT END statement-1 … [NOT AT END statement-2 …] [END-READ] • File-name appears in SELECT statement, FD entry and OPEN • AT END tests if there are more records FORMAT

  9. PERFORMUNTIL … END-PERFORM PERFORM UNTIL condition-1 statement-1 ... [END-PERFORM] • Repeatedly executes statement(s) between PERFORM UNTIL … END-PERFORM until condition specified in UNTIL clause is met FORMAT

  10. Simple PERFORM PERFORM paragraph-name • To execute instructions in separate paragraph or module one time • Transfers control to named paragraph • Executes all instructions in paragraph • Control returns to statement following PERFORM FORMAT

  11. Out-Of-Line PERFORM PERFORM paragraph-nameUNTIL condition • Repeats paragraph until condition met • Control transfers to named paragraph • Executes instructions in paragraph and returns FORMAT

  12. In-Line PERFORM PERFORMUNTIL condition statement(s)END-PERFORM • Repeats statement(s) until condition met • Statement(s) to be executed are in-line, not in separate paragraph FORMAT

  13. MOVE statement • MOVE identifier-1 TO identifier-2 • Copies contents of identifier-1 to identifier-2 FORMAT

  14. WRITE statement • WRITE record-name-1 • Transmits data from output record area to associated file on device specified • Record-name is 01 level name following FD for a file opened for output • READ file-name, WRITE record-name FORMAT

  15. CLOSE statement • CLOSE file-name-1 ... • Close all files opened • Indicates files no longer needed for processing • Releases files and deactivates devices FORMAT

  16. STOP RUN • Terminates the program • Usually last instruction in main module • Execution continues with next paragraph if STOP RUN is omitted

  17. PROCEDURE DIVISION • Batch processing instructions • Access files and read them • Write output to files • Interactive processing instructions • Accept input from keyboard • Display output on screen

  18. Batch Programs Review • Programs that process large quantity of data stored in files • Require ENVIRONMENT DIVISION • Require FILE SECTION in DATA DIVISION • Use OPEN, READ, WRITE, CLOSE verbs to process files

  19. Interactive Program Statements • DISPLAY to prompt for input • ACCEPT to store input in WORKING-STORAGE areas • Various statements to process input • DISPLAY to show output • DISPLAY to ask if there is more input • ACCEPT to get response

More Related