Code: Alles auswählen.
* Selektion Daten zur Person
SELECT pernr vorna nachn gbdat name2 FROM pa0002
INTO (wa_empl-empnosap, wa_empl-firstname, wa_empl-lastname, l_gbdat, l_name2)
WHERE begda <= sy-datum
AND endda >= sy-datum.
IF NOT l_gbdat IS INITIAL.
CONCATENATE l_gbdat+0(4) l_gbdat+4(2) l_gbdat+6(2) INTO wa_empl-dbirth.
ENDIF.
* Selektion Anschriften zur Person
SELECT land1 pstlz ort01 stras endda FROM pa0006
INTO (wa_empl-country, wa_empl-zipcode, wa_empl-city, wa_empl-street1, l_dummy)
WHERE pernr = wa_empl-empnosap
AND begda <= sy-datum
AND endda >= sy-datum
AND aedtm BETWEEN w_zidat-datum AND l_gestern
ORDER BY endda ASCENDING.
ENDSELECT.
* Es wurde eine Adressänderung gefunden, die eine Änderung hat.
IF sy-subrc EQ 0.
CLEAR: l_eintritt, l_datum.
*
* Selektion Ein-/Austritt
SELECT begda FROM pa0000 INTO l_eintritt
WHERE pernr = wa_empl-empnosap
AND massn IN ('01','12','19','20','32','52','63')
ORDER BY begda ASCENDING.
ENDSELECT.
IF NOT l_eintritt IS INITIAL.
CONCATENATE l_eintritt '000000' INTO wa_empl-timestampfrom.
ENDIF.
CLEAR : l_datum, l_dummy.
SELECT begda endda FROM pa0000 INTO (l_datum, l_dummy)
WHERE pernr = wa_empl-empnosap
AND begda >= l_eintritt
AND massn IN ('10','30','54','64')
ORDER BY endda ASCENDING.
ENDSELECT.
IF NOT l_datum IS INITIAL.
CONCATENATE l_datum '000000' INTO wa_empl-timestampto.
ENDIF.
* In Ausgabetabelle.
PERFORM in_ausgabe_tabelle.
ELSE.
* Überprüfe auf Änderung Ein/Ausrittsdatum
SELECT begda FROM pa0000 INTO l_datum
WHERE pernr = wa_empl-empnosap
AND aedtm BETWEEN w_zidat-datum AND l_gestern
AND massn IN ('01','12','19','20','32','52','63','10','30','54','64').
ENDSELECT.
IF sy-subrc EQ 0.
* Es wurde eine Namenänderung gefunden
SELECT pernr vorna nachn gbdat name2 FROM pa0002
INTO (wa_empl-empnosap, wa_empl-firstname, wa_empl-lastname, l_gbdat, l_name2)
WHERE pernr = wa_empl-empnosap
AND aedtm BETWEEN w_zidat-datum AND sy-datum
AND begda <= sy-datum
AND endda >= sy-datum.
IF NOT l_gbdat IS INITIAL.
CONCATENATE l_gbdat+0(4) l_gbdat+4(2) l_gbdat+6(2) INTO wa_empl-dbirth.
ENDIF.
ENDSELECT.
*
CLEAR: l_eintritt, l_datum.
SELECT land1 pstlz ort01 stras endda FROM pa0006
INTO (wa_empl-country, wa_empl-zipcode, wa_empl-city, wa_empl-street1, l_dummy)
WHERE pernr = wa_empl-empnosap
AND begda <= sy-datum
AND endda >= sy-datum
ORDER BY endda ASCENDING.
ENDSELECT.
* Selektion Ein-/Austritt
SELECT begda FROM pa0000 INTO l_eintritt
WHERE pernr = wa_empl-empnosap
AND massn IN ('01','12','19','20','21','32','52','63')
ORDER BY begda ASCENDING.
ENDSELECT.
IF NOT l_eintritt IS INITIAL.
CONCATENATE l_eintritt '000000' INTO wa_empl-timestampfrom.
ENDIF.
CLEAR : l_datum, l_dummy.
SELECT begda endda FROM pa0000 INTO (l_datum, l_dummy)
WHERE pernr = wa_empl-empnosap
AND begda >= l_eintritt
AND massn IN ('10','30','54','64')
ORDER BY endda ASCENDING.
ENDSELECT.
IF NOT l_datum IS INITIAL.
CONCATENATE l_datum '000000' INTO wa_empl-timestampto.
ENDIF.
* In Ausgabetabelle.
PERFORM in_ausgabe_tabelle.
ENDIF.
ENDIF.
CLEAR wa_empl.
ENDSELECT.