DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PCE_INS

Source


1 PACKAGE BODY per_pce_ins AS
2 /* $Header: pepcerhi.pkb 120.1 2006/10/18 09:19:34 grreddy noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  VARCHAR2(33) := '  per_pce_ins.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< insert_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the actual dml insert logic. The processing of
17 --   this procedure are as follows:
18 --   1) Initialise the object_version_number to 1 if the object_version_number
19 --      IS defined as an attribute for this entity.
20 --   2) To set and unset the g_api_dml status as required (as we are about to
21 --      perform dml).
22 --   3) To insert the row into the schema.
23 --   4) To trap any constraint violations that may have occurred.
24 --   5) To raise any other errors.
25 --
26 -- Prerequisites:
30 --
27 --   This IS an internal private procedure which must be called from the ins
28 --   procedure and must have all mandatory attributes set (except the
29 --   object_version_number which IS initialised within this procedure).
31 -- In Parameters:
32 --   A Pl/Sql record structre.
33 --
34 -- Post Success:
35 --   The specified row will be inserted into the schema.
36 --
37 -- Post Failure:
38 --   On the insert dml failure it IS important to note that we always reset the
39 --   g_api_dml status to false.
40 --   If a check, unique or parent integrity constraint violation IS raised the
41 --   constraint_error procedure will be called.
42 --   If any other error IS reported, the error will be raised after the
43 --   g_api_dml status IS reset.
44 --
45 -- Developer Implementation Notes:
46 --   None.
47 --
48 -- Access Status:
49 --   Internal Row Handler Use Only.
50 --
51 -- {END Of Comments}
52 -- ----------------------------------------------------------------------------
53 PROCEDURE insert_dml
54   (p_rec IN OUT NOCOPY per_pce_shd.g_rec_type
55   ) IS
56 --
57   l_proc  VARCHAR2(72) := g_package||'insert_dml';
58 --
59 BEGIN
60   hr_utility.set_location('Entering:'||l_proc, 5);
61   p_rec.object_version_number := 1;  -- Initialise the object version
62   --
63   --
64   --
65   -- Insert the row into: per_cagr_entitlements
66   --
67   INSERT INTO per_cagr_entitlements
68       (cagr_entitlement_id
69       ,cagr_entitlement_item_id
70       ,collective_agreement_id
71       ,start_date
72       ,end_date
73       ,status
74       ,formula_criteria
75       ,formula_id
76       ,units_of_measure
77 	  ,message_level
78       ,object_version_number
79       )
80   VALUES
81     (p_rec.cagr_entitlement_id
82     ,p_rec.cagr_entitlement_item_id
83     ,p_rec.collective_agreement_id
84     ,p_rec.start_date
85     ,p_rec.end_date
86     ,p_rec.status
87     ,p_rec.formula_criteria
88     ,p_rec.formula_id
89     ,p_rec.units_of_measure
90 	,p_rec.message_level
91     ,p_rec.object_version_number
92     );
93   --
94   --
95   --
96   hr_utility.set_location(' Leaving:'||l_proc, 10);
97 EXCEPTION
98   WHEN hr_api.check_integrity_violated THEN
99     -- A check constraint has been violated
100     --
101     per_pce_shd.constraint_error
102       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
103   WHEN hr_api.parent_integrity_violated THEN
104     -- Parent integrity has been violated
105     --
106     per_pce_shd.constraint_error
107       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
108   WHEN hr_api.unique_integrity_violated THEN
109     -- Unique integrity has been violated
110     --
111     per_pce_shd.constraint_error
112       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
113   WHEN Others THEN
114     --
115     RAISE;
116 END insert_dml;
117 --
118 -- ----------------------------------------------------------------------------
119 -- |------------------------------< pre_insert >------------------------------|
120 -- ----------------------------------------------------------------------------
121 -- {Start Of Comments}
122 --
123 -- Description:
124 --   This private procedure contains any processing which IS required before
125 --   the insert dml. Presently, if the entity has a corresponding primary
126 --   key which IS maintained by an associating sequence, the primary key for
127 --   the entity will be populated with the next sequence value IN
128 --   preparation for the insert dml.
129 --
130 -- Prerequisites:
131 --   This IS an internal procedure which IS called from the ins procedure.
132 --
133 -- In Parameters:
134 --   A Pl/Sql record structre.
135 --
136 -- Post Success:
137 --   Processing continues.
138 --
139 -- Post Failure:
140 --   If an error has occurred, an error message and exception will be raised
141 --   but not handled.
142 --
143 -- Developer Implementation Notes:
144 --   Any pre-processing required before the insert dml IS issued should be
145 --   coded within this procedure. As stated above, a good example IS the
146 --   generation of a primary key NUMBER via a corresponding sequence.
147 --   It IS important to note that any 3rd party maintenance should be reviewed
148 --   before placing IN this procedure.
149 --
150 -- Access Status:
151 --   Internal Row Handler Use Only.
152 --
153 -- {END Of Comments}
154 -- ----------------------------------------------------------------------------
155 PROCEDURE pre_insert
156   (p_rec  IN OUT NOCOPY per_pce_shd.g_rec_type
157   ) IS
158 --
159   l_proc  VARCHAR2(72) := g_package||'pre_insert';
160 --
161   Cursor C_Sel1 IS select per_cagr_entitlements_s.nextval from sys.dual;
162 --
163 BEGIN
164   hr_utility.set_location('Entering:'||l_proc, 5);
165   --
166   --
167   -- Select the next sequence NUMBER
168   --
169   Open C_Sel1;
170   Fetch C_Sel1 Into p_rec.cagr_entitlement_id;
171   Close C_Sel1;
172   --
173   hr_utility.set_location(' Leaving:'||l_proc, 10);
174 END pre_insert;
175 --
176 -- ----------------------------------------------------------------------------
180 --
177 -- |-----------------------------< post_insert >------------------------------|
178 -- ----------------------------------------------------------------------------
179 -- {Start Of Comments}
181 -- Description:
182 --   This private procedure contains any processing which IS required after
183 --   the insert dml.
184 --
185 -- Prerequisites:
186 --   This IS an internal procedure which IS called from the ins procedure.
187 --
188 -- In Parameters:
189 --   A Pl/Sql record structre.
190 --
191 -- Post Success:
192 --   Processing continues.
193 --
194 -- Post Failure:
195 --   If an error has occurred, an error message and exception will be raised
196 --   but not handled.
197 --
198 -- Developer Implementation Notes:
199 --   Any post-processing required after the insert dml IS issued should be
200 --   coded within this procedure. It IS important to note that any 3rd party
201 --   maintenance should be reviewed before placing IN this procedure.
202 --
203 -- Access Status:
204 --   Internal Row Handler Use Only.
205 --
206 -- {END Of Comments}
207 -- ----------------------------------------------------------------------------
208 PROCEDURE post_insert
209   (p_effective_date               IN DATE
210   ,p_rec                          IN per_pce_shd.g_rec_type
211   ) IS
212 --
213   l_proc  VARCHAR2(72) := g_package||'post_insert';
214 --
215 BEGIN
216   hr_utility.set_location('Entering:'||l_proc, 5);
217   begin
218     --
219     per_pce_rki.after_insert
220       (p_effective_date              => p_effective_date
221       ,p_cagr_entitlement_id         => p_rec.cagr_entitlement_id
222       ,p_cagr_entitlement_item_id    => p_rec.cagr_entitlement_item_id
223       ,p_collective_agreement_id     => p_rec.collective_agreement_id
224       ,p_start_date                  => p_rec.start_date
225       ,p_end_date                    => p_rec.end_date
226       ,p_status                      => p_rec.status
227       ,p_formula_criteria            => p_rec.formula_criteria
228       ,p_formula_id                  => p_rec.formula_id
229       ,p_units_of_measure            => p_rec.units_of_measure
230 	  ,p_message_level               => p_rec.message_level
231       ,p_object_version_number       => p_rec.object_version_number
232       );
233     --
234   exception
235     --
236     when hr_api.cannot_find_prog_unit then
237       --
238       hr_api.cannot_find_prog_unit_error
239         (p_module_name => 'PER_CAGR_ENTITLEMENTS'
240         ,p_hook_type   => 'AI');
241       --
242   end;
243   --
244   hr_utility.set_location(' Leaving:'||l_proc, 10);
245 END post_insert;
246 --
247 -- ----------------------------------------------------------------------------
248 -- |---------------------------------< ins >----------------------------------|
249 -- ----------------------------------------------------------------------------
250 PROCEDURE ins
251   (p_effective_date               IN DATE
252   ,p_rec                          IN OUT NOCOPY per_pce_shd.g_rec_type
253   ) IS
254 --
255   l_proc  VARCHAR2(72) := g_package||'ins';
256 --
257 BEGIN
258   --
259   hr_utility.set_location('Entering:'||l_proc, 5);
260   --
261   p_rec.start_date := TRUNC(p_effective_date);
262   --
263   -- Call the supporting insert validate operations
264   --
265   per_pce_bus.insert_validate
266      (p_effective_date
267      ,p_rec
268      );
269   --
270   -- Call the supporting pre-insert operation
271   --
272   per_pce_ins.pre_insert(p_rec);
273   --
274   -- Insert the row
275   --
276   per_pce_ins.insert_dml(p_rec);
277   --
278   -- Call the supporting post-insert operation
279   --
280   per_pce_ins.post_insert
281      (p_effective_date
282      ,p_rec
283      );
284   --
285   hr_utility.set_location('Leaving:'||l_proc, 20);
286 end ins;
287 --
288 -- ----------------------------------------------------------------------------
289 -- |---------------------------------< ins >----------------------------------|
290 -- ----------------------------------------------------------------------------
291 PROCEDURE ins
292   (p_effective_date                 IN     DATE
293   ,p_cagr_entitlement_item_id       IN     NUMBER
294   ,p_collective_agreement_id        IN     NUMBER
295   ,p_status                         IN     VARCHAR2
296   ,p_formula_criteria               IN     VARCHAR2
297   ,p_end_date                       IN     DATE     DEFAULT NULL
298   ,p_formula_id                     IN     NUMBER   DEFAULT NULL
299   ,p_units_of_measure               IN     VARCHAR2 DEFAULT NULL
300   ,p_message_level                  IN     VARCHAR2
301   ,p_cagr_entitlement_id               OUT NOCOPY NUMBER
302   ,p_object_version_number             OUT NOCOPY NUMBER
303   ) IS
304   --
305   l_rec   per_pce_shd.g_rec_type;
306   l_proc  VARCHAR2(72) := g_package||'ins';
307   l_start_date DATE;
308   --
309 BEGIN
310   --
311   hr_utility.set_location('Entering:'||l_proc, 5);
312   --
313   l_start_Date := TRUNC(p_effective_date);
314   --
318   l_rec :=
315   -- Call conversion function to turn arguments into the
316   -- p_rec structure.
317   --
319   per_pce_shd.convert_args
320     (NULL
321     ,p_cagr_entitlement_item_id
322     ,p_collective_agreement_id
323     ,l_start_date
324     ,p_end_date
325     ,p_status
326     ,p_formula_criteria
327     ,p_formula_id
328     ,p_units_of_measure
329 	,p_message_level
330     ,NULL
331     );
332   --
333   -- Having converted the arguments into the per_pce_rec
334   -- plsql record structure we call the corresponding record business process.
335   --
336   per_pce_ins.ins
337      (p_effective_date
338      ,l_rec
339      );
340   --
341   -- As the primary key argument(s)
342   -- are specified as an OUT's we must set these values.
343   --
344   p_cagr_entitlement_id := l_rec.cagr_entitlement_id;
345   p_object_version_number := l_rec.object_version_number;
346   --
347   hr_utility.set_location(' Leaving:'||l_proc, 10);
348 END ins;
349 --
350 end per_pce_ins;