# I. Requirement

How to calculate consecutive 7 days for absence in Time Evaluation? If employee is on leave consecutive 7 days, system raise an information message.

First of all, you have to make clear the requirement whether it’s CALENDAR days or WORKING DAYS. Because it will impact how to design the enhancement in Time Eval.

In the document, I will demonstrate 2 solutions to handle each above requirement: CALENDAR and WORKING DAYS. And I only focus on 1 absence type 1211, you can adjust accordingly with your current configuration.

II. Master Data

My employee has the planned working time in IT7 as below, it is simple ws: working on Mon to Fri ; off on SAT to Sun.

III.(A) SOLUTION 1 for CALENDAR

The tricky part when calculating by calendar day is that the standard P2001 function will not generate any record in TIP table if the date is DAY OFF. In order to overcome the situation, we have to use AB with function ACTION while calling pcr /VN1 in time schema.

1) I create one Time Type to hold each day on leave and accumulate accordingly as well.

(2) The 1st pcr: if absence type is 1211, assign 1 into Time Type ZABS

(3) The 2nd pcr: if Time Type ZABS > 0 (it means that employee is on leave on that date), so plus with all total consecutive leave until the previous date (HRS+LZABS).

(4) Insert into Time schema: I copies standard one TM04 and add more 2 lines just immediately after block Provide time data in row 350.

The AB above (part 2) with function ACTIO will help us to check whether employee is on leave on DAY OFF or not. Without AB, SAP will only check employee is on leave on DAY WORK only.

III.(B) Testing SOLUTION 1 for CALENDAR

TC01:

INPUT Employee is on-leave from 26.08.2015 to 03.09.2015. Expected result is that system should raise message on 01.09.2015.

OUTPUT: The 2nd pcr /VN9 generated the information message on 01.09.2015 as expected.

Run standard report with period from 25.08.2015 to 30.09.2015: output is expected.

Time Type ZBAS in Time cluster result: We can easily see that system is capable to accumulate consecutive CALENDAR days from 28.08.2015 to 01.09.2015.

TC02:

INPUT: Employee is on-leave from 26.08.2015 to 29.08.2015 and 31.08.2015 to 03.09.15. (No leave is on date 30.08.2015)

Expected result is that system should NOT raise any message.

OUTPUT: system DOES NOT generate message any more.

Time Type ZABS in time cluster result.

System is smart enough to re-start counting from 31.08.2015 as there is no absence record on 30.08.2015. Therefore, system does NOT generate the message anymore.

IV.(A) SOLUTION 2 for WORKING DAY

The tricky part when calculating by working day is how to ensure that on Mon we can able to check that the previous Fri employee is on leave. The logic in /VNA will handle it.

(1) Time Type ZABS keep as the same.

(2) 1st prc not change: /VN1, but the way to call in schema will be changed.

(3) 2nd pcr /VNA: It is quite the same pcr /ZVN9 above but having additional condition on DAY OFF (VARSTFREE is Y) is to carry previous value from the previous working day (e.g. Fri) on DAY OFF such as Sat and Sun. So the next working day (Mon), we can ensure that employee was on leave on last Fri.

(4) Calling the 2 pcr in time schema:

IV.(B) Testing SOLUTION 2 for WORKING DAY

TC03:

INPUT: Employee is on-leave from 26.08.2015 to 29.08.2015 and 31.08.2015 to 03.09.2015. (Same input in TC02 above)

Expected result is that system should raise the information message on 03.09.2015

OUTPUT:

The 2nd pcr /VNA generated the information message on 03.09.2015 as expected.

Run standard report with period from 25.08.2015 to 30.09.2015: output is expected.

Time Type ZABS on Sat and Sun, it’s 3 days as we automatically carry forward from Fri (value 3 days) to DAY OFF on Sat and Sun.

TC04:

INPUT: Employee is on-leave from 24.08.2015 to 27.08.2015 and 31.08.2015 to 03.09.2015.

Expected result is that system should NOT raise the information message.

OUTPUT:

System does NOT generate any message anymore because time type ZABS has not reached 7 consecutive days yet.

We can see that system accumulate from 24.08.2015 to 27.08.2015 as 4 days. But Fri 28.08 does NOT have any absence, so system reset the counting and restart again from next Mon on 31.08.2015.

V. CONCLUSION

With 2 different approaches, we are able to handle both requirement: consecutive CALENDAR DAYS / WORKING DAYS on leave. Hope you can apply the document for the various scenarios. Thanks.

Best Regards,

Woody

### Assigned Tags

You must be Logged on to comment or reply to a post.

Hi Woody,

Excellentttttt!!!!!

Regards, Sankarsan

Hi Woody,

Asusual , Master piece once again brother. thanks for providing it.

Regards

Sriram

Trong Minh (Woody) Nguyen
Blog Post Author

Thanks Sriram and Sankarsan ðŸ™‚

Happy to know that it's useful one ðŸ˜€

Regards,

Woody (Trong Minh)