DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_PUT_SHD

Source


1 Package Body pay_put_shd as
2 /* $Header: pyputrhi.pkb 115.0 2003/09/23 08:07 tvankayl noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pay_put_shd.';  -- Global package name
9 --
10 -- The following two global variables are only to be used
11 -- by the chk_compatible_startup_mode function.
12 --
13 g_CSMC_business_group_id      number         default null;
14 g_CSMC_legislation_code       varchar2(150)  default null;
15 --
16 -- ----------------------------------------------------------------------------
17 -- |---------------------< chk_startup_mode_compatible >----------------------|
18 -- ----------------------------------------------------------------------------
19 function chk_startup_mode_compatible
20 (p_parent_bgid    in number
21 ,p_parent_legcode in varchar2
22 ,p_child_bgid     in number
23 ,p_child_legcode  in varchar2
24 ) return boolean is
25 --
26 cursor csr_legcode(p_business_group_id in number) is
27 select legislation_code
28 from   per_business_groups_perf
29 where  business_group_id = p_business_group_id;
30 --
31 l_legcode varchar2(150);
32 begin
33   --
34   -- Parent startup mode is GENERIC. Anything is compatible in this case.
35   --
36   if p_parent_bgid is null and p_parent_legcode is null then
37     return true;
38   --
39   -- Parent startup mode is USER. Child is only compatible if it has a
40   -- matching BUSINESS_GROUP_ID.
41   --
42   elsif p_parent_bgid is not null then
43     return p_parent_bgid = p_child_bgid;
44   --
45   -- Parent startup mode is STARTUP. Match is either on LEGISLATION_CODE
46   -- or if child BUSINESS_GROUP belongs to the parent's legislation.
47   --
48   elsif p_parent_legcode is not null then
49     if p_parent_legcode = p_child_legcode then
50       return true;
51     --
52     -- Look for cached LEGISLATION_CODE.
53     --
54     elsif p_child_bgid = g_CSMC_business_group_id then
55       return p_parent_legcode = g_CSMC_legislation_code;
56     --
57     -- Update the cached LEGISLATION_CODE from the database and try again.
58     --
59     else
60       open csr_legcode(p_business_group_id => p_child_bgid);
61       fetch csr_legcode
62       into  l_legcode;
63       if csr_legcode%notfound then
64         close csr_legcode;
65         hr_utility.set_message(801, 'HR_7208_API_BUS_GRP_INVALID');
66         hr_utility.raise_error;
67       end if;
68       close csr_legcode;
69       --
70       g_CSMC_business_group_id := p_child_bgid;
71       g_CSMC_legislation_code := l_legcode;
72       return p_parent_legcode = g_CSMC_legislation_code;
73     end if;
74   end if;
75   return false;
76 end chk_startup_mode_compatible;
77 --
78 -- ----------------------------------------------------------------------------
79 -- |------------------------< return_api_dml_status >-------------------------|
80 -- ----------------------------------------------------------------------------
81 Function return_api_dml_status Return Boolean Is
82 --
83 Begin
84   --
85   Return (nvl(g_api_dml, false));
86   --
87 End return_api_dml_status;
88 --
89 -- ----------------------------------------------------------------------------
90 -- |---------------------------< constraint_error >---------------------------|
91 -- ----------------------------------------------------------------------------
92 Procedure constraint_error
93   (p_constraint_name in all_constraints.constraint_name%TYPE
94   ) Is
95 --
96   l_proc        varchar2(72) := g_package||'constraint_error';
97 --
98 Begin
99   --
100   If (p_constraint_name = 'PAY_USER_TABLES_PK') Then
101     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
102     fnd_message.set_token('PROCEDURE', l_proc);
103     fnd_message.set_token('STEP','5');
104     fnd_message.raise_error;
105   ElsIf (p_constraint_name = 'PAY_USER_TABLES_UK2') Then
106     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
107     fnd_message.set_token('PROCEDURE', l_proc);
108     fnd_message.set_token('STEP','10');
109     fnd_message.raise_error;
110   ElsIf (p_constraint_name = 'PAY_UTAB_RANGE_OR_MATCH_CHK') Then
111     fnd_message.set_name('PAY', 'HR_52966_INVALID_LOOKUP');
112     fnd_message.set_token('COLUMN', 'RANGE_OR_MATCH');
113     fnd_message.set_token('LOOKUP_TYPE','RANGE_MATCH');
114     fnd_message.raise_error;
115   ElsIf (p_constraint_name = 'PAY_UTAB_USER_KEY_UNITS_CHK') Then
116     fnd_message.set_name('PAY', 'HR_52966_INVALID_LOOKUP');
117     fnd_message.set_token('COLUMN', 'USER_KEY_UNITS');
118     fnd_message.set_token('LOOKUP_TYPE','DATA_TYPE');
119     fnd_message.raise_error;
120   Else
121     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
122     fnd_message.set_token('PROCEDURE', l_proc);
123     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
124     fnd_message.raise_error;
125   End If;
126   --
127 End constraint_error;
128 --
129 -- ----------------------------------------------------------------------------
130 -- |-----------------------------< api_updating >-----------------------------|
131 -- ----------------------------------------------------------------------------
132 Function api_updating
133   (p_user_table_id                        in     number
134   ,p_object_version_number                in     number
135   )
136   Return Boolean Is
137   --
138   --
139   -- Cursor selects the 'current' row from the HR Schema
140   --
141   Cursor C_Sel1 is
142     select
143        user_table_id
144       ,business_group_id
145       ,legislation_code
146       ,range_or_match
147       ,user_key_units
148       ,user_table_name
149       ,user_row_title
150       ,object_version_number
151     from        pay_user_tables
152     where       user_table_id = p_user_table_id;
153   --
154   l_fct_ret     boolean;
155   --
156 Begin
157   --
158   If (p_user_table_id is null and
159       p_object_version_number is null
160      ) Then
161     --
162     -- One of the primary key arguments is null therefore we must
163     -- set the returning function value to false
164     --
165     l_fct_ret := false;
166   Else
167     If (p_user_table_id
168         = pay_put_shd.g_old_rec.user_table_id and
169         p_object_version_number
170         = pay_put_shd.g_old_rec.object_version_number
171        ) Then
172       --
173       -- The g_old_rec is current therefore we must
174       -- set the returning function to true
175       --
176       l_fct_ret := true;
177     Else
178       --
179       -- Select the current row into g_old_rec
180       --
181       Open C_Sel1;
182       Fetch C_Sel1 Into pay_put_shd.g_old_rec;
183       If C_Sel1%notfound Then
184         Close C_Sel1;
185         --
186         -- The primary key is invalid therefore we must error
187         --
188         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
189         fnd_message.raise_error;
190       End If;
191       Close C_Sel1;
192       If (p_object_version_number
193           <> pay_put_shd.g_old_rec.object_version_number) Then
194         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
195         fnd_message.raise_error;
196       End If;
197       l_fct_ret := true;
198     End If;
199   End If;
200   Return (l_fct_ret);
201 --
202 End api_updating;
203 --
204 -- ----------------------------------------------------------------------------
205 -- |---------------------------------< lck >----------------------------------|
206 -- ----------------------------------------------------------------------------
207 Procedure lck
208   (p_user_table_id                        in     number
209   ,p_object_version_number                in     number
210   ) is
211 --
212 -- Cursor selects the 'current' row from the HR Schema
213 --
214   Cursor C_Sel1 is
215     select
216        user_table_id
217       ,business_group_id
218       ,legislation_code
219       ,range_or_match
220       ,user_key_units
221       ,user_table_name
222       ,user_row_title
223       ,object_version_number
224     from        pay_user_tables
225     where       user_table_id = p_user_table_id
226     for update nowait;
227 --
228   l_proc        varchar2(72) := g_package||'lck';
229 --
230 Begin
231   hr_utility.set_location('Entering:'||l_proc, 5);
232   --
233   hr_api.mandatory_arg_error
234     (p_api_name           => l_proc
235     ,p_argument           => 'USER_TABLE_ID'
236     ,p_argument_value     => p_user_table_id
237     );
238   hr_utility.set_location(l_proc,6);
239   hr_api.mandatory_arg_error
240     (p_api_name           => l_proc
241     ,p_argument           => 'OBJECT_VERSION_NUMBER'
242     ,p_argument_value     => p_object_version_number
243     );
244   --
245   Open  C_Sel1;
246   Fetch C_Sel1 Into pay_put_shd.g_old_rec;
247   If C_Sel1%notfound then
248     Close C_Sel1;
249     --
250     -- The primary key is invalid therefore we must error
251     --
252     fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
253     fnd_message.raise_error;
254   End If;
255   Close C_Sel1;
256   If (p_object_version_number
257       <> pay_put_shd.g_old_rec.object_version_number) Then
258         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
259         fnd_message.raise_error;
260   End If;
261   --
262   hr_utility.set_location(' Leaving:'||l_proc, 10);
263   --
264   -- We need to trap the ORA LOCK exception
265   --
266 Exception
267   When HR_Api.Object_Locked then
268     --
269     -- The object is locked therefore we need to supply a meaningful
270     -- error message.
271     --
272     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
273     fnd_message.set_token('TABLE_NAME', 'pay_user_tables');
274     fnd_message.raise_error;
275 End lck;
276 --
277 -- ----------------------------------------------------------------------------
278 -- |-----------------------------< convert_args >-----------------------------|
279 -- ----------------------------------------------------------------------------
280 Function convert_args
281   (p_user_table_id                  in number
282   ,p_business_group_id              in number
283   ,p_legislation_code               in varchar2
284   ,p_range_or_match                 in varchar2
285   ,p_user_key_units                 in varchar2
286   ,p_user_table_name                in varchar2
287   ,p_user_row_title                 in varchar2
288   ,p_object_version_number          in number
289   )
290   Return g_rec_type is
291 --
292   l_rec   g_rec_type;
293 --
294 Begin
295   --
296   -- Convert arguments into local l_rec structure.
297   --
298   l_rec.user_table_id                    := p_user_table_id;
299   l_rec.business_group_id                := p_business_group_id;
300   l_rec.legislation_code                 := p_legislation_code;
301   l_rec.range_or_match                   := p_range_or_match;
302   l_rec.user_key_units                   := p_user_key_units;
303   l_rec.user_table_name                  := p_user_table_name;
304   l_rec.user_row_title                   := p_user_row_title;
305   l_rec.object_version_number            := p_object_version_number;
306   --
307   -- Return the plsql record structure.
308   --
309   Return(l_rec);
310 --
311 End convert_args;
312 --
313 end pay_put_shd;