设中国护士网为首页 | 中国护士网专注于知识的分享,因为专注,所以更好!
分享到:

HR开发中常用的FM

来源:SAP HR资源网  作者:小彭

1、RH_STRUC_GET 用于获取组织单元下的职位及人员信息

CALL FUNCTION ‘RH_STRUC_GET’ ” 获取人员信息
EXPORTING
ACT_OTYPE = ‘O’
ACT_OBJID = PNPOBJID-LOW
ACT_WEGID = ‘O-O-P’
* ACT_INT_FLAG =
ACT_PLVAR = ‘01′
ACT_BEGDA = PNPDISBD ” 这个时间以前的有效的组织单元和人
ACT_ENDDA = PNPDISED
ACT_TDEPTH = 0
ACT_TFLAG = ‘X’
ACT_VFLAG = ‘X’
AUTHORITY_CHECK = ‘X’
TABLES
RESULT_TAB = RESULT_TAB
* RESULT_OBJEC = TAB_ORG
* RESULT_STRUC =
EXCEPTIONS
NO_PLVAR_FOUND = 1
NO_ENTRY_FOUND = 2
OTHERS = 3.

2、CU_READ_RGDIR 获取期间
CALL FUNCTION ‘CU_READ_RGDIR’
EXPORTING
PERSNR = ZPERNR
TABLES
IN_RGDIR = RGDIR
EXCEPTIONS
NO_RECORD_FOUND = 1
OTHERS = 2.

3、PYXX_READ_PAYROLL_RESULT
* 根据索引号得到工资数
CALL FUNCTION ‘PYXX_READ_PAYROLL_RESULT’
EXPORTING
CLUSTERID = ‘CN’
EMPLOYEENUMBER = IT_WERKS-PERNR
SEQUENCENUMBER = I_SEQNR-SEQNR
CHANGING
PAYROLL_RESULT = I_RT.
IF SY-SUBRC 0.
ENDIF.

4、F4帮助 用于屏幕中的F4 帮助
CALL FUNCTION ‘F4IF_INT_TABLE_VALUE_REQUEST’
EXPORTING
RETFIELD = ‘ZVARNAME’
DYNPPROG = SY-REPID
DYNPNR = SY-DYNNR
DYNPROFIELD = ‘ZVAR’
VALUE_ORG = ‘S’
TABLES
VALUE_TAB = IT_VARMC
RETURN_TAB = SELECTED_TABLE
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3.

5、进行工资模拟核算
* Simulation run payroll
SUBMIT HCNCALC0 ” 薪资核算
* VIA SELECTION-SCREEN
WITH PNPTIMRA EQ ‘X’
* with pnppermo eq pn/permo
WITH PNPPERNR EQ PERNR-PERNR
WITH PNPXABKR EQ PNPXABKR
WITH PNPPABRP EQ PNPDISBD+4(2) “Month
WITH PNPPABRJ EQ PNPDISBD+0(4) “Year
* WITH pnpabkrs EQ pnpxabkr
WITH SCHEMA EQ ‘ZM01′ ” 蒙东电力工资核算模式
WITH TEST EQ ‘NOUPD/RT/OFF’
WITH TST_ON EQ ‘X’
WITH PRT_PROT EQ ‘ ‘
WITH ECALLED EQ ‘X’
WITH SW_SPOOL EQ ‘ ‘
AND RETURN.

IMPORT RT FROM MEMORY ID ‘RT’.
FREE MEMORY ID ‘RT’.
6、动态内表
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IT_STRUCTURE
IMPORTING
EP_TABLE = DY_TABLE.
*设定指向 dy_table
ASSIGN DY_TABLE->* TO .

” 赋值
CREATE DATA DY_LINE LIKE LINE OF .
ASSIGN DY_LINE->* TO .
DATA: INDEX LIKE SY-TABIX .

7、获取最一个月的后一天
CALL FUNCTION ‘RP_LAST_DAY_OF_MONTHS’
EXPORTING
DAY_IN = W_BEGDA
IMPORTING
LAST_DAY_OF_MONTH = W_ENDDA
EXCEPTIONS
DAY_IN_NO_DATE = 1
OTHERS = 2.
8、 弹出消息框 (这个FMABAP中用的比较多)
CALL FUNCTION ‘POPUP_TO_CONFIRM_WITH_MESSAGE’
EXPORTING
DEFAULTOPTION = ‘N’
DIAGNOSETEXT1 = TEXT-020 “warning against inconsistency
DIAGNOSETEXT2 = TEXT-021
DIAGNOSETEXT3 = TEXT-022 “red = already booked!
TEXTLINE1 = ‘ ‘
TEXTLINE2 = TEXT-023 “delete nevertheless?
TITEL = ‘Delete?’(026)
START_COLUMN = 25
START_ROW = 6
IMPORTING
ANSWER = ANSWER
EXCEPTIONS
OTHERS = 1.
IF SY-SUBRC NE 0.
MESSAGE E241(57) “error in function module &1 with return code &2
WITH ‘POPUP_TO_CONFIRM_WITH_MESSAGE’ SY-SUBRC.
ENDIF.
IF ANSWER = ‘J’.

ENDIF

9、 CALL FUNCTION ‘REBUILD_PAYROLL_DIRECTORY’ 很少用 (参照程序: PUDEL20)

10、HR_GET_TIME_BETWEEN_DATES 获取日期 年月差
CALL FUNCTION ‘HR_GET_TIME_BETWEEN_DATES’
EXPORTING
BEG_DATE = IT_WERKS-ZRZRQ
END_DATE = SY-DATUM
IMPORTING
* DAYS =
MONTHS = L_MONTH
YEARS = L_YEAR .

11、RH_GET_PERNR_WITHOUT_POSITION

12、RH_OBJID_REQUEST 这个用的比较多,用于获取HR组织构架结构图的F4帮助

13、HR_HCP_READ_OBJECT_TEXT 获取对象文本

14、RP_GET_HIRE_DATE 通过时间类型找对应的日期 常用语0041 中