You are on page 1of 4

SAP ABAP Enhancements

There are various techniques which come under the enhancement framework
which are,
1. Source code enhancements (plug-ins)
2. Function group enhancements
3. Class Enhancements
4. Kernel-BADI enhancements
Source Code Enhancement:
Source Code Enhancement is one of the enhancement technologies available under
Enhancement Framework. Implementing this technology is also called as Source Code Plug-
In. Technically the source code plug-in implementations are stored in a separate include
program and not as part of the original source program. Source code enhancements
(plug-ins) allow us to directly enhance the standard source code without any
modifications in the source code.

There are two possible source code enhancements:


1. Implicit Source code enhancement option
2. Explicit Source code enhancement option

As implicit enhancements are predefined enhancements provided by SAP in the source


code, the explicit enhancements can be implemented by the customers or partners.

Enhancement Operations -> Show implicit Enhancement Options


All Implicit Enhancement option will be displayed. All yellow lines indicate Implicit
Enhancement options. In ABAP programs, implicit enhancement options are predefined at
the following places:

• Begin/End of an include
• Begin/End of Method/Function Module/Form Routine
• End of a structure
• End of Private/Protected/Public Section of a local class

Note - Explicit enhancements though can be placed anywhere in the source code but, not
just anywhere except some areas where SAP would allow (program allows).

In Explicit Enhancements there are more two ways of enhancing,


1. Enhancement point (Syntax - ENHANCEMENT-POINT)
2. Enhancement section (Syntax - ENHANCEMENT-SECTION)

Enhancement section is used to replace a set of code or statements with the customer
(custom code). In this technique the original source code does not get executed but, the
customer implementation (custom code) gets executed.

The following enhancement option types are available in a source code:


· ENHANCEMENT-POINT – can either be static (for example, additional data
declaration) or dynamic (for example, additional coding).
· ENHANCEMENT-SECTION – can either be static (for example, replace an existing
data declaration) or dynamic (for example, replace coding).
· Overlay enhancement – overwrite an existing enhancement instead of modifying
it.

Source Code Enhancements vs. Modifications


Advantages of source code enhancements:
· No modifications;
· No object key is needed;
· Are switchable by the switch framework;
· Fewer upgrade effort.
Disadvantages of source code enhancements:
· exist only at special source code lines (implicit, explicit).
Implicit Enhancement Options in ABAP Source Codes
Use
In ABAP programs, implicit enhancement options are predefined at the following places:
· At the end of an include. There are some restrictions, for example, not at the end of a
method include.
· At the end of a PUBLIC-, PROTECTED-, PRIVATE-SECTION of a class.
· At the end of the implementation part of a class
(Before the ENDCLASS, which belongs to CLASS … IMPLEMENTATION)
· At the end of an interface definition (before the ENDINTERFACE).
· At the end of a structure definition
(Before TYPES END OF, DATA END OF, CONSTANTS END OF, and STATICS END OF).
· At the beginning and at the end of a procedure (FORM, FUNCTION, METHOD). That is,
after commands
FORM, FUNCTION, and METHOD, and before statements ENDFORM, ENDFUNCTION,
and ENDMETHOD.
· At the end of the CHANGING-, IMPORTING-, EXPORTING-parameter list of a method.
These enhancement options are located in the middle of a statement.
Implicit enhancement options always exist and no enhancement spot is assigned
to them

Explicit Enhancement Options in ABAP Source Codes


Use
In ABAP programs, you can select either a position or a program section as an explicit
enhancement option. Source code plug-ins for an enhancement are either entered at such a
position or they replace the selected section.

An explicit enhancement option of an ABAP program is part of the program. It is thus


assigned to the package of the program and not necessarily to the package of the
enhancement spot to which it belongs.

Activities
· To mark a position in an ABAP program as an explicit enhancement option, use the
following ABAP statement:
ENHANCEMENT-POINT enh_id SPOTS spot1 spot2 ...

· To mark a section in an ABAP program as an explicit enhancement option, use the


following ABAP statement:
ENHANCEMENT-SECTION enh_id SPOTS spot1 spot2 ...
...
END-ENHANCEMENT-SECTION.

Creating Source Code Plug-Ins


Procedure
1. Call the Enhancement Builder from the ABAP Editor using forward navigation.
2. Create an enhancement implementation for an implicit or explicit enhancement
option. For more information, see Creating an Enhancement Implementation.

An empty source code plug-in is automatically created. It has a unique ID and is displayed
in the ABAP Editor below the enhancement option as follows:

ENHANCEMENT id.
...
ENDENHANCEMENT.

3. Implement the enhancement between the ENHANCEMENT and


ENDENHANCEMENT lines.

A source code plug-in is assigned to exactly one enhancement option. An enhancement


option can be enhanced through several source code plug-ins of an enhancement
implementation and through several enhancement implementations.
Although source code plug-ins is displayed in the same source code as the respective
enhancement options, they are actually stored in other Include programs managed by the
Enhancement Builder.

Enhancement Builder
Definition
The Enhancement Builder is an ABAP Workbench tool for creating and managing enhancements within the
enhancement concept. The Enhancement Builder is fully integrated into the ABAP Workbench. You cannot use a
transaction code to call it directly.

Use
The Enhancement Builder is a collection of individual tools for creating and maintaining enhancement spots and
enhancement implementations, and their administration. The tools of the Enhancement Builder are called by
forward navigation from within the other ABAP Workbench tools. In addition, there are special tools for navigation
and administration.

Creating, Editing, and Deleting Enhancement Implementations


Purpose
Enhancement implementations are created and changed by means of forward navigation.
• For explicit enhancement options, enhancement implementations are created for the related enhancement
spots.
• For implicit enhancement options, enhancement implementations are created directly.
The appropriate tool for the respective enhancement technology is opened automatically.

Procedure
...

1. Start the Object Navigator (SE80).


2. Display the package in which an enhancement implementation is defined, or is to be created.
If you want to Then
Create an enhancement implementation The method is different for explicit and implicit
enhancement options. For an explicit
enhancement option, select the enhancement
spot in the Object Navigator, and choose
Implement in the context menu. For an implicit
enhancement option, call the Enhancement
Builder in the relevant tool (ABAP Editor,
Function Builder, Class Builder) for executing
an enhancement.
Then, in the dialog box that appears, continue
with the following steps:
...

1. Enter a name for the (simple)


enhancement implementation.
2. Enter a short text for the (simple)
enhancement implementation.
3. Select a composite enhancement
implementation, or create a new one.

4. Choose Creation of
Enhancement (Enter).
The subsequent process depends on the
enhancement technology of the
enhancement spot.
...

Edit an enhancement implementation 1. Select the package and expand it.


2. Expand the Enhancements node.
3. Expand the Enhancement
Implementations node.
4. Select the desired enhancement
implementation.
5. Select Change from the context
menu.
If you only want to display the
enhancement implementation, choose
Display.
...

Delete an enhancement implementation 1. Select the package and expand it.


2. Expand the Enhancements node.
3. Expand the Enhancement
Implementations node.
4. Select the desired enhancement
implementation.
5. Select Delete from the context
menu.