Working with the Keyword SUPER in object Oriented Programming

By Vikram Chellappa, Mouri Tech Solutions 

SUPER is the key word used to represent the super class of a class in oops you can access the methods and attributes of the super class using this word SUPER. 

Press CREATE.

Save it. 

Provide parameter for this method.

Double click on the method then provide the logic.

Save it, check it. And Activate it.

Go to SE24.

Provide another sub class.

In this we can provide super class name in the sub class attributes.

Save it.

Then we can see the methods tab.

In this we can get automatically the super class method

Go to attributes tab.

Then provide the variables.

Save it.

Go to the methods.

Provide the logic in the method double click.

Save it, check it and activate it.

Here we can user SUPER keyword.

Then go to SE38.

Provide the logic in this program.

*&---------------------------------------------------------------------*
*& Report  ZCL_SUB_METHOD                                              *
*&                                                                     *
*&---------------------------------------------------------------------*
*&   How to work with SUPER keyword                                     
*                                   By Vikram.C
*&                                                                     *
*&---------------------------------------------------------------------*
REPORT  ZCL_SUB_METHOD .
*Provide object for sub class
DATA: OBJ TYPE REF TO ZCL_SUB_METHOD.
*provide parameters
PARAMETERS: P_VBELN TYPE VBAK-VBELN.
*Provide data object
DATA: WA_VBAK TYPE VBAK,
      WA_VBAP TYPE VBAP,
      IT_VBAP TYPE Z_VBAP.
*Create the object
CREATE OBJECT OBJ.
*Call select method
CALL METHOD OBJ->SELECT_METHOD
  EXPORTING
    P_VBELN = P_VBELN
  IMPORTING
    WA_VBAK = WA_VBAK.
*Display header data
WRITE:/ WA_VBAK-VBELN,
        WA_VBAK-ERDAT,
        WA_VBAK-ERZET,
        WA_VBAK-ERNAM.
SKIP 2.
*Provide item data
IT_VBAP = OBJ->IT_VBAP."For Your Reference this IT_VBAP is declared in attribute
*Display item data
LOOP AT IT_VBAP INTO WA_VBAP.
WRITE:/ WA_VBAP-VBELN,
        WA_VBAP-POSNR,
        WA_VBAP-MATKL.
        ENDLOOP. 

Then save it, check it, and  activate it.

Here one important point is by using one object in the sub class.

Then we can implement the super class method automatically.

The output for this program is as follows.

Provide the values.

Execute it. 

 

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