1 Package Body pay_bct_ins as
2 /* $Header: pybctrhi.pkb 120.0.12000000.4 2007/08/20 08:21:49 ayegappa noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_bct_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_bct_shd.g_rec_type
55 ) is
56 --
57 l_proc varchar2(72) := g_package||'insert_dml';
58 l_range_flag varchar2(2) := 'F';
59 l_control_total_dup1 pay_batch_control_totals.control_total%TYPE;
60
61 --
62 Begin
63 hr_utility.set_location('Entering:'|| l_proc, 5);
64 p_rec.object_version_number := 1; -- Initialise the object version
65 --
66 pay_bct_shd.g_api_dml := true; -- Set the api dml status
67 --
68 -- added for bug 6013383
69 -- convert the Number format from Display format( 99,999.99 OR 99.999,99) to
70 -- database format (99999.99)
71 --
72 l_control_total_dup1 := p_rec.control_total;
73
74 hr_utility.set_location('Converting Control total from display format to database format: '||l_proc,6) ;
75 --
76
77 hr_chkfmt.checkformat ( p_rec.control_total ,
78 'NUMBER' ,
79 l_control_total_dup1,
80 null ,
81 null ,
82 'N' ,
83 l_range_flag,
84 null );
85
86 p_rec.control_total := l_control_total_dup1;
87 -- Insert the row into: pay_batch_control_totals
88 --
89
90 insert into pay_batch_control_totals
91 (batch_control_id
92 ,batch_id
93 ,control_status
94 ,control_total
95 ,control_type
96 ,object_version_number
97 )
98 Values
99 (p_rec.batch_control_id
100 ,p_rec.batch_id
101 ,p_rec.control_status
102 ,p_rec.control_total
103 ,p_rec.control_type
104 ,p_rec.object_version_number
105 );
106 --
107 pay_bct_shd.g_api_dml := false; -- Unset the api dml status
108 --
109 hr_utility.set_location(' Leaving:'||l_proc, 10);
110
111 Exception
112 When hr_api.check_integrity_violated Then
113 -- A check constraint has been violated
114 pay_bct_shd.g_api_dml := false; -- Unset the api dml status
115 pay_bct_shd.constraint_error
116 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
117 When hr_api.parent_integrity_violated Then
118 -- Parent integrity has been violated
119 pay_bct_shd.g_api_dml := false; -- Unset the api dml status
120 pay_bct_shd.constraint_error
121 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
122 When hr_api.unique_integrity_violated Then
123 -- Unique integrity has been violated
124 pay_bct_shd.g_api_dml := false; -- Unset the api dml status
125 pay_bct_shd.constraint_error
126 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
127 When Others Then
128 pay_bct_shd.g_api_dml := false; -- Unset the api dml status
129 Raise;
130 End insert_dml;
131 --
132 -- ----------------------------------------------------------------------------
133 -- |------------------------------< pre_insert >------------------------------|
134 -- ----------------------------------------------------------------------------
135 -- {Start Of Comments}
136 --
137 -- Description:
138 -- This private procedure contains any processing which is required before
139 -- the insert dml. Presently, if the entity has a corresponding primary
140 -- key which is maintained by an associating sequence, the primary key for
141 -- the entity will be populated with the next sequence value in
142 -- preparation for the insert dml.
143 --
144 -- Prerequisites:
145 -- This is an internal procedure which is called from the ins procedure.
146 --
147 -- In Parameters:
148 -- A Pl/Sql record structre.
149 --
150 -- Post Success:
151 -- Processing continues.
152 --
153 -- Post Failure:
154 -- If an error has occurred, an error message and exception will be raised
155 -- but not handled.
156 --
157 -- Developer Implementation Notes:
158 -- Any pre-processing required before the insert dml is issued should be
159 -- coded within this procedure. As stated above, a good example is the
160 -- generation of a primary key number via a corresponding sequence.
161 -- It is important to note that any 3rd party maintenance should be reviewed
162 -- before placing in this procedure.
163 --
164 -- Access Status:
165 -- Internal Row Handler Use Only.
166 --
167 -- {End Of Comments}
168 -- ----------------------------------------------------------------------------
169 Procedure pre_insert
170 (p_rec in out nocopy pay_bct_shd.g_rec_type
171 ) is
172 --
173 l_proc varchar2(72) := g_package||'pre_insert';
174 --
175 Cursor C_Sel1 is select pay_batch_control_totals_s.nextval from sys.dual;
176 --
177 Begin
178 hr_utility.set_location('Entering:'||l_proc, 5);
179 --
180 --
181 -- Select the next sequence number
182 --
183 Open C_Sel1;
184 Fetch C_Sel1 Into p_rec.batch_control_id;
185 Close C_Sel1;
186 --
187 hr_utility.set_location(' Leaving:'||l_proc, 10);
188 End pre_insert;
189 --
190 -- ----------------------------------------------------------------------------
191 -- |-----------------------------< post_insert >------------------------------|
192 -- ----------------------------------------------------------------------------
193 -- {Start Of Comments}
194 --
195 -- Description:
196 -- This private procedure contains any processing which is required after the
197 -- insert dml.
198 --
199 -- Prerequisites:
200 -- This is an internal procedure which is called from the ins procedure.
201 --
202 -- In Parameters:
203 -- A Pl/Sql record structre.
204 --
205 -- Post Success:
206 -- Processing continues.
207 --
208 -- Post Failure:
209 -- If an error has occurred, an error message and exception will be raised
210 -- but not handled.
211 --
212 -- Developer Implementation Notes:
213 -- Any post-processing required after the insert dml is issued should be
214 -- coded within this procedure. It is important to note that any 3rd party
215 -- maintenance should be reviewed before placing in this procedure.
216 --
217 -- Access Status:
218 -- Internal Row Handler Use Only.
219 --
220 -- {End Of Comments}
221 -- ----------------------------------------------------------------------------
222 Procedure post_insert
223 (p_session_date in date
224 ,p_rec in pay_bct_shd.g_rec_type
225 ) is
226 --
227 l_proc varchar2(72) := g_package||'post_insert';
228 --
229 Begin
230 hr_utility.set_location('Entering:'||l_proc, 5);
231 begin
232 --
233 pay_bct_rki.after_insert
234 (p_session_date
235 => p_session_date
236 ,p_batch_control_id
237 => p_rec.batch_control_id
238 ,p_batch_id
239 => p_rec.batch_id
240 ,p_control_status
241 => p_rec.control_status
242 ,p_control_total
243 => p_rec.control_total
244 ,p_control_type
245 => p_rec.control_type
246 ,p_object_version_number
247 => p_rec.object_version_number
248 );
249 --
250 exception
251 --
252 when hr_api.cannot_find_prog_unit then
253 --
254 hr_api.cannot_find_prog_unit_error
255 (p_module_name => 'PAY_BATCH_CONTROL_TOTALS'
256 ,p_hook_type => 'AI');
257 --
258 end;
259 --
260 hr_utility.set_location(' Leaving:'||l_proc, 10);
261 End post_insert;
262 --
263 -- ----------------------------------------------------------------------------
264 -- |---------------------------------< ins >----------------------------------|
265 -- ----------------------------------------------------------------------------
266 Procedure ins
267 (p_session_date in date,
268 p_rec in out nocopy pay_bct_shd.g_rec_type
269 ) is
270 --
271 l_proc varchar2(72) := g_package||'ins';
272 --
273 Begin
274 hr_utility.set_location('Entering:'||l_proc, 5);
275 --
276 -- Call the supporting insert validate operations
277 --
278 pay_bct_bus.insert_validate
279 (p_session_date,
280 p_rec
281 );
282 --
283 -- Call the supporting pre-insert operation
284 --
285 pay_bct_ins.pre_insert(p_rec);
286 --
287 -- Insert the row
288 --
289 pay_bct_ins.insert_dml(p_rec);
290 --
291 -- Call the supporting post-insert operation
292 --
293 pay_bct_ins.post_insert
294 (p_session_date
295 ,p_rec
296 );
297 --
298 hr_utility.set_location('Leaving:'||l_proc, 20);
299 end ins;
300 --
301 -- ----------------------------------------------------------------------------
302 -- |---------------------------------< ins >----------------------------------|
303 -- ----------------------------------------------------------------------------
304 Procedure ins
305 (p_session_date in date
306 ,p_batch_id in number
307 ,p_control_status in varchar2
308 ,p_control_total in varchar2 default null
309 ,p_control_type in varchar2 default null
310 ,p_batch_control_id out nocopy number
311 ,p_object_version_number out nocopy number
312 ) is
313 --
314 l_rec pay_bct_shd.g_rec_type;
315 l_proc varchar2(72) := g_package||'ins';
316 --
317 Begin
318 hr_utility.set_location('Entering:'||l_proc, 5);
319 --
320 -- Call conversion function to turn arguments into the
321 -- p_rec structure.
322 --
323 l_rec :=
324 pay_bct_shd.convert_args
325 (null
326 ,p_batch_id
327 ,p_control_status
328 ,p_control_total
329 ,p_control_type
330 ,null
331 );
332 --
333 -- Having converted the arguments into the pay_bct_rec
334 -- plsql record structure we call the corresponding record business process.
335 --
336 pay_bct_ins.ins
337 (p_session_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_batch_control_id := l_rec.batch_control_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 pay_bct_ins;