比如,我们想获得personnel number 为 1 的员工的wage type /262 2009年4月份的值。
我们可以在t-code: pa_payresult中查看, RT表中wage type /262 的值为:395.60
在程序中取得这个结果:
*&---------------------------------------------------------------------*
*& Report ZTEST08
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZTEST09.
tables: pernr.
nodes: peras.
infotypes: 0001.
data: ls_result TYPE pay99_result,
lv_monsl type betrg,
lt_rt TYPE hrpay99_rt.
constants: ac_monwt type lgart value '/262'.
field-symbols: <ls_py_inter_rt>type pc207.
get peras.
rp_provide_from_last p0001 space pn-begda pn-endda.
perform get_payroll_result usingpn-begda pn-endda peras-pernr
changing ls_result.
if ls_result is notinitial.
loop at ls_result-inter-rtASSIGNING <ls_py_inter_rt> where ( lgart = ac_monwt ).
lv_monsl = lv_monsl + <ls_py_inter_rt>-betrg.
endloop.
endif.
if lv_monsl is notinitial.
write : / peras-pernr, '===>',lv_monsl.
else.
write : / peras-pernr, '--- Wage Type /262 Not Found in Payroll Result'.
endif.
form get_payroll_result using iv_begda type datum
iv_endda type datum
iv_pernr type pernr-pernr
changing
es_result type pay99_result.
data: lt_rgdir type standard table of pc261,
lv_molga type molga,
ls_t500l type t500l,
lt_evp type hrpy_tt_rgdir,
lv_import_relid type relid_pcl."Area identifier for cluster in tables PCLx
field-symbols: <ls_evp> type pc261.
*Get Correct Payroll Data for Employee
CALL FUNCTION 'CU_READ_RGDIR'
EXPORTING
persnr = iv_pernr
IMPORTING
MOLGA = lv_molga
tables
in_rgdir = lt_rgdir
EXCEPTIONS
NO_RECORD_FOUND = 1
OTHERS = 2 .
check sy-subrc = 0.
ls_t500l = cl_hr_t500l=>read(molga = lv_molga ).
lv_import_relid = ls_t500l-relid.
CALL FUNCTION 'CD_SELECT_SRTZA'
EXPORTING
RECORD_TYPE = 'A'
TABLES
in_rgdir = lt_rgdir
out_rgdir = lt_evp .
*Get the lastest payroll result between the selected period
sort lt_evp by fpbeg DESCENDING.
loop at lt_evp ASSIGNING <ls_evp> where fpbeg BETWEEN iv_begda and iv_endda.
CALL FUNCTION 'PYXX_READ_PAYROLL_RESULT'
EXPORTING
CLUSTERID = lv_import_relid
employeenumber = iv_pernr
sequencenumber = <ls_evp>-seqnr
READ_ONLY_INTERNATIONAL = 'X'
CHANGING
payroll_result = ls_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 .
IF sy-subrc = 0.
es_result = ls_result .
exit.
ENDIF.
endloop.
endform.
选择屏幕上的选择如下图所示,时间范围选择为 20009/04/01 -- 2009/04/30
运行结果如下图所示,也就是我们去到了pernsonenl number 为 1的四月份的/262这个wage type的结果。