INCLUDE (ABAP Keyword)

INCLUDE is a keyword used in SAP ABAP programming.
This tutorial covers its introduction & syntax details.

INCLUDE

INCLUDE prog

Basic form
INCLUDE
prog.

Effect
Includes the program prog in the main program for syntax
check and generation purposes.
Include programs are used to divide very large
programs into smaller more manageable units. They also allow you to create
common program components.

Example

INCLUDE
LSPRITOP.

Notes
The whole of an INCLUDE statement must appear
on one line where it is the only statement allowed. The include program must
consist of complete statements (and comments). You can use the service report
RSINCL00 to generate reference lists for include programs.

INCLUDE STRUCTURE

Basic
form
INCLUDE STRUCTURE rec.

Effect
When you define a structure rec
(with DATA or TYPES ), this statement copies the components of the structured
data type subRec to the structure rec .

Since you can define nested data
structures (i.e. structures with sub-structures) starting from Release 3.0, you
should use INCLUDE STRUCTURE only if you want to introduce types in a program
first and nested structures in a later step.

A data
definition

DATA: BEGIN OF rec.
INCLUDE STRUCTURE subRec.
DATA:
END OF rec.

is equivalent to

DATA rec LIKE
subRec.

You are recommended to use the second
formulation.

Even if the structure rec to be defined contains additional
components, instead of

DATA: BEGIN OF rec,

INCLUDE
STRUCTURE subRec.
DATA: …
END OF rec.

you should
use

DATA: BEGIN OF rec,

rec LIKE subRec,

END OF
rec.

so that subRec can be referenced as a sub-structure of rec
.

Note
Although ” INCLUDE STRUCTURE subRec. ” breaks up the
sub-structure subRec into its components, the alignment of subRec is retained.
This means that padding fields may be inserted before the first and/or before
the last component of subRec in rec .
Related INCLUDE TYPE

INCLUDE TYPE

Basic form
INCLUDE
TYPE subRec.

Effect
When you define a structure rec (with DATA or
TYPES ), this statement copies the components of the structured data type subRec
to the structure rec .

Since you can define nested data structures (i.e.
structures with sub-structures) starting from Release 3.0, you should use
INCLUDE TYPE only if you want to introduce types in a program first and nested
structures in a later step.