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

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

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 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 = monthly_salary - monthly_deducations.<br />

CALL METHOD super->add_employee<br />

EXPORTING im_no = no<br />

im_name = name<br />

im_wage = l_wage.<br />

ENDMETHOD.<br />

ENDCLASS.<br />

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

* R E P O R T<br />

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

DATA:

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

Saved successfully!

Ooh no, something went wrong!