Sunday 16 April 2017

Absence Entry Validation Fast Formula Dependents on Another Leave's Accrual Balance


Requirement :
     Employee is allowed to apply for unpaid leave only when his/her Annual leave balance is 0(Zero).


STEP 1:
      Create Fast Formula as Mentioned Below 

--------------------------------------------------------------------------------------------------------------------
NAME                           : XX_GET_PLAN_BALANCE
TYPE                             : Global Absence Accrual
: Choose Your Legislation 


Formula Text : 

/*************  Retrieve the accrual balance in the formula *********************/

INPUTS ARE IV_PERSON_ID,IV_TERM_ID,IV_EFF_DT (DATE)

DEFAULT FOR IV_PERSON_ID IS 0
DEFAULT FOR IV_TERM_ID IS 0
DEFAULT FOR IV_EFF_DT IS '2014/01/01' (DATE)

L_Leave_Balance = 0
L_Accrual_Plan_ID = 300000001679015 /* Accrual Plan ID */
L_Term_Id = IV_TERM_ID
L_Person_Id = IV_PERSON_ID
L_Eff_Dt = IV_EFF_DT

CHANGE_CONTEXTS(ACCRUAL_PLAN_ID = L_Accrual_Plan_ID,
HR_ASSIGNMENT_ID = L_Term_Id,
PERSON_ID = L_Person_Id,
EFFECTIVE_DATE =L_Eff_Dt )

(
  L_Leave_Balance = GET_ACCRUAL_BALANCE()
)

return L_Leave_Balance 

/****************************************************************************/

---------------------------------------------------------------------------------------------------------------------





STEP 2:
    Create Fast Formula as Mentioned Below 

---------------------------------------------------------------------------------------------------------------------
NAME                           : XX_VALIDATION_FF
TYPE                             : Global Absence Entry Validation
  : Choose Your Legislation 

Formula Text : 
/********************validation formula***********************/

INPUTS ARE IV_START_DATE(DATE),iv_end_date (date)

DEFAULT FOR IV_START_DATE IS '2014/01/01' (DATE)
DEFAULT FOR IV_END_DATE IS '4712/01/01' (DATE)

L_Acrl_Balance = 0
L_Person_Id = GET_CONTEXT(PERSON_ID,0)
L_Term_Id = GET_CONTEXT(HR_TERM_ID,0)
L_Eff_Dt = IV_START_DATE
L_occurence = 0

SET_INPUT('IV_PERSON_ID', L_Person_Id)
SET_INPUT('IV_TERM_ID', L_Term_Id)e
SET_INPUT('IV_EFF_DT', L_Eff_Dt)

EXECUTE('
XX_GET_PLAN_BALANCE')

L_Acrl_Balance = GET_OUTPUT('L_Leave_Balance', 0)

IF (L_Acrl_Balance < 1) THEN
(
VALID = 'Y'
)
ELSE
(
VALID = 'N'
ERROR_MESSAGE = 'ERROR -  Current Leave Balance: '+to_text(L_Acrl_Balance)+'  You can take this type of leave only when your annual leave balance is 0(Zero) '
)

return VALID, ERROR_MESSAGE


/****************************************************************************/
---------------------------------------------------------------------------------------------------------------------



STEP 3:
     Attach Validation formula at Absence Type. 
---------------------------------------------------------------------------------------------------------------------
Absence Type > Select 'Validation Formula' 

i.e. 
As per the current requirement 

Go to UNPAID leave > Select 'XX_VALIDATION_FF' formula as validation formula.

Navigation : Absence Administration > Absence Type > Search UNPAID Leave

 NOTE:-  Make sure Absence Type and Formulas must be fall under same Legislation.

---------------------------------------------------------------------------------------------------------------------

20 comments:

  1. GREAT WORK!!! GREAT ARTICLE, really helped and i was able to do validation on my absence, just a couple of things to work on in my scenario is a bit different.

    I need to check the total number of days from previously applied leaves + balance + currently applied leave to be less than eligible days to get from Accrual Matrix. So yeah, a little difference but surely gave me a good hint on how to work it out..THANKS A TON

    ReplyDelete
  2. Hi Jigar,

    Can you please let me know how can you get the absence plan ID ?

    ReplyDelete
    Replies
    1. Hi,

      You can get it from OTBI. You need to write down query for the same.

      Table : ANC_ABSENCE_PLANS_F

      Delete
  3. Dear Jigar
    When I tried to compile it, system showed me an error on line 16 (SET_INPUT('IV_EFF_DT', L_Eff_Dt)
    from second step. Do you know how I can fix it?
    Thanks!

    ReplyDelete
  4. Dear Jigar, line 16 is EXECUTE('XX_GET_PLAN_BALANCE'), sorry. Thanks again.

    ReplyDelete
  5. Dear Jigar, could you send both FF (get plan balance and Validation) via email. I need a complete and compiled one asap.

    Thanks a lot, Matias.

    ReplyDelete
    Replies
    1. Hi Matias,

      I am not sure how to get your email.

      Delete
  6. Hi Team ,

    We have one requirement, Actually we have configured our absence management system as an incremental basis, but here we want to allow the employee to apply the leave in future dates, but we don't want to allow the employee to apply the leave more than sysdate balance amount.

    For Ex: If Employee "A" has the sick leave plan and leave balance is added into his account as a incremental basis .

    every month 1 day is added into his account , mean 31/dec he will get 12 days as a balance.

    In the month of Feb employee will 2 days balance .in the month of june we will have 6 days balance .

    if employee apply the leave in the month of Feb with future dates like june 10th to some other date in June , here we want allow the employee to apply 2 days only not 6 days , because as for the sysdate( Feb Month) employee have only 2 days .

    ReplyDelete
    Replies
    1. Hi Raghav,

      Is it resolved ?? you can contact me on jigarm0312@gmail.com in case if you need any help.

      Delete
  7. Hi,
    We have a requirement where employee can apply 13 days in a month but not more than 60 days in year
    Can anyone please help with this requirement

    ReplyDelete
    Replies
    1. Hi Raghav,

      Is it resolved ?? you can contact me on jigarm0312@gmail.com in case if you need any help.

      Delete
  8. Hi Jigar,

    I was trying to Execute same Fast Formula for my absence, but I am getting accural Balance as Zero.
    Not sure, what is the root cause..If you want, i can share my details to your email ID

    ReplyDelete
    Replies
    1. Hi Vishwa

      You may be utilizing incorrect plan id.
      Can you send me your formulas on my email so i can help you

      Delete
  9. Hi,
    Thanks for sharing, it was informative. We play a small role in upskilling people providing the latest tech courses. Join us to upgradeAPIGEE ONLINE TRAINING

    ReplyDelete
  10. Hi Jigar,

    I was trying to Execute same Fast Formula for my absence, but I am getting accrual Balance as Zero.
    Not sure, what is the issue. Please help.

    ReplyDelete
    Replies
    1. Hi Sorry for delay

      Are you still facing issue ??
      please mail me your fast formula - jigarm0312@gmail.com

      Delete