✒️ABAP Los Field Exits
ABAP Los Field Exits
Field Exits
Field Exits, also known as field enhancements, validate data elements associated with screens or dynpros in SAP. They're function modules executed after the system's standard validations. These modules have their own memory space. While running, they only have one INPUT parameter that can be altered through a single OUTPUT parameter.
They're useful for ensuring fields accept only specific values. You can discover all existing Field Exits in the system by entering 'FIELD_EXIT_*' in transaction SE37 and pressing F4.
Advantages of using Field Exits include:
- Simplifying field validation in standard programs without altering the original code.
- Reusable code across multiple transactions.
- Global validity in the system or restricted to specific programs and dynpros.
However, there are drawbacks:
- They retrieve only one value from the dynpro, referencing the field. Specific internal tables of the standard program cannot be used.
- The same Field Exit code must serve all assigned programs. If behavior should vary, actions must be specified based on the program.
- Debugging Field Exit code isn't straightforward. Messages must be used to track progress and examine data content.
- Certain ABAP instructions are forbidden within Field Exit code, such as Breakpoint, Call Screen, Call Dialog, Call Transaction, Submit, Commit Work, Rollback Work, and type I messages. To enable Field Exits, the server parameter 'ABAP Field Exit' must be set to 'Yes' via transaction RZ10.
How to Create a Field Exit
- Navigate to CMOD and execute 'PRFB' in the command screen without the need for '/n'.
- The subsequent screen displays all Field Exits in the system, including relevant information such as scope of action (global or specific programs/dynpros) and status (active or inactive).
- To create additional Field Exits, select 'Exit Field' from the menu and choose 'Create'.
- In the dialog window, specify the data element to which the Field Exit will apply, ensuring it matches the field's data element in the dynpro. Confirm.
- The system will propose a function module name to create. If the module is created, a function group will be requested, ideally unique to the Field Exit. Provide a brief description.
- The function module will have one INPUT parameter containing the current field value and one OUTPUT parameter with the field value after the Field Exit.
- In the 'Source Code' tab, enter the validation code to add. If the validation won't modify the field value, assign 'OUTPUT = INPUT' as the first line.
- Within the module, only these parameters can be manipulated. To retrieve values from other dynpro fields, use the SET PARAMETER statement to store their value in memory and retrieve it with GET PARAMETER in your module. Alternatively, use GAT_DYN_VALUE to fetch dynpro data without relying on other Field Exits.
- Once coding is complete, assign the Field Exit to a program and dynpro or make it globally applicable. Remember, if not limited to a specific dynpro, the Field Exit will affect all screens with the affected data element.
- To assign a Field Exit to a program/dynpro, click 'Assign prog./dynpro' in CMOD - PRFB. In the dialog, specify the program and relevant dynpro. Multiple programs and dynpros can be assigned to one Field Exit.
- Finally, activate the Field Exit by selecting 'Exit Field' from the menu and choosing 'Activate'.
Testing the Field Exit
- Navigate to transaction SM30, as the data element for which we created the Field Exit belongs to the "Address" field of a Z table.
- Create a new entry in the table, entering "CORRIENTES 123" in the Address field and press Enter.
- On the screen, you'll see the error message we coded.
 
 
 
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