2008 May 21 11:05 AM
I want detail about User exits with example in Real time Scenario & diff between User exits & enhancements
2008 May 21 11:23 AM
Hi Nandu
USER EXITS is a provision provided by SAP to ENHANCE the required object.In USER EXIT we write our code of enhancement.
1. Introduction
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 ❤️ digit suffix>
Example:
The program for transaction VA01 Create salesorder 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.
The exit calls function module EXIT_SAPMV45A_003
2. How to find user exits
Display the program where you are searching for and exit and search for CALL CUSTOMER-EXIT
If you know the Exit name, go to transaction CMOD. Choose menu Utillities->SAP Enhancements.
Enter the exit name and press enter.
You will now come to a screen that shows the function module exits for the exit.
3. Using Project management of SAP Enhancements
We want to create a project to enahance trasnaction VA01
Go to transaction CMOD
Create a project called ZVA01
Choose the Enhancement assign radio button and press the Change button
In the first column enter V45A0002 Predefine sold-to party in sales document . Note that an
enhancement can only be used i 1 project. If the enhancement is allready in use, and error message
will be displayed
Press Save
Press Components. You can now see that enhancement uses user exit EXIT_SAPMV45A_002.
Double click on the exit.
Now the function module is displayed. Double click on include ZXVVAU04 in the function module
Insert the following code into the include: E_KUNNR = '2155'.
Activate the include program. Go back to CMOD and activate the project.
Goto transaction VA01 and craete a salesorder. Note that Sold-to-party now automatically is "2155"
Reward if helpful
Regards
Lakshman
2008 May 21 11:49 AM
Hi,
Check the difference by below links
http://www.sap-img.com/abap/difference-between-badi-and-user-exits.htm
The following are the sample code that you can reference.
DATA: LW_POSTED_HEADER TYPE MEPOHEADER.
DATA: ITAB_IF_ITEM TYPE PURCHASE_ORDER_ITEMS.
DATA: LW_IF_ITEM TYPE PURCHASE_ORDER_ITEM.
DATA: ITAB_IF_ACCT TYPE PURCHASE_ORDER_ACCOUNTINGS.
DATA: LW_IF_ACCT TYPE PURCHASE_ORDER_ACCOUNTING.
DATA: LW_ACCT TYPE MEPOACCOUNTING.
DATA: LW_POSTED_ACCT TYPE MEPOACCOUNTING.
DATA: W_MODIFIED(5) TYPE C.
DATA: W_BNAME TYPE UST04-BNAME.
*
*
CHECK SY-UNAME+0(5) <> 'BATCH'.
Get the posted header data
CLEAR LW_POSTED_HEADER.
*
CALL METHOD IM_HEADER->GET_PERSISTENT_DATA
IMPORTING
EX_DATA = LW_POSTED_HEADER
EXCEPTIONS
NO_DATA = 1.
*
CHECK SY-SUBRC = 0.
*
Get PO line items
REFRESH ITAB_IF_ITEM.
CLEAR ITAB_IF_ITEM.
*
CALL METHOD IM_HEADER->GET_ITEMS
RECEIVING
RE_ITEMS = ITAB_IF_ITEM.
*
CLEAR W_MODIFIED.
*
LOOP AT ITAB_IF_ITEM INTO LW_IF_ITEM.
Get account assignment for each PO line item
REFRESH ITAB_IF_ACCT.
CLEAR ITAB_IF_ACCT.
*
CALL METHOD LW_IF_ITEM-ITEM->GET_ACCOUNTINGS
RECEIVING
RE_ACCOUNTINGS = ITAB_IF_ACCT.
*
LOOP AT ITAB_IF_ACCT INTO LW_IF_ACCT.
CLEAR LW_ACCT.
Get the newly updated PO item data
CALL METHOD LW_IF_ACCT-ACCOUNTING->GET_DATA
RECEIVING
RE_DATA = LW_ACCT.
*
CLEAR LW_POSTED_ACCT.
Get the posted PO item data
CALL METHOD LW_IF_ACCT-ACCOUNTING->GET_PERSISTENT_DATA
IMPORTING
EX_DATA = LW_POSTED_ACCT
EXCEPTIONS
NO_DATA = 1.
*
IF SY-SUBRC > 0.
CLEAR LW_POSTED_ACCT.
ENDIF.
*
IF LW_ACCT-LOEKZ <> LW_POSTED_ACCT-LOEKZ OR " Delete indicator
LW_ACCT-PRCTR <> LW_POSTED_ACCT-PRCTR OR " Cost center/WBS element
LW_ACCT-SAKTO <> LW_POSTED_ACCT-SAKTO OR " GL acct
LW_ACCT-VPROZ <> LW_POSTED_ACCT-VPROZ OR " Dist. Percentage
LW_ACCT-GSBER <> LW_POSTED_ACCT-GSBER OR " Business area
LW_ACCT-AUFNR <> LW_POSTED_ACCT-AUFNR. " Internal order
Account assignment was changed
W_MODIFIED = 'YES'.
EXIT.
ENDIF.
ENDLOOP.
*
IF W_MODIFIED = 'YES'.
EXIT.
ENDIF.
*
ENDLOOP.
Regards
Kiran Sure