Skip to end of metadata
Go to start of metadata

1. Introduction

Customer exits (aka user exits) are possibilites offered by SAP at strategic moments to call customer ABAP code so that to enhance the standard. Hence, customer exits acts as 'Hook' points for the custom business functionality.

These exits are function modules called by SAP, with fixed input and output parameters, and only containing an INCLUDE ZX... ABAP statement, that the client may create. The exit belongs to exactly one Enhancement (an 8 characters code), that SAP creates using SMOD transaction.

To add ABAP code, the client has to create a Project via CMOD transaction, link it to the Enhancement, create the ZX... include where he puts ABAP code, and activate both the include and the project.

Note: since NetWeaver 7.0, this concept is obsolete because replaced by the classic and new BAdIs, and SAP does not create any more customer exit. Moreover, SAP may have migrated some customer exits to classic BAdIs (an enhancement is migrated into a BAdI definition, and its customer exits are migrated into methods with the same names and signatures, i.e. list of parameters).

2. How SAP calls the exit

The call to an exit is implemented by SAP as:

CALL CUSTOMER-FUNCTION '<3 digit suffix>'
  [EXPORTING <parameters>]
  [IMPORTING <parameters>]
  [CHANGING <parameters>]
  [TABLES <parameters>]
  [EXCEPTIONS <exceptions>].

Which calls function module EXIT_<program name>_<3 digit suffix> (where <program name> is the program which calls the customer function).

Notes:

  • Sometimes, SAP uses directly CALL FUNCTION statement because the exit needs to be called from 2 different programs.
  • The difference between the 2 ABAP statements is that CALL CUSTOMER-FUNCTION does NOT call the function module if it is not linked to an active project (see below "how to implement an exit"). Thus, a break-point in the function module will be ineffective.

In this function module, SAP usually puts this code:

INCLUDE  ZX<3 characters>U<2 digits>.

Example:

  • The program for transaction VA01 Create sales order is 'SAPMV45A'
  • In program SAPMV45A (SAP R/3 or ECC), there is:
CALL CUSTOMER-FUNCTION '003'
 exporting
    xvbak   = vbak
    xvbuk   = vbuk
    xkomk   = tkomk
  importing
    lvf_subrc = lvf_subrc
  tables
    xvbfa = xvbfa
    xvbap = xvbap
    xvbup = xvbup.
  • It means that it will call the function module 'EXIT_SAPMV45A_003', which only contains this code: INCLUDE zxvvau05.
  • (as already said, this include is not initially delivered by SAP, but it may be created by the client)

3. How to implement an exit

First of all, the client must check whether an existing customer exit fits his requirements. There are 2 main ways to do this:

  1. Use transaction SPRO (SAP IMG reference guide) and look for activities named "enhancement" or "extension" and display its documentation.
  2. OR get the main program which corresponds to the transaction (status option in system menu), so that you know the potential exit function module names (EXIT_<program name>_*), then look at their documentation (SE37 transaction) or at the documentation of their corresponding enhancement (SMOD transaction).
    1. You may get the enhancement and enhancement projects associated to the customer exit by using the extended options of the search help, or by using transaction SE84 - Repository Information System.

Now, you may implement the exit this way:

  • Go to transaction CMOD
  • Create a project
  • Go to the Enhancement screen, and enter the Enhancement code which contains the user exit. Note that an enhancement can only be used in 1 project.
  • Go to the Components screen (where the available customer exits are displayed). Double click on the one you want to implement.
  • Now the function module is displayed, double click on the include ZX..., SAP displays a warning that this include will be created
  • Press enter, SAP asks for a package and a transport request
  • Insert the ABAP code into the include
  • Activate the include program. Go back to CMOD and activate the project. 

Example:

  • For example, we want to enhance transaction 'VA01', so that to default Sold-to-party field to value "2155". We already know that we have to implement user exit EXIT_SAPMV45A_002, which belongs to enhancement V45A0002
  • 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. 
  • Press Save
  • Go to the Components tab. 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. 
  • Go to transaction VA01 and create a salesorder. 
  • You see that Sold-to-party is automatically set to "2155"

More information on troubleshooting can be found here:

  • No labels

6 Comments

  1. Former Member

    Nice doc..

    Regards,

    Praveen Chitturi

  2. Former Member

    Good! It's very kind of you !

  3. Good article.

    Thanks.

  4. Former Member

    Thank you, best article I have seen about Customer Exits.

  5. Former Member

    really helpful, thanks

  6. Former Member

    Very useful article. Simple and Clear. Thank you.