Scenario: Maternity Leave
Employee maternity leave should be evaluated based on her experience in the organization.
If employee is less than 1 year old then she should not be paid.
If employee is between 1 and 3 years then she should be paid 50%.
If employee is more than 3 years old then she should be paid.
Using standard schema, we cannot achieve this.
We will create a custom function to pick correct absence valuation rule and add that function to the payroll schema.
Describe Absence Valuation Rule in V_T554L and set up counting classes in V_T554C for.
1. Paid Absence
2. Unpaid Absence
3. 50% Paid
Create Maternity Absence type(in V_T554S) and Assign Absence type to any of the above created rules.
Create a function in PE04.
Enter Function Name and Click on create Button.
Enter Description of the function and Assign Country Grouping.
Create a subroutine fu_zab in include PCBURZ990 and put the below code.
DATA: gv_date TYPE sy-datum,
gv_year TYPE PEA_SCRYY.
* Get Hire Date
CALL FUNCTION ‘RP_GET_HIRE_DATE’
persnr = pernr-pernr
check_infotypes = ‘0041’
datumsart = ’01’
status2 = ‘3’
* P0016_OPTIONEN = ‘ ‘
hiredate = gv_date.
LOOP AT ab.
CALL FUNCTION ‘HR_HK_DIFF_BT_2_DATES’
date1 = ab-begda
date2 = gv_date
output_format = ’01’
years = gv_year
* MONTHS =
* DAYS =
invalid_dates_specified = 1
* OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* Changing Absence Valuation rule based on experience
* ’01’ is Paid Absence Valuation Rule
* ’14’ is 50% Paid Absence Valuation Rule
* ’11’ is Unpaid Absence Valuation Rule.
IF gv_year GE 3.
ab-klbew = ’01’.
ELSEIF gv_year GE 1.
ab-klbew = ’14’.
ab-klbew = ’11’.
Insert the newly created function into Z schema Z003(It is copy of X000 Schema).