DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_DUT_INS

Source


1 Package Body ghr_dut_ins as
2 /* $Header: ghdutrhi.pkb 120.0.12000000.1 2007/01/18 13:42:07 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ghr_dut_ins.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |----------------------------< dt_insert_dml >-----------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the actual dml insert logic for datetrack. The
17 --   functions of this procedure are as follows:
18 --   1) Get the object_version_number.
19 --   2) To set the effective start and end dates to the corresponding
20 --      validation start and end dates. Also, the object version number
21 --      record attribute is set.
22 --   3) To set and unset the g_api_dml status as required (as we are about to
23 --      perform dml).
24 --   4) To insert the row into the schema with the derived effective start
25 --      and end dates and the object version number.
26 --   5) To trap any constraint violations that may have occurred.
27 --   6) To raise any other errors.
28 --
29 -- Prerequisites:
30 --   This is an internal private procedure which must be called from the
31 --   insert_dml and pre_update (logic permitting) procedure and must have
32 --   all mandatory arguments set.
33 --
34 -- In Parameters:
35 --   A Pl/Sql record structre.
36 --
37 -- Post Success:
38 --   The specified row will be inserted into the schema.
39 --
40 -- Post Failure:
41 --   On the insert dml failure it is important to note that we always reset the
42 --   g_api_dml status to false.
43 --   If a check or unique integrity constraint violation is raised the
44 --   constraint_error procedure will be called.
45 --   If any other error is reported, the error will be raised after the
46 --   g_api_dml status is reset.
47 --
48 -- Developer Implementation Notes:
49 --   This is an internal datetrack maintenance procedure which should
50 --   not be modified in anyway.
51 --
52 -- Access Status:
53 --   Internal Row Handler Use Only.
54 --
55 -- {End Of Comments}
56 -- ----------------------------------------------------------------------------
57 Procedure dt_insert_dml
58 	(p_rec 			 in out nocopy ghr_dut_shd.g_rec_type,
59 	 p_effective_date	 in	date,
60 	 p_datetrack_mode	 in	varchar2,
61 	 p_validation_start_date in	date,
62 	 p_validation_end_date	 in	date) is
63 --
64 -- Cursor to select 'old' created AOL who column values
65 --
66   Cursor C_Sel1 Is
67     select t.created_by,
68            t.creation_date
69     from   ghr_duty_stations_f t
70     where  t.duty_station_id       = p_rec.duty_station_id
71     and    t.effective_start_date =
72              ghr_dut_shd.g_old_rec.effective_start_date
73     and    t.effective_end_date   = (p_validation_start_date - 1);
74 --
75   l_proc		varchar2(72) := g_package||'dt_insert_dml';
76   l_created_by          ghr_duty_stations_f.created_by%TYPE;
77   l_creation_date       ghr_duty_stations_f.creation_date%TYPE;
78   l_last_update_date   	ghr_duty_stations_f.last_update_date%TYPE;
79   l_last_updated_by     ghr_duty_stations_f.last_updated_by%TYPE;
80   l_last_update_login   ghr_duty_stations_f.last_update_login%TYPE;
81 --
82 Begin
83   hr_utility.set_location('Entering:'||l_proc, 5);
84   --
85   -- Get the object version number for the insert
86   --
87   p_rec.object_version_number :=
88     dt_api.get_object_version_number
89 	(p_base_table_name => 'ghr_duty_stations_f',
90 	 p_base_key_column => 'duty_station_id',
91 	 p_base_key_value  => p_rec.duty_station_id);
92 
93   --
94   -- Set the effective start and end dates to the corresponding
95   -- validation start and end dates
96   --
97   p_rec.effective_start_date := p_validation_start_date;
98   p_rec.effective_end_date   := p_validation_end_date;
99   --
100   -- If the datetrack_mode is not INSERT then we must populate the WHO
101   -- columns with the 'old' creation values and 'new' updated values.
102   --
103   If (p_datetrack_mode <> 'INSERT') then
104     hr_utility.set_location(l_proc, 10);
105     --
106     -- Select the 'old' created values
107     --
108     Open C_Sel1;
109     Fetch C_Sel1 Into l_created_by, l_creation_date;
110     If C_Sel1%notfound Then
111       --
112       -- The previous 'old' created row has not been found. We need
113       -- to error as an internal datetrack problem exists.
114       --
115       Close C_Sel1;
116       fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
117       fnd_message.set_token('PROCEDURE', l_proc);
118       fnd_message.set_token('STEP','10');
119       fnd_message.raise_error;
120     End If;
121     Close C_Sel1;
122     --
123     -- Set the AOL updated WHO values
124     --
125     l_last_update_date   := sysdate;
126     l_last_updated_by    := fnd_global.user_id;
127     l_last_update_login  := fnd_global.login_id;
128   End If;
129   --
130   ghr_dut_shd.g_api_dml := true;  -- Set the api dml status
131   --
132   -- Insert the row into: ghr_duty_stations_f
133   --
134   insert into ghr_duty_stations_f
135   (	duty_station_id,
136 	effective_start_date,
137 	effective_end_date,
138 	locality_pay_area_id,
139         leo_pay_area_code,
140         name,
141         duty_station_code,
142         msa_code  ,
143         cmsa_code ,
144         state_or_country_code,
145         county_code,
146         is_duty_station,
147 	object_version_number,
148 	created_by,
149    	creation_date,
150    	last_update_date,
151    	last_updated_by,
152    	last_update_login
153   )
154   Values
155   (	p_rec.duty_station_id,
156 	p_rec.effective_start_date,
157 	p_rec.effective_end_date,
158 	p_rec.locality_pay_area_id,
159         p_rec.leo_pay_area_code,
160         p_rec.name,
161         p_rec.duty_station_code,
162         p_rec.msa_code  ,
163         p_rec.cmsa_code ,
164         p_rec.state_or_country_code,
165         p_rec.county_code,
166         p_rec.is_duty_station,
167 	p_rec.object_version_number,
168 	l_created_by,
169    	l_creation_date,
170    	l_last_update_date,
171    	l_last_updated_by,
172    	l_last_update_login
173   );
174   --
175   ghr_dut_shd.g_api_dml := false;   -- Unset the api dml status
176   hr_utility.set_location(' Leaving:'||l_proc, 15);
177 --
178 Exception
179   When hr_api.check_integrity_violated Then
180     -- A check constraint has been violated
181     ghr_dut_shd.g_api_dml := false;   -- Unset the api dml status
182     ghr_dut_shd.constraint_error
183       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
184   When hr_api.unique_integrity_violated Then
185     -- Unique integrity has been violated
186     ghr_dut_shd.g_api_dml := false;   -- Unset the api dml status
187     ghr_dut_shd.constraint_error
188       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
189   When Others Then
190     ghr_dut_shd.g_api_dml := false;   -- Unset the api dml status
191     Raise;
192 End dt_insert_dml;
193 --
194 -- ----------------------------------------------------------------------------
195 -- |------------------------------< insert_dml >------------------------------|
196 -- ----------------------------------------------------------------------------
197 Procedure insert_dml
198 	(p_rec 			 in out nocopy ghr_dut_shd.g_rec_type,
199 	 p_effective_date	 in	date,
200 	 p_datetrack_mode	 in	varchar2,
201 	 p_validation_start_date in	date,
202 	 p_validation_end_date	 in	date) is
203 --
204   l_proc	varchar2(72) := g_package||'insert_dml';
205 --
206 Begin
207   hr_utility.set_location('Entering:'||l_proc, 5);
208   --
209   dt_insert_dml(p_rec			=> p_rec,
210 		p_effective_date	=> p_effective_date,
211 		p_datetrack_mode	=> p_datetrack_mode,
212        		p_validation_start_date	=> p_validation_start_date,
213 		p_validation_end_date	=> p_validation_end_date);
214   --
215   hr_utility.set_location(' Leaving:'||l_proc, 10);
216 End insert_dml;
217 --
218 -- ----------------------------------------------------------------------------
219 -- |------------------------------< pre_insert >------------------------------|
220 -- ----------------------------------------------------------------------------
221 -- {Start Of Comments}
222 --
223 -- Description:
224 --   This private procedure contains any processing which is required before
225 --   the insert dml. Presently, if the entity has a corresponding primary
226 --   key which is maintained by an associating sequence, the primary key for
227 --   the entity will be populated with the next sequence value in
228 --   preparation for the insert dml.
229 --   Also, if comments are defined for this entity, the comments insert
230 --   logic will also be called, generating a comment_id if required.
231 --
232 -- Prerequisites:
233 --   This is an internal procedure which is called from the ins procedure.
234 --
235 -- In Parameters:
236 --   A Pl/Sql record structre.
237 --
238 -- Post Success:
239 --   Processing continues.
240 --
241 -- Post Failure:
242 --   If an error has occurred, an error message and exception will be raised
243 --   but not handled.
244 --
245 -- Developer Implementation Notes:
246 --   Any pre-processing required before the insert dml is issued should be
247 --   coded within this procedure. As stated above, a good example is the
248 --   generation of a primary key number via a corresponding sequence.
249 --   It is important to note that any 3rd party maintenance should be reviewed
250 --   before placing in this procedure.
251 --
252 -- Access Status:
253 --   Internal Row Handler Use Only.
254 --
255 -- {End Of Comments}
256 -- ----------------------------------------------------------------------------
257 Procedure pre_insert
258 	(p_rec  			in out nocopy ghr_dut_shd.g_rec_type,
259 	 p_effective_date		in date,
260 	 p_datetrack_mode		in varchar2,
261 	 p_validation_start_date	in date,
262 	 p_validation_end_date		in date) is
263 --
264   l_proc	varchar2(72) := g_package||'pre_insert';
265 
266 -- Bug#3630066 Added ghr_duty_stations_f_s sequence.
267 cursor c1 is
268       select ghr_duty_stations_f_s.nextval
269       from dual;
270 --
271 --
272 Begin
273   hr_utility.set_location('Entering:'||l_proc, 5);
274   --
275   open c1;
276   fetch c1 into p_rec.duty_station_id;
277   close c1;
278   --
279   hr_utility.set_location(' Leaving:'||l_proc, 10);
280 End pre_insert;
281 --
282 -- ----------------------------------------------------------------------------
283 -- |-----------------------------< post_insert >------------------------------|
284 -- ----------------------------------------------------------------------------
285 -- {Start Of Comments}
286 --
287 -- Description:
288 --   This private procedure contains any processing which is required after the
289 --   insert dml.
290 --
291 -- Prerequisites:
292 --   This is an internal procedure which is called from the ins procedure.
293 --
294 -- In Parameters:
295 --   A Pl/Sql record structre.
296 --
297 -- Post Success:
298 --   Processing continues.
299 --
300 -- Post Failure:
301 --   If an error has occurred, an error message and exception will be raised
302 --   but not handled.
303 --
304 -- Developer Implementation Notes:
305 --   Any post-processing required after the insert dml is issued should be
306 --   coded within this procedure. It is important to note that any 3rd party
307 --   maintenance should be reviewed before placing in this procedure.
308 --
309 -- Access Status:
310 --   Internal Row Handler Use Only.
311 --
312 -- {End Of Comments}
313 -- ----------------------------------------------------------------------------
314 Procedure post_insert
315 	(p_rec 			 in ghr_dut_shd.g_rec_type,
316 	 p_effective_date	 in date,
317 	 p_datetrack_mode	 in varchar2,
318 	 p_validation_start_date in date,
319 	 p_validation_end_date	 in date) is
320 --
321   l_proc	varchar2(72) := g_package||'post_insert';
322 --
323 Begin
324   hr_utility.set_location('Entering:'||l_proc, 5);
325   --
326   ghr_dut_rki.after_insert(
327 			    p_duty_station_id 	     =>   p_rec.duty_station_id
328 			   ,p_effective_start_date   =>   p_rec.effective_start_date
329 			   ,p_effective_end_date     =>   p_rec.effective_end_date
330 			   ,p_locality_pay_area_id   =>   p_rec.locality_pay_area_id
331 			   ,p_leo_pay_area_code      =>   p_rec.leo_pay_area_code
332 			   ,p_name                   =>   p_rec.name
333 			   ,p_duty_station_code      =>   p_rec.duty_station_code
334 			   ,p_msa_code		     =>	  p_rec.msa_code
335 			   ,p_cmsa_code              =>	  p_rec.cmsa_code
336 			   ,p_state_or_country_code  =>   p_rec.state_or_country_code
337 			   ,p_county_code	     =>	  p_rec.county_code
338 			   ,p_is_duty_station	     =>   p_rec.is_duty_station
339 			   ,p_effective_date         =>   trunc(p_effective_date)
340 			   ,p_object_version_number  =>   p_rec.object_version_number
341 			   );
342   hr_utility.set_location(' Leaving:'||l_proc, 10);
343 End post_insert;
344 --
345 -- ----------------------------------------------------------------------------
346 -- |-------------------------------< ins_lck >--------------------------------|
347 -- ----------------------------------------------------------------------------
348 -- {Start Of Comments}
349 --
350 -- Description:
351 --   The ins_lck process has one main function to perform. When inserting
352 --   a datetracked row, we must validate the DT mode.
353 --
354 -- Prerequisites:
355 --   This procedure can only be called for the datetrack mode of INSERT.
356 --
357 -- In Parameters:
358 --
359 -- Post Success:
360 --   On successful completion of the ins_lck process the parental
361 --   datetracked rows will be locked providing the p_enforce_foreign_locking
362 --   argument value is TRUE.
363 --   If the p_enforce_foreign_locking argument value is FALSE then the
364 --   parential rows are not locked.
365 --
366 -- Post Failure:
367 --   The Lck process can fail for:
368 --   1) When attempting to lock the row the row could already be locked by
369 --      another user. This will raise the HR_Api.Object_Locked exception.
370 --   2) When attempting to the lock the parent which doesn't exist.
374 --   None.
371 --      For the entity to be locked the parent must exist!
372 --
373 -- Developer Implementation Notes:
375 --
376 -- Access Status:
377 --   Internal Row Handler Use Only.
378 --
379 -- {End Of Comments}
380 -- ----------------------------------------------------------------------------
381 Procedure ins_lck
382 	(p_effective_date	 in  date,
383 	 p_datetrack_mode	 in  varchar2,
384 	 p_rec	 		 in  ghr_dut_shd.g_rec_type,
385 	 p_validation_start_date out nocopy date,
386 	 p_validation_end_date	 out nocopy date) is
387 --
388   l_proc		  varchar2(72) := g_package||'ins_lck';
389   l_validation_start_date date;
390   l_validation_end_date	  date;
391 --
392 Begin
393   hr_utility.set_location('Entering:'||l_proc, 5);
394   --
395   -- Validate the datetrack mode mode getting the validation start
396   -- and end dates for the specified datetrack operation.
397   --
398   dt_api.validate_dt_mode
399 	 (p_datetrack_mode	   => p_datetrack_mode,
400 	 p_effective_date	   => p_effective_date,
401 	 p_base_table_name	   => 'ghr_duty_stations_f',
402 	 p_base_key_column	   => 'duty_station_id',
403 	 p_base_key_value 	   => p_rec.duty_station_id,
404 	 p_enforce_foreign_locking => true,
405 	 p_validation_start_date   => l_validation_start_date,
406  	 p_validation_end_date	   => l_validation_end_date);
407   --
408   -- Set the validation start and end date OUT arguments
409   --
410   p_validation_start_date := l_validation_start_date;
411   p_validation_end_date   := l_validation_end_date;
412   --
413   hr_utility.set_location(' Leaving:'||l_proc, 10);
414 --
415 End ins_lck;
416 --
417 -- ----------------------------------------------------------------------------
418 -- |---------------------------------< ins >----------------------------------|
419 -- ----------------------------------------------------------------------------
420 Procedure ins
421   (
422   p_rec		   in out nocopy ghr_dut_shd.g_rec_type,
423   p_effective_date in     date
424   ) is
425 --
426   l_proc			varchar2(72) := g_package||'ins';
427   l_datetrack_mode		varchar2(30) := 'INSERT';
428   l_validation_start_date	date;
429   l_validation_end_date		date;
430 --
431 Begin
432   hr_utility.set_location('Entering:'||l_proc, 5);
433   --
434   -- Call the lock operation
435   --
436   ins_lck
437 	(p_effective_date	 => p_effective_date,
438 	 p_datetrack_mode	 => l_datetrack_mode,
439 	 p_rec	 		 => p_rec,
440 	 p_validation_start_date => l_validation_start_date,
441 	 p_validation_end_date	 => l_validation_end_date);
442   --
443   -- Call the supporting insert validate operations
444   --
445   ghr_dut_bus.insert_validate
446 	(p_rec			 => p_rec,
447 	 p_effective_date	 => p_effective_date,
448 	 p_datetrack_mode	 => l_datetrack_mode,
449 	 p_validation_start_date => l_validation_start_date,
450 	 p_validation_end_date	 => l_validation_end_date);
451   --
452   -- Call the supporting pre-insert operation
453   --
454   pre_insert
455  	(p_rec			 => p_rec,
456 	 p_effective_date	 => p_effective_date,
457 	 p_datetrack_mode	 => l_datetrack_mode,
458 	 p_validation_start_date => l_validation_start_date,
459 	 p_validation_end_date	 => l_validation_end_date);
460   --
461   -- Insert the row
462   --
463   insert_dml
464  	(p_rec			 => p_rec,
465 	 p_effective_date	 => p_effective_date,
466 	 p_datetrack_mode	 => l_datetrack_mode,
467 	 p_validation_start_date => l_validation_start_date,
468 	 p_validation_end_date	 => l_validation_end_date);
469   --
470   -- Call the supporting post-insert operation
471   --
472   post_insert
473  	(p_rec			 => p_rec,
474 	 p_effective_date	 => p_effective_date,
475 	 p_datetrack_mode	 => l_datetrack_mode,
476 	 p_validation_start_date => l_validation_start_date,
477 	 p_validation_end_date	 => l_validation_end_date);
478 
479   hr_utility.set_location('Leaving INS2',30);
480 end ins;
481 --
482 -- ----------------------------------------------------------------------------
483 -- |---------------------------------< ins >----------------------------------|
484 -- ----------------------------------------------------------------------------
485 Procedure ins
486   (
487   p_duty_station_id              out nocopy number,
488   p_effective_start_date         out nocopy date,
489   p_effective_end_date           out nocopy date,
490   p_locality_pay_area_id         in         number,
491   p_leo_pay_area_code		 in         varchar2,
492   p_name			 in         varchar2,
493   p_duty_station_code		 in	    varchar2,
494   p_msa_code			 in 	    varchar2,
495   p_cmsa_code			 in	    varchar2,
496   p_state_or_country_code	 in	    varchar2,
497   p_county_code			 in	    varchar2,
498   p_is_duty_station		 in	    varchar2,
499   p_object_version_number        in out nocopy number,
500   p_effective_date		 in	    date
501   ) is
502 --
503   l_rec		ghr_dut_shd.g_rec_type;
504   l_proc	varchar2(72) := g_package||'ins';
505 --
506 Begin
507   hr_utility.set_location('Entering:'||l_proc, 5);
508   --
509   -- Call conversion function to turn arguments into the
510   -- p_rec structure.
511   --
512   l_rec :=
513   ghr_dut_shd.convert_args
514   (
515     null
516    ,null
517    ,null
518    ,p_locality_pay_area_id
519    ,p_leo_pay_area_code
520    ,p_name
521    ,p_duty_station_code
522    ,p_msa_code
523    ,p_cmsa_code
524    ,p_state_or_country_code
525    ,p_county_code
526    ,p_is_duty_station
527    ,p_object_version_number
528    );
529   --
530   -- Having converted the arguments into the ghr_dut_rec
531   -- plsql record structure we call the corresponding record
532   -- business process.
533   --
534   ins(l_rec, p_effective_date);
535   --
536   -- Set the OUT arguments.
537   --
538   p_duty_station_id        	:= l_rec.duty_station_id;
539   p_effective_start_date  	:= l_rec.effective_start_date;
540   p_effective_end_date    	:= l_rec.effective_end_date;
541   --
542   --
543   hr_utility.set_location(' Leaving:'||l_proc, 10);
544 End ins;
545 --
546 end ghr_dut_ins;