688: origSystemId := possibleSubordApproverIn.orig_system_id;
689: loop
690: select supervisor_id
691: into superiorId
692: from per_all_assignments_f
693: where
694: per_all_assignments_f.person_id = origSystemId and
695: per_all_assignments_f.primary_flag = 'Y' and
696: per_all_assignments_f.assignment_type in ('E','C') and
690: select supervisor_id
691: into superiorId
692: from per_all_assignments_f
693: where
694: per_all_assignments_f.person_id = origSystemId and
695: per_all_assignments_f.primary_flag = 'Y' and
696: per_all_assignments_f.assignment_type in ('E','C') and
697: per_all_assignments_f.assignment_status_type_id not in
698: (select assignment_status_type_id
691: into superiorId
692: from per_all_assignments_f
693: where
694: per_all_assignments_f.person_id = origSystemId and
695: per_all_assignments_f.primary_flag = 'Y' and
696: per_all_assignments_f.assignment_type in ('E','C') and
697: per_all_assignments_f.assignment_status_type_id not in
698: (select assignment_status_type_id
699: from per_assignment_status_types
692: from per_all_assignments_f
693: where
694: per_all_assignments_f.person_id = origSystemId and
695: per_all_assignments_f.primary_flag = 'Y' and
696: per_all_assignments_f.assignment_type in ('E','C') and
697: per_all_assignments_f.assignment_status_type_id not in
698: (select assignment_status_type_id
699: from per_assignment_status_types
700: where per_system_status = 'TERM_ASSIGN') and
693: where
694: per_all_assignments_f.person_id = origSystemId and
695: per_all_assignments_f.primary_flag = 'Y' and
696: per_all_assignments_f.assignment_type in ('E','C') and
697: per_all_assignments_f.assignment_status_type_id not in
698: (select assignment_status_type_id
699: from per_assignment_status_types
700: where per_system_status = 'TERM_ASSIGN') and
701: trunc(sysdate) between
698: (select assignment_status_type_id
699: from per_assignment_status_types
700: where per_system_status = 'TERM_ASSIGN') and
701: trunc(sysdate) between
702: per_all_assignments_f.effective_start_date and
703: per_all_assignments_f.effective_end_date;
704: if(superiorId is null) then
705: exit;
706: elsif(superiorId = approverIn.orig_system_id) then
699: from per_assignment_status_types
700: where per_system_status = 'TERM_ASSIGN') and
701: trunc(sysdate) between
702: per_all_assignments_f.effective_start_date and
703: per_all_assignments_f.effective_end_date;
704: if(superiorId is null) then
705: exit;
706: elsif(superiorId = approverIn.orig_system_id) then
707: superiorFound := true;
1461: begin
1462: if(approverIn.orig_system = ame_util.perOrigSystem) then
1463: superiorOut.orig_system := ame_util.perOrigSystem;
1464: select
1465: per_all_assignments_f.supervisor_id,
1466: wf_roles.name,
1467: wf_roles.display_name
1468: into
1469: superiorOut.orig_system_id,
1470: superiorOut.name,
1471: superiorOut.display_name
1472: from
1473: wf_roles,
1474: per_all_assignments_f
1475: where
1476: wf_roles.orig_system = ame_util.perOrigSystem and
1477: wf_roles.orig_system_id = per_all_assignments_f.supervisor_id and
1478: wf_roles.status = 'ACTIVE' and
1473: wf_roles,
1474: per_all_assignments_f
1475: where
1476: wf_roles.orig_system = ame_util.perOrigSystem and
1477: wf_roles.orig_system_id = per_all_assignments_f.supervisor_id and
1478: wf_roles.status = 'ACTIVE' and
1479: (wf_roles.expiration_date is null or sysdate < wf_roles.expiration_date) and
1480: exists (select null
1481: from fnd_user u
1487: where wf_roles.orig_system = wf2.orig_system
1488: and wf_roles.orig_system_id = wf2.orig_system_id
1489: and wf_roles.start_date > wf2.start_date
1490: ) and
1491: per_all_assignments_f.person_id =approverIn.orig_system_id and
1492: per_all_assignments_f.primary_flag = 'Y' and
1493: per_all_assignments_f.assignment_type in ('E','C') and
1494: per_all_assignments_f.assignment_status_type_id not in
1495: (select assignment_status_type_id
1488: and wf_roles.orig_system_id = wf2.orig_system_id
1489: and wf_roles.start_date > wf2.start_date
1490: ) and
1491: per_all_assignments_f.person_id =approverIn.orig_system_id and
1492: per_all_assignments_f.primary_flag = 'Y' and
1493: per_all_assignments_f.assignment_type in ('E','C') and
1494: per_all_assignments_f.assignment_status_type_id not in
1495: (select assignment_status_type_id
1496: from per_assignment_status_types
1489: and wf_roles.start_date > wf2.start_date
1490: ) and
1491: per_all_assignments_f.person_id =approverIn.orig_system_id and
1492: per_all_assignments_f.primary_flag = 'Y' and
1493: per_all_assignments_f.assignment_type in ('E','C') and
1494: per_all_assignments_f.assignment_status_type_id not in
1495: (select assignment_status_type_id
1496: from per_assignment_status_types
1497: where per_system_status = 'TERM_ASSIGN') and
1490: ) and
1491: per_all_assignments_f.person_id =approverIn.orig_system_id and
1492: per_all_assignments_f.primary_flag = 'Y' and
1493: per_all_assignments_f.assignment_type in ('E','C') and
1494: per_all_assignments_f.assignment_status_type_id not in
1495: (select assignment_status_type_id
1496: from per_assignment_status_types
1497: where per_system_status = 'TERM_ASSIGN') and
1498: trunc(sysdate) between
1495: (select assignment_status_type_id
1496: from per_assignment_status_types
1497: where per_system_status = 'TERM_ASSIGN') and
1498: trunc(sysdate) between
1499: per_all_assignments_f.effective_start_date and
1500: per_all_assignments_f.effective_end_date and
1501: rownum < 2;
1502: if(superiorOut.orig_system_id is null) then
1503: raise noSurrogateException;
1496: from per_assignment_status_types
1497: where per_system_status = 'TERM_ASSIGN') and
1498: trunc(sysdate) between
1499: per_all_assignments_f.effective_start_date and
1500: per_all_assignments_f.effective_end_date and
1501: rownum < 2;
1502: if(superiorOut.orig_system_id is null) then
1503: raise noSurrogateException;
1504: end if;
1504: end if;
1505: elsif(approverIn.orig_system = ame_util.fndUserOrigSystem) then
1506: superiorOut.orig_system := ame_util.fndUserOrigSystem;
1507: select
1508: per_all_assignments_f.supervisor_id,
1509: wf_roles.name,
1510: wf_roles.display_name
1511: into
1512: superiorOut.orig_system_id,
1513: superiorOut.name,
1514: superiorOut.display_name
1515: from
1516: wf_roles,
1517: per_all_assignments_f
1518: where
1519: wf_roles.orig_system = ame_util.perOrigSystem and
1520: wf_roles.orig_system_id = per_all_assignments_f.supervisor_id and
1521: wf_roles.status = 'ACTIVE' and
1516: wf_roles,
1517: per_all_assignments_f
1518: where
1519: wf_roles.orig_system = ame_util.perOrigSystem and
1520: wf_roles.orig_system_id = per_all_assignments_f.supervisor_id and
1521: wf_roles.status = 'ACTIVE' and
1522: (wf_roles.expiration_date is null or sysdate < wf_roles.expiration_date) and
1523: exists (select null
1524: from fnd_user u
1524: from fnd_user u
1525: where u.user_name = wf_roles.name
1526: and trunc(sysdate) between u.start_date
1527: and nvl(u.end_date,trunc(sysdate))) and
1528: per_all_assignments_f.person_id =
1529: (select employee_id
1530: from fnd_user
1531: where
1532: user_id = approverIn.orig_system_id and
1530: from fnd_user
1531: where
1532: user_id = approverIn.orig_system_id and
1533: rownum < 2) and
1534: per_all_assignments_f.primary_flag = 'Y' and
1535: per_all_assignments_f.assignment_type in ('E','C') and
1536: per_all_assignments_f.assignment_status_type_id not in
1537: (select assignment_status_type_id
1538: from per_assignment_status_types
1531: where
1532: user_id = approverIn.orig_system_id and
1533: rownum < 2) and
1534: per_all_assignments_f.primary_flag = 'Y' and
1535: per_all_assignments_f.assignment_type in ('E','C') and
1536: per_all_assignments_f.assignment_status_type_id not in
1537: (select assignment_status_type_id
1538: from per_assignment_status_types
1539: where per_system_status = 'TERM_ASSIGN') and
1532: user_id = approverIn.orig_system_id and
1533: rownum < 2) and
1534: per_all_assignments_f.primary_flag = 'Y' and
1535: per_all_assignments_f.assignment_type in ('E','C') and
1536: per_all_assignments_f.assignment_status_type_id not in
1537: (select assignment_status_type_id
1538: from per_assignment_status_types
1539: where per_system_status = 'TERM_ASSIGN') and
1540: trunc(sysdate) between
1537: (select assignment_status_type_id
1538: from per_assignment_status_types
1539: where per_system_status = 'TERM_ASSIGN') and
1540: trunc(sysdate) between
1541: per_all_assignments_f.effective_start_date and
1542: per_all_assignments_f.effective_end_date and
1543: rownum < 2
1544: order by wf_roles.name; /* Select the first matching wf_roles entry. */
1545: if(superiorOut.orig_system_id is null) then
1538: from per_assignment_status_types
1539: where per_system_status = 'TERM_ASSIGN') and
1540: trunc(sysdate) between
1541: per_all_assignments_f.effective_start_date and
1542: per_all_assignments_f.effective_end_date and
1543: rownum < 2
1544: order by wf_roles.name; /* Select the first matching wf_roles entry. */
1545: if(superiorOut.orig_system_id is null) then
1546: raise noSurrogateException;
1656: begin
1657: begin
1658: if(origSystemIn = ame_util.perOrigSystem) then
1659: select
1660: per_all_assignments_f.supervisor_id,
1661: wf_roles.name,
1662: wf_roles.display_name
1663: into
1664: origSystemIdOut,
1665: wfRolesNameOut,
1666: displayNameOut
1667: from
1668: wf_roles,
1669: per_all_assignments_f
1670: where
1671: wf_roles.orig_system = ame_util.perOrigSystem and
1672: wf_roles.orig_system_id = per_all_assignments_f.supervisor_id and
1673: wf_roles.status = 'ACTIVE' and
1668: wf_roles,
1669: per_all_assignments_f
1670: where
1671: wf_roles.orig_system = ame_util.perOrigSystem and
1672: wf_roles.orig_system_id = per_all_assignments_f.supervisor_id and
1673: wf_roles.status = 'ACTIVE' and
1674: (wf_roles.expiration_date is null or sysdate < wf_roles.expiration_date) and
1675: exists (select null
1676: from fnd_user u
1682: where wf_roles.orig_system = wf2.orig_system
1683: and wf_roles.orig_system_id = wf2.orig_system_id
1684: and wf_roles.start_date > wf2.start_date
1685: ) and
1686: per_all_assignments_f.person_id = origSystemIdIn and
1687: per_all_assignments_f.primary_flag = 'Y' and
1688: per_all_assignments_f.assignment_type in ('E','C') and
1689: per_all_assignments_f.assignment_status_type_id not in
1690: (select assignment_status_type_id
1683: and wf_roles.orig_system_id = wf2.orig_system_id
1684: and wf_roles.start_date > wf2.start_date
1685: ) and
1686: per_all_assignments_f.person_id = origSystemIdIn and
1687: per_all_assignments_f.primary_flag = 'Y' and
1688: per_all_assignments_f.assignment_type in ('E','C') and
1689: per_all_assignments_f.assignment_status_type_id not in
1690: (select assignment_status_type_id
1691: from per_assignment_status_types
1684: and wf_roles.start_date > wf2.start_date
1685: ) and
1686: per_all_assignments_f.person_id = origSystemIdIn and
1687: per_all_assignments_f.primary_flag = 'Y' and
1688: per_all_assignments_f.assignment_type in ('E','C') and
1689: per_all_assignments_f.assignment_status_type_id not in
1690: (select assignment_status_type_id
1691: from per_assignment_status_types
1692: where per_system_status = 'TERM_ASSIGN') and
1685: ) and
1686: per_all_assignments_f.person_id = origSystemIdIn and
1687: per_all_assignments_f.primary_flag = 'Y' and
1688: per_all_assignments_f.assignment_type in ('E','C') and
1689: per_all_assignments_f.assignment_status_type_id not in
1690: (select assignment_status_type_id
1691: from per_assignment_status_types
1692: where per_system_status = 'TERM_ASSIGN') and
1693: trunc(sysdate) between
1690: (select assignment_status_type_id
1691: from per_assignment_status_types
1692: where per_system_status = 'TERM_ASSIGN') and
1693: trunc(sysdate) between
1694: per_all_assignments_f.effective_start_date and
1695: per_all_assignments_f.effective_end_date and
1696: rownum < 2;
1697: if(origSystemIdOut is null) then
1698: raise noSurrogateException;
1691: from per_assignment_status_types
1692: where per_system_status = 'TERM_ASSIGN') and
1693: trunc(sysdate) between
1694: per_all_assignments_f.effective_start_date and
1695: per_all_assignments_f.effective_end_date and
1696: rownum < 2;
1697: if(origSystemIdOut is null) then
1698: raise noSurrogateException;
1699: end if;
1698: raise noSurrogateException;
1699: end if;
1700: elsif(origSystemIn = ame_util.fndUserOrigSystem) then
1701: select
1702: per_all_assignments_f.supervisor_id,
1703: wf_roles.name,
1704: wf_roles.display_name
1705: into
1706: origSystemIdOut,
1707: wfRolesNameOut,
1708: displayNameOut
1709: from
1710: wf_roles,
1711: per_all_assignments_f
1712: where
1713: wf_roles.orig_system = ame_util.perOrigSystem and
1714: wf_roles.orig_system_id = per_all_assignments_f.supervisor_id and
1715: wf_roles.status = 'ACTIVE' and
1710: wf_roles,
1711: per_all_assignments_f
1712: where
1713: wf_roles.orig_system = ame_util.perOrigSystem and
1714: wf_roles.orig_system_id = per_all_assignments_f.supervisor_id and
1715: wf_roles.status = 'ACTIVE' and
1716: exists (select null
1717: from fnd_user u
1718: where u.user_name = wf_roles.name
1718: where u.user_name = wf_roles.name
1719: and trunc(sysdate) between u.start_date
1720: and nvl(u.end_date,trunc(sysdate))) and
1721: (wf_roles.expiration_date is null or sysdate < wf_roles.expiration_date) and
1722: per_all_assignments_f.person_id =
1723: (select employee_id
1724: from fnd_user
1725: where
1726: user_id = origSystemIdIn and
1724: from fnd_user
1725: where
1726: user_id = origSystemIdIn and
1727: rownum < 2) and
1728: per_all_assignments_f.primary_flag = 'Y' and
1729: per_all_assignments_f.assignment_type in ('E','C') and
1730: per_all_assignments_f.assignment_status_type_id not in
1731: (select assignment_status_type_id
1732: from per_assignment_status_types
1725: where
1726: user_id = origSystemIdIn and
1727: rownum < 2) and
1728: per_all_assignments_f.primary_flag = 'Y' and
1729: per_all_assignments_f.assignment_type in ('E','C') and
1730: per_all_assignments_f.assignment_status_type_id not in
1731: (select assignment_status_type_id
1732: from per_assignment_status_types
1733: where per_system_status = 'TERM_ASSIGN') and
1726: user_id = origSystemIdIn and
1727: rownum < 2) and
1728: per_all_assignments_f.primary_flag = 'Y' and
1729: per_all_assignments_f.assignment_type in ('E','C') and
1730: per_all_assignments_f.assignment_status_type_id not in
1731: (select assignment_status_type_id
1732: from per_assignment_status_types
1733: where per_system_status = 'TERM_ASSIGN') and
1734: trunc(sysdate) between
1731: (select assignment_status_type_id
1732: from per_assignment_status_types
1733: where per_system_status = 'TERM_ASSIGN') and
1734: trunc(sysdate) between
1735: per_all_assignments_f.effective_start_date and
1736: per_all_assignments_f.effective_end_date and
1737: rownum < 2
1738: order by wf_roles.name; /* Select the first matching wf_roles entry. */
1739: if(origSystemIdOut is null) then
1732: from per_assignment_status_types
1733: where per_system_status = 'TERM_ASSIGN') and
1734: trunc(sysdate) between
1735: per_all_assignments_f.effective_start_date and
1736: per_all_assignments_f.effective_end_date and
1737: rownum < 2
1738: order by wf_roles.name; /* Select the first matching wf_roles entry. */
1739: if(origSystemIdOut is null) then
1740: raise noSurrogateException;
1999: from
2000: per_all_people_f pap
2001: ,hr_all_organization_units haou
2002: ,wf_roles wfr
2003: ,per_all_assignments_f pas
2004: where pap.person_id = pas.person_id
2005: and pas.primary_flag = 'Y'
2006: and pas.assignment_type in ('E','C')
2007: and pas.assignment_status_type_id not in