COBOL Procedure Division

COBOL Linkage Section COBOL Data Item Declaration

Advertisements


The PROCEDURE DIVISION is used specify the operations to be performed by the program or where the actual logic coded.

PROCEDURE DIVISION may contain declarative as well as non-declarative procedures.

The PROCEDURE DIVISION contains all the statements which will execute by the compiler in which the order written by the programmer.

However, the programmer can alter the flow of execution by using the flow control statements like IF, PERFORM, GO TO and EVALUATE.

PROCEDURE DIVISION contains sections, paragraphs, sentences and statements.

Program execution starts from PROCEDURE DIVISION.

PROCEDURE DIVISION ends at STOP RUN, GO BACK statement encountered.

PROCEDURE DIVISION may contain the DECLARATIVES and it is coupled with the END DECLARATIVES.

In the PROCEDURE DIVISION, programmer can specify procedures that are to be executed only under special circumstances.

Syntax:

The PROCEDURE DIVISION syntax was like below

1) Normal Main program procedure division

	PROCEDURE DIVISION

2) Sub program procedure division

	PROCEDURE DIVISION [USING {data-name-1}...]

USING Clause

The USING clause in the PROCEDURE DIVISION is required only if the program to be called by another COBOL program through the CALL statement.

The CALL statement itself includes a USING clause.

Then USING clause in a PROCEDURE DIVISION identifies the program that as a subprogram called by the sub program


3) Procedure division with declaratives.

   PROCEDURE DIVISION.
	 DECLARATIVES.
	 -----------
	 -----------
	 END DECLARATIVES.

When Declaring the DECLARATIVES in the PROCEDURE DIVISION, it must be the first section immediately after PROCEDURE DIVISION and should ending with the END DECLARATIVES.

A declarative sentence contains a USE statement.

The USE statements themselves are not executed and calling conditions of USE procedures.

These declarative procedures are optional paragraphs.

A USE procedure is terminated in a source program by either a new section name which indicates the beginning of another declarative statement.

END DECLARATIVES which indicates the end of the list of declarative sections.

Note: The PROCEDURE DIVISION begins in Area B

Practical Example:

Below example is used to display section names automatically based on the control flow.


If any questions on the above, post your queries on Cobol Discussion forum


COBOL Linkage Section COBOL Data Item Declaration

Advertisements