To obtain the access key for changing a SAP standard object, one must go to the SAP Service Marketplace website and register the object. To code a function exit, one locates the exit point in the SAP code, creates an include program, writes custom code in the include program, and activates the function exit by adding it to a project using transaction CMOD. Transaction CMOD is used to create projects that can activate enhancements, while transaction SMOD is used to create and view enhancements and their components, such as function exits.
2. Objectives
• The participants will be able to:
– Discuss the procedure of modifying SAP Standard
program through procedure SSCR (SAP Software
Change Registration).
– Locate, code and implement Function exits.
– Differentiate between CALL FUNCTION and CALL
CUSTOMER-FUNCTION statements.
– Identify Projects and Enhancements and use the
transactions CMOD and SMOD.
Dec-2008 User Exits | 2
3. Overview
Dec-2008 User Exits | 3
If you try to change the SAP
program “SAPMF02K”, you will
be prompted to enter the access
key for that object.
It mandatory for users to register all manual changes to SAP source coding and
SAP Dictionary objects through a procedure called SSCR.
4. SAP Modification
Dec-2008 User Exits | 4
After you enter the appropriate access key, you will be able to modify a SAP
standard object. You should avoid making repairs to SAP objects/code.
5. Obtaining Object Access Key
Dec-2008 User Exits | 5
To obtain the access key for changing a SAP
Standard object, either run transaction OSS1 or
go to the site www.service.sap.com.
6. Obtaining Object Access Key (Contd.)
Dec-2008 User Exits | 6
Go to the registration tab
Go to Register Objects
7. Obtaining Object Access Key (Contd.)
Dec-2008 User Exits | 7
Select your server by matching
installation number.
Provide the Object name, SAP
Release and click on the
‘Register’ tab.
The Registration Key for the
Object will be displayed.
8. Different Enhancement Techniques
Dec-2008 User Exits | 8
SAP 3 Tier Architecture
PRESENTATION :
Field Exits (SAP would no longer support Field Exits)
Screen Exits
Menu Exits
APPLICATION:
Program exits ( Function Exits, BAdis, Business
Transaction Events, Substitution Exits )
DATABASE
Append Structure
9. Information on existing User-Exits
Dec-2008 User Exits | 9
Using transaction SPRO, one can information along with detailed documentation
on the Exits available for areas of concern.
10. Function-Exits
Dec-2008 User Exits | 10
*-------------------------------
---*
* include zxf05u01.
*
*-------------------------------
---*
This INCLUDE
program is where you
will write the
customer-specific
code.
call customer-function
“001”...
function
exit_sapmf02k_001.
include zxf05u01.
endfunction.
SAP Original Code
“SAPMF02K”
Function Module INCLUDE Program
This INCLUDE program
will not be overwritten
with an SAP upgrade
because it is not SAP
original code.
11. Call Customer-Function Versus Call
Function
Dec-2008 User Exits | 11
The CALL CUSTOMER-FUNCTION
statement will only execute the
function module if the module
is activated.
call function ‘EXIT_SAPMF02K_001’
Both of these CALL statements refer
to the function module
“EXIT_SAPMF02K_001”.
12. Business Case Scenario
Dec-2008 User Exits | 12
UPDATE LOG
Vendor #
Vendor name
When the user updates a vendor record, you want to
insert a record into an update log that contains the
vendor number and name of the updated record.
13. Steps to Coding a Function-Exit
Dec-2008 User Exits | 13
1. Locate Function-Exit(s)
2. Go to Function Module
3. Create INCLUDE Program
4. Code in INCLUDE Program
5. Activate Function-Exit
15. Locate Function-Exit(s)
Dec-2008 User Exits | 15
In program “SAPMF02K”, search
for the string “call customer-
function” in the main program to
find all of the function-exit(s) in
the program.
16. Locate Function-Exit(s)
Dec-2008 User Exits | 16
Double-click anywhere on
the call customer-function
“001” statement to go to that
line in the SAP program.
In program “SAPMF02K”, there is
only one function-exit at line 83 of
“MF02KFEX”.
17. Go to Function Module
Dec-2008 User Exits | 17
Double-click on ‘001’ of the
CALL CUSTOMER-FUNCTION
“001” statement in the SAP
program to go to the function
module “EXIT_SAPMF02K_001”.
18. Create INCLUDE Program
Dec-2008 User Exits | 18
Double-click on the INCLUDE
ZXF05U01 statement in the
function module to create the
INCLUDE program.
19. Code in INCLUDE Program
*------------------------------
* INCLUDE ZXF05U01
*------------------------------
if sy-uname = ‘SANGRAMC’.
endif.
Dec-2008 User Exits | 19
Write code in the include program.
Whatever logic you add here will affect all
SAP standard transaction where this
particular User Exit is being called.
Put all your code within the username
check, while you are at the middle of the
user exit development. So, that your logic
in the exit (which is incomplete now) does
not affect others users in the system.
At the end of the development, when you
have tested that your logic is correct,
remove the username check. So, the
additional logic (tested & verified now) is
now triggered for all users in the system.
20. Activating Function-Exit
Dec-2008 User Exits | 20
X
X
PROJECT 1
(can be activated/deactivated)
Enhancement
1
Enhancement
2
Function
Exit
Screen
Exit
Function
Exit
PROJECT 2
(can be activated/deactivated)
Enhancement
3
Function
Exit
You do not actually activate a single function-exit; instead, you activate a
PROJECT that will include your user-exit(s).
21. User-Exit Transactions
Dec-2008 User Exits | 21
CMOD : This transaction allows you to create a PROJECT by identifying its
ENHANCEMENT(S). After determining all of the ENHANCEMENTS that are part
of the PROJECT, you will have to activate the PROJECT. You will still need to code
your user-exit; therefore, you may want to wait until this step is completed before
activating the PROJECT.
SMOD : This transaction allows you to create an ENHANCEMENT, which you will
include in a PROJECT, by identifying its COMPONENT(S). In the case where SAP
has already created an ENHANCEMENT for its pre-defined user-exits, you will not
need to use transaction SMOD; instead, you should just use transaction CMOD.
22. Transaction CMOD
Dec-2008 User Exits | 22
In transaction CMOD, type in the
name of your project and press
the CREATE pushbutton.
23. Transaction CMOD
Dec-2008 User Exits | 23
Once you SAVE your project,
you can add as many
enhancements as you want by
pressing the SAP
enhancements pushbutton.
27. Transaction SMOD
Dec-2008 User Exits | 27
In the case of enhancement
“SAPMF02K”, there is only one
user-exit – a function-exit using
the function module
“EXIT_SAPMF02K_001”.
28. Additional Information
28 Dec-2008User Exits |
You can use table MODACT to find the Project an Enhancement is included in.
You can use table MODSAP to find the Enhancement for a Function Exit.
Component or Function Exit
29. Summary
• You should avoid making
modifications/repairs to SAP objects/code
whenever possible.
• It mandatory for users to register all manual
changes to SAP source coding and SAP
Dictionary objects through a procedure called
SSCR.
• To obtain the access key for changing a SAP
Standard object, either run transaction OSS1
or go to the site www.service.sap.com.
Dec-2008 User Exits | 29
30. Questions
• How do you obtain access key for changing a
SAP standard object ?
• What are the steps for coding a Function
Exits ?
• What does CMOD and SMOD do ?
Dec-2008 User Exits | 30
Editor's Notes
In certain situations, you may notice that the SAP Standard object does not exactly match the requirement of your client. So, you may feel to modify the SAP objects/code to match the requirement. But, this is not a good way of achieving the results. You should avoid making modifications/repairs to SAP objects/code whenever possible. There are other rational ways to incorporate your additional requirements to SAP standard code. The main reason for which you should refrain from altering SAP standard object is, any modified SAP code will be overwritten with upgraded versions of SAP.
Because of this problem, SAP has made it mandatory for users to register all manual changes to SAP source coding and SAP Dictionary objects through a procedure called SSCR (SAP Software Change Registration). Basically, SSCR involves you, the user, obtaining an access key from SAP to make changes to original SAP code.
If you tried to change the SAP program “SAPMF02K”, you would be prompted to enter the access key for that object.
After you enter the appropriate access key, you will be able to modify this program.
Note: Any changes you make to the program will be overwritten when the next SAP upgrade is installed.
You should avoid making modifications/repairs to SAP objects/code whenever possible. However if it is absolutely necessary to change a SAP standard program with the access key, then follow the below mentioned procedure.
Get the Installation No. of your SAP System and remember it. (Go to “System -> Status” tab in the menu bar of your SAP screen)
To obtain the access key for changing a SAP Standard object, either run transaction OSS1 or go to the site www.service.sap.com.
Give the SAPNet User ID and Password to logon to the OSS.
Go to the registration tab.
Go to Register Objects.
Select your server by matching installation number.
Provide the Object name, SAP Release and click on the ‘Register’ tab.
The Registration Key for the Object will be displayed, use this key when you are prompted for the object access key while attempting to change a SAP Standard object.
You can view your registration by selecting “Objects registered by Me” tab.
As per SAP’s 3 Tier Architecture, at the Presentation layer you had Field Exits, Screen Exits and Menu Exits. At the Application layer you had Program exits, at the Database layer you could Append structures to the existing SAP structures.
Function-Exits: These are the function modules created by SAP and activated by the customer (non-activated function-exits do not slow down the transaction).
Menu-Exits: These allow the customer to activate menu items and assign additional functionality to them.
Screen-Exits: These allow the customer to add additional fields to a screen and make entries.
Using transaction SPRO, one can information along with detailed documentation on the Exits available for areas of concern.
This helps in using the proper exit and the relevant program to meet the requirement.
The concept of a function-exit involves various points in original SAP programs that have calls to specific function modules (EXIT_<program name>_xxx).
<program name>: name of program that the function module is called from
xxx: unique number for each function-exit within a particular program
These function modules only contain an “INCLUDE” statement.
It is in these INCLUDES that you will code the customer-specific program that will be called from an original SAP program but will not be overwritten with SAP upgrades.
If you notice from the previous slide, the call to the function module for a function-exit is not the typical CALL FUNCTION “EXIT_SAPMF02K_001”; instead, it is a CALL CUSTOMER-FUNCTION ‘001'.
These two statements are similar in that they both call the same function module (EXIT_SAPMF02K_001).
The difference between the two calls is that the “CALL CUSTOMER-FUNCTION” statement will only execute the function module if the function module is activated (activating user-exits is covered in later slides).
With the “CALL FUNCTION” statement, the system will try to execute the code in the function module whether it is active or not.
The reason that SAP uses the CALL CUSTOMER-FUNCTION in its original code is that resources are not wasted if the customer has not utilized this particular user-exit functionality.
As an example, assume that you want to create a log when a vendor record is updated.
The change vendor transaction is “FK02”.
Using the “System->Status” menu path in this transaction, you can determine that the program is “SAPMF02K”.
Steps to Coding a Function-Exit
Locate Function-Exit in SAP Program (in our example, program “SAPMF02K”).
Go to Function Module associated with that Function-Exit
Create INCLUDE Program that is used in the Function Module
Code in the INCLUDE Program (in our example, the code would insert a record into the update log)
Activate the Function-Exit
Using our example with program “SAPMF02K”, these steps are covered in detail in the following slides.
Using transaction “SE38” (ABAP Editor), display the program “SAPMF02K”.
Search for the string “call customer-function” in the main program to find the function-exit(s) in the program.
If the string “call customer-function” is found, you will be able to determine where and how many function-exits there are in the program.
In program “SAPMF02K”, there is only one function-exit.
Once your search has found a function-exit, you can go to it by double-clicking on the specific function module call statement or the line number (in this example, “100”). By doing this, you will go to the area of the main program that contains the call statement (in this example, program “MF02KFEX”).
Note:This method may not find all the function exits in the program. If a function exits occurs in a function module “called” from the program, this method will not find it.
The best way to find User Exits available for a particular transaction is to run the Transaction in the Runtime Analysis tool (SE30). Then, in the analysis results screen ( where all program, function and method calls during the runtime of the transaction are displayed) search by the keyword ‘EXIT_’. Then Navigate to each Function Exit call by clicking the source code button after placing the cursor on it. From the Function Exit call, double click to go into the Function Exit. Then using table MODSAP find the enhancement related to it.
Once you are in the SAP program at the spot of the function-exit, you can go to the actual function module (EXIT_SAPMF02K_001) by double-clicking on ‘001’ of the “CALL CUSTOMER-FUNCTION” statement.
Note: An SAP program can have more than one function-exit. The difficulty comes in determining when these function-exits get executed in the course of the program.
For our example, assume that you know the above function-exit occurs when a vendor record is being saved (updated or inserted).
Notice that the only code in this function module is the INCLUDE statement.
Double-click on the “INCLUDE” statement to create the INCLUDE program.
When prompted that “Include ZXF05U01 does not exist. Do you want to create the object?”, press the YES pushbutton.
When prompted with the name of the INCLUDE program, press the green checkmark button.
For the attributes of the INCLUDE program, you will need to enter a title, the program type (in this case, “I” for include), and an application.
It is in this INCLUDE program that you will put your specific code (in our example, the code to insert a record in an update log).
Remember, because the SAP program “SAPMF02K” uses the “CALL CUSTOMER-FUNCTION” statement, the code in this INCLUDE program will not be executed until the function-exit is activated.
Notice the use of the “IF SY-UNAME = ‘SANGRAMC’ ... ENDIF” statements. This logic is used for testing your function-exit so that the only time the code within the “IF” statement is executed is when you are the user executing the appropriate transaction (in this example, transaction “FK02”).
You do not actually activate a single function-exit; instead, you activate a PROJECT that will include your user-exit(s). To activate a PROJECT, you use transaction CMOD (menu path: Tools-> ABAP workbench-> Environment-> Enhancements-> Project management).
PROJECT - The highest level in the modification process. Projects are simply used to group together ENHANCEMENTS. It's purpose is to enable the modifier to activate a number of different enhancements that are related and to as ensure that other ENHANCEMENTS are not undesirably activated.
ENHANCEMENT - These are used to group together a collection of COMPONENTS that are inter-related. The naming convention for these usually corresponds to the program(s) in which the user-exits exist
Note:One SAP program may have more than one user-exit; each of these exits will usually be a part of the same ENHANCEMENT. [relationship with PROJECT = one to zero or one to one]
COMPONENTS - These are the actual modifications that may be used in the SAP system to help customize the system. This is the lowest level of the modification process and includes the various categories of user-exits. [relationship with ENHANCEMENT = one to zero or one to one]
CMOD - This transaction allows you to create a PROJECT by identifying its ENHANCEMENT(S). After determining all of the ENHANCEMENTS that are part the PROJECT, you will have to activate the PROJECT. You will still need to code your user-exit; therefore, you may want to wait until this step is completed before activating the PROJECT.
SMOD - This transaction allows you to create an ENHANCEMENT, which you will include in a PROJECT, by identifying its COMPONENT(S). In the case where SAP has already created an ENHANCEMENT for its pre-defined user-exits, you will not need to use transaction SMOD; instead, you should just use transaction CMOD.
You determine which enhancements should be included in a particular project using transaction CMOD. SAP comes with standard enhancements that include various user-exits. However, if these user-exits do not involve a transaction activity that you want to modify, you will have to create your own user-exit and enhancement using transaction SMOD.
Note:That to create your own function-exit, you will have to modify original SAP code to include the “CALL CUSTOMER-FUNCTION” statement that will execute your customer-specific code (remember: this code will be overwritten with an SAP upgrade).
In order for our example function-exit to execute, we need to activate it.
Because we do not activate individual user-exits, we need to create a project to activate using transaction CMOD.
Another way to find components of an enhancement is to use the transaction SMOD (Menu path: Tools-> ABAP workbench-> Utilities-> Enhancements-> Project Management).
Note:Once you are in transaction CMOD, form the initial screen (as above) you can display the relevant documentation by selecting the Documentation radio button.
Next, you enter a short description and save the project.
Then, you need to add enhancements to the project (press the “Enhancement assignments’’ pushbutton).
From the enhancements screen, you enter the appropriate enhancements (you can use the serachhelp to find particular enhancement).
Once you add the enhancements you want, you must save the project.
After saving the project, you should green arrow back to the initial CMOD screen so that you can activate the project.
You must activate the project on the initial CMOD screen.
You can always go back into transaction CMOD to activate/deactivate or delete a particular project.
After activating the project for our example, we can execute transaction “FK02” and the code we have written in the function-exit INCLUDE program will be executed.
Another way to find components of an enhancement is to use the transaction SMOD (Menu path: Tools-> ABAP workbench-> Utilities-> Enhancements-> Definition).
Once you know the name of the enhancement, go into transaction SMOD and display the components of the appropriate enhancement.
As you can see, there is only one component to this enhancement, the function module “EXIT_SAPMF02K_001”.
You will still need to determine where this function module is called from within the main program, but notice that the short text does give you an indication.
Once you know the name of the function module, you can display it using the Function Library (transaction SE37) and proceed to the appropriate INCLUDE area where you will put the customer-specific code.
Again, you must follow all the steps to create a project, include the enhancement, and activate it.