Enhancement Framework – Class Enhancement

By | April 21, 2014 | Enhancement Implementation | 27,823 | 2

Enhancement framework offers unique way to enhance the class and interface. Lets take a deep dive.

Class Enhancement using Implicit

You can enhance the method of the class using the implicit enhancement points. This is exactly same as the enhancement points on the subroutines / Function Modules. The points are available at the beginning of the method and end of the method.

To implement the implicit points in the class,
1. Display the class in SE24
2. Display the method source code – Navigating to source code is important if you want to implement the implicit points. If you are on class overview screen, the menu options will not be displayed.
3. Get into the enhancement mode
4. Menu Edit > Enhancement Operations > Show implicit points

Class_Enhancement_implicit

Once points are available, you can implement the points the way you implement any implicit point.

Enhance a class

Class enhancement has more power than implicit points. As part of the class enhancement, you can create

  • Pre Exit – This implementation would be called before the original method call
  • Post Exit – This implementation would be called after the method call
  • Overwrite Exit – This implementation would replace the original method call with the newly implemented method
  • Parameter enhancement – Additional parameters to the method signature
  • Additional Attributes – Additional Attributes
  • Additional Methods – Additional new methods within the class

Once you are in the enhancement mode, you will see the table control open for changes. You can add the new methods, new attributes etc in the Enhancement Mode.

You can’t create the exit methods for the methods inherited from the super class. But you can create the exit methods for the redefined methods.

Enhance A Class

For class enhancement,
1. Display the class in SE24 and Select menu Class > Enhance

Class_Enhancement_1

2. Enter the Implementation name and save.

Class_Enhancement_2

3. Upon save, you will notice the editor to display PreExit, PostExit and OverwriteExit with Enhancement columns.

Class_Enhancement_3

4. Select menu Edit > Enhancement Operations > Insert Pre-Method. Here you will find functions to create and remove each of the three exit.

Class_Enhancement_4

5. Click on the editor icon to enter your code

Class_Enhancement_5

Adding New Method Parameters

To add the new method parameter, head to the method signature. Here you would find that the table control is open for changes. You can add the parameters. The parameters would be Optional as they are new and would not be called from different places where method is called.

Class_Enhancement_6_param

Adding New Attributes

Similarly, you can add the new attribute. The attribute could be as same as the any other attribute.

Class_Enhancement_7_attributes

Class Enhancement Vs Method Implicit implementation

You can achieve the Pre-Exit and Post-Exit related implementation using the method’s source code implementation. As you can see, the class enhancement has more functions like Overwrite Method, New methods, new Attributes, New parameters to the methods.

Next Article

Enhancement Framework – Class enhancement source code and debugging

Table of Content – Enhancement Framework

Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{274 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 274 articles.

Load comments

2 Comments

  • Steve Oldner

    Very handy. I’ve not enhanced class attributes or method parameters so this can be very useful! Or very dangerous!!

    Thanks much!

  • Alok

    Hi,

    I am new in ABAP and few days back i come across this nice learning website for SAP.
    I have a question related to enhancement .
    Which enhancement technique is better i.e BADI or Exits?
    Other question is little complex i hope u understand.

    When we r implementing BADI we r writing code in Interface methods and for exits in some includes
    for a particular transaction.
    My question is if i add code using BADI , Is it affect Exits and vice versa ?
    Is there any dependency between them?

    Thanks
    Alok

Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.