Absence Duration Validation Based on DFF Value

 


Using below fast formula we can validate and display error message based on DFF selection.

Requirement : Employees will select absence type, Start/End dates and select relationship from DFF Value. Now based on the DFF value we need to validate and display error messages

Scenario 1: If employee selects relationship as "Spouse" then he is eligible for 3 days of leave and if he is exceeding that duration then we need to define custom messages.

Scenario 2: If employee selects relationship as "Parents" then he is eligible for 2 days of leave and if he is exceeding that duration then we need to define custom messages.

Solution:

Define a DFF with related value set in Absence Recording DFF

Use below fast formula to validate and display errors based on DFF selection

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

FORMULA NAME: ABSENCE_VALIDATION

FORMULA TYPE: Global Absence Entry Validation

DESCRIPTION: This formula validates the absence Duration based on relationship selected

Change History: Name Date Version Comments

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

Modified Version by Dinesh.N  on 18-Aug-2020

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

DEFAULT FOR IV_START_DATE IS '4712/12/31 00:00:00' (date)

DEFAULT FOR IV_END_DATE IS '4712/12/31 00:00:00' (date)

DEFAULT_DATA_VALUE for ANC_PER_ABS_ENTRS_ABSENCE_ENTRY_ID_ARR is 0

DEFAULT FOR ANC_ABS_ENTRS_ABSENCE_TYPE_ID is 0

DEFAULT FOR ANC_ABS_ENTRS_ABSENCE_STATUS_CD IS 'NA'

DEFAULT FOR ANC_ABS_TYP_NAME IS 'NA'

DEFAULT FOR PER_ASG_WORK_SCH_WORKDAY_PATTERN IS 'NA'

DEFAULT for ANC_ABS_ENTRS_ATTRIBUTE3 is 'Others'


INPUTS ARE IV_END_DATE (date), IV_START_DATE (date), IV_TOTALDURATION, IV_ATTRIBUTE_3 (text)

m = 0

n = 0




/*==============VALIDATION SECTION BEGIN 22-NOV-2019 ================*/

j = 1

l_new_duration = IV_TOTALDURATION

ln_child_count = 0

ln_rem = MOD(IV_TOTALDURATION,0.5)

IF (ln_rem <> 0)

THEN

(

VALID = 'N'

ERROR_MESSAGE = 'Leave Duration should either be Half/Full Day.Please change absence start and end dates accordingly'

RETURN VALID,ERROR_MESSAGE

)


/*============== VALIDATION SECTION END 22-NOV-2019  ================*/


l_relationship = IV_ATTRIBUTE_3

IF (  l_relationship = 'Sibling' ) THEN

(

IF (l_new_duration > 2) THEN

(

VALID = 'N'

ERROR_MESSAGE = 'XXXTEST_MSG1'

RETURN VALID,ERROR_MESSAGE

)

)

IF (  l_relationship = 'Grand_Parent' ) THEN

(

IF (l_new_duration > 2) THEN

(

VALID = 'N'

ERROR_MESSAGE = 'XXXTEST_MSG1'

RETURN VALID,ERROR_MESSAGE

)

)


IF ( l_relationship = 'Parent_In_Law' ) THEN

(

IF (l_new_duration > 2) THEN

(

VALID = 'N'

ERROR_MESSAGE = 'XXXTEST_MSG1'

RETURN VALID,ERROR_MESSAGE

)

)

IF ( l_relationship = 'Parents'  ) THEN

(

IF (l_new_duration > 7) THEN

(

VALID = 'N'

ERROR_MESSAGE = 'XXXTEST_MSG2'

RETURN VALID,ERROR_MESSAGE

)

)

IF (  l_relationship = 'Children'  ) THEN

(

IF (l_new_duration > 7) THEN

(

VALID = 'N'

ERROR_MESSAGE = 'XXXTEST_MSG2'

RETURN VALID,ERROR_MESSAGE

)

)

IF (  l_relationship = 'Spouse'  ) THEN

(

IF (l_new_duration > 7) THEN

(

VALID = 'N'

ERROR_MESSAGE = 'XXXTEST_MSG2'

RETURN VALID,ERROR_MESSAGE

)

)

valid = 'Y'

ERROR_MESSAGE = 'Leave has been submitted succesfully'

return VALID,ERROR_MESSAGE

Post a Comment

0 Comments