✒️ABAP Las Ampliaciones: los User Exits y los Customer Exits
ABAP Las Ampliaciones: los User Exits y los Customer Exits
What is an Enhancement?
Enhancements: These are various tools provided by SAP to make improvements, modifications, or additions to a standard system program.
Some standard programs are designed to add new functionality to existing ones. In some cases, you can validate fields on a particular dynpro, add fields to a screen with code to handle that new data, add a new option within a menu, or add fields to standard tables. Enhancements are generated and coded in separate modules from the standard code, so there's no need to modify it, thus maintaining the original functionality and proper operation.
The main advantages of enhancements are:
- They allow modifying certain programs to adapt them to the specific needs of the company, adding new features to existing ones.
- They enable improvements to a program without modifying its original code, thus maintaining its proper functioning and features.
- Changes take effect by simply transporting the new objects.
The main disadvantages of enhancements are:
- Not all modifications can always be made satisfactorily since most enhancements are prepared for a specific task and moment within the execution of a program.
- Not all standard programs are prepared to add all types of enhancements.
In SAP, there are several types of enhancements, each used according to the type of improvement or requirement to be developed, each with its own particularities that will be explained in detail later. The most important ones are:
- User Exits
- Customer Exits
- KeyWord Exits
- Field Exits
- Append Structures
- Badis
- Enhancements
- Menu Exits
User Exits
It is a subroutine defined within a standard ABAP program that is empty, meaning it has no code, it's there for the user to add their own source code to perform specific tasks not foreseen by SAP.
They are the first enhancements introduced by SAP and are specific to the SAP SD Sales and Distribution module, not existing in other SAP modules. They are implemented as subroutines.
All User Exits are named by SAP as USEREXIT_XXXXXXXX. The main problem they present is finding the correct User Exit. Once found, we must verify that it serves our purpose. The ABAP code to be inserted into the User Exit can be placed within an INCLUDE that will start with Z or separately.
For entering ABAP code or modifying existing code within a User Exit, a SAP access key is not required.
For example, in the standard program MV45AFZZ, we find the following User Exit used by transaction VA02 every time it reads a document.
Transaction VA02: We will use the standard transaction VA02 to modify sales orders.
Some SD module applications still use this type of enhancement, but this practice is not used for new SAP code extensions. Instead, the other available enhancement types are used, although it's worth noting that User Exits will be maintained by SAP in the new system versions.
User Exits are hollow points generated by SAP in the standard system, located at specific places in the system. It's important to clarify that it's not possible to generate new holes or User Exits, but we must work only with existing ones. If we don't find a User Exit that fits our requirement, then we should look for another alternative solution among the other possible enhancement solutions offered by SAP in its system.
Customer Exits
It's a point within a program where a custom program can be called. They are executed from a standard program by calling a function module. Some standard programs have within their code, calls to function modules that can be modified by the programmer. Customer Exits are called within standard programs through a number. This number is the end of the function module name associated with the program.
In the MODSAP table, all function modules used in Customer Exits are found.
MODSAP Table: The standard database table MODSAP stores all existing enhancements in the SAP system.
For each enhancement, the following is stored: the enhancement name, the component type which can be "E" for Function Exits, "S" for Screens, "T" for Tables, and "C" for GUI Code, and finally the name of the SAP object (program, function module, etc.) being modified.
The main advantages of a Customer Exit are:
- The Customer Exit is a good tool to add new functionality to a standard program such as validation or execution of control routines without modifying the original code.
- To transport and activate Customer Exits, only the new Include is sufficient, without touching the original program.
The main disadvantages of a Customer Exit are:
- The Customer Exit does not always fit the programmer's needs since the objects it imports or exports are fixed and may not have all the objects required.
- There is no search for Customer Exits by program with a comprehensive explanation of their usage; to find them, you have to search for the string CALL CUSTOMER-FUNCTION within the standard control program, and its functioning is tested without knowing exactly if it is correct for what you want to do.
To work with Customer Exits, we will mainly use two transactions:
- SMOD: to manage enhancements.
- CMOD: for enhancement project management.
Steps to Perform a Customer Exit
- First, go to transaction SMOD. In the transaction, fill in the enhancement name containing the function module to be used.
- If you don't know the name, in transaction SE16 with the MODSAP table, in the MEMBER field, fill in the function module name to search for, and the NAME field will tell us the enhancement that contains it.
- If you don't know the specific name, you should search in the code of the standard program for user function calls, indicated by CALL CUSTOMER-FUNCTION '001'.
- Once you have used the name, you will see the enhancement name on the SMOD transaction screen, enter the enhancement in the SMOD transaction field, and view it.
- In the next step, press the COMPONENTS button to view all modules.
- Once you have the name of the function to use, double-click on it, which will take you to another screen, to view objects to import and export this function.
- In the Code tab, there is a Z include to add user code.
- If the include does not exist when double-clicking, the user will be prompted to assign a transport order to generate it.
- Once created, it is possible to generate ABAP code; in the objects of the IMPORT, MODIF, and TABLES tabs, being able to return results by modifying the objects found in the EXPORT, MODIF, TABLES tabs.
- Once the coding is complete, the enhancement must be activated and included in a project. Projects are created in the CMOD transaction. There, a Z project must be generated in which the enhancements to be included will be added.
An enhancement project associates multiple enhancements. Its activation or deactivation affects all associated enhancements. The transaction to access enhancement projects is CMOD. There, enter the project name and press Create. Now press the Assignment Enhancement button to assign the enhancements to include. Then, introduce the enhancements and press the Components button to visualize each enhancement's components. On the components screen, activate the enhancement by pressing the activation button. Each of these components represents the exits of the enhancement. Once activated, the enhancement project will turn green. You can deactivate the activation of the enhancement project by pressing the deactivate button.
How to test Customer Exits
A challenging aspect of using Customer Exits is locating them and understanding when they occur in the process. To conduct this investigation effectively, the most efficient method is to create an enhancement project, assign the enhancement, activate it, and then place a breakpoint in the function module to determine the data available at that moment and the exact point in the process where it is located.
 
 
 
Sobre el autor
Publicación académica de Jaime Eduardo Gomez Arango, en su ámbito de estudios para la Carrera Consultor ABAP.
Jaime Eduardo Gomez Arango
Profesión: Ingeniero de Sistemas y Computación - España - Legajo: SW34C
✒️Autor de: 102 Publicaciones Académicas
🎓Cursando Actualmente: Consultor ABAP Nivel Avanzado
🎓Egresado del módulo:
Disponibilidad Laboral: FullTime
Presentación:
Ingeniero de sistemas y computación con 8 años de experiencia el desarrollo frontend & backend (react/node) y en cloud (aws), actualmente desarrollando habilidades en sap btp, ui5, abap y fiori.
Certificación Académica de Jaime Gomez