What is User Exit in SAP?
A user exit is a specific location within a standard program in an SAP system where a user can add their own custom code to enhance the functionality of the program. A user exit provides a way for users to add their own business-specific requirements to a standard SAP system, without changing the original code of the standard program. User exits are written in the ABAP programming language and are triggered during the execution of the standard program.
The purpose of a user exit is to enable users to extend the functionality of the SAP system beyond what is provided by the standard programs. User exits are available in various SAP modules and can be used to implement custom business logic, validate data, or modify the behavior of standard SAP transactions.
Example:
Some examples of user exits in SD are:
USEREXIT_NUMBER_RANGE
This user exit is used to assign a different internal document number to the sales order VA01 when it is created depending on some criteria like a different SALES ORGANIZAION(VKORG).
USEREXIT_SAVE_DOCUMENT_PREPARE
This user exit is used to insert the ABAP code which will be called when the document (sales order VA01) is just about to be saved. This user exit is used generally for custom checks on different fields, to display some information before the order will be saved, or for making changes to certain fields before the sales order will be saved.
Types of User Exit in SAP
There are five types of user exits available in SAP, which include:
i) Function module exits:
These exits allow users to replace or enhance the functionality of a specific SAP function module. Function module exits are often used in the SD (Sales and Distribution) module to modify the pricing logic or to create custom fields in billing documents.
ii) Menu exits:
These exits allow users to add custom menu options to the SAP system. Menu exits are often used to provide links to external systems or to add custom reports.
iii) Screen exits:
These exits allow users to add custom screens to SAP transactions. Screen exits are often used to collect additional data that is not available in the standard SAP screen, such as additional customer-specific fields.
iv) Field exits:
These exits allow users to add validation and formatting rules to specific fields in SAP transactions. Field exits are often used to enforce business-specific validation rules or to perform additional calculations based on the entered data.
v) Business Transaction Events (BTEs):
These are events that occur at specific points during the execution of a business transaction, and they allow users to trigger custom code. BTEs are often used to perform additional checks, perform custom calculations, or trigger external processes.
How to Find User Exit in SAP?
Please follow the steps below to find user exit in SAP:
Go to t-code SE80 from the SAP command field.
Next, select the development class from the list and enter VMOD in it
All of the user exits in SD are contained in the development class VMOD. Press enter and you will find all the includes that contain user exits in SD for different functions like PRICING, ORDER PROCESSING, etc.
How to Create User Exit?
Please follow the steps below to create user exit:
First choose a t-code for which the user exit needs to be created for example t-code OD00
Execute the tcode OD00 or for which user exit needs to be created.
Next to get the program name of that tcode on the menu bar click System > Status.
Under SAP data section you will find program, double click on it, it will display the program.
Now execute tcode SMOD in SAP command field.
On the menu bar go to Utilities > Find as shown in the image below.
Now enter the package name and press F8.
You will get list of all the exits present for that particular tcode. Select the exit according to your requirement
Now enter t-code CMOD in the SAP command field and Execute it.
Next enter a Project name and click on Create button to create a project
Now enter the project description and other details
Click on Save button to save the project.
A message Attribute of STE saved will be displayed on the bottom of your screen.
Now click on the Enhancement assignement button.
Next enter the Enhancement code that has the user exit.
Next click on the Save button to save the configurtions
Next click the Component button navigate to Components screen
Now the function module is displayed, double click on the include ZX..., SAP displays a warning that this include will be created
Insert the ABAP code into the include
At last write down your code here and activate the user exit.
How to Create Enhancement in User Exit?
Please follow the steps below to create enhancements in user exit:
Execute t-code SPRO in the SAP command field
Next click on the SAP Reference IMG path to go to the next screen.
Now navigate to following IMG path:
SPRO > SAP Reference IMG > Sales and Distribution > System Adaption > User Exits.
Now run the t-code SE38 in the SAP command field
Next click on the Display button as shown in the imge below.
Next click on Enhance icon to go to edit mode as shown in the image below.
Next right click on th double quotes and select Enhancement Operation > Create Implementation
Now on Choose Type of Enhancement option click on Code
Click the new enhancement option and enter details about the new enhancement and click continue.
Next on the new enhancement screen make the code changes
Now Save, Activate, and Execute the changes made inthe User exit.