Code: Alles auswählen.
METHOD get_avg_percentage.
DATA:
lr_außen_employee TYPE REF TO lcl_field_staff.
FIELD-SYMBOLS:
<lr_employee> TYPE REF TO lcl_employee.
LOOP AT me->mt_employees ASSIGNING <lr_employee>.
TRY.
r_außen_employee ?= <lr_employee>.
* Hier rein, was zu machen ist, wenn es sich beim Mitarbeiter um einen Außendienst-Mitarbeiter handelt
CATCH cx_root.
* Einfach ALLE Fehler (auch vom Casting) mal abfangen. Braucht vorerst (im Sinne der Aufgabenstellung) keine weitere Verarbeitung.
ENDTRY.
ENDLOOP.
ENDMETHOD.
Folgende Benutzer bedankten sich beim Autor black_adept für den Beitrag:
Unit605
Aber deine Frage bezog sich auf den Inhalt der von dir zitierten Aufgabenstellung. Wo kommt denn diese Aufgabe her wenn nicht aus irgendwelchen Schulungsunterlagen.Trulchen hat geschrieben:Ja bin Studentin , aber erst ab 1 Oktober!! Derzeit im Praktium im Betrieb ( BA Studium )
Habe also noch keine Unterlagen um nachzu lesen ! EInziges Material ist das Internet das ich habe !
Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Include ZZ_1097_COMPANY_CLASSES
*&---------------------------------------------------------------------*
Class lcl_employee DEFINITION.
PUBLIC SECTION.
Methods: set_name IMPORTING im_name type string,
set_firstname importing im_firstname type string,
set_address importing im_address type string.
Methods get_name RETURNING Value(re_name) type string.
Methods get_firstname RETURNING Value(re_firstname) type string.
Methods get_address RETURNING Value(re_address) type string.
Methods get_dob RETURNING Value(re_dob) type d.
Methods get_base_salary RETURNING Value(re_base_salary) type i.
Methods get_salary RETURNING VALUE(re_salary) type i.
Methods get_full_name RETURNING Value(re_full_name) type string.
Methods get_n_o_employees RETURNING VALUE(re_n_o_employees) type i.
Methods Constructor importing im_name type string im_firstname type string im_base_salary type i im_dob type d.
Methods print.
Methods get_age Returning Value(re_age) type i.
Methods change_base_salary IMPORTING im_amount type i.
PRIVATE SECTION.
Methods set_dob importing im_dob type d.
Methods init_base_salary IMPORTING im_base_salary type i.
Data: n_o_employees type i value 0,
name type string,
firstname type string,
address type string,
dob type d,
base_salary type i.
Endclass.
Class lcl_employee IMPLEMENTATION.
Method set_name.
name = im_name.
Endmethod.
Method set_firstname.
firstname = im_firstname.
ENDMETHOD.
Method set_address.
address = im_address.
ENDMETHOD.
Method set_dob.
dob = im_dob.
ENDMETHOD.
Method get_name.
ENDMETHOD.
Method get_firstname.
ENDMETHOD.
Method get_address.
ENDMETHOD.
Method get_dob.
ENDMETHOD.
Method get_base_salary.
ENDMETHOD.
Method get_salary.
Data age type i.
age = get_age( ).
IF age between 40 and 50.
re_salary = base_salary * '1.05'.
Elseif age > 50.
re_salary = base_salary * '1.10'.
ELSE.
re_salary = base_salary.
ENDIF.
ENDMETHOD.
Method get_full_name.
CONCATENATE firstname name into re_full_name SEPARATED BY ','.
ENDMETHOD.
Method get_n_o_employees.
add 1 to re_n_o_employees.
n_o_employees = re_n_o_employees.
re_n_o_employees = sy-tabix.
Endmethod.
Method init_base_salary.
IF im_base_salary LT 0.
base_salary = 0.
Else.
base_salary = im_base_salary.
ENDIF.
Endmethod.
Method Constructor.
name = im_name.
firstname = im_firstname.
base_salary = im_base_salary.
dob = im_dob.
add 1 to n_o_employees.
Endmethod.
Method print.
Data: full_name type string,
salary type i,
age type i.
full_name = get_full_name( ).
salary = get_salary( ).
age = get_age( ).
Write: / 'Name:' , full_name,
'Addresse:' , address ,
'Gehalt:' , salary ,
'Geburtsdatum:' , dob DD/MM/YYYY ,
'Alter:' , age.
Endmethod.
Method get_age.
Data age1 type i.
age1 = sy-datum - dob.
re_age = age1 / 365.
Endmethod.
Method change_base_salary.
base_salary = base_salary - im_amount.
IF base_salary < 0.
base_salary = 0.
ENDIF.
Endmethod.
Endclass.
CLASS lcl_department DEFINITION.
PUBLIC SECTION.
METHODS:
constructor IMPORTING iv_abteilungsname TYPE c,
set_abteilungsname IMPORTING iv_abteilungsname TYPE c,
get_abteilungsname RETURNING value(rv_abteilungsname) TYPE string,
add_employee IMPORTING im_employees TYPE REF TO lcl_employee ,
print.
PRIVATE SECTION.
DATA:
mv_abteilungsname(20) TYPE c,
it_employees TYPE STANDARD TABLE OF REF TO lcl_employee with NON-unique default key.
ENDCLASS.
CLASS lcl_department IMPLEMENTATION.
METHOD set_abteilungsname.
mv_abteilungsname = iv_abteilungsname.
ENDMETHOD.
METHOD get_abteilungsname.
rv_abteilungsname = mv_abteilungsname.
ENDMETHOD.
METHOD add_employee.
append im_employees to it_employees.
ENDMETHOD.
METHOD constructor.
mv_abteilungsname = iv_abteilungsname.
ENDMETHOD.
METHOD print.
Write: / 'Name:' , it_employees-full_name,
'Addresse:' , address ,
'Gehalt:' , salary ,
'Geburtsdatum:' , dob DD/MM/YYYY ,
'Alter:' , age.
WRITE: / 'Abteilung:', mv_abteilungsname,
/ .
ENDMETHOD. "print
ENDCLASS.
Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Report ZZ_3057_COMPANY
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZZ_3057_COMPANY.
INCLUDE ZZ_1097_COMPANY_CLASSES.
Data r_employee type ref to lcl_employee.
Data r_department type ref to lcl_department.
START-OF-SELECTION.
r_department = New lcl_department( iv_abteilungsname = 'Einkauf' ).
r_employee = NEW lcl_employee( im_name = 'Schnetz' im_firstname = 'Jürgen' im_base_salary = '12000' im_dob = '19700111' ).
r_employee->set_address( Exporting im_address = 'Superweg 5 72488 Sigmaringen' ).
R_department->add_employee( R_employee ).
r_department->print( ).
Code: Alles auswählen.
METHOD print.
LOOP AT me->it_employees ASSIGNING FIELD-SYMBOLS(<lr_employee>).
<lr_employee>->pint( ).
ENDLOOP.
ENDMETHOD.
Folgende Benutzer bedankten sich beim Autor a-dead-trousers für den Beitrag:
Alexoberzell