Sie sind auf Seite 1von 30

IBM Global Services

User Exits

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

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.

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Overview
It mandatory for users to register all manual changes to SAP source coding and
SAP Dictionary objects through a procedure called SSCR.

If you try to change the SAP


program SAPMF02K, you will
be prompted to enter the access
key for that object.

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

SAP Modification
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.

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Obtaining Object Access Key


To obtain the access key for changing a SAP
Standard object, either run transaction OSS1 or
go to the site www.service.sap.com.

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Obtaining Object Access Key (Contd.)


Go to the registration tab
Go to Register Objects

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Obtaining Object Access Key (Contd.)

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.

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Different Enhancement Techniques


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

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Information on existing User-Exits


Using transaction SPRO, one can information along with detailed documentation
on the Exits available for areas of concern.

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Function-Exits
SAP Original Code
SAPMF02K
call customer-function
001...

Function Module

function
exit_sapmf02k_001.
include zxf05u01.
endfunction.

INCLUDE Program

*---------------------------------*
* include zxf05u01.
*
*---------------------------------*
This INCLUDE
program is where you
will write the
This
INCLUDE program
customer-specific
will
not be overwritten
code.
with an SAP upgrade
because it is not SAP
original code.

10

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Call Customer-Function Versus Call Function


Both of these CALL statements refer
to the function module
EXIT_SAPMF02K_001.

call function EXIT_SAPMF02K_001

The CALL CUSTOMER-FUNCTION


statement will only execute the
function module if the module
is activated.

11

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Business Case Scenario


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.

12

User Exits |

UPDATE LOG
Vendor #
Vendor name

Dec-2008

2005 IBM Corporation

IBM Global Services

Steps to Coding a Function-Exit

1. Locate Function-Exit(s)
2. Go to Function Module
3. Create INCLUDE Program
4. Code in INCLUDE Program
5. Activate Function-Exit

13

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Locate Function-Exit(s)

14

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Locate Function-Exit(s)

In program SAPMF02K, search


for the string call customerfunction in the main program to
find all of the function-exit(s) in
the program.

15

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Locate Function-Exit(s)

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.

16

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Go to Function Module

Double-click on 001 of the


CALL CUSTOMER-FUNCTION
001 statement in the SAP
program to go to the function
module EXIT_SAPMF02K_001.

17

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Create INCLUDE Program

Double-click on the INCLUDE


ZXF05U01 statement in the
function module to create the
INCLUDE program.

18

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Code in INCLUDE Program


Write code in the include program.
*-----------------------------* INCLUDE ZXF05U01
*------------------------------

Whatever logic you add here will affect all


SAP standard transaction where this
particular User Exit is being called.

if sy-uname = SANGRAMC.

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.

endif.

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.

19

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Activating Function-Exit
You do not actually activate a single function-exit; instead, you activate a
PROJECT that will include your user-exit(s).
PROJECT 1
(can be activated/deactivated)

Enhancement
1

Functio
n
Exit

20

Screen
Exit

User Exits |

Enhancement
2

Functio
n
Exit

PROJECT 2
(can be activated/deactivated)

X
X

Enhancement
3

Functio
n
Exit

Dec-2008

2005 IBM Corporation

IBM Global Services

User-Exit Transactions
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.

21

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Transaction CMOD

In transaction CMOD, type in the


name of your project and press
the CREATE pushbutton.

22

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Transaction CMOD

Once you SAVE your project,


you can add as many
enhancements as you want by
pressing the SAP
enhancements pushbutton.

23

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Transaction CMOD

Add the enhancements you


want included in
the project.

24

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Transaction CMOD

After saving your project,


you need to ACTIVATE it.

25

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Transaction SMOD

With the name of the enhancement,


you can display its components.

26

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Transaction SMOD

In the case of enhancement


SAPMF02K, there is only
one user-exit a functionexit using the function
module
EXIT_SAPMF02K_001.

27

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

Additional Information
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

28

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

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.
The concept of a function-exit involves various points in original SAP programs
that have calls to specific function modules.
CALL CUSTOMER-FUNCTION statement will only execute a function module if
the function module is activated.
CMOD : This transaction allows you to create a PROJECT by identifying its
ENHANCEMENT(S).
SMOD : This transaction allows you to create an ENHANCEMENT, which you will
include in a PROJECT, by identifying its COMPONENT(S).

29

User Exits |

Dec-2008

2005 IBM Corporation

IBM Global Services

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 ?

30

User Exits |

Dec-2008

2005 IBM Corporation

Das könnte Ihnen auch gefallen