Entering content frameProcedure documentation Creating Customer-Specific Function Modules Locate the document in its SAP Library structure

Function module exits allow you to implement your own functions and processing logic in standard SAP programs. To take advantage of a function module exit, you first need to create a project as described in the section Creating an Add-on Project. Then, you must include the SAP enhancement that contains the function module exit you want to use in your project. From the main screen of the Project management transaction, proceed as follows:

  1. Select Enhancement components and choose Change.
  2. The system lists all the customer exits contained within the enhancements included in your project.

  3. Place the cursor on the function module exit you want to use.
  4. Choose Edit component.
  5. The system displays the exit’s corresponding function module, which has been prepared by an SAP application developer. You can fill this module with functions you want by calling the include program (called ZXnnnU01) contained within the module and inserting your own source code into it. Both the function module and the include program lie within the namespace reserved for customers.

  6. Call the function module’s include program by double-clicking on it.
  7. The system asks you if you want to create the include program.

  8. Confirm that you want to create the include program.
  9. Enter your function’s source code in the editor.
  10. Save your include program.

Using Predefined Interface Parameters

When you use a function module exit, you need to be aware of how your function module fits into the program logic of the standard R/3 program that calls it. When defining function module calls in its standard program, SAP specifies exactly what data can be transferred to and from the standard program. If the customer function call includes import and export parameters, the customer function module will itself have the same predefined interface.

You can not make changes to the general framework or to the interface of a function module exit’s function module. You are only allowed to use the special include program it contains to add your own programming logic. When you create the source code for your include program, be aware of the restrictions set by the function module exit’s interface. You can only transfer values to and from your include program if these values are included in the function module’s predefined interface.

Using Sample Code Provided by SAP

SAP sometimes supplies sample coding for the function module exits it provides. You can copy this sample code into your include program. To use sample code, proceed as follows:

  1. Create and save a customer include program as described in steps 1 - 6 of the section on Creating Customer-specific Function Modules.
  2. Return to the Project management transaction.
  3. Display the exits in your project and place the cursor on the function modules exit you created an include program for.
  4. Choose Edit ® Use SAP source code.

If sample code exits, the system copies this code to your include program. If you have already written your own code in the include program, the system appends the sample to your code. You are free to alter the sample code as needed.

Declaring Global Data

SAP often supplies function module exits with predefined global data. Global data is required if, for example, SAP provides subroutines with a function module exit. All global data defined by SAP is stored in an include called LXnnnTOP, where nnn stands for the other characters in the function group. You can define your own global data in any function module exit.

Take advantage of the ABAP Workbench’s navigational features when creating global data definitions:

  1. Enter the name of the field or internal table you want to define in the editor.
  2. Double-click on the field or table name.
  3. The system asks you if you want to define the object, since no data definition exists for it yet.

  4. Confirm that you want to create a new data definition.

The system automatically creates a new include called ZXnnnTOP. Use this include to store all of the data definitions for your function module exit(s).

Creating Subroutines

SAP may include pre-programmed subroutines in certain function module exits. These predefined subroutines are stored in an include called LXnnnF00, where nnn stands for the other characters in the function group. You may call these routines from within your customer include program.

You can also create your own subroutines. To create new subroutines, use forward navigation in the ABAP Workbench and proceed as follows: Proceed as follows to create new subroutines:

  1. Open the editor and write the keyword PERFORM, followed by the name of your subroutine.
  2. Double-click on the subroutine’s name.
  3. Since the routine does not yet exist, the system asks if you wish to create it.

  4. Confirm that you want to create a new subroutine.

The system automatically creates an include called ZXnnnZZZ, where nnn stands for the other characters in the function group. This include should contain all subroutines used in your customer function modules.

Caution

The central include program (called ZXnnnU01) contains the commands FUNCTION and ENDFUNCTION. Therefore, you should not use the keywords FORM and ENDFORM in this include.

 

Calling Your Own Screens

You can call your own screens from within a customer function module. For example, you might want to call a screen that lets users carry out certain processes not available in a standard R/3 transaction. Use forward navigation in the ABAP Workbench to create your own screens and their flow logic. Proceed as follows:

  1. Write the command CALL SCREEN xxx in the editor, where xxx stands for the screen number.
  2. Double-click on the screen number.

The system asks if you want to create the screen and then branches to the Screen Painter.

To create PBO and PAI modules, proceed as follows:

  1. Enter the modules’ names in the Flow Logic Editor.
  2. Double-click on each name.

The system creates the modules. At the same time, the system creates include programs that adhere to SAP’s naming standards.

Use Workbench navigation to create any other program objects (like events) that you want to include in your function module.

 

 

 

Leaving content frame