DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_BTH_INS

Source


1 Package Body pay_bth_ins as
2 /* $Header: pybthrhi.pkb 120.2 2005/06/12 16:19:52 susivasu noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pay_bth_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:
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).
30 --
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 pay_bth_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   pay_bth_shd.g_api_dml := true;  -- Set the api dml status
64   --
65   -- Insert the row into: pay_batch_headers
66   --
67   insert into pay_batch_headers
68       (batch_id
69       ,business_group_id
70       ,batch_name
71       ,batch_status
72       ,action_if_exists
73       ,batch_reference
74       ,batch_source
75       ,batch_type
76       ,comments
77       ,date_effective_changes
78       ,purge_after_transfer
79       ,reject_if_future_changes
80       ,reject_if_results_exists
81       ,purge_after_rollback
82       ,REJECT_ENTRY_NOT_REMOVED
83       ,ROLLBACK_ENTRY_UPDATES
84       ,object_version_number
85       )
86   Values
87     (p_rec.batch_id
88     ,p_rec.business_group_id
89     ,p_rec.batch_name
90     ,p_rec.batch_status
91     ,p_rec.action_if_exists
92     ,p_rec.batch_reference
93     ,p_rec.batch_source
94     ,p_rec.batch_type
95     ,p_rec.comments
96     ,p_rec.date_effective_changes
97     ,p_rec.purge_after_transfer
98     ,p_rec.reject_if_future_changes
99     ,p_rec.reject_if_results_exists
100     ,p_rec.purge_after_rollback
101     ,p_rec.REJECT_ENTRY_NOT_REMOVED
102     ,p_rec.ROLLBACK_ENTRY_UPDATES
103     ,p_rec.object_version_number
104     );
105   --
106   pay_bth_shd.g_api_dml := false;   -- Unset the api dml status
107   --
108   hr_utility.set_location(' Leaving:'||l_proc, 10);
109 Exception
110   When hr_api.check_integrity_violated Then
111     -- A check constraint has been violated
112     pay_bth_shd.g_api_dml := false;   -- Unset the api dml status
113     pay_bth_shd.constraint_error
114       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
115   When hr_api.parent_integrity_violated Then
116     -- Parent integrity has been violated
117     pay_bth_shd.g_api_dml := false;   -- Unset the api dml status
118     pay_bth_shd.constraint_error
119       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
120   When hr_api.unique_integrity_violated Then
121     -- Unique integrity has been violated
122     pay_bth_shd.g_api_dml := false;   -- Unset the api dml status
123     pay_bth_shd.constraint_error
124       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
125   When Others Then
126     pay_bth_shd.g_api_dml := false;   -- Unset the api dml status
127     Raise;
128 End insert_dml;
129 --
130 -- ----------------------------------------------------------------------------
131 -- |------------------------------< pre_insert >------------------------------|
132 -- ----------------------------------------------------------------------------
133 -- {Start Of Comments}
134 --
135 -- Description:
136 --   This private procedure contains any processing which is required before
137 --   the insert dml. Presently, if the entity has a corresponding primary
138 --   key which is maintained by an associating sequence, the primary key for
139 --   the entity will be populated with the next sequence value in
140 --   preparation for the insert dml.
141 --
142 -- Prerequisites:
143 --   This is an internal procedure which is called from the ins procedure.
144 --
145 -- In Parameters:
146 --   A Pl/Sql record structre.
147 --
148 -- Post Success:
149 --   Processing continues.
150 --
151 -- Post Failure:
152 --   If an error has occurred, an error message and exception will be raised
153 --   but not handled.
154 --
155 -- Developer Implementation Notes:
156 --   Any pre-processing required before the insert dml is issued should be
157 --   coded within this procedure. As stated above, a good example is the
158 --   generation of a primary key number via a corresponding sequence.
159 --   It is important to note that any 3rd party maintenance should be reviewed
160 --   before placing in this procedure.
161 --
162 -- Access Status:
163 --   Internal Row Handler Use Only.
164 --
165 -- {End Of Comments}
166 -- ----------------------------------------------------------------------------
167 Procedure pre_insert
168   (p_rec  in out nocopy pay_bth_shd.g_rec_type
169   ) is
170 --
171   l_proc  varchar2(72) := g_package||'pre_insert';
172 --
173   Cursor C_Sel1 is select pay_batch_headers_s.nextval from sys.dual;
174 --
175 Begin
176   hr_utility.set_location('Entering:'||l_proc, 5);
177   --
178   --
179   -- Select the next sequence number
180   --
181   Open C_Sel1;
182   Fetch C_Sel1 Into p_rec.batch_id;
183   Close C_Sel1;
184   --
185   hr_utility.set_location(' Leaving:'||l_proc, 10);
186 End pre_insert;
187 --
188 -- ----------------------------------------------------------------------------
189 -- |-----------------------------< post_insert >------------------------------|
190 -- ----------------------------------------------------------------------------
191 -- {Start Of Comments}
192 --
193 -- Description:
194 --   This private procedure contains any processing which is required after the
195 --   insert dml.
196 --
197 -- Prerequisites:
198 --   This is an internal procedure which is called from the ins procedure.
199 --
200 -- In Parameters:
201 --   A Pl/Sql record structre.
202 --
203 -- Post Success:
204 --   Processing continues.
205 --
206 -- Post Failure:
207 --   If an error has occurred, an error message and exception will be raised
208 --   but not handled.
209 --
210 -- Developer Implementation Notes:
211 --   Any post-processing required after the insert dml is issued should be
212 --   coded within this procedure. It is important to note that any 3rd party
213 --   maintenance should be reviewed before placing in this procedure.
214 --
215 -- Access Status:
216 --   Internal Row Handler Use Only.
217 --
218 -- {End Of Comments}
219 -- ----------------------------------------------------------------------------
220 Procedure post_insert
221   (p_session_date                 in date
222   ,p_rec                          in pay_bth_shd.g_rec_type
223   ) is
224 --
225   l_proc  varchar2(72) := g_package||'post_insert';
226 --
227 Begin
228   hr_utility.set_location('Entering:'||l_proc, 5);
229   begin
230     --
231     pay_bth_rki.after_insert
232       (p_session_date
233       => p_session_date
234       ,p_batch_id
235       => p_rec.batch_id
236       ,p_business_group_id
237       => p_rec.business_group_id
238       ,p_batch_name
239       => p_rec.batch_name
240       ,p_batch_status
241       => p_rec.batch_status
242       ,p_action_if_exists
243       => p_rec.action_if_exists
244       ,p_batch_reference
245       => p_rec.batch_reference
246       ,p_batch_source
247       => p_rec.batch_source
248       ,p_batch_type
249       => p_rec.batch_type
250       ,p_comments
251       => p_rec.comments
252       ,p_date_effective_changes
253       => p_rec.date_effective_changes
254       ,p_purge_after_transfer
255       => p_rec.purge_after_transfer
256       ,p_reject_if_future_changes
257       => p_rec.reject_if_future_changes
258       ,p_object_version_number
259       => p_rec.object_version_number
260       ,p_reject_if_results_exists
261       => p_rec.reject_if_results_exists
262       ,p_purge_after_rollback
263       => p_rec.purge_after_rollback
264       ,p_REJECT_ENTRY_NOT_REMOVED
265       => p_rec.REJECT_ENTRY_NOT_REMOVED
266       ,p_ROLLBACK_ENTRY_UPDATES
267       => p_rec.ROLLBACK_ENTRY_UPDATES
268       );
269     --
270   exception
271     --
272     when hr_api.cannot_find_prog_unit then
273       --
274       hr_api.cannot_find_prog_unit_error
275         (p_module_name => 'PAY_BATCH_HEADERS'
276         ,p_hook_type   => 'AI');
277       --
278   end;
279   --
280   hr_utility.set_location(' Leaving:'||l_proc, 10);
281 End post_insert;
282 --
283 -- ----------------------------------------------------------------------------
284 -- |---------------------------------< ins >----------------------------------|
285 -- ----------------------------------------------------------------------------
286 Procedure ins
287   (p_session_date                 in date,
288    p_rec                          in out nocopy pay_bth_shd.g_rec_type
289   ) is
290 --
291   l_proc  varchar2(72) := g_package||'ins';
292 --
293 Begin
294   hr_utility.set_location('Entering:'||l_proc, 5);
295   --
296   -- Call the supporting insert validate operations
297   --
298   pay_bth_bus.insert_validate
299      (p_session_date,
300       p_rec
301      );
302   --
303   -- Call the supporting pre-insert operation
304   --
305   pay_bth_ins.pre_insert(p_rec);
306   --
307   -- Insert the row
308   --
309   pay_bth_ins.insert_dml(p_rec);
310   --
311   -- Call the supporting post-insert operation
312   --
313   pay_bth_ins.post_insert
314      (p_session_date
315      ,p_rec
316      );
317   --
318   hr_utility.set_location('Leaving:'||l_proc, 20);
319 end ins;
320 --
321 -- ----------------------------------------------------------------------------
322 -- |---------------------------------< ins >----------------------------------|
323 -- ----------------------------------------------------------------------------
324 Procedure ins
325   (p_session_date                   in     date
326   ,p_business_group_id              in     number
327   ,p_batch_name                     in     varchar2
328   ,p_batch_status                   in     varchar2
329   ,p_action_if_exists               in     varchar2 default null
330   ,p_batch_reference                in     varchar2 default null
331   ,p_batch_source                   in     varchar2 default null
332   ,p_batch_type                     in     varchar2 default null
333   ,p_comments                       in     varchar2 default null
334   ,p_date_effective_changes         in     varchar2 default null
335   ,p_purge_after_transfer           in     varchar2 default null
336   ,p_reject_if_future_changes       in     varchar2 default null
337   ,p_batch_id                          out nocopy number
338   ,p_object_version_number             out nocopy number
339   ,p_reject_if_results_exists       in     varchar2 default null
340   ,p_purge_after_rollback           in     varchar2 default null
341   ,p_REJECT_ENTRY_NOT_REMOVED       in     varchar2 default null
342   ,p_ROLLBACK_ENTRY_UPDATES         in     varchar2 default null
343   ) is
344 --
345   l_rec	  pay_bth_shd.g_rec_type;
346   l_proc  varchar2(72) := g_package||'ins';
347 --
348 Begin
349   hr_utility.set_location('Entering:'||l_proc, 5);
350   --
351   -- Call conversion function to turn arguments into the
352   -- p_rec structure.
353   --
354   l_rec :=
355   pay_bth_shd.convert_args
356     (null
357     ,p_business_group_id
358     ,p_batch_name
359     ,p_batch_status
360     ,p_action_if_exists
361     ,p_batch_reference
362     ,p_batch_source
363     ,p_batch_type
364     ,p_comments
365     ,p_date_effective_changes
366     ,p_purge_after_transfer
367     ,p_reject_if_future_changes
368     ,p_reject_if_results_exists
369     ,p_purge_after_rollback
370     ,p_REJECT_ENTRY_NOT_REMOVED
371     ,p_ROLLBACK_ENTRY_UPDATES
372     ,null
373     );
374   --
375   -- Having converted the arguments into the pay_bth_rec
376   -- plsql record structure we call the corresponding record business process.
377   --
378   pay_bth_ins.ins
379      (p_session_date,
380       l_rec
381      );
382   --
383   -- As the primary key argument(s)
384   -- are specified as an OUT's we must set these values.
385   --
386   p_batch_id := l_rec.batch_id;
387   p_object_version_number := l_rec.object_version_number;
388   --
389   hr_utility.set_location(' Leaving:'||l_proc, 10);
390 End ins;
391 --
392 end pay_bth_ins;