DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_PGA_SHD

Source


1 Package Body pay_pga_shd as
2 /* $Header: pypgarhi.pkb 120.0 2005/09/29 10:53 tvankayl noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_pga_shd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |---------------------------< constraint_error >---------------------------|
12 -- ----------------------------------------------------------------------------
13 Procedure constraint_error
14   (p_constraint_name in all_constraints.constraint_name%TYPE
15   ) Is
16 --
17   l_proc        varchar2(72) := g_package||'constraint_error';
18 --
19 Begin
20   --
21   If (p_constraint_name = 'PAY_PAYMENT_GL_ACCOUNTS_PK') Then
22     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
23     fnd_message.set_token('PROCEDURE', l_proc);
24     fnd_message.set_token('STEP','5');
25     fnd_message.raise_error;
26   Else
27     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
28     fnd_message.set_token('PROCEDURE', l_proc);
29     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
30     fnd_message.raise_error;
31   End If;
32   --
33 End constraint_error;
34 --
35 -- ----------------------------------------------------------------------------
36 -- |-----------------------------< api_updating >-----------------------------|
37 -- ----------------------------------------------------------------------------
38 Function api_updating
39   (p_effective_date                   in date
40   ,p_pay_gl_account_id                in number
41   ,p_object_version_number            in number
42   ) Return Boolean Is
43   --
44   -- Cursor selects the 'current' row from the HR Schema
45   --
46   Cursor C_Sel1 is
47     select
48      pay_gl_account_id
49     ,effective_start_date
50     ,effective_end_date
51     ,set_of_books_id
52     ,gl_cash_ac_id
53     ,gl_cash_clearing_ac_id
54     ,gl_control_ac_id
55     ,gl_error_ac_id
56     ,external_account_id
57     ,org_payment_method_id
58     ,object_version_number
59     from        pay_payment_gl_accounts_f
60     where       pay_gl_account_id = p_pay_gl_account_id
61     and         p_effective_date
62     between     effective_start_date and effective_end_date;
63 --
64   l_fct_ret     boolean;
65 --
66 Begin
67   --
68   If (p_effective_date is null or
69       p_pay_gl_account_id is null or
70       p_object_version_number is null) Then
71     --
72     -- One of the primary key arguments is null therefore we must
73     -- set the returning function value to false
74     --
75     l_fct_ret := false;
76   Else
77     If (p_pay_gl_account_id =
78         pay_pga_shd.g_old_rec.pay_gl_account_id and
79         p_object_version_number =
80         pay_pga_shd.g_old_rec.object_version_number
81 ) Then
82       --
83       -- The g_old_rec is current therefore we must
84       -- set the returning function to true
85       --
86       l_fct_ret := true;
87     Else
88       --
89       -- Select the current row
90       --
91       Open C_Sel1;
92       Fetch C_Sel1 Into pay_pga_shd.g_old_rec;
93       If C_Sel1%notfound Then
94         Close C_Sel1;
95         --
96         -- The primary key is invalid therefore we must error
97         --
98         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
99         fnd_message.raise_error;
100       End If;
101       Close C_Sel1;
102       If (p_object_version_number
103           <> pay_pga_shd.g_old_rec.object_version_number) Then
104         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
105         fnd_message.raise_error;
106       End If;
107       l_fct_ret := true;
108     End If;
109   End If;
110   Return (l_fct_ret);
111 --
112 End api_updating;
113 --
114 -- ----------------------------------------------------------------------------
115 -- |---------------------------< find_dt_upd_modes >--------------------------|
116 -- ----------------------------------------------------------------------------
117 Procedure find_dt_upd_modes
118   (p_effective_date         in date
119   ,p_base_key_value         in number
120   ,p_correction             out nocopy boolean
121   ,p_update                 out nocopy boolean
122   ,p_update_override        out nocopy boolean
123   ,p_update_change_insert   out nocopy boolean
124   ) is
125 --
126   l_proc        varchar2(72) := g_package||'find_dt_upd_modes';
127 --
128 Begin
129   hr_utility.set_location('Entering:'||l_proc, 5);
130   --
131   -- Call the corresponding datetrack api
132   --
133   dt_api.find_dt_upd_modes
134     (p_effective_date        => p_effective_date
135     ,p_base_table_name       => 'pay_payment_gl_accounts_f'
136     ,p_base_key_column       => 'pay_gl_account_id'
137     ,p_base_key_value        => p_base_key_value
138     ,p_correction            => p_correction
139     ,p_update                => p_update
140     ,p_update_override       => p_update_override
141     ,p_update_change_insert  => p_update_change_insert
142     );
143   --
144   hr_utility.set_location(' Leaving:'||l_proc, 10);
145 End find_dt_upd_modes;
146 --
147 -- ----------------------------------------------------------------------------
148 -- |---------------------------< find_dt_del_modes >--------------------------|
149 -- ----------------------------------------------------------------------------
150 Procedure find_dt_del_modes
151   (p_effective_date        in date
152   ,p_base_key_value        in number
153   ,p_zap                   out nocopy boolean
154   ,p_delete                out nocopy boolean
155   ,p_future_change         out nocopy boolean
156   ,p_delete_next_change    out nocopy boolean
157   ) is
158   --
159   l_proc                varchar2(72)    := g_package||'find_dt_del_modes';
160   --
161   --
162 Begin
163   hr_utility.set_location('Entering:'||l_proc, 5);
164   --
165   -- Call the corresponding datetrack api
166   --
167   dt_api.find_dt_del_modes
168    (p_effective_date                => p_effective_date
169    ,p_base_table_name               => 'pay_payment_gl_accounts_f'
170    ,p_base_key_column               => 'pay_gl_account_id'
171    ,p_base_key_value                => p_base_key_value
172    ,p_zap                           => p_zap
173    ,p_delete                        => p_delete
174    ,p_future_change                 => p_future_change
175    ,p_delete_next_change            => p_delete_next_change
176    );
177   --
178   hr_utility.set_location(' Leaving:'||l_proc, 10);
179 End find_dt_del_modes;
180 --
181 -- ----------------------------------------------------------------------------
182 -- |-----------------------< upd_effective_end_date >-------------------------|
183 -- ----------------------------------------------------------------------------
184 Procedure upd_effective_end_date
185   (p_effective_date                   in date
186   ,p_base_key_value                   in number
187   ,p_new_effective_end_date           in date
188   ,p_validation_start_date            in date
189   ,p_validation_end_date              in date
190   ,p_object_version_number  out nocopy number
191   ) is
192 --
193   l_proc                  varchar2(72) := g_package||'upd_effective_end_date';
194   l_object_version_number number;
195 --
196 Begin
197   hr_utility.set_location('Entering:'||l_proc, 5);
198   --
199   -- Because we are updating a row we must get the next object
200   -- version number.
201   --
202   l_object_version_number :=
203     dt_api.get_object_version_number
204       (p_base_table_name    => 'pay_payment_gl_accounts_f'
205       ,p_base_key_column    => 'pay_gl_account_id'
206       ,p_base_key_value     => p_base_key_value
207       );
208   --
209   hr_utility.set_location(l_proc, 10);
210   --
211 --
212   -- Update the specified datetrack row setting the effective
213   -- end date to the specified new effective end date.
214   --
215   update  pay_payment_gl_accounts_f t
216   set     t.effective_end_date    = p_new_effective_end_date
217     ,     t.object_version_number = l_object_version_number
218   where   t.pay_gl_account_id        = p_base_key_value
219   and     p_effective_date
220   between t.effective_start_date and t.effective_end_date;
221   --
222   --
223   p_object_version_number := l_object_version_number;
224   hr_utility.set_location(' Leaving:'||l_proc, 15);
225 --
226 End upd_effective_end_date;
227 --
228 -- ----------------------------------------------------------------------------
229 -- |---------------------------------< lck >----------------------------------|
230 -- ----------------------------------------------------------------------------
231 Procedure lck
232   (p_effective_date                   in date
233   ,p_datetrack_mode                   in varchar2
234   ,p_pay_gl_account_id                in number
235   ,p_object_version_number            in number
236   ,p_validation_start_date            out nocopy date
237   ,p_validation_end_date              out nocopy date
238   ) is
239 --
240   l_proc                  varchar2(72) := g_package||'lck';
241   l_validation_start_date date;
242   l_validation_end_date   date;
243   l_argument              varchar2(30);
244   --
245   -- Cursor C_Sel1 selects the current locked row as of session date
246   -- ensuring that the object version numbers match.
247   --
248   Cursor C_Sel1 is
249     select
250      pay_gl_account_id
251     ,effective_start_date
252     ,effective_end_date
253     ,set_of_books_id
254     ,gl_cash_ac_id
255     ,gl_cash_clearing_ac_id
256     ,gl_control_ac_id
257     ,gl_error_ac_id
258     ,external_account_id
259     ,org_payment_method_id
260     ,object_version_number
261     from    pay_payment_gl_accounts_f
262     where   pay_gl_account_id = p_pay_gl_account_id
263     and     p_effective_date
264     between effective_start_date and effective_end_date
265     for update nowait;
266   --
267   --
268   --
269 Begin
270   hr_utility.set_location('Entering:'||l_proc, 5);
271   --
272   -- Ensure that all the mandatory arguments are not null
273   --
274   hr_api.mandatory_arg_error(p_api_name       => l_proc
275                             ,p_argument       => 'effective_date'
276                             ,p_argument_value => p_effective_date
277                             );
278   --
279   hr_api.mandatory_arg_error(p_api_name       => l_proc
280                             ,p_argument       => 'datetrack_mode'
281                             ,p_argument_value => p_datetrack_mode
282                             );
283   --
284   hr_api.mandatory_arg_error(p_api_name       => l_proc
285                             ,p_argument       => 'pay_gl_account_id'
286                             ,p_argument_value => p_pay_gl_account_id
287                             );
288   --
289     hr_api.mandatory_arg_error(p_api_name       => l_proc
290                             ,p_argument       => 'object_version_number'
291                             ,p_argument_value => p_object_version_number
292                             );
293   --
294   -- Check to ensure the datetrack mode is not INSERT.
295   --
296   If (p_datetrack_mode <> hr_api.g_insert) then
297     --
298     -- We must select and lock the current row.
299     --
300     Open  C_Sel1;
301     Fetch C_Sel1 Into pay_pga_shd.g_old_rec;
302     If C_Sel1%notfound then
303       Close C_Sel1;
304       --
305       -- The primary key is invalid therefore we must error
306       --
307       fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
308       fnd_message.raise_error;
309     End If;
310     Close C_Sel1;
311     If (p_object_version_number
312           <> pay_pga_shd.g_old_rec.object_version_number) Then
313         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
314         fnd_message.raise_error;
315     End If;
316     --
317     --
318     -- Validate the datetrack mode mode getting the validation start
319     -- and end dates for the specified datetrack operation.
320     --
321     if pay_pga_shd.g_old_rec.org_payment_method_id is not null then
322 
323       dt_api.validate_dt_mode
324         (p_effective_date          => p_effective_date
325         ,p_datetrack_mode          => p_datetrack_mode
326         ,p_base_table_name         => 'pay_payment_gl_accounts_f'
327         ,p_base_key_column         => 'pay_gl_account_id'
328         ,p_base_key_value          => p_pay_gl_account_id
329         ,p_parent_table_name1      => 'pay_org_payment_methods_f'
330         ,p_parent_key_column1      => 'org_payment_method_id'
331         ,p_parent_key_value1       => pay_pga_shd.g_old_rec.org_payment_method_id
332         ,p_enforce_foreign_locking => false
333         ,p_validation_start_date   => l_validation_start_date
334         ,p_validation_end_date     => l_validation_end_date
335         );
336 
337     else
338 
339       dt_api.validate_dt_mode
340         (p_effective_date          => p_effective_date
341         ,p_datetrack_mode          => p_datetrack_mode
342         ,p_base_table_name         => 'pay_payment_gl_accounts_f'
343         ,p_base_key_column         => 'pay_gl_account_id'
344         ,p_base_key_value          => p_pay_gl_account_id
345         ,p_enforce_foreign_locking => true
346         ,p_validation_start_date   => l_validation_start_date
347         ,p_validation_end_date     => l_validation_end_date
348         );
349 
350     end if;
351   Else
352     --
353     -- We are doing a datetrack 'INSERT' which is illegal within this
354     -- procedure therefore we must error (note: to lck on insert the
355     -- private procedure ins_lck should be called).
356     --
357     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
358     fnd_message.set_token('PROCEDURE', l_proc);
359     fnd_message.set_token('STEP','20');
360     fnd_message.raise_error;
361   End If;
362   --
363   -- Set the validation start and end date OUT arguments
364   --
365   p_validation_start_date := l_validation_start_date;
366   p_validation_end_date   := l_validation_end_date;
367   --
368   hr_utility.set_location(' Leaving:'||l_proc, 30);
369 --
370 -- We need to trap the ORA LOCK exception
371 --
372 Exception
373   When HR_Api.Object_Locked then
374     --
375     -- The object is locked therefore we need to supply a meaningful
376     -- error message.
377     --
378     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
379     fnd_message.set_token('TABLE_NAME', 'pay_payment_gl_accounts_f');
380     fnd_message.raise_error;
381 End lck;
382 --
383 -- ----------------------------------------------------------------------------
384 -- |-----------------------------< convert_args >-----------------------------|
385 -- ----------------------------------------------------------------------------
386 Function convert_args
387   (p_pay_gl_account_id              in number
388   ,p_effective_start_date           in date
389   ,p_effective_end_date             in date
390   ,p_set_of_books_id                in number
391   ,p_gl_cash_ac_id                  in number
392   ,p_gl_cash_clearing_ac_id         in number
393   ,p_gl_control_ac_id               in number
394   ,p_gl_error_ac_id                 in number
395   ,p_external_account_id            in number
396   ,p_org_payment_method_id          in number
397   ,p_object_version_number          in number
398   )
399   Return g_rec_type is
400 --
401   l_rec   g_rec_type;
402 --
403 Begin
404   --
405   -- Convert arguments into local l_rec structure.
406   --
407   l_rec.pay_gl_account_id                := p_pay_gl_account_id;
408   l_rec.effective_start_date             := p_effective_start_date;
409   l_rec.effective_end_date               := p_effective_end_date;
410   l_rec.set_of_books_id                  := p_set_of_books_id;
411   l_rec.gl_cash_ac_id                    := p_gl_cash_ac_id;
412   l_rec.gl_cash_clearing_ac_id           := p_gl_cash_clearing_ac_id;
413   l_rec.gl_control_ac_id                 := p_gl_control_ac_id;
414   l_rec.gl_error_ac_id                   := p_gl_error_ac_id;
415   l_rec.external_account_id              := p_external_account_id;
416   l_rec.org_payment_method_id            := p_org_payment_method_id;
417   l_rec.object_version_number            := p_object_version_number;
418   --
419   -- Return the plsql record structure.
420   --
421   Return(l_rec);
422 --
423 End convert_args;
424 --
425 end pay_pga_shd;