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.

* Adds a new employee to the list of employees<br />

DATA: l_employee TYPE t_employee.<br />

l_employee-no = im_no.<br />

l_employee-name = im_name.<br />

l_employee-wage = im_wage.<br />

APPEND l_employee TO i_employee_list.<br />

ENDMETHOD.<br />

METHOD display_employee_list.<br />

* Displays all employees and there wage<br />

DATA: l_employee TYPE t_employee.<br />

WRITE: / 'List of Employees'.<br />

LOOP AT i_employee_list INTO l_employee.<br />

WRITE: / l_employee-no, l_employee-name, l_employee-wage.<br />

ENDLOOP.<br />

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 />

lif_employee~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.

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

Saved successfully!

Ooh no, something went wrong!