DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_CALENDAR_ENTRY_API

Source


1 Package Body HR_CALENDAR_ENTRY_API as
2 /* $Header: peentapi.pkb 120.0 2005/05/31 08:08:02 appldev noship $ */
3 --
4 -- Package Variables
5 --
6 g_package  varchar2(22) := 'HR_CALENDAR_ENTRY_API.';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |-----------------------< create_calendar_entry >---------------------------|
10 -- ----------------------------------------------------------------------------
11 --
12  procedure create_calendar_entry
13   (p_validate                      in     boolean  default false
14   ,p_effective_date                in     date
15   ,p_name                          in     varchar2
16   ,p_type                          in     varchar2
17   ,p_start_date                    in     date
18   ,p_start_hour                    in     varchar2 default null
19   ,p_start_min                     in     varchar2 default null
20   ,p_end_date                      in     date
21   ,p_end_hour                      in     varchar2 default null
22   ,p_end_min                       in     varchar2 default null
23   ,p_business_group_id             in     number   default null
24   ,p_description                   in     varchar2 default null
25   ,p_hierarchy_id                  in     number   default null
26   ,p_value_set_id                  in     number   default null
27   ,p_organization_structure_id     in     number   default null
28   ,p_org_structure_version_id      in     number   default null
29   ,p_legislation_code              in     varchar2 default null
30   ,p_identifier_key                in     varchar2 default null
31   ,p_calendar_entry_id                out nocopy number
32   ,p_object_version_number            out nocopy number
33   ) IS
34   --
35   -- Declare cursors and local variables
36   --
37   l_proc                   varchar2(70) := g_package||'create_calendar_entry';
38   l_calendar_entry_id      per_calendar_entries.calendar_entry_id%TYPE;
39   l_object_version_number  per_calendar_entries.object_version_number%TYPE;
40   l_leg_code               per_calendar_entries.legislation_code%TYPE;
41   l_effective_date         date;
42   --
43 begin
44   hr_utility.set_location('Entering:'|| l_proc, 10);
45   --
46   -- Issue a savepoint
47   --
48   savepoint create_calendar_entry;
49   --
50   -- Truncate the time portion from all IN date parameters
51   --
52   l_effective_date := trunc(p_effective_date);
53   if p_legislation_code IS NOT NULL then
54     l_leg_code := UPPER(p_legislation_code);
55   end if;
56   --
57   -- Call Before Process User Hook
58   --
59   begin
60     HR_CALENDAR_ENTRY_BK1.create_calendar_entry_b
61       (p_effective_date                => l_effective_date
62       ,p_name                          => p_name
63       ,p_type                          => p_type
64       ,p_start_date                    => p_start_date
65       ,p_start_hour                    => p_start_hour
66       ,p_start_min                     => p_start_min
67       ,p_end_date                      => p_end_date
68       ,p_end_hour                      => p_end_hour
69       ,p_end_min                       => p_end_min
70       ,p_business_group_id             => p_business_group_id
71       ,p_description                   => p_description
72       ,p_hierarchy_id                  => p_hierarchy_id
73       ,p_value_set_id                  => p_value_set_id
74       ,p_organization_structure_id     => p_organization_structure_id
75       ,p_org_structure_version_id      => p_org_structure_version_id
76       );
77   exception
78     when hr_api.cannot_find_prog_unit then
79       hr_api.cannot_find_prog_unit_error
80         (p_module_name => 'create_calendar_entry_b'
81         ,p_hook_type   => 'BP'
82         );
83   end;
84   --
85   -- Validation in addition to Row Handlers
86   --
87   --
88   -- Process Logic
89   --
90    per_ent_ins.ins
91        (p_effective_date                => l_effective_date
92        ,p_name                          => p_name
93        ,p_type                          => p_type
94        ,p_start_date                    => p_start_date
95        ,p_start_hour                    => p_start_hour
96        ,p_start_min                     => p_start_min
97        ,p_end_date                      => p_end_date
98        ,p_end_hour                      => p_end_hour
99        ,p_end_min                       => p_end_min
100        ,p_business_group_id             => p_business_group_id
101        ,p_description                   => p_description
102        ,p_hierarchy_id                  => p_hierarchy_id
103        ,p_value_set_id                  => p_value_set_id
104        ,p_organization_structure_id     => p_organization_structure_id
105        ,p_org_structure_version_id      => p_org_structure_version_id
106        ,p_legislation_code              => l_leg_code
107        ,p_identifier_key                => p_identifier_key
108        ,p_calendar_entry_id             => l_calendar_entry_id
109        ,p_object_version_number         => l_object_version_number);
110   --
111   -- Call After Process User Hook
112   --
113   begin
114     HR_CALENDAR_ENTRY_BK1.create_calendar_entry_a
115        (p_effective_date                => l_effective_date
116        ,p_name                          => p_name
117        ,p_type                          => p_type
118        ,p_start_date                    => p_start_date
119        ,p_start_hour                    => p_start_hour
120        ,p_start_min                     => p_start_min
121        ,p_end_date                      => p_end_date
122        ,p_end_hour                      => p_end_hour
123        ,p_end_min                       => p_end_min
124        ,p_business_group_id             => p_business_group_id
125        ,p_description                   => p_description
126        ,p_hierarchy_id                  => p_hierarchy_id
127        ,p_value_set_id                  => p_value_set_id
128        ,p_organization_structure_id     => p_organization_structure_id
129        ,p_org_structure_version_id      => p_org_structure_version_id
130        ,p_calendar_entry_id             => l_calendar_entry_id
131        ,p_object_version_number         => l_object_version_number
132        );
133   exception
134     when hr_api.cannot_find_prog_unit then
135       hr_api.cannot_find_prog_unit_error
136         (p_module_name => 'create_calendar_entry_a'
137         ,p_hook_type   => 'AP'
138         );
139   end;
140   --
141   -- When in validation only mode raise the Validate_Enabled exception
142   --
143   if p_validate then
144     raise hr_api.validate_enabled;
145   end if;
146   --
147   -- Set all output arguments
148   --
149   p_calendar_entry_id      := l_calendar_entry_id;
150   p_object_version_number  := l_object_version_number;
151   --
152   hr_utility.set_location(' Leaving:'||l_proc, 70);
153 exception
154   when hr_api.validate_enabled then
155     --
156     -- As the Validate_Enabled exception has been raised
157     -- we must rollback to the savepoint
158     --
159     rollback to create_calendar_entry;
160     --
161     -- Only set output warning arguments
162     -- (Any key or derived arguments must be set to null
163     -- when validation only mode is being used.)
164     --
165     p_calendar_entry_id      := null;
166     p_object_version_number  := null;
167     hr_utility.set_location(' Leaving:'||l_proc, 80);
168   when others then
169     --
170     -- A validation or unexpected error has occured
171     --
172     rollback to create_calendar_entry;
173     hr_utility.set_location(' Leaving:'||l_proc, 90);
174     raise;
175 end create_calendar_entry;
176 --
177 -- ----------------------------------------------------------------------------
178 -- |---------------------------< update_calendar_entry >---------------------------|
179 -- ----------------------------------------------------------------------------
180 --
181 procedure update_calendar_entry
182   (p_validate                      in     boolean  default false
183   ,p_effective_date                in     date
184   ,p_calendar_entry_id             in     number
185   ,p_object_version_number         in out nocopy number
186   ,p_name                          in     varchar2 default hr_api.g_varchar2
187   ,p_type                          in     varchar2 default hr_api.g_varchar2
188   ,p_start_date                    in     date
189   ,p_start_hour                    in     varchar2 default hr_api.g_varchar2
190   ,p_start_min                     in     varchar2 default hr_api.g_varchar2
191   ,p_end_date                      in     date
192   ,p_end_hour                      in     varchar2 default hr_api.g_varchar2
193   ,p_end_min                       in     varchar2 default hr_api.g_varchar2
194   ,p_description                   in     varchar2 default hr_api.g_varchar2
195   ,p_hierarchy_id                  in     number   default hr_api.g_number
196   ,p_value_set_id                  in     number   default hr_api.g_number
197   ,p_organization_structure_id     in     number   default hr_api.g_number
198   ,p_org_structure_version_id      in     number   default hr_api.g_number
199   ,p_business_group_id             in     number   default null
200   ) is
201   --
202   -- Declare cursors and local variables
203   --
204   l_proc                   varchar2(80) := g_package||'update_calendar_entry';
205   l_calendar_entry_id      per_calendar_entries.calendar_entry_id%TYPE;
206   l_object_version_number  per_calendar_entries.object_version_number%TYPE;
207   l_effective_date         date;
208   --
209 begin
210   hr_utility.set_location('Entering:'|| l_proc, 10);
211   --
212   -- Issue a savepoint
213   --
214   savepoint update_calendar_entry;
215   --
216   -- Store initial values for IN OUT parameters
217   --
218   l_object_version_number := p_object_version_number;
219   --
220   -- Truncate the time portion from all IN date parameters
221   --
222   l_effective_date := trunc(p_effective_date);
223   --
224   -- Call Before Process User Hook
225   --
226   begin
227     HR_CALENDAR_ENTRY_BK2.update_calendar_entry_b
228       (p_effective_date                => l_effective_date
229       ,p_object_version_number         => l_object_version_number
230       ,p_calendar_entry_id             => p_calendar_entry_id
231       ,p_name                          => p_name
232       ,p_type                          => p_type
233       ,p_start_date                    => p_start_date
234       ,p_start_hour                    => p_start_hour
235       ,p_start_min                     => p_start_min
236       ,p_end_date                      => p_end_date
237       ,p_end_hour                      => p_end_hour
238       ,p_end_min                       => p_end_min
239       ,p_description                   => p_description
240       ,p_hierarchy_id                  => p_hierarchy_id
241       ,p_value_set_id                  => p_value_set_id
242       ,p_organization_structure_id     => p_organization_structure_id
243       ,p_org_structure_version_id      => p_org_structure_version_id
244        );
245   exception
246     when hr_api.cannot_find_prog_unit then
247       hr_api.cannot_find_prog_unit_error
248         (p_module_name => 'update_calendar_entry_b'
249         ,p_hook_type   => 'BP'
250         );
251   end;
252   --
253   -- Validation in addition to Row Handlers
254   --
255   --
256   -- Process Logic
257   --
258    per_ent_upd.upd
259        (p_effective_date               => l_effective_date
260        ,p_calendar_entry_id            => p_calendar_entry_id
261        ,p_object_version_number        => l_object_version_number
262        ,p_name                         => p_name
263        ,p_type                         => p_type
264        ,p_start_date                   => p_start_date
265        ,p_start_hour                   => p_start_hour
266        ,p_start_min                    => p_start_min
267        ,p_end_date                     => p_end_date
268        ,p_end_hour                     => p_end_hour
269        ,p_end_min                      => p_end_min
270        ,p_description                  => p_description
271        ,p_hierarchy_id                 => p_hierarchy_id
272        ,p_value_set_id                 => p_value_set_id
273        ,p_organization_structure_id    => p_organization_structure_id
274        ,p_org_structure_version_id     => p_org_structure_version_id
275        ,p_business_group_id            => p_business_group_id
276        );
277 
278   --
279   --
280   begin
281       HR_CALENDAR_ENTRY_BK2.update_calendar_entry_a
282        (p_effective_date                => l_effective_date
283        ,p_calendar_entry_id             => p_calendar_entry_id
284        ,p_object_version_number         => l_object_version_number
285        ,p_name                          => p_name
286        ,p_type                          => p_type
287        ,p_start_date                    => p_start_date
288        ,p_start_hour                    => p_start_hour
289        ,p_start_min                     => p_start_min
290        ,p_end_date                      => p_end_date
291        ,p_end_hour                      => p_end_hour
292        ,p_end_min                       => p_end_min
293        ,p_description                   => p_description
294        ,p_hierarchy_id                  => p_hierarchy_id
295        ,p_value_set_id                  => p_value_set_id
296        ,p_organization_structure_id     => p_organization_structure_id
297        ,p_org_structure_version_id      => p_org_structure_version_id
298        );
299 
300   exception
301     when hr_api.cannot_find_prog_unit then
302       hr_api.cannot_find_prog_unit_error
303         (p_module_name => 'update_calendar_entry_a'
304         ,p_hook_type   => 'AP'
305         );
306   end;
307   --
308   -- When in validation only mode raise the Validate_Enabled exception
309   --
310   if p_validate then
311     raise hr_api.validate_enabled;
312   end if;
313   --
314   -- Set all output arguments
315   --
316   p_object_version_number  := l_object_version_number;
317   --
318   hr_utility.set_location(' Leaving:'||l_proc, 70);
319 exception
320   when hr_api.validate_enabled then
321     --
322     -- As the Validate_Enabled exception has been raised
323     -- we must rollback to the savepoint
324     --
325     rollback to update_calendar_entry;
326     --
327     -- Only set output warning arguments
328     -- (Any key or derived arguments must be set to null
329     -- when validation only mode is being used.)
330     --
331     hr_utility.set_location(' Leaving:'||l_proc, 80);
332   when others then
333     --
334     -- A validation or unexpected error has occured
335     --
336     rollback to update_calendar_entry;
337     hr_utility.set_location(' Leaving:'||l_proc, 90);
338     raise;
339 end update_calendar_entry;
340 --
341 --
342 -- ----------------------------------------------------------------------------
343 -- |------------------------< delete_calendar_entry >-------------------------|
344 -- ----------------------------------------------------------------------------
345 --
346 procedure delete_calendar_entry
347   (p_validate                      in     boolean  default false
348   ,p_calendar_entry_id             in     number
349   ,p_object_version_number         in     number
350   ) is
351   --
352   -- Declare cursors and local variables
353   --
354   CURSOR csr_ev IS
355   Select env.CAL_ENTRY_VALUE_ID, env.OBJECT_VERSION_NUMBER
356   From per_cal_entry_values env
357   Where env.calendar_entry_id =  p_calendar_entry_id
358   Order By decode(env.parent_ENTRY_VALUE_ID,NULL,1,2) desc;
359 
360   --
361   l_proc                  varchar2(72) := g_package||'delete_calendar_entry';
362   --
363 begin
364   hr_utility.set_location('Entering:'|| l_proc, 5);
365   --
366   -- Issue a savepoint if operating in validation only mode.
367   --
368   savepoint delete_calendar_entry;
369   --
370   -- Call Before Process User Hook
371   --
372   begin
373     HR_CALENDAR_ENTRY_BK3.delete_calendar_entry_b
374      (p_calendar_entry_id       => p_calendar_entry_id,
375       p_object_version_number   => p_object_version_number
376      );
377      exception
378        when hr_api.cannot_find_prog_unit then
379          hr_api.cannot_find_prog_unit_error
380           (p_module_name => 'delete_calendar_entry_b',
381            p_hook_type   => 'BP'
382           );
383   end;
384   --
385   --
386   hr_utility.set_location(l_proc, 7);
387   --
388   -- First delete any entry value children
389   -- ensuring EVX are removed before EV
390   --
391   for del_rec in CSR_EV loop
392     hr_cal_entry_value_api.DELETE_ENTRY_VALUE
393      (P_VALIDATE              => false
394      ,P_CAL_ENTRY_VALUE_ID    => del_rec.CAL_ENTRY_VALUE_ID
395      ,P_OBJECT_VERSION_NUMBER => del_rec.OBJECT_VERSION_NUMBER);
396   end loop;
397 
398   hr_utility.set_location(l_proc, 8);
399 
400   -- Process Logic
401   --
402   per_ent_del.del
403   (p_calendar_entry_id             => p_calendar_entry_id
404   ,p_object_version_number         => p_object_version_number
405   );
406   --
407   hr_utility.set_location(l_proc, 9);
408   --
409   --
410   -- Call After Process User Hook
411   begin
412     HR_CALENDAR_ENTRY_BK3.delete_calendar_entry_a
413      (p_calendar_entry_id       => p_calendar_entry_id,
414       p_object_version_number   => p_object_version_number
415      );
416       exception
417         when hr_api.cannot_find_prog_unit then
418           hr_api.cannot_find_prog_unit_error
419            (p_module_name  => 'delete_calendar_entry_a',
420             p_hook_type   => 'AP'
421            );
422   end;
423   --
424   -- When in validation only mode raise the Validate_Enabled exception
425   --
426   if p_validate then
427     raise hr_api.validate_enabled;
428   end if;
429   --
430   hr_utility.set_location(' Leaving:'||l_proc, 11);
431 exception
432   when hr_api.validate_enabled then
433     --
434     -- As the Validate_Enabled exception has been raised
435     -- we must rollback to the savepoint
436     --
437     ROLLBACK TO delete_calendar_entry;
438     --
439     hr_utility.set_location(' Leaving:'||l_proc, 12);
440   --
441   when others then
442   --
443   --
444   ROLLBACK TO delete_calendar_entry;
445   --
446   raise;
447   --
448 end delete_calendar_entry;
449 --
450 end HR_CALENDAR_ENTRY_API;