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.

hours = im_hours.<br />

hourly_payment = im_hourly_payment.<br />

ENDMETHOD.<br />

METHOD lif_employee~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->lif_employee~add_employee<br />

EXPORTING im_no = no<br />

im_name = name<br />

im_wage = l_wage.<br />

ENDMETHOD.<br />

ENDCLASS.<br />

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

* Sub class LCL_WhiteCollar_Employee<br />

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

CLASS lcl_whitecollar_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_monthly_salary TYPE i<br />

im_monthly_deducations TYPE i,<br />

lif_employee~add_employee REDEFINITION.<br />

PRIVATE SECTION.<br />

DATA:<br />

no TYPE i,<br />

name TYPE string,<br />

monthly_salary TYPE i,<br />

monthly_deducations TYPE i.<br />

ENDCLASS.<br />

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

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

monthly_salary = im_monthly_salary.<br />

monthly_deducations = im_monthly_deducations.<br />

ENDMETHOD.<br />

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

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

Saved successfully!

Ooh no, something went wrong!