Monday, February 7, 2011

Working with the keyword SUPER in object oriented programming

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.





No comments:

Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)

Userexits/BADIs

Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

Blog Archive

goodsites