- Start transaction PE04 (Maintain Functions and Operations):
Click on button Create. - Maintain the processed payroll operation:
- Final source code of form routine OPZ_DDS. Form is found in a main program (based on country assignment| HSKCALC0. Each main program has a special custom include where all form routine of custom operations are to be stored. In our case, it is include PCBURZSK0.
*&---------------------------------------------------------------------*
*& Form OPZ_DDS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM opz_dds. *--------------------------------------------------------------------*
* Under certain circumstances, processed wage types are to be deleted from
* table IT[].
*
*--------------------------------------------------------------------*
* Local variables:
DATA:
lv_beg_period TYPE sy-datum,
lv_end_period TYPE sy-datum,
lv_workdays TYPE i, "workdays
lv_abscdays TYPE i. "absence days
DATA:
lv_begda TYPE sy-datum,
lv_endda TYPE sy-datum,
lv_days TYPE i.
DATA:
ls_ot TYPE pc207,
ls_it TYPE pc207. DATA: BEGIN OF lt_p2001 OCCURS 2.
INCLUDE STRUCTURE p2001.
DATA: END OF lt_p2001. CONSTANTS:
lc_calendar_sk TYPE hident VALUE 'SK',
lc_modif_o TYPE char1 VALUE 'O',
lc_yes TYPE char1 VALUE 'Y',
lc_no TYPE char1 VALUE 'N'. * (1.) Set period (begin and end) + working days of period
CLEAR: lv_beg_period,
lv_end_period.
lv_beg_period = first_date_in_period.
lv_end_period = last_date_in_period. CLEAR: lv_workdays.
CALL FUNCTION 'HR_RO_WORKDAYS_IN_INTERVAL'
EXPORTING
begda = lv_beg_period
endda = lv_end_period
mofid = lc_calendar_sk
CHANGING
wrkdays = lv_workdays. * (2.) Get amount of PERNR absences in a given period
REFRESH: lt_p2001[].
CLEAR: lt_p2001.
lt_p2001[] = p2001[]. CLEAR: lv_abscdays.
LOOP AT lt_p2001. * -> is absence in a given period
IF ( lt_p2001-begda <= lv_end_period ) AND
( lt_p2001-endda >= lv_beg_period ). * -> absence start
CLEAR: lv_begda.
IF lt_p2001-begda < lv_beg_period.
lv_begda = lv_beg_period.
ELSE.
lv_begda = lt_p2001-begda.
ENDIF. * -> absence end
CLEAR: lv_endda.
IF lt_p2001-endda > lv_end_period.
lv_endda = lv_end_period.
ELSE.
lv_endda = lt_p2001-endda.
ENDIF. * -> amount of working days from selected absences
CLEAR: lv_days.
CALL FUNCTION 'HR_RO_WORKDAYS_IN_INTERVAL'
EXPORTING
begda = lv_begda
endda = lv_endda
mofid = lc_calendar_sk
CHANGING
wrkdays = lv_days. lv_abscdays = lv_abscdays + lv_days.
ENDIF.
ENDLOOP. * (3.) Modify IT[] table of wage types if workdays = abscdays
IF lv_workdays = lv_abscdays.
CASE op-modif.
WHEN space. "table IT
CLEAR: ls_it.
READ TABLE it[] INTO ls_it WITH KEY lgart = op-lgart.
IF sy-subrc = 0.
vargt = lc_no. "do not process wage type
ELSE.
vargt = lc_yes. "process wage type
ENDIF.
WHEN lc_modif_o. "table OT
CLEAR: ls_ot.
READ TABLE ot[] INTO ls_ot WITH KEY lgart = op-lgart.
IF sy-subrc = 0.
vargt = lc_no. "do not process wage type
ELSE.
vargt = lc_yes. "process wage type
ENDIF.
ENDCASE.
ELSE. * -> we leave wage types for processing, since there was no special
* circumstance
vargt = lc_yes. "process wage types
ENDIF. * -> update variable "Variable key" VARGT
PERFORM fillvargt. ENDFORM. "opz_dds - Illustration of how payroll operation Z_DDS is used in HR rule - transaction PE02 (Personnel Calculation Rules).
Display of the HR rule using HR operation Z_DDS.
štvrtok 31. mája 2012
Create Custom HR Payroll Operation
Article displays a process of creating custom HR payroll operation.
Prihlásiť na odber:
Príspevky (Atom)