Before we get into a long discussion about user exits, we should consider the proper role that a user exit should play in SAP development. But before we can do that, we need to understand what exactly it is an SAP Developer should be doing:
- We need to know the ins and outs of our SAP systems as well as all the tools available to us within these systems.
- We need to further understand (in full detail) the business process we are touching and select the best tools and practices in order to build an elegant and maintainable solution.
The theory behind this article applies to all SAP ABAP based products; however the concrete examples and screen shots are derived from an ECC system.
As we have a responsibility incumbent upon ourselves to build elegant solutions, we should now look at applying user exits as one such instrument to consider for this purpose. First let us consider if coding solutions should be used at all. The truth of the matter is this: we should discourage coding solutions whenever possible. A solution that can be built and maintained using the inherent framework of the packaged system is clearly more elegant and more maintainable; thus we have the responsibility to ensure that this avenue is fully explored before considering other options.
A good technique is what I like to call the commonality approach. It consists of asking yourself one simple question: ‘How common is what I am doing?’ That is, try to discern using your best judgment as to whether your business process is quite unique or if this is likely something that has been faced by others before you.
- If it seems to be clearly something that weaves a common thread across all or most businesses, then you should really search for a configuration-based solution, as the tools for it probably do exist.
- If it falls more on the unique end of the spectrum, you should still perform due diligence and check the IMG, the Internet, SAPhelp.com, your network of SAP savvy friends and of course - consult with your favorite HR Focal Point resource (tell them Jeff sent you).
Often a solution based in configuration will have some coding components, such as dynamic actions.
Once we’ve eliminated the possibility that the system has a pre-built, configuration-based solution, we can move on to the design and development of our own solution. Most often there will be many options for building a solution. Again, trying to work within the SAP framework as much as possible will help us build more elegant and maintainable solutions. Adding a myriad of custom tables is often an indicator that you may have overlooked a configurable process already provided by SAP.
To make SAP-based solutions easier, SAP has provided user exits. These user exits come in a variety of forms, and here are some examples:
- Enhancement Spots
- Function modules
- Dynamic actions
We should definitely consider the application of these user exits before considering the option of creating a custom process, custom screens and custom tables. Fully utilizing the user exits before considering custom objects will help keep your enterprise system clean and stable. Even when we do decide to utilize a user-exit, we should work within the standard SAP framework to every extent possible.
It used to be that the questions of whether an appropriately placed user exit exists and how one could find the appropriate user exit was daunting. Now with the addition of implicit enhancement spots we are often able to find locations for our user exits much more easily. However, often a client’s comfort level is higher when using the more traditional user exits than placing custom code in the implicit enhancement spots, as using the SAP recommended areas tend to lead to a better overall design. Looking within SE80 to find the SAP’s pre-built user exits per each specific functional area is a good place to start. For example if you have a requirement within Personnel Administration you can search using the Repository Browser.
Figure 1: List of Functional Areas with for SAP Package PAOC_PAD* Selected
In figure 2, you’ll see that if you need help determining which package to search you can matchup your requirements with the Development Hierarchy in SE81.
Figure 2: SE81 Development Hierarchy – Use the Package names to search.
Use the combination of SE80 and SE81 you can search for BAdi’s and Enhancement Spots for your specific functional area.
Having a user exit in the appropriate spot is critical for customizing a process through coding. The other concern is having access to the proper variables within a user exit. Another way to say this is: having a user exit that doesn’t allow for accessing the information you need doesn’t really help you much. However, there is a technique that allows you to greatly expand the scope of variables you can use inside your user exits. Being able to have more variables to read greatly enhances the power of user exits.
The following technique is a powerful tool and as with any tool it has the potential to be used properly or abused so please do not use it to change stack variable values.
Figure 3: Example of The Debugger Call Stack
At a client some time ago - I needed to filter out CATS (Timesheet) reporting based on cost center values. I took advantage of the CATS Data Selected method for the CATS Reporting BADI. In this example if the user entered in a cost center on the selection screen the client wanted to make sure the personnel number was valid in that cost center for the records displayed.
METHOD if_ex_cats_reporting~cats_data_selected .
* Table CH_CATS_DATA is the table to change
lt_cats_data TYPE catsdb_ext_itab,
lt_pnpkostl TYPE STANDARD TABLE OF kostl_rang,
l_prog(40) TYPE c VALUE '(RCATS_DISPLAY_ACTIVITIES)PNPKOSTL',
ls_cats_data LIKE LINE OF lt_cats_data,
ls_pernr TYPE pernr-pernr,
lt_0001 TYPE STANDARD TABLE OF pa0001,
lt_date_range TYPE RANGE OF sy-datum,
ls_date_range LIKE LINE OF lt_date_range,
ls_0001 LIKE LINE OF lt_0001.
<kostl> TYPE table.
lt_cats_data = ch_cats_data.
ASSIGN (l_prog) TO <kostl>.
IF NOT sy-subrc IS INITIAL.
lt_pnpkostl = <kostl>.
CHECK NOT lt_pnpkostl IS INITIAL.
SORT lt_cats_data BY pernr.
*--- If user entered cost center only include pernr records when pernr
*--- was in that cost center
Notice the use of the l_prog variable and <kostl> field symbol. This technique allows me to check that a variable from a prior stack call is populated before continuing.
In summary, user exits are a very important part of letting us modify an SAP system and knowing when and where to use them is crucial. Once you have found one to use you can use this technique to greatly expand the user exit’s reach by reading variables from programs that are nested several layers within the system.
ABOUT HR FOCAL POINT
- When time, accuracy and high-quality support are essential, HR Focal Point's precision approach to SAP HCM solutions is the clear choice.
- HR Focal Point has been the SAP HCM expert since 2004 with hundreds of years of combined consulting experience its team.
- HR Focal Point has the SAP HCM experts that will allow you to achieve your goals on time, on point and on budget, thus maximizing your ROI.
- HR Focal Point offers a flexible engagement model so you only pay for the services you require, when you require them.
- As an SAP Services Partner, HR Focal Point is known for delivering high-quality solutions, in support of SAP HCM, that are completed accurately and on schedule.
- HR Focal Point has partnered with SuccessFactors to develop and deliver innovative Cloud solutions, including Employee Central Payroll, for their clients.
FOR MORE INFORMATION
HR Focal Point
Telephone: +1 855.464.4737