21.03.2013 Views

Object Oriented ABAP

Object Oriented ABAP

Object Oriented ABAP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Sub class: truck (contains more specific methods)<br />

Here method4 is the specific for the sub class and remaining methods are inherited from the<br />

super class.<br />

Now create the object with reference to the subclass.<br />

1. Declare a variable with reference to the subclass.<br />

DATA: REF_TRUCK TYPE REF TO TRUCK.<br />

2. Create object with this reference.<br />

CREATE OBJECT REF_TRUCK.<br />

Narrowing cast:<br />

1. Declare a variable with reference to the super class.<br />

DATA: REF_VEHICLE TYPE REF TO VEHICLE.<br />

2. Assign the object reference (REF_TRUCK) to REF_VEHICLE.<br />

REF_VEHICLE = REF_TRUCK.

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

Saved successfully!

Ooh no, something went wrong!