Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

user exits

Former Member
0 Likes
781

hi

experts

i m new to user exits can any body help me

by explainning a simple user exit in SD how to use it by writing relevant code.

hi

experts

i m new to user exits can any body help me

by explainning a simple user exit in SD how to use it by writing relevant code.

5 REPLIES 5
Read only

Former Member
0 Likes
742
Read only

Former Member
0 Likes
742

Hi Mallika,

Check this code for a simple user exit.

Writing code to an User exit depends on the requirement.

----


  • FORM USEREXIT_SAVE_DOCUMENT_PREPARE *

----


  • This userexit can be used for changes or checks, before a *

  • document is saved. *

  • *

  • If field T180-TRTYP contents 'H', the document will be *

  • created, else it will be changed. *

  • *

  • This form is called at the beginning of form BELEG_SICHERN *

  • *

----


<b>FORM USEREXIT_SAVE_DOCUMENT_PREPARE.

INCLUDE ZSDRRDPT.

ENDFORM.</b>

Check these links for User exits

http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm

http://www.sap-img.com/abap/what-is-user-exits.htm

http://www.planetsap.com/userexit_main_page.htm

http://www.easymarketplace.de/userexit.php

http://expertanswercenter.techtarget.com/eac/knowledgebaseAnswer/0,295199,sid63_gci982756,00.html

http://sap.ittoolbox.com/documents/popular-q-and-a/debugging-a-user-exit-or-program-3022

http://help.sap.com/saphelp_nw04/helpdata/en/81/8c5738ee806b0ee10000009b38f889/content.htm

http://help.sap.com/saphelp_nw04/helpdata/en/bf/ec07a25db911d295ae0000e82de14a/content.htm

Thanks,

Vinay

Read only

Former Member
0 Likes
742

hi mallika,

check this below link it will give u good idea how to do

http://www.sap-img.com/abap/a-short-tutorial-on-user-exits.htm

~~Guduri

Read only

Former Member
0 Likes
742

Mallika,

Here is the procedure:

1. Go to SMOD transaction and enter Enhancement of SD module (any one eg. VA01 Enhancement).

2. Select proper EXIT (it's nothing but function module) and go the source code.

3. This EXIT will have 1 include program, double click and create Include, ignore the message.

4. Add your sample code here in include.

5. Save, check and Activate

5. At last activate your Enhancement.

6. Test using transaction VA01.

I hope this will help you.

Regards,

Amey

Read only

Former Member
0 Likes
742

Hi Mallika rao,

Check this info.

USEREXIT

UserExits allow us to add our own functionality to SAP standard program without modifying it . These are implemented in the form of subroutines and hence are also known as FORM EXITs. The UserExits are generally collected in includes and attached to the standard program by the SAP.

All UserExits start with the word 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 bundled in enhancement packages . Nevertheless existing USEREXITS will be supported by SAP an all the newer versions of SAP.

HOW TO FIND USEREXITS

UserExits can be found in number of ways:

1) To find UserExits in SD module , goto object navigator(SE80) and select

development class from the list and enter VMOD in it. All of the UserExits in SD are contained in the development class VMOD. Press

enter and you will find all the includes which contain UserExits in SD for

different functions like PRICING, ORDER PROCESSING etc. Select the userexit according to the requirement and read the comment inserted in it

and start coding .

Some examples of UserExits in SD(SALES & DISTRIBUTION ) are:

1)ADDING OF NEW FIELDS IN PRICING

In Pricing in SD the fields on the basis of which pricing is done are derived from the FIELD CATALOG which is a structure KOMG .This structure is used to transfer transaction data to the pricing procedure in SD and is also known as communication structure.This structure KOMG consists of two tables KOMK for Header related fields and KOMP for item related fields.

The fields which are not in either of the two tables KOMK and KOMP

cannot be used in pricing .Sometimes a need arises when the pricing

is to be based on some other criteria which is not present in the form of fields in either of the two tables.

This problem can be solved by using USEREXITS which are provided for pricing in SD.

Pricing takes place both when the SALES ORDER ( Transaction VA01) is created as well as when INVOICING ( Transaction VF01) is done.Hence SAP provides 2 UserExits ,one for sales order processing which is

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.

This example code is based on enhancement SUSR0001.This enhancement uses function exit EXIT_SAPLSUSF_001 .

Enhancement : SUSR0001 User Exit after logon to SAP system.

When the User logs in the system, this exit is called each and every time for every user after logon to the R/3 system.

Function Exit : EXIT_SAPLSUSF_001 .

Every dialog user passes through this function module after logon, It can be used to execute individual customer checks and send messages to the user.

TABLE USR02 CONTAINS LOGON DATA and can be used in this exit to get the user logon data and take necessary actions as required by the customer requirement and even LOG_OFF (not recommended by SAP).

STEPS REQUIRED FOR IMPLEMETING THE EXIT

1) Open CMOD(Project maintenance) Transaction. Enter a project name starting with Z. Press enter.

2) Goto Enhancement window by clicking the enhancement button in the application tool bar.

3) Write SUSR0001 in the enhancement column and press enter.

4) Goto Components window (It will show all the exits included in this enhancement), in our case only one Function Exit will be shown.

5) Double click on the Function exit EXIT_SAPLSUSF_001.

The following function source code will be displayed in the function editor

FUNCTION EXIT_SAPLSUSF_001.

*"----


""Lokale Schnittstelle:

*"----


INCLUDE ZXUSRU01.

ENDFUNCTION.

6) Double click on the include ZXUSRU01 .If it will ask to create the include say yes .

7)Write the following code in the include.

DATA W_TEXT(30) TYPE C.

DATA W_DATE(10) TYPE C.

WRITE sy-datum TO W_DATE DD/MM/YYYY.

CONCATENATE ' Date is ' W_DATE INTO W_TEXT.

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

title = 'Welcome to Paradise !'

txt1 = 'Have A Nice Day'

txt2 = W_TEXT

  • TXT3 = ' '

  • TXT4 = ' '

8)Save the include and activate it .Activate the Project also by going to the menu in CMOD transaction. Now The user exit SUSR0001 has been implemented and is ready to use.

9) Logon to the R/3 system . A dialog box will appear with the message

Welcome to Paradise ! with date .

NOTE: BAPIs like BAPI_USER_GET_DETAIL can also be used to get user info or directly read from tables USR02 etc.

Hope this resolves your query.

Reward all the helpful answers.

Regards