DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_CATEGORY_USAGE_API

Source


1 Package Body ota_category_usage_api as
2 /* $Header: otctuapi.pkb 120.0 2005/05/29 07:10:13 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ota_category_usage_api.';
9 --
10 -- ----------------------------------------------------------------------------
11 -- |--------------------------< get_act_def_name_with_cat_id >-----------------|
12 -- ----------------------------------------------------------------------------
13 function get_act_def_name_with_cat_id
14   (p_act_def_name      in     varchar2
15   ,p_cat_usg_id        in     number
16   ) return varchar2 is
17 
18   MAX_ACT_DEF_NAME_LEN constant number := 240;
19 
20   l_new_act_def_len number;
21   l_cat_id_len number;
22   l_act_def_name ota_activity_definitions_tl.name%type := p_act_def_name;
23   l_old_act_def_len number := length(l_act_def_name);
24 
25 begin
26   --
27   l_new_act_def_len := length(l_act_def_name||'-'||p_cat_usg_id);
28   --
29   If l_new_act_def_len > MAX_ACT_DEF_NAME_LEN then
30     --
31     l_cat_id_len := l_new_act_def_len - MAX_ACT_DEF_NAME_LEN;
32     l_act_def_name := substr(l_act_def_name,1,l_old_act_def_len - l_cat_id_len)||'-'||to_char(p_cat_usg_id);
33     --
34   Else
35    --
36    l_act_def_name := l_act_def_name||'-'||p_cat_usg_id;
37    --
38   End if;
39   --
40   return l_act_def_name;
41 end get_act_def_name_with_cat_id;
42 --
43 -- ----------------------------------------------------------------------------
44 -- |---------------------------< CREATE_CATEGORY >----------------------------|
45 -- ----------------------------------------------------------------------------
46 --
47 procedure Create_category
48   (p_validate                      in     boolean  default false
49   ,p_effective_date                in     date
50   ,p_business_group_id             in     number
51   ,p_category			   in	  varchar2
52   ,p_type			   in	  varchar2
53   ,p_description		   in	  varchar2
54   ,p_parent_cat_usage_id	   in	  number
55   ,p_synchronous_flag		   in	  varchar2
56   ,p_online_flag                   in	  varchar2 default null
57   ,p_attribute_category            in     varchar2 default null
58   ,p_attribute1                    in     varchar2 default null
59   ,p_attribute2                    in     varchar2 default null
60   ,p_attribute3                    in     varchar2 default null
61   ,p_attribute4                    in     varchar2 default null
62   ,p_attribute5                    in     varchar2 default null
63   ,p_attribute6                    in     varchar2 default null
64   ,p_attribute7                    in     varchar2 default null
65   ,p_attribute8                    in     varchar2 default null
66   ,p_attribute9                    in     varchar2 default null
67   ,p_attribute10                   in     varchar2 default null
68   ,p_attribute11                   in     varchar2 default null
69   ,p_attribute12                   in     varchar2 default null
70   ,p_attribute13                   in     varchar2 default null
71   ,p_attribute14                   in     varchar2 default null
72   ,p_attribute15                   in     varchar2 default null
73   ,p_attribute16                   in     varchar2 default null
74   ,p_attribute17                   in     varchar2 default null
75   ,p_attribute18                   in     varchar2 default null
76   ,p_attribute19                   in     varchar2 default null
77   ,p_attribute20                   in     varchar2 default null
78   ,p_data_source                   in     varchar2 default null
79   ,p_start_date_active             in     date
80   ,p_end_date_active               in     date default null
81   ,p_category_usage_id             out nocopy number
82   ,p_object_version_number         out nocopy number
83   ,p_comments                      in     varchar2 default null
84   ) is
85   --
86   -- Declare cursors and local variables
87   --
88   l_proc                    varchar2(72) := g_package||'Create_Category';
89   l_category_usage_id       number;
90   l_object_version_number   number;
91   l_act_object_version_number  ota_activity_definitions.object_version_number%TYPE;
92   l_activity_id ota_activity_definitions.activity_id%TYPE;
93   l_effective_date          date;
94   l_category                varchar2(240);
95 
96 begin
97   hr_utility.set_location('Entering:'|| l_proc, 10);
98   --
99   -- Issue a savepoint
100   --
101   savepoint CREATE_CATEGORY;
102   --
103   -- Truncate the time portion from all IN date parameters
104   --
105   l_effective_date := trunc(p_effective_date);
106   l_category := rtrim(p_category);
107   --
108   -- Call Before Process User Hook
109   --
110   begin
111     ota_category_usage_bk1.create_category_b
112   (p_effective_date                   => l_effective_date
113   ,p_business_group_id                => p_business_group_id
114   ,p_category			      => l_category
115   ,p_type			      => p_type
116   ,p_parent_cat_usage_id	      => p_parent_cat_usage_id
117   ,p_synchronous_flag		      => p_synchronous_flag
118   ,p_online_flag                      => p_online_flag
119   ,p_attribute_category               => p_attribute_category
120   ,p_attribute1                       => p_attribute1
121   ,p_attribute2                       => p_attribute2
122   ,p_attribute3                       => p_attribute3
123   ,p_attribute4                       => p_attribute4
124   ,p_attribute5                       => p_attribute5
125   ,p_attribute6                       => p_attribute6
126   ,p_attribute7                       => p_attribute7
127   ,p_attribute8                       => p_attribute8
128   ,p_attribute9                       => p_attribute9
129   ,p_attribute10                      => p_attribute10
130   ,p_attribute11                      => p_attribute11
131   ,p_attribute12                      => p_attribute12
132   ,p_attribute13                      => p_attribute13
133   ,p_attribute14                      => p_attribute14
134   ,p_attribute15                      => p_attribute15
135   ,p_attribute16                      => p_attribute16
136   ,p_attribute17                      => p_attribute17
137   ,p_attribute18                      => p_attribute18
138   ,p_attribute19                      => p_attribute19
139   ,p_attribute20                      => p_attribute20
140   ,p_data_source                      => p_data_source
141   ,p_start_date_active                => p_start_date_active
142   ,p_end_date_active                  => p_end_date_active
143   ,p_comments                         => p_comments
144    );
145   exception
146     when hr_api.cannot_find_prog_unit then
147       hr_api.cannot_find_prog_unit_error
148         (p_module_name => 'CREATE_CATEGORY'
149         ,p_hook_type   => 'BP'
150         );
151   end;
152   --
153   -- Validation in addition to Row Handlers
154   --
155   --
156   -- Process Logic (Base table)
157   --
158   ota_ctu_ins.ins
159   (p_effective_date              => l_effective_date
160   ,p_business_group_id           => p_business_group_id
161   ,p_category		         => l_category
162   ,p_type		         => p_type
163   ,p_parent_cat_usage_id         => p_parent_cat_usage_id
164   ,p_synchronous_flag	         => p_synchronous_flag
165   ,p_online_flag                 => p_online_flag
166   ,p_attribute_category          => p_attribute_category
167   ,p_attribute1                  => p_attribute1
168   ,p_attribute2                  => p_attribute2
169   ,p_attribute3                  => p_attribute3
170   ,p_attribute4                  => p_attribute4
171   ,p_attribute5                  => p_attribute5
172   ,p_attribute6                  => p_attribute6
173   ,p_attribute7                  => p_attribute7
174   ,p_attribute8                  => p_attribute8
175   ,p_attribute9                  => p_attribute9
176   ,p_attribute10                 => p_attribute10
177   ,p_attribute11                 => p_attribute11
178   ,p_attribute12                 => p_attribute12
179   ,p_attribute13                 => p_attribute13
180   ,p_attribute14                 => p_attribute14
181   ,p_attribute15                 => p_attribute15
182   ,p_attribute16                 => p_attribute16
183   ,p_attribute17                 => p_attribute17
184   ,p_attribute18                 => p_attribute18
185   ,p_attribute19                 => p_attribute19
186   ,p_attribute20                 => p_attribute20
187   ,p_data_source                 => p_data_source
188   ,p_start_date_active           => p_start_date_active
189   ,p_end_date_active             => p_end_date_active
190   ,p_category_usage_id           => l_category_usage_id
191   ,p_object_version_number       => l_object_version_number
192   ,p_comments                    => p_comments
193 
194   );
195   --
196   -- Process Logic (MLS table)
197   --
198   ota_ctt_ins.ins_tl
199   (p_effective_date              => p_effective_date
200   ,p_language_code               => USERENV('LANG')
201   ,p_category_usage_id           => l_category_usage_id
202   ,p_category		         => l_category
203   ,p_description                 => p_description
204   );
205   --
206   --Call activity type API to create corresponding activity type
207   IF p_type = 'C' THEN
208     --
209     ota_tad_api.ins(p_activity_id             => l_activity_id
210                     ,p_business_group_id      => p_business_group_id
211                     ,p_name                   => get_act_def_name_with_cat_id( l_category,l_category_usage_id)
212                     ,p_description            => p_description
213                     ,p_object_version_number  => l_act_object_version_number
214                     ,p_category_usage_id      => l_category_usage_id
215                     ,p_multiple_con_versions_flag => 'Y' );
216 
217     ota_adt_ins.ins_tl(p_effective_date       => p_effective_date
218                        ,p_language_code       => USERENV('LANG')
219                        ,p_activity_id         => l_activity_id
220                        ,p_name                => get_act_def_name_with_cat_id( l_category,l_category_usage_id)
221                        ,p_description         => p_description);
222     --end call activity type APIs to create activity type for the category
223     -- Call After Process User Hook
224   END IF;
225   --
226 
227   begin
228   ota_category_usage_bk1.create_category_a
229   (p_effective_date              => l_effective_date
230   ,p_business_group_id           => p_business_group_id
231   ,p_category		         => l_category
232   ,p_type		         => p_type
233   ,p_parent_cat_usage_id         => p_parent_cat_usage_id
234   ,p_synchronous_flag	         => p_synchronous_flag
235   ,p_online_flag                 => p_online_flag
236   ,p_attribute_category          => p_attribute_category
237   ,p_attribute1                  => p_attribute1
238   ,p_attribute2                  => p_attribute2
239   ,p_attribute3                  => p_attribute3
240   ,p_attribute4                  => p_attribute4
241   ,p_attribute5                  => p_attribute5
242   ,p_attribute6                  => p_attribute6
243   ,p_attribute7                  => p_attribute7
244   ,p_attribute8                  => p_attribute8
245   ,p_attribute9                  => p_attribute9
246   ,p_attribute10                 => p_attribute10
247   ,p_attribute11                 => p_attribute11
248   ,p_attribute12                 => p_attribute12
249   ,p_attribute13                 => p_attribute13
250   ,p_attribute14                 => p_attribute14
251   ,p_attribute15                 => p_attribute15
252   ,p_attribute16                 => p_attribute16
253   ,p_attribute17                 => p_attribute17
254   ,p_attribute18                 => p_attribute18
255   ,p_attribute19                 => p_attribute19
256   ,p_attribute20                 => p_attribute20
257   ,p_data_source                 => p_data_source
258   ,p_start_date_active           => p_start_date_active
259   ,p_end_date_active             => p_end_date_active
260   ,p_category_usage_id           => l_category_usage_id
261   ,p_object_version_number       => l_object_version_number
262   ,p_comments                    => p_comments
263 
264   );
265   exception
266     when hr_api.cannot_find_prog_unit then
267       hr_api.cannot_find_prog_unit_error
268         (p_module_name => 'CREATE_CATEGORY'
269         ,p_hook_type   => 'AP'
270         );
271   end;
272   --
273   -- When in validation only mode raise the Validate_Enabled exception
274   --
275   if p_validate then
276     raise hr_api.validate_enabled;
277   end if;
278   --
279   -- Set all output arguments
280   --
281   p_category_usage_id        := l_category_usage_id;
282   p_object_version_number   := l_object_version_number;
283   --
284   hr_utility.set_location(' Leaving:'||l_proc, 70);
285 exception
286   when hr_api.validate_enabled then
287     --
288     -- As the Validate_Enabled exception has been raised
289     -- we must rollback to the savepoint
290     --
291     rollback to CREATE_CATEGORY;
292     --
293     -- Only set output warning arguments
294     -- (Any key or derived arguments must be set to null
295     -- when validation only mode is being used.)
296     --
297     p_category_usage_id := null;
298     p_object_version_number   := null;
299     hr_utility.set_location(' Leaving:'||l_proc, 80);
300   when others then
301     --
302     -- A validation or unexpected error has occured
303     --
304     rollback to CREATE_CATEGORY;
305     p_category_usage_id        := null;
306     p_object_version_number   := null;
307     hr_utility.set_location(' Leaving:'||l_proc, 90);
308     raise;
309 end create_category;
310 -- ----------------------------------------------------------------------------
311 -- |--------------------------< UPDATE_CATEGORY >-----------------------------|
312 -- ----------------------------------------------------------------------------
313 --
314 procedure Update_category
315   (p_validate                      in     boolean  default false
316   ,p_effective_date                in     date
317   ,p_category_usage_id             in     number
318   ,p_object_version_number         in out nocopy number
319   ,p_category                      in     varchar2
320   ,p_type                          in	  varchar2
321   ,p_description                   in     varchar2
322   ,p_parent_cat_usage_id           in	  number
323   ,p_synchronous_flag              in	  varchar2
324   ,p_online_flag                   in	  varchar2 default null
325   ,p_attribute_category            in     varchar2 default null
326   ,p_attribute1                    in     varchar2 default null
327   ,p_attribute2                    in     varchar2 default null
328   ,p_attribute3                    in     varchar2 default null
329   ,p_attribute4                    in     varchar2 default null
330   ,p_attribute5                    in     varchar2 default null
331   ,p_attribute6                    in     varchar2 default null
332   ,p_attribute7                    in     varchar2 default null
333   ,p_attribute8                    in     varchar2 default null
334   ,p_attribute9                    in     varchar2 default null
335   ,p_attribute10                   in     varchar2 default null
336   ,p_attribute11                   in     varchar2 default null
337   ,p_attribute12                   in     varchar2 default null
338   ,p_attribute13                   in     varchar2 default null
339   ,p_attribute14                   in     varchar2 default null
340   ,p_attribute15                   in     varchar2 default null
341   ,p_attribute16                   in     varchar2 default null
342   ,p_attribute17                   in     varchar2 default null
343   ,p_attribute18                   in     varchar2 default null
344   ,p_attribute19                   in     varchar2 default null
345   ,p_attribute20                   in     varchar2 default null
346   ,p_data_source                   in     varchar2 default null
347   ,p_start_date_active             in     date
348   ,p_end_date_active               in     date default null
349   ,p_comments                      in     varchar2 default null
350 
351   ) is
352   --
353   -- Declare cursors and local variables
354   -- get the activity id for the category_usage_id
355   CURSOR get_activity_id
356       IS
357   SELECT activity_id,
358          object_version_number
359     FROM ota_activity_definitions
360    WHERE category_usage_id = p_category_usage_id;
361 
362   --
363   l_proc                    varchar2(72) := g_package||'Update_category';
364   l_effective_date          date;
365   l_object_version_number   number := p_object_version_number;
366   l_act_object_version_number ota_activity_definitions.object_version_number%TYPE;
367   l_activity_id             ota_activity_definitions.activity_id%TYPE;
368   l_category                varchar2(240);
369 
370 begin
371   hr_utility.set_location('Entering:'|| l_proc, 10);
372   --
373   -- Issue a savepoint
374   --
375   savepoint UPDATE_CATEGORY;
376   --
377   -- Truncate the time portion from all IN date parameters
378   --
379   l_effective_date := trunc(p_effective_date);
380   --
381   l_category := rtrim(p_category);
382   --
383   -- Call Before Process User Hook
384   --
385   begin
386     ota_category_usage_bk2.update_category_b
387   (p_effective_date                 => l_effective_date
388   ,p_category_usage_id              => p_category_usage_id
389   ,p_object_version_number          => p_object_version_number
390   ,p_category                       => l_category
391   ,p_type                           => p_type
392   ,p_parent_cat_usage_id            => p_parent_cat_usage_id
393   ,p_synchronous_flag	            => p_synchronous_flag
394   ,p_online_flag                    => p_online_flag
395   ,p_attribute_category             => p_attribute_category
396   ,p_attribute1                     => p_attribute1
397   ,p_attribute2                     => p_attribute2
398   ,p_attribute3                     => p_attribute3
399   ,p_attribute4                     => p_attribute4
400   ,p_attribute5                     => p_attribute5
401   ,p_attribute6                     => p_attribute6
402   ,p_attribute7                     => p_attribute7
403   ,p_attribute8                     => p_attribute8
404   ,p_attribute9                     => p_attribute9
405   ,p_attribute10                    => p_attribute10
406   ,p_attribute11                    => p_attribute11
407   ,p_attribute12                    => p_attribute12
408   ,p_attribute13                    => p_attribute13
409   ,p_attribute14                    => p_attribute14
410   ,p_attribute15                    => p_attribute15
411   ,p_attribute16                    => p_attribute16
412   ,p_attribute17                    => p_attribute17
413   ,p_attribute18                    => p_attribute18
414   ,p_attribute19                    => p_attribute19
415   ,p_attribute20                    => p_attribute20
416   ,p_data_source                    => p_data_source
417   ,p_start_date_active              => p_start_date_active
418   ,p_end_date_active                => p_end_date_active
419   ,p_comments                       => p_comments
420   );
421   exception
422     when hr_api.cannot_find_prog_unit then
423       hr_api.cannot_find_prog_unit_error
424         (p_module_name => 'UPDATE_CATEGORY'
425         ,p_hook_type   => 'BP'
426         );
427   end;
428   --
429   -- Validation in addition to Row Handlers
430   --
431 /*
432   ota_ctu_bus.Chk_valid_parent_category
433   (p_parent_cat_usage_id	    => p_parent_cat_usage_id
434   ,p_category_usage_id              => p_category_usage_id
435   );
436 */
437   --
438   -- Process Logic (Base table)
439   --
440   ota_ctu_upd.upd
441   (p_effective_date                 => l_effective_date
442   ,p_category_usage_id              => p_category_usage_id
443   ,p_object_version_number          => p_object_version_number
444   ,p_category                       => l_category
445   ,p_type                           => p_type
446   ,p_parent_cat_usage_id            => p_parent_cat_usage_id
447   ,p_synchronous_flag               => p_synchronous_flag
448   ,p_online_flag                    => p_online_flag
449   ,p_attribute_category             => p_attribute_category
450   ,p_attribute1                     => p_attribute1
451   ,p_attribute2                     => p_attribute2
452   ,p_attribute3                     => p_attribute3
453   ,p_attribute4                     => p_attribute4
454   ,p_attribute5                     => p_attribute5
455   ,p_attribute6                     => p_attribute6
456   ,p_attribute7                     => p_attribute7
457   ,p_attribute8                     => p_attribute8
458   ,p_attribute9                     => p_attribute9
459   ,p_attribute10                    => p_attribute10
460   ,p_attribute11                    => p_attribute11
461   ,p_attribute12                    => p_attribute12
462   ,p_attribute13                    => p_attribute13
463   ,p_attribute14                    => p_attribute14
464   ,p_attribute15                    => p_attribute15
465   ,p_attribute16                    => p_attribute16
466   ,p_attribute17                    => p_attribute17
467   ,p_attribute18                    => p_attribute18
468   ,p_attribute19                    => p_attribute19
469   ,p_attribute20                    => p_attribute20
470   ,p_data_source                    => p_data_source
471   ,p_start_date_active              => p_start_date_active
472   ,p_end_date_active                => p_end_date_active
473   ,p_comments                       => p_comments
474 
475   );
476   --
477   -- Process Logic (MLS table)
478   --
479   ota_ctt_upd.upd_tl
480   (p_effective_date              => p_effective_date
481   ,p_language_code               => USERENV('LANG')
482   ,p_category_usage_id           => p_category_usage_id
483   ,p_category		         => l_category
484   ,p_description                 => p_description
485   );
486   --
487   IF p_type = 'C' THEN-- if category type is Classification
488   --Call activity type API to update corresponding activity type
489      OPEN get_activity_id;
490     FETCH get_activity_id INTO l_activity_id, l_act_object_version_number;
491     CLOSE get_activity_id;
492 
493        IF l_activity_id IS NOT NULL THEN
494 
495           ota_tad_api.upd(p_activity_id             => l_activity_id
496                           ,p_name                   => get_act_def_name_with_cat_id( l_category,p_category_usage_id)
497                           ,p_description            => p_description
498                           ,p_object_version_number  => l_act_object_version_number
499                           ,p_category_usage_id      => p_category_usage_id
500                           ,p_multiple_con_versions_flag => 'Y');
501 
502           ota_adt_upd.upd_tl(p_effective_date       => p_effective_date
503                              ,p_language_code       => USERENV('LANG')
504                              ,p_activity_id         => l_activity_id
505                              ,p_name                => get_act_def_name_with_cat_id( l_category,p_category_usage_id)
506                              ,p_description         => p_description);
507       END IF;
508   --end call activity type APIs to update activity type for the category
509  END IF; -- if category type is Classification
510   -- Call After Process User Hook
511   --
512   begin
513   ota_category_usage_bk2.update_category_a
514   (p_effective_date                 => l_effective_date
515   ,p_category_usage_id              => p_category_usage_id
516   ,p_object_version_number          => p_object_version_number
517   ,p_category                       => l_category
518   ,p_type                           => p_type
519   ,p_parent_cat_usage_id            => p_parent_cat_usage_id
520   ,p_synchronous_flag	            => p_synchronous_flag
521   ,p_online_flag                    => p_online_flag
522   ,p_attribute_category             => p_attribute_category
523   ,p_attribute1                     => p_attribute1
524   ,p_attribute2                     => p_attribute2
525   ,p_attribute3                     => p_attribute3
526   ,p_attribute4                     => p_attribute4
527   ,p_attribute5                     => p_attribute5
528   ,p_attribute6                     => p_attribute6
529   ,p_attribute7                     => p_attribute7
530   ,p_attribute8                     => p_attribute8
531   ,p_attribute9                     => p_attribute9
532   ,p_attribute10                    => p_attribute10
533   ,p_attribute11                    => p_attribute11
534   ,p_attribute12                    => p_attribute12
535   ,p_attribute13                    => p_attribute13
536   ,p_attribute14                    => p_attribute14
537   ,p_attribute15                    => p_attribute15
538   ,p_attribute16                    => p_attribute16
539   ,p_attribute17                    => p_attribute17
540   ,p_attribute18                    => p_attribute18
541   ,p_attribute19                    => p_attribute19
542   ,p_attribute20                    => p_attribute20
543   ,p_data_source                    => p_data_source
544   ,p_start_date_active              => p_start_date_active
545   ,p_end_date_active                => p_end_date_active
546   ,p_comments                       => p_comments
547 
548     );
549   exception
550     when hr_api.cannot_find_prog_unit then
551       hr_api.cannot_find_prog_unit_error
552         (p_module_name => 'UPDATE_CATEGORY'
553         ,p_hook_type   => 'AP'
554         );
555   end;
556   --
557   -- When in validation only mode raise the Validate_Enabled exception
558   --
559   if p_validate then
560     raise hr_api.validate_enabled;
561   end if;
562   --
563   -- Set all output arguments
564   --
565   hr_utility.set_location(' Leaving:'||l_proc, 70);
566 exception
567   when hr_api.validate_enabled then
568     --
569     -- As the Validate_Enabled exception has been raised
570     -- we must rollback to the savepoint
571     --
572     rollback to UPDATE_CATEGORY;
573     --
574     -- Only set output warning arguments
575     -- (Any key or derived arguments must be set to null
576     -- when validation only mode is being used.)
577     --
578     p_object_version_number  := null;
579     hr_utility.set_location(' Leaving:'||l_proc, 80);
580   when others then
581     --
582     -- A validation or unexpected error has occured
583     --
584     rollback to UPDATE_CATEGORY;
585     p_object_version_number  := l_object_version_number;
586     hr_utility.set_location(' Leaving:'||l_proc, 90);
587     raise;
588 end update_category;
589 --
590 -- ----------------------------------------------------------------------------
591 -- |--------------------------< DELETE_CATEGORY >-----------------------------|
592 -- ----------------------------------------------------------------------------
593 --
594 procedure delete_category
595   (p_validate                      in     boolean  default false
596   ,p_category_usage_id             in     number
597   ,p_object_version_number         in     number
598   ) is
599   --
600   -- Declare cursors and local variables
601   --
602    -- get the activity id for the category_usage_id
603   CURSOR get_activity_id
604       IS
605   SELECT activity_id,
606          object_version_number
607     FROM ota_activity_definitions
608    WHERE category_usage_id = p_category_usage_id;
609 
610   --
611   l_proc                    varchar2(72) := g_package||'Delete_category';
612   l_budget_version_id       number;
613   l_act_object_version_number ota_activity_definitions.object_version_number%TYPE;
614   l_activity_id             ota_activity_definitions.activity_id%TYPE;
615 
616 
617 
618   --
619   --
620 begin
621   hr_utility.set_location('Entering:'|| l_proc, 10);
622   --
623   -- Issue a savepoint
624   --
625   savepoint DELETE_CATEGORY;
626   --
627   -- Truncate the time portion from all IN date parameters
628   --
629   --
630   -- Call Before Process User Hook
631   --
632   begin
633     ota_category_usage_bk3.delete_category_b
634   (p_category_usage_id           => p_category_usage_id
635   ,p_object_version_number       => p_object_version_number
636   );
637   exception
638     when hr_api.cannot_find_prog_unit then
639       hr_api.cannot_find_prog_unit_error
640         (p_module_name => 'DELETE_CATEGORY'
641         ,p_hook_type   => 'BP'
642         );
643   end;
644   --
645   -- Validation in addition to Row Handlers
646   --
647   --
648   -- Process Logic (MLS table
649   --
650   ota_ctt_del.del_tl
651   (p_category_usage_id           => p_category_usage_id
652   );
653   --
654   -- Process Logic (Base table)
655   --
656   ota_ctu_del.del
657   (p_category_usage_id       => p_category_usage_id
658   ,p_object_version_number   => p_object_version_number
659   );
660   --
661     --Call activity type API to delete corresponding activity type
662     OPEN get_activity_id;
663     FETCH get_activity_id INTO l_activity_id, l_act_object_version_number;
664     CLOSE get_activity_id;
665 
666     IF l_activity_id IS NOT NULL THEN
667 
668        ota_tad_api.del(p_activity_id             => l_activity_id,
669                        p_object_version_number   => l_act_object_version_number);
670 
671        ota_adt_del.del_tl(p_activity_id       => l_activity_id );
672     END IF;
673     --end call activity type APIs to delete activity type for the category
674   --
675   -- Call After Process User Hook
676   --
677   begin
678   ota_category_usage_bk3.delete_category_a
679   (p_category_usage_id           => p_category_usage_id
680   ,p_object_version_number       => p_object_version_number
681   );
682   exception
683     when hr_api.cannot_find_prog_unit then
684       hr_api.cannot_find_prog_unit_error
685         (p_module_name => 'DELETE_CATEGORY'
686         ,p_hook_type   => 'AP'
687         );
688   end;
689   --
690   -- When in validation only mode raise the Validate_Enabled exception
691   --
692   if p_validate then
693     raise hr_api.validate_enabled;
694   end if;
695   --
696   -- Set all output arguments
697   --
698   --
699   hr_utility.set_location(' Leaving:'||l_proc, 170);
700 exception
701   when hr_api.validate_enabled then
702     --
703     -- As the Validate_Enabled exception has been raised
704     -- we must rollback to the savepoint
705     --
706     rollback to DELETE_CATEGORY;
707     --
708     -- Only set output warning arguments
709     -- (Any key or derived arguments must be set to null
710     -- when validation only mode is being used.)
711     --
712     hr_utility.set_location(' Leaving:'||l_proc, 180);
713   when others then
714     --
715     -- A validation or unexpected error has occured
716     --
717     rollback to DELETE_CATEGORY;
718     hr_utility.set_location(' Leaving:'||l_proc, 190);
719     raise;
720 end delete_category;
721 --
722 end OTA_CATEGORY_USAGE_API;