1 PACKAGE BODY BEN_CHECK_ORGANIZATION AS
2 /* $Header: bechkorg.pkb 120.1 2011/02/02 14:23:51 krupani ship $ */
3
4 cursor chk_org_role_upd(p_organization_id in number, p_date_from in date , p_date_to in date) is
5 select '1' from ben_popl_org_f
6 where organization_id = p_organization_id
7 and ( p_date_from > effective_start_date
8 or nvl(p_date_to, effective_end_date) < effective_end_date);
9
10 cursor chk_org_role_del(p_organization_id in number) is
11 select '1' from ben_popl_org_f
12 where organization_id = p_organization_id;
13
14 cursor chk_org_bnf_upd(p_organization_id in number, p_date_from in date, p_date_to in date) is
15 select '1' from ben_pl_bnf_f
16 where organization_id = p_organization_id
17 and ( p_date_from > effective_start_date
18 or nvl(p_date_to, effective_end_date) < effective_end_date);
19
20 cursor chk_org_bnf_del(p_organization_id in number) is
21 select '1' from ben_pl_bnf_f
22 where organization_id = p_organization_id;
23
24 l_data_exists varchar2(2);
25 l_status varchar2(1);
26 l_industry varchar2(1);
27
28 procedure chk_org_role_bnf_upd
29 (
30 p_organization_id IN hr_all_organization_units.organization_id%TYPE
31 ,p_date_from IN date
32 ,p_date_to IN date
33 )
34 is
35 Begin
36 hr_utility.set_location('Entering BEN_CHECK_ORGANIZATION.chk_org_role_bnf_upd ',11);
37
38 hr_utility.set_location('p_date_from '||p_date_from ,11);
39 hr_utility.set_location('p_date_to '||p_date_to,11);
40
41 -- Bug 10383109: When we update an organization from the form, the parameters are passed to
42 -- hr_organization_api.update_organization. So, the validation works correctly.
43 -- But in Financials, when we try to update Balancing Segment Values, p_date_from and p_date_to
44 -- is not passed to hr_organization_api.update_organization call, due to which default value
45 -- of hr_api.g_date gets passed, due to which the below validation fails. Bypassing the below
46 -- validations when p_date_from and p_date_to is passed as hr_api.g_date, since the validation
47 -- is not required while updating the organization record.
48
49 if p_date_from = hr_api.g_date and p_date_to = hr_api.g_date then
50 hr_utility.set_location('returning to bypass the validation ',11);
51 return;
52 else
53 if (fnd_installation.get(appl_id => 805
54 ,dep_appl_id => 805
55 ,status => l_status
56 ,industry => l_industry)) then
57 if (l_status = 'I') then
58 open chk_org_role_upd(p_organization_id, p_date_from, p_date_to);
59 fetch chk_org_role_upd into l_data_exists;
60 if chk_org_role_upd%found then
61 close chk_org_role_upd;
62 fnd_message.set_name('BEN', 'BEN_93384_ORG_ROLE_EXISTS');
63 fnd_message.raise_error;
64 end if;
65 close chk_org_role_upd;
66
67 open chk_org_bnf_upd(p_organization_id, p_date_from, p_date_to);
68 fetch chk_org_bnf_upd into l_data_exists;
69 if chk_org_bnf_upd%found then
70 close chk_org_bnf_upd;
71 fnd_message.set_name('BEN', 'BEN_93385_ORG_BNF_EXISTS');
72 fnd_message.raise_error;
73 end if;
74 close chk_org_bnf_upd;
75 end if;
76 end if;
77 end if;
78 hr_utility.set_location('Leaving ben_check_organization.chk_org_role_bnf_upd ',11);
79 End;
80
81 procedure chk_org_role_bnf_del
82 (
83 p_organization_id IN hr_all_organization_units.organization_id%TYPE
84 )
85 is
86 Begin
87 if (fnd_installation.get(appl_id => 805
88 ,dep_appl_id => 805
89 ,status => l_status
90 ,industry => l_industry)) then
91 if (l_status = 'I') then
92 open chk_org_role_del(p_organization_id);
93 fetch chk_org_role_del into l_data_exists;
94 if chk_org_role_del%found then
95 close chk_org_role_del;
96 fnd_message.set_name('BEN', 'BEN_93384_ORG_ROLE_EXISTS');
97 fnd_message.raise_error;
98 end if;
99 close chk_org_role_del;
100
101 open chk_org_bnf_del(p_organization_id);
102 fetch chk_org_bnf_del into l_data_exists;
103 if chk_org_bnf_del%found then
104 close chk_org_bnf_del;
105 fnd_message.set_name('BEN', 'BEN_93385_ORG_BNF_EXISTS');
106 fnd_message.raise_error;
107 end if;
108 close chk_org_bnf_del;
109 end if;
110 end if;
111 End;
112
113
114 END BEN_CHECK_ORGANIZATION;
115