DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_FORM_TEMPLATES_API

Source


1 Package Body hr_form_templates_api as
2 /* $Header: hrtmpapi.pkb 115.8 2003/10/31 06:54:25 bsubrama noship $ */
3 --
4 -- Package Variables
5 --
6 g_package  varchar2(33) := '  hr_form_templates_api.';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |--------------------------< session_mode procedures>----------------------|
10 -- ----------------------------------------------------------------------------
11 --
12 procedure set_seed_data_session_mode is
13 begin
14   hr_form_templates_api.g_session_mode := 'SEED_DATA';
15 end set_seed_data_session_mode;
16 --
20 end set_customer_data_session_mode;
17 procedure set_customer_data_session_mode is
18 begin
19   hr_form_templates_api.g_session_mode := 'CUSTOMER_DATA';
21 --
22 function seed_data_session_mode return boolean
23 is
24 begin
25  IF hr_form_templates_api.g_session_mode = 'SEED_DATA' THEN
26     return true;
27  END IF;
28  return false;
29 end seed_data_session_mode;
30 --
31 procedure assert_seed_data_session_mode is
32 begin
33  IF hr_form_templates_api.g_session_mode = 'SEED_DATA' THEN
34 -- error message
35    fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
36    fnd_message.raise_error;
37  END IF;
38 end assert_seed_data_session_mode;
39 --
40 -- ----------------------------------------------------------------------------
41 -- |--------------------------< copy_template >--------------------------|
42 -- ----------------------------------------------------------------------------
43 --
44 procedure copy_template
45   (p_validate                     in boolean  default false
46   ,p_effective_date               in date
47   ,p_form_template_id_from        in number
48   ,p_language_code                in varchar2 default hr_api.userenv_lang
49   --,p_template_name                in varchar2 default hr_api.g_varchar2
50   ,p_template_name                in varchar2
51   ,p_user_template_name           in varchar2 default hr_api.g_varchar2
52   ,p_description                  in varchar2 default hr_api.g_varchar2
53   ,p_enabled_flag                 in varchar2 default hr_api.g_varchar2
54   ,p_legislation_code             in varchar2 default hr_api.g_varchar2
55   ,p_attribute_category           in varchar2 default hr_api.g_varchar2
56   ,p_attribute1                   in varchar2 default hr_api.g_varchar2
57   ,p_attribute2                   in varchar2 default hr_api.g_varchar2
58   ,p_attribute3                   in varchar2 default hr_api.g_varchar2
59   ,p_attribute4                   in varchar2 default hr_api.g_varchar2
60   ,p_attribute5                   in varchar2 default hr_api.g_varchar2
61   ,p_attribute6                   in varchar2 default hr_api.g_varchar2
62   ,p_attribute7                   in varchar2 default hr_api.g_varchar2
63   ,p_attribute8                   in varchar2 default hr_api.g_varchar2
64   ,p_attribute9                   in varchar2 default hr_api.g_varchar2
65   ,p_attribute10                  in varchar2 default hr_api.g_varchar2
66   ,p_attribute11                  in varchar2 default hr_api.g_varchar2
67   ,p_attribute12                  in varchar2 default hr_api.g_varchar2
68   ,p_attribute13                  in varchar2 default hr_api.g_varchar2
69   ,p_attribute14                  in varchar2 default hr_api.g_varchar2
70   ,p_attribute15                  in varchar2 default hr_api.g_varchar2
71   ,p_attribute16                  in varchar2 default hr_api.g_varchar2
72   ,p_attribute17                  in varchar2 default hr_api.g_varchar2
73   ,p_attribute18                  in varchar2 default hr_api.g_varchar2
74   ,p_attribute19                  in varchar2 default hr_api.g_varchar2
75   ,p_attribute20                  in varchar2 default hr_api.g_varchar2
76   ,p_attribute21                  in varchar2 default hr_api.g_varchar2
77   ,p_attribute22                  in varchar2 default hr_api.g_varchar2
78   ,p_attribute23                  in varchar2 default hr_api.g_varchar2
79   ,p_attribute24                  in varchar2 default hr_api.g_varchar2
80   ,p_attribute25                  in varchar2 default hr_api.g_varchar2
81   ,p_attribute26                  in varchar2 default hr_api.g_varchar2
82   ,p_attribute27                  in varchar2 default hr_api.g_varchar2
83   ,p_attribute28                  in varchar2 default hr_api.g_varchar2
84   ,p_attribute29                  in varchar2 default hr_api.g_varchar2
85   ,p_attribute30                  in varchar2 default hr_api.g_varchar2
86   ,p_form_template_id_to            out nocopy number
87   ,p_object_version_number          out nocopy number
88   ) is
89   --
90   -- Declare cursors and local variables
91   --
92   Type l_rec_type Is Record
93   (application_id hr_form_templates_b.application_id%TYPE
94   ,form_id hr_form_templates_b.form_id%TYPE
95   ,template_name hr_form_templates_b.template_name%TYPE
96   ,enabled_flag hr_form_templates_b.enabled_flag%TYPE
97   ,legislation_code hr_form_templates_b.legislation_code%TYPE
98   ,attribute_category hr_form_templates_b.attribute_category%TYPE
99   ,attribute1 hr_form_templates_b.attribute1%TYPE
100   ,attribute2 hr_form_templates_b.attribute2%TYPE
101   ,attribute3 hr_form_templates_b.attribute3%TYPE
102   ,attribute4 hr_form_templates_b.attribute4%TYPE
103   ,attribute5 hr_form_templates_b.attribute5%TYPE
104   ,attribute6 hr_form_templates_b.attribute6%TYPE
105   ,attribute7 hr_form_templates_b.attribute7%TYPE
106   ,attribute8 hr_form_templates_b.attribute8%TYPE
107   ,attribute9 hr_form_templates_b.attribute9%TYPE
108   ,attribute10 hr_form_templates_b.attribute10%TYPE
109   ,attribute11 hr_form_templates_b.attribute11%TYPE
110   ,attribute12 hr_form_templates_b.attribute12%TYPE
111   ,attribute13 hr_form_templates_b.attribute13%TYPE
112   ,attribute14 hr_form_templates_b.attribute14%TYPE
113   ,attribute15 hr_form_templates_b.attribute15%TYPE
114   ,attribute16 hr_form_templates_b.attribute16%TYPE
115   ,attribute17 hr_form_templates_b.attribute17%TYPE
116   ,attribute18 hr_form_templates_b.attribute18%TYPE
117   ,attribute19 hr_form_templates_b.attribute19%TYPE
118   ,attribute20 hr_form_templates_b.attribute20%TYPE
119   ,attribute21 hr_form_templates_b.attribute21%TYPE
120   ,attribute22 hr_form_templates_b.attribute22%TYPE
121   ,attribute23 hr_form_templates_b.attribute23%TYPE
122   ,attribute24 hr_form_templates_b.attribute24%TYPE
123   ,attribute25 hr_form_templates_b.attribute25%TYPE
124   ,attribute26 hr_form_templates_b.attribute26%TYPE
125   ,attribute27 hr_form_templates_b.attribute27%TYPE
126   ,attribute28 hr_form_templates_b.attribute28%TYPE
130   l_rec l_rec_type;
127   ,attribute29 hr_form_templates_b.attribute29%TYPE
128   ,attribute30 hr_form_templates_b.attribute30%TYPE);
129 
131 
132   CURSOR cur_tmplt_rec
133   IS
134   SELECT tmp.application_id
135   ,tmp.form_id
136   ,DECODE(p_template_name,hr_api.g_varchar2,tmp.template_name,p_template_name)
137   ,DECODE(p_enabled_flag,hr_api.g_varchar2,tmp.enabled_flag,p_enabled_flag)
138   ,DECODE(p_legislation_code,hr_api.g_varchar2,tmp.legislation_code,p_legislation_code)
139   ,DECODE(p_attribute_category,hr_api.g_varchar2,tmp.attribute_category,p_attribute_category)
140   ,DECODE(p_attribute1,hr_api.g_varchar2,tmp.attribute1,p_attribute1)
141   ,DECODE(p_attribute2,hr_api.g_varchar2,tmp.attribute2,p_attribute2)
142   ,DECODE(p_attribute3,hr_api.g_varchar2,tmp.attribute3,p_attribute3)
143   ,DECODE(p_attribute4,hr_api.g_varchar2,tmp.attribute4,p_attribute4)
144   ,DECODE(p_attribute5,hr_api.g_varchar2,tmp.attribute5,p_attribute5)
145   ,DECODE(p_attribute6,hr_api.g_varchar2,tmp.attribute6,p_attribute6)
146   ,DECODE(p_attribute7,hr_api.g_varchar2,tmp.attribute7,p_attribute7)
147   ,DECODE(p_attribute8,hr_api.g_varchar2,tmp.attribute8,p_attribute8)
148   ,DECODE(p_attribute9,hr_api.g_varchar2,tmp.attribute9,p_attribute9)
149   ,DECODE(p_attribute10,hr_api.g_varchar2,tmp.attribute10,p_attribute10)
150   ,DECODE(p_attribute11,hr_api.g_varchar2,tmp.attribute11,p_attribute11)
151   ,DECODE(p_attribute12,hr_api.g_varchar2,tmp.attribute12,p_attribute12)
152   ,DECODE(p_attribute13,hr_api.g_varchar2,tmp.attribute13,p_attribute13)
153   ,DECODE(p_attribute14,hr_api.g_varchar2,tmp.attribute14,p_attribute14)
154   ,DECODE(p_attribute15,hr_api.g_varchar2,tmp.attribute15,p_attribute15)
155   ,DECODE(p_attribute16,hr_api.g_varchar2,tmp.attribute16,p_attribute16)
156   ,DECODE(p_attribute17,hr_api.g_varchar2,tmp.attribute17,p_attribute17)
157   ,DECODE(p_attribute18,hr_api.g_varchar2,tmp.attribute18,p_attribute18)
158   ,DECODE(p_attribute19,hr_api.g_varchar2,tmp.attribute19,p_attribute19)
159   ,DECODE(p_attribute20,hr_api.g_varchar2,tmp.attribute20,p_attribute20)
160   ,DECODE(p_attribute21,hr_api.g_varchar2,tmp.attribute21,p_attribute21)
161   ,DECODE(p_attribute22,hr_api.g_varchar2,tmp.attribute22,p_attribute22)
162   ,DECODE(p_attribute23,hr_api.g_varchar2,tmp.attribute23,p_attribute23)
163   ,DECODE(p_attribute24,hr_api.g_varchar2,tmp.attribute24,p_attribute24)
164   ,DECODE(p_attribute25,hr_api.g_varchar2,tmp.attribute25,p_attribute25)
165   ,DECODE(p_attribute26,hr_api.g_varchar2,tmp.attribute26,p_attribute26)
166   ,DECODE(p_attribute27,hr_api.g_varchar2,tmp.attribute27,p_attribute27)
167   ,DECODE(p_attribute28,hr_api.g_varchar2,tmp.attribute28,p_attribute28)
168   ,DECODE(p_attribute29,hr_api.g_varchar2,tmp.attribute29,p_attribute29)
169   ,DECODE(p_attribute30,hr_api.g_varchar2,tmp.attribute30,p_attribute30)
170   FROM hr_form_templates_b tmp
171   WHERE tmp.form_template_id = p_form_template_id_from;
172 
173   CURSOR cur_tmplt_tl
174   IS
175   SELECT COUNT(0)
176   ,tmptl.source_lang
177   ,DECODE(p_user_template_name,hr_api.g_varchar2,tmptl.user_template_name,p_user_template_name) user_template_name
178   ,DECODE(p_description,hr_api.g_varchar2,tmptl.description,p_description) description
179   FROM hr_form_templates_tl tmptl
180   WHERE tmptl.form_template_id = p_form_template_id_from
181   GROUP BY tmptl.source_lang
182   ,DECODE(p_user_template_name,hr_api.g_varchar2,tmptl.user_template_name,p_user_template_name)
183   ,DECODE(p_description,hr_api.g_varchar2,tmptl.description,p_description)
184   ORDER BY 1;
185 
186   CURSOR cur_tmplt_win
187   IS
188   SELECT twn.template_window_id
189   FROM hr_template_windows twn
190   WHERE twn.form_template_id = p_form_template_id_from;
191 
192   CURSOR cur_tmplt_item
193   IS
194   SELECT tit.template_item_id
195   FROM hr_template_items tit
196   WHERE tit.form_template_id = p_form_template_id_from;
197 
198   CURSOR cur_tmplt_data_group
199   IS
200   SELECT tdg.template_data_group_id
201   FROM hr_template_data_groups tdg
202   WHERE tdg.form_template_id = p_form_template_id_from;
203 
204   CURSOR csr_source_form_templates
205     (p_form_template_id IN NUMBER
206     )
207   IS
208     SELECT sft.form_template_id_from
209       FROM hr_source_form_templates sft
210      WHERE sft.form_template_id_to = p_form_template_id;
211   l_source_form_template csr_source_form_templates%ROWTYPE;
212 
213   l_proc                varchar2(72) := g_package||'copy_template';
214   l_object_version_number number;
215   l_form_template_id_to number;
216 -- Local Vars not used
217   l_form_property_id number;
218   l_source_form_template_id number;
219   l_template_window_id_to number;
220   l_ovn_tmplt_win number;
221   l_template_item_id_to number;
222   l_ovn_tmplt_item number;
223   l_template_data_group_id_to number;
224   l_ovn_tmplt_data_group number;
225   l_language_code fnd_languages.language_code%TYPE;
226   l_form_template_id_from number;
227 
228 begin
229   hr_utility.set_location('Entering:'|| l_proc, 10);
230   --
231   -- Issue a savepoint
232   --
233   savepoint copy_template;
234   --
235   -- Truncate the time portion from all IN date parameters
236   --
237      -- p_effective_date := TRUNC(p_effective_date);
238   --
239   -- Validate the language parameter. l_language_code should be passed
240   -- instead of p_language_code from now on, to allow an IN OUT parameter to
241   -- be passed through.
242   --
243   l_language_code := p_language_code;
244   hr_api.validate_language_code(p_language_code => l_language_code);
245   --
246   hr_utility.set_location(l_proc, 20);
247   --
248   --
249   -- Call Before Process User Hook
250   --
251   begin
252     hr_form_templates_api_bk1.copy_template_b
253       (p_effective_date               => TRUNC(p_effective_date)
257       ,p_user_template_name          => p_user_template_name
254       ,p_form_template_id_from       => p_form_template_id_from
255       ,p_language_code               => l_language_code
256       ,p_template_name               => p_template_name
258       ,p_description                 => p_description
259       ,p_enabled_flag                => p_enabled_flag
260       ,p_legislation_code            => p_legislation_code
261       ,p_attribute_category          => p_attribute_category
262       ,p_attribute1                  => p_attribute1
263       ,p_attribute2                  => p_attribute2
264       ,p_attribute3                  => p_attribute3
265       ,p_attribute4                  => p_attribute4
266       ,p_attribute5                  => p_attribute5
267       ,p_attribute6                  => p_attribute6
268       ,p_attribute7                  => p_attribute7
269       ,p_attribute8                  => p_attribute8
270       ,p_attribute9                  => p_attribute9
271       ,p_attribute10                 => p_attribute10
272       ,p_attribute11                 => p_attribute11
273       ,p_attribute12                 => p_attribute12
274       ,p_attribute13                 => p_attribute13
275       ,p_attribute14                 => p_attribute14
276       ,p_attribute15                 => p_attribute15
277       ,p_attribute16                 => p_attribute16
278       ,p_attribute17                 => p_attribute17
279       ,p_attribute18                 => p_attribute18
280       ,p_attribute19                 => p_attribute19
281       ,p_attribute20                 => p_attribute20
282       ,p_attribute21                 => p_attribute21
283       ,p_attribute22                 => p_attribute22
284       ,p_attribute23                 => p_attribute23
285       ,p_attribute24                 => p_attribute24
286       ,p_attribute25                 => p_attribute25
287       ,p_attribute26                 => p_attribute26
288       ,p_attribute27                 => p_attribute27
289       ,p_attribute28                 => p_attribute28
290       ,p_attribute29                 => p_attribute29
291       ,p_attribute30                 => p_attribute30);
292   exception
293     when hr_api.cannot_find_prog_unit then
294       hr_api.cannot_find_prog_unit_error
295         (p_module_name => 'copy_template'
296         ,p_hook_type   => 'BP'
297         );
298   end;
299 
300   --
301   -- Process Logic
302   --
303   hr_utility.set_location('At:'|| l_proc, 20);
304 
305   OPEN cur_tmplt_rec;
306   FETCH cur_tmplt_rec INTO l_rec;
307 -- ask john not in lld
308   IF cur_tmplt_rec%NOTFOUND THEN
309    CLOSE cur_tmplt_rec;
310 -- error message
311    fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
312    fnd_message.set_token('PROCEDURE', l_proc);
313    fnd_message.set_token('STEP','10');
314    fnd_message.raise_error;
315   END IF;
316   CLOSE cur_tmplt_rec;
317 
318   hr_utility.set_location('At:'|| l_proc, 30);
319 
320   hr_tmp_ins.ins(p_effective_date               => TRUNC(p_effective_date)
321                 ,p_application_id               => l_rec.application_id
322                 ,p_form_id                      => l_rec.form_id
323                 ,p_template_name                => l_rec.template_name
324                 ,p_enabled_flag                 => l_rec.enabled_flag
325                 ,p_legislation_code             => l_rec.legislation_code
326                 ,p_attribute_category           => l_rec.attribute_category
327                 ,p_attribute1                   => l_rec.attribute1
328                 ,p_attribute2                   => l_rec.attribute2
329                 ,p_attribute3                   => l_rec.attribute3
330                 ,p_attribute4                   => l_rec.attribute4
331                 ,p_attribute5                   => l_rec.attribute5
332                 ,p_attribute6                   => l_rec.attribute6
333                 ,p_attribute7                   => l_rec.attribute7
334                 ,p_attribute8                   => l_rec.attribute8
335                 ,p_attribute9                   => l_rec.attribute9
336                 ,p_attribute10                  => l_rec.attribute10
337                 ,p_attribute11                  => l_rec.attribute11
338                 ,p_attribute12                  => l_rec.attribute12
339                 ,p_attribute13                  => l_rec.attribute13
340                 ,p_attribute14                  => l_rec.attribute14
341                 ,p_attribute15                  => l_rec.attribute15
342                 ,p_attribute16                  => l_rec.attribute16
343                 ,p_attribute17                  => l_rec.attribute17
344                 ,p_attribute18                  => l_rec.attribute18
345                 ,p_attribute19                  => l_rec.attribute19
346                 ,p_attribute20                  => l_rec.attribute20
347                 ,p_attribute21                  => l_rec.attribute21
348                 ,p_attribute22                  => l_rec.attribute22
349                 ,p_attribute23                  => l_rec.attribute23
350                 ,p_attribute24                  => l_rec.attribute24
351                 ,p_attribute25                  => l_rec.attribute25
352                 ,p_attribute26                  => l_rec.attribute26
353                 ,p_attribute27                  => l_rec.attribute27
354                 ,p_attribute28                  => l_rec.attribute28
355                 ,p_attribute29                  => l_rec.attribute29
356                 ,p_attribute30                  => l_rec.attribute30
357                 ,p_form_template_id             => l_form_template_id_to
358                 ,p_object_version_number        => l_object_version_number);
359 
360   hr_utility.set_location('At:'|| l_proc, 40);
361 
362    IF (p_user_template_name <> hr_api.g_varchar2
366 
363             AND p_description <> hr_api.g_varchar2) THEN
364 
365     hr_utility.set_location('At:'|| l_proc, 41);
367      hr_tmt_ins.ins_tl( p_language_code                => l_language_code
368                        ,p_form_template_id             => l_form_template_id_to
369                        ,p_user_template_name           => p_user_template_name
370                        ,p_description                  => p_description);
371   ELSE
372 
373     hr_utility.set_location('At:'|| l_proc, 42);
374 
375     FOR cur_rec IN cur_tmplt_tl LOOP
376        hr_utility.set_location('At:'|| l_proc, 43);
377 
378        IF cur_tmplt_tl%ROWCOUNT = 1 THEN
379           hr_utility.set_location('At:'|| l_proc, 44);
380           hr_tmt_ins.ins_tl(
381                   p_language_code                => cur_rec.source_lang
382                   ,p_form_template_id             => l_form_template_id_to
383                   ,p_user_template_name           => cur_rec.user_template_name
384                   ,p_description                  => cur_rec.description);
385        ELSE
386          hr_utility.set_location('At:'|| l_proc, 45);
387          hr_tmt_upd.upd_tl(
388                   p_language_code                => cur_rec.source_lang
389                   ,p_form_template_id             => l_form_template_id_to
390                   ,p_user_template_name           => cur_rec.user_template_name
391                   ,p_description                  => cur_rec.description);
392        END IF;
393     END LOOP;
394   END IF;
395 
396   hr_utility.set_location('At:'|| l_proc, 50);
397 
398   l_object_version_number := p_object_version_number; -- Bug 3211362
399 
400   hr_form_properties_bsi.copy_form_property(
401             p_effective_date               => TRUNC(p_effective_date)
402             ,p_form_template_id_from        => p_form_template_id_from
403             ,p_form_template_id_to          => l_form_template_id_to
404             ,p_form_property_id             => l_form_property_id
405             ,p_object_version_number        => l_object_version_number);
406 
407   hr_utility.set_location('At:'|| l_proc, 55);
408 
409 /*  commented for bug 1692567 and replaced by text immediately below
410 
411   l_form_template_id_from := p_form_template_id_from;
412   LOOP
413     OPEN csr_source_form_templates(l_form_template_id_from);
414     FETCH csr_source_form_templates INTO l_source_form_template;
415     CLOSE csr_source_form_templates;
416     IF (l_source_form_template.form_template_id_from IS NOT NULL)
417     THEN
418       l_form_template_id_from := l_source_form_template.form_template_id_from;
419     ELSE
420       EXIT;
421     END IF;
422   END LOOP;
423 
424 */
425   l_form_template_id_from := p_form_template_id_from;
426   LOOP
427     OPEN csr_source_form_templates(l_form_template_id_from);
428     FETCH csr_source_form_templates INTO l_source_form_template;
429     IF csr_source_form_templates%notfound then
430       CLOSE csr_source_form_templates;
431       EXIT;
432     ELSE
433       CLOSE csr_source_form_templates;
434     END IF;
435     IF (l_source_form_template.form_template_id_from IS NOT NULL)
436     THEN
437       l_form_template_id_from := l_source_form_template.form_template_id_from;
438     ELSE
439       EXIT;
440     END IF;
441   END LOOP;
442 
443   hr_source_form_templates_bsi.create_source_form_template(
444             p_effective_date                => TRUNC(p_effective_date)
445             ,p_form_template_id_to          => l_form_template_id_to
446             ,p_form_template_id_from        => l_form_template_id_from
447             ,p_source_form_template_id      => l_source_form_template_id
448             ,p_object_version_number        => l_object_version_number);
449 
450   hr_utility.set_location('At:'|| l_proc, 60);
451 
452   FOR cur_rec in cur_tmplt_win LOOP
453     hr_template_windows_api.copy_template_window(
454                p_effective_date                => TRUNC(p_effective_date)
455                ,p_language_code                 => l_language_code
456                ,p_template_window_id_from      => cur_rec.template_window_id
457                ,p_form_template_id             => l_form_template_id_to
458                ,p_template_window_id_to        => l_template_window_id_to
459                ,p_object_version_number        => l_ovn_tmplt_win);
460   END LOOP;
461 
462   hr_utility.set_location('At:'|| l_proc, 65);
463 
464   FOR cur_rec in cur_tmplt_item LOOP
465     hr_template_items_api.copy_template_item(
466                p_effective_date                => TRUNC(p_effective_date)
467                ,p_language_code                => l_language_code
468                ,p_template_item_id_from        => cur_rec.template_item_id
469                ,p_form_template_id             => l_form_template_id_to
470                ,p_template_item_id_to          => l_template_item_id_to
471                ,p_object_version_number        => l_ovn_tmplt_item);
472   END LOOP;
473 
474   hr_utility.set_location('At:'|| l_proc, 70);
475 
476   FOR cur_rec in cur_tmplt_data_group LOOP
477     hr_template_data_groups_api.copy_template_data_group(
478                p_effective_date                => TRUNC(p_effective_date)
479                ,p_language_code                => l_language_code
480                ,p_template_data_group_id_from  => cur_rec.template_data_group_id
481                ,p_form_template_id             => l_form_template_id_to
482                ,p_template_data_group_id_to    => l_template_data_group_id_to
483                ,p_object_version_number        => l_ovn_tmplt_data_group);
484   END LOOP;
485 
486   hr_utility.set_location('At:'|| l_proc, 75);
487   --
488   -- Call After Process User Hook
489   --
490   begin
491     hr_form_templates_api_bk1.copy_template_a
492       (p_effective_date               => TRUNC(p_effective_date)
493       ,p_form_template_id_from       => p_form_template_id_from
494       ,p_language_code               => l_language_code
495       ,p_template_name               => p_template_name
496       ,p_user_template_name          => p_user_template_name
497       ,p_description                 => p_description
498       ,p_enabled_flag                => p_enabled_flag
499       ,p_legislation_code            => p_legislation_code
500       ,p_attribute_category          => p_attribute_category
501       ,p_attribute1                  => p_attribute1
502       ,p_attribute2                  => p_attribute2
503       ,p_attribute3                  => p_attribute3
504       ,p_attribute4                  => p_attribute4
505       ,p_attribute5                  => p_attribute5
506       ,p_attribute6                  => p_attribute6
507       ,p_attribute7                  => p_attribute7
508       ,p_attribute8                  => p_attribute8
509       ,p_attribute9                  => p_attribute9
510       ,p_attribute10                 => p_attribute10
511       ,p_attribute11                 => p_attribute11
512       ,p_attribute12                 => p_attribute12
513       ,p_attribute13                 => p_attribute13
514       ,p_attribute14                 => p_attribute14
515       ,p_attribute15                 => p_attribute15
516       ,p_attribute16                 => p_attribute16
517       ,p_attribute17                 => p_attribute17
518       ,p_attribute18                 => p_attribute18
519       ,p_attribute19                 => p_attribute19
520       ,p_attribute20                 => p_attribute20
521       ,p_attribute21                 => p_attribute21
522       ,p_attribute22                 => p_attribute22
523       ,p_attribute23                 => p_attribute23
524       ,p_attribute24                 => p_attribute24
525       ,p_attribute25                 => p_attribute25
526       ,p_attribute26                 => p_attribute26
527       ,p_attribute27                 => p_attribute27
528       ,p_attribute28                 => p_attribute28
529       ,p_attribute29                 => p_attribute29
530       ,p_attribute30                 => p_attribute30
531       ,p_form_template_id_to           => l_form_template_id_to
532       ,p_object_version_number        => l_object_version_number);
533   exception
534     when hr_api.cannot_find_prog_unit then
535       hr_api.cannot_find_prog_unit_error
536         (p_module_name => 'copy_template'
537         ,p_hook_type   => 'AP'
538         );
539   end;
540   --
541   -- When in validation only mode raise the Validate_Enabled exception
542   --
543   hr_utility.set_location('At:'|| l_proc, 80);
544 
545   if p_validate then
546     raise hr_api.validate_enabled;
547   end if;
548   --
549   -- Set all output arguments
550   --
551   p_form_template_id_to             := l_form_template_id_to;
552   p_object_version_number        := l_object_version_number;
553   --
554   hr_utility.set_location(' Leaving:'||l_proc, 85);
555 exception
556   when hr_api.validate_enabled then
557     --
558     -- As the Validate_Enabled exception has been raised
559     -- we must rollback to the savepoint
560     --
561     rollback to copy_template;
562     --
563     -- Only set output warning arguments
564     -- (Any key or derived arguments must be set to null
565     -- when validation only mode is being used.)
566     --
567     p_form_template_id_to          := null;
568     p_object_version_number        := null;
569     hr_utility.set_location(' Leaving:'||l_proc, 80);
570   when others then
571     --
572     -- A validation or unexpected error has occured
573     --
574     p_form_template_id_to          := null;
575     p_object_version_number        := null;
576 
577     rollback to copy_template;
578     hr_utility.set_location(' Leaving:'||l_proc, 90);
579     raise;
580 end copy_template;
581 --
582 -- ----------------------------------------------------------------------------
583 -- |--------------------------< create_template >--------------------------|
584 -- ----------------------------------------------------------------------------
585 --
586 procedure create_template
587   (p_validate                     in boolean  default false
588   ,p_effective_date               in date
589   ,p_language_code                in varchar2 default hr_api.userenv_lang
590   ,p_application_id               in number
591   ,p_form_id                      in number
592   ,p_template_name                in varchar2
593   ,p_enabled_flag                 in varchar2
594   ,p_user_template_name           in varchar2
595   ,p_description                  in varchar2 default null
596   ,p_legislation_code             in varchar2 default null
597   ,p_attribute_category           in varchar2 default null
598   ,p_attribute1                   in varchar2 default null
599   ,p_attribute2                   in varchar2 default null
600   ,p_attribute3                   in varchar2 default null
601   ,p_attribute4                   in varchar2 default null
602   ,p_attribute5                   in varchar2 default null
603   ,p_attribute6                   in varchar2 default null
604   ,p_attribute7                   in varchar2 default null
605   ,p_attribute8                   in varchar2 default null
606   ,p_attribute9                   in varchar2 default null
607   ,p_attribute10                  in varchar2 default null
608   ,p_attribute11                  in varchar2 default null
609   ,p_attribute12                  in varchar2 default null
610   ,p_attribute13                  in varchar2 default null
611   ,p_attribute14                  in varchar2 default null
612   ,p_attribute15                  in varchar2 default null
613   ,p_attribute16                  in varchar2 default null
614   ,p_attribute17                  in varchar2 default null
615   ,p_attribute18                  in varchar2 default null
616   ,p_attribute19                  in varchar2 default null
617   ,p_attribute20                  in varchar2 default null
618   ,p_attribute21                  in varchar2 default null
619   ,p_attribute22                  in varchar2 default null
620   ,p_attribute23                  in varchar2 default null
621   ,p_attribute24                  in varchar2 default null
622   ,p_attribute25                  in varchar2 default null
623   ,p_attribute26                  in varchar2 default null
624   ,p_attribute27                  in varchar2 default null
625   ,p_attribute28                  in varchar2 default null
626   ,p_attribute29                  in varchar2 default null
627   ,p_attribute30                  in varchar2 default null
628   ,p_help_target                  in varchar2 default hr_api.g_varchar2
629   ,p_information_category         in varchar2 default hr_api.g_varchar2
630   ,p_information1                 in varchar2 default hr_api.g_varchar2
631   ,p_information2                 in varchar2 default hr_api.g_varchar2
632   ,p_information3                 in varchar2 default hr_api.g_varchar2
633   ,p_information4                 in varchar2 default hr_api.g_varchar2
634   ,p_information5                 in varchar2 default hr_api.g_varchar2
635   ,p_information6                 in varchar2 default hr_api.g_varchar2
636   ,p_information7                 in varchar2 default hr_api.g_varchar2
637   ,p_information8                 in varchar2 default hr_api.g_varchar2
638   ,p_information9                 in varchar2 default hr_api.g_varchar2
639   ,p_information10                in varchar2 default hr_api.g_varchar2
640   ,p_information11                in varchar2 default hr_api.g_varchar2
641   ,p_information12                in varchar2 default hr_api.g_varchar2
642   ,p_information13                in varchar2 default hr_api.g_varchar2
643   ,p_information14                in varchar2 default hr_api.g_varchar2
644   ,p_information15                in varchar2 default hr_api.g_varchar2
645   ,p_information16                in varchar2 default hr_api.g_varchar2
646   ,p_information17                in varchar2 default hr_api.g_varchar2
647   ,p_information18                in varchar2 default hr_api.g_varchar2
648   ,p_information19                in varchar2 default hr_api.g_varchar2
649   ,p_information20                in varchar2 default hr_api.g_varchar2
650   ,p_information21                in varchar2 default hr_api.g_varchar2
651   ,p_information22                in varchar2 default hr_api.g_varchar2
652   ,p_information23                in varchar2 default hr_api.g_varchar2
653   ,p_information24                in varchar2 default hr_api.g_varchar2
654   ,p_information25                in varchar2 default hr_api.g_varchar2
655   ,p_information26                in varchar2 default hr_api.g_varchar2
656   ,p_information27                in varchar2 default hr_api.g_varchar2
657   ,p_information28                in varchar2 default hr_api.g_varchar2
658   ,p_information29                in varchar2 default hr_api.g_varchar2
659   ,p_information30                in varchar2 default hr_api.g_varchar2
660   ,p_form_template_id                out nocopy number
661   ,p_object_version_number           out nocopy number
662   ) is
663   --
664   -- Declare cursors and local variables
665   --
666 
667   l_proc                varchar2(72) := g_package||'create_template';
668   l_form_template_id number;
669   l_object_version_number number;
670 -- local vars
671   l_form_property_id number;
672   l_source_form_template_id number;
673   l_language_code fnd_languages.language_code%TYPE;
674 
675 begin
676   hr_utility.set_location('Entering:'|| l_proc, 10);
677   --
678   -- Issue a savepoint
679   --
680   savepoint create_template;
681   --
682   -- Truncate the time portion from all IN date parameters
683   --
684     -- p_effective_date := TRUNC(p_effective_date);
685   --
686   -- Validate the language parameter. l_language_code should be passed
687   -- instead of p_language_code from now on, to allow an IN OUT parameter to
688   -- be passed through.
692   --
689   --
690   l_language_code := p_language_code;
691   hr_api.validate_language_code(p_language_code => l_language_code);
693   hr_utility.set_location(l_proc, 20);
694   --
695   --
696   -- Call Before Process User Hook
697   --
698   begin
699     hr_form_templates_api_bk2.create_template_b
700       (p_effective_date              => TRUNC(p_effective_date)
701       ,p_language_code               => l_language_code
702       ,p_application_id              => p_application_id
703       ,p_form_id                     => p_form_id
704       ,p_template_name               => p_template_name
705       ,p_enabled_flag                => p_enabled_flag
706       ,p_user_template_name          => p_user_template_name
707       ,p_description                 => p_description
708       ,p_legislation_code            => p_legislation_code
709       ,p_attribute_category          => p_attribute_category
710       ,p_attribute1                  => p_attribute1
711       ,p_attribute2                  => p_attribute2
712       ,p_attribute3                  => p_attribute3
713       ,p_attribute4                  => p_attribute4
714       ,p_attribute5                  => p_attribute5
715       ,p_attribute6                  => p_attribute6
716       ,p_attribute7                  => p_attribute7
717       ,p_attribute8                  => p_attribute8
718       ,p_attribute9                  => p_attribute9
719       ,p_attribute10                 => p_attribute10
720       ,p_attribute11                 => p_attribute11
721       ,p_attribute12                 => p_attribute12
722       ,p_attribute13                 => p_attribute13
723       ,p_attribute14                 => p_attribute14
724       ,p_attribute15                 => p_attribute15
725       ,p_attribute16                 => p_attribute16
726       ,p_attribute17                 => p_attribute17
727       ,p_attribute18                 => p_attribute18
728       ,p_attribute19                 => p_attribute19
729       ,p_attribute20                 => p_attribute20
730       ,p_attribute21                 => p_attribute21
731       ,p_attribute22                 => p_attribute22
732       ,p_attribute23                 => p_attribute23
733       ,p_attribute24                 => p_attribute24
737       ,p_attribute28                 => p_attribute28
734       ,p_attribute25                 => p_attribute25
735       ,p_attribute26                 => p_attribute26
736       ,p_attribute27                 => p_attribute27
738       ,p_attribute29                 => p_attribute29
739       ,p_attribute30                 => p_attribute30
740       ,p_help_target                 => p_help_target
741       ,p_information_category        => p_information_category
742       ,p_information1                => p_information1
743       ,p_information2                => p_information2
744       ,p_information3                => p_information3
745       ,p_information4                => p_information4
746       ,p_information5                => p_information5
747       ,p_information6                => p_information6
748       ,p_information7                => p_information7
749       ,p_information8                => p_information8
750       ,p_information9                => p_information9
751       ,p_information10               => p_information10
752       ,p_information11               => p_information11
753       ,p_information12               => p_information12
754       ,p_information13               => p_information13
755       ,p_information14               => p_information14
756       ,p_information15               => p_information15
757       ,p_information16               => p_information16
758       ,p_information17               => p_information17
759       ,p_information18               => p_information18
760       ,p_information19               => p_information19
761       ,p_information20               => p_information20
762       ,p_information21               => p_information21
763       ,p_information22               => p_information22
764       ,p_information23               => p_information23
765       ,p_information24               => p_information24
766       ,p_information25               => p_information25
767       ,p_information26               => p_information26
768       ,p_information27               => p_information27
769       ,p_information28               => p_information28
770       ,p_information29               => p_information29
771       ,p_information30               => p_information30);
772   exception
773     when hr_api.cannot_find_prog_unit then
774       hr_api.cannot_find_prog_unit_error
775         (p_module_name => 'create_template'
776         ,p_hook_type   => 'BP'
777         );
778   end;
779   --
780   -- Process Logic
781   --
782   hr_utility.set_location(' At:'||l_proc, 20);
783 
784   hr_tmp_ins.ins( p_effective_date           => TRUNC(p_effective_date)
785              ,p_application_id               => p_application_id
786              ,p_form_id                      => p_form_id
787              ,p_template_name                => p_template_name
788              ,p_enabled_flag                 => p_enabled_flag
789              ,p_legislation_code             => p_legislation_code
790              ,p_attribute_category           => p_attribute_category
791              ,p_attribute1                   => p_attribute1
792              ,p_attribute2                   => p_attribute2
793              ,p_attribute3                   => p_attribute3
794              ,p_attribute4                   => p_attribute4
795              ,p_attribute5                   => p_attribute5
796              ,p_attribute6                   => p_attribute6
797              ,p_attribute7                   => p_attribute7
798              ,p_attribute8                   => p_attribute8
799              ,p_attribute9                   => p_attribute9
800              ,p_attribute10                  => p_attribute10
801              ,p_attribute11                  => p_attribute11
802              ,p_attribute12                  => p_attribute12
803              ,p_attribute13                  => p_attribute13
804              ,p_attribute14                  => p_attribute14
805              ,p_attribute15                  => p_attribute15
806              ,p_attribute16                  => p_attribute16
807              ,p_attribute17                  => p_attribute17
808              ,p_attribute18                  => p_attribute18
809              ,p_attribute19                  => p_attribute19
810              ,p_attribute20                  => p_attribute20
811              ,p_attribute21                  => p_attribute21
812              ,p_attribute22                  => p_attribute22
813              ,p_attribute23                  => p_attribute23
814              ,p_attribute24                  => p_attribute24
815              ,p_attribute25                  => p_attribute25
816              ,p_attribute26                  => p_attribute26
817              ,p_attribute27                  => p_attribute27
818              ,p_attribute28                  => p_attribute28
819              ,p_attribute29                  => p_attribute29
820              ,p_attribute30                  => p_attribute30
821              ,p_form_template_id             => l_form_template_id
822              ,p_object_version_number        => l_object_version_number);
823 
824   hr_utility.set_location(' At:'||l_proc, 25);
825 
826   hr_tmt_ins.ins_tl( p_language_code                => l_language_code
827              ,p_form_template_id             => l_form_template_id
828              ,p_user_template_name           => p_user_template_name
829              ,p_description                  => p_description);
830 
831   hr_utility.set_location(' At:'||l_proc, 30);
832 
833   hr_form_properties_bsi.copy_form_property(
834              p_effective_date                => TRUNC(p_effective_date)
835              ,p_application_id               => p_application_id
836              ,p_form_id                      => p_form_id
837              ,p_form_template_id             => l_form_template_id
838              ,p_help_target                  => p_help_target
839              ,p_information_category         => p_information_category
843              ,p_information4                 => p_information4
840              ,p_information1                 => p_information1
841              ,p_information2                 => p_information2
842              ,p_information3                 => p_information3
844              ,p_information5                 => p_information5
845              ,p_information6                 => p_information6
846              ,p_information7                 => p_information7
847              ,p_information8                 => p_information8
848              ,p_information9                 => p_information9
849              ,p_information10                => p_information10
850              ,p_information11                => p_information11
851              ,p_information12                => p_information12
852              ,p_information13                => p_information13
853              ,p_information14                => p_information14
854              ,p_information15                => p_information15
855              ,p_information16                => p_information16
856              ,p_information17                => p_information17
857              ,p_information18                => p_information18
858              ,p_information19                => p_information19
859              ,p_information20                => p_information20
860              ,p_information21                => p_information21
861              ,p_information22                => p_information22
862              ,p_information23                => p_information23
863              ,p_information24                => p_information24
864              ,p_information25                => p_information25
865              ,p_information26                => p_information26
866              ,p_information27                => p_information27
867              ,p_information28                => p_information28
868              ,p_information29                => p_information29
869              ,p_information30                => p_information30
870              ,p_form_property_id             => l_form_property_id
871              ,p_object_version_number        => l_object_version_number);
872 
873   hr_utility.set_location(' At:'||l_proc, 30);
874 
875    IF g_session_mode <> 'SEED_DATA' THEN
876 
877      hr_source_form_templates_bsi.create_source_form_template(
878                 p_effective_date                => TRUNC(p_effective_date)
879                 ,p_form_template_id_to          => l_form_template_id
880                 ,p_form_template_id_from        => NULL
881                 ,p_source_form_template_id      => l_source_form_template_id
882                 ,p_object_version_number        => l_object_version_number);
883    END IF;
884 
885   --
886   -- Call After Process User Hook
887   --
888   begin
889     hr_form_templates_api_bk2.create_template_a
890       (p_effective_date              => TRUNC(p_effective_date)
891       ,p_language_code               => l_language_code
892       ,p_application_id              => p_application_id
893       ,p_form_id                     => p_form_id
894       ,p_template_name               => p_template_name
895       ,p_enabled_flag                => p_enabled_flag
896       ,p_user_template_name          => p_user_template_name
897       ,p_description                 => p_description
898       ,p_legislation_code            => p_legislation_code
899       ,p_attribute_category          => p_attribute_category
900       ,p_attribute1                  => p_attribute1
901       ,p_attribute2                  => p_attribute2
902       ,p_attribute3                  => p_attribute3
903       ,p_attribute4                  => p_attribute4
904       ,p_attribute5                  => p_attribute5
905       ,p_attribute6                  => p_attribute6
906       ,p_attribute7                  => p_attribute7
907       ,p_attribute8                  => p_attribute8
908       ,p_attribute9                  => p_attribute9
909       ,p_attribute10                 => p_attribute10
910       ,p_attribute11                 => p_attribute11
911       ,p_attribute12                 => p_attribute12
912       ,p_attribute13                 => p_attribute13
913       ,p_attribute14                 => p_attribute14
914       ,p_attribute15                 => p_attribute15
915       ,p_attribute16                 => p_attribute16
916       ,p_attribute17                 => p_attribute17
917       ,p_attribute18                 => p_attribute18
918       ,p_attribute19                 => p_attribute19
919       ,p_attribute20                 => p_attribute20
920       ,p_attribute21                 => p_attribute21
921       ,p_attribute22                 => p_attribute22
922       ,p_attribute23                 => p_attribute23
923       ,p_attribute24                 => p_attribute24
924       ,p_attribute25                 => p_attribute25
925       ,p_attribute26                 => p_attribute26
926       ,p_attribute27                 => p_attribute27
927       ,p_attribute28                 => p_attribute28
928       ,p_attribute29                 => p_attribute29
929       ,p_attribute30                 => p_attribute30
930       ,p_help_target                 => p_help_target
931       ,p_information_category        => p_information_category
932       ,p_information1                => p_information1
933       ,p_information2                => p_information2
934       ,p_information3                => p_information3
935       ,p_information4                => p_information4
936       ,p_information5                => p_information5
937       ,p_information6                => p_information6
938       ,p_information7                => p_information7
939       ,p_information8                => p_information8
940       ,p_information9                => p_information9
941       ,p_information10               => p_information10
942       ,p_information11               => p_information11
943       ,p_information12               => p_information12
947       ,p_information16               => p_information16
944       ,p_information13               => p_information13
945       ,p_information14               => p_information14
946       ,p_information15               => p_information15
948       ,p_information17               => p_information17
949       ,p_information18               => p_information18
950       ,p_information19               => p_information19
951       ,p_information20               => p_information20
952       ,p_information21               => p_information21
953       ,p_information22               => p_information22
954       ,p_information23               => p_information23
955       ,p_information24               => p_information24
956       ,p_information25               => p_information25
957       ,p_information26               => p_information26
958       ,p_information27               => p_information27
959       ,p_information28               => p_information28
960       ,p_information29               => p_information29
961       ,p_information30               => p_information30
962       ,p_form_template_id            => l_form_template_id
963       ,p_object_version_number       => l_object_version_number);
964 
965   exception
966     when hr_api.cannot_find_prog_unit then
967       hr_api.cannot_find_prog_unit_error
968         (p_module_name => 'create_template'
969         ,p_hook_type   => 'AP'
970         );
971   end;
972   --
973   -- When in validation only mode raise the Validate_Enabled exception
974   --
975   if p_validate then
976     raise hr_api.validate_enabled;
977   end if;
978   --
979   -- Set all output arguments
980   --
981   p_form_template_id            := l_form_template_id;
982   p_object_version_number       := l_object_version_number;
983   --
984   hr_utility.set_location(' Leaving:'||l_proc, 70);
985 exception
986   when hr_api.validate_enabled then
987     --
988     -- As the Validate_Enabled exception has been raised
989     -- we must rollback to the savepoint
990     --
991     rollback to create_template;
992     --
993     -- Only set output warning arguments
994     -- (Any key or derived arguments must be set to null
995     -- when validation only mode is being used.)
996     --
997     p_form_template_id       := null;
998     p_object_version_number  := null;
999     hr_utility.set_location(' Leaving:'||l_proc, 80);
1000   when others then
1001     --
1002     -- A validation or unexpected error has occured
1003     --
1004      p_form_template_id       := null;
1005     p_object_version_number  := null;
1006 
1007     rollback to create_template;
1008     hr_utility.set_location(' Leaving:'||l_proc, 90);
1009     raise;
1010 end create_template;
1011 --
1012 -- ----------------------------------------------------------------------------
1013 -- |--------------------------< delete_template >--------------------------|
1014 -- ----------------------------------------------------------------------------
1015 --
1016 procedure delete_template
1017   (p_validate                      in boolean  default false
1018   ,p_form_template_id              in number
1019   ,p_object_version_number         in number
1020   ,p_delete_children_flag          in varchar2 default 'N'
1021   ) is
1022   --
1023   -- Declare cursors and local variables
1024   --
1025 
1026   CURSOR cur_del_item
1027   IS
1028   SELECT template_item_id
1029   ,object_version_number
1030   FROM hr_template_items
1031   WHERE form_template_id = p_form_template_id;
1032 
1033   CURSOR cur_del_win
1034   IS
1035   SELECT template_window_id
1036   ,object_version_number
1037   FROM hr_template_windows
1038   WHERE form_template_id = p_form_template_id;
1039 
1040   CURSOR cur_del_data_group
1041   IS
1042   SELECT template_data_group_id
1043   ,object_version_number
1044   FROM hr_template_data_groups
1045   WHERE form_template_id = p_form_template_id;
1046 
1047   CURSOR cur_del_form_tmplt
1048   IS
1049   SELECT source_form_template_id
1050   FROM hr_source_form_templates
1051   WHERE form_template_id_to = p_form_template_id;
1052 
1053   l_temp number;
1054 
1055   CURSOR cur_api_val
1056   IS
1057   SELECT source_form_template_id
1058   FROM hr_source_form_templates hsf
1059   WHERE hsf.form_template_id_to = p_form_template_id;
1060 
1061   l_proc                varchar2(72) := g_package||'delete_template';
1062 begin
1063   hr_utility.set_location('Entering:'|| l_proc, 10);
1064   --
1065   -- Issue a savepoint
1066   --
1067   savepoint delete_template;
1068   --
1069   -- Call Before Process User Hook
1070   --
1071   begin
1072     hr_form_templates_api_bk3.delete_template_b
1073       (p_form_template_id       => p_form_template_id
1074        ,p_object_version_number => p_object_version_number
1075        ,p_delete_children_flag  => p_delete_children_flag
1076       );
1077   exception
1078     when hr_api.cannot_find_prog_unit then
1079       hr_api.cannot_find_prog_unit_error
1080         (p_module_name => 'delete_template'
1081         ,p_hook_type   => 'BP'
1082         );
1083   end;
1084   --
1085   -- extra validation
1086   hr_utility.set_location('At:'|| l_proc, 20);
1087      OPEN cur_api_val;
1088      FETCH cur_api_val INTO l_temp;
1089      IF (cur_api_val%NOTFOUND AND
1090          hr_form_templates_api.g_session_mode <> 'SEED_DATA') THEN
1091          CLOSE cur_api_val;
1092        -- error message
1093        fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
1094        fnd_message.set_token('PROCEDURE', l_proc);
1095        fnd_message.set_token('STEP','10');
1096        fnd_message.raise_error;
1097      END IF;
1101   -- Process Logic
1098      CLOSE cur_api_val;
1099   --
1100   --
1102   --
1103   hr_utility.set_location('At:'|| l_proc, 30);
1104 
1105   hr_tmp_shd.lck( p_form_template_id             => p_form_template_id
1106                  ,p_object_version_number        => p_object_version_number);
1107 
1108   hr_utility.set_location('At:'|| l_proc, 40);
1109   IF p_delete_children_flag = 'Y' THEN
1110     hr_utility.set_location('At:'|| l_proc, 50);
1111 
1112     FOR cur_rec in cur_del_item LOOP
1113       hr_template_items_api.delete_template_item(
1114                  p_template_item_id             => cur_rec.template_item_id
1115                 ,p_object_version_number        => cur_rec.object_version_number
1116                 ,p_delete_children_flag         => p_delete_children_flag);
1117     END LOOP;
1118 
1119     hr_utility.set_location('At:'|| l_proc, 60);
1120 
1121     FOR cur_rec in cur_del_win LOOP
1122       hr_template_windows_api.delete_template_window(
1123                 p_template_window_id           => cur_rec.template_window_id
1124                 ,p_object_version_number        => cur_rec.object_version_number
1125                 ,p_delete_children_flag         => p_delete_children_flag);
1126     END LOOP;
1127 
1128     hr_utility.set_location('At:'|| l_proc, 70);
1129 
1130     FOR cur_rec in cur_del_data_group LOOP
1131       hr_template_data_groups_api.delete_template_data_group(
1132                p_template_data_group_id       => cur_rec.template_data_group_id
1133                ,p_object_version_number        => cur_rec.object_version_number);
1134     END LOOP;
1135   END IF;
1136 
1137   hr_utility.set_location('At:'|| l_proc, 80);
1138 
1139   FOR cur_rec in cur_del_form_tmplt LOOP
1140     hr_source_form_templates_bsi.delete_source_form_template
1141            (p_source_form_template_id      => cur_rec.source_form_template_id
1142            ,p_object_version_number        => p_object_version_number);
1143   END LOOP;
1144 
1145   hr_utility.set_location('At:'|| l_proc, 81);
1146 
1147   hr_form_properties_bsi.delete_form_property
1148              (p_form_template_id             => p_form_template_id
1149              ,p_object_version_number        => p_object_version_number);
1150 
1151   hr_utility.set_location('At:'|| l_proc, 82);
1152 
1153   hr_tmt_del.del_tl(p_form_template_id             => p_form_template_id);
1154 
1155   hr_utility.set_location('At:'|| l_proc, 83);
1156 
1157   hr_tmp_del.del( p_form_template_id             => p_form_template_id
1158                  ,p_object_version_number        => p_object_version_number);
1159 
1160   hr_utility.set_location('At:'|| l_proc, 84);
1161 
1162   --
1163   -- Call After Process User Hook
1164   --
1165   begin
1166     hr_form_templates_api_bk3.delete_template_a
1167       (p_form_template_id       => p_form_template_id
1168        ,p_object_version_number => p_object_version_number
1169        ,p_delete_children_flag  => p_delete_children_flag
1170       );
1171   exception
1172     when hr_api.cannot_find_prog_unit then
1173       hr_api.cannot_find_prog_unit_error
1174         (p_module_name => 'delete_template'
1175         ,p_hook_type   => 'AP'
1176         );
1177   end;
1178   --
1179   -- When in validation only mode raise the Validate_Enabled exception
1180   --
1181   hr_utility.set_location('At:'|| l_proc, 85);
1182 
1183   if p_validate then
1184     raise hr_api.validate_enabled;
1185   end if;
1186   --
1187   hr_utility.set_location(' Leaving:'||l_proc, 90);
1188 exception
1189   when hr_api.validate_enabled then
1190     --
1191     -- As the Validate_Enabled exception has been raised
1192     -- we must rollback to the savepoint
1193     --
1194     rollback to delete_template;
1195     --
1196     -- Only set output warning arguments
1197     -- (Any key or derived arguments must be set to null
1198     -- when validation only mode is being used.)
1199     --
1200     hr_utility.set_location(' Leaving:'||l_proc, 91);
1201   when others then
1202     --
1203     -- A validation or unexpected error has occured
1204     --
1205     rollback to delete_template;
1206     hr_utility.set_location(' Leaving:'||l_proc, 92);
1207     raise;
1208 end delete_template;
1209 --
1210 -- ----------------------------------------------------------------------------
1211 -- |--------------------------< update_template >--------------------------|
1212 -- ----------------------------------------------------------------------------
1213 --
1214 procedure update_template
1215   (p_validate                     in boolean  default false
1216   ,p_effective_date               in date
1217   ,p_form_template_id             in number
1218   ,p_object_version_number        in out nocopy number
1219   ,p_language_code                in varchar2 default hr_api.userenv_lang
1220   ,p_template_name                in varchar2 default hr_api.g_varchar2
1221   ,p_enabled_flag                 in varchar2 default hr_api.g_varchar2
1222   ,p_user_template_name           in varchar2 default hr_api.g_varchar2
1223   ,p_description                  in varchar2 default hr_api.g_varchar2
1224   ,p_legislation_code             in varchar2 default hr_api.g_varchar2
1225   ,p_attribute_category           in varchar2 default hr_api.g_varchar2
1226   ,p_attribute1                   in varchar2 default hr_api.g_varchar2
1227   ,p_attribute2                   in varchar2 default hr_api.g_varchar2
1228   ,p_attribute3                   in varchar2 default hr_api.g_varchar2
1229   ,p_attribute4                   in varchar2 default hr_api.g_varchar2
1230   ,p_attribute5                   in varchar2 default hr_api.g_varchar2
1231   ,p_attribute6                   in varchar2 default hr_api.g_varchar2
1232   ,p_attribute7                   in varchar2 default hr_api.g_varchar2
1233   ,p_attribute8                   in varchar2 default hr_api.g_varchar2
1234   ,p_attribute9                   in varchar2 default hr_api.g_varchar2
1235   ,p_attribute10                  in varchar2 default hr_api.g_varchar2
1236   ,p_attribute11                  in varchar2 default hr_api.g_varchar2
1237   ,p_attribute12                  in varchar2 default hr_api.g_varchar2
1238   ,p_attribute13                  in varchar2 default hr_api.g_varchar2
1239   ,p_attribute14                  in varchar2 default hr_api.g_varchar2
1240   ,p_attribute15                  in varchar2 default hr_api.g_varchar2
1241   ,p_attribute16                  in varchar2 default hr_api.g_varchar2
1242   ,p_attribute17                  in varchar2 default hr_api.g_varchar2
1243   ,p_attribute18                  in varchar2 default hr_api.g_varchar2
1244   ,p_attribute19                  in varchar2 default hr_api.g_varchar2
1245   ,p_attribute20                  in varchar2 default hr_api.g_varchar2
1246   ,p_attribute21                  in varchar2 default hr_api.g_varchar2
1247   ,p_attribute22                  in varchar2 default hr_api.g_varchar2
1248   ,p_attribute23                  in varchar2 default hr_api.g_varchar2
1249   ,p_attribute24                  in varchar2 default hr_api.g_varchar2
1250   ,p_attribute25                  in varchar2 default hr_api.g_varchar2
1251   ,p_attribute26                  in varchar2 default hr_api.g_varchar2
1252   ,p_attribute27                  in varchar2 default hr_api.g_varchar2
1253   ,p_attribute28                  in varchar2 default hr_api.g_varchar2
1254   ,p_attribute29                  in varchar2 default hr_api.g_varchar2
1255   ,p_attribute30                  in varchar2 default hr_api.g_varchar2
1256   ,p_help_target                  in varchar2 default hr_api.g_varchar2
1257   ,p_information_category         in varchar2 default hr_api.g_varchar2
1258   ,p_information1                 in varchar2 default hr_api.g_varchar2
1259   ,p_information2                 in varchar2 default hr_api.g_varchar2
1260   ,p_information3                 in varchar2 default hr_api.g_varchar2
1261   ,p_information4                 in varchar2 default hr_api.g_varchar2
1262   ,p_information5                 in varchar2 default hr_api.g_varchar2
1263   ,p_information6                 in varchar2 default hr_api.g_varchar2
1264   ,p_information7                 in varchar2 default hr_api.g_varchar2
1265   ,p_information8                 in varchar2 default hr_api.g_varchar2
1266   ,p_information9                 in varchar2 default hr_api.g_varchar2
1267   ,p_information10                in varchar2 default hr_api.g_varchar2
1268   ,p_information11                in varchar2 default hr_api.g_varchar2
1269   ,p_information12                in varchar2 default hr_api.g_varchar2
1270   ,p_information13                in varchar2 default hr_api.g_varchar2
1271   ,p_information14                in varchar2 default hr_api.g_varchar2
1272   ,p_information15                in varchar2 default hr_api.g_varchar2
1273   ,p_information16                in varchar2 default hr_api.g_varchar2
1274   ,p_information17                in varchar2 default hr_api.g_varchar2
1275   ,p_information18                in varchar2 default hr_api.g_varchar2
1276   ,p_information19                in varchar2 default hr_api.g_varchar2
1277   ,p_information20                in varchar2 default hr_api.g_varchar2
1278   ,p_information21                in varchar2 default hr_api.g_varchar2
1279   ,p_information22                in varchar2 default hr_api.g_varchar2
1280   ,p_information23                in varchar2 default hr_api.g_varchar2
1281   ,p_information24                in varchar2 default hr_api.g_varchar2
1282   ,p_information25                in varchar2 default hr_api.g_varchar2
1283   ,p_information26                in varchar2 default hr_api.g_varchar2
1284   ,p_information27                in varchar2 default hr_api.g_varchar2
1285   ,p_information28                in varchar2 default hr_api.g_varchar2
1286   ,p_information29                in varchar2 default hr_api.g_varchar2
1287   ,p_information30                in varchar2 default hr_api.g_varchar2
1288   ) is
1289   --
1290   -- Declare cursors and local variables
1291   --
1292 
1293   l_temp number;
1294   l_language_code fnd_languages.language_code%TYPE;
1295 
1296 
1297   CURSOR cur_api_val
1298   IS
1299   SELECT source_form_template_id
1300   FROM hr_source_form_templates hsf
1301   WHERE hsf.form_template_id_to = p_form_template_id;
1302 
1303   l_proc                varchar2(72) := g_package||'update_template';
1304   l_object_version_number number;
1305 begin
1306   hr_utility.set_location('Entering:'|| l_proc, 10);
1307   --
1308   -- Issue a savepoint
1309   --
1310   savepoint update_template;
1311   --
1312   -- Truncate the time portion from all IN date parameters
1313   --
1314      -- p_effective_date := TRUNC(p_effective_date);
1315      l_object_version_number := p_object_version_number;
1316   --
1317   -- Validate the language parameter. l_language_code should be passed
1318   -- instead of p_language_code from now on, to allow an IN OUT parameter to
1319   -- be passed through.
1320   --
1321   l_language_code := p_language_code;
1322   hr_api.validate_language_code(p_language_code => l_language_code);
1323   --
1324   hr_utility.set_location(l_proc, 20);
1325   --
1326   --
1327   -- Call Before Process User Hook
1328   --
1329   begin
1330     hr_form_templates_api_bk4.update_template_b
1331       (p_effective_date              => TRUNC(p_effective_date)
1332       ,p_form_template_id            => p_form_template_id
1333       ,p_object_version_number       => l_object_version_number
1334       ,p_language_code               => l_language_code
1335       ,p_template_name               => p_template_name
1336       ,p_enabled_flag                => p_enabled_flag
1337       ,p_user_template_name          => p_user_template_name
1338       ,p_description                 => p_description
1339       ,p_legislation_code            => p_legislation_code
1340       ,p_attribute_category          => p_attribute_category
1341       ,p_attribute1                  => p_attribute1
1342       ,p_attribute2                  => p_attribute2
1343       ,p_attribute3                  => p_attribute3
1344       ,p_attribute4                  => p_attribute4
1345       ,p_attribute5                  => p_attribute5
1346       ,p_attribute6                  => p_attribute6
1347       ,p_attribute7                  => p_attribute7
1348       ,p_attribute8                  => p_attribute8
1349       ,p_attribute9                  => p_attribute9
1350       ,p_attribute10                 => p_attribute10
1351       ,p_attribute11                 => p_attribute11
1352       ,p_attribute12                 => p_attribute12
1353       ,p_attribute13                 => p_attribute13
1354       ,p_attribute14                 => p_attribute14
1355       ,p_attribute15                 => p_attribute15
1356       ,p_attribute16                 => p_attribute16
1357       ,p_attribute17                 => p_attribute17
1358       ,p_attribute18                 => p_attribute18
1359       ,p_attribute19                 => p_attribute19
1360       ,p_attribute20                 => p_attribute20
1361       ,p_attribute21                 => p_attribute21
1362       ,p_attribute22                 => p_attribute22
1363       ,p_attribute23                 => p_attribute23
1364       ,p_attribute24                 => p_attribute24
1365       ,p_attribute25                 => p_attribute25
1366       ,p_attribute26                 => p_attribute26
1367       ,p_attribute27                 => p_attribute27
1368       ,p_attribute28                 => p_attribute28
1369       ,p_attribute29                 => p_attribute29
1370       ,p_attribute30                 => p_attribute30
1371       ,p_help_target                 => p_help_target
1372       ,p_information_category        => p_information_category
1373       ,p_information1                => p_information1
1374       ,p_information2                => p_information2
1375       ,p_information3                => p_information3
1376       ,p_information4                => p_information4
1377       ,p_information5                => p_information5
1378       ,p_information6                => p_information6
1379       ,p_information7                => p_information7
1380       ,p_information8                => p_information8
1381       ,p_information9                => p_information9
1382       ,p_information10               => p_information10
1383       ,p_information11               => p_information11
1384       ,p_information12               => p_information12
1385       ,p_information13               => p_information13
1386       ,p_information14               => p_information14
1387       ,p_information15               => p_information15
1388       ,p_information16               => p_information16
1389       ,p_information17               => p_information17
1390       ,p_information18               => p_information18
1391       ,p_information19               => p_information19
1392       ,p_information20               => p_information20
1393       ,p_information21               => p_information21
1394       ,p_information22               => p_information22
1395       ,p_information23               => p_information23
1396       ,p_information24               => p_information24
1397       ,p_information25               => p_information25
1401       ,p_information29               => p_information29
1398       ,p_information26               => p_information26
1399       ,p_information27               => p_information27
1400       ,p_information28               => p_information28
1402       ,p_information30               => p_information30);
1403   exception
1404     when hr_api.cannot_find_prog_unit then
1405       hr_api.cannot_find_prog_unit_error
1406         (p_module_name => 'update_template'
1407         ,p_hook_type   => 'BP'
1408         );
1409   end;
1410   -- Extra Validation
1411   hr_utility.set_location('At:'|| l_proc, 20);
1412 
1413      OPEN cur_api_val;
1414      FETCH cur_api_val INTO l_temp;
1415      IF (cur_api_val%NOTFOUND AND
1416          hr_form_templates_api.g_session_mode <> 'SEED_DATA') THEN
1417          CLOSE cur_api_val;
1418        -- error message
1419        fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
1420        fnd_message.set_token('PROCEDURE', l_proc);
1421        fnd_message.set_token('STEP','10');
1422        fnd_message.raise_error;
1423      END IF;
1424      CLOSE cur_api_val;
1425   --
1426   -- Process Logic
1427   --
1428 
1429   hr_utility.set_location('At:'|| l_proc, 30);
1430 
1431   hr_tmp_upd.upd( p_effective_date           => TRUNC(p_effective_date)
1432              ,p_form_template_id             => p_form_template_id
1433              ,p_template_name                => p_template_name
1434              ,p_enabled_flag                 => p_enabled_flag
1435              ,p_legislation_code             => p_legislation_code
1436              ,p_attribute_category           => p_attribute_category
1437              ,p_attribute1                   => p_attribute1
1438              ,p_attribute2                   => p_attribute2
1439              ,p_attribute3                   => p_attribute3
1440              ,p_attribute4                   => p_attribute4
1441              ,p_attribute5                   => p_attribute5
1442              ,p_attribute6                   => p_attribute6
1443              ,p_attribute7                   => p_attribute7
1444              ,p_attribute8                   => p_attribute8
1445              ,p_attribute9                   => p_attribute9
1446              ,p_attribute10                  => p_attribute10
1447              ,p_attribute11                  => p_attribute11
1448              ,p_attribute12                  => p_attribute12
1449              ,p_attribute13                  => p_attribute13
1450              ,p_attribute14                  => p_attribute14
1451              ,p_attribute15                  => p_attribute15
1452              ,p_attribute16                  => p_attribute16
1453              ,p_attribute17                  => p_attribute17
1454              ,p_attribute18                  => p_attribute18
1455              ,p_attribute19                  => p_attribute19
1456              ,p_attribute20                  => p_attribute20
1457              ,p_attribute21                  => p_attribute21
1458              ,p_attribute22                  => p_attribute22
1459              ,p_attribute23                  => p_attribute23
1460              ,p_attribute24                  => p_attribute24
1461              ,p_attribute25                  => p_attribute25
1462              ,p_attribute26                  => p_attribute26
1463              ,p_attribute27                  => p_attribute27
1464              ,p_attribute28                  => p_attribute28
1465              ,p_attribute29                  => p_attribute29
1466              ,p_attribute30                  => p_attribute30
1467              ,p_object_version_number        => l_object_version_number);
1468 
1469   hr_utility.set_location('At:'|| l_proc, 35);
1470 
1471   hr_tmt_upd.upd_tl( p_language_code                => l_language_code
1472              ,p_form_template_id             => p_form_template_id
1473              ,p_user_template_name           => p_user_template_name
1474              ,p_description                  => p_description);
1475 
1476   hr_utility.set_location('At:'|| l_proc, 40);
1477 
1478   l_object_version_number := p_object_version_number; --3211362
1479 
1480   hr_form_properties_bsi.update_form_property(
1481              p_effective_date                => TRUNC(p_effective_date)
1482              ,p_object_version_number        => l_object_version_number
1483              ,p_form_template_id             => p_form_template_id
1484              ,p_help_target                  => p_help_target
1485              ,p_information_category         => p_information_category
1486              ,p_information1                 => p_information1
1487              ,p_information2                 => p_information2
1488              ,p_information3                 => p_information3
1489              ,p_information4                 => p_information4
1490              ,p_information5                 => p_information5
1491              ,p_information6                 => p_information6
1492              ,p_information7                 => p_information7
1493              ,p_information8                 => p_information8
1494              ,p_information9                 => p_information9
1495              ,p_information10                => p_information10
1496              ,p_information11                => p_information11
1497              ,p_information12                => p_information12
1498              ,p_information13                => p_information13
1499              ,p_information14                => p_information14
1500              ,p_information15                => p_information15
1501              ,p_information16                => p_information16
1502              ,p_information17                => p_information17
1503              ,p_information18                => p_information18
1504              ,p_information19                => p_information19
1505              ,p_information20                => p_information20
1506              ,p_information21                => p_information21
1507              ,p_information22                => p_information22
1508              ,p_information23                => p_information23
1509              ,p_information24                => p_information24
1510              ,p_information25                => p_information25
1511              ,p_information26                => p_information26
1512              ,p_information27                => p_information27
1513              ,p_information28                => p_information28
1514              ,p_information29                => p_information29
1515              ,p_information30                => p_information30);
1516 
1517   --
1518   -- Call After Process User Hook
1519   --
1520   begin
1521     hr_form_templates_api_bk4.update_template_a
1522       (p_effective_date              => TRUNC(p_effective_date)
1523       ,p_form_template_id            => p_form_template_id
1524       ,p_object_version_number       => l_object_version_number
1525       ,p_language_code               => l_language_code
1526       ,p_template_name               => p_template_name
1527       ,p_enabled_flag                => p_enabled_flag
1528       ,p_user_template_name          => p_user_template_name
1529       ,p_description                 => p_description
1530       ,p_legislation_code            => p_legislation_code
1531       ,p_attribute_category          => p_attribute_category
1532       ,p_attribute1                  => p_attribute1
1533       ,p_attribute2                  => p_attribute2
1534       ,p_attribute3                  => p_attribute3
1535       ,p_attribute4                  => p_attribute4
1536       ,p_attribute5                  => p_attribute5
1537       ,p_attribute6                  => p_attribute6
1538       ,p_attribute7                  => p_attribute7
1539       ,p_attribute8                  => p_attribute8
1540       ,p_attribute9                  => p_attribute9
1541       ,p_attribute10                 => p_attribute10
1542       ,p_attribute11                 => p_attribute11
1543       ,p_attribute12                 => p_attribute12
1544       ,p_attribute13                 => p_attribute13
1545       ,p_attribute14                 => p_attribute14
1546       ,p_attribute15                 => p_attribute15
1547       ,p_attribute16                 => p_attribute16
1548       ,p_attribute17                 => p_attribute17
1549       ,p_attribute18                 => p_attribute18
1550       ,p_attribute19                 => p_attribute19
1551       ,p_attribute20                 => p_attribute20
1552       ,p_attribute21                 => p_attribute21
1553       ,p_attribute22                 => p_attribute22
1554       ,p_attribute23                 => p_attribute23
1555       ,p_attribute24                 => p_attribute24
1556       ,p_attribute25                 => p_attribute25
1557       ,p_attribute26                 => p_attribute26
1558       ,p_attribute27                 => p_attribute27
1559       ,p_attribute28                 => p_attribute28
1560       ,p_attribute29                 => p_attribute29
1561       ,p_attribute30                 => p_attribute30
1562       ,p_help_target                 => p_help_target
1563       ,p_information_category        => p_information_category
1564       ,p_information1                => p_information1
1565       ,p_information2                => p_information2
1566       ,p_information3                => p_information3
1567       ,p_information4                => p_information4
1568       ,p_information5                => p_information5
1569       ,p_information6                => p_information6
1570       ,p_information7                => p_information7
1571       ,p_information8                => p_information8
1572       ,p_information9                => p_information9
1573       ,p_information10               => p_information10
1574       ,p_information11               => p_information11
1575       ,p_information12               => p_information12
1576       ,p_information13               => p_information13
1577       ,p_information14               => p_information14
1578       ,p_information15               => p_information15
1579       ,p_information16               => p_information16
1580       ,p_information17               => p_information17
1581       ,p_information18               => p_information18
1582       ,p_information19               => p_information19
1583       ,p_information20               => p_information20
1584       ,p_information21               => p_information21
1585       ,p_information22               => p_information22
1586       ,p_information23               => p_information23
1587       ,p_information24               => p_information24
1588       ,p_information25               => p_information25
1589       ,p_information26               => p_information26
1590       ,p_information27               => p_information27
1591       ,p_information28               => p_information28
1592       ,p_information29               => p_information29
1593       ,p_information30               => p_information30);
1594   exception
1595     when hr_api.cannot_find_prog_unit then
1596       hr_api.cannot_find_prog_unit_error
1597         (p_module_name => 'update_template'
1598         ,p_hook_type   => 'AP'
1599         );
1600   end;
1601   --
1602   -- When in validation only mode raise the Validate_Enabled exception
1603   --
1604   if p_validate then
1605     raise hr_api.validate_enabled;
1606   end if;
1607   --
1608   -- Set all output arguments
1609   --
1610   p_object_version_number  := l_object_version_number;
1611   --
1612   hr_utility.set_location(' Leaving:'||l_proc, 70);
1613 exception
1614   when hr_api.validate_enabled then
1615     --
1616     -- As the Validate_Enabled exception has been raised
1617     -- we must rollback to the savepoint
1618     --
1619     rollback to update_template;
1620     --
1621     -- Only set output warning arguments
1622     -- (Any key or derived arguments must be set to null
1623     -- when validation only mode is being used.)
1624     --
1625     hr_utility.set_location(' Leaving:'||l_proc, 80);
1626   when others then
1627     --
1628     -- A validation or unexpected error has occured
1629     --
1630     rollback to update_template;
1631     hr_utility.set_location(' Leaving:'||l_proc, 90);
1632     raise;
1633 end update_template;
1634 --
1635 end hr_form_templates_api;