DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_BGT_INS

Source


1 Package Body pqh_bgt_ins as
2 /* $Header: pqbgtrhi.pkb 120.1 2005/09/21 03:11:10 hmehta noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_bgt_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 --   3) To insert the row into the schema.
21 --   4) To trap any constraint violations that may have occurred.
22 --   5) To raise any other errors.
23 --
24 -- Prerequisites:
25 --   This is an internal private procedure which must be called from the ins
26 --   procedure and must have all mandatory attributes set (except the
27 --   object_version_number which is initialised within this procedure).
28 --
29 -- In Parameters:
30 --   A Pl/Sql record structre.
31 --
32 -- Post Success:
33 --   The specified row will be inserted into the schema.
34 --
35 -- Post Failure:
36 --   If a check, unique or parent integrity constraint violation is raised the
37 --   constraint_error procedure will be called.
38 --
39 -- Developer Implementation Notes:
40 --   None.
41 --
42 -- Access Status:
43 --   Internal Row Handler Use Only.
44 --
45 -- {End Of Comments}
46 -- ----------------------------------------------------------------------------
47 Procedure insert_dml(p_rec in out nocopy pqh_bgt_shd.g_rec_type) is
48 --
49   l_proc  varchar2(72) := g_package||'insert_dml';
50 --
51 Begin
52   hr_utility.set_location('Entering:'||l_proc, 5);
53   p_rec.object_version_number := 1;  -- Initialise the object version
54   --
55   --
56   -- Insert the row into: pqh_budgets
57   --
58   insert into pqh_budgets
59   (	budget_id,
60 	business_group_id,
61 	start_organization_id,
62 	org_structure_version_id,
63 	budgeted_entity_cd,
64 	budget_style_cd,
65 	budget_name,
66 	period_set_name,
67 	budget_start_date,
68 	budget_end_date,
69 	gl_budget_name,
70 	psb_budget_flag,
71 	transfer_to_gl_flag,
72 	transfer_to_grants_flag,
73 	status,
74 	object_version_number,
75 	budget_unit1_id,
76 	budget_unit2_id,
77 	budget_unit3_id,
78         gl_set_of_books_id,
79         budget_unit1_aggregate,
80         budget_unit2_aggregate,
81         budget_unit3_aggregate,
82         position_control_flag,
83         valid_grade_reqd_flag,
84         currency_code,
85         dflt_budget_set_id
86   )
87   Values
88   (	p_rec.budget_id,
89 	p_rec.business_group_id,
90 	p_rec.start_organization_id,
91 	p_rec.org_structure_version_id,
92 	p_rec.budgeted_entity_cd,
93 	p_rec.budget_style_cd,
94 	p_rec.budget_name,
95 	p_rec.period_set_name,
96 	p_rec.budget_start_date,
97 	p_rec.budget_end_date,
98 	p_rec.gl_budget_name,
99 	p_rec.psb_budget_flag,
100 	p_rec.transfer_to_gl_flag,
101 	p_rec.transfer_to_grants_flag,
102 	p_rec.status,
103 	p_rec.object_version_number,
104 	p_rec.budget_unit1_id,
105 	p_rec.budget_unit2_id,
106 	p_rec.budget_unit3_id,
107 	p_rec.gl_set_of_books_id,
108         p_rec.budget_unit1_aggregate,
109         p_rec.budget_unit2_aggregate,
110         p_rec.budget_unit3_aggregate,
111         p_rec.position_control_flag,
112         p_rec.valid_grade_reqd_flag,
113         p_rec.currency_code,
114         p_rec.dflt_budget_set_id
115   );
116   --
117   --
118   hr_utility.set_location(' Leaving:'||l_proc, 10);
119 Exception
120   When hr_api.check_integrity_violated Then
121     -- A check constraint has been violated
122     pqh_bgt_shd.constraint_error
123       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
124   When hr_api.parent_integrity_violated Then
125     -- Parent integrity has been violated
126     pqh_bgt_shd.constraint_error
127       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
128   When hr_api.unique_integrity_violated Then
129     -- Unique integrity has been violated
130     pqh_bgt_shd.constraint_error
131       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
132   When Others Then
133     Raise;
134 End insert_dml;
135 --
136 -- ----------------------------------------------------------------------------
137 -- |------------------------------< pre_insert >------------------------------|
138 -- ----------------------------------------------------------------------------
139 -- {Start Of Comments}
140 --
141 -- Description:
142 --   This private procedure contains any processing which is required before
143 --   the insert dml. Presently, if the entity has a corresponding primary
144 --   key which is maintained by an associating sequence, the primary key for
145 --   the entity will be populated with the next sequence value in
146 --   preparation for the insert dml.
147 --
148 -- Also If GL Budget Name is Not Nul then transfer_to_gl_flag will to set to 'Y'
149 --
150 -- Prerequisites:
151 --   This is an internal procedure which is called from the ins procedure.
152 --
153 -- In Parameters:
154 --   A Pl/Sql record structre.
155 --
156 -- Post Success:
157 --   Processing continues.
158 --
159 -- Post Failure:
160 --   If an error has occurred, an error message and exception will be raised
161 --   but not handled.
162 --
163 -- Developer Implementation Notes:
164 --   Any pre-processing required before the insert dml is issued should be
165 --   coded within this procedure. As stated above, a good example is the
166 --   generation of a primary key number via a corresponding sequence.
167 --   It is important to note that any 3rd party maintenance should be reviewed
168 --   before placing in this procedure.
169 --
170 -- Access Status:
171 --   Internal Row Handler Use Only.
172 --
173 -- {End Of Comments}
174 -- ----------------------------------------------------------------------------
175 Procedure pre_insert(p_rec  in out nocopy pqh_bgt_shd.g_rec_type) is
176 --
177   l_proc  varchar2(72) := g_package||'pre_insert';
178 --
179   Cursor C_Sel1 is select pqh_budgets_s.nextval from sys.dual;
180 --
181 Begin
182   hr_utility.set_location('Entering:'||l_proc, 5);
183   --
184   --
185   -- Select the next sequence number
186   --
187   Open C_Sel1;
188   Fetch C_Sel1 Into p_rec.budget_id;
189   Close C_Sel1;
190   --
191   -- If gl_budget_name is not null set transfer_to_gl_flag to 'Y'
192   IF(p_rec.gl_budget_name is not null)
193   THEN
194   p_rec.transfer_to_gl_flag :='Y';
195   END IF;
196   --
197   hr_utility.set_location(' Leaving:'||l_proc, 10);
198 End pre_insert;
199 --
200 -- ----------------------------------------------------------------------------
201 -- |-----------------------------< post_insert >------------------------------|
202 -- ----------------------------------------------------------------------------
203 -- {Start Of Comments}
204 --
205 -- Description:
206 --   This private procedure contains any processing which is required after the
207 --   insert dml.
208 --
209 -- Prerequisites:
210 --   This is an internal procedure which is called from the ins procedure.
211 --
212 -- In Parameters:
213 --   A Pl/Sql record structre.
214 --
215 -- Post Success:
216 --   Processing continues.
217 --
218 -- Post Failure:
219 --   If an error has occurred, an error message and exception will be raised
220 --   but not handled.
221 --
222 -- Developer Implementation Notes:
223 --   Any post-processing required after the insert dml is issued should be
224 --   coded within this procedure. It is important to note that any 3rd party
225 --   maintenance should be reviewed before placing in this procedure.
226 --
227 -- Access Status:
228 --   Internal Row Handler Use Only.
229 --
230 -- {End Of Comments}
231 -- ----------------------------------------------------------------------------
232 Procedure post_insert(
233 p_effective_date in date,p_rec in pqh_bgt_shd.g_rec_type) is
234 --
235   l_proc  varchar2(72) := g_package||'post_insert';
236 --
237 Begin
238   hr_utility.set_location('Entering:'||l_proc, 5);
239 --
240   --
241   -- Start of API User Hook for post_insert.
242   --
243   begin
244     --
245     pqh_bgt_rki.after_insert
246       (
247   p_budget_id                     =>p_rec.budget_id
248  ,p_business_group_id             =>p_rec.business_group_id
249  ,p_start_organization_id         =>p_rec.start_organization_id
250  ,p_org_structure_version_id      =>p_rec.org_structure_version_id
251  ,p_budgeted_entity_cd            =>p_rec.budgeted_entity_cd
252  ,p_budget_style_cd               =>p_rec.budget_style_cd
253  ,p_budget_name                   =>p_rec.budget_name
254  ,p_period_set_name               =>p_rec.period_set_name
255  ,p_budget_start_date             =>p_rec.budget_start_date
256  ,p_budget_end_date               =>p_rec.budget_end_date
257  ,p_gl_budget_name                =>p_rec.gl_budget_name
258  ,p_psb_budget_flag               =>p_rec.psb_budget_flag
259  ,p_transfer_to_gl_flag           =>p_rec.transfer_to_gl_flag
260  ,p_transfer_to_grants_flag       =>p_rec.transfer_to_grants_flag
261  ,p_status                        =>p_rec.status
262  ,p_object_version_number         =>p_rec.object_version_number
263  ,p_budget_unit1_id               =>p_rec.budget_unit1_id
264  ,p_budget_unit2_id               =>p_rec.budget_unit2_id
265  ,p_budget_unit3_id               =>p_rec.budget_unit3_id
266  ,p_gl_set_of_books_id            =>p_rec.gl_set_of_books_id
267  ,p_budget_unit1_aggregate        =>p_rec.budget_unit1_aggregate
268  ,p_budget_unit2_aggregate        =>p_rec.budget_unit2_aggregate
269  ,p_budget_unit3_aggregate        =>p_rec.budget_unit3_aggregate
270  ,p_position_control_flag         =>p_rec.position_control_flag
271  ,p_valid_grade_reqd_flag         =>p_rec.valid_grade_reqd_flag
272  ,p_currency_code                 =>p_rec.currency_code
273  ,p_dflt_budget_set_id            =>p_rec.dflt_budget_set_id
274  ,p_effective_date                =>p_effective_date
275       );
276     --
277   exception
278     --
279     when hr_api.cannot_find_prog_unit then
280       --
281       hr_api.cannot_find_prog_unit_error
282         (p_module_name => 'pqh_budgets'
283         ,p_hook_type   => 'AI');
284       --
285   end;
286   --
287   -- End of API User Hook for post_insert.
288   --
289   --
290   hr_utility.set_location(' Leaving:'||l_proc, 10);
291 End post_insert;
292 --
293 -- ----------------------------------------------------------------------------
294 -- |---------------------------------< ins >----------------------------------|
295 -- ----------------------------------------------------------------------------
296 Procedure ins
297   (
298   p_effective_date in date,
299   p_rec        in out nocopy pqh_bgt_shd.g_rec_type
300   ) is
301 --
302   l_proc  varchar2(72) := g_package||'ins';
303 --
304 Begin
305   hr_utility.set_location('Entering:'||l_proc, 5);
306   --
307   -- Call the supporting insert validate operations
308   --
309   pqh_bgt_bus.insert_validate(p_rec
310   ,p_effective_date);
311   --
312   -- Call the supporting pre-insert operation
313   --
314   pre_insert(p_rec);
315   --
316   -- Insert the row
317   --
318   insert_dml(p_rec);
319   --
320   -- Call the supporting post-insert operation
321   --
322   post_insert(
323 p_effective_date,p_rec);
324 end ins;
325 --
326 -- ----------------------------------------------------------------------------
327 -- |---------------------------------< ins >----------------------------------|
328 -- ----------------------------------------------------------------------------
329 Procedure ins
330   (
331   p_effective_date in date,
332   p_budget_id                    out nocopy number,
333   p_business_group_id            in number           default null,
334   p_start_organization_id        in number           default null,
335   p_org_structure_version_id     in number           default null,
336   p_budgeted_entity_cd           in varchar2         default null,
337   p_budget_style_cd              in varchar2,
338   p_budget_name                  in varchar2,
339   p_period_set_name              in varchar2,
340   p_budget_start_date            in date,
341   p_budget_end_date              in date,
342   p_gl_budget_name               in varchar2         default null,
343   p_psb_budget_flag              in varchar2         default 'N',
344   p_transfer_to_gl_flag          in varchar2         default null,
345   p_transfer_to_grants_flag      in varchar2         default null,
346   p_status                       in varchar2         default null,
347   p_object_version_number        out nocopy number,
348   p_budget_unit1_id              in number           default null,
349   p_budget_unit2_id              in number           default null,
350   p_budget_unit3_id              in number           default null,
351   p_gl_set_of_books_id           in number           default null,
352   p_budget_unit1_aggregate       in varchar2         default null,
353   p_budget_unit2_aggregate       in varchar2         default null,
354   p_budget_unit3_aggregate       in varchar2         default null,
355   p_position_control_flag        in varchar2         default null,
356   p_valid_grade_reqd_flag        in varchar2         default null,
357   p_currency_code                in varchar2         default null,
358   p_dflt_budget_set_id           in number           default null
359   ) is
360 --
361   l_rec	  pqh_bgt_shd.g_rec_type;
362   l_proc  varchar2(72) := g_package||'ins';
363 --
364 Begin
365   hr_utility.set_location('Entering:'||l_proc, 5);
366   --
367   -- Call conversion function to turn arguments into the
368   -- p_rec structure.
369   --
370   l_rec :=
371   pqh_bgt_shd.convert_args
372   (
373   null,
374   p_business_group_id,
375   p_start_organization_id,
376   p_org_structure_version_id,
377   p_budgeted_entity_cd,
378   p_budget_style_cd,
379   p_budget_name,
380   p_period_set_name,
381   p_budget_start_date,
382   p_budget_end_date,
383   p_gl_budget_name,
384   p_psb_budget_flag,
385   p_transfer_to_gl_flag,
386   p_transfer_to_grants_flag,
387   p_status,
388   null,
389   p_budget_unit1_id,
390   p_budget_unit2_id,
391   p_budget_unit3_id,
392   p_gl_set_of_books_id,
393   p_budget_unit1_aggregate,
394   p_budget_unit2_aggregate,
395   p_budget_unit3_aggregate,
396   p_position_control_flag,
397   p_valid_grade_reqd_flag,
398   p_currency_code,
399   p_dflt_budget_set_id
400   );
401   --
402   -- Having converted the arguments into the pqh_bgt_rec
403   -- plsql record structure we call the corresponding record business process.
404   --
405   ins(
406     p_effective_date,l_rec);
407   --
408   -- As the primary key argument(s)
409   -- are specified as an OUT's we must set these values.
410   --
411   p_budget_id := l_rec.budget_id;
412   p_object_version_number := l_rec.object_version_number;
413   --
414   hr_utility.set_location(' Leaving:'||l_proc, 10);
415 End ins;
416 --
417 end pqh_bgt_ins;