user exit

12
What is a SAP USER EXIT? A SAP User Exit is a user defined FORM routine that is used to calculate and/or replace values within a validation, substitution, or rule. User exits have the following format: U (for a user-defined user exit) or S (for a standard user exit) The user exit number (three digits) For example, U123 is a user-defined user exit. You can configure the form pool name of the sap user exit and must store it in the table for client-dependent user exits (T80D) in Customizing. Table T80D contains the form pool names for the user exits used in validations, substitutions, and rules. Each validation/substitution form pool is client-dependent. (For more information, refer to the Maintain Client-Dependent User Exits activity in the Implementation Guide (IMG) for Special Purpose Ledger.) Example form pools RGGBS000 and RGGBR000 for client 000 are delivered with the SAP R/3 System. You must copy these form pools and configure them in T80D. The new form pool name should conform to the customer naming convention (beginning with the letter Z ) so that is not overwritten when the next SAP upgrade is installed (for example, ZGGBR000). Example FORM routine for substitution exit 001 (U001). TABLES: COBL. FORM U001. COBL-KOSTL = COBL-BUKRS. ENDFORM.

description

user exit

Transcript of user exit

Page 1: user exit

What is a SAP USER EXIT?

A SAP User Exit is a user defined FORM routine that is used to calculate and/or replace values within a validation, substitution, or rule.

User exits have the following format:

U (for a user-defined user exit) or S (for a standard user exit)

The user exit number (three digits)

For example, U123 is a user-defined user exit.

You can configure the form pool name of the sap user exit and must store it in the table for client-dependent user exits (T80D) in Customizing. Table T80D contains the form pool names for the user exits used in validations, substitutions, and rules. Each validation/substitution form pool is client-dependent. (For more information, refer to the Maintain Client-Dependent User Exits activity in the Implementation Guide (IMG) for Special Purpose Ledger.)

Example form pools RGGBS000 and RGGBR000 for client 000 are delivered with the SAP R/3 System. You must copy these form pools and configure them in T80D. The new form pool name should conform to the customer naming convention (beginning with the letter Z ) so that is not overwritten when the next SAP upgrade is installed (for example, ZGGBR000).

Example FORM routine for substitution exit 001 (U001).

TABLES: COBL.

FORM U001.COBL-KOSTL = COBL-BUKRS.

ENDFORM.

Tables and structures should not be declared in the FORM routines so that the contents can be used together with the calling transaction.

SAP exits are FORM routines that have been programmed by SAP. The name of the form pool for SAP exits is SAPFGBEB.

If you still store your rules in table T890 (interpreted rules), you cannot use user exits in your rule definition. It is highly recommended that you use report program RGUGBR10 to convert interpreted rules into generated rules so that you can use the Customizing function for maintaining rules. For more information, see Using the Rule Manager Reports .

Page 2: user exit

The following table shows the types of user exits that can be used in validations, substitutions, and rules.

User exit   type

Description Application Example

1 No parameters are defined for the user exit.

Rules, validations, and substitutions   (prerequisite)

See form pool RGGBR000, parameter type   C_EXIT_PARAM_NONE

2 Same as user exit type 1, except one parameter   (the field to be substituted) is defined in the user exit. For example, you   can create a substitution routine that analyzes the cost center irrespective   of the used field.

Substitutions See form pool RGGBS000, parameter type   C_EXIT_PARAM_FIELD

3 All data is passed as one parameter; this exit   type can only be used in matrix validations and substitutions.

Rules, validations, and substitutions   (prerequisite)

See form pool RGGBR000, parameter type C_EXIT_PARAM_CLASS

Validations and rules use exit numbers 1 and 3 from the above table.

Substitutions use all of the exit numbers from the above table.

For substitutions, you can also create user exits that accept a field as one parameter and then return the changed value in this parameter. This allows you to create a user exit that can be used independently of the field and table name. This type of user exit cannot be used as an entry in the Exit only field in the list of values to be substituted; you can only use this exit type in conjunction with a field name. An example of this user exit type is in form pool RGGBS000.

If you want to define a parameter for your user exit that is different from the result of a validation (B_RESULT), you must make an entry for your user exit in the FORM routine GET_EXIT_TITLES in the form pool you defined. It is recommended that you copy the SAP example form pool RGGBR000 for validation exits or RGGBS000 for substitution exits. These example

 

You can implement company-specific enhancements (user exits) that will provide additional functions. Customer-specific user exits may encompass such activities as:

Page 3: user exit

Specifying the conditions for dispatching      certificates (FORM routines as user exits)

Defining additional data origins for inspection      specifications, results, and short texts for characteristics in the      certificate profile (self-defined function modules as table entries)

Defining and evaluating additional limitations      for the selection of inspection lots and partial lots (SAP user exit with      menu function in the certificate profile and function modules)

The automatic entry of the characteristic detail      data in the certificate profile (SAP user exit)

Defining the layout (text elements from a      SAPscript® layout set, SAPscript® standard texts, SAPscript® layout sets)

Defining the layout and the output data for      characteristics (special text elements in the SAPscript® layout set for      the characteristic output format, inspection method and supplementary      text, if the result is outside of the tolerance; SAPscript® standard      texts)

Adding new objects to which certificate profiles      can be assigned (enhancement of a structure in the dictionary and an SAP      user exit with a function module)

Using your own program to select the data and      print the certificates (as a table entry)

To obtain information about additional enhancement possibilities, you can create a list as follows:

1. Choose Tools ® ABAP Workbench.

The system displays the initial screen for the ABAP Workbench.

1. Choose Utilities ® Enhancement ® Definition.

The system displays the initial screen for SAP enhancements.

1. Choose the possible entries help for the Enhancement field.

The system displays the selection screen for locating SAP enhancements.

1. Enter QC in the Enhancement field.2. Choose Execute

Page 4: user exit

A user exit is a place in a software program where a customer can arrange for their own tailor-made code. SD module has a large number of User exit available.

The below is the create/ change sales order screen (VA01/VA02).

The requirement is to put the validation to the line items such that the quantity field for the line item should not be less than 2 units.

Step 1: How to find the appropriate USER EXIT.

Go to object navigator(SE80) and select package  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 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 .

Page 5: user exit

There is a lot of confusion in using USER EXIT, like do we need access key to modify the USER EXIT ?.

The answer is Yes as well as NO.

If you see the include MV45AFZZ.we have many FORMS and ENDFORMS init which is in custom name space. So we don’t need key to modify it. Check out the below screen shot.

Page 6: user exit

So open that include and write your logic in ZMV45AFZZ_SAVE_DOCUMENT_PREP.

While some EXITs like MV50AFZ1. You need an access key to modify it Don’t get puzzled, this is how SAP has given J.

Step 2:

So we got our USEREXIT ZMV45AFZZ_SAVE_DOCUMENT_PREP. Open it and put the below code inside it.

data: lv_flag(1)   type c.

* exit if not SAVEif sy-ucomm ne ‘SICH’.leave to screen sy-dynnr.endif.

* check line itemsclear lv_flag.loop at xvbap where updkz ne ‘D’.*   This checks for quantity less than 2*   As xvbap-kwmeng is pack with 3 decimal we are comparing with 2000if xvbap-kwmeng < 2000.

Page 7: user exit

message i000(fb) with ‘quantity is less than 2′.lv_flag = ‘X’.clear sy-ucomm.exit.endif.endloop.

if lv_flag = ‘X’.leave to screen sy-dynnr.endif.

Go To Transaction VA01/VA02 and try to create/change the order item quantity less than 2.

Ref: http://sapignite.com/user-exits-in-sap-abap-with-tutorial/

Page 8: user exit

What is User Exits and Customer Exits? Ref: http://www.erpgreat.com/abap/what-is-user-exits.htm

Difference between user exits & customer exits:

User exit - A user exit is a three character code that instructs the system to access a program during system processing.

SXX: S is for standard exits that are delivered by SAP.   XX represents the 2-digit exit number.

UXX: U is for user exits that are defined by the user.  XX represents the 2-digit exit number

Customer exit - The R/3 enhancement concept allows you to add your own functionality to SAP’s standard business applications without having to modify the original applications. SAP creates customer exits for specific programs, screens, and menus within standard R/3 applications. These exits do not contain any functionality. Instead, the customer exits act as hooks. You can hang your own add-on functionality onto these hooks.     *-- Mani  

The following document is about exits in SAP :-

The R/3 enhancement concept allows you to add your own functionality to SAP’s standard business applications without having to modify the original applications. 

SAP creates user exits for specific programs, screens, and menus within standard R/3 applications. These exits do not contain any functionality. Instead, the customer exits act as hooks. You can hang your own add-on functionality onto these hooks.

Types of Exits  There are several different types of user exits. Each of these exits acts as hooks where you can attach or "hang" your own add-ons.

Menu Exits Menu exits add items to the pulldown menus in standard SAP applications. You can use these menu items to call up your own screens or to trigger entire add-on applications.

SAP creates menu exits by defining special menu items in the Menu Painter. These special entries have function codes that begin with "+" (a plus sign). You specify the menu item’s text when activating the item in an add-on project.

Screen Exits Screen exits add fields to screens in R/3 applications. SAP creates screen exits by placing

Page 9: user exit

special subscreen areas on a standard R/3 screen and calling a customer subscreen from the standard screen’s flow logic.

Function Module Exits  Function module exits add functions to R/3 applications. Function module exits play a role in both menu and screen exits. 

When you add a new menu item to a standard pull down menu, you use a function module exit to define the actions that should take place once your menu is activated. 

Function module exits also control the data flow between standard programs and screen exit fields. SAP application developers create function module exits by writing calls to customer functions into the source code of standard R/3 programs. 

These calls have the following syntax: 

CALL CUSTOMER-FUNCTION ‘001’.

Field Exits Field exits allow you to create your own programming logic for any data element in the Dictionary. You can use this logic to carry out checks, conversions, or business-related processing for any screen field.  Example: The data element BBBNR identifies a company’s international location number. You might want to set up your R/3 System so that all international location numbers are larger than 100. 

The field exit concept lets you create a special function module that contains this logic. 

You assign the special function module to the data element BBBNR. You then assign the module to any programs and screens in which users can add new international location numbers. When you activate your field exit, the system automatically triggers your special routine whenever a user enters a company location number. 

In 4.6c, you can use "RSMODPRF" program to create field exits.

An example of a user exits :-

MODULE user_exit_0001 INPUT      CASE okcode.         WHEN 'BACK OR EXIT'.             CASE sy-dynnr.                     WHEN '100'.                          SET SCREEN 0.                          LEAVE SCREEN.                     WHEN '200'. ******************************************************************************

Page 10: user exit

**** Note that you can write any code that satisfy your needs.                                                     **** **** But in this case, this was wrote as a sample code for reference sake.                                    **** **** And you can test it.                                                                                                             **** ******************************************************************************                           SET SCREEN 100.                          LEAVE SCREEN.              ENDCASE.       ENDCASE.