TSO-ISPF JCL COBOL VSAM DB2 CICS Tools Articles Job Portal Forum Quiz Interview Q&A

COBOL - Procedure Division


The PROCEDURE DIVISION consists of a series of procedures called paragraphs, each designed to perform a specific function.

A paragraph consists of a paragraph name coded in Area A and a series of procedural statements designed to perform a desired function coded in Area B.

Procedures frequently execute other procedures as indicated in the following example:

0000-MAIN-PARA.
       PERFORM 1000-INITIALIZE-PARA
          THRU 1000-EXIT.
       PERFORM 2000-MAIN-PARA
          THRU 2000-EXIT
         UNTIL END-OF-FILE.
       PERFORM 3000-END-PARA
          THRU 3000-EXIT.
       STOP RUN.

Notice the use of punctuation in the preceding paragraph. Each statement should be a sentence, that is, it should end with a period unless it is part of a conditional sentence.

Sentences which are continued across multiple lines should be indented on the succeeding lines. Phrases which modify the behavior of a statement such as UNTIL in the PERFORM statement should be coded on a new line so that they stand out.

Let's see how the COBOL program looks if we code all the divisions.

IDENTIFICATION DIVISION.           ---> Identification division starts here
PROGRAM-ID. HELLOWRD.              ---> Identification division ends here

ENVIRONMENT DIVISION.              ---> Environment division starts here
CONFIGURATION SECTION.
SOURCE-COMPUTER. XXX-ZOS.
OBJECT-COMPUTER. XXX-ZOS.

INPUT-OUTPUT SECTION.
FILE-CONTROL.
   SELECT FILEN ASSIGN TO INPUT.
   ORGANIZATION IS SEQUENTIAL.
   ACCESS IS SEQUENTIAL.           ---> Environment division ends here

DATA DIVISION.                     ---> Data division starts here
FILE SECTION.
FD FILEN
01 NAME PIC A(25).

WORKING-STORAGE SECTION.
01 WS-STUDENT PIC A(30).
01 WS-ID PIC 9(5).

LOCAL-STORAGE SECTION.
01 LS-CLASS PIC 9(3).

LINKAGE SECTION.
01 LS-ID PIC 9(5).                ---> Data division ends here

PROCEDURE DIVISION.               ---> Procedure division starts here
   DISPLAY 'Executing COBOL program using JCL'.
   STOP RUN.                      ---> Procedure division ends here

Don't need to understand each line of code. This example, just to show you how COBOL looks when we code all the divisions.



If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!

Are you looking for Job Change? Job Portal