enhancement framework for a class

Upload: saravana-kumar

Post on 06-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 Enhancement Framework for a Class

    1/26

  • 8/3/2019 Enhancement Framework for a Class

    2/26

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

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

    These are three methods which need to be enhanced,

  • 8/3/2019 Enhancement Framework for a Class

    3/26

    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,

  • 8/3/2019 Enhancement Framework for a Class

    4/26

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

  • 8/3/2019 Enhancement Framework for a Class

    5/26

    Execute the report, to check out the standard functionality

    Test case I -

    Observe the outcome,

  • 8/3/2019 Enhancement Framework for a Class

    6/26

    Test case II -

    Observe the outcome,

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

  • 8/3/2019 Enhancement Framework for a Class

    7/26

    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 creating a 'Pre-exit' method enhancement.

  • 8/3/2019 Enhancement Framework for a Class

    8/26

    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,

  • 8/3/2019 Enhancement Framework for a Class

    9/26

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

    Observe the difference,

  • 8/3/2019 Enhancement Framework for a Class

    10/26

  • 8/3/2019 Enhancement Framework for a Class

    11/26

    Check the parameters for the method 'ZDAVE_METHOD_KNA2',

    Original source code for method 'ZDAVE_METHOD_KNA2',

  • 8/3/2019 Enhancement Framework for a Class

    12/26

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

    Test case I -

    Observe the output,

  • 8/3/2019 Enhancement Framework for a Class

    13/26

    Test case II -

    Observe the output,

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

    Create an Implementation for the method 'ZDAVE_METHOD_KNA2',

  • 8/3/2019 Enhancement Framework for a Class

    14/26

    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,

  • 8/3/2019 Enhancement Framework for a Class

    15/26

    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.

  • 8/3/2019 Enhancement Framework for a Class

    16/26

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

  • 8/3/2019 Enhancement Framework for a Class

    17/26

    Execute and enter the desired data,

  • 8/3/2019 Enhancement Framework for a Class

    18/26

    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,

  • 8/3/2019 Enhancement Framework for a Class

    19/26

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

    Test case I -

    Output -

  • 8/3/2019 Enhancement Framework for a Class

    20/26

    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,

  • 8/3/2019 Enhancement Framework for a Class

    21/26

    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,

  • 8/3/2019 Enhancement Framework for a Class

    22/26

    Observe the coding logic,

  • 8/3/2019 Enhancement Framework for a Class

    23/26

    Activate and call the method in the application report program,

  • 8/3/2019 Enhancement Framework for a Class

    24/26

    Now, its time to test the application,

    First test case,

    Observe that the overwrite-exit method has been triggered,

  • 8/3/2019 Enhancement Framework for a Class

    25/26

    To confirm, observe the output,

    Second, test case

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

    Confirm with the output,

  • 8/3/2019 Enhancement Framework for a Class

    26/26

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