You are on page 1of 5

Todays class:

ABstract Method
Abstract Class
-------------------------------
Abstract Method:
Method is defined but not implemented in its cLASS.
--------------------------------------
Abstract class:( one or many ABstract methods )
If a class contains atleast one ABstract Method ..
we cannot create object for abstract class because Abstract class is not fully i
mplemented.
----------------------------------------------------
Interface: ( all Abstract mehtods )
Interface contains all methods as ABSTRCT Mthods:
we cannot create object for INTERFACE because Interface doesnot contain any impl
ementation.
===================================================
IN which situation we create ABSTRACT Method ?
NOte: Whenever we require Different implementations for same method in different
subclasses.
=====================================================
NOte: when we implement ABSTRACT method in sub class, we have to "REDEFINE" that
method
-----------------------------------------------------------------------
NOte: we can create object for Sub class if all abstract methods are implemente
d.

Note: we cannot object for ABstract class because Abstract class is not fully im
plemented.
but we can Define the refernce to ABstract class.
------------------------------------------------------------------------
On Abstractract class Reference we can trigger methods of
1) first sub class. ref = obj_sales.
2) second sub class. ref = obj_cust.
3) third sub class.
--------------------------------------------------------------------
Generic Class

Sales class ( sub class ) Implements the abstract class methods of Generic CLA
S.
customer class( sub class )Implements the abstract class methods of Generic cla
ss.
================================================================================
==========
ABtract methods can be declared only in Public section or protected section only
.
If abstarct method is declared in public section ,
then in subclass also that methods shud be redefined with "PUBLIC section".
If abstarct method is declared in protected section ,
then in subclass also that methods shud be redefined with "protected section".
Note; abstract methods which are in Protected section cannot be executed from ou
tside the class.
--------------------------------------------------------------------------------
----------
===============================================================================
=========
Public section protected section private section
--------------------------------------------------------------------------------
---------
in Same class YES YES YES
--------------------------------------------------------------------------------
---------
From sub class YES YES NO
================================================================================
=========
From outside class YES NO NO
================================================================================
=========

Final method :
Method which cannot be REDEFINE in sub class.
Method declared as FINAL , that method cannot be REDEFINED in SUBCLASS.
--------------------------------------------------------------------------------
---------
Abstract Method:
To implemen ABstract method, the method must be REDEFINed in SUBCLASS.
============================================================================
Conclusion:
FINAL keyword on Mehtod and Abstract Keyword on Mehtod SHud never be USED togeth
er
--------------------------------------------------------------------------------
----
FINAL CLASS:
A class which is FINAL, cannnot be INHERITED.
FINAL class will not have SUB CLASSes.
--------------------------------------------------------------
If any one of the abstract method is not implement in sub class.
Then that sub class also becomes "ABSTRACT clASS".
----------------------------------------------------------------------
Local class Program:
----------------------------
class Generic DEFINITION ABSTRACT .
public section .
methods : create ABSTRACT ,
change ABSTRACT,
display ABSTRACT.
endclass.
Class sales_sub definition inheriting from Generic.
Public SECTION .
methods : create redefinition,
change redefinition,
display redefinition.
endclass.
Class sales_sub implementation.
Method Create.
call transaction 'VA01'.
ENDMETHOD.
Method Change.
call transaction 'VA02'.
ENDMETHOD.
Method display.
call transaction 'VA03'.
ENDMETHOD.
endclass.
Class customer_sub definition inheriting from Generic.
Public SECTION .
methods : create redefinition,
change redefinition,
display redefinition.
endclass.
Class customer_sub implementation.
Method Create.
call transaction 'XD01'.
ENDMETHOD.
Method Change.
call transaction 'XD02'.
ENDMETHOD.
Method display.
call transaction 'XD03'.
ENDMETHOD.
endclass.
start-of-selection.
Selection-screen begin of Block B1 with Frame Title Options2.
Parameter: RB_sales RadioButton Group G1,
RB_cust RadioButton Group G1.
Selection-screen end of Block B1.
Selection-screen begin of Block B2 with Frame Title Options.
Parameter: RB_crete RadioButton Group G2,
RB_chnge RadioButton Group G2,
RB_displ RadioButton Group G2.
Selection-screen end of Block B2.
Data : ref type ref to Generic. "abstract class
data : obj_sales type ref to sales_sub.
data : obj_cust type ref to Customer_sub.
create object obj_sales. " bcoz sales class is fully impleme
nted.
create object obj_cust. " bcoz customer class is fully impl
emented.
if RB_sales = 'X'.
ref = obj_sales. " Sales sub class object is assigned
to ABSTRACT class refernce
elseif RB_cust = 'X'.
ref = obj_cust. " customer sub class object is assign
ed to ABSTRACT class refernce
endif.
******************************
if RB_crete = 'X'.
ref->create( ).
elseif RB_chnge = 'X'.
ref->change( ).
elseif RB_displ = 'X'.
ref->display( ).
endif.
.

You might also like