DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_TCC_INS

Source


1 Package Body ota_tcc_ins as
2 /* $Header: ottccrhi.pkb 120.1 2005/09/01 07:26:31 ssur noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ota_tcc_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
24 --   5) To raise any other errors.
21 --      perform dml).
22 --   3) To insert the row into the schema.
23 --   4) To trap any constraint violations that may have occurred.
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 ota_tcc_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: ota_cross_charges
66   --
67   insert into ota_cross_charges
68       (cross_charge_id
69       ,business_group_id
70       ,gl_set_of_books_id
71       ,object_version_number
72       ,type
73       ,from_to
74       ,start_date_active
75       ,end_date_active
76       )
77   Values
78     (p_rec.cross_charge_id
79     ,p_rec.business_group_id
80     ,p_rec.gl_set_of_books_id
81     ,p_rec.object_version_number
82     ,p_rec.type
83     ,p_rec.from_to
84     ,p_rec.start_date_active
85     ,p_rec.end_date_active
86     );
87   --
88   --
89   --
90   hr_utility.set_location(' Leaving:'||l_proc, 10);
91 Exception
92   When hr_api.check_integrity_violated Then
93     -- A check constraint has been violated
94     --
95     ota_tcc_shd.constraint_error
96       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
97   When hr_api.parent_integrity_violated Then
98     -- Parent integrity has been violated
99     --
100     ota_tcc_shd.constraint_error
101       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
102   When hr_api.unique_integrity_violated Then
103     -- Unique integrity has been violated
104     --
105     ota_tcc_shd.constraint_error
106       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
107   When Others Then
108     --
109     Raise;
110 End insert_dml;
111 --
112 -- ----------------------------------------------------------------------------
113 -- |------------------------------< pre_insert >------------------------------|
114 -- ----------------------------------------------------------------------------
115 -- {Start Of Comments}
116 --
117 -- Description:
118 --   This private procedure contains any processing which is required before
119 --   the insert dml. Presently, if the entity has a corresponding primary
120 --   key which is maintained by an associating sequence, the primary key for
121 --   the entity will be populated with the next sequence value in
122 --   preparation for the insert dml.
123 --
124 -- Prerequisites:
125 --   This is an internal procedure which is called from the ins procedure.
126 --
127 -- In Parameters:
128 --   A Pl/Sql record structre.
129 --
130 -- Post Success:
131 --   Processing continues.
132 --
133 -- Post Failure:
134 --   If an error has occurred, an error message and exception will be raised
135 --   but not handled.
136 --
137 -- Developer Implementation Notes:
138 --   Any pre-processing required before the insert dml is issued should be
139 --   coded within this procedure. As stated above, a good example is the
140 --   generation of a primary key number via a corresponding sequence.
141 --   It is important to note that any 3rd party maintenance should be reviewed
142 --   before placing in this procedure.
143 --
144 -- Access Status:
145 --   Internal Row Handler Use Only.
146 --
147 -- {End Of Comments}
148 -- ----------------------------------------------------------------------------
149 Procedure pre_insert
150   (p_rec  in out nocopy ota_tcc_shd.g_rec_type
151   ) is
152 --
153   l_proc  varchar2(72) := g_package||'pre_insert';
154 --
155   Cursor C_Sel1 is select ota_cross_charges_s.nextval from sys.dual;
156 --
157 Begin
158   hr_utility.set_location('Entering:'||l_proc, 5);
159   --
160   --
161   -- Select the next sequence number
162   --
163   Open C_Sel1;
164   Fetch C_Sel1 Into p_rec.cross_charge_id;
165   Close C_Sel1;
166   --
167   hr_utility.set_location(' Leaving:'||l_proc, 10);
168 End pre_insert;
169 --
170 -- ----------------------------------------------------------------------------
171 -- |-----------------------------< post_insert >------------------------------|
172 -- ----------------------------------------------------------------------------
173 -- {Start Of Comments}
174 --
175 -- Description:
176 --   This private procedure contains any processing which is required after the
177 --   insert dml.
178 --
179 -- Prerequisites:
180 --   This is an internal procedure which is called from the ins procedure.
181 --
182 -- In Parameters:
183 --   A Pl/Sql record structre.
184 --
185 -- Post Success:
186 --   Processing continues.
187 --
188 -- Post Failure:
189 --   If an error has occurred, an error message and exception will be raised
190 --   but not handled.
191 --
192 -- Developer Implementation Notes:
193 --   Any post-processing required after the insert dml is issued should be
194 --   coded within this procedure. It is important to note that any 3rd party
195 --   maintenance should be reviewed before placing in this procedure.
196 --
197 -- Access Status:
198 --   Internal Row Handler Use Only.
199 --
200 -- {End Of Comments}
201 -- ----------------------------------------------------------------------------
202 Procedure post_insert
203   (p_effective_date               in date
204   ,p_rec                          in ota_tcc_shd.g_rec_type
205   ) is
206 --
207   l_proc  varchar2(72) := g_package||'post_insert';
208 --
209 Begin
210   hr_utility.set_location('Entering:'||l_proc, 5);
211   begin
212     --
213     ota_tcc_rki.after_insert
214       (p_effective_date              => p_effective_date
215       ,p_cross_charge_id
216       => p_rec.cross_charge_id
217       ,p_business_group_id
218       => p_rec.business_group_id
219       ,p_gl_set_of_books_id
220       => p_rec.gl_set_of_books_id
221       ,p_object_version_number
222       => p_rec.object_version_number
223       ,p_type
224       => p_rec.type
225       ,p_from_to
226       => p_rec.from_to
227       ,p_start_date_active
228       => p_rec.start_date_active
229       ,p_end_date_active
230       => p_rec.end_date_active
231       );
232     --
233   exception
234     --
235     when hr_api.cannot_find_prog_unit then
236       --
237       hr_api.cannot_find_prog_unit_error
238         (p_module_name => 'OTA_CROSS_CHARGES'
239         ,p_hook_type   => 'AI');
240       --
241   end;
242   --
243   hr_utility.set_location(' Leaving:'||l_proc, 10);
244 End post_insert;
245 --
246 -- ----------------------------------------------------------------------------
247 -- |---------------------------------< ins >----------------------------------|
248 -- ----------------------------------------------------------------------------
249 Procedure ins
250   (p_effective_date               in date
251   ,p_rec                          in out nocopy ota_tcc_shd.g_rec_type
252   ,p_validate                     in     boolean    default false
253   ) is
254 --
255   l_proc  varchar2(72) := g_package||'ins';
256 --
257 Begin
258   hr_utility.set_location('Entering:'||l_proc, 5);
259   --
260   -- Call the supporting insert validate operations
261   --
262   If p_validate then
263     --
264     -- Issue the savepoint.
265     --
266     SAVEPOINT ins_ota_tcc;
267   End If;
268 
269 
270   ota_tcc_bus.insert_validate
271      (p_effective_date
272      ,p_rec
273      );
274   --
275   -- Call the supporting pre-insert operation
276   --
277   ota_tcc_ins.pre_insert(p_rec);
278   --
279   -- Insert the row
280   --
281   ota_tcc_ins.insert_dml(p_rec);
282   --
283   -- Call the supporting post-insert operation
284   --
285   ota_tcc_ins.post_insert
286      (p_effective_date
287      ,p_rec
288      );
289   --
290   If p_validate then
291     Raise HR_Api.Validate_Enabled;
292   End If;
293 
294   hr_utility.set_location('Leaving:'||l_proc, 20);
295   Exception
296   When HR_Api.Validate_Enabled Then
297     --
298     -- As the Validate_Enabled exception has been raised
299     -- we must rollback to the savepoint
300     --
301     ROLLBACK TO ins_ota_tcc;
302 
303 end ins;
304 --
305 -- ----------------------------------------------------------------------------
306 -- |---------------------------------< ins >----------------------------------|
307 -- ----------------------------------------------------------------------------
308 Procedure ins
309   (p_effective_date               in     date
310   ,p_business_group_id            in     number
311   ,p_gl_set_of_books_id           in     number
312   ,p_type                         in     varchar2
313   ,p_from_to                      in     varchar2
314   ,p_start_date_active            in     date
315   ,p_end_date_active              in     date     default null
316   ,p_cross_charge_id                   out nocopy number
317   ,p_object_version_number             out nocopy number
318   ,p_validate                     in     boolean default false
319   ) is
320 --
321   l_rec	  ota_tcc_shd.g_rec_type;
322   l_proc  varchar2(72) := g_package||'ins';
323 --
324 Begin
325   hr_utility.set_location('Entering:'||l_proc, 5);
326   --
327   -- Call conversion function to turn arguments into the
328   -- p_rec structure.
329   --
330   l_rec :=
331   ota_tcc_shd.convert_args
332     (null
333     ,p_business_group_id
334     ,p_gl_set_of_books_id
335     ,null
336     ,p_type
337     ,p_from_to
338     ,p_start_date_active
339     ,p_end_date_active
340     );
341   --
342   -- Having converted the arguments into the ota_tcc_rec
343   -- plsql record structure we call the corresponding record business process.
344   --
345   ota_tcc_ins.ins
346      (p_effective_date
347      ,l_rec
348      ,p_validate
349      );
350   --
351   -- As the primary key argument(s)
352   -- are specified as an OUT's we must set these values.
353   --
354   p_cross_charge_id := l_rec.cross_charge_id;
355   p_object_version_number := l_rec.object_version_number;
356   --
357   hr_utility.set_location(' Leaving:'||l_proc, 10);
358 End ins;
359 --
360 end ota_tcc_ins;