Entering content frame

Include Programs Locate the document in its SAP Library structure

Include programs are global R/3 Repository objects. They are solely for modularizing source code, and have no parameter interface.

They have the following functions:

Creating Your Own Include Programs

If you create an include program yourself, you must assign it the type I in its program attributes. You can also create or change an include program by double-clicking on the name of the program after the INCLUDE statement in your ABAP program. If the program exists, the ABAP Workbench navigates to it. If it does not exist, the system creates it for you.

An include program cannot run independently, but must be built into other programs. Include programs can contain other includes.

The only restrictions for writing the source code of include programs are:

You must ensure that the statements of your include program fit logically into the source code of the programs from which it is called. Choosing Check while editing an include program in the ABAP Editor is normally not sufficient for this.



TEXT = 'Hello!'.

Here, the syntax check reports an error because the field TEXT is not declared. However, you can include INCL_TST in any program in which a field called TEXT with the correct type has been declared.

For the syntax check to produce valid results, you must check the program in which the include occurs. The exception to this is the TOP include, the contents of which are always included when you check the syntax of another include.

Using Include Programs

To use an include program in another program, enter the statement

INCLUDE <incl>.

The INCLUDE statement has the same effect as copying the source code of the include program <incl> into the program. In the syntax check, the contents of the include program are also analyzed. Include programs are not loaded at runtime, but are expanded when the program is generated. Once the program has been generated, the load version contains static versions of all of its includes. If you subsequently change an include program, the programs that use it are automatically regenerated.

The INCLUDE statement must be the only statement on a line and cannot extend over several lines.


Suppose we have the following program:


WRITE: / 'Program started by', SY-UNAME,
/ 'on host', SY-HOST,
'date:', SY-DATUM, 'time:', SY-UZEIT.

We can then include this program in any other ABAP program to display a standard list header.



This could produce the following output:

Program started by KELLERH

on host ds0025   date: 03/19/1998 time: 09:00:39






Leaving content frame