DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PCE_SHD

Source


1 PACKAGE BODY per_pce_shd AS
2 /* $Header: pepcerhi.pkb 120.1 2006/10/18 09:19:34 grreddy noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  VARCHAR2(33) := '  per_pce_shd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |-------------------------< retrieve_cagr_info >---------------------------|
12 -- ----------------------------------------------------------------------------
13 --
14 PROCEDURE retrieve_cagr_info
15   (p_collective_agreement_id IN     NUMBER
16   ,p_business_group_id          OUT NOCOPY NUMBER) IS
17   --
18   -- Declare Local Cursors
19   --
20   CURSOR csr_cagr_info IS
21     SELECT cag.business_group_id
22 	FROM   per_collective_agreements cag
23 	WHERE  cag.collective_agreement_id = p_collective_agreement_id;
24   --
25   -- Declare Local Variables
26   --
27   l_proc VARCHAR2(72) := g_package || 'retrieve_cagr_info';
28   --
29 BEGIN
30   --
31   hr_utility.set_location('Entering:'||l_proc, 10);
32   --
33   -- Check mandatory parameters has been set
34   --
35   hr_api.mandatory_arg_error
36     (p_api_name	      => l_proc
37     ,p_argument	      => 'COLLECTIVE_AGREEMENT_ID'
38     ,p_argument_value => p_collective_agreement_id);
39   --
40   OPEN csr_cagr_info;
41   FETCH csr_cagr_info INTO p_business_group_id;
42   --
43   IF csr_cagr_info%NOTFOUND THEN
44     --
45 	CLOSE csr_cagr_info;
46 	--
47 	hr_utility.set_message(800, 'HR_289345_CAGR_REC_INV');
48     hr_utility.raise_error;
49 	--
50   ELSE
51     --
52 	CLOSE csr_cagr_info;
53 	--
54   END IF;
55   --
56   hr_utility.set_location('Leaving :'||l_proc, 999);
57   --
58 END retrieve_cagr_info;
59 --
60 -- ----------------------------------------------------------------------------
61 -- |---------------------------< constraint_error >---------------------------|
62 -- ----------------------------------------------------------------------------
63 PROCEDURE constraint_error
64   (p_constraint_name IN all_constraints.constraint_name%TYPE
65   ) Is
66 --
67   l_proc        VARCHAR2(72) := g_package||'constraint_error';
68 --
69 BEGIN
70   --
71   If (p_constraint_name = 'SYS_C00118392') THEN
72     fnd_message.set_name('PAY', 'HR_6153_ALL_PROCEDURE_FAIL');
73     fnd_message.set_token('PROCEDURE', l_proc);
74     fnd_message.set_token('STEP','5');
75     fnd_message.raise_error;
76   Else
77     fnd_message.set_name('PAY', 'HR_7877_API_INVALID_CONSTRAINT');
78     fnd_message.set_token('PROCEDURE', l_proc);
79     fnd_message.set_token('CONSTRAINT_NAME', p_constraint_name);
80     fnd_message.raise_error;
81   END If;
82   --
83 END constraint_error;
84 --
85 -- ----------------------------------------------------------------------------
86 -- |-----------------------------< api_updating >-----------------------------|
87 -- ----------------------------------------------------------------------------
88 Function api_updating
89   (p_cagr_entitlement_id                  IN     NUMBER
90   ,p_object_version_number                IN     NUMBER
91   )
92   Return Boolean Is
93   --
94   --
95   -- Cursor selects the 'current' row from the HR Schema
96   --
97   Cursor C_Sel1 IS
98     select
99        cagr_entitlement_id
100       ,cagr_entitlement_item_id
101       ,collective_agreement_id
102       ,start_date
103       ,end_date
104       ,status
105       ,formula_criteria
106       ,formula_id
107       ,units_of_measure
108 	  ,message_level
109       ,object_version_number
110     from        per_cagr_entitlements
111     where       cagr_entitlement_id = p_cagr_entitlement_id;
112   --
113   l_fct_ret     boolean;
114   --
115 BEGIN
116   --
117   If (p_cagr_entitlement_id IS NULL and
118       p_object_version_number IS NULL
119      ) THEN
120     --
121     -- One of the primary key arguments IS NULL therefore we must
122     -- set the returning function value to false
123     --
124     l_fct_ret := false;
125   Else
126     If (p_cagr_entitlement_id
127         = per_pce_shd.g_old_rec.cagr_entitlement_id and
128         p_object_version_number
129         = per_pce_shd.g_old_rec.object_version_number
130        ) THEN
131       --
132       -- The g_old_rec IS current therefore we must
133       -- set the returning function to true
134       --
135       l_fct_ret := true;
136     Else
137       --
138       -- Select the current row into g_old_rec
139       --
140       Open C_Sel1;
141       Fetch C_Sel1 Into per_pce_shd.g_old_rec;
142       If C_Sel1%notfound THEN
143         Close C_Sel1;
144         --
145         -- The primary key IS invalid therefore we must error
146         --
147         fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
148         fnd_message.raise_error;
149       END If;
150       Close C_Sel1;
151       If (p_object_version_number
152           <> per_pce_shd.g_old_rec.object_version_number) THEN
153         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
154         fnd_message.raise_error;
155       END If;
156       l_fct_ret := true;
157     END If;
158   END If;
159   Return (l_fct_ret);
160 --
161 END api_updating;
162 --
163 -- ----------------------------------------------------------------------------
164 -- |---------------------------------< lck >----------------------------------|
165 -- ----------------------------------------------------------------------------
166 PROCEDURE lck
167   (p_cagr_entitlement_id                  IN     NUMBER
168   ,p_object_version_number                IN     NUMBER
169   ) IS
170 --
171 -- Cursor selects the 'current' row from the HR Schema
172 --
173   Cursor C_Sel1 IS
174     select
175        cagr_entitlement_id
176       ,cagr_entitlement_item_id
177       ,collective_agreement_id
178       ,start_date
179       ,end_date
180       ,status
181       ,formula_criteria
182       ,formula_id
183       ,units_of_measure
184 	  ,message_level
185       ,object_version_number
186     from        per_cagr_entitlements
187     where       cagr_entitlement_id = p_cagr_entitlement_id
188     for update nowait;
189 --
190   l_proc        VARCHAR2(72) := g_package||'lck';
191 --
192 BEGIN
193   --
194   hr_utility.set_location('Entering:'||l_proc, 5);
195   --
196   hr_api.mandatory_arg_error
197     (p_api_name           => l_proc
198     ,p_argument           => 'CAGR_ENTITLEMENT_ID'
199     ,p_argument_value     => p_cagr_entitlement_id
200     );
201   hr_utility.set_location(l_proc,6);
202   hr_api.mandatory_arg_error
203     (p_api_name           => l_proc
204     ,p_argument           => 'OBJECT_VERSION_NUMBER'
205     ,p_argument_value     => p_object_version_number
206     );
207   --
208   Open  C_Sel1;
209   Fetch C_Sel1 Into per_pce_shd.g_old_rec;
210   If C_Sel1%notfound then
211     Close C_Sel1;
212     --
213     -- The primary key IS invalid therefore we must error
214     --
215     fnd_message.set_name('PAY', 'HR_7220_INVALID_PRIMARY_KEY');
216     fnd_message.raise_error;
217   END If;
218   Close C_Sel1;
219   If (p_object_version_number
220       <> per_pce_shd.g_old_rec.object_version_number) THEN
221         fnd_message.set_name('PAY', 'HR_7155_OBJECT_INVALID');
222         fnd_message.raise_error;
223   END If;
224   --
225   hr_utility.set_location(' Leaving:'||l_proc, 10);
226   --
227   -- We need to trap the ORA LOCK exception
228   --
229 EXCEPTION
230   WHEN HR_Api.Object_Locked then
231     --
232     -- The object IS locked therefore we need to supply a meaningful
233     -- error message.
234     --
235     fnd_message.set_name('PAY', 'HR_7165_OBJECT_LOCKED');
236     fnd_message.set_token('TABLE_NAME', 'per_cagr_entitlements');
237     fnd_message.raise_error;
238 END lck;
239 --
240 -- ----------------------------------------------------------------------------
241 -- |-----------------------------< convert_args >-----------------------------|
242 -- ----------------------------------------------------------------------------
243 Function convert_args
244   (p_cagr_entitlement_id            IN NUMBER
245   ,p_cagr_entitlement_item_id       IN NUMBER
246   ,p_collective_agreement_id        IN NUMBER
247   ,p_start_date                     IN DATE
248   ,p_end_date                       IN DATE
249   ,p_status                         IN VARCHAR2
250   ,p_formula_criteria               IN VARCHAR2
251   ,p_formula_id                     IN NUMBER
252   ,p_units_of_measure               IN VARCHAR2
253   ,p_message_level                  IN VARCHAR2
254   ,p_object_version_number          IN NUMBER
255   )
256   Return g_rec_type IS
257 --
258   l_rec   g_rec_type;
259 --
260 BEGIN
261   --
262   -- Convert arguments into local l_rec structure.
263   --
264   l_rec.cagr_entitlement_id              := p_cagr_entitlement_id;
265   l_rec.cagr_entitlement_item_id         := p_cagr_entitlement_item_id;
266   l_rec.collective_agreement_id          := p_collective_agreement_id;
267   l_rec.start_date                       := p_start_date;
268   l_rec.end_date                         := p_end_date;
269   l_rec.status                           := p_status;
270   l_rec.formula_criteria                 := p_formula_criteria;
271   l_rec.formula_id                       := p_formula_id;
272   l_rec.units_of_measure                 := p_units_of_measure;
273   l_rec.message_level                    := p_message_level;
274   l_rec.object_version_number            := p_object_version_number;
275   --
276   -- Return the plsql record structure.
277   --
278   RETURN(l_rec);
279 --
280 END convert_args;
281 --
282 end per_pce_shd;