649: origSystemId := possibleSubordApproverIn.orig_system_id;
650: loop
651: select supervisor_id
652: into superiorId
653: from per_all_assignments_f
654: where
655: per_all_assignments_f.person_id = origSystemId and
656: per_all_assignments_f.primary_flag = 'Y' and
657: per_all_assignments_f.assignment_type in ('E','C') and
651: select supervisor_id
652: into superiorId
653: from per_all_assignments_f
654: where
655: per_all_assignments_f.person_id = origSystemId and
656: per_all_assignments_f.primary_flag = 'Y' and
657: per_all_assignments_f.assignment_type in ('E','C') and
658: per_all_assignments_f.assignment_status_type_id not in
659: (select assignment_status_type_id
652: into superiorId
653: from per_all_assignments_f
654: where
655: per_all_assignments_f.person_id = origSystemId and
656: per_all_assignments_f.primary_flag = 'Y' and
657: per_all_assignments_f.assignment_type in ('E','C') and
658: per_all_assignments_f.assignment_status_type_id not in
659: (select assignment_status_type_id
660: from per_assignment_status_types
653: from per_all_assignments_f
654: where
655: per_all_assignments_f.person_id = origSystemId and
656: per_all_assignments_f.primary_flag = 'Y' and
657: per_all_assignments_f.assignment_type in ('E','C') and
658: per_all_assignments_f.assignment_status_type_id not in
659: (select assignment_status_type_id
660: from per_assignment_status_types
661: where per_system_status = 'TERM_ASSIGN') and
654: where
655: per_all_assignments_f.person_id = origSystemId and
656: per_all_assignments_f.primary_flag = 'Y' and
657: per_all_assignments_f.assignment_type in ('E','C') and
658: per_all_assignments_f.assignment_status_type_id not in
659: (select assignment_status_type_id
660: from per_assignment_status_types
661: where per_system_status = 'TERM_ASSIGN') and
662: trunc(sysdate) between
659: (select assignment_status_type_id
660: from per_assignment_status_types
661: where per_system_status = 'TERM_ASSIGN') and
662: trunc(sysdate) between
663: per_all_assignments_f.effective_start_date and
664: per_all_assignments_f.effective_end_date;
665: if(superiorId is null) then
666: exit;
667: elsif(superiorId = approverIn.orig_system_id) then
660: from per_assignment_status_types
661: where per_system_status = 'TERM_ASSIGN') and
662: trunc(sysdate) between
663: per_all_assignments_f.effective_start_date and
664: per_all_assignments_f.effective_end_date;
665: if(superiorId is null) then
666: exit;
667: elsif(superiorId = approverIn.orig_system_id) then
668: superiorFound := true;
1417: begin
1418: if(approverIn.orig_system = ame_util.perOrigSystem) then
1419: superiorOut.orig_system := ame_util.perOrigSystem;
1420: select
1421: per_all_assignments_f.supervisor_id,
1422: wf_roles.name,
1423: wf_roles.display_name
1424: into
1425: superiorOut.orig_system_id,
1426: superiorOut.name,
1427: superiorOut.display_name
1428: from
1429: wf_roles,
1430: per_all_assignments_f
1431: where
1432: wf_roles.orig_system = ame_util.perOrigSystem and
1433: wf_roles.orig_system_id = per_all_assignments_f.supervisor_id and
1434: wf_roles.status = 'ACTIVE' and
1429: wf_roles,
1430: per_all_assignments_f
1431: where
1432: wf_roles.orig_system = ame_util.perOrigSystem and
1433: wf_roles.orig_system_id = per_all_assignments_f.supervisor_id and
1434: wf_roles.status = 'ACTIVE' and
1435: (wf_roles.expiration_date is null or sysdate < wf_roles.expiration_date) and
1436: exists (select null
1437: from fnd_user u
1443: where wf_roles.orig_system = wf2.orig_system
1444: and wf_roles.orig_system_id = wf2.orig_system_id
1445: and wf_roles.start_date > wf2.start_date
1446: ) and
1447: per_all_assignments_f.person_id =approverIn.orig_system_id and
1448: per_all_assignments_f.primary_flag = 'Y' and
1449: per_all_assignments_f.assignment_type in ('E','C') and
1450: per_all_assignments_f.assignment_status_type_id not in
1451: (select assignment_status_type_id
1444: and wf_roles.orig_system_id = wf2.orig_system_id
1445: and wf_roles.start_date > wf2.start_date
1446: ) and
1447: per_all_assignments_f.person_id =approverIn.orig_system_id and
1448: per_all_assignments_f.primary_flag = 'Y' and
1449: per_all_assignments_f.assignment_type in ('E','C') and
1450: per_all_assignments_f.assignment_status_type_id not in
1451: (select assignment_status_type_id
1452: from per_assignment_status_types
1445: and wf_roles.start_date > wf2.start_date
1446: ) and
1447: per_all_assignments_f.person_id =approverIn.orig_system_id and
1448: per_all_assignments_f.primary_flag = 'Y' and
1449: per_all_assignments_f.assignment_type in ('E','C') and
1450: per_all_assignments_f.assignment_status_type_id not in
1451: (select assignment_status_type_id
1452: from per_assignment_status_types
1453: where per_system_status = 'TERM_ASSIGN') and
1446: ) and
1447: per_all_assignments_f.person_id =approverIn.orig_system_id and
1448: per_all_assignments_f.primary_flag = 'Y' and
1449: per_all_assignments_f.assignment_type in ('E','C') and
1450: per_all_assignments_f.assignment_status_type_id not in
1451: (select assignment_status_type_id
1452: from per_assignment_status_types
1453: where per_system_status = 'TERM_ASSIGN') and
1454: trunc(sysdate) between
1451: (select assignment_status_type_id
1452: from per_assignment_status_types
1453: where per_system_status = 'TERM_ASSIGN') and
1454: trunc(sysdate) between
1455: per_all_assignments_f.effective_start_date and
1456: per_all_assignments_f.effective_end_date and
1457: rownum < 2;
1458: if(superiorOut.orig_system_id is null) then
1459: raise noSurrogateException;
1452: from per_assignment_status_types
1453: where per_system_status = 'TERM_ASSIGN') and
1454: trunc(sysdate) between
1455: per_all_assignments_f.effective_start_date and
1456: per_all_assignments_f.effective_end_date and
1457: rownum < 2;
1458: if(superiorOut.orig_system_id is null) then
1459: raise noSurrogateException;
1460: end if;
1460: end if;
1461: elsif(approverIn.orig_system = ame_util.fndUserOrigSystem) then
1462: superiorOut.orig_system := ame_util.fndUserOrigSystem;
1463: select
1464: per_all_assignments_f.supervisor_id,
1465: wf_roles.name,
1466: wf_roles.display_name
1467: into
1468: superiorOut.orig_system_id,
1469: superiorOut.name,
1470: superiorOut.display_name
1471: from
1472: wf_roles,
1473: per_all_assignments_f
1474: where
1475: wf_roles.orig_system = ame_util.perOrigSystem and
1476: wf_roles.orig_system_id = per_all_assignments_f.supervisor_id and
1477: wf_roles.status = 'ACTIVE' and
1472: wf_roles,
1473: per_all_assignments_f
1474: where
1475: wf_roles.orig_system = ame_util.perOrigSystem and
1476: wf_roles.orig_system_id = per_all_assignments_f.supervisor_id and
1477: wf_roles.status = 'ACTIVE' and
1478: (wf_roles.expiration_date is null or sysdate < wf_roles.expiration_date) and
1479: exists (select null
1480: from fnd_user u
1480: from fnd_user u
1481: where u.user_name = wf_roles.name
1482: and trunc(sysdate) between u.start_date
1483: and nvl(u.end_date,trunc(sysdate))) and
1484: per_all_assignments_f.person_id =
1485: (select employee_id
1486: from fnd_user
1487: where
1488: user_id = approverIn.orig_system_id and
1486: from fnd_user
1487: where
1488: user_id = approverIn.orig_system_id and
1489: rownum < 2) and
1490: per_all_assignments_f.primary_flag = 'Y' and
1491: per_all_assignments_f.assignment_type in ('E','C') and
1492: per_all_assignments_f.assignment_status_type_id not in
1493: (select assignment_status_type_id
1494: from per_assignment_status_types
1487: where
1488: user_id = approverIn.orig_system_id and
1489: rownum < 2) and
1490: per_all_assignments_f.primary_flag = 'Y' and
1491: per_all_assignments_f.assignment_type in ('E','C') and
1492: per_all_assignments_f.assignment_status_type_id not in
1493: (select assignment_status_type_id
1494: from per_assignment_status_types
1495: where per_system_status = 'TERM_ASSIGN') and
1488: user_id = approverIn.orig_system_id and
1489: rownum < 2) and
1490: per_all_assignments_f.primary_flag = 'Y' and
1491: per_all_assignments_f.assignment_type in ('E','C') and
1492: per_all_assignments_f.assignment_status_type_id not in
1493: (select assignment_status_type_id
1494: from per_assignment_status_types
1495: where per_system_status = 'TERM_ASSIGN') and
1496: trunc(sysdate) between
1493: (select assignment_status_type_id
1494: from per_assignment_status_types
1495: where per_system_status = 'TERM_ASSIGN') and
1496: trunc(sysdate) between
1497: per_all_assignments_f.effective_start_date and
1498: per_all_assignments_f.effective_end_date and
1499: rownum < 2
1500: order by wf_roles.name; /* Select the first matching wf_roles entry. */
1501: if(superiorOut.orig_system_id is null) then
1494: from per_assignment_status_types
1495: where per_system_status = 'TERM_ASSIGN') and
1496: trunc(sysdate) between
1497: per_all_assignments_f.effective_start_date and
1498: per_all_assignments_f.effective_end_date and
1499: rownum < 2
1500: order by wf_roles.name; /* Select the first matching wf_roles entry. */
1501: if(superiorOut.orig_system_id is null) then
1502: raise noSurrogateException;
1612: begin
1613: begin
1614: if(origSystemIn = ame_util.perOrigSystem) then
1615: select
1616: per_all_assignments_f.supervisor_id,
1617: wf_roles.name,
1618: wf_roles.display_name
1619: into
1620: origSystemIdOut,
1621: wfRolesNameOut,
1622: displayNameOut
1623: from
1624: wf_roles,
1625: per_all_assignments_f
1626: where
1627: wf_roles.orig_system = ame_util.perOrigSystem and
1628: wf_roles.orig_system_id = per_all_assignments_f.supervisor_id and
1629: wf_roles.status = 'ACTIVE' and
1624: wf_roles,
1625: per_all_assignments_f
1626: where
1627: wf_roles.orig_system = ame_util.perOrigSystem and
1628: wf_roles.orig_system_id = per_all_assignments_f.supervisor_id and
1629: wf_roles.status = 'ACTIVE' and
1630: (wf_roles.expiration_date is null or sysdate < wf_roles.expiration_date) and
1631: exists (select null
1632: from fnd_user u
1638: where wf_roles.orig_system = wf2.orig_system
1639: and wf_roles.orig_system_id = wf2.orig_system_id
1640: and wf_roles.start_date > wf2.start_date
1641: ) and
1642: per_all_assignments_f.person_id = origSystemIdIn and
1643: per_all_assignments_f.primary_flag = 'Y' and
1644: per_all_assignments_f.assignment_type in ('E','C') and
1645: per_all_assignments_f.assignment_status_type_id not in
1646: (select assignment_status_type_id
1639: and wf_roles.orig_system_id = wf2.orig_system_id
1640: and wf_roles.start_date > wf2.start_date
1641: ) and
1642: per_all_assignments_f.person_id = origSystemIdIn and
1643: per_all_assignments_f.primary_flag = 'Y' and
1644: per_all_assignments_f.assignment_type in ('E','C') and
1645: per_all_assignments_f.assignment_status_type_id not in
1646: (select assignment_status_type_id
1647: from per_assignment_status_types
1640: and wf_roles.start_date > wf2.start_date
1641: ) and
1642: per_all_assignments_f.person_id = origSystemIdIn and
1643: per_all_assignments_f.primary_flag = 'Y' and
1644: per_all_assignments_f.assignment_type in ('E','C') and
1645: per_all_assignments_f.assignment_status_type_id not in
1646: (select assignment_status_type_id
1647: from per_assignment_status_types
1648: where per_system_status = 'TERM_ASSIGN') and
1641: ) and
1642: per_all_assignments_f.person_id = origSystemIdIn and
1643: per_all_assignments_f.primary_flag = 'Y' and
1644: per_all_assignments_f.assignment_type in ('E','C') and
1645: per_all_assignments_f.assignment_status_type_id not in
1646: (select assignment_status_type_id
1647: from per_assignment_status_types
1648: where per_system_status = 'TERM_ASSIGN') and
1649: trunc(sysdate) between
1646: (select assignment_status_type_id
1647: from per_assignment_status_types
1648: where per_system_status = 'TERM_ASSIGN') and
1649: trunc(sysdate) between
1650: per_all_assignments_f.effective_start_date and
1651: per_all_assignments_f.effective_end_date and
1652: rownum < 2;
1653: if(origSystemIdOut is null) then
1654: raise noSurrogateException;
1647: from per_assignment_status_types
1648: where per_system_status = 'TERM_ASSIGN') and
1649: trunc(sysdate) between
1650: per_all_assignments_f.effective_start_date and
1651: per_all_assignments_f.effective_end_date and
1652: rownum < 2;
1653: if(origSystemIdOut is null) then
1654: raise noSurrogateException;
1655: end if;
1654: raise noSurrogateException;
1655: end if;
1656: elsif(origSystemIn = ame_util.fndUserOrigSystem) then
1657: select
1658: per_all_assignments_f.supervisor_id,
1659: wf_roles.name,
1660: wf_roles.display_name
1661: into
1662: origSystemIdOut,
1663: wfRolesNameOut,
1664: displayNameOut
1665: from
1666: wf_roles,
1667: per_all_assignments_f
1668: where
1669: wf_roles.orig_system = ame_util.perOrigSystem and
1670: wf_roles.orig_system_id = per_all_assignments_f.supervisor_id and
1671: wf_roles.status = 'ACTIVE' and
1666: wf_roles,
1667: per_all_assignments_f
1668: where
1669: wf_roles.orig_system = ame_util.perOrigSystem and
1670: wf_roles.orig_system_id = per_all_assignments_f.supervisor_id and
1671: wf_roles.status = 'ACTIVE' and
1672: exists (select null
1673: from fnd_user u
1674: where u.user_name = wf_roles.name
1674: where u.user_name = wf_roles.name
1675: and trunc(sysdate) between u.start_date
1676: and nvl(u.end_date,trunc(sysdate))) and
1677: (wf_roles.expiration_date is null or sysdate < wf_roles.expiration_date) and
1678: per_all_assignments_f.person_id =
1679: (select employee_id
1680: from fnd_user
1681: where
1682: user_id = origSystemIdIn and
1680: from fnd_user
1681: where
1682: user_id = origSystemIdIn and
1683: rownum < 2) and
1684: per_all_assignments_f.primary_flag = 'Y' and
1685: per_all_assignments_f.assignment_type in ('E','C') and
1686: per_all_assignments_f.assignment_status_type_id not in
1687: (select assignment_status_type_id
1688: from per_assignment_status_types
1681: where
1682: user_id = origSystemIdIn and
1683: rownum < 2) and
1684: per_all_assignments_f.primary_flag = 'Y' and
1685: per_all_assignments_f.assignment_type in ('E','C') and
1686: per_all_assignments_f.assignment_status_type_id not in
1687: (select assignment_status_type_id
1688: from per_assignment_status_types
1689: where per_system_status = 'TERM_ASSIGN') and
1682: user_id = origSystemIdIn and
1683: rownum < 2) and
1684: per_all_assignments_f.primary_flag = 'Y' and
1685: per_all_assignments_f.assignment_type in ('E','C') and
1686: per_all_assignments_f.assignment_status_type_id not in
1687: (select assignment_status_type_id
1688: from per_assignment_status_types
1689: where per_system_status = 'TERM_ASSIGN') and
1690: trunc(sysdate) between
1687: (select assignment_status_type_id
1688: from per_assignment_status_types
1689: where per_system_status = 'TERM_ASSIGN') and
1690: trunc(sysdate) between
1691: per_all_assignments_f.effective_start_date and
1692: per_all_assignments_f.effective_end_date and
1693: rownum < 2
1694: order by wf_roles.name; /* Select the first matching wf_roles entry. */
1695: if(origSystemIdOut is null) then
1688: from per_assignment_status_types
1689: where per_system_status = 'TERM_ASSIGN') and
1690: trunc(sysdate) between
1691: per_all_assignments_f.effective_start_date and
1692: per_all_assignments_f.effective_end_date and
1693: rownum < 2
1694: order by wf_roles.name; /* Select the first matching wf_roles entry. */
1695: if(origSystemIdOut is null) then
1696: raise noSurrogateException;
1950: from
1951: per_all_people_f pap
1952: ,hr_all_organization_units haou
1953: ,wf_roles wfr
1954: ,per_all_assignments_f pas
1955: where pap.person_id = pas.person_id
1956: and pas.primary_flag = 'Y'
1957: and pas.assignment_type in ('E','C')
1958: and pas.assignment_status_type_id not in