cancel
Showing results for 
Search instead for 
Did you mean: 

Leap year

Former Member
0 Kudos

Hi Experts,

Could you please help me write a rule for identifying a leap year?

I could find some details in google that a leap year is evenly divisible by 4, 100 and 400 if not then it is not a leap year.

How to identify via a PCR that a number is evenly divisible. Is there a way?

Rgds,

Arun

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

2 points:

- you should doubke check your logic. This one doesn't make sense (every number divisible by 400 is automatically divisible by 4 and 100 - if your logic was right, the last condition alone would be enough and we had leap years once every 400 years only

- it would probably help, if you share the full business requirement, as it may well be yo don't need to implement such a generic algorithm to achieve your purpose

Kind regards

Sven

Former Member
0 Kudos

Hi Sven,

True. Please see below the requirement;

The entitlement for the quota varies based on seniority. The table is as follows:

Years of Service           Entitlement

0 to 5 yrs                      15 days/yr

6 to 9 yrs                      17 days/yr and so on.....

The seniority date is stored in IT0041 (please note that this date is different from hire date).

I tried setting up table T559L but the function QUOTA does not identify the base period correctly i.e. say for an employee;

Hire date in SAP - 26.08.2015

Seniority date - 05.09.2013 (Seniority date < Hire date)

The QUOTA function creates the first base period as 05.09.2014 to 04.09.2015 and based on the end date of this base period, it calculates the years of service i.e. as per this base period end date of 04.09.2015, the 5 year completion happens on 04.09.2019 but ideally the 5 year completion should happen on 04.09.2018 as the service date is 05.09.2013.

Based on your experience could you please let me know where could have I gone wrong, as I have checked all the possible fields in selection rule (accrual period tab) and base entitlement nodes in T559L.

Now I understand that I do not require a rule to identify a leap year rather if I can pass the right day balance to the QUOTA function, it would take care of the leap year. However, since the seniority calculation is happening incorrectly, could you please help me identify the root cause?

Thanks Jagan for your inputs.

Rgds,

Arun

jagan_gunja
Active Contributor
0 Kudos

In V_T559L - Quota entitlement, you can use seq.no's for different no.of years of service.

Or use a time type for entitlement and a date type for hire date.  In a pcr, you can get the no.of years worked and accordingly add the entl hrs per accr  period to the time type.

Sanky
Active Contributor
0 Kudos

Hi,

You can get the output based upon the hiring date which you will maintain in IT41. In the quota base entitlement you will maintain day time type and select the accrual period.

In the constant table maintain two constant as 15 & 17.

Now your pcr will structure like below

ZTST

*

  ****

        HRS=YDAADJ

        HRS?1

            <

                LEAVE

            =

                HRS=CZQUOT

                ADDDB1000Z

            >

                HRS?2

                     <

                        LEAVE

                     =

                        HRS=CZQUOT

                        ADDDB1000Z

Continue this pcr in the same way.

Here 1000 is the day type which is using in the quota base entitlement. ZQUOT is the constant of 15 in the constant table. & DJ is the date of joining date type in IT41.

Use this PCR with ACTIO function before CUMBT function.

Check and let me know.

*** Now your previous query is not matching with scenario.

Regards, Sankarsan

Former Member
0 Kudos

Hi Sankaran,

Before I go ahead with writing rule, I would like to share my configuration in the table T559L.

Please let me know whether this is correct for the business scenario mentioned earlier as the quota entitlement is not increasing on the correct date (See my previous update for the scenario):

Please see below the Annual leave quota accrual PCR that I created for test purpose:

This rule has been placed before the CUMBT function and this is followed by the QUOTA function.

Please advise.

Thank you.

Warm Rgds,

Arun.M

Former Member
0 Kudos

Please find below the annual quota accrual rule:

Rgds,

Arun

Sanky
Active Contributor
0 Kudos

Hi Arun,

1st Check equal to 1 year then more than 1 year and Less than equal to 5years and then more than 5years.

Remove the relevant date type from base entitlement. Check and let me know.

Regards, Sankarsan

Former Member
0 Kudos

Hi All,

The issue is resolved.

Thank you.

Warm Rgds,

Arun

Answers (3)

Answers (3)

Sanky
Active Contributor
0 Kudos

Hi Arun,

Based upon the Leap Year would you like to give any benefit to the employee after completion of the year.

Please share your business scenario then could be possible give some alternative solutions.

Regards, Sankarsan

jagan_gunja
Active Contributor
0 Kudos

Hi every one

As Sven pointed out, the leap year rules which Arun provided is not correct.  I did not look at the veracity of the rules  when I posted a solution earlier.  The rule is:

In the Gregorian calendar 3 criteria must be taken into account to identify leap years:

  • The year is evenly divisible by 4;
  • If the year can be evenly divided by 100, it is NOT a leap year, unless;
    • The year is also evenly divisible by 400. Then it is a leap year.

See links below

1. Leap Year nearly every 4 years

2. https://en.wikipedia.org/wiki/Leap_year

    - This is not correct I think.

3. When is a leap year not a leap year? | Science | The Guardian

4. When is Leap Year? When is the next Leap Day?

5. Leap Year -- from Eric Weisstein's World of Astronomy

6. Leap Year Rules


regards, JG

jagan_gunja
Active Contributor
0 Kudos

Hi Arun

PCR's are like program routines or data flow diagrams with calculations.

Flow will be as below:

[Set Leap Year Flag = NO]

            I

            v

[Get year part of the date]

            I

            v                            

<Year divided year by 4 has a remainder?>  -> Exit

                        I  No                                 Yes

                        v

<Year divided year by 100 has a remainder?>  -> Exit

                        I  No                                    Yes

                        v

<Year divided year by 400 has a remainder?>  -> Exit

                        I  No                                    Yes

                        v

[Set Leap Year Flag = Yes]

Corresponding PCR will need an operation to obtain the year part of a date.  DATES is an operation to manipulate dates.  If this is not suitable you can adapt the operation to suit your requirements.  After getting the year in the NUM (or HRS for a time eval PCR), following will do to find the leap year.

Note here, I have no used any NEXTR.  This is just to show the calculation and logic

                 SCOND=F IF          Set leap year lag to NO

                 ZERO=&YEAR       Clear year variable

                 AMT=1                  Set amt = 1

                 ADDWT&YEAR      Add current w/t to year var

                 NUM$4                  Integral division of year (in NUM filed) by 4

                 NUM*4                   Multiply by 4 to get back original value (if it is divisible)

           D    NUM? &YEAR        Result same as before?  (to check for remainder in division)       

*

=         D    NUM$100   NUM*100  NUM? &YEAR       -No;Remainder after division by 100?

= *

= =      D    NUM$400   NUM*400  NUM? &YEAR       - -No;Remainder after division by 400?

= = *

= = =         SCOND=T IF             Set leap year flag to yes

In Time eval, you can do similarly using time types instead of variable and operation ADDDB instead of ADDWT.   ADDDBxxxxZ sets time type to zero.

Hope this helps.

TAKE A BREAK, IF YOU NEED!  THINK!!  YOU WILL FIND A SOLUTION!!!

br, JG

Message was edited by: Jagan Gunja

Former Member
0 Kudos

HI Jagan,


Thank you very much for your time And for a detailed explanation.

I Will check this and come back.

Rgds,

Arun