[Home] [Help]
PACKAGE BODY: APPS.PAY_PWA_BUS
Source
1 Package Body pay_pwa_bus as
2 /* $Header: pypwarhi.pkb 115.2 2002/12/05 14:25:59 swinton noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_pwa_bus.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------< chk_account_id >------|
12 -- ----------------------------------------------------------------------------
13 --
14 -- Description
15 -- This procedure is used to check that the primary key for the table
16 -- is created properly. It should be null on insert and
17 -- should not be able to be updated.
18 --
19 -- Pre Conditions
20 -- None.
21 --
22 -- In Parameters
23 -- account_id PK of record being inserted or updated.
24 -- object_version_number Object version number of record being
25 -- inserted or updated.
26 --
27 -- Post Success
28 -- Processing continues
29 --
30 -- Post Failure
31 -- Errors handled by the procedure
32 --
33 -- Access Status
34 -- Internal table handler use only.
35 --
36 Procedure chk_account_id(p_account_id in number,
37 p_object_version_number in number) is
38 --
39 l_proc varchar2(72) := g_package||'chk_account_id';
40 l_api_updating boolean;
41 --
42 Begin
43 --
44 hr_utility.set_location('Entering:'||l_proc, 5);
45 --
46 l_api_updating := pay_pwa_shd.api_updating
47 (p_account_id => p_account_id,
48 p_object_version_number => p_object_version_number);
49 --
50 if (l_api_updating
51 and nvl(p_account_id,hr_api.g_number)
52 <> pay_pwa_shd.g_old_rec.account_id) then
53 --
54 -- raise error as PK has changed
55 --
56 pay_pwa_shd.constraint_error('PAY_WCI_ACCOUNTS_PK');
57 --
58 elsif not l_api_updating then
59 --
60 -- check if PK is null
61 --
62 if p_account_id is not null then
63 --
64 -- raise error as PK is not null
65 --
66 pay_pwa_shd.constraint_error('PAY_WCI_ACCOUNTS_PK');
67 --
68 end if;
69 --
70 end if;
71 --
72 hr_utility.set_location('Leaving:'||l_proc, 10);
73 --
74 End chk_account_id;
75 --
76 -- ----------------------------------------------------------------------------
77 -- |---------------------------< insert_validate >----------------------------|
78 -- ----------------------------------------------------------------------------
79 Procedure insert_validate(p_rec in pay_pwa_shd.g_rec_type) is
80 --
81 l_proc varchar2(72) := g_package||'insert_validate';
82 --
83 Begin
84 hr_utility.set_location('Entering:'||l_proc, 5);
85 --
86 -- Call all supporting business operations
87 --
88 chk_account_id
89 (p_account_id => p_rec.account_id,
90 p_object_version_number => p_rec.object_version_number);
91 --
92 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate Bus Grp
93 --
94 hr_utility.set_location(' Leaving:'||l_proc, 10);
95 End insert_validate;
96 --
97 -- ----------------------------------------------------------------------------
98 -- |---------------------------< update_validate >----------------------------|
99 -- ----------------------------------------------------------------------------
100 Procedure update_validate(p_rec in pay_pwa_shd.g_rec_type) is
101 --
102 l_proc varchar2(72) := g_package||'update_validate';
103 --
104 Begin
105 hr_utility.set_location('Entering:'||l_proc, 5);
106 --
107 -- Call all supporting business operations
108 --
109 chk_account_id
110 (p_account_id => p_rec.account_id,
111 p_object_version_number => p_rec.object_version_number);
112 --
113 hr_api.validate_bus_grp_id(p_rec.business_group_id); -- Validate Bus Grp
114 --
115 hr_utility.set_location(' Leaving:'||l_proc, 10);
116 End update_validate;
117 --
118 -- ----------------------------------------------------------------------------
119 -- |---------------------------< delete_validate >----------------------------|
120 -- ----------------------------------------------------------------------------
121 Procedure delete_validate(p_rec in pay_pwa_shd.g_rec_type) is
122 --
123 l_proc varchar2(72) := g_package||'delete_validate';
124 --
125 Begin
126 hr_utility.set_location('Entering:'||l_proc, 5);
127 --
128 -- Call all supporting business operations
129 --
130 hr_utility.set_location(' Leaving:'||l_proc, 10);
131 End delete_validate;
132 --
133 --
134 -- ---------------------------------------------------------------------------
135 -- |---------------------< return_legislation_code >-------------------------|
136 -- ---------------------------------------------------------------------------
137 --
138 function return_legislation_code
139 (p_account_id in number) return varchar2 is
140 --
141 -- Declare cursor
142 --
143 cursor csr_leg_code is
144 select a.legislation_code
145 from per_business_groups a,
146 pay_wci_accounts b
147 where b.account_id = p_account_id
148 and a.business_group_id = b.business_group_id;
149 --
150 -- Declare local variables
151 --
152 l_legislation_code varchar2(150);
153 l_proc varchar2(72) := g_package||'return_legislation_code';
154 --
155 begin
156 --
157 hr_utility.set_location('Entering:'|| l_proc, 10);
158 --
159 -- Ensure that all the mandatory parameter are not null
160 --
161 hr_api.mandatory_arg_error(p_api_name => l_proc,
162 p_argument => 'account_id',
163 p_argument_value => p_account_id);
164 --
165 open csr_leg_code;
166 --
167 fetch csr_leg_code into l_legislation_code;
168 --
169 if csr_leg_code%notfound then
170 --
171 close csr_leg_code;
172 --
173 -- The primary key is invalid therefore we must error
174 --
175 hr_utility.set_message(801,'HR_7220_INVALID_PRIMARY_KEY');
176 hr_utility.raise_error;
177 --
178 end if;
179 --
180 close csr_leg_code;
181 --
182 hr_utility.set_location(' Leaving:'|| l_proc, 20);
183 --
184 return l_legislation_code;
185 --
186 end return_legislation_code;
187 --
188 end pay_pwa_bus;