GoodleAds

Oops-Abap- Inheritance



                                      INHERITANCE

1. Copying of one class properties to another class is called INHERITANCE.
                                                        or
It is the concept of passing the properties of one class to another class.
2. Class which receives the properties is called CHILD CLASS/SUB CLASS.
3. Class which passes the properties is called SUPER CLASS.
4. We can use an existing class to derive a new class; derived class inherits the data and method of super class.
5. Derived class can over write the existing method also we can add new code.
6. The main assest is REUSABILITY.
   I.e. we can add additional features to the existing class without modifying it.

METHOD OVERLOADING

Method are of same name but different parameters (import/export).

METHOD OVERRIDING

Child class inherits the super class method s and over writes with some additional functionality is called method overriding.

REDEFINITION

Nothing but to add extra logic to the super class method.
                                                 It is nothing but 'Method overriding'.

EXAMPLE ON INHERITANCE

Step1

1.      Go to Tcode SE24 and create a super class.
2.      Create a class as ZCL_SUPERCLASS.

 



      3.We should remove checkbox FINAL because we need to inherit super class in child class.





1.      Define method as likp_header_data .






1.      with parameters im_vbeln and ex_likp





 

1.      Write code as per requirement.

 

STEP2
1.      Create a child class using TCode SE24.

 

 

1.      Click on save and the super class method LIKP_HEADER_DATA will be copied automatically.

 

1.      So select our super class method LIKP_HEADER_DATA and click on REDEFINE ICON to add some extra functionality.

 

1.      Code will be generated automatically then uncomment our code if needed,



And then write our extra piece of code as below .

 

1.      And declare ex_lips in Attributes Tab as below.

 

Save and activate child class.

UING CHILD CLASS IN THE PROGRAM SE38.











OUTPUT:

 



 







No comments:

Post a Comment