21.03.2013 Views

Object Oriented ABAP

Object Oriented ABAP

Object Oriented ABAP

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

METHOD xyz.<br />

write : / 'Child class b new method --------- xyz()'.<br />

ENDMETHOD. "xyz<br />

ENDCLASS. "b IMPLEMENTATION<br />

********End of Class Definition and implementations***************<br />

***Global declaration<br />

***Creating reference variables for the classes defined above<br />

data :<br />

*Reference variable of type class a<br />

obj_a type ref to a,<br />

*Reference variable of type class b<br />

obj_b1 type ref to b,<br />

*Reference variable of type class b<br />

obj_b2 type ref to b.<br />

***********************************<br />

******************************************************************<br />

* START-OF-SELECTION<br />

*******************************************************************<br />

START-OF-SELECTION.<br />

create object : obj_a,<br />

obj_b1,<br />

obj_b2.<br />

******************************************************************<br />

* END-OF-SELECTION<br />

*******************************************************************<br />

END-OF-SELECTION.<br />

call method : obj_a->fall,<br />

obj_a->rise,<br />

obj_b1->fall.<br />

Now output of above code is :<br />

Super class a-----------fall()<br />

Super class a-----------rise()<br />

Super class a-----------fall()<br />

We will just discuss how we got this output and what will happen when we assign subclass<br />

objects to reference variables of parent class.<br />

2.2 Binding<br />

We have reference variables<br />

obj_a , obj_b1 ,obj_b2<br />

Further we created object obj_a (refers to object of class a) and obj_b1(refers to object of<br />

class b) using create object statement.<br />

When we assign

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!