30
User Exits Dec-2008 User Exits |

Chapter 01 user exits

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Chapter 01 user exits

User Exits

Dec-2008 User Exits |

Page 2: Chapter 01 user exits

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

Page 3: Chapter 01 user exits

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.

Page 4: Chapter 01 user exits

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.

Page 5: Chapter 01 user exits

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.

Page 6: Chapter 01 user exits

Obtaining Object Access Key (Contd.)

Dec-2008 User Exits | 6

Go to the registration tab Go to Register Objects

Page 7: Chapter 01 user exits

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.

Page 8: Chapter 01 user exits

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

Page 9: Chapter 01 user exits

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.

Page 10: Chapter 01 user exits

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.

Page 11: Chapter 01 user exits

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”.

Page 12: Chapter 01 user exits

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.

Page 13: Chapter 01 user exits

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

Page 14: Chapter 01 user exits

Locate Function-Exit(s)

Dec-2008 User Exits | 14

Page 15: Chapter 01 user exits

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.

Page 16: Chapter 01 user exits

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”.

Page 17: Chapter 01 user exits

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”.

Page 18: Chapter 01 user exits

Create INCLUDE Program

Dec-2008 User Exits | 18

Double-click on the INCLUDE ZXF05U01 statement in the function module to create the INCLUDE program.

Page 19: Chapter 01 user exits

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.

Page 20: Chapter 01 user exits

Activating Function-Exit

Dec-2008 User Exits | 20

X

X

PROJECT 1

(can be activated/deactivated)

Enhancement 1

Enhancement2

Function Exit

Screen Exit

Function Exit

PROJECT 2

(can be activated/deactivated)

Enhancement3

Function Exit

You do not actually activate a single function-exit; instead, you activate a PROJECT that will include your user-exit(s).

Page 21: Chapter 01 user exits

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 codeyour 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 willinclude in a PROJECT, by identifying its COMPONENT(S). In the case where SAPhas already created an ENHANCEMENT for its pre-defined user-exits, you will notneed to use transaction SMOD; instead, you should just use transaction CMOD.

Page 22: Chapter 01 user exits

Transaction CMOD

Dec-2008 User Exits | 22

In transaction CMOD, type in the name of your project and press the CREATE pushbutton.

Page 23: Chapter 01 user exits

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.

Page 24: Chapter 01 user exits

Transaction CMOD

Dec-2008 User Exits | 24

Add the enhancements you want included in the project.

Page 25: Chapter 01 user exits

Transaction CMOD

Dec-2008 User Exits | 25

After saving your project, you need to ACTIVATE it.

Page 26: Chapter 01 user exits

Transaction SMOD

Dec-2008 User Exits | 26

With the name of the enhancement, you can display its components.

Page 27: Chapter 01 user exits

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”.

Page 28: Chapter 01 user exits

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

Page 29: Chapter 01 user exits

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).

Dec-2008 User Exits | 29

Page 30: Chapter 01 user exits

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