DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_ORS_SHD

Source


1 Package Body per_ors_shd as
2 /* $Header: peorsrhi.pkb 115.8 2003/06/30 09:58:15 kjagadee noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_ors_shd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------< return_api_dml_status >-------------------------|
12 -- ----------------------------------------------------------------------------
13 Function return_api_dml_status Return Boolean Is
14 --
15 Begin
16   --
17   Return (nvl(g_api_dml, false));
18   --
19 End return_api_dml_status;
20 --
21 -- ----------------------------------------------------------------------------
22 -- |---------------------------< constraint_error >---------------------------|
23 -- ----------------------------------------------------------------------------
24 Procedure constraint_error
25   (p_constraint_name in all_constraints.constraint_name%TYPE
26   ) Is
27 --
28   l_proc        varchar2(72) := g_package||'constraint_error';
29 --
30 Begin
31   --
32   If (p_constraint_name = 'PER_ORGANIZATION_STRUCTURE_FK1') Then
33     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
34     fnd_message.set_token('PROCEDURE', l_proc);
35     fnd_message.set_token('STEP','5');
36     fnd_message.raise_error;
37   ElsIf (p_constraint_name = 'PER_ORGANIZATION_STRUCTURE_PK') Then
38     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
39     fnd_message.set_token('PROCEDURE', l_proc);
40     fnd_message.set_token('STEP','10');
41     fnd_message.raise_error;
42   ElsIf (p_constraint_name = 'PER_ORGANIZATION_STRUCTURE_UK2') Then
43     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
44     fnd_message.set_token('PROCEDURE', l_proc);
45     fnd_message.set_token('STEP','15');
46     fnd_message.raise_error;
47   ElsIf (p_constraint_name = 'PER_OS_PRIMARY_STRUCTURE_F_CHK') Then
48     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
49     fnd_message.set_token('PROCEDURE', l_proc);
50     fnd_message.set_token('STEP','20');
51     fnd_message.raise_error;
52   Else
53     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
54     fnd_message.set_token('PROCEDURE', l_proc);
55     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
56     fnd_message.raise_error;
57   End If;
58   --
59 End constraint_error;
60 --
61 -- ----------------------------------------------------------------------------
62 -- |-----------------------------< api_updating >-----------------------------|
63 -- ----------------------------------------------------------------------------
64 Function api_updating
65   (p_organization_structure_id            in     number
66   ,p_object_version_number                in     number
67   )
68   Return Boolean Is
69   --
70   --
71   -- Cursor selects the 'current' row from the HR Schema
72   --
73   Cursor C_Sel1 is
74     select
75        organization_structure_id
76       ,business_group_id
77       ,name
78       ,comments
79       ,primary_structure_flag
80       ,request_id
81       ,program_application_id
82       ,program_id
83       ,program_update_date
84       ,attribute_category
85       ,attribute1
86       ,attribute2
87       ,attribute3
88       ,attribute4
89       ,attribute5
90       ,attribute6
91       ,attribute7
92       ,attribute8
93       ,attribute9
94       ,attribute10
95       ,attribute11
96       ,attribute12
97       ,attribute13
98       ,attribute14
99       ,attribute15
100       ,attribute16
101       ,attribute17
102       ,attribute18
103       ,attribute19
104       ,attribute20
105       ,position_control_structure_flg
106       ,object_version_number
107     from        per_organization_structures
108     where       organization_structure_id = p_organization_structure_id;
109   --
110   l_fct_ret     boolean;
111   --
112 Begin
113   --
114   If (p_organization_structure_id is null and
115       p_object_version_number is null
116      ) Then
117     --
118     -- One of the primary key arguments is null therefore we must
119     -- set the returning function value to false
120     --
121     l_fct_ret := false;
122   Else
123     If (p_organization_structure_id
124         = per_ors_shd.g_old_rec.organization_structure_id and
125         p_object_version_number
126         = per_ors_shd.g_old_rec.object_version_number
127        ) Then
128       --
129       -- The g_old_rec is current therefore we must
130       -- set the returning function to true
131       --
132       l_fct_ret := true;
133     Else
134       --
135       -- Select the current row into g_old_rec
136       --
137       Open C_Sel1;
138       Fetch C_Sel1 Into per_ors_shd.g_old_rec;
139       If C_Sel1%notfound Then
140         Close C_Sel1;
141         --
142         -- The primary key is invalid therefore we must error
143         --
144         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
145         fnd_message.raise_error;
146       End If;
147       Close C_Sel1;
148       If (p_object_version_number
149           <> per_ors_shd.g_old_rec.object_version_number) Then
150         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
151         fnd_message.raise_error;
152       End If;
153       l_fct_ret := true;
154     End If;
155   End If;
156   Return (l_fct_ret);
157 --
158 End api_updating;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |---------------------------------< lck >----------------------------------|
162 -- ----------------------------------------------------------------------------
163 Procedure lck
164   (p_organization_structure_id            in     number
165   ,p_object_version_number                in     number
166   ) is
167 --
168 -- Cursor selects the 'current' row from the HR Schema
169 --
170   Cursor C_Sel1 is
171     select
172        organization_structure_id
173       ,business_group_id
174       ,name
175       ,comments
176       ,primary_structure_flag
177       ,request_id
178       ,program_application_id
179       ,program_id
180       ,program_update_date
181       ,attribute_category
182       ,attribute1
183       ,attribute2
184       ,attribute3
185       ,attribute4
186       ,attribute5
187       ,attribute6
188       ,attribute7
189       ,attribute8
190       ,attribute9
191       ,attribute10
192       ,attribute11
193       ,attribute12
194       ,attribute13
195       ,attribute14
196       ,attribute15
197       ,attribute16
198       ,attribute17
199       ,attribute18
200       ,attribute19
201       ,attribute20
202       ,position_control_structure_flg
203       ,object_version_number
204     from        per_organization_structures
205     where       organization_structure_id = p_organization_structure_id
206     for update nowait;
207 --
208   l_proc        varchar2(72) := g_package||'lck';
209 --
210 Begin
211   hr_utility.set_location('Entering:'||l_proc, 5);
212   --
213   hr_api.mandatory_arg_error
214     (p_api_name           => l_proc
215     ,p_argument           => 'ORGANIZATION_STRUCTURE_ID'
216     ,p_argument_value     => p_organization_structure_id
217     );
218   hr_utility.set_location(l_proc,6);
219   hr_api.mandatory_arg_error
220     (p_api_name           => l_proc
221     ,p_argument           => 'OBJECT_VERSION_NUMBER'
222     ,p_argument_value     => p_object_version_number
223     );
224   --
225   Open  C_Sel1;
226   Fetch C_Sel1 Into per_ors_shd.g_old_rec;
227   If C_Sel1%notfound then
228     Close C_Sel1;
229     --
230     -- The primary key is invalid therefore we must error
231     --
232     fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
233     fnd_message.raise_error;
234   End If;
235   Close C_Sel1;
236   If (p_object_version_number
237       <> per_ors_shd.g_old_rec.object_version_number) Then
238         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
239         fnd_message.raise_error;
240   End If;
241   --
242   hr_utility.set_location(' Leaving:'||l_proc, 10);
243   --
244   -- We need to trap the ORA LOCK exception
245   --
246 Exception
247   When HR_Api.Object_Locked then
248     --
249     -- The object is locked therefore we need to supply a meaningful
250     -- error message.
251     --
252     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
253     fnd_message.set_token('TABLE_NAME', 'per_organization_structures');
254     fnd_message.raise_error;
255 End lck;
256 --
257 -- ----------------------------------------------------------------------------
258 -- |-----------------------------< convert_args >-----------------------------|
259 -- ----------------------------------------------------------------------------
260 Function convert_args
261   (p_organization_structure_id      in number
262   ,p_business_group_id              in number
263   ,p_name                           in varchar2
264   ,p_comments                       in varchar2
265   ,p_primary_structure_flag         in varchar2
266   ,p_request_id                     in number
267   ,p_program_application_id         in number
268   ,p_program_id                     in number
269   ,p_program_update_date            in date
270   ,p_attribute_category             in varchar2
271   ,p_attribute1                     in varchar2
272   ,p_attribute2                     in varchar2
273   ,p_attribute3                     in varchar2
274   ,p_attribute4                     in varchar2
275   ,p_attribute5                     in varchar2
276   ,p_attribute6                     in varchar2
277   ,p_attribute7                     in varchar2
278   ,p_attribute8                     in varchar2
279   ,p_attribute9                     in varchar2
280   ,p_attribute10                    in varchar2
281   ,p_attribute11                    in varchar2
282   ,p_attribute12                    in varchar2
283   ,p_attribute13                    in varchar2
284   ,p_attribute14                    in varchar2
285   ,p_attribute15                    in varchar2
286   ,p_attribute16                    in varchar2
287   ,p_attribute17                    in varchar2
288   ,p_attribute18                    in varchar2
289   ,p_attribute19                    in varchar2
290   ,p_attribute20                    in varchar2
291   ,p_position_control_structure_f   in varchar2
292   ,p_object_version_number          in number
293   )
294   Return g_rec_type is
295 --
296   l_rec   g_rec_type;
297 --
298 Begin
299   --
300   -- Convert arguments into local l_rec structure.
301   --
302   l_rec.organization_structure_id        := p_organization_structure_id;
303   l_rec.business_group_id                := p_business_group_id;
304   l_rec.name                             := p_name;
305   l_rec.comments                         := p_comments;
306   l_rec.primary_structure_flag           := p_primary_structure_flag;
307   l_rec.request_id                       := p_request_id;
308   l_rec.program_application_id           := p_program_application_id;
309   l_rec.program_id                       := p_program_id;
310   l_rec.program_update_date              := p_program_update_date;
311   l_rec.attribute_category               := p_attribute_category;
312   l_rec.attribute1                       := p_attribute1;
313   l_rec.attribute2                       := p_attribute2;
314   l_rec.attribute3                       := p_attribute3;
315   l_rec.attribute4                       := p_attribute4;
316   l_rec.attribute5                       := p_attribute5;
317   l_rec.attribute6                       := p_attribute6;
318   l_rec.attribute7                       := p_attribute7;
319   l_rec.attribute8                       := p_attribute8;
320   l_rec.attribute9                       := p_attribute9;
321   l_rec.attribute10                      := p_attribute10;
322   l_rec.attribute11                      := p_attribute11;
323   l_rec.attribute12                      := p_attribute12;
324   l_rec.attribute13                      := p_attribute13;
325   l_rec.attribute14                      := p_attribute14;
326   l_rec.attribute15                      := p_attribute15;
327   l_rec.attribute16                      := p_attribute16;
328   l_rec.attribute17                      := p_attribute17;
329   l_rec.attribute18                      := p_attribute18;
330   l_rec.attribute19                      := p_attribute19;
331   l_rec.attribute20                      := p_attribute20;
332   l_rec.position_control_structure_flg   := p_position_control_structure_f;
333   l_rec.object_version_number            := p_object_version_number;
334   --
335   -- Return the plsql record structure.
336   --
337   Return(l_rec);
338 --
339 End convert_args;
340 --
341 end per_ors_shd;