[Home] [Help]
PACKAGE BODY: APPS.PER_JBT_SHD
Source
1 Package Body per_jbt_shd as
2 /* $Header: pejbtrhi.pkb 115.2 2003/05/16 06:44:35 adudekul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_jbt_shd.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |---------------------------< constraint_error >---------------------------|
12 -- ----------------------------------------------------------------------------
13 Procedure constraint_error
14 (p_constraint_name in all_constraints.constraint_name%TYPE
15 ) Is
16 --
17 l_proc varchar2(72) := g_package||'constraint_error';
18 --
19 Begin
20 --
21 If (p_constraint_name = 'PER_JOBS_TL_PK') Then
22 fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
23 fnd_message.set_token('PROCEDURE', l_proc);
24 fnd_message.set_token('STEP','5');
25 fnd_message.raise_error;
26 Else
27 fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
28 fnd_message.set_token('PROCEDURE', l_proc);
29 fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
30 fnd_message.raise_error;
31 End If;
32 --
33 End constraint_error;
34 --
35 -- ----------------------------------------------------------------------------
36 -- |-----------------------------< api_updating >-----------------------------|
37 -- ----------------------------------------------------------------------------
38 Function api_updating
39 (p_job_id in number
40 ,p_language in varchar2
41 ) Return Boolean Is
42 --
43 --
44 -- Cursor selects the 'current' row from the HR Schema
45 --
46 Cursor C_Sel1 is
47 select
48 job_id
49 ,language
50 ,source_lang
51 ,name
52 from per_jobs_tl
53 where job_id = p_job_id
54 and language = p_language;
55 --
56 l_fct_ret boolean;
57 --
58 Begin
59 --
60 If (p_job_id is null or
61 p_language is null
62 ) Then
63 --
64 -- One of the primary key arguments is null therefore we must
65 -- set the returning function value to false
66 --
67 l_fct_ret := false;
68 Else
69 If (p_job_id
70 = per_jbt_shd.g_old_rec.job_id and
71 p_language
72 = per_jbt_shd.g_old_rec.language
73 ) Then
74 --
75 -- The g_old_rec is current therefore we must
76 -- set the returning function to true
77 --
78 l_fct_ret := true;
79 Else
80 --
81 -- Select the current row into g_old_rec
82 --
83 Open C_Sel1;
84 Fetch C_Sel1 Into per_jbt_shd.g_old_rec;
85 If C_Sel1%notfound Then
86 Close C_Sel1;
87 --
88 -- The primary key is invalid therefore we must error
89 --
90 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
91 fnd_message.raise_error;
92 End If;
93 Close C_Sel1;
94 --
95 l_fct_ret := true;
96 End If;
97 End If;
98 Return (l_fct_ret);
99 --
100 End api_updating;
101 --
102 -- ----------------------------------------------------------------------------
103 -- |---------------------------------< lck >----------------------------------|
104 -- ----------------------------------------------------------------------------
105 Procedure lck
106 (p_job_id in number
107 ,p_language in varchar2
108 ) is
109 --
110 -- Cursor selects the 'current' row from the HR Schema
111 --
112 Cursor C_Sel1 is
113 select
114 job_id
115 ,language
116 ,source_lang
117 ,name
118 from per_jobs_tl
119 where job_id = p_job_id
120 and language = p_language
121 for update nowait;
122 --
123 l_proc varchar2(72) := g_package||'lck';
124 --
125 Begin
126 hr_utility.set_location('Entering:'||l_proc, 5);
127 --
128 hr_api.mandatory_arg_error
129 (p_api_name => l_proc
130 ,p_argument => 'JOB_ID'
131 ,p_argument_value => p_job_id
132 );
133 hr_utility.set_location(l_proc,6);
134 hr_api.mandatory_arg_error
135 (p_api_name => l_proc
136 ,p_argument => 'LANGUAGE'
137 ,p_argument_value => p_language
138 );
139 --
140 Open C_Sel1;
141 Fetch C_Sel1 Into per_jbt_shd.g_old_rec;
142 If C_Sel1%notfound then
143 Close C_Sel1;
144 --
145 -- The primary key is invalid therefore we must error
146 --
147 fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
148 fnd_message.raise_error;
149 End If;
150 Close C_Sel1;
151 --
152 --
153 hr_utility.set_location(' Leaving:'||l_proc, 10);
154 --
155 -- We need to trap the ORA LOCK exception
156 --
157 Exception
158 When HR_Api.Object_Locked then
159 --
160 -- The object is locked therefore we need to supply a meaningful
161 -- error message.
162 --
163 fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
164 fnd_message.set_token('TABLE_NAME', 'per_jobs_tl');
165 fnd_message.raise_error;
166 End lck;
167 --
168 -- ----------------------------------------------------------------------------
169 -- |----------------------------< add_language >------------------------------|
170 -- ----------------------------------------------------------------------------
171 PROCEDURE add_language IS
172 --
173 -- Return new tl job records for new languages
174 --
175 cursor c_new_jobs_tl is
176 select jbt.job_id
177 , jb.id_flex_num
178 , jb.job_definition_id
179 , jbt.created_by
180 , jbt.creation_date
181 , jbt.last_updated_by
182 , jbt.last_update_date
183 , jbt.last_update_login
184 , l.language_code
185 , jbt.source_lang
186 , l.nls_language
187 , jbt.name
188 from per_jobs job
189 , per_job_definitions jb
190 , per_jobs_tl jbt
191 , fnd_languages l
192 where job.job_definition_id = jb.job_definition_id
193 and job.job_id = jbt.job_id
194 and jbt.language = userenv('LANG')
195 and l.installed_flag in ('I', 'B')
196 and not exists (select null
197 from per_jobs_tl t
198 where t.job_id = jbt.job_id
199 and t.language = l.language_code)
200 order by l.language_code;
201 --
202 l_userenv_language_code VARCHAR2(4) := userenv('LANG'); --Bug2962837.
203 --
204 l_current_nls_language VARCHAR2(30);
205 --
206 l_proc varchar2(72) := g_package||'add_language';
207 --
208 Begin
209 --
210 hr_utility.set_location('Entering:'||l_proc, 5);
211 --
212 delete from PER_JOBS_TL T
213 where not exists
214 (select NULL
215 from PER_JOBS B
216 where B.JOB_ID = T.JOB_ID
217 );
218 --
219 --
220 For l_jobs_tl IN c_new_jobs_tl loop
221 --
222 -- Only set session nls language if changed.
223 --
224 If l_current_nls_language = l_jobs_tl.nls_language then
225
226 null; -- Have not changed so do nothing.
227
228 Else
229
230 hr_kflex_utility.set_session_nls_language( l_jobs_tl.nls_language );
231 l_current_nls_language := l_jobs_tl.nls_language;
232
233 End if;
234 --
235 insert into per_jobs_tl (
236 job_id
237 , name
238 , created_by
239 , creation_date
240 , last_updated_by
241 , last_update_date
242 , last_update_login
243 , language
244 , source_lang)
245 values (l_jobs_tl.job_id
246 , nvl(fnd_flex_ext.get_segs( g_app_code
247 , g_flex_code
248 , l_jobs_tl.id_flex_num
249 , l_jobs_tl.job_definition_id
250 )
251 , l_jobs_tl.name
252 )
253 , l_jobs_tl.created_by
254 , l_jobs_tl.creation_date
255 , l_jobs_tl.last_updated_by
256 , l_jobs_tl.last_update_date
257 , l_jobs_tl.last_update_login
258 , l_jobs_tl.language_code
259 , l_jobs_tl.source_lang);
260 --
261 End loop;
262 --
263 hr_kflex_utility.set_session_language_code( l_userenv_language_code );
264 --
265 hr_utility.set_location(' Leaving:'||l_proc, 10);
266 --
267 Exception
268 --
269 When Others Then
270 --
271 hr_kflex_utility.set_session_language_code( l_userenv_language_code );
272 --
273 raise;
274 End;
275 --
276 -- ----------------------------------------------------------------------------
277 -- |-----------------------------< convert_args >-----------------------------|
278 -- ----------------------------------------------------------------------------
279 Function convert_args
280 (p_job_id in number
281 ,p_language in varchar2
282 ,p_source_lang in varchar2
283 ,p_name in varchar2
284 )
285 Return g_rec_type is
286 --
287 l_rec g_rec_type;
288 --
289 Begin
290 --
291 -- Convert arguments into local l_rec structure.
292 --
293 l_rec.job_id := p_job_id;
294 l_rec.language := p_language;
295 l_rec.source_lang := p_source_lang;
296 l_rec.name := p_name;
297 --
298 -- Return the plsql record structure.
299 --
300 Return(l_rec);
301 --
302 End convert_args;
303 --
304 end per_jbt_shd;