The INCLUDE statement inserts application code, including declarations and statements, into a source program.
Rules:
Syntax:
INCLUDE [SQLCA / SQLDA / member-name] |
Example: Include an SQL communications area
EXEC SQL INCLUDE SQLCA END-EXEC; |
During the Pre-compilation process, INCLUDE statement replaces by the statements in member.
We will see another use of include.
The ++INCLUDE statement is used to include all of the data records of one source file in another source file at compilation time.
Syntax:
++INCLUDE member-name |
Rules:
Example:
Below example will explain about how the cobol code include will work.
INCLCODE.INCLUDE will include to the main program during the pre-compilation process. So program will be compiled as a single piece of code
Below example will explain about how the cobol code include will work.
MOVE SPACES TO NAME. ACCEPT NAME. |
COBOL Main Program:
IDENTIFICATION DIVISION. PROGRAM-ID. COBINCLD. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 NAME PIC X(10) VALUE SPACES. PROCEDURE DIVISION. ++INCLUDE INCLCODE DISPLAY 'ENTERED NAME : ' NAME. STOP RUN. |
This is simple COBOL program. you can add any number of line in include library member.
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!