Show TOC Start of Content Area

Procedure documentation Enhancing the Components of Global Classes or Interfaces  Locate the document in its SAP Library structure

Use

Use this procedure to implement enhancements (pre, post, and overwrite methods) of global classes or interfaces. In the context of the enhancement concept, a global class or global interface provides implicit enhancement options.

Procedure

To implement an enhancement of global classes or interfaces, use the Class Builder to call the Enhancement Builder.

...

       1.      In the form-based mode of the Class Builder, choose Class Enhance or Interface Enhance for an existing class or an interface.

A dialog box appears.

       2.      Select an existing enhancement implementation or create a new one

This takes you to the enhancement mode of the Class Builder in which the original components of the class or interface are displayed and cannot be changed.

       3.      Create your enhancements following the steps below:

                            a.      Create the new attributes in the same way as when you create a class or interface.

                            b.      Insert new, optional formal parameters in the same way as when you create a method.

                            c.      Insert or delete pre- and/or post-methods:

                                                  i.       Select the desired method

                                                ii.       Choose Edit Enhancement OperationsEnhancement Operations and then choose one of the menu entries:

(i)       Insert Pre-Method, Insert Post-Method or Insert Overwrite-Method

(ii)     Delete Pre-Method, Delete Post-Method or Delete Overwrite-Method.

Note

An overwrite-method cannot exist simultaneously with pre- or post-methods for the same method.

                            d.      Insert new methods in the same way as when you create a class or interface.

                            e.      Insert new interfaces.

                              f.      Insert new events.

                            g.      Insert new types

       4.      Save and activate the class.

You can further use the new components for implicit and explicit enhancement options in enhancements to the source code of the class. This can be done via ABAP Source Code Enhancements.

Additional Information

When pre/post/overwrite methods are created, a local class named lcl_<enhancement_name> is generated for the enhancement <enhancement_name>. This local class is attached to the end of the local class implementation section in the original class (as an implementation of the predefined enhancement option).

You can access the components of the original class within lcl_<enhancement_name> by the object reference CORE_OBJECT.

The local class lcl_<enhancement_name> can implement 3 interfaces:

      IPR_<enhancement_name> for pre methods;

      IPO_<enhancement_name> for post methods;

      IOW_<enhancement_name> for overwrite methods.

The parameters of pre/post/overwrite methods are similar to the parameters of the original method but the following restrictions exist:

      The pre method does not have export parameters.

      The post method does not have export parameters; the export parameters become changing parameters.

      The returning parameter of a functional method becomes a changing parameter

      overwrite methods have the same signature as the original method.

      The parameter definitions of pre/post/overwrite methods cannot be changed.

 

 

End of Content Area