Sometimes while working on SAP we get some issue or error that cannot be solved using default standard methods present in our SAP system. Therefore to solve these kinds of errors we need need to enhance the existing standard methods or create custom methods.
This tutorial explains step by step procedure to add a custom method to any standard global class and also to enhance an existing method using exits.
Types of Exist
There are three types of exit:
- Pre-Method Exit: This exit executes the custom logic before the standard method gets executed.
- Post-Method Exit: This exit executes the custom logic after the standard method gets executed.
- Overwrite-Method Exit: This exit completely replaces the standard logic.
How to Enhance the Standard Class?
Please follow the steps below to enhance the standard class:
Execute t-code SE24 in the SAP command field.
Next, enter the Object type CL_SALV_TABLE and click on the Display button.
The following screen gets open
Now go to Class on the top menu and click Enhance option to create an enhancement implementation.
Next on the pop screen input the Name and Description for the enhancement implementation and click OK to continue.
Next, enter the Package name and click the Save icon to create the new enhancement implementation.
Once implementation gets created successfully click the Activate button to make the enhancement active.
Note: Click on the Source code button and the standard interface screen opens up in change mode, here you can enter your custom code inside the method.
Next, navigate to following
Edit->Enhancement Operations->Insert Pre-Method / Insert Post-Method/Add Overwrite Method.
Select the exist according to your requirement
Once you select a type Exit option, the source code button appears on the Pre-Exit column. Press that button to implement the pre-method of the display.