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.

ENDMETHOD.<br />

METHOD display_no_of_employees.<br />

* Displays total number of employees<br />

SKIP 3.<br />

WRITE: / 'Total number of employees:', no_of_employees.<br />

ENDMETHOD.<br />

ENDCLASS.<br />

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

* Sub class LCL_BlueCollar_Employee<br />

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

CLASS lcl_bluecollar_employee DEFINITION<br />

INHERITING FROM lcl_company_employees.<br />

PUBLIC SECTION.<br />

METHODS:<br />

constructor<br />

IMPORTING im_no TYPE i<br />

im_name TYPE string<br />

im_hours TYPE i<br />

im_hourly_payment TYPE i,<br />

add_employee REDEFINITION.<br />

PRIVATE SECTION.<br />

DATA:no TYPE i,<br />

name TYPE string,<br />

hours TYPE i,<br />

hourly_payment TYPE i.<br />

ENDCLASS.<br />

*---- CLASS LCL_BlueCollar_Employee IMPLEMENTATION<br />

CLASS lcl_bluecollar_employee IMPLEMENTATION.<br />

METHOD constructor.<br />

* The superclass constructor method must be called from the subclass<br />

* constructor method<br />

CALL METHOD super->constructor.<br />

no = im_no.<br />

name = im_name.<br />

hours = im_hours.<br />

hourly_payment = im_hourly_payment.<br />

ENDMETHOD.<br />

METHOD add_employee.<br />

* Calculate wage an call the superclass method add_employee to add<br />

* the employee to the employee list<br />

DATA: l_wage TYPE i.<br />

l_wage = hours * hourly_payment.<br />

CALL METHOD super->add_employee<br />

EXPORTING im_no = no<br />

im_name = name<br />

im_wage = l_wage.

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

Saved successfully!

Ooh no, something went wrong!