DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_DOCUMENT_TYPES_API

Source


1 Package Body hr_document_types_api as
2 /* $Header: hrdtyapi.pkb 120.0 2005/05/30 23:53:41 appldev noship $ */
3 --
4 -- Package Variables
5 --
6 g_package  varchar2(33) := '  hr_document_types_api.';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |-----------------------< create_document_type >------------------------|
10 -- ----------------------------------------------------------------------------
11 --
12 procedure create_document_type(
13    p_validate                       in     boolean  default false
14   ,p_language_code                  IN     VARCHAR2  DEFAULT hr_api.userenv_lang
15   ,p_description                    in     varchar2  default null
16   ,p_document_type                  in     varchar2
17   ,p_effective_date                 in     date       default sysdate
18   ,p_category_code                  in     varchar2
19   ,p_active_inactive_flag           in     varchar2
20   ,p_multiple_occurences_flag       in     varchar2
21   ,p_authorization_required         in     varchar2
22   ,p_sub_category_code              in     varchar2 default null
23   ,p_legislation_code               in     varchar2 default null
24   ,p_warning_period                 in     number   default null
25   ,p_request_id                     in     number   default null
26   ,p_program_application_id         in     number   default null
27   ,p_program_id                     in     number   default null
28   ,p_program_update_date            in     date     default sysdate
29   ,p_document_type_id               out nocopy number
30   ,p_object_version_number          out nocopy number
31   ) IS
32   -- Declare cursors and local variables
33   --
34     l_proc			varchar2(72) := g_package||'create_document_type';
35     l_object_version_number	hr_document_types.object_version_number%type;
36     l_document_type_id 	        hr_document_types.document_type_id%type;
37     l_language_code         hr_all_organization_units_tl.language%TYPE;
38     l_document_type varchar2(40);
39 BEGIN
40 
41   --
42   -- Issue a savepoint
43   --
44 
45   savepoint create_document_type;
46   --
47   -- Call Before Process User Hook
48   --
49   begin
50     hr_document_types_bk1.create_document_type_b(
51        p_effective_date                => p_effective_date
52       ,p_document_type                 => p_document_type
53       ,p_language_code                 => p_language_code
54       ,p_description                   => p_description
55       ,p_category_code                 => p_category_code
56       ,p_active_inactive_flag          => p_active_inactive_flag
57       ,p_multiple_occurences_flag      => p_multiple_occurences_flag
58       ,p_authorization_required        => p_authorization_required
59       ,p_sub_category_code             => p_sub_category_code
60       ,p_legislation_code              => p_legislation_code
61       ,p_warning_period                => p_warning_period
62       ,p_request_id                    => p_request_id
63       ,p_program_application_id        => p_program_application_id
64       ,p_program_id                    => p_program_id
65       ,p_program_update_date           => p_program_update_date
66   );
67             exception
68               when hr_api.cannot_find_prog_unit then
69               hr_api.cannot_find_prog_unit_error
70                (p_module_name => 'CREATE_DOCUMENT_TYPE'
71                ,p_hook_type   => 'BP'
72                );
73       end;
74     --
75 
76     -- End of Before Process User Hook call
77     --
78   hr_utility.set_location(l_proc, 7);
79   --
80   --
81   -- Validate the language parameter. l_language_code should be passed to functions
82   -- instead of p_language_code from now on, to allow an IN OUT parameter to
83   -- be passed through.
84   --
85   l_language_code := p_language_code;
86   --hr_api.validate_language_code(p_language_code => l_language_code);
87   --
88   hr_utility.set_location(l_proc, 20);
89 
90   --
91   -- Process Logic
92   --
93   hr_dty_ins.ins(
94        p_effective_date                => p_effective_date
95       ,p_system_document_type          => p_document_type
96       ,p_category_code                 => p_category_code
97       ,p_active_inactive_flag          => p_active_inactive_flag
98       ,p_multiple_occurences_flag      => p_multiple_occurences_flag
99       ,p_authorization_required        => p_authorization_required
100       ,p_sub_category_code             => p_sub_category_code
101       ,p_legislation_code              => p_legislation_code
102       ,p_warning_period                => p_warning_period
103       ,p_request_id                    => p_request_id
104       ,p_program_application_id        => p_program_application_id
105       ,p_program_id                    => p_program_id
106       ,p_program_update_date           => p_program_update_date
107       ,p_document_type_id              => l_document_type_id
108       ,p_object_version_number         => l_object_version_number
109   );
110 
111   --
112   --  Now insert translatable rows in HR_DOCUMENT_TYPES_TL table
113   --
114 
115   hr_dtt_ins.ins_tl
116     ( p_language_code                 => l_language_code,
117       p_document_type_id              => l_document_type_id,
118       p_document_type                 => p_document_type,
119       p_description                   => p_description
120     );
121 
122   --
123 
124     p_object_version_number	    := l_object_version_number;
125     p_document_type_id	        := l_document_type_id;
126     --
127     hr_utility.set_location(l_proc, 8);
128     --
129     -- Call After Process User Hook
130     --
131 
132     begin
133       hr_document_types_bk1.create_document_type_a(
134        p_document_type_id              => l_document_type_id
135       ,p_effective_date                => p_effective_date
136       ,p_document_type                 => p_document_type
137       ,p_language_code                 => p_language_code
138       ,p_description                   => p_description
139       ,p_category_code                 => p_category_code
140       ,p_active_inactive_flag          => p_active_inactive_flag
141       ,p_multiple_occurences_flag      => p_multiple_occurences_flag
142       ,p_authorization_required        => p_authorization_required
143       ,p_sub_category_code             => p_sub_category_code
144       ,p_legislation_code              => p_legislation_code
145       ,p_warning_period                => p_warning_period
146       ,p_request_id                    => p_request_id
147       ,p_program_application_id        => p_program_application_id
148       ,p_program_id                    => p_program_id
149       ,p_program_update_date           => p_program_update_date
150       ,p_object_version_number         => l_document_type_id
151 );
152 exception
153       when hr_api.cannot_find_prog_unit then
154         hr_api.cannot_find_prog_unit_error
155           (p_module_name => 'CREATE_DOCUMENT_TYPE',
156            p_hook_type   => 'BP'
157           );
158 end;
159   --
160   -- End of After Process User Hook call
161   --
162   -- When in validation only mode raise the Validate_Enabled exception
163   --
164   if p_validate then
165     raise hr_api.validate_enabled;
166   end if;
167   --
168   hr_utility.set_location(' Leaving:'||l_proc, 11);
169 exception
170   when hr_api.validate_enabled then
171     --
172     -- As the Validate_Enabled exception has been raised
173     -- we must rollback to the savepoint
174     --
175     ROLLBACK TO create_document_type;
176     --
177     -- Only set output warning arguments
178     -- (Any key or derived arguments must be set to null
179     -- when validation only mode is being used.)
180     --
181     p_document_type_id       := null;
182     p_object_version_number  := null;
183     --
184     hr_utility.set_location(' Leaving:'||l_proc, 12);
185     --
186   when others then
187     --
188     -- A validation or unexpected error has occurred
189     --
190     --
191     ROLLBACK TO create_document_type;
192     --
193     -- set in out parameters and set out parameters
194     --
195     p_document_type_id   := null;
196     p_object_version_number  := null;
197     --
198     raise;
199     --
200 end create_document_type;
201 --
202 --
203 -- ----------------------------------------------------------------------------
204 -- |-----------------------< update_document_type >------------------------|
205 -- ----------------------------------------------------------------------------
206 --
207 procedure update_document_type(
208   p_validate                     in     boolean  default false
209  ,p_effective_date               in     date     default sysdate
210  ,p_language_code                IN     VARCHAR2  DEFAULT hr_api.userenv_lang
211  ,p_description                  in     varchar2
212  ,p_document_type                in     varchar2
213  ,p_document_type_id             in     number
214  ,p_object_version_number        in out nocopy number
215  ,p_category_code                in     varchar2
216  ,p_active_inactive_flag         in     varchar2
217  ,p_multiple_occurences_flag     in     varchar2
218  ,p_legislation_code             in     varchar2  default hr_api.g_varchar2
219  ,p_authorization_required       in     varchar2
220  ,p_sub_category_code            in     varchar2  default hr_api.g_varchar2
221  ,p_warning_period               in     number    default hr_api.g_number
222  ,p_request_id                   in     number    default hr_api.g_number
223  ,p_program_application_id       in     number    default hr_api.g_number
224  ,p_program_id                   in     number    default hr_api.g_number
225  ,p_program_update_date          in     date      default hr_api.g_date
226 ) IS
227 --
228 --
229   -- Declare cursors and local variables
230   --
231   l_proc                  varchar2(72) := g_package||'update_document_type';
232   l_object_version_number hr_document_types.object_version_number%TYPE;
233   l_ovn 		  hr_document_types.object_version_number%TYPE := p_object_version_number;
234   --
235 begin
236   hr_utility.set_location('Entering:'|| l_proc, 5);
237   --
238   -- Issue a savepoint
239   --
240   savepoint update_document_type;
241   --
242   -- Call Before Process User Hook
243   --
244   begin
245     hr_document_types_bk2.update_document_type_b(
246           p_effective_date                => p_effective_date
247          ,p_category_code                 => p_category_code
248          ,p_document_type                 => p_document_type
249          ,p_language_code                 => p_language_code
250          ,p_description                   => p_description
251          ,p_active_inactive_flag          => p_active_inactive_flag
252          ,p_multiple_occurences_flag      => p_multiple_occurences_flag
253          ,p_authorization_required        => p_authorization_required
254          ,p_sub_category_code             => p_sub_category_code
255          ,p_legislation_code              => p_legislation_code
256          ,p_warning_period                => p_warning_period
257          ,p_request_id                    => p_request_id
258          ,p_program_application_id        => p_program_application_id
259          ,p_program_id                    => p_program_id
260          ,p_program_update_date           => p_program_update_date
261          ,p_document_type_id              => p_document_type_id
262          ,p_object_version_number         => p_object_version_number
263 );
264   exception
265    when hr_api.cannot_find_prog_unit then
266    hr_api.cannot_find_prog_unit_error
267       (p_module_name => 'UPDATE_DOCUMENT_TYPE',
268        p_hook_type   => 'BP'
269                     );
270         end;
271           --
272    -- End of Before Process User Hook call
273    --
274    --
275    hr_utility.set_location(l_proc, 7);
276    --
277    -- Store the original ovn in case we rollback when p_validate is true
278    --
279    l_object_version_number  := p_object_version_number;
280    --
281    -- Process Logic - UPDATE_DOCUMENT_TYPE
282    --
283    hr_dty_upd.upd(
284           p_effective_date                => p_effective_date
285          ,p_category_code                 => p_category_code
286          ,p_active_inactive_flag          => p_active_inactive_flag
287          ,p_multiple_occurences_flag      => p_multiple_occurences_flag
288          ,p_authorization_required        => p_authorization_required
289          ,p_sub_category_code             => p_sub_category_code
290          ,p_legislation_code              => p_legislation_code
291          ,p_warning_period                => p_warning_period
292          ,p_request_id                    => p_request_id
293          ,p_program_application_id        => p_program_application_id
294          ,p_program_id                    => p_program_id
295          ,p_program_update_date           => p_program_update_date
296          ,p_document_type_id              => p_document_type_id
297          ,p_object_version_number         => p_object_version_number
298          );
299       --
300 
301   hr_dtt_upd.upd_tl
302    (
303     p_language_code => p_language_code,
304     p_document_type_id => p_document_type_id,
305     p_description => p_description,
306     p_document_type =>p_document_type
307     );
308         hr_utility.set_location(l_proc, 8);
309         --
310         -- Call After Process User Hook
311         --
312         begin
313     hr_document_types_bk2.update_document_type_a(
314            p_effective_date                => p_effective_date
315           ,p_category_code                 => p_category_code
316           ,p_document_type                 => p_document_type
317           ,p_language_code                 => p_language_code
318           ,p_description                   => p_description
319           ,p_active_inactive_flag          => p_active_inactive_flag
320           ,p_multiple_occurences_flag      => p_multiple_occurences_flag
321           ,p_authorization_required        => p_authorization_required
322           ,p_sub_category_code             => p_sub_category_code
323           ,p_legislation_code              => p_legislation_code
324           ,p_warning_period                => p_warning_period
325           ,p_request_id                    => p_request_id
326           ,p_program_application_id        => p_program_application_id
327           ,p_program_id                    => p_program_id
328           ,p_program_update_date           => p_program_update_date
329           ,p_document_type_id              => p_document_type_id
330           ,p_object_version_number         => p_object_version_number
331     );
332      exception
333             when hr_api.cannot_find_prog_unit then
334               hr_api.cannot_find_prog_unit_error
335           	    (p_module_name => 'UPDATE_DOCUMENT_TYPE',
336                      p_hook_type   => 'AP'
337                     );
338     end;
339       --
340       -- End of After Process User Hook call
341       --
342       -- When in validation only mode raise the Validate_Enabled exception
343       --
344       if p_validate then
345         raise hr_api.validate_enabled;
346       end if;
347       --
348       hr_utility.set_location(' Leaving:'||l_proc, 11);
349     exception
350       when hr_api.validate_enabled then
351         --
352         -- As the Validate_Enabled exception has been raised
353         -- we must rollback to the savepoint
354         --
355         ROLLBACK TO update_document_type;
356         --
357         -- Only set output warning arguments
358         -- (Any key or derived arguments must be set to null
359         -- when validation only mode is being used.)
360         --
361         p_object_version_number  := l_object_version_number;
362         --
363         hr_utility.set_location(' Leaving:'||l_proc, 12);
364         --
365       when others then
366         --
367         -- A validation or unexpected error has occurred
368         --
369         ROLLBACK TO update_document_type;
370         --
371         -- set in out parameters and set out parameters
372         --
373             p_object_version_number  := l_ovn;
374         --
375         raise;
376         --
377     end update_document_type;
378     --
379 --
380 -- ----------------------------------------------------------------------------
381 -- |-----------------------< delete_document_type >------------------------|
382 -- ----------------------------------------------------------------------------
383 --
384 procedure delete_document_type
385   (p_validate                      in     boolean  default false
386   ,p_document_type_id              in     number
387   ,p_object_version_number         in     number
388   ) is
389   --
390   -- Declare cursors and local variables
391   --
392   l_proc                  varchar2(72) := g_package||'delete_document_type';
393   --
394 begin
395   hr_utility.set_location('Entering:'|| l_proc, 5);
396   --
397   -- Issue a savepoint
398   --
399   savepoint delete_document_type;
400   --
401   -- Call Before Process User Hook
402   --
403   begin
404     hr_document_types_bk3.delete_document_type_b
405       (p_document_type_id           => p_document_type_id,
406        p_object_version_number      => p_object_version_number
407       );
408       exception
409         when hr_api.cannot_find_prog_unit then
410           hr_api.cannot_find_prog_unit_error
411             (p_module_name => 'DELETE_DOCUMENT_TYPE',
412              p_hook_type   => 'BP'
413             );
414 end;
415   --
416   -- End of Before Process User Hook call
417   --
418   hr_utility.set_location(l_proc, 7);
419   --
420   -- Process Logic - Delete Person Extra Info details
421   --
422   hr_dty_del.del
423   (p_document_type_id              => p_document_type_id
424   ,p_object_version_number         => p_object_version_number
425   );
426   --
427  hr_dtt_del.del_tl
428  (
429  p_document_type_id              => p_document_type_id
430  );
431   hr_utility.set_location(l_proc, 8);
432   --
433   -- Call Before Process User Hook
434   --
435   begin
436     hr_document_types_bk3.delete_document_type_a
437       (p_document_type_id          => p_document_type_id,
438        p_object_version_number     => p_object_version_number
439       );
440       exception
441         when hr_api.cannot_find_prog_unit then
442           hr_api.cannot_find_prog_unit_error
443             (p_module_name => 'DELETE_DOCUMENT_TYPE',
444              p_hook_type   => 'AP'
445             );
446 end;
447   --
448   -- End of After Process User Hook call
449   --
450   -- When in validation only mode raise the Validate_Enabled exception
451   --
452   if p_validate then
453     raise hr_api.validate_enabled;
454   end if;
455   --
456   hr_utility.set_location(' Leaving:'||l_proc, 11);
457 exception
458   when hr_api.validate_enabled then
459     --
460     -- As the Validate_Enabled exception has been raised
461     -- we must rollback to the savepoint
462     --
463     ROLLBACK TO delete_person_extra_info;
464     --
465     hr_utility.set_location(' Leaving:'||l_proc, 12);
466     --
467   when others then
468     --
469     -- A validation or unexpected error has occurred
470     --
471     ROLLBACK TO delete_document_type;
472     --
473     raise;
474     --
475 end delete_document_type;
476 --
477 end hr_document_types_api;