Use the #INCLUDE statement to merge source lines from another file into the source code you are working on at the position of the #INCLUDE statement. The line number of the original statement is replaced with the line number of the statement that results from an operation, such as MOVE.
The #INCLUDE statement is analogous to the COPY statement. The compiler copies the contents of the 'included file-name' into the program at the point where the statement occurs. The contents of the file are treated as additional program source.
The difference between the #INCLUDE and COPY statements relate to the fact that PowerCOBOL uses a preprocessor to turn your program code into an actual COBOL program. #INCLUDE statements are processed by the preprocessor, immediately (during preprocess time), while COPY statements are ignored by the preprocessor and passed onto the COBOL compiler to deal with.
#INCLUDE "INCLUDE FILE-NAME"
The #INCLUDE statement can be described in the A or B area of the DATA DIVISION, ENVIRONMENT DIVISION and the PROCEDURE DIVISION.
You cannot use the #INCLUDE statement if the same file name is referenced in an INCLUDE statement in the target file.
The 'Include file-name' must be a file name in the #INCLUDE library.
Use of the #INCLUDE statement must follow the COBOL language specification.
The 'included' file can contain #INCLUDE statements.
#INCLUDE statements can be nested up to 16 levels.
DATA DIVISION. WORKING-STORAGE SECTION. * Get the #INCLUDE file to the data control #INCLUDE "NUMDATA.COB". PROCEDURE DIVISION. MOVE WK-1 TO POW-FONTSIZE OF LABEL1. : +--- The contents of NUMDATA.COB file -------------------+ | | |000100 01 WK-G. | |000200 02 WK-D1 PICTURE IS S9(4) USAGE IS DISPLAY. | |000300 02 WK-D2 PICTURE IS S9(4) USAGE IS DISPLAY. | |000400 02 WK-1 PICTURE IS S9(9) USAGE IS BINARY. | |000500 02 WK-2 PICTURE IS S9(9) USAGE IS PACKED-DECIMAL. | | | +---------------------------------------------------------+