Code: Alles auswählen.
REPORT zyr_test_logidb.
TABLES pernr.
INFOTYPES: 0001, "Org. Zuorndung
0002. "Daten zur Person
DATA alter TYPE p.
START-OF-SELECTION.
WRITE 'Vorname'(fsn).
WRITE 42 'Nachname'(lsn).
WRITE 83 'Geburtsdatum'(dob).
WRITE 105 'Alter'(age).
SKIP.
* GET pernr liefert jedes mal eine Personalnummer und füllt die Infotypen
* get pernr füllt außerdem die in infotypes angegebenen infotyp tabellen p0001, p0002 - Tabellen mit Kopzeile
GET pernr.
CHECK p0001-persg = '1' AND p0001-persk ='01'. "Es werden nur Daten von Personen angezeigt,
"die i.d Mitarbeitergruppe "1" und -kreis "01" sind.
PERFORM get_pernr.
*&---------------------------------------------------------------------*
*& Form GET_PERNR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_pernr.
*Berechnen des Alters
CALL FUNCTION 'COMPUTE_YEARS_BETWEEN_DATES'
EXPORTING
first_date = p0002-gbdat
"MODIFY_INTERVAL = ' '
second_date = sy-datum
IMPORTING
years_between_dates = alter
EXCEPTIONS
sequence_of_dates_not_valid = 1
OTHERS = 2.
IF sy-subrc <> 0.
"
ENDIF.
LOOP AT p0001.
* WRITE: / p0001-persg,
* p0001-persk.
ENDLOOP.
LOOP AT p0002.
WRITE: / p0002-vorna,
p0002-nachn,
p0002-gbdat COLOR 2,
alter COLOR 2.
ENDLOOP.
SORT p0002 BY gbdat DESCENDING.
ENDFORM.
Code: Alles auswählen.
IF ( p0002-gbjhr <= 1970 ).
WRITE alter COLOR 1.
* ELSEIF ( p0002-gbjhr <= 1980 ).
* WRITE alter COLOR 2.
* ELSEIF ( p0002-gbjhr <= 1990 ).
* WRITE alter COLOR 3.
ELSEIF ( p0002-gbjhr <= 2001 ).
WRITE alter COLOR 4.
ENDIF.