cancel
Showing results for 
Search instead for 
Did you mean: 

Need to check 10 Consecutive days for absence in PCR and then generate message

Former Member
0 Kudos

Hi Experts,

Can anyone guide me how to check the condition of 10 consecutive days in time PCR and then generate message in time evaluation.

Business requirement is if employees takes 10 consecutive absence days of sick leave then on the 10th day time evaluation should generate message.

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Sanky
Active Contributor
0 Kudos

Hi,

You can create a two pcr's for the same.

1. 1st one will cumulate the day's upto 10day's.

ZTST

*

  ****

        VARSTFREE

            N

                 VARSTPRSNT

                        Y

                          VARSTP2001

                             Y

                                LEAVE

                             N

                                HRS=1

                                ADDDB1000Z

                        N

                            LEAVE

           Y

                VARSTPRSNT

                     Y

                         VARSTP2001

                             Y

                                LEAVE

                             N

                                HRS=1

                                ADDDB1000Z

                    N

                         LEAVE

Here 1000 is the time type and you will maintain as 1 for this time type in T555A table for cumulative period balance.

You will insert this PCR after P2002 function in the time schema with the help of ACTIO function.

2. 2nd one will check the 10day's count and then will generate the message and will make Ttype1000 reset.

ZCHK

*

   ****

         HRS=M1000

         HRS?10

               <

                   LEAVE

               *

                  COLER20I

                  HRS=M1000

                  HRS-M1000

                  ADDMB1000Z

Here 20 is the message type mabsed upon the PSG grouping for your case.

You will insert this PCR after LIMIT function with the help of ACTIO function.

Regards, Sankarsan

Former Member
0 Kudos

Hi Sankarsan,

Thanks for the quick reply.

My requirement is to check consecutive days. I have written the PCR as per your logic but system is not checking the consecutive days.

For ex. if an employee is taking leave on 2,3,4 and then on 9,10,11,12,13,14,15 system is passing message on 15th which it should not.

It should check the consecutive days and if the condition is satisfied then it should generate message

Thanks

former_member182377
Active Contributor
0 Kudos

Hi Anil.

You need check the previous day whether time types has the value or not.. you need to add those check in the PCR,, Like

HRS=LXXXX

Where XXXX will be your wage type .

So consecutive days will be added.

Thanks

Sriram

Former Member
0 Kudos

Hi Sriram,

How will I check for weekends as "L" transfer the value of previous day in ZES table.

Can you explain in detail.

Regards,

former_member182377
Active Contributor
0 Kudos

Hi Anil,

HRS=Lxxxx will give you the previous day details of ZES, for example if employee is applied leave only for two days , you will query in PCR as Sankarsan stated ,

If employee is applied sick leave you are adding 1 to the time type right?, before you just check the like this HRS=Lxxxx which says previous day employee is present or not, you will add one to the time type one and only if employee applied sick leave. so HRS = Lxxxx,

if the HRS has 0 which means previous day he was not in sick leave , incase if its 1, previous day he was in sick leave,, so like this you can do it for continous ten days.. any gap is there time type give value 0, so no continously he applied.. but you must makesure you cover weekend as well. you can query weekday using operation VARSTWEDAY will give you monday to sunday.

Little logic will help you here..

Thanks

Sriram

seg_hr_it
Active Contributor
0 Kudos

Hi Anil,

I thought it is impossible to build the logic via standard time eval as SAP will NOT consider employee is on leave on DAY OFF. Please look at the following 2 examples:

Normal working time: from Mon to Fri. Sat & Sun are DAY OFF.

(1) Employee apply leave from 01.09.2015 to 10.09.2015 (continuously).

=> Time Eval, SAP will not generate record in TIP on 05.09.2015 and 06.09.2015 (Sat & Sun). System will generate record in TIP from 01.09.2015 to 04.09.2015 and from 07.09.2015 to 10.09.2015.

(2) 2nd scenario: emp apply 2 separate leaves: 01.09.2015 to 04.09.2015 & 07.09.2015 to 10.09.2015.

=> Output in TIP in Time Eval should be as same as in 1st scenario.

Because of that I don't think we have a standard solution for that.

Moreover I thought the requirement is not necessary to process in Time Eval, Standard addhoc query can export the same outcome. In addition to this, if it is an error, you can build a customized logic in user-exit in IT2001 to raise error message when employee apply leave. I believe it should be a better solution than trying to carry everything in Time Eval which it is already complicated.

Hope it helps.

Best Regards,

Woody

PS: in case you can consider both above scenarios are same and raise the message, we might have solution but it is difficult to write down with the following main steps:

(1) Within 1 week, please use L as mentioned by another guy (if you are not quit sure, please using F1 key or t-code pdsy to have more SAP documents)

L        Time type zzzz from the previous day is put in the
          No. of hours field from table ZES

to validate employee is continuous on leave or not.

(2) On Friday you need to store the record some where (can use accumulative configuration in V_T555A) to do so then retrieve it again on Monday. Must clear the value, but notice dont use ADDMB to clear because will have issue which I mentioned in doc Understanding operation ADDMB

(3) if the value store on Friday is not NULL => mean employee is on leave on Fri, on Monday, continue to check.

(4) Keep the logic until total accumulative for Leave reach 10, then raise message.

One more time I don't recommend to build the logic in Time eval as you can extract the information easily via standard add-hoc query. Just propose the option to your customer and explain to them the difficulty in Time eval. Good luck.

seg_hr_it
Active Contributor
0 Kudos

I found out the one may be useful for checking on Friday

LzzzzA   Time type zzzz from the last day before the current
          day on which the employee worked and whose time
          recording status is not equal to zero is put in the
          No. of hours field from table ZES

But I did NOT check Let try this one instead of L, so it will be more easy

Former Member
0 Kudos

Hi Woody,

My client just want a information message on 10th consecutive day of sick leave. I am able to generate the message but the system is not checking the 10 consecutive days. even if there is a gap on leave taken on the 10th day of sick leave the message is generated. I just need logic to check consecutive days. If I am using "L" then when Sat and Sun or public holiday is there the value is 0. 

Is there any logic to check 10 consecutive days.

seg_hr_it
Active Contributor
0 Kudos

As I mentioned earlier, on DAY OFF, SAP will not create a record in TIP for absence. So on Mon, if you use L, return value is always 0, because previous day is Sunday as a DAY OFF.

Once more time, I want to emphasize that both scenarios are same while processing in Time Eval.

If you want to implement the requirement in Time Eval, I am afraid that you have to build a customized function and then call in Time Eval.

If you want to calculate 10 consecutive WORKING DAYS, it is possible with high level logic I mentioned above. (The most difficult part is to ensure that on Mon you are able to check last Fri, employee is on leave or not. And you know employee may have various work schedules, 2 days a weeks, 3 days a week, etc).

If you want to calculate 10 consecutive CALENDAR DAYS, potentially create your own customized function.

FYI I share the screenshot how P2001 when it processes on working day and DAY OFF. TIP is NULL when it is DAY OFF.

PS for your reference, assuming you can build logic to identity 10 consecutive days and raise message. How about employee has 30 / 40 / 50 consecutive leave, how system should behave? 1 time only or 3 times or 21 times or more generating message. It is the case you should take into account. I guess your client only expect 1 message only on the end-date of Sick Leave Time Eval should NOT handle these cases

Sanky
Active Contributor
0 Kudos

Hi Anil,

You will creat the below 3PCRs for the above requirement. Here 1003 is the Sick leave, ZQSL is the time type(only day balance is 1) & SL is the information message type.

PCR-1

/ZSL

Insert this PCR just after P2001 function with fuction ACTIO.

PCR-2

/ZSC

Insert this PCR just after the 1st PCR with function ACTIO.

PCR-3

/MSG

Insert this PCR just after LIMIT function with function ACTIO.

Hope so it you give you the required result. Let me know the status.

Note:- Here i have no taken the condition that if employee is coming on day off that means clock in & clock out is there. Then we have to modify PCR 2 regarding this.

Regards, Sankarsan

Former Member
0 Kudos

Hi Sankarsan,

Thanks for your reply, but the logic is not working as required. On every Monday, Friday balance is not getting carry forward.Value is setting to 1. Please help.

Sanky
Active Contributor
0 Kudos

Hi,

In the 2nd Pcr this logic is already incorporated. I have already tested and its working.

Check once , hope so it will work.

Regards,Sankarsan

seg_hr_it
Active Contributor
0 Kudos

Hi Sankarsan & Anil,

The tricky part is how you ensure employee is ON LEAVE on SAT and SUN ? Otherwise the leave is NOT consecutive anymore (if you are expecting to validate consecutive CALENDAR DAY leave).

If you consider consecutive WORKING DAY leave, it is possible to carry value from Fri to Mon, it is possible but have to use at least 2 time types: please refer the document I mentioned earlier with below solution:

Solution: if you want to accumulate from date X to date Y (example from Mon to Sun every week), 3 steps below must be done:

     1. creating 2 Time types (ZV01 & ZV03) with all configurations are 1 in V_T555A

     2. when the date in TE is X (eg Mon) => add MZV01 into ZV03 (note: must be minus current value in ZV03).

     3. when the date in TE is Y (eg Sun) => simply assign ZV02 = DZV01 +  MZV01 - MZV03 => output is accumulate from X to Y (from Mon to Sun).

And let's try the LzzzzA, I did NOT test so not sure but the above I tested already, you can re-use for your requirements. Good luck

Sanky
Active Contributor
0 Kudos

Hi Woody,

Thanks for your valuabl we

I thought it Same way with two  types but with the help of one time type and query that VARSTFREE operation we can query the last days SICK Leave which I have incorporated in 2nd PCR.

Hi Anil,You please go with Mr.Woody's suggestion.

Regards,Sankarsan

seg_hr_it
Active Contributor
0 Kudos

I got what you mean in 2nd prc already.

On Sat & Sunday (or day OFF) you will carry the number LZQSL to current date. It's good idea indeed.

It means if employee is on leave on Thu, Fri and Mon (the same output if employee is on leave from Thu to Mon): the output of ZQSL will be as below

Thu: 1 day

Fri: 2 day

Sat: 2 days (carry from Fri)

Sun: 2 days (carry from Sat)

Mon: 3 days

I thought you might combine pcr 2 & 3 as below, it might be more simple and clearer

*

   ****

     VARSTFREE  Plnd hrs DWS = 0?

       N

         HRS=D0600  Set

         HRS?0      Decision op.     HRS

           *

           >

             HRS+L0600  Addition

             ADDDB0600Z Set day balance = 0

             HRS?10     Decision op.     HRS

               *

                 COLER00I   Information

               <

       Y

         HRS=L0600  Set

         ADDDB0600Z Set day balance = 0

You can see my testing, system raise Message (1.jpg) on 15.01.2015 (as I run Time Eval from 02.01.2015). You can see output (2.jpg), on 02 / 03 / 04 Jan, my time type 0060 is 1 day only as 02 / 03 Jan is Sat & Sun. 05 Jan increase to 2, and so on.

seg_hr_it
Active Contributor
0 Kudos

When my leave is from 02.01.2015 to 14.01.2015 and another one from 16.01.2015 to 20.01.2015

Sanky
Active Contributor
0 Kudos

Hi Anil,

Thanks for Woody's help on this.

In the 2nd PCR i have incoeporated this logic that if employee takes a leave in between thrusday to monday.

On the thrusday ,In the 1st PCR will generate the ZQSL time type and in the 2nd PCR will check with current day balance and previous day balance and will start carry forward.(Here ZQSL=1)

On the Friday , Again 1st PCR will generate the ZQSL time type and check previous day ZQSL value and adding in the current day.(Here ZQSL=2)

On the Saturday, Since is a day off then Previous day ZQSL will carry forward to current day(Here ZQSL=2) and it will same for Sunday as well as day balance(Here ZQSL=2).

On the Monday system will get again ZQSL as 1 since employee has taken Sick leave on that day also. PCR will check the current day balance of ZQSL and then previous day's cumulated value to current day balance. So it will 3.

Please go with Mr. Woody's suggestion.


Hi Woody,

I have thought it this way and designed.

Regards, Sankarsan

seg_hr_it
Active Contributor
0 Kudos

Hi all,

I have found how to check CALENDAR consecutive days already. You can use the Function ACTIO with part 2 as AB, Time Eval will process even the date is DAY OFF or not.

I believe the req is quite common, I will publish new document soon to explain how to calculate both CALENDAR or WORKING consecutive days in Time Eval. Meanwhile you can try with the above function.

Good luck.

Best Regards,

Woody

Former Member
0 Kudos

Hi Sankarsan & Woody,

Thanks for all your help and guidance.

I am finally able to get the required results

Regards,

Anil

Answers (2)

Answers (2)

jagan_gunja
Active Contributor
0 Kudos

You can do following:

1.1 Time schema:  Use following lines to read planned working times with P2000

     P2000

     IF   ZOFF

     P2000  EVER              (2nd par = EVER to read planned times irrespective of working or not)

     ENDIF

  

This ensures planned hrs pair exists in TIP - it shows off or not.

1.2   PCR ZOFF */****

           D    VARSTFREE

N              SCOND=F IF               NOT FREE; SET COND FALSE

Y              SCONF=T IF               FREE: SET COND TRUE

2. Configure time type 9100 Sick leave hrs, with cumulation

3. Time schema: checking for SL: 

3.1 Insert following lines after call to TP09 pcr,

     RTIPA  ZSK1  GEN

     ACTIO  ZSK2

3.2 PCR ZSK1  */****   Check if employee absent with SL

Assuming xx & yy are absence categories for sick leave and you want to check empl is fully absent with Sick leave

     

             D    COLOP *  VARSTP2001    Pair from IT 2001?

*   

Y          D    HRS=PNUM   HRS?S       Yes; Pair hrs same as planned hrs?

Y *

Y =       D    VARABCAT                      Yes;Yes;Absence category?

Y = *

Y = **

Y = xx   Z    GCY ZSKA                       Yes;Yes;SL; check further

Y = yy   Z    GCY ZSKA

'

3.3  PCR  ZSKA   */****     Check if continuous SL

             D     HRS=L9100   HRS?0        Empl sick yesterday?

*                   HRS+1          ADDDB9100     Yes; add to no.of days absent

=                  HRS=1          ADDDB9100Z    No;start counting SL days

3.4  PCR  ZSK2  */****       Check if SL 10d continuous

Use zz as a code to indicate SL 10d continuously

             D    HRS=D9100   HRS?10           Continuous 10d SL?

  *

  <               COLERzzI                            -Yes;issue informational message zz

You can modify the above if you do not want to count OFF days, irrespective of whether employee is on leave on that day or not.  However, in this case, the leave period may be split so that there is no record on OFF days. 

Hope this helps

former_member182377
Active Contributor
0 Kudos

Hi Anil,

if employee is applied leaves in IT2001 for consecutive days, you can do that through a PCR

Please go with operation VARABTYP which reads the absence types from IT2001, write this PCR and store the results in Time type , if continously it happens you can give time evaulation error messages using the operation COLOR E and store the error messages type in the table T555E,

Try this and let me know

Thanks

Sriram