Absence Quota basing on Working Date

I. Purpose

            This document will help you more deeply understand Absence Quota Generation and Time Schema. I have seen a lot of question involving Time Schema - one of the most difficult things in SAP HCM,so I hope the document will support you better to control Time Schema. In document, I will generate Absence Quota by using Time Schema. I have to create many PCRs with quite complex logic and input them into many where in Time Schema. You can find how to link mater data, controlling Time Type and processes of Time Evaluation.
          Note: before looking at the document, basic knowledge in Absence Quota must be investigated carefully first.

II. Requirement

         I will focus on 1 actual customer's expectation. It's one of common request whenever implementing or supporting SAP HCM in enterprise's system:
          1. Employee will has 1 Paid Leave Quota after having 20 working days on system.
          2. Working date is: when he has Attendance on IT2002 (of-course not including the day off: Saturday or Sunday), and has full check-in and check out in Time Events IT2011.
          3. Absence Quota'll generated yearly.
          4. Only Available for applying from the next year, until 31.12.9999

III. Solution

          First in Time Schema, you have to calculate Working Days by using data from 2 Infotype: 2002 (Attendances) and 2011 (Time Events), thus we have to copy from standards schema TM00 to our schema and modifying it. Standard Functions in Time Schema retrieve data from 2 Infotype and post them into internal table TIP, in Schema - useful links & T-Codes there is useful link to understand how time data stored in TIP. In order to retreive data in TIP, standard functions RTIP or PTIP must be used to get data and then checking it.
          Origin indicator of TIP as below
                    E = Time event
                    O = Overtime from Overtime infotype (2005)
                    A = Absence from Absences infotype (2001)
                    P = Attendance from Attendances infotype (2002)
                    R = Availability from Availability infotype (2004)
                    D = Generated planned pair
                    C = Attendance/absence reasons
          So we will check: if origin indicator is P, 1 working day will be counted. If origin indicator is E, next step is checking whether in that day employee has full check in check out or not. These points above will accumulate Working Date Total into 1 Time Type.

          Next checking whether the last date coming, Working Date Total divide 20 and giving these number to Absence Quota. So in Time Evaluation, we have to check whenever 31-Dec is run.
          It's just summarization. Now steps be steps will be shown in order from here.

1. Grouping

Personnel Structure (EE group and EE subgroup)
Using Table View V_503_E in T-Code SM31 / SM30. My grouping is 2.

Enterprise Structure (Personnel Area and Personnel Sub-Area).
Using Table View V_001P_I. It's 08

Grouping for Time Recording:
Using Table View V_001P_H

2. Base Entitlement

As you can see, 3 grouping values above will be used here (2, 08 and 01).
Thanks to time type 9D50, whenever we assign value to 9D50, Absence Quota Type 10 (Paid Leave) in IT2006 will be created. The configuration of Type Type 9D50, nothing is important with configuration of 9D50

3. Counting Working Days

As I mention at the beginning in solution part, the PCR ZWA1 has logic as below (using T-Code PE02 to create PCR).
Operation "OUTTPORIGS Origin status" returns Origin status in internal table TIP (E: data inputted from IT2011, P data inputted from IT2002).
Operation "OUTTPEXTIM Times exist?" checks whether Time Event has full check in and check out or not. Y means it's correct, both check in and check out exist.

The day fits conditions here, Time Type 9M99 will be accumulated 1. It's configuration of 9M99
Cumulate in period balance is 1: The time type is cumulated in a period balance. Our period here is month.
2 Transfer previous are clear right? because we just generate on last date of year so we have move data all months (from Jan to Nov) into Dec.
Transfer previous year is up to you. In my schema, it isn't necessary because in 31st Dec, Absence Quota is generated, so Accumulated working days will be blank.
Now using with Function RTIP / PTIP in Time schema (IMPORTANT)
I copied schema ZW01 from TM00 in T-Code PE01.
After successfully calling Function P2011, P2002, P2001, etc, ZWA1 is inserted into Time Schema with Function RTIP.
This is these all logic to calculate Working Days.

4. Checking EOY (Dec-31st)

Creating 1 PCR to check whether month is Dec or not.
VARSTCURMO Current period: it returns current period (not current system , current period is the month that Time Evaluation is running. For example if you are running PT60 for 2 months: Jan to Feb, so the first current period is Jan, after accomplish running for all days in Jan, current period will be Feb).
Next ZI15 is inserted into Time Schema ZW01.
As you can see, 1st check Dec, 2nd check EOM, the day fitting 2 conditions is Dec-31st, the last date of Dec. There are many solutions for checking Dec-31st. You can check by using Month and Day directly by using 2 operations: HRS=BCURDY :      current day; HRS=CURMO :      current month period

On Dec-31st, ZWA2 will be called to generate Absence Quota. Next point will explain the PCR. Note: these PCRs have to inserted Time Schema before 2 standard Functions: CUMBT and QUOTA.

5. Generate Absence Quota.

PCR ZWA2 will take responsibility to generate Absence Quota.
Retrieving Accumulated Working Days in 9M99 by HRS=M9M99. Must plus with D9M99 (Daily value of 9M99, because only running CUMBT, Daily time type value will be updated into Accumulated time type).
Comparing with constant in V_T511K ZZ000 (it's 20). If accumulated working days is lower than 20 until last day of year, I will clear by assigning 0 to them.
Other while, Accumulated Woring Days divides ZZ000 and inserts into time type 9D50. After that clearing value of 9M99.

These's all done for calculating Working Days Yearly and updating value into Absence Quota in IT2006 throung time type 9D50.

6. Period in Absence Quota

Next, I will show how to generated yearly and Available for applying from the next year, until 31.12.9999.
It's done in Table View V_T559D with grouping 2, 08 and absence Quota 10 Paid Leave

Deduction Period.jpg
Validity Interval: it's period for Start Date and End Date in IT2006. In these picture, on the left, it's Start of Calendar Year (normally it's Jan-01st), and the right it's End of Calendar Year( of course it's Dec-31st).
Deduction Interval: it's period that employee can be apply your Absence Quota.
Deduction From: End of validity interval, it means Dec-31st. But looking Relative Position: 1 Days. So Deduction From will start from Dec-31st + 1 days, so it will be Jan-01st of next year
Deduction To: as same as Deduction From but relative is 999 Month so it'll be 31.12.9999.

That's all Next part is testing to be sure that solution is correct

IV. Testing

Hiring employee in Grouping 2, 08 and 01 on Jan-01st-2010.
1st case: having only 2 attendance records in IT2002
Attendance Total: 26 (Jan) + 26 (Oct) = 52 days.
After running PT60 until Dec-31st:
     Employee has 2.6 days in Absence Quota ( 52/20 = 2.6).
     Period: 01.01.2010 -> 31.12.2010.
     Deduction period: 01.01.2011 -> 31.12.9999
               => All is correct
2nd case: Inputting more 2 days full check in and check out (for case miss check in/ check out, I tested but not post here & moreover I have test same case in Understanding Relationship PT and PY):
Working days = 52 (attendance in IT2002) + 2 ( in IT2011) = 54 days.
After running PT60 until Dec-31st:
     Employee has 2.7 days in Absence Quota ( 54/20 = 2.6).
     Period: 01.01.2010 -> 31.12.2010.
     Deduction period: 01.01.2011 -> 31.12.9999
               => All is correct


No comments:

Post a Comment