Enhancement to a Standard Class

By Pranshu Kukreti

Introduction

Sometimes we come across a requirement which cannot be solved using available standard methods. In such cases we can either enhance the existing method or go for our custom development. This document explains how to add a custom method to a standard global class and how to enhance an existing method using exits.  Below are three different exits available to enhance a standard method:

1.     Pre-Method Exit: Implement this exit if we want to execute our custom logic before standard method gets executed.

2.     Post-Method Exit: Implement this exit if we want to execute our custom logic after the standard method gets executed.

3.     Overwrite-Method Exit: If we want to completely replace the standard logic then this exit should be implemented.

Steps

1)     Go to transaction SE24 and open up a standard class (CL_SALV_TABLE) in our case.

 

2)     Now select the option class->Enhance to create an enhancement implementation.

3)     A pop up screen will appear where we need to pass enhancement implementation name and description.

4)     Once the implementation gets created successfully a message will appear at the bottom of the screen and standard interface screen opens up in change mode.

5)     Now add a public method as shown below and implement the logic inside this method.

6)     We are going to display an information message inside this method.

7)     Now our next task is to add/modify the logic of existing standard method. For this put your cursor on the method name (DISPLAY in our case) and select the option Edit->Enhancement Operations->Insert Pre-Method / Insert Post-Method/Add Overwrite Method. Pre-Method gets called before the standard method and Post-Method gets called after the standard method. But if we want to completely replace the standard method logic with our won logic we can go for Over write method which gets called (if implementation is active) in place of standard method.

8)     We are going to implement the pre method first. So once we select the ‘Insert Pre-Method’ option, source code button   starts appearing on the Pre-Exit column. Press this button to implement the pre-method of display.

9)     In pre-method of display add logic to display an information message.

10)  Repeat steps 7 & 8 to implement Post-Exit method of display.

11)  Implement the post-exit method to display an information message.

12)  It should be noted that, if at this point we try to implement the over write exit, it will give a compilation error. This happens because we cannot have over write exit along with Pre/Post exit. 

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image