HR取数逻辑
2018-12-25 本文已影响28人
Mmm_余安
- HR-员工所属组,部门,上层部门
CALL FUNCTION 'RH_STRUC_GET'
EXPORTING
ACT_OTYPE = 'O'
ACT_OBJID = PERNR-ORGEH "员工号
ACT_WEGID = 'O-O' "从组织到组织
ACT_BEGDA = PN-BEGDA
ACT_ENDDA = PN-ENDDA
TABLES
RESULT_OBJEC = LT_OBJEC
EXCEPTIONS
NO_PLVAR_FOUND = 1
NO_ENTRY_FOUND = 2
OTHERS = 3.
image.png
OBJID即为部门编号
- 获取考勤信息
对应的前台Tcode:PT66
PT66
每个月有一条数据
每个月有一条数据,选中展开一条。
image.png
后台
DATA LV_ZNUM TYPE I.
DATA: IT_TIME_RESULTS TYPE PTT_TIME_RESULTS WITH HEADER LINE,
WA_TIME_RESULTS TYPE PTT_TIME_RESULTS.
REFRESH IT_TIME_RESULTS.
CALL FUNCTION 'HR_TIME_RESULTS_IN_INTERVAL'
EXPORTING
INT_PERNR = PERNR-PERNR
INT_BEGDA = PN-BEGDA "对每一天的数据进行汇总
INT_ENDDA = PN-ENDDA
INT_CLTYP = '1'
TABLES
* GET_TBUFF =
* GET_BUFFER_DIR =
INT_TIME_RESULTS = IT_TIME_RESULTS.
IF SY-SUBRC NE 0.
* RAISE EXCEPTION TYPE cx_pt_import_cluster_b2_failed
* EXPORTING
* textid = cx_pt_import_cluster_b2_failed=>cx_pt_import_timetype_failed.
ENDIF.
LOOP AT IT_TIME_RESULTS.
LT_PSP = IT_TIME_RESULTS-PSP .
LT_PT = IT_TIME_RESULTS-PT .
LT_FEHLER = IT_TIME_RESULTS-FEHLER .
LT_ZES = IT_TIME_RESULTS-ZES .
LT_ZL = IT_TIME_RESULTS-ZL.
LT_ANW = IT_TIME_RESULTS-ANWKONTI.
* 控制日期
IF PNPBEGDA+4(2) <> PNPENDDA+4(2).
IF IT_TIME_RESULTS-PABRP = PNPBEGDA+4(2)."判断选择屏幕low值的时间
LV_C = IT_TIME_RESULTS-ENDDA - PNPBEGDA + 1."选择屏幕low值到月底的天数
LV_DATA = PNPBEGDA.
ELSEIF IT_TIME_RESULTS-PABRP = PNPENDDA+4(2).
LV_C = PNPENDDA - IT_TIME_RESULTS-BEGDA + 1."选择屏幕high值到月初的天数
LV_DATA = IT_TIME_RESULTS-BEGDA.
ELSE.
LV_C = IT_TIME_RESULTS-ENDDA - IT_TIME_RESULTS-BEGDA + 1."整月的天数
LV_DATA = IT_TIME_RESULTS-BEGDA.
ENDIF.
ELSE.
LV_C = PNPENDDA - PNPBEGDA + 1."选择屏幕low值到月底的天数
LV_DATA = PNPBEGDA.
ENDIF.
ENDLOOP.
后台没有办法限制日期,需要自己控制
-
获取薪资明细
前台Tcode:pc_payresult
每个月数据单独存放
DATA: LS_PY_RESULT TYPE PAYCN_RESULT,
LT_RGDIR TYPE TABLE OF PC261,
LWA_RGDIR TYPE PC261.
*查询员工的薪资
CALL FUNCTION 'CU_READ_RGDIR'
EXPORTING
PERSNR = P0001-PERNR
IMPORTING
MOLGA = L_MOLGA
TABLES
IN_RGDIR = LT_RGDIR
EXCEPTIONS
NO_RECORD_FOUND = 1
OTHERS = 2.
*对应的数据存放在L_MOLGA内表中
image.png
DATA: L_CLUSTERID TYPE PCL2-RELID,
L_EMPLOYEENUMBER TYPE PC200-PERNR,
L_SEQUENCENUMBER TYPE PC261-SEQNR,
LS_PY_RESULT TYPE PAYCN_RESULT.
L_DYNWHERE = 'payty = l_dal1 AND fpbeg <= pn-endda AND fpend >= pn-begda AND srtza = l_dal'.
LOOP AT LT_RGDIR INTO LWA_RGDIR WHERE (L_DYNWHERE).
EXIT.
ENDLOOP .
IF SY-SUBRC <> 0.
REJECT.
ENDIF.
LOOP AT LT_RGDIR INTO LWA_RGDIR WHERE (L_DYNWHERE).
L_EMPLOYEENUMBER = P0001-PERNR.
L_SEQUENCENUMBER = LWA_RGDIR-SEQNR .
*
CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
EXPORTING
CLUSTERID = L_CLUSTERID
EMPLOYEENUMBER = L_EMPLOYEENUMBER
SEQUENCENUMBER = L_SEQUENCENUMBER
CHECK_READ_AUTHORITY = ' '
CHANGING
PAYROLL_RESULT = LS_PY_RESULT
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
ERROR_READING_ARCHIVE = 8
ERROR_READING_RELID = 9
OTHERS = 10.
*所需的数据在LS_PY_RESULT,LS_PY_RESULT-INTER里有RT等等表
- 获取员工对应的国家以及对应的编号
CALL FUNCTION 'PYXX_GET_RELID_FROM_PERNR'
EXPORTING
EMPLOYEE = P0001-PERNR
IMPORTING
RELID = L_RELID
MOLGA = L_MOLGA
EXCEPTIONS
ERROR_READING_INFOTYPE_0001 = 1
ERROR_READING_MOLGA = 2
ERROR_READING_RELID = 3
OTHERS = 4.
*
SORT LT_RGDIR BY SEQNR DESCENDING.