Summary -

In this topic, we described about the include programs with detailed example.

If same set of statements (source code) used in more than one program, those statements can add to the include program. Include programs is available to all the programs and used in any program.

Include programs are only used to modularize the source code but have no parameter interface. Include programs are not standalone programs and cannot be executed independently.

Include programs available globally and can use in any ABAP program. Include program contains small piece of source code that can be included in a program with an INCLUDE statement.

INCLUDE statement is responsible for copying the include program source code to the main program during the runtime. Include programs can’t call themselves. Include program must be syntax error free and contain complete statements.

Syntax -

INCLUDE <include-program>

  • Include-program - Specifies the include program name. INCLUDE programs can be created in the ABAP Editor.

Example -

Below example explains how to create an include program and how it is included in the program.


Step-1: Go to SE38 transaction. Enter the include name (Z_INCLSUB) and click on create. Include Program Example

Step-2: Re-enter the program name(Z_INCLSUB), select the Type of the program as INCLUDE program and click on Save.
Include Program Example

Step-3: Enter the package details and click on Local object to open ABAP editor.

Step-4: Add the code to the Z_INCLSUB in ABAP editor. In this case, we added the below code to the include Z_INCLSUB.
WRITE / 'Inside the include..'. 

Step-5: Save, Activate the include and close the ABAP Editor.

Step-6: Open a new program to add Z_INCLSUB to the program. In this case we are creating Z_INCLMAIN program as a main program. Add the include Z_INCLSUB to the program Z_INCLMAIN like below –
REPORT  Z_INCLMAIN.

Write 'Main program execution starts...'.

INCLUDE Z_INCLSUB.

Write / 'Main program execution ends..'. 

Step-7: Save, Activate and Execute the main program Z_INCLMAIN.


Output -

Include Program Example Output

Explaining Example -

In the above example, each and every statement is preceeded with a comment to explain about the statement. Go through them to get clear understanding of example code.

The code from Z_INCLSUB includes in Z_INCLMAIN during the run time and produces the above result.