User Exits

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 38

ENHANCING SAP SOFTWARE

SAP has developed its various modules with standards, which are broadly practiced all over. But yet the
requirements of customers differ from place to place. In this scenario it becomes imperative to modify
SAP objects to suit the customer needs.

Hence SAP allows you to change the system accordingly and add your own functionality to the SAP
system. There are four different ways of changing the SAP system to fit our needs.

1. Customizing: Customizing constitutes changing the system parameters with its own special user
interface. These changes are organized and preplanned. It is an obligatory part of a SAP
Implementation.

2. Enhancements: It constitutes changes of SAP Repository objects by the customer without


modification. Inserting user developments into SAP development objects at predefined positions
using User Exits, Customer exits, Appends, Includes, and classical BADI’s.

3. Modification: Modifying the SAP repository objects in the form of custom changes. This should be
avoided because when SAP changes occur in new version then the custom version and the new SAP
version have to be reconciled manually. This means an increased maintenance workload because of
the need to adjust all such modifications. Hence, use of this option has to be avoided as far as possible.

4. Customer Development: If the customer requirements are not met by SAP then we should go in for
custom development. This means that we need to create customer specific objects within the
customer range.

Modification and Customer Development involve high maintenance and costs. Hence use these only
when customer requirements are not met by Customizing or by Enhancements.

The way the standard SAP system is enhanced lot better with the introduction of ‘Enhancement
Framework’ a new technology. The future ABAP enhancement functionalities will be using this new
framework.

Enhancement METHODS available


Prior to introduction of Enhancement Framework

User-Exit

Customer-Exit

Classic BADIs

User-Exit is one of the very first mechanisms provided by SAP to execute custom code in between the
standard SAP control flow. This is implemented as subroutine call (PERFORM xxx). A classic example for
User-Exit is MV45AFZZ include in order processing module of SAP R/3. Though this include object
doesn’t fall under customer namespace, the object doesn’t get overwritten during upgrade.
Customer-Exit is better than the user-exit, in the sense that it is implemented using Function Modules
and so has a well-defined parameter interface. Also since the custom coding done as part of these
customer-exits is located away from the original SAP code, the maintenance is easier than user-exits.

BADI-s (Business Add-Ins), as they exist in pre NW04s releases are now called old classic-BADIs. This was
the first object-oriented way to enhance the ABAP system. This, to a certain extent, allows multiple
implementations with limited filter support. The classic-BADIs are implemented using ABAP Objects.

Method 1:-
User Exit:-
Function-Exit:-

User exits (Function module exits) are exits developed by SAP. The exit is implementerd as a call to a
functionmodule. The code for the function module is writeen by the developer. You are not writing the
code directly in the function module, but in the include that is implemented in the function module.

The naming standard of function modules for functionmodule exits is:


EXIT_<program name><3 digit suffix>

The call to a functionmodule exit is implemented as:


CALL CUSTOMER.-FUNCTION <3 digit suffix>

Example:
The program for transaction VA01 Create sales order is SAPMV45A

If you search for CALL CUSTOMER-FUNCTION i program


SAPMV45A you will find ( Among other user exits):

CALL CUSTOMER-FUNCTION '003'


exporting
xvbak = vbak
xvbuk = vbuk
xkomk = tkomk
importing
lvf_subrc = lvf_subrc
tables
xvbfa = xvbfa
xvbap = xvbap
xvbup = xvbup.

This blog is going to explain you many ways to find the User Exit's & BADi's for desired transaction code.
Since the objective of the document is to explain the search method I'm not going to take much time in
explaining the functionality of the said features.

In order to explain you in the simple manor I've taken 'MM01 - Creation of Material Master' transaction
code as an example. Please follow the below steps to know the different ways of finding user exits and
BADi's.

Method 2:-

 Enter the transaction code in the command bar, for which you would like to search for an user
exit and then click on enter, so that it would take you to the initial screen of the transaction.
 Go to Menu bar - Click on 'System' and then click on 'Status' as shown in the below screen shot.
o Once you click on the 'Status' below screen would get popped up. Here, double click on the
program name.
o Once the program window is open, go to Menu Bar --> click on 'Goto' and then click on 'Object
Directory Entry'.
o The above step would take you to a pop up window and here copy the Package Name as
shown in the below screen shot.

o Once you get the package number execute the transaction code SE80 (We can also try with
SE84) and then click on 'Repository Information System'.
o As soon as you done with the above step the system would display the respectiveObjects
list, here drill down Enhancements and then Customer Exists.
o Now, double click on Enhancements, which is under Customer Exists, so that the selections
screen would get displayed in right side.
o Here go to package field and paste the copied package number from the previous step
(program) and then execute the transaction as shown in the below screen shot.
o As soon as you execute the above step, it would display the list of user exits for the relevant
transaction / package number.

In order to find out the relevant BADi for a transaction code, follow the above steps but
instead of expanding Customer exits, expand Business Add-ins as shown below.
o Drill down Business Add-ins and then double click on Definitions, so that the selection
window would get open in the right side of the screen. Here enter the copied package number
in the Package field and then execute the transaction as show below.
o As soon as you execute the above step, it would display the list of BADi's for the relevant
transaction / package number.

Method 3:

o Execute the transaction code SE93 --> enter the desired transaction code in Transaction Code
field and then click on Display button as shown in the below screen shot.
o Once you click on Display button it would show the below screen, double click on the program
name.

o Once the above step is done, go to Menu Bar--> click on 'Goto' and then click on 'Object
Directory Entry'.
o As soon as you done with the above step, the system would pop up with a window as shown
below, copy the Package name for the further process.
o Once you get the package number execute the transaction code SMOD --> place cursor
on Enhancement field and then press F4.
o It would take you to the below screen (Repository Info Systems). Enter the package number,
which has copied from the previous step. And then click on enter button.
o As soon as you execute the above step, it would display the list of user exits for the relevant
transaction / package number.

Method 4:

Along with above methods I would like to show the ways to find the Exist / BADi's at
configuration / SPRO as well.

Example: If you would like to know the relevant user exits at the functionality level like,
‘Logistics Invoice Verification’, follow the below steps.

o Execute the transaction code SPRO and click on SAP Reference IMG --> drill down Materials
Management --> Logistics Invoice Verification --> Maintain Customer Exits and Business Add-Ins
--> click on IMG Activity Document on Maintain Customer Exits for Invoice Verification, so
that it would show the list of Customer / User Exits for the functionality.
In order to find out the relevant BADi at the functionality level, follow the above steps but
instead of clicking on click on IMG Activity Document for Maintain Customer Exits for Invoice
Verification, click on IMG Activity Document for Maintain Business Add-Ins for Invoice
Verification, so that it would display the , so that it would show the list of BADi's for the
functionality.

Method 5:
If you find difficulty in finding the exact node, follow the below steps

o Execute the transaction code SPRO and click on SAP Reference IMG--> click on Find
button or press Ctrl+F.
o Once you click on find button the below pop up window gets displayed --> enterCustomer
Exits in the Search Term field and then press enter button.
o Once you hit enter, the system would provide you the list of results for the search term, which
you have entered. You should be very patience in finding the right node as the list would be
very big. You can take the 'In Area' reference as that would provide the information about the
functionality of the node. Refer the below screen shot for your info.
o As soon as you find the right node, double click on it and it would take you to the configuration
node, for which it belongs to.

 Now you can click on IMG Activity Document for Maintain Customer Exits for Invoice
Verification to display the relevant Exits.
Method 6: -
BADI Findings
Screen Exit :-

Before we start with this article of how to create a screen EXIT have a look into the below image.

> Whenever the statement CALL CUSTOMER-SUBSCREEN <area> INCLUDING <X-function-pool>

<screen_number> occurs at PBO in the flow control of a screen, a subscreen is included in the subscreen

area defined by SAP application programmers. At this point, all modules called during the PBO event of the

subscreen are also processed.

> The PAI event of a subscreen is processed when the calling screen calls the subscreen during its PAI event

using the statement CALL CUSTOMER-SUBSCREEN <area>.


> The global data of the calling program is not known to the X function group that contains your subscreen;

SAP application programmers use function module exits to explicitly provide this data to subscreens.

> In order to facilitate data transport, modules are called in the flow control of the calling program that

contain function module exits for transferring data via interface parameters.

> Function modules belonging to these kinds of function module exits can be found in the same function

groups as their corresponding subscreens.

> Data must be transported in the other direction as well, since global data from the X function group that

contains your subscreen is not known to the calling program either. For this reason, SAP application

programmers use function module exits to return any data to the calling program that was changed in the

subscreen.

> This is done by calling a module during the main screen’s PAI event that contains a function module exit

for returning customer data via interface parameters.

So In simple words Screen exit also require Two function module exits to make it to stand

properly.

Starting with the Practical:

Below is ME22N screen, Now the requirement is to modify it with few extra fields into item level data.
Step 1 :CMOD is the transaction code using which we can use this components

Go to Transaction code CMOD -> Enter the Project name As ZDEPO (you can give any name).

Step 2 :

Click on the button Enhancement Assignment

Include this Enhancement MM06E005 (Transaction code SMOD is used to find the proper enhancement

needs to be used) Read article Enhancement in SAP to know how to find out appropriate enhancement.

We have already discussed how to find the respective component for your change.
Step 3:

Click on Components Button.

You can see the below components into your Project:

It is having Function EXITs, Screen EXITs and few includes for the table.

As we have discussed you want to Display Extra fields into ME22N screen.

Double click on the CI_EKPODB it will take you to SE11 screen.

Step 4:

Include the field which you want to Show or enhance.

Here we have used field ZZPOTYP which is of type Char4. Save it and activate it.

(Note: it may take long time to activate as this field will be inserted into EKPO table.)
Step 5:

Click on the BACK button and go back to the below screen. Now you can design visual part of your work.

Double click on the Screen EXIT 0111.It will take to you to Screen painter Se51.

Step 6:

Click on the layout button in the screen. And create label and text field.

Here we are going to insert our created field ZZPOTYP.

Click on the button Dict./Program fields.

Enter the Table/Field name as : EKPO_CI-ZZPOTYP and click Get From Dictionary button.

Select that field and insert it into the screen.

Save your changes and activate this screen.


Step 7: Again go back to the below screen using back button.

Till now we have created a SCREEN. (First image of this article: Calling customer subscreen ).

Now we need to implement Two Function EXIT to transfer data to the sub screen and to read the data from

the subscreen .

Here Function EXIT:

EXIT_SAPMM06E_016.–> use to transfer data to the subscreen.

EXIT_SAPMM06E_018.–> use to get the data back from the subscreen.

Double click in the First 016 exit it will take you to the function module , you will find one include

INCLUDE ZXM06U41 .

Double click on this include and create it. Put your code to initialize the variable EKPO-ZZPOTYP here.
Step 8:

For learning purpose we have just use a single line of code to make it easy.
EKPO_CI-ZZPOTYP = ‘ABCD’.

Step 9:

Same way you can use the EXIT: EXIT_SAPMM06E_018. For reading the value if use modify it in screen.

For time being ignore this step. And Go back Again to the CMOD screen and Activate your project ZDEPO.
Step 10:

Go to transaction code ME22N open any existing PO. You can see an extra tab is added into ITEM detail

Customer Data. Which will have your new field ZZPOTYP.

This Extra tab Customer Data is added by standard SAP code. Whenever it finds any active screen exit

while execution, it will activate this tab. (Note: screen 0111 which we have used is defined under “Customer

Data” tab.)
Menu Exit:--

Menu Exit is use to add custom menu option to the standard menu.

As an example suppose you want to add the extra option to navigate to transaction SU01D from the SE38

Program Display screen. Suppose you want put that menu option just below the UtilitiesàVersions. Check

the below screen shot.

Step 1:

Find out the Menu exit which can be used to achieve this functionality.

Go to System status and find out the package name used for this SE38 Source code Display screen. The

program name is SAPLS38E to display the source code in transaction SE38. Go to attribute of this Program,

you can find the package as SEDI.


Take this package name SEDI and Go to transaction code CMOD .Use the menu path Utilities->SAP

Enhancement.

Give the package name as SEDI and execute it. You can find the below list of enhancements

As per the description : Enhancement SEUED001 Can be used. So Now when you got your dream

enhancement let’s start the movie.

Step 2:

Go to Transaction CMOD and create a Project ZMETEST (You can give any name).Click on the button Assign

Enhancement and include the Enhancement SEUED001.Click on the components button you can see the

below Exits.
Step 3:

Double click on the EXIT SAPLS38E +PGE. It will popup you the extra menu option which you

want to add.

Step 4:
When you click on the “Go to Su01d” menu option the screen execution should go to the SU01D transaction.

To write this navigation code we can use Function exit EXIT_SAPLLOCAL_EDT1_002 (Some time you need to

try trial and error method to find out the related function module name).Double click on it and write the

below code into the include ZXSEUU25.(which is inside the Function module EXIT_SAPLLOCAL_EDT1_002).

(Note: Set parameter statement is not required it is just for setting the user id as your id in SU01D)
set PARAMETER ID ‘XUS’ FIELD SY-uname.
Call transaction ‘SU01D’ .

Step 5:

Go back to CMOD screen and activate your project.

Step 6:

Open Se38 screen with any report program and go to the menu path UtilitiesàGo to Su01d.

It will take you to Su01d screen.

(Note: It is good practice to De activate the project if you are doing this tutorial for learning purpose. J )
Field Exit:--

“In this scenario, I would like to explain about Field exit enhancement for MK01standard transaction
in Control tab under Tax information”.

Note : This field Enhancement will reflect in the transactions XD01, FK01 andMK01.

Go to “MK01” transaction

Enter the Vendor, Purchase Organization and Check the Control details in General data

The Enhancement fields are SS number, em no and Fiscal address under Tax Information (as shown
below)
Go to “CMOD” transaction

Go to Standard Menu : Goto-->Text enhancements-->Keywords-->Change

Enter the Data Element: STCD1

Change Description : ss number


Change Tax Code1 is as shown below

Press “Save”

Specify the Request Number


Enter the Data Element: STCD2

Change Tax Code2 as shown below


Press “Save”

Specify the Request Number

Enter the Data Element : FISKN_K

Change description is as shown below with “Financial Year”


Press “Save”

Specify the Request Number

Now, Go to transaction MK01.

The Field Enhancement details are shown below.

You might also like