在SAP HR模块中,人事信息类型0041用于维护各种日期,实际业务中,用户可能有以下两种维护方式。
方式一:
方式二:
对应的后台表:
此时如果规定用户都按照方式一(即默认每个栏位只能填写固定的日期类型)维护值的话,可以直接用函数或者select 取值;
否则需要换种方式来进行取值,请参考以下自己之前写过的一段代码:
FUNCTION zfg_local_2.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(I_PERNR) TYPE PERNR_D
*" EXPORTING
*" VALUE(E_DATE1) TYPE SY-DATUM
*" VALUE(E_DATE2) TYPE SY-DATUM
*" VALUE(E_DATE3) TYPE SY-DATUM
*" VALUE(E_DATE4) TYPE SY-DATUM
*"----------------------------------------------------------------------
DATA: wa_pa0041 TYPE pa0041.
DATA: lv_line(2) TYPE c.
DATA: fieldname1(30) TYPE c,
fieldname2(30) TYPE c.
FIELD-SYMBOLS: <fs1> TYPE any,
<fs2> TYPE any.
SELECT SINGLE * FROM pa0041 INTO wa_pa0041 WHERE pernr EQ i_pernr
AND begda LE sy-datum
AND endda GE sy-datum.
DO.
CLEAR:fieldname1,fieldname2.
lv_line = lv_line + 1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_line
IMPORTING
output = lv_line.
CONCATENATE 'DAR' lv_line INTO fieldname1.
CONCATENATE 'DAT' lv_line INTO fieldname2.
ASSIGN COMPONENT fieldname1 OF STRUCTURE wa_pa0041 TO <fs1>.
ASSIGN COMPONENT fieldname2 OF STRUCTURE wa_pa0041 TO <fs2>.
IF <fs1> = 'Z1'.
e_date1 = <fs2>.
ELSEIF <fs1> = 'Z2'.
e_date2 = <fs2>.
ELSEIF <fs1> = 'Z3'.
e_date3 = <fs2>.
ELSEIF <fs1> = 'Z4'.
e_date4 = <fs2>.
ENDIF.
UNASSIGN:<fs1>,<fs2>.
IF sy-index GE 5.
EXIT.
ENDIF.
ENDDO.
ENDFUNCTION.