DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_TEMPLATE_ITEM_TAB_PAGES_API

Source


1 Package Body hr_template_item_tab_pages_api as
2 /* $Header: hrtfpapi.pkb 115.4 2002/12/18 06:15:25 raranjan noship $ */
3 --
4 -- Package Variables
5 --
6 g_package  varchar2(33) := '  hr_template_item_tab_pages_api.';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |-----------------------< create_template_item_tab_page >------------------|
10 -- ----------------------------------------------------------------------------
11 --
12 procedure create_template_item_tab_page
13   (p_validate                      in     boolean  default false
14   ,p_effective_date                in     date
15   ,p_template_item_id              in     number
16   ,p_template_tab_page_id          in     number
17   ,p_upd_template_item_contexts    in     boolean  default false
18   ,p_template_item_tab_page_id        out nocopy number
19   ,p_object_version_number            out nocopy number
20   ) is
21   --
22   -- Declare cursors and local variables
23   --
24 
25   l_temp number;
26 
27   CURSOR cur_api_val
28   IS
29   SELECT source_form_template_id
30   FROM hr_source_form_templates hsf
31        ,hr_template_items_b hti
32   WHERE hsf.form_template_id_to = hti.form_template_id
33   AND hti.template_item_id = p_template_item_id;
34 
35   CURSOR csr_template_item_contexts
36     (p_template_item_id            IN NUMBER
37     ,p_template_tab_page_id        IN NUMBER
38     )
39   IS
40     SELECT tic.template_item_context_id
41       FROM hr_template_item_contexts_b tic
42      WHERE NOT EXISTS (SELECT 0
43                          FROM hr_template_item_context_pages tcp
44                         WHERE tcp.template_tab_page_id = p_template_tab_page_id
45                           AND tcp.template_item_context_id = tic.template_item_context_id)
46        AND tic.template_item_id = p_template_item_id;
47   l_template_item_context        csr_template_item_contexts%ROWTYPE;
48 
49   l_template_item_context_page_i NUMBER;
50   l_tcp_object_version_number    NUMBER;
51 
52   l_object_version_number number;
53   l_template_item_Tab_page_id number;
54   l_proc                varchar2(72) := g_package||'create_template_item_tab_page';
55 begin
56   hr_utility.set_location('Entering:'|| l_proc, 10);
57   --
58   -- Issue a savepoint
59   --
60   savepoint create_template_item_tab_page;
61   --
62   -- Truncate the time portion from all IN date parameters
63   --
64     -- p_effective_date := TRUNC(p_effective_date);
65   --
66   -- Call Before Process User Hook
67   --
68   begin
69     hr_template_item_tab_pages_bk1.create_tip_b
70       (p_effective_date                => TRUNC(p_effective_date)
71        ,p_template_item_id             => p_template_item_id
72        ,p_template_tab_page_id         => p_template_tab_page_id
73       ,p_upd_template_item_contexts    => p_upd_template_item_contexts
74       );
75   exception
76     when hr_api.cannot_find_prog_unit then
77       hr_api.cannot_find_prog_unit_error
78         (p_module_name => 'create_template_item_tab_page'
79         ,p_hook_type   => 'BP'
80         );
81   end;
82   --
83   -- Validation in addition to Row Handlers
84   --
85 
86   hr_utility.set_location('At:'|| l_proc, 15);
87 
88      OPEN cur_api_val;
89      FETCH cur_api_val INTO l_temp;
90      IF (cur_api_val%NOTFOUND AND
91          hr_form_templates_api.g_session_mode <> 'SEED_DATA') THEN
92          CLOSE cur_api_val;
93        -- error message
94        fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
95        fnd_message.set_token('PROCEDURE', l_proc);
96        fnd_message.set_token('STEP','10');
97        fnd_message.raise_error;
98      END IF;
99      CLOSE cur_api_val;
100   --
101   -- Process Logic
102   --
103 
104   if (p_upd_template_item_contexts) then
105     for l_template_item_context in csr_template_item_contexts
106       (p_template_item_id     => p_template_item_id
107       ,p_template_tab_page_id => p_template_tab_page_id
108       )
109     loop
110       hr_tcp_api.create_tcp
111         (p_effective_date               => p_effective_date
112         ,p_template_item_context_id     => l_template_item_context.template_item_context_id
113         ,p_template_tab_page_id         => p_template_tab_page_id
114         ,p_template_item_context_page_i => l_template_item_context_page_i
115         ,p_object_version_number        => l_tcp_object_version_number
116         );
117     end loop;
118   end if;
119 
120   hr_utility.set_location('At:'|| l_proc, 20);
121 
122   hr_tip_ins.ins( p_template_item_id        => p_template_item_id
123                   ,p_template_tab_page_id         => p_template_tab_page_id
124                   ,p_template_item_tab_page_id    => l_template_item_tab_page_id
125                   ,p_object_version_number        => l_object_version_number);
126   --
127   -- Call After Process User Hook
128   --
129   hr_utility.set_location('At:'|| l_proc, 25);
130 
131   begin
132     hr_template_item_tab_pages_bk1.create_tip_a
133       (p_effective_date                => TRUNC(p_effective_date)
134        ,p_template_item_id             => p_template_item_id
135        ,p_template_tab_page_id         => p_template_tab_page_id
136        ,p_upd_template_item_contexts   => p_upd_template_item_contexts
137        ,p_template_item_tab_page_id    => l_template_item_tab_page_id
138        ,p_object_version_number        => l_object_version_number
139       );
140   exception
141     when hr_api.cannot_find_prog_unit then
142       hr_api.cannot_find_prog_unit_error
143         (p_module_name => 'create_template_item_tab_page'
144         ,p_hook_type   => 'AP'
145         );
146   end;
147   --
148   -- When in validation only mode raise the Validate_Enabled exception
149   --
150   if p_validate then
151     raise hr_api.validate_enabled;
152   end if;
153   --
154   -- Set all output arguments
155   --
156     p_template_item_tab_page_id    := l_template_item_tab_page_id;
157     p_object_version_number        := l_object_version_number;
158   --
159   hr_utility.set_location(' Leaving:'||l_proc, 70);
160 exception
161   when hr_api.validate_enabled then
162     --
163     -- As the Validate_Enabled exception has been raised
164     -- we must rollback to the savepoint
165     --
166     rollback to create_template_item_tab_page;
167     --
168     -- Only set output warning arguments
169     -- (Any key or derived arguments must be set to null
170     -- when validation only mode is being used.)
171     --
172     p_template_item_tab_page_id    := null;
173     p_object_version_number  := null;
174     hr_utility.set_location(' Leaving:'||l_proc, 80);
175   when others then
176     --
177     -- A validation or unexpected error has occured
178     --
179        p_template_item_tab_page_id    := null;
180     p_object_version_number  := null;
181 
182     rollback to create_template_item_tab_page;
183     hr_utility.set_location(' Leaving:'||l_proc, 90);
184     raise;
185 end create_template_item_tab_page;
186 --
187 -- ----------------------------------------------------------------------------
188 -- |-----------------------< delete_template_item_tab_page >------------------|
189 -- ----------------------------------------------------------------------------
190 --
191 procedure delete_template_item_tab_page
192   (p_validate                      in     boolean  default false
193   ,p_template_item_tab_page_id     in      number
194   ,p_object_version_number         in      number
195   ,p_upd_template_item_contexts    in     boolean  default false
196   ) is
197   --
198   -- Declare cursors and local variables
199   --
200   l_temp number;
201 
202   CURSOR cur_api_val
203   IS
204   SELECT source_form_template_id
205   FROM hr_source_form_templates hsf
206        ,hr_template_items_b hti
207        ,hr_template_item_tab_pages htit
208   WHERE hsf.form_template_id_to = hti.form_template_id
209   AND hti.template_item_id = htit.template_item_id
210   AND htit.template_item_tab_page_id = p_template_item_tab_page_id;
211 
212   CURSOR csr_template_item_context_page
213     (p_template_item_tab_page_id   IN NUMBER
214     )
215   IS
216     SELECT tcp.template_item_context_page_id
217           ,tcp.object_version_number
218       FROM hr_template_item_context_pages tcp
219           ,hr_template_item_contexts_b tic
220           ,hr_template_item_tab_pages tip
221      WHERE tcp.template_tab_page_id = tip.template_tab_page_id
222        AND tcp.template_item_context_id = tic.template_item_context_id
223        AND tic.template_item_id = tip.template_item_id
224        AND tip.template_item_tab_page_id = p_template_item_tab_page_id;
225   l_template_item_context_page csr_template_item_context_page%ROWTYPE;
226 
227   l_proc                varchar2(72) := g_package||'delete_template_item_tab_page';
228 begin
229   hr_utility.set_location('Entering:'|| l_proc, 10);
230   --
231   -- Issue a savepoint
232   --
233   savepoint delete_template_item_tab_page;
234 
235   --
236   -- Call Before Process User Hook
237   --
238   begin
239     hr_template_item_tab_pages_bk2.delete_tip_b
240       (p_template_item_tab_page_id     => p_template_item_tab_page_id
241        ,p_object_version_number        => p_object_version_number
242        ,p_upd_template_item_contexts   => p_upd_template_item_contexts
243       );
244   exception
245     when hr_api.cannot_find_prog_unit then
246       hr_api.cannot_find_prog_unit_error
247         (p_module_name => 'delete_template_item_tab_page'
248         ,p_hook_type   => 'BP'
249         );
250   end;
251   --
252   -- Validation in addition to Row Handlers
253   --
254   hr_utility.set_location('At:'|| l_proc, 15);
255 
256      OPEN cur_api_val;
257      FETCH cur_api_val INTO l_temp;
258      IF (cur_api_val%NOTFOUND AND
259          hr_form_templates_api.g_session_mode <> 'SEED_DATA') THEN
260          CLOSE cur_api_val;
261        -- error message
262        fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
263        fnd_message.set_token('PROCEDURE', l_proc);
264        fnd_message.set_token('STEP','10');
265        fnd_message.raise_error;
266      END IF;
267      CLOSE cur_api_val;
268   --
269   --
270   -- Process Logic
271   --
272 
273   if (p_upd_template_item_contexts) then
274     for l_template_item_context_page in csr_template_item_context_page
275       (p_template_item_tab_page_id => p_template_item_tab_page_id
276       )
277     loop
278       hr_tcp_api.delete_tcp
279         (p_template_item_context_page_i => l_template_item_context_page.template_item_context_page_id
280         ,p_object_version_number        => l_template_item_context_page.object_version_number
281         );
282     end loop;
283   end if;
284 
285   hr_utility.set_location('At:'|| l_proc, 20);
286 
287   hr_tip_del.del( p_template_item_tab_page_id    => p_template_item_tab_page_id
288                  ,p_object_version_number        => p_object_version_number);
289 
290   hr_utility.set_location('At:'|| l_proc, 30);
291 
292   --
293   -- Call After Process User Hook
294   --
295   begin
296     hr_template_item_tab_pages_bk2.delete_tip_a
297       (p_template_item_tab_page_id     => p_template_item_tab_page_id
298        ,p_object_version_number        => p_object_version_number
299        ,p_upd_template_item_contexts   => p_upd_template_item_contexts
300       );
301   exception
302     when hr_api.cannot_find_prog_unit then
303       hr_api.cannot_find_prog_unit_error
304         (p_module_name => 'delete_template_item_tab_page'
305         ,p_hook_type   => 'AP'
306         );
307   end;
308   --
309   -- When in validation only mode raise the Validate_Enabled exception
310   --
311   if p_validate then
312     raise hr_api.validate_enabled;
313   end if;
314   --
315   hr_utility.set_location(' Leaving:'||l_proc, 70);
316 exception
317   when hr_api.validate_enabled then
318     --
319     -- As the Validate_Enabled exception has been raised
320     -- we must rollback to the savepoint
321     --
322     rollback to delete_template_item_tab_page;
323     --
324     -- Only set output warning arguments
325     -- (Any key or derived arguments must be set to null
326     -- when validation only mode is being used.)
327     --
328     hr_utility.set_location(' Leaving:'||l_proc, 80);
329   when others then
330     --
331     -- A validation or unexpected error has occured
332     --
333     rollback to delete_template_item_tab_page;
334     hr_utility.set_location(' Leaving:'||l_proc, 90);
335     raise;
336 end delete_template_item_tab_page;
337 --
338 end hr_template_item_tab_pages_api;