DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_CANCEL_PLACEMENT_API

Source


1 PACKAGE BODY hr_cancel_placement_api AS
2 /* $Header: pecplapi.pkb 115.7 2002/12/10 15:36:42 pkakar noship $ */
3 --
4 -- Package Variables
5 --
6 g_package  VARCHAR2(33) := 'hr_cancel_placement_api.';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |----------------------------< cancel_placement >--------------------------|
10 -- ----------------------------------------------------------------------------
11 --
12 PROCEDURE cancel_placement
13   (p_validate            IN     BOOLEAN  DEFAULT FALSE
14   ,p_person_id           IN     NUMBER
15   ,p_effective_date      IN     DATE
16   ,p_supervisor_warning     OUT NOCOPY BOOLEAN
17   ,p_recruiter_warning      OUT NOCOPY BOOLEAN
18   ,p_event_warning          OUT NOCOPY BOOLEAN
19   ,p_interview_warning      OUT NOCOPY BOOLEAN
20   ,p_review_warning         OUT NOCOPY BOOLEAN
21   ,p_vacancy_warning        OUT NOCOPY BOOLEAN
22   ,p_requisition_warning    OUT NOCOPY BOOLEAN
23   ,p_budget_warning         OUT NOCOPY BOOLEAN
24   ,p_payment_warning        OUT NOCOPY BOOLEAN) IS
25   --
26   -- Declare cursors and local variables
27   --
28   l_proc                VARCHAR2(72) := g_package||'cancel_placement';
29   l_system_person_type  per_person_types.system_person_type%TYPE;
30   l_business_group_id   per_periods_of_placement.business_group_id%TYPE;
31   l_date_start          DATE;
32   l_effective_date      DATE;
33   --
34   CURSOR csr_date_start IS
35     SELECT date_start,
36            business_group_id
37     FROM   per_periods_of_placement pp
38     WHERE  pp.person_id = p_person_id
39     AND    l_effective_date BETWEEN pp.date_start
40                                 AND NVL(pp.actual_termination_date,hr_general.end_of_time);
41   --
42 BEGIN
43   --
44   hr_utility.set_location('Entering:'|| l_proc, 10);
45   --
46   -- Issue a savepoint
47   --
48   SAVEPOINT cancel_placement;
49   --
50   -- Truncate the time portion from all IN date parameters
51   --
52   l_effective_date := TRUNC(p_effective_date);
53   --
54   -- Retrieve date_start from the period of placement record.
55   --
56   OPEN  csr_date_start;
57   FETCH csr_date_start INTO l_date_start, l_business_group_id;
58   --
59   IF csr_date_start%NOTFOUND THEN
60     --
61     CLOSE csr_date_start;
62     --
63     hr_utility.set_message(801,'HR_289751_CWK_POP_ERROR');
64     hr_utility.raise_error;
65     --
66   END IF;
67   --
68   CLOSE csr_date_start;
69   --
70   -- Call Before Process User Hook
71   --
72   BEGIN
73     --
74     per_cancel_placement_bk1.cancel_placement_b
75       (p_business_group_id => l_business_group_id
76       ,p_person_id         => p_person_id
77       ,p_effective_date    => l_effective_date);
78     --
79   EXCEPTION
80     --
81     WHEN hr_api.cannot_find_prog_unit THEN
82       --
83       hr_api.cannot_find_prog_unit_error
84         (p_module_name => 'cancel_placement'
85         ,p_hook_type   => 'BP');
86       --
87   END;
88   --
89   hr_utility.set_location(l_proc, 20);
90   --
91   per_cancel_hire_or_apl_pkg.lock_cwk_rows
92     (p_person_id         => p_person_id
93     ,p_effective_date    => l_effective_date
94     ,p_business_group_id => l_business_group_id);
95   --
96   hr_utility.set_location(l_proc, 25);
97   --
98   -- Validation checks to ensure that the canelling of
99   -- the placement is a valid operation for the worker.
100   --
101   per_cancel_hire_or_apl_pkg.pre_cancel_placement_checks
102     (p_person_id           => p_person_id
103     ,p_business_group_id   => l_business_group_id
104     ,p_effective_date      => l_effective_date
105     ,p_date_start          => l_date_start
106     ,p_supervisor_warning  => p_supervisor_warning
107     ,p_recruiter_warning   => p_recruiter_warning
108     ,p_event_warning       => p_event_warning
109     ,p_interview_warning   => p_interview_warning
110     ,p_review_warning      => p_review_warning
111     ,p_vacancy_warning     => p_vacancy_warning
112     ,p_requisition_warning => p_requisition_warning
113     ,p_budget_warning      => p_budget_warning
114     ,p_payment_warning     => p_payment_warning );
115   --
116   hr_utility.set_location(l_proc, 30);
117   --
118   -- Process Logic
119   --
120   per_cancel_hire_or_apl_pkg.do_cancel_placement
121     (p_person_id            => p_person_id
122     ,p_business_group_id    => l_business_group_id
123     ,p_effective_date       => l_effective_date
124     ,p_date_start           => l_date_start);
125   --
126   hr_utility.set_location(l_proc, 40);
127   --
128   -- Call After Process User Hook
129   --
130   BEGIN
131     --
132     per_cancel_placement_bk1.cancel_placement_a
133       (p_business_group_id   => l_business_group_id
134       ,p_person_id           => p_person_id
135       ,p_effective_date      => l_effective_date
136       ,p_supervisor_warning  => p_supervisor_warning
137       ,p_recruiter_warning   => p_recruiter_warning
138       ,p_event_warning       => p_event_warning
139       ,p_interview_warning   => p_interview_warning
140       ,p_review_warning      => p_review_warning
141       ,p_vacancy_warning     => p_vacancy_warning
142       ,p_requisition_warning => p_requisition_warning
143       ,p_budget_warning      => p_budget_warning
144       ,p_payment_warning     => p_payment_warning);
145     --
146   EXCEPTION
147     --
148     WHEN hr_api.cannot_find_prog_unit THEN
149       --
150       hr_api.cannot_find_prog_unit_error
151         (p_module_name => 'cancel_placement'
152         ,p_hook_type   => 'AP');
153       --
154   END;
155   --
156   hr_utility.set_location(l_proc, 50);
157   --
158   -- When in validation only mode raise the Validate_Enabled exception
159   --
160   IF p_validate THEN
161     --
162     RAISE hr_api.validate_enabled;
163     --
164   END IF;
165   --
166   -- Set all output arguments
167   --
168   hr_utility.set_location(' Leaving:'||l_proc, 997);
169   --
170 EXCEPTION
171   --
172   WHEN hr_api.validate_enabled THEN
173     --
174     -- As the Validate_Enabled exception has been raised
175     -- we must rollback to the savepoint
176     --
177     ROLLBACK TO cancel_placement;
178     --
179     -- Only set output warning arguments
180     -- (Any key or derived arguments must be set to null
181     -- when validation only mode is being used.)
182     --
183     hr_utility.set_location(' Leaving:'||l_proc, 998);
184     --
185   WHEN OTHERS THEN
186     --
187     -- A validation or unexpected error has occured
188     --
189     ROLLBACK TO cancel_placement;
190     --
191     -- set out parameters
192     --
193    p_supervisor_warning := false;
194    p_recruiter_warning  := false;
195    p_event_warning      := false;
196    p_interview_warning  := false;
197    p_review_warning     := false;
198    p_vacancy_warning    := false;
199    p_requisition_warning := false;
200    p_budget_warning      := false;
201    p_payment_warning      := false;
202    hr_utility.set_location(' Leaving:'||l_proc, 999);
203     RAISE;
204     --
205 END cancel_placement;
206 --
207 END hr_cancel_placement_api;