NODES:PERNR
GET PERNR
rp_provide_from_last P0001 space pn-begda pn-endda.
*&---------------------------------------------------------------------*
*& FORM INSERT_DATA_CREATE
*&---------------------------------------------------------------------*
* 新增请假或出差
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM INSERT_DATA.
DATA L_PCT TYPE I.
DATA L_MSG(100). "记录信息
CLEAR V_LINE.
******************去除内表中重复行
SORT RECORD_100 BY PERNR BEGDA.
"按照a.b列删除内表中的数据
DELETE ADJACENT DUPLICATES FROM RECORD_100 COMPARING PERNR BEGDA.
DESCRIBE TABLE RECORD_100 LINES V_LINE.
IF V_LINE = 0.
EXIT.
ENDIF.
SORT RECORD_100 ASCENDING BY PERNR BEGDA.
LOOP AT RECORD_100.
"显示进度
DO V_LINE TIMES.
MESSAGE S251 WITH SY-INDEX V_LINE INTO L_MSG.
L_PCT = 100 * SY-INDEX / V_LINE.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = L_PCT "注释本行可以隐藏时钟
TEXT = L_MSG
EXCEPTIONS
OTHERS = 1.
ENDDO.
*-----判断是否用BATCH INPUT导入资料还是用函数导入资料
IF P_MODE = 'A' OR P_MODE = 'E'.
*------汇整 PATCH INPUT 所需信息
CLEAR BDCDATA.
REFRESH BDCDATA.
REFRESH MESSTAB.
* IF P_MODE = 'A' OR P_MODE = 'E'.
PERFORM FILL_PCASCREEN_2002. "执行信息类型为2002(出)新增事件屏幕
REFRESH BDCMSGE.
CLEAR BDCMSGE.
CALL TRANSACTION 'PA30' " 执行批次输入
USING BDCDATA
MODE P_MODE
UPDATE 'S'
MESSAGES INTO BDCMSGE.
LOOP AT BDCMSGE . " 整理批次输入产生之讯息,讯息
CLEAR MSG_LIST.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
MSGID = BDCMSGE-MSGID
MSGNR = BDCMSGE-MSGNR
MSGV1 = BDCMSGE-MSGV1
MSGV2 = BDCMSGE-MSGV2
MSGV3 = BDCMSGE-MSGV3
MSGV4 = BDCMSGE-MSGV4
IMPORTING
MESSAGE_TEXT_OUTPUT = MSG_LIST-REASON.
IF BDCMSGE-MSGTYP = 'E'.
RECORD_100-MSGTYP = BDCMSGE-MSGTYP.
CONCATENATE RECORD_100-ZMSGE002 '[E:]' MSG_LIST-REASON INTO RECORD_100-ZMSGE002.
RECORD_100-ZMSGE001 = 'N'.
ENDIF.
ENDLOOP.
ELSEIF P_MODE = 'N'.
*-----将汇入数据整理成函数所需的数据
REFRESH BDCMSGE1.
CLEAR BDCMSGE1.
REFRESH MESSTAB.
p2002-pernr = record_100-pernr.
p2002-infty = '2002'.
p2002-subty = record_100-subty.
p2002-begda = record_100-begda.
p2002-endda = record_100-begda.
p2002-beguz = record_100-beguz.
p2002-enduz = record_100-enduz.
CONCATENATE p2002-beguz(2) p2002-beguz+3(2) '00' INTO p2002-beguz.
CONCATENATE p2002-enduz(2) p2002-enduz+3(2) '00' INTO p2002-enduz.
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
NUMBER = P2002-PERNR.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
INFTY = '2002'
NUMBER = P2002-PERNR
VALIDITYEND = P2002-BEGDA
VALIDITYBEGIN = P2002-BEGDA
RECORD = P2002
OPERATION = 'INS'
DIALOG_MODE = '0'
IMPORTING
RETURN = BDCMSGE1.
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
NUMBER = P2002-PERNR.
APPEND BDCMSGE1.
LOOP AT BDCMSGE1. " 整理批次输入产生之讯息,讯息
IF BDCMSGE1-TYPE = 'E'.
CONCATENATE '[E:]' BDCMSGE1-MESSAGE INTO RECORD_100-ZMSGE002.
RECORD_100-ZMSGE001 = 'N'.
ENDIF.
ENDLOOP.
ENDIF.
MODIFY RECORD_100.
CLEAR RECORD_100.
ENDLOOP.
*---取出错误的资料
LOOP AT RECORD_100 WHERE ZMSGE001 = 'N'.
MOVE-CORRESPONDING RECORD_100 TO ITAB_300.
APPEND ITAB_300.
CLEAR :ITAB_300,RECORD_100.
ENDLOOP.
ENDFORM. " INSERT_DATA_CREATE
*&---------------------------------------------------------------------*
*& Form get_work_days
*&---------------------------------------------------------------------*
* 根据工厂日历计算两个日期间的工作日(包含结束日期)
*----------------------------------------------------------------------*
FORM GET_WORK_DAYS USING VALUE(P_DATE1) VALUE(P_DATE2) P_CAL.
DATA: YEAR(4) TYPE C,
MONTH(2) TYPE C,
days_tprxx(6),days_ftkxx(6) TYPE C,
TPRXX(20),
DAYS_SEQ(2) type n..
CLEAR YEAR.
CLEAR MONTH.
CLEAR DAYS_SEQ.
clear days_tprxx.
clear days_ftkxx.
clear tprxx.
year = P_date1(4).
month = P_date1+4(2).
DAYS_SEQ = P_date1+6(2).
WHILE p_date1 LE p_date2.
CONCATENATE 'TPR' DAYS_SEQ ' FTK' DAYS_SEQ INTO TPRXX.
SELECT single (TPRXX) into (days_tprxx,days_ftkxx)
FROM T552A
WHERE ZEITY = '2'
and MOFID = 'CN'
and MOSID = '28'
and SCHKZ = 'NORM'
and KJAHR = year
and MONAT = month.
IF days_ftkxx = '1' or days_ftkxx = '3' or days_tprxx = 'OFF' .
WA_WORKDAY-DATE = P_DATE1.
COLLECT WA_WORKDAY INTO ITAB_WORKDAY.
CLEAR WA_WORKDAY.
ENDIF.
DAYS_SEQ = DAYS_SEQ + 1.
p_date1 = p_date1 + 1.
ENDWHILE.
ENDFORM. "get_work_days
''取评估期间
CALL FUNCTION 'CU_READ_RGDIR_NEW'
EXPORTING
PERSNR = PERNR-PERNR
TABLES
IN_RGDIR = RGDIR "OUTPUT RGDIR
EXCEPTIONS
no_record_found = 1
import_mismatch_error = 2
no_read_authority = 3
OTHERS = 4.
IF sy-subrc NE 0.
EXIT.
ENDIF.
LOOP AT RGDIR WHERE FPBEG >= PN-BEGDA AND FPEND <= PN-ENDDA.
IF RGDIR-FPPER <> RGDIR-INPER.
DELETE RGDIR.
CONTINUE.
ENDIF.
MOVE-CORRESPONDING RGDIR TO EVP.
APPEND EVP.
CLEAR EVP.
ENDLOOP.
REFRESH LT_RESULT.
REFRESH LT_RT.
* find PAYROLL RESULT
LOOP AT EVP.
CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
EXPORTING
CLUSTERID = 'CN'
EMPLOYEENUMBER = PERNR-PERNR " PERSON NUMBER
SEQUENCENUMBER = EVP-SEQNR " SEQUENCE NUMBER
READ_ONLY_INTERNATIONAL = 'X'
CHANGING
PAYROLL_RESULT = LT_RESULT " OUTPUT TABLE
EXCEPTIONS
ILLEGAL_ISOCODE_OR_CLUSTERID = 1
ERROR_GENERATING_IMPORT = 2
IMPORT_MISMATCH_ERROR = 3
SUBPOOL_DIR_FULL = 4
NO_READ_AUTHORITY = 5
NO_RECORD_FOUND = 6
VERSIONS_DO_NOT_MATCH = 7
OTHERS = 8.
IF SY-SUBRC = 0.
CLEAR LT_RT.
APPEND LINES OF LT_RESULT-INTER-RT TO LT_RT. "取结果表至LT_RT
CLEAR LT_RESULT.
CLEAR LT_RT.
ELSE.
CLEAR LT_RESULT.
ENDIF.
LOOP AT LT_RT.
CASE LT_RT-LGART.
WHEN '1006'.
* MOVE LT_RT-BETRG TO IT_TAB-PY01.
IT_TAB-PY01 = LT_RT-BETRG.
WHEN '1007'.
* MOVE LT_RT-BETRG TO IT_TAB-PY02.
IT_TAB-PY02 = LT_RT-BETRG.
WHEN '/101'.
* MOVE LT_RT-BETRG TO IT_TAB-PY03.
IT_TAB-PY03 = LT_RT-BETRG.
WHEN '/403'.
* MOVE LT_RT-BETRG TO IT_TAB-PY04.
IT_TAB-PY04 = LT_RT-BETRG.
ENDCASE.
ENDLOOP.
CLEAR LT_RT.
ENDLOOP.
APPEND IT_TAB.
*取员工考勤数据
CALL FUNCTION 'HR_TIME_RESULTS_IN_INTERVAL'
EXPORTING
INT_PERNR = WA_OUTPUT-PERNR
INT_BEGDA = FROMDATE
INT_ENDDA = TODATE
* INT_CLTYP = '1'
TABLES
* GET_TBUFF =
* GET_BUFFER_DIR =
INT_TIME_RESULTS = I_TIMERES
EXCEPTIONS
NO_PERIOD_SPECIFIED = 1
WRONG_CLUSTER_VERSION = 2
NO_READ_AUTHORITY = 3
CLUSTER_ARCHIVED = 4
TECHNICAL_ERROR = 5
OTHERS = 6.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
LOOP AT I_TIMERES.
T_HR_SALDO[] = I_TIMERES-SALDO.
LOOP AT T_HR_SALDO.
IF T_HR_SALDO-ZTART = 'Z012' OR T_HR_SALDO-ZTART = 'Z013'.
ADD T_HR_SALDO-ANZHL TO WA_OUTPUT-BINGJIA.
ENDIF.
IF T_HR_SALDO-ZTART = 'Z011'.
ADD T_HR_SALDO-ANZHL TO WA_OUTPUT-SHIJIA.
ENDIF.
IF T_HR_SALDO-ZTART = 'Z014'.
ADD T_HR_SALDO-ANZHL TO WA_OUTPUT-KUANGZHI.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDIF.