Professional Documents
Culture Documents
Page 1 of 14
Added by Harsh Dave, last edited by Harsh Dave on Mar 17, 2009
We can take the advantage of enhancing the global parameters and interface of a class with the help of the new enhancement framework to achieve the expected business functionality.
What things are possible when we can think of enhancing the features or functionality of a class?
The best way to utilize the functionality would be the combined use of enhancing the global parameters as well as applying the 'Pre-Post-Overwrite exit' methods.
In Short,
Pre-exit methods -
Pre-exit methods are the enhanced methods which can be invoked at runtime before the original method code is supposed to be executed or triggered.
A pre-exit can be utilized for certain validations or passing some data from the pre-exit to the original method.
Note: In addition to the pre-exit some source code enhancements can be well used to adapt the changes from the enhanced 'pre-exit' method to the original method.
Post-exit methods -
Post-exit methods are the enhanced methods which can be invoked at runtime after the original method code has been executed or triggered.
The post-exit can be used to add or enhance the data flowing from the original method and satisfy the custom business functionality.
Overwrite-exit methods -
Overwrite-exit methods are the enhanced methods which act as a replacement at run time for the original method.
Point to correlate -
If the things are observed closely then it reveals that the 'Pre-exit' and 'Post-exit' methods act like 'Enhancement-point' as in source code enhancements.
Also, the 'overwrite-exit' method acts like 'Enhancement-section'.
Note: This is the biggest function of the framework which knows what needs to be invoked for that particular 'Exit' method applied instead or along with the original code.
To understand these powerful techniques here is a practical demonstration of them by means of some basic scenarios.
Note: Here in this scenario the class used is in customer name space ('Z' class).
With respect to the scenario, three methods are used to demonstrate the functionalities of the three enhancement methods (Pre, Post and Overwrite Exit methods).
http://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enh... 12/01/2011
SAP Community Network Wiki - ABAP Development - Enhancement Framework - C... Page 2 of 14
This method can be called into an application (say) like a report program which will offer the standard functionality,
http://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enh... 12/01/2011
SAP Community Network Wiki - ABAP Development - Enhancement Framework - C... Page 3 of 14
Test case I -
Test case II -
http://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enh... 12/01/2011
SAP Community Network Wiki - ABAP Development - Enhancement Framework - C... Page 4 of 14
After selecting the implementation access the enhancement operation option for creating a 'Pre-exit' method enhancement.
Observe the post-exit created and click on that indication to navigate to enter the custom code.
In this case there are some validations and operations performed in this 'Pre-exit' method,
Activate the 'Pre-exit' method and call the 1st method 'ZDAVE_METHOD_KNA1' into the customer report program 'ZDAVE_KATEGORIEN_ENHC'.
Test the functionality achieved for different test cases,
http://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enh... 12/01/2011
SAP Community Network Wiki - ABAP Development - Enhancement Framework - C... Page 5 of 14
As some validation for customer range was carried out, observe the 'Pre-exit' method has triggered
Finally, observe the difference in the output of the report as the 'Pre-exit' method of the class 'ZDAVE_METHOD_KNA1' has been invoked or triggered.
http://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enh... 12/01/2011
SAP Community Network Wiki - ABAP Development - Enhancement Framework - C... Page 6 of 14
After calling the method in the application report program, execute the report
Test case I -
http://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enh... 12/01/2011
SAP Community Network Wiki - ABAP Development - Enhancement Framework - C... Page 7 of 14
Test case II -
Create a 'Post-exit' method by accessing the path 'Enhancement operations' → 'Insert Post-method'
http://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enh... 12/01/2011
SAP Community Network Wiki - ABAP Development - Enhancement Framework - C... Page 8 of 14
Observe the 'Post-exit' method created and navigate inside to write the enhancement code,
After the original method does its job the 'Post-exit' method will get invoked and it will allow to enhance the application by adding one more parameter which will be displayed by the application
(here report program), here's the code.
http://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enh... 12/01/2011
SAP Community Network Wiki - ABAP Development - Enhancement Framework - C... Page 9 of 14
http://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enh... 12/01/2011
SAP Community Network Wiki - ABAP Development - Enhancement Framework ... Page 10 of 14
Call the method in the application report program and test it (Execute)
Test case I -
Output -
http://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enh... 12/01/2011
SAP Community Network Wiki - ABAP Development - Enhancement Framework ... Page 11 of 14
Test case II -
Output -
Now, to replace this functionality with the customer's functionality, we make use of 'Overwrite-exit' method
As usual access the path 'Method' → 'Enhance' to enable the enhancement mode.
Create an Implementation,
Observe that the method has been created and follow the indication to code the functionality which will replace the original one,
http://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enh... 12/01/2011
SAP Community Network Wiki - ABAP Development - Enhancement Framework ... Page 12 of 14
http://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enh... 12/01/2011
SAP Community Network Wiki - ABAP Development - Enhancement Framework ... Page 13 of 14
http://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enh... 12/01/2011
SAP Community Network Wiki - ABAP Development - Enhancement Framework ... Page 14 of 14
Labels
enhancement framework class pre-exit post-exit overwrite-exit method concept simple scenario kategorien verbesserungen global parameter interface business functionality
customer trigger execute invoke runtime original validations source code enhancement-point indication program access replace navigate enhc application report
enhancement-section zdave kna1 standard mode implementation operation klasse
Comments (1)
http://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enh... 12/01/2011