Lets see in details how the Enhancement Framework Class Enhancements – pre, post and overwrite methods – are designed in the class context.
Design
It is important to understand how the class enhancement is designed. So, you can better understand it when you need to implement one. Read Enhancement Framework – Class Enhancement implementation to learn more on how to enhance a class.
When you create the class enhancement, Enhancement builder would create following objects:
- Attribute – A new attribute would be created with name
%_{implementation_name}
in the class attributes - Local Class – A new local class would be created. This class name would be
LCL_{implementation_name}
- Attribute to refer to core Object. This would be referred as the CORE_OBJECT
- CONSTRUCTOR method
- Interface would implemented
- Source Code Plugin implementations
- Implementation 1 – This would define the local attribute to store the singletone object
- Implementation 2 – This would define the Interface. This interface would be implemented in the Local Class. This would call the CONSTRUCTOR method defined in the local class
- Implementation 3 – This would instantiate the singletone object. After that it would call the method which is part of the interface
Interface Name
System creates specific interface for each of the different type of methods – Pre, Post and Overwrite. Naming standards for the interface name is like:
- Pre Exit –
IPR_{implementation_name}
- Post Exit –
IPO_{implementation_name}
- Overwrite Exit –
IWO_{implementation_name}
All the methods which has Pre Exit, would be defined in the Interface for the Pre-Exit. The method would have all the parameters of the actual method which is being enhanced.
Various Artifacts
The attribute in the class – the one highlighted with arrow:
The Local Class is defined like:
** ** PROGRAM NAME - ZTEST_NP_MEREQ================EIMP ** CLASS LCL_ZTEST_NP_MEREQ DEFINITION. PUBLIC SECTION. CLASS-DATA OBJ TYPE REF TO LCL_ZTEST_NP_MEREQ. DATA CORE_OBJECT TYPE REF TO CL_MMPUR_MEREQ_DB_UTILITY . INTERFACES IPR_ZTEST_NP_MEREQ. METHODS: CONSTRUCTOR IMPORTING CORE_OBJECT TYPE REF TO CL_MMPUR_MEREQ_DB_UTILITY OPTIONAL. ENDCLASS. CLASS LCL_ZTEST_NP_MEREQ IMPLEMENTATION. METHOD CONSTRUCTOR. ME->CORE_OBJECT = CORE_OBJECT. ENDMETHOD. METHOD IPR_ZTEST_NP_MEREQ~GET_EBAN. *"------------------------------------------------------------------------* *" Declaration of PRE-method, do not insert any comments here please! *" *"class-methods GET_EBAN *" importing *" !IM_BANFN type BANFN *" raising *" CX_MMPUR_NOT_FOUND . *"------------------------------------------------------------------------* ## - New code goes here ENDMETHOD. ENDCLASS.
The source code implementation is like:
** ** PROGRAM - ZTEST_NP_MEREQ================E ** ENHANCEMENT 1 . data %_ZTEST_NP_MEREQ type ref to OBJECT . ENDENHANCEMENT. ENHANCEMENT 2 . INTERFACE IPR_ZTEST_NP_MEREQ . class-methods GET_EBAN importing !IM_BANFN type BANFN raising CX_MMPUR_NOT_FOUND . ENDINTERFACE. INCLUDE ZTEST_NP_MEREQ================EIMP . ENDENHANCEMENT. ENHANCEMENT 3 . IF LCL_ZTEST_NP_MEREQ=>OBJ IS INITIAL. CREATE OBJECT LCL_ZTEST_NP_MEREQ=>OBJ . ENDIF. LCL_ZTEST_NP_MEREQ=>OBJ->IPR_ZTEST_NP_MEREQ~GET_EBAN( IM_BANFN = IM_BANFN ). ENDENHANCEMENT.
Debugging
When you debug the Method enhancement, you would see all of this in action.
Source Code plugin is called:
Pre method implementation would be called
Next Article
Enhancement Framework – Function Module Enhancement
Table of Content – Enhancement Framework
- Enhancement Framework – Introduction
- Enhancement Framework – Explicit Enhancement-POINT Implementation
- Enhancement Framework – Debugging Implementation
- Enhancement Framework – Explicit Enhancement-SECTION Implementation
- Enhancement Framework – Implicit Enhancement Options
- Enhancement Framework – Class Enhancement
- Enhancement Framework – Class Enhancement – How designed
- Enhancement Framework – Function Module Enhancement
- Enhancement Framework – Table Enhancement Category
- Enhancement Framework – Table Enhancement – Append Structure
- Enhancement Framework – Append Search Help
- Enhancement Framework – Extension Index
- Enhancement Framework – Fixed Value Append
Hi Naimesh,
Good one.
I have a requirement for adding field in existing tab in migo transaction.
Is it possible for u to provide document for it.
Regards
Alok
Hi Naimesh,
Very nice articles.
Thank you.
Regards,
Vamshi.