Userexits
Userexits
Userexits
User exits are SAP supplied ‘hooks’ within specific program which allow
user customizations to meet specific requirements. When the program is run,
SAP checks to see is the user has setup any logic within these hooks. For
example in the fixed asset module lets say the gain/loss from disposal is
normally booked to GL account 65410. During posting however you wish to
book certain asset retirement transaction types to 65499 for reporting
purposes. An enhancement AINT0002 exists to do this. User exits are
commonly used also with validation and substitution rules. To implement
user exist you need an understanding of the ABAP programming language.
However for those who have worked across several SAP projects its
inevitable that at some point they will have come across user exits at some
stage even if its just at a conceptual level.
Overview
R/3 provides three "customization spots" that allow you to enhance FI/CO features
without modifying the standard code. Although often collectively referred to as "user
exits," two of the three have different names. SAP Enhancements are used to expand the
standard functionality within SAP. Enhancements use function modules and are called
from the standard SAP code. Each module in the system has a set of delivered
enhancements that help companies expand the standard functionality where they need it.
Enhancements were new in release 3.0.
The Open FI Interfaces or Business Transaction Events are also used to expand the
standard functionality within SAP. These events are defined in the IMG. Business
Transaction Events were new in release 4.0. They are not available for all modules and
are not called on all integrated transactions into FI as of release 4.5B. This will change
with each release and should be retested.
Page 1
The older User Exits in FI/CO are "Z" programs that are defined in table T80D for client-
dependent user exits, and in table T80I for client-independent user exits. These are also
used to expand the standard functionality within the FI/CO modules. These User Exits
have been available since the early releases of SAP. All of these FI/CO User Exits are
listed in this document in the Configuring User Exits (Older). The list is included because
these User Exits are not a part of the Enhancements or Business Transaction Events and
do not have an Info System for searching.
Benefits
Standard SAP functionality can be enhanced without modification to the
standard code.
Upgrades do not erase the functionality and it does not have to be re-
transported or re-entered into the system. The enhancements should be
thoroughly tested when upgrading to ensure the system will still work as
implemented.
Detailed Steps
Page 2
*mast* in the short text (see Figure 1). You’ll start there. Searching for an exit
can be tricky, so make sure you try several things before giving up.
3. Execute the search.
4. Look through the list until you find the Enhancement for User exits: Customer
Master Data.
5. Double-click on the enhancement SAPMF02D. This will take you to the details of
the Enhancement and list the function modules included in the Enhancement.
6. To continue, double-click on the function module EXIT_SAPMF02D_001
7. This will take you to the source code for the function module. Click on the Import
tab to review the tables/fields that are available for the Enhancement (see Figure
2).
Page 3
Figure 2. The Tables That Are Available for the Enhancement
8. To view the tables/fields that can be changed in the function module, click on
the Export and Changing tabs. For this function module, these tabs are empty
because you can only validate data. You cannot change any fields in this
enhancement.
9. Return to the Source Code tab.
10. Scroll down until you see the Include statement in the program. The "Z"
program listed after the Include is where your code will be written (see Figure
3).
Page 4
Figure 3. Your Program Will Begin After the Include Statement
11. Double-click on the Include. You will be prompted to create the include. Click
on Yes to create.
12. At this point you will be prompted to enter a development class and to create a
transport request. If you do not know which development class to use, please
contact your technical team.
13. Enter the following ABAP code into the program (Figure 4):
*
* User exit to ensure that all US customers have a group key
* entered on the customer master.
*
if i_kna1-land1 = 'US' and
i_kna1-brsch = ' '.
message e001(F2).
endif.
Page 5
Figure 4. The ABAP Code You Need to Enter
14. Note that the table name matches the table name in the import tab tables.
15. In this example you are using the standard message class F2 with message
number 001. Normally, you will create your own message within your own
message class. All customer message classes must begin with a "Z" and are
created in transaction SE91.
16. Save the program.
17. The next step is to create the project. Go to transaction code CMOD or follow
menu path: Tools ABAP Workbench Utilities Enhancements
Project Management.
18. Enter the project name; begin the name with a "Z."
Page 6
19. Click on the Create button.
Page 7
Figure 6. Enter the Name of the Enhancement Here
The SAP Enhancement is ready to be tested! Try creating a customer with U.S. as
the country and a blank group key. Be sure to test one with a group key to make
sure the message is not displayed in error as well.
Page 8
Enter the ABAP code into the source code section of the new "Z" function
module. You may choose to create a "Z" program to enter the code into and
then insert the "Z" program into your function module source code.
Activate the function module.
Assign the function module to the event, country and application.
To accomplish this requirement, Company A will use the Business Transaction Event
1130, Post Document: SAP Internal Field Substitution.
Page 9
Figure 7. Find the Correct Interface for the Business Event
5. Put your cursor on the event and click on the Sample Function Module button.
6. You are now in transaction SE37 – Function Builder. This is the function module
(sample_process_00001130) you will need to copy into a "Z" name function module
for your coding (see Figure 8).
Page 10
Figure 8. This Is the Function Module You Need to Copy Your "Z" Name Function
Module
Page 11
Figure 9. Enter Your "Z" Function Module Name Here
10. In Function Builder (transaction SE37), enter the new "Z" function module. Click on
the Change button.
11. The system will default into the source code screen where you may enter your ABAP
code.
12. Notice the tables available for the code. Additional tables may be declared if
necessary.
13. Enter the following source code (see Figure 10):
tables: lfa1.
data: z_groupkey like lfa1-konzs.
Page 12
Figure 10. The Screen Where You Enter Your Source Code
Page 13
Figure 11. Activate the Function Module from This Screen
17. Assign the function module to the event in the IMG: Financial Accounting
Financial Accounting Global Settings Business Transaction Events
Settings Process Function Modules of an SAP Appl.
18. Hit enter past the warning messages that this is SAP data.
19. Click on the New Entries button.
20. Enter the process for your interface. In your example it is 00001130.
21. Enter the country the interface is valid for. If it is valid for all countries, leave this
field blank.
22. Enter the application the interface should be called for. If it should be called for all
applications, leave this field blank. Please note that not all integrated transactions are
programmed to go through these interfaces! You will need to test to find out!
23. Enter the new "Z" function module (see Figure 12).
Page 14
Figure 12. Enter Your New "Z" Function Module Here
24. Save the settings. At this point you will be prompted for a CTS number for the
configuration change.
25. The Business Transaction Event is complete! You are ready for testing.
Page 15
Rollups in SPL
Fixed Field Movements in SPL
Cost Center Summarization on Detail Screen
Sets Formula Variables
Company A would like to add a "Z" field in the Special Purpose Ledger to capture a
Business Unit field for reporting. They have used all the standard SAP fields such as
Business Area and Profit Center. The field will only be used for reporting and is only
needed in the Special Purpose Ledger. You created a special ledger table (ZZSPL1) with
field Z_BUNIT and need to populate this field based on a combination of G/L account,
fund and functional area.
To accomplish this requirement, Company A will use the Variable Field Movement User
Exit. To make maintenance easier, table ZZBUSUNIT was created with the G/L account,
fund and functional area fields as key fields, and the business unit field as a non-key
field. You generated the table maintenance so the table could be updated using
transaction SM30. SAP users update the business unit determination rules in table
ZZBUSUNIT by entering the G/L account, fund and functional area, and then the
business unit that combination should be posting to. The User Exit will read table
ZZBUSUNIT using the G/L account, fund and functional area from the posting
transaction and determine the business unit. The steps for using the user exit are detailed
below. This example was created on a 4.6C system.
1. Copy the delivered template User Exit program RGIVU000_TEMPLATE into a "Z"
program. Follow menu path Tools ABAP Workbench Development
ABAP Editor (transaction code SE38). In early releases, the delivered program was
RGIVU000.
2. You will be prompted for a development class and a transport. Please check with the
technical team for the correct development class.
3. At the initial ABAP Editor screen, enter your new "Z" program name, select the
Source Code button and click on Change (see Figure 13).
Page 16
Figure 13. To Enter Your New Code, Select Source Code and Click on the Change
Button
ENDFORM.
Page 17
Figure 14. Enter Your New Code at This Screen.
Page 18
Figure 15. Enter Your "Z" Program in the Application Area GIMV: Variable Field
Movement
Page 19
Figure 16. After You Assign the Business Unit Field and the G/L Account, the Exit Field
Should Contain U01.
11. Assign the business unit field as a receiver and the G/L account as the sender. The
Exit field should contain U01 (see Figure 16).
12. The User Exit number U01 calls User Exit E01_MVC form in the "Z" program.
13. Save the field movement.
14. You are ready to test your User Exit!
Page 20