ABAP Keyword Documentation → ABAP - Reference → Enhancements → Source Code Enhancements → Explicit enhancement options
ENHANCEMENT-SECTION
Other versions: 7.31 | 7.40 | 7.54
Syntax
ENHANCEMENT-SECTION enh_id SPOTS spot1 spot2 ...
[STATIC]
[INCLUDE BOUND].
...
END-ENHANCEMENT-SECTION.
Extras
1. ... STATIC
2. ... INCLUDE BOUND
Effect
These statements turn a section of the current program into an explicit enhancement option, as a result of which the section can be replaced by a source code enhancement. When the program is generated, exactly one source code plug-in of the assigned enhancement implementation, whose switch has the status stand-by or on, replaces this program section. If no switch is assigned to a source code plug-in, it is treated as if the switch has the status on.
If the addition STATIC
is not specified, the source code enhancement is dynamic. In a dynamic source code enhancement,
declarative statements are not replaced. Instead,
the declarative statements of the source code plug-in are added to the declarative statements in the program section. Furthermore, only source code plug-ins whose
switches have the status on are respected by dynamic source code enhancements when a program is executed.
The program section may only contain complete control structures and processing blocks. If no suitable source code plug-in is found, the original section is executed.
enh_id
requires an ID for the enhancement option to be specified directly; this ID must be unique without the addition INCLUDE BOUND
in the current
compilation unit and it must be unique with this addition in the current include program. At least one
enhancement spot must
be assigned to the enhancement option by specifying the values spot1
, spot2
, and so on, as
simple enhancement spots.
One or more source code plug-ins can be created for an enhancement option. A source code plug-in is created by assigning an
enhancement implementation for the element definition in
Enhancement Builder.
This process automatically generates a source code plug-in (with a unique ID), which is displayed after
the END-ENHANCEMENT-SECTION
in the editor. Initially, the plug-in contains
the code to be replaced between ENHANCEMENT
and ENDENHANCEMENT
; the code can be overwritten there. A source code plug-in is assigned to exactly one enhancement option.
Multiple source code plug-ins of multiple enhancement implementations can be assigned to one enhancement option. If multiple source code plug-ins with the switch position on or stand-by are found when the program is executed, a conflict resolution is performed internally and the conflict resolving enhancement implementation that takes precedence is used. If more than one conflict resolving enhancement implementation takes precedence, or there is no conflict resolving enhancement implementation, the conflict cannot be resolved correctly. Instead, one of the primary conflict resolving enhancement implementations or one of the conflict resolving enhancement implementations is used. Exactly which implementation is used is the same for each program execution, but is otherwise undefined.
Notes
-
In the terminology of the
enhancement concept, the section between
ENHANCEMENT-SECTION
andEND-ENHANCEMENT-SECTION
is both the enhancement spot element definition and the enhancement spot element invocation of the enhancement option. -
The
ENHANCEMENT-SECTION
statement can either be entered directly or created after a block of lines is selected by choosing Enhancements → Create Enhancement in Enhancement Builder. After the program has been saved or created by choosing Enhancements → Create Enhancement, the statement can only be deleted by choosing Enhancements → Delete Enhancement. -
The statements
ENHANCEMENT-SECTION
-END-ENHANCEMENT-SECTION
can also be included in a source code plug-in.
Addition 1
... STATIC
Effect
You use the addition STATIC
to define a static source code enhancement. The declarative statements of a source code plug-in are not added, but replace the ones from the program section.
In a static source code enhancement, all incorporated source code plug-ins are respected when the program is executed, including those whose switch has the status stand-by.
Note
Unlike the ENHANCEMENT-POINT
statement, the STATIC
addition of the ENHANCEMENT-SECTION
statement should only be used with maximum caution when changing data declarations. This is because
a replacement is being done, not an enhancement. Application developers at SAP in particular should
not use the STATIC
addition at all with ENHANCEMENT-SECTION
since the change will be active in the entire customer system.
Addition 2
... INCLUDE BOUND
Effect
This addition has the same effect as it does for the ENHANCEMENT-POINT
statement.