FUNCTION TYR_GET_HR_ROLE(p_transaction_id IN NUMBER, P_ROLE_NAME IN VARCHAR2
)
---case when supervisor is in the role of approver users in the next level, then skip the role approval, as already the supervisor approved it.
RETURN VARCHAR2
AS
L_person_id NUMBER(10);
L_selected_person_id hr_api_transactions.selected_person_id%TYPE;
L_creator_person_id hr_api_transactions.creator_person_id%TYPE;
l_business_group_id NUMBER;
BEGIN
fnd_profile.get ('PER_BUSINESS_GROUP_ID', l_business_group_id);
BEGIN
SELECT selected_person_id,creator_person_id
INTO L_selected_person_id,L_creator_person_id
FROM hr_api_transactions
WHERE transaction_id = p_transaction_id;
EXCEPTION
WHEN OTHERS THEN
RETURN NULL;
END;
BEGIN
select ppf.PERSON_ID
INTO l_person_id
from pqh_roles PR, per_people_extra_info pei, per_all_people_f ppf, fnd_user usr
where pei.PEI_INFORMATION3 = to_char(pr.role_id)
and ppf.person_id = pei.PERSON_ID
and usr.EMPLOYEE_ID = ppf.PERSON_ID
and sysdate between ppf.EFFECTIVE_START_DATE and ppf.EFFECTIVE_END_DATE
and pr.role_name= P_ROLE_NAME
and pei.INFORMATION_TYPE='PQH_ROLE_USERS'
and ppf.PERSON_ID <> (SELECT selected_person_id FROM hr_api_transactions WHERE transaction_id = p_transaction_id)
and ppf.PERSON_ID <> (SELECT nvl(paaf.supervisor_id,0) FROM per_all_assignments_f paaf
WHERE paaf.person_id=(SELECT selected_person_id FROM hr_api_transactions WHERE transaction_id = p_transaction_id)
AND TRUNC(SYSDATE) BETWEEN paaf.effective_start_date AND paaf.effective_end_date
AND PRIMARY_FLAG = 'Y');
EXCEPTION
WHEN NO_DATA_FOUND THEN
l_person_id :=null;
END;
IF (L_selected_person_id = L_person_id) OR (l_creator_person_id = l_person_id) THEN
RETURN NULL;
ELSE
RETURN 'PER:'||to_char(L_person_id);
END IF;
EXCEPTION
WHEN OTHERS THEN
RETURN NULL;
END TYR_GET_HR_ROLE;
No comments:
Post a Comment