FUNCTION Z_HR_RETIRE_001.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(P_DATE) TYPE CHAR8
*" EXPORTING
*" VALUE(MSGFLAG) TYPE CHAR1
*" TABLES
*" PO_01 STRUCTURE ZSTR_HRP_TXYG01 OPTIONAL
*"----------------------------------------------------------------------
DATA HR_TABLE LIKE STANDARD TABLE OF ZSTR_HRP_TXYG01 WITH HEADER LINE.
DATA FK_TABLE LIKE TABLE OF ZHR_RETIRE_LOG WITH HEADER LINE.
*通过日期查出离职或退休人员信息
SELECT * INTO CORRESPONDING FIELDS
OF TABLE HR_TABLE FROM PA0000 WHERE BEGDA >= P_DATE AND ( MASSN = 'C4' OR MASSN = 'C6' ).
*查询记录反馈表里存在的员工号
SELECT PERNR
INTO CORRESPONDING FIELDS OF TABLE FK_TABLE FROM ZHR_RETIRE_LOG.
*剔除重复提交的员工号
LOOP AT HR_TABLE.
READ TABLE FK_TABLE WITH KEY
PERNR = HR_TABLE-PERNR.
IF SY-SUBRC = 0.
DELETE TABLE HR_TABLE FROM HR_TABLE.
ENDIF.
ENDLOOP.
*查询ZESS表,取出相同员工工号的OA登入名
SELECT * INTO CORRESPONDING FIELDS OF TABLE PO_01
FROM ZESS_LOGON FOR ALL ENTRIES IN HR_TABLE
WHERE PERNR = HR_TABLE-PERNR.
*删除重复值
DELETE ADJACENT DUPLICATES FROM PO_01[] COMPARING PERNR.
LOOP AT PO_01.
CLEAR HR_TABLE.
READ TABLE HR_TABLE WITH KEY PERNR = PO_01-PERNR.
PO_01-BEGDA = HR_TABLE-BEGDA.
PO_01-MASSN = HR_TABLE-MASSN.
MODIFY PO_01.
ENDLOOP.
IF SY-SUBRC = 0.
MSGFLAG = 0.
ELSE.
MSGFLAG = 1.
ENDIF.
ENDFUNCTION.