The following article shows a procedure of implementing user-exit in standard SAP HR program HSKCREC0 (Transaction PC00_M31_REKAPI - Recapitulation of payment types).
Program HSKCREC0 is used for Slovakia, but the procedure itself may be carried out for other HR reports as well.
Firstly, let me show you the exact spot, where the implemented user-exit will be called.
The form AT_GET_PERNR is used to retrieve data for the relevant personnel number from cluster. From this place a form FILL_FROM_CLUSTER is called. This is the place, where data from cluster are read. Form FILL_RESTAB1 is a place, where the retrieved payment types are processed. From FILL_RESTAB1 a form UEXIT_AND_ADD is called.
*---------------------------------------------------------------------*
* Form Uexit_And_Add
*---------------------------------------------------------------------*
FORM UEXIT_AND_ADD.
PERFORM (FRM_NAME_UE) IN PROGRAM (PRG_NAME_UE) IF FOUND. " user-exit
...
ENDFORM. " Uexit_And_Add
As it is show, on the example above. A certain form is called from a subroutine pool.
This settings is maintained in dB T7SK4F (Reports - user-exits). There is maintenance available, so feel free to call transaction SM30.
This is the example implementation of the called form SET_PSPNR_ZL customized in table T7SK4F. The example shows, how to fill PAR18 of the enhanced report with a value relevant for certain payment types.
*&---------------------------------------------------------------------*
*& Modulpool Z_HSKCREC0_UE
*&
*&
*&---------------------------------------------------------------------*
*&
*& User-Exits for report HSKCREC0.
*&
*&---------------------------------------------------------------------*
PROGRAM zmp_hr_sm_hskcrec0_ue.
* -> Declaration of the locally used tables
- copy the COMMON-PART from the beginning of the enhanced report
* in order to gain access to infotype data
DATA: BEGIN OF COMMON PART it.
INFOTYPES: 0000, 0001, 0002.
DATA: END OF COMMON PART it.
* -> Include COMMON PART, with the desired structure
INCLUDE hsklxxl4.
* -> Form used to fill field POSNR for payment types:
* -> Payment types /333 & /354
FORM set_pspnr_zl.
**********************************************************************
DATA:
lv_pernr TYPE p0001-pernr, "personnel number
ls_p0015 TYPE p0015, "infotype 15 - add.payment
ls_assob TYPE assob_hr. "relationship to assignm.objects
CONSTANTS:
lc_333 TYPE char04 VALUE '/333', "payment type /333
lc_354 TYPE char04 VALUE '/354', "payment type /354
lc_m96v TYPE subty VALUE 'M96V', "payment type M96V
lc_it15 TYPE infty VALUE '0015'. "Infotype 15
**********************************************************************
* -> Set POSNR field for payment types /333 a /354
IF ( comm-par15+0(4) = lc_333 ) OR
( comm-par15+0(4) = lc_354 ).
CLEAR: lv_pernr.
lv_pernr = p0001-pernr.
* -> Read the last relevant entry from infotype 0015
CLEAR: ls_p0015.
SELECT *
INTO CORRESPONDING FIELDS OF ls_p0015
UP TO 1 ROWS
FROM pa0015
WHERE pernr = lv_pernr
AND subty = lc_m96v
ORDER BY endda DESCENDING.
ENDSELECT.
CHECK sy-subrc = 0.
* -> Get the assignment objects based on infotype 0015
CLEAR: ls_assob.
SELECT SINGLE *
INTO CORRESPONDING FIELDS OF ls_assob
FROM assob_hr
WHERE pernr = ls_p0015-pernr
AND infty = lc_it15
AND subty = ls_p0015-subty
AND objps = ls_p0015-objps
AND sprps = ls_p0015-sprps
AND endda = ls_p0015-endda
AND begda = ls_p0015-begda
AND seqnr = ls_p0015-seqnr.
CHECK sy-subrc = 0.
* -> Conversion of PONSR to external format
CALL FUNCTION 'PSPNUM_INTERN_TO_EXTERN_CONV'
EXPORTING
int_num = ls_assob-posnr
IMPORTING
ext_num = comm-par18
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
comm-par18 = ls_assob-posnr. "set POSNR field
ENDIF.
ENDIF.
ENDFORM. "set_pspnr_zl
Žiadne komentáre:
Zverejnenie komentára