enhancement framework methods

Upload: roys4396510

Post on 03-Apr-2018

233 views

Category:

Documents


1 download

TRANSCRIPT

  • 7/28/2019 Enhancement Framework Methods

    1/27

    Enhancement Framework - Class

    Enhancements - Pre-exit, Post-exit and

    Overwrite-exit methods - Concept andSimple Scenarios

    Attachments: 50

    Added by Harsh Dave, last edited by Suhas Saha on Apr 12, 2011 (view change)

    Enhancement Framework Class Enhancements Pre-exit, Post-exit and

    Overwrite-exit methods

    Class Enhancements (Klasse Verbesserungen) -

    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 businessfunctionality.

    What things are possible when we can think of enhancing the features or functionality of

    a class?

    Adding new methods to the existing ones. Adding new, but optional global parameters to the existing method parameters.

    Enhancing (Customer defined business functionality) the way the methods are

    triggered or executed with the help of Pre-exit, Post-exit and Overwrite methodsrespectively with customer logic.

    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 toadapt the changes from the enhanced 'pre-exit' method to the original method.

    http://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enhancements+-+Pre-exit%2C+Post-exit+and+Overwrite-exit+methods+-+Concept+and+Simple+Scenarioshttp://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enhancements+-+Pre-exit%2C+Post-exit+and+Overwrite-exit+methods+-+Concept+and+Simple+Scenarioshttp://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enhancements+-+Pre-exit%2C+Post-exit+and+Overwrite-exit+methods+-+Concept+and+Simple+Scenarioshttp://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enhancements+-+Pre-exit%2C+Post-exit+and+Overwrite-exit+methods+-+Concept+and+Simple+Scenarioshttp://wiki.sdn.sap.com/wiki/pages/viewpageattachments.action?pageId=82313287&metadataLink=truehttp://wiki.sdn.sap.com/wiki/display/~zaclr8ihttp://wiki.sdn.sap.com/wiki/display/~102fi1v3bhttp://wiki.sdn.sap.com/wiki/pages/diffpages.action?pageId=82313287&originalId=233409491http://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enhancements+-+Pre-exit%2C+Post-exit+and+Overwrite-exit+methods+-+Concept+and+Simple+Scenarioshttp://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enhancements+-+Pre-exit%2C+Post-exit+and+Overwrite-exit+methods+-+Concept+and+Simple+Scenarioshttp://wiki.sdn.sap.com/wiki/display/ABAP/Enhancement+Framework+-+Class+Enhancements+-+Pre-exit%2C+Post-exit+and+Overwrite-exit+methods+-+Concept+and+Simple+Scenarioshttp://wiki.sdn.sap.com/wiki/pages/viewpageattachments.action?pageId=82313287&metadataLink=truehttp://wiki.sdn.sap.com/wiki/display/~zaclr8ihttp://wiki.sdn.sap.com/wiki/display/~102fi1v3bhttp://wiki.sdn.sap.com/wiki/pages/diffpages.action?pageId=82313287&originalId=233409491
  • 7/28/2019 Enhancement Framework Methods

    2/27

    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 methodand 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 bymeans 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).

    Access the class in 'Display' mode which needs to be enhanced.

  • 7/28/2019 Enhancement Framework Methods

    3/27

    These are three methods which need to be enhanced,

    Scenario 1: Applying 'pre-exit' for enhancing method'ZDAVE_METHOD_KNA1'.

    Considering the first method 'ZDAVE_METHOD_KNA1', observe the global parameters

    Check the source code for the original method,

  • 7/28/2019 Enhancement Framework Methods

    4/27

    This method can be called into an application (say) like a report program which will offerthe standard functionality,

  • 7/28/2019 Enhancement Framework Methods

    5/27

    Execute the report, to check out the standard functionality

    Test case I -

    Observe the outcome,

  • 7/28/2019 Enhancement Framework Methods

    6/27

    Test case II -

    Observe the outcome,

    Now, we need to enhance this method. To access the enhancement mode,

  • 7/28/2019 Enhancement Framework Methods

    7/27

    As expected it is needed to create an implementation,

    Note - It is suggested to create separate implementations for all the three 'Exit method'

    enhancements.

    After selecting the implementation access the enhancement operation option for creatinga 'Pre-exit' method enhancement.

  • 7/28/2019 Enhancement Framework Methods

    8/27

    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,

  • 7/28/2019 Enhancement Framework Methods

    9/27

    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,

    As some validation for customer range was carried out, observe the 'Pre-exit' method hastriggered

  • 7/28/2019 Enhancement Framework Methods

    10/27

    Observe the difference,

    Another test case,

    Validations are processed for the above test case,

    Finally, observe the difference in the output of the report as the 'Pre-exit' method of theclass 'ZDAVE_METHOD_KNA1' has been invoked or triggered.

  • 7/28/2019 Enhancement Framework Methods

    11/27

    Scenario 2: Applying 'post-exit' for enhancing method'ZDAVE_METHOD_KNA2'.

    Check the parameters for the method 'ZDAVE_METHOD_KNA2',

  • 7/28/2019 Enhancement Framework Methods

    12/27

    Original source code for method 'ZDAVE_METHOD_KNA2',

  • 7/28/2019 Enhancement Framework Methods

    13/27

    After calling the method in the application report program, execute the report

    Test case I -

    Observe the output,

  • 7/28/2019 Enhancement Framework Methods

    14/27

    Test case II -

    Observe the output,

    Access the 'Enhance' path (Enhancement Mode) 'Method' 'Enhance'.

    Create an Implementation for the method 'ZDAVE_METHOD_KNA2',

  • 7/28/2019 Enhancement Framework Methods

    15/27

    Create a 'Post-exit' method by accessing the path 'Enhancement operations' 'Insert

    Post-method'

    Observe the 'Post-exit' method created and navigate inside to write the enhancement

    code,

  • 7/28/2019 Enhancement Framework Methods

    16/27

    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.

  • 7/28/2019 Enhancement Framework Methods

    17/27

    Now, call the second method 'ZDAVE_METHOD_KNA2' in the report program,

  • 7/28/2019 Enhancement Framework Methods

    18/27

    Execute and enter the desired data,

  • 7/28/2019 Enhancement Framework Methods

    19/27

    Observe the difference,

    Scenario 3: Applying 'Overwrite-exit' method to the method'ZDAVE_METHOD_KNA3',

    Check the parameters of the method 'ZDAVE_METHOD_KNA3',

    Observe the source code of the original method,

  • 7/28/2019 Enhancement Framework Methods

    20/27

    Call the method in the application report program and test it (Execute)

    Test case I -

    Output -

  • 7/28/2019 Enhancement Framework Methods

    21/27

    Test case II -

    Output -

    Now, to replace this functionality with the customer's functionality, we make use of

    'Overwrite-exit' methodAs usual access the path 'Method' 'Enhance' to enable the enhancement mode.

    Create an Implementation,

  • 7/28/2019 Enhancement Framework Methods

    22/27

    Add an 'Overwrite-method' accessing the path,

    Observe that the method has been created and follow the indication to code the

    functionality which will replace the original one,

  • 7/28/2019 Enhancement Framework Methods

    23/27

    Observe the coding logic,

  • 7/28/2019 Enhancement Framework Methods

    24/27

    Activate and call the method in the application report program,

  • 7/28/2019 Enhancement Framework Methods

    25/27

    Now, its time to test the application,

    First test case,

  • 7/28/2019 Enhancement Framework Methods

    26/27

    Observe that the overwrite-exit method has been triggered,

    To confirm, observe the output,

    Second, test case

    Again, observe that the overwrite-exit method has been triggered,

    Confirm with the output,

  • 7/28/2019 Enhancement Framework Methods

    27/27

    You can refer to the SAP documentation onEnhancing the Components of Classes or

    Interfaces.

    .

    http://help.sap.com/saphelp_nw04s/helpdata/en/86/b83142680d5c33e10000000a155106/content.htmhttp://help.sap.com/saphelp_nw04s/helpdata/en/86/b83142680d5c33e10000000a155106/content.htmhttp://help.sap.com/saphelp_nw04s/helpdata/en/86/b83142680d5c33e10000000a155106/content.htmhttp://help.sap.com/saphelp_nw04s/helpdata/en/86/b83142680d5c33e10000000a155106/content.htmhttp://help.sap.com/saphelp_nw04s/helpdata/en/86/b83142680d5c33e10000000a155106/content.htm