OOPS ABAP : Abstract Class with Example

Abstract Class:

  • It is a special type of class which has at least one abstract method.
  • Abstract method is that method which has only definition. There will not be any implementation.
  • We can not create object of Abstract class.
  • We can create objects of sub classes of Abstract class.

Example:

  • Go to se24
  • Enter class name and click on create and select 'Abstract' Inst.Generation.
  • Uncheck the Final check box(If it is checked we can not create sub classes) .
  • Press enter.
 
  • Enter the method details and click on 'Goto properties' icon
.
  •  Check the 'Abstract' check box and clickon 'yes'.

 
  • Click on 'change' and activate the class.

  • If we try to write code in 'DISPLAY' method, it throws the message 'Method DISPLAY is abstract.
 Using this abstract method in Subclass:
  • Create subclass and it can be final.

  • Goto properties tab,click on superclass button and enter the class name zabstract_cls.
 
  •  Save and activate.
  • Click on 'redefine' icon.
 
  • Now click on source code button and write the below code.
  • save, check and activate.
if you don't want to implement this method you can simply undo the method by clicking on 'undo redefinition' icon next to redefine method.
 
 

Comments

Popular posts from this blog

Passing Dynamic Variables to SO10 TEXT

Edit/Delete entries in Standard Table

TMG Events