Enhancement to a Standard Class

...Previous

13)  Now create a report with the below logic to display an ALV output using DISPLAY method of class CL_SALV_TABLE.

14)  When we execute the report with above logic, a pop up window gets displayed. This information message appears because of new method (MY_METHOD) which we have added to class CL_SALV_TABLE. Press enter to process further.

15)  New pop up will appear due to logic that has been implemented in Pre-Exit method of display. Press enter to process further.

16)  Now ALV output will get displayed. This is the normal case when we call DISPLAY method of class CL_SALV_TABLE.  Now press back button present at the top of the ALV screen.

17)  When we press the back button from ALV screen another pop up will appear and this comes due to logic we have implemented in post-exit method.

18)  In next step delete the pre/post exit implementations. This is required to implement the over write exit for display method.

19)  Now add over write exit for display method and implement its logic.

20)  Add logic to display an information message in over write exit method of display. It should be noted here that code in the upper part of the below screen shot got generated automatically. We just added the message logic in it.

21)  Now execute the below logic and see the results.

22)  Only a pop up window will appear and there will not be any ALV display. This happened because when we called the display( ) method from our report it calls the implemented over write exit method in place of standard display method.

Summary

To enhance logic of a standard method of a global class we can opt for the available exit:

·         Pre-Method exit: Called before the standard method.

·         Post-Method exit:  Called after the standard method.

·         Overwrite Method exit:  Replaces the standard method.

Source Code

Create a report with below logic:

DATA: lt_sflight TYPE STANDARD TABLE OF sflight.

SELECT FROM sflight INTO TABLE lt_sflight UP TO 10 ROWS.

DATA: l_or_alv 
TYPE REF TO cl_salv_table.

  TRY.
  
CALL METHOD CL_SALV_TABLE=>FACTORY
    
IMPORTING
      R_SALV_TABLE   = l_or_alv
    
CHANGING
      T_TABLE        = lt_sflight.
   
CATCH CX_SALV_MSG .
  ENDTRY.

  l_or_alv->display( )
.

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image