ABAP Keyword Documentation → ABAP − Reference → Program Layout → Modularization Statements → Source Code Modules → Include Programs
INCLUDE
Other versions: 7.31 | 7.40 | 7.54
Syntax
INCLUDE incl [IF FOUND].
Addition
Effect
The statement INCLUDE
includes the
include program
incl in this position in the source code. In syntax checks and when the program is generated
by ABAP Compiler, the statement is replaced by the source code of the include program. The included INCLUDE
program must consist of full statements.
If the specified include program does not exist, the syntax of the program is incorrect and cannot be executed. This error message can be suppressed by specifying the addition IF FOUND
.
Programming Guidelines
Notes
-
The statement
INCLUDE
is the only statement that can be used instead of a statement that introduces a program in the first position of a program. The requirement is that, after the include program is resolved, a statement that introduces a program is located at the beginning of the including program. - ABAP Workbench supports the automatic creation of include programs for specific program parts, such as the top include for global declarative statements. It is advisable to always use the naming conventions proposed by ABAP Workbench. The top include can contain only declarative statements and is respected when individual include programs of a program are compiled.
-
In Repository Browser
(a part of Object Navigator in ABAP Workbench), the
INCLUDE
programs bound by a program are executed as the subnodes of the program.
Addition
... IF FOUND
Effect
The addition IF FOUND
dictates that the specified
include program can
be included only if it exists. If the include program does not exist, the INCLUDE
statement is ignored and no syntax error occurs here.
Note
If the addition IF FOUND
is specified, it is recommended that the including
program not be dependent on the source code of the include program. Otherwise, the include program may have correct syntax in systems where it exists but incorrect syntax in other systems.
Example
These lines show the master
program of the function group ABAP_DOCU. This function group displays the keyword documentation
on Application Server ABAP. It only contains INCLUDE
statements that embed the actual source code. labap_docutop
itself is made up of include programs for the individual declarations (global data and class declarations local to the program).
*& Function Group SAPLABAP_DOCU
*&----------------------------------------------------------------*
INCLUDE labap_docutop. " Global Declarations
INCLUDE labap_docue00. " Load of Program
INCLUDE labap_docuuxx. " Function Modules
INCLUDE labap_docuo01. " PBO Modules
INCLUDE labap_docui01. " PAI Modules
INCLUDE labap_docue01. " Handling of Runtime-Events
INCLUDE labap_docup01. " Class implementations
INCLUDE labap_docup02.
INCLUDE labap_docup03.
INCLUDE labap_docup04.
INCLUDE labap_docut99. " Unit tests