Professional Documents
Culture Documents
Sap SD User Exits: User Exit and Enhancement Explained in Detail
Sap SD User Exits: User Exit and Enhancement Explained in Detail
USEREXIT
FORM USEREXIT_..
z..
ENDFORM.
The problem lies in finding the correct userexit and how to find it if one exists for the purpose. Once
the correct userexit is found the necessary customer code is inserted in the customer include
starting with the z.. in the form routine.
e.g. USEREXIT_SAVE_DOCUMENT_PREPARE
Certain application like SD still provide this form of enhancement using userexit but this practice is
no longer being followed for newer extensions instead they are using EXITs which come bundeled
in enhancement packages . Neverthiless existing USEREXITS will be supported by SAP an all the
newer versions of SAP.
USEREXIT_PRICING_PREPARE_TKOMP or
USEREXIT_PRICING_PREPARE_TKOMK
Depending upon which table (KOMK or KOMP) the new fields were inserted we use either of the
above two userexits.These userexits are found in include MV45AFZZ of the standard SAP sales
order creation program SAPMV45A.
In the case of userexit which will be called when invoicing is done ,these are provided in the include
RY60AFZZ which is in the standard SAP program SAPMV45A. The name of the userexits are
same. i.e
USEREXIT_PRICING_PREPARE_TKOMP or
USEREXIT_PRICING_PREPARE_TKOMK
These userexits are used for passing the data from the communication structure to the pricing
procedure, for this we have to fill the newely created field in the communication structure KOMG for
this we fill the code in the above userexit using the MOVE statement after the data that
has to be passed is taken from the database table by using the SELECT statement. The actual
structure which is visible in these userexits and which is to be filled for that particular field is
TKOMP or TKOMK.
Before the coding for these userexits is done ,it is necessary to create a new field in either of the
two tables KOMK or KOMP .For this purpose includes are provided in each of them .
To create the field in header data(KOMK) the include provided is KOMKAZ
and to create the field in item data(KOMP) the include provided is KOMPAZ.
One possible example for the need of creating new fields can be e.g. Frieght to be based upon
transportation zone ,for this no field is available in field catalog and hence it can be created in
KOMK and then above userexits can be used to fill the transportation data to it.
2)The other method of finding userexit is to find the word USEREXIT in the
associated program of the transaction for which we want to determine userexit using SE38.
3)The other method of finding userexits is to find the include in case of SD/MM applications where
the userexits are located ,this can be found in the SAP reference IMG generally in the subfolder
under SYSTEM MODIFICATION.
USEREXIT_NUMBER_RANGE
This userexit is used to assign a different internal document number to the
sales order(VA01) when it is created depending on some criteria like a different SALES
ORGANIZAION(VKORG) .
USEREXIT_SAVE_DOCUMENT_PREPARE
This userexit is used to insert the ABAP code which will be called when the document (sales order
VA01) is just about to be saved.This userexit is used generally for custom checks on different fields
, to display some information before the order will be saved or for making changes to certain fields
before the sales order will be saved.
e.g. EXIT_SAPMV45A_002
This exit is found in SD in enhancement V45A0002.
TYPES OF EXITS
1)MENU EXITS
2)FUNCTION EXITS
3)TABLE EXITS
4)SCREEN EXITS
5)KEYWORD EXITS
6)FIELD EXITS
We use SAP transactions CMOD and SMOD to manage exits. Before implementing an exit , it is
required to create the project by using CMOD selecting the enhancement e.g. V45A0002 and
selecting the component (one which fulfills our need) i.e the exit which will be implemented in
SMOD and after coding has been done the project has to be activated.
An exit can be coded only once.
FUNCTION EXITS
These are used to add functionality through ABAP code . These start from the word
EXIT_programname_NNN ending in a 3 digit number. No access code is required to implement any
tupe of exit including function exits.
The function exits are called from the standard SAP program in the form
of ABAP statement
CALL CUSTOMER-FUNCTION 'NNN'
e.g.
Double clicking on this exit will takes us to function builder (SE37) . This
function exit has one exporting parameters and two importing parameters, we are interested in
exporting parameter which is E_KUNNR of type KNA1-KUNNR i.e if we move the desired
customer name to this structure(E_KUNNR) it will be shown in the field as the default value when
we create the sales order.
This function also contains a customer include ZXVVA04 . This include will be used to write our
custom code .
Double clicking on this include and it will prompt us that this include does not exists do you want to
create this object ,select yes and the include will be created .In this include we can write our own
code that will fill the field E_KUNNR.
e.g. E_KUNNR = 301.
Activate the include and Activate the project. Now when ever the SALES ORDER will be created ,
sold-to-party field will come up with a predefined customer .
FIELD EXITS
The field exits are managed,created,activated through program RSMODPRF. The field exit is
associated with a data element existing in ABAP dictionary and hence to the screen field using that
data element.
The format of field exit is :
FIELD_EXIT_dataelement_A-Z or 0-9
If a particular screen and program name is not specified than the field exit will effect all the
screens containing that data element.
The function module associated with field exit shows two parameters INPUT and OUTPUT. Input
parameter contains the data passed to the field exit when the field exit was invoked by the R/3 , We
can write our own code to change the output parameter depending upon our requirements.
Before the field exit can have any effect the system profile parameter
ABAP/FIELDEXIT in all the application servers should be set to YES
ABAP/FIELDEXIT = YES.