1 Package Body irc_ipt_bus as
2 /* $Header: iriptrhi.pkb 120.1 2010/06/10 06:01:23 uuddavol ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' irc_ipt_bus.'; -- Global package name
9 --
10 -- The following two global variables are only to be
11 -- used by the return_legislation_code function.
12 --
13 g_legislation_code varchar2(150) default null;
14 g_posting_content_id number default null;
15 g_language varchar2(4) default null;
16 --
17 -- ----------------------------------------------------------------------------
18 -- |-----------------------< chk_non_updateable_args >------------------------|
19 -- ----------------------------------------------------------------------------
20 -- {Start Of Comments}
21 --
22 -- Description:
23 -- This procedure is used to ensure that non updateable attributes have
24 -- not been updated. If an attribute has been updated an error is generated.
25 --
26 -- Pre Conditions:
27 -- g_old_rec has been populated with details of the values currently in
28 -- the database.
29 --
30 -- In Arguments:
31 -- p_rec has been populated with the updated values the user would like the
32 -- record set to.
33 --
34 -- Post Success:
35 -- Processing continues if all the non updateable attributes have not
36 -- changed.
37 --
38 -- Post Failure:
39 -- An application error is raised if any of the non updatable attributes
40 -- have been altered.
41 --
42 -- {End Of Comments}
43 -- ----------------------------------------------------------------------------
44 Procedure chk_non_updateable_args
45 (p_rec in irc_ipt_shd.g_rec_type
46 ) IS
47 --
48 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
49 --
50 Begin
51 --
52 -- Only proceed with the validation if a row exists for the current
53 -- record in the HR Schema.
54 --
55 IF NOT irc_ipt_shd.api_updating
56 (p_posting_content_id => p_rec.posting_content_id
57 ,p_language => p_rec.language
58 ) THEN
59 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
60 fnd_message.set_token('PROCEDURE ', l_proc);
61 fnd_message.set_token('STEP ', '5');
62 fnd_message.raise_error;
63 END IF;
64 --
65 End chk_non_updateable_args;
66 --
67 -- ----------------------------------------------------------------------------
68 -- |-----------------------< chk_name>------------------------|
69 -- ----------------------------------------------------------------------------
70 -- {Start Of Comments}
71 --
72 -- Description:
73 -- This procedure ensures a valid name is entered
74 -- Pre Conditions:
75 -- g_old_rec has been populated with details of the values currently in
76 -- the database.
77 --
78 -- In Arguments:
79 -- p_name
80 -- p_language
81 -- Post Success:
82 -- Processing continues if name is not null and unique
83 --
84 -- Post Failure:
85 -- An application error is raised if name is null or exists already
86 --
87 -- {End Of Comments}
88 -- ----------------------------------------------------------------------------
89 Procedure chk_name
90 (p_name in irc_posting_contents_tl.name%TYPE
91 ,p_language in irc_posting_contents_tl.language%TYPE
92 ) IS
93 --
94 l_proc varchar2(72) := g_package || 'chk_name';
95 l_name varchar2(1);
96 cursor csr_name is
97 select null
98 from irc_posting_contents_tl
99 where name = p_name
100 and language = p_language;
101 --
102 Begin
103 hr_utility.set_location('Entering:'||l_proc,10);
104 if (p_name is null)
105 then
106 fnd_message.set_name('PER','IRC_412029_IPT_NAME_MND');
107 fnd_message.raise_error;
108 end if;
109 hr_utility.set_location('Entering:'||l_proc,20);
110 if ((irc_ipt_shd.g_old_rec.posting_content_id is
111 null)
112 or (irc_ipt_shd.g_old_rec.posting_content_id is not null
113 and irc_ipt_shd.g_old_rec.name <> p_name)) then
114 open csr_name;
115 fetch csr_name into l_name;
116 hr_utility.set_location('Entering:'||l_proc,30);
117 if (csr_name%found)
118 then
119 close csr_name;
120 fnd_message.set_name('PER','IRC_412122_DUPLICATE_POST_NAME');
121 fnd_message.raise_error;
122 end if;
123 close csr_name;
124 end if;
125 hr_utility.set_location(' Leaving:'||l_proc,35);
126 exception
127 when app_exception.application_exception then
128 if hr_multi_message.exception_add
129 (p_associated_column1 => 'IRC_POSTING_CONTENTS_TL.POSTING_CONTENT_ID'
130 )then
131 hr_utility.set_location(' Leaving:'||l_proc, 40);
132 raise;
133 end if;
134 hr_utility.set_location(' Leaving:'||l_proc,50);
135 End chk_name;
136 --
137 -- ----------------------------------------------------------------------------
138 -- |---------------------------< chk_source_lang >----------------------------|
139 -- ----------------------------------------------------------------------------
140 Procedure chk_source_lang
141 (p_language in irc_posting_contents_tl.language%TYPE
142 ,p_source_lang in irc_posting_contents_tl.source_language%TYPE
143 ) is
144 --
145 cursor csr_language is
146 select l.installed_flag
147 from fnd_languages l
148 where l.language_code = p_source_lang;
149 --
150 l_proc varchar2(72) := g_package || 'chk_source_lang';
151 l_installed_flag varchar2(30);
152 --
153 Begin
154 hr_utility.set_location('Entering:'||l_proc, 10);
155 --
156 -- Only proceed with SQL validation if absolutely necessary
157 --
158 hr_api.mandatory_arg_error
159 (p_api_name => l_proc
160 ,p_argument => 'source_lang'
161 ,p_argument_value => p_source_lang
162 );
163 --
164 hr_utility.set_location(l_proc,20);
165 if ((irc_ipt_shd.g_old_rec.posting_content_id is
166 null and p_language is not null)
167 or (irc_ipt_shd.g_old_rec.posting_content_id is not null
168 and nvl(irc_ipt_shd.g_old_rec.language, hr_api.g_varchar2)
169 <> nvl(p_language, hr_api.g_varchar2))) then
170 --
171 hr_utility.set_location(l_proc,30);
172 --
173 -- Check value has been passed
174 --
175 --
176 -- Check source language exists and is base or installed language
177 --
178 open csr_language;
179 fetch csr_language into l_installed_flag;
180 if csr_language%notfound then
181 close csr_language;
182 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
183 fnd_message.set_token('PROCEDURE', l_proc);
184 fnd_message.set_token('STEP','10');
185 fnd_message.raise_error;
186 end if;
187 close csr_language;
188 --
189 hr_utility.set_location('Leaving:'||l_proc,40);
190 if nvl(l_installed_flag,hr_api.g_varchar2) not in ('I','B') then
191 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
192 fnd_message.set_token('PROCEDURE', l_proc);
193 fnd_message.set_token('STEP','20');
194 fnd_message.raise_error;
195 end if;
196 --
197 end if;
198 --
199 hr_utility.set_location('Leaving:'||l_proc, 50);
200 End chk_source_lang;
201 --
202 -- ----------------------------------------------------------------------------
203 -- |---------------------------< insert_validate >----------------------------|
204 -- ----------------------------------------------------------------------------
205 Procedure insert_validate
206 (p_rec in irc_ipt_shd.g_rec_type
207 ) is
208 --
209 l_proc varchar2(72) := g_package||'insert_validate';
210 --
211 Begin
212 hr_utility.set_location('Entering:'||l_proc, 5);
213 --
214 --
215 hr_utility.set_location(l_proc, 10);
216 irc_ipt_bus.chk_source_lang
217 (
218 p_language => p_rec.language
219 ,p_source_lang => p_rec.source_language
220 );
221 hr_utility.set_location(l_proc, 20);
222 irc_ipt_bus.chk_name
223 (
224 p_name => p_rec.name
225 ,p_language => p_rec.language
226 );
227 hr_utility.set_location(' Leaving:'||l_proc, 30);
228 End insert_validate;
229 --
230 -- ----------------------------------------------------------------------------
231 -- |---------------------------< update_validate >----------------------------|
232 -- ----------------------------------------------------------------------------
233 Procedure update_validate
234 (p_rec in irc_ipt_shd.g_rec_type
235 ) is
236 --
237 l_proc varchar2(72) := g_package||'update_validate';
238 --
239 Begin
240 hr_utility.set_location('Entering:'||l_proc, 5);
241 chk_non_updateable_args
242 (p_rec => p_rec
243 );
244 hr_utility.set_location(l_proc, 10);
245 irc_ipt_bus.chk_source_lang
246 (
247 p_language => p_rec.language
248 ,p_source_lang => p_rec.source_language
249 );
250 hr_utility.set_location(l_proc, 20);
251 irc_ipt_bus.chk_name
252 (
253 p_name => p_rec.name
254 ,p_language => p_rec.language
255 );
256 hr_utility.set_location(' Leaving:'||l_proc, 30);
257 End update_validate;
258 --
259 -- ----------------------------------------------------------------------------
260 -- |---------------------------< delete_validate >----------------------------|
261 -- ----------------------------------------------------------------------------
262 Procedure delete_validate
263 (p_rec in irc_ipt_shd.g_rec_type
264 ) is
265 --
266 l_proc varchar2(72) := g_package||'delete_validate';
267 --
268 Begin
269 hr_utility.set_location('Entering:'||l_proc, 5);
270 --
271 hr_utility.set_location(' Leaving:'||l_proc, 10);
272 End delete_validate;
273 --
274 end irc_ipt_bus;