Mentor SAP

Implicit Enhancement Points and Options in SAP classes

 

 

To enhance the interface for global SAP methods and define additional attributes or methods for global SAP classes, proceed as follows:

  1. Display the class in the class builder
  2. Choose a class -> Enhance and specify an enhancement implementation
  3. Add new attributes, methods, and interface parameters to existing methods
  4. To branch to the method editor so you can add the code, double click the name of any additional methods you have created.
  5. Choose the Activate Enhancements pushbutton
  6. These newly added interface parameters must always be optional.

Pre-, Post-, and Overwrite Methods

These methods are automatically called before, after, or instead of the SAP method. When pre-, post-, and overwrite methods are created, the system generates a local class named lcl_<enhancement_name> for the enhancement <enhancement_name>. This local class is attached to the end of the local class implementation section in the original class. You can access the components of the original class within the local class lcl_<enhancement_name> through the object reference CORE_OBJECT.

 

The local class lcl_<enhancement_name> can implement the following interfaces:

  1. IPR_<enhancement_name> for pre methods
  2. IPO_<enhancement_name> for post methods
  3. IOW_<enhancement_name> for overwrite methods

The parameters of pre-, post, and overwrite methods are like the parameters of the original method, but the following restriction exist:

  1. Pre-methods do not have export parameters.
  2. Post-methods do not have EXPORT parameters; the EXPORT parameters of the original SAP method become CHANGING parameters in the post-method.
  3. The returning parameter of a functional method becomes a changing parameter
  4. Overwrite methods have the same signature as the original method
  5. You cannot change the parameter definitions of pre, post, and overwrite methods.

Define a Pre-, Post-, or Overwrite Method

The following are the steps to define pre-, post-, or overwrite method of a global SAP class:

  1. Display the class in the class builder
  2. Choose class -> Enhance and specify an enhancement implementation
  3. Use the cursor to mark the required SAP method
  4. Choose Edit -> Enhancement Operations and then choose insert Pre-Method, Insert Post-Method, or Add Overwrite Method
  5. Choose the newpushbutton in the Pre-/Post-/Overwrite-Exit column to implement the corresponding method. To call components of the global class in the method, you have to use the reference variable core_object, which is set in the local constructor.
  6. Save the method
  7. Choose the Activate Enhancements pushbutton

The advantages of pre- or post-methods are as follows: