Thursday, 8 September 2016

Global Abstract Class

Ex:-

Steps :-


1.Abstract Class Creation.
  • Go to Transaction Code SE24.
  • Enter the class name start's with ZCL_< class name > and click on Create.
  • Enter the description.
  • Select the instantiation as Abstract.
  • Un-check the Final Keyword.
  • Click on SAVE.


  • Enter the Method name , Level , Visibility and description.
  • To assign the parameters , click on method name and click on Parameters .
  • Enter the parameter , Type and Associated Type.

  • Click on Save and click on Back Button.



To make Method as Abstract Method.
  • Select the method and Click on " Detail View ".

  • Pop-up will appear.
  • Select Abstract .

  • Pop-up will appear.
  • Click on Continue.



  • Click on Change.
  • Check the status bar.
  • Create a normal method to display data.
  • To pass the parameter , place the cursor on method name and click on Parameters.
  • Enter the importing parameter.
  • Click on Save and click on back button.
  • To implement the method , double click on method name.


  • Enter the logic.

  • Save it and click on Back.
  • Save -> Check -> Activate.

  • Copy the Class name.
  • Click on Back.


2.Inheriting a Class from Abstract Class :-

  • Enter the class name start's with ZCL_<class name > and click on Create.

  • Pop-up will appear.
  • Enter the description and click on Create Inheritance.
  • Enter Super class name as Abstract class name and click on SAVE.
  • To re-define the method , click on method name and click on Redefine.
  • Enter the logic .


  • Click on SAVE and click on Back button.
  • Save -> Check -> Activate.

  • Copy the Class name.

Main Program

  • Go to Transaction code SE38.
  • Enter the program name which start's with Y or Z< program name > and click on Create.
  • Enter the Title.
  • Select the Attribute Type as Executable Program and click on Create.

Source Code



DATA : OBJ TYPE REF TO  ZCL_INHERIT_ABSRACT.
DATA : IT_VBAP TYPE TABLE OF VBAP.

PARAMETERS : P_VBELN TYPE VBAP-VBELN.

START-OF-SELECTION.

CREATE OBJECT OBJ.

CALL METHOD OBJ->FETCH_DATA
  EXPORTING
    IM_VBELN =  P_VBELN
  CHANGING
    CH_ITAB  = IT_VBAP
    .

CALL METHOD OBJ->DISPLAY
  EXPORTING
    IM_ITAB = IT_VBAP
    .

  • Save -> Check -> Activate.
  • Click on Execute ( F8 ).

Input

  • Enter the Input.

Output

  • Click on Execute.


No comments:

Post a Comment