Skip to content

ABAP Keyword Documentation →  ABAP Programming Guidelines →  Structure and Style →  Source Code Organization 

Multiple Use of Include Programs

Other versions: 7.31 | 7.40 | 7.54

Background

From a technical point of view, it is possible to use an include program multiple times by integrating it more than once into a master program or different master programs.

Rule

Do not use include programs more than once

Use an include program for the modularization of exactly one master program. It must not be integrated into multiple different master programs. Also, an include program should only be integrated once within a master program.

Details

The multiple use of include programs is highly problematic conceptually. This particularly concerns the use of include programs for the reuse of:

  • Type definitions
  • Data declarations
  • Local classes
  • Procedure implementations

We strongly recommended using only suitable means for reuse, such as global classes or interfaces, for the reasons specified in the following sections.

Restricted maintainability

Increased resource consumption

The memory consumption also increases if an include program is used multiple times within one master program (for example, through integration into the source code of multiple function modules of a function group or into the source code of multiple methods of a class) because this expands the master program unnecessarily. When using centrally defined, standalone types and storing required constants in suitable classes or interfaces, there remains no conceivable scenario where it would be useful to use include programs multiple times within a master program.

Missing semantic context

Bad Example

The following source code shows an include program that contains declarations of constants intended for use in multiple programs. According to the above rule, procedures of this type are no longer permitted.

*&---------------------------------------------*
*& Include Z_ORDERS_OF_MAGNITUDE
*&---------------------------------------------*
CONSTANTS:
  mega TYPE  p DECIMALS 6 VALUE '1000000.0',
  kilo TYPE  p DECIMALS 6 VALUE '1000.0',
  milli TYPE p DECIMALS 6 VALUE '0.001',
  micro TYPE p DECIMALS 6 VALUE '0.000001'.

Good Example

The following source code shows the same declarations of constants as in the above example, but this time in a global class suitable for reuse. Here, a corresponding ABAP Unit test method would even be possible that checks the consistency of the constants.

CLASS zcl_orders_of_magnitude DEFINITION PUBLIC .
  PUBLIC SECTION.
    CONSTANTS:
      mega TYPE  p DECIMALS 6 VALUE '1000000.0',
      kilo TYPE  p DECIMALS 6 VALUE '1000.0',
      milli TYPE p DECIMALS 6 VALUE '0.001',
      micro TYPE p DECIMALS 6 VALUE '0.000001'.
ENDCLASS.