[Home] [Help]
PACKAGE BODY: APPS.PAY_ELEMENT_LINK_INTERNAL
Source
1 Package Body pay_element_link_internal as
2 /* $Header: pypelbsi.pkb 120.0 2006/10/05 13:28:34 thabara noship $ */
3 --
4 -- Package Variables
5 --
6 g_package varchar2(33) := 'pay_element_link_internal.';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |--------------------------<create_element_link>--------------------------|
10 -- ----------------------------------------------------------------------------
11 --
12 procedure create_element_link
13 (p_effective_date in date
14 ,p_element_type_id in number
15 ,p_business_group_id in number
16 ,p_costable_type in varchar2
17 ,p_payroll_id in number default null
18 ,p_job_id in number default null
19 ,p_position_id in number default null
20 ,p_people_group_id in number default null
21 ,p_cost_allocation_keyflex_id in out nocopy number
22 ,p_organization_id in number default null
23 ,p_location_id in number default null
24 ,p_grade_id in number default null
25 ,p_balancing_keyflex_id in out nocopy number
26 ,p_element_set_id in number default null
27 ,p_pay_basis_id in number default null
28 ,p_link_to_all_payrolls_flag in varchar2 default 'N'
29 ,p_standard_link_flag in out nocopy varchar2
30 ,p_transfer_to_gl_flag in varchar2 default 'N'
31 ,p_comments in varchar2 default null
32 ,p_employment_category in varchar2 default null
33 ,p_qualifying_age in number default null
34 ,p_qualifying_length_of_service in number default null
35 ,p_qualifying_units in varchar2 default null
36 ,p_attribute_category in varchar2 default null
37 ,p_attribute1 in varchar2 default null
38 ,p_attribute2 in varchar2 default null
39 ,p_attribute3 in varchar2 default null
40 ,p_attribute4 in varchar2 default null
41 ,p_attribute5 in varchar2 default null
42 ,p_attribute6 in varchar2 default null
43 ,p_attribute7 in varchar2 default null
44 ,p_attribute8 in varchar2 default null
45 ,p_attribute9 in varchar2 default null
46 ,p_attribute10 in varchar2 default null
47 ,p_attribute11 in varchar2 default null
48 ,p_attribute12 in varchar2 default null
49 ,p_attribute13 in varchar2 default null
50 ,p_attribute14 in varchar2 default null
51 ,p_attribute15 in varchar2 default null
52 ,p_attribute16 in varchar2 default null
53 ,p_attribute17 in varchar2 default null
54 ,p_attribute18 in varchar2 default null
55 ,p_attribute19 in varchar2 default null
56 ,p_attribute20 in varchar2 default null
57 ,p_cost_segment1 in varchar2 default null
58 ,p_cost_segment2 in varchar2 default null
59 ,p_cost_segment3 in varchar2 default null
60 ,p_cost_segment4 in varchar2 default null
61 ,p_cost_segment5 in varchar2 default null
62 ,p_cost_segment6 in varchar2 default null
63 ,p_cost_segment7 in varchar2 default null
64 ,p_cost_segment8 in varchar2 default null
65 ,p_cost_segment9 in varchar2 default null
66 ,p_cost_segment10 in varchar2 default null
67 ,p_cost_segment11 in varchar2 default null
68 ,p_cost_segment12 in varchar2 default null
69 ,p_cost_segment13 in varchar2 default null
70 ,p_cost_segment14 in varchar2 default null
71 ,p_cost_segment15 in varchar2 default null
72 ,p_cost_segment16 in varchar2 default null
73 ,p_cost_segment17 in varchar2 default null
74 ,p_cost_segment18 in varchar2 default null
75 ,p_cost_segment19 in varchar2 default null
76 ,p_cost_segment20 in varchar2 default null
77 ,p_cost_segment21 in varchar2 default null
78 ,p_cost_segment22 in varchar2 default null
79 ,p_cost_segment23 in varchar2 default null
80 ,p_cost_segment24 in varchar2 default null
81 ,p_cost_segment25 in varchar2 default null
82 ,p_cost_segment26 in varchar2 default null
83 ,p_cost_segment27 in varchar2 default null
84 ,p_cost_segment28 in varchar2 default null
85 ,p_cost_segment29 in varchar2 default null
86 ,p_cost_segment30 in varchar2 default null
87 ,p_balance_segment1 in varchar2 default null
88 ,p_balance_segment2 in varchar2 default null
89 ,p_balance_segment3 in varchar2 default null
90 ,p_balance_segment4 in varchar2 default null
91 ,p_balance_segment5 in varchar2 default null
92 ,p_balance_segment6 in varchar2 default null
93 ,p_balance_segment7 in varchar2 default null
94 ,p_balance_segment8 in varchar2 default null
95 ,p_balance_segment9 in varchar2 default null
96 ,p_balance_segment10 in varchar2 default null
97 ,p_balance_segment11 in varchar2 default null
98 ,p_balance_segment12 in varchar2 default null
99 ,p_balance_segment13 in varchar2 default null
100 ,p_balance_segment14 in varchar2 default null
101 ,p_balance_segment15 in varchar2 default null
102 ,p_balance_segment16 in varchar2 default null
103 ,p_balance_segment17 in varchar2 default null
104 ,p_balance_segment18 in varchar2 default null
105 ,p_balance_segment19 in varchar2 default null
106 ,p_balance_segment20 in varchar2 default null
107 ,p_balance_segment21 in varchar2 default null
108 ,p_balance_segment22 in varchar2 default null
109 ,p_balance_segment23 in varchar2 default null
110 ,p_balance_segment24 in varchar2 default null
111 ,p_balance_segment25 in varchar2 default null
112 ,p_balance_segment26 in varchar2 default null
113 ,p_balance_segment27 in varchar2 default null
114 ,p_balance_segment28 in varchar2 default null
115 ,p_balance_segment29 in varchar2 default null
116 ,p_balance_segment30 in varchar2 default null
117 ,p_cost_concat_segments in varchar2
118 ,p_balance_concat_segments in varchar2
119 ,p_element_link_id out nocopy number
120 ,p_comment_id out nocopy number
121 ,p_object_version_number out nocopy number
122 ,p_effective_start_date out nocopy date
123 ,p_effective_end_date out nocopy date
124 ) is
125 --
126 -- Declare cursors and local variables
127 --
128 l_proc varchar2(72) := g_package||'create_element_link';
129 l_effective_date date;
130
131 -- The variables to get the cost/balance id and structure number
132 l_flex_num number;
133 l_cost_allocation_id number := p_cost_allocation_keyflex_id;
134 l_bal_allocation_id number := p_balancing_keyflex_id;
135
136 -- Variable used to collect the concat segments. Not used furthur hence
137 -- called temp
138 l_temp varchar2(1000);
139
140 -- Variable to collect the default standard link flag,Qualifying conditions
141 -- and multiply value flag from the element type
142 l_standard_link_flag pay_element_links_f.standard_link_flag%type;
143 l_qualifying_age pay_element_links_f.qualifying_age%type;
144 l_qualifying_length_of_service
145 pay_element_links_f.qualifying_length_of_service%type;
146 l_qualifying_units pay_element_links_f.qualifying_units%type;
147 l_multiply_value_flag pay_element_links_f.multiply_value_flag%type;
148
149 -- Cursor to get the structure number to be passed to get the cost/balance id
150 cursor csr_flexnum is
151 select cost_allocation_structure
152 from per_business_groups
153 where business_group_id = p_business_group_id;
154 --
155 -- Variables to hold the values returned.
156 --
157 l_element_link_id number;
158 l_comment_id number;
159 l_object_version_number number;
160 l_effective_start_date date;
161 l_effective_end_date date;
162 --
163 begin
164 hr_utility.set_location('Entering:'|| l_proc, 10);
165 --
166 -- Truncate the time portion from all IN date parameters
167 --
168 l_effective_date := trunc(p_effective_date);
169
170 -- If the costable type is Distributed/Costed/Fixed Costed then call hr_kflex_utility for
171 -- mandatory balancing segments
172
173 if (p_costable_type = 'D' or p_costable_type = 'C'
174 or p_costable_type = 'F') then
175
176 if (l_bal_allocation_id is null
177 or l_cost_allocation_id is null) then
178
179 -- Call to hr_kflex_utility.ins_or_sel_keyflex_comb
180 open csr_Flexnum;
181 fetch csr_Flexnum into l_flex_num;
182 if csr_Flexnum%notfound then
183 close csr_Flexnum;
184 hr_utility.set_message(801,'HR_7471_FLEX_PEA_INVALID_ID');
185 hr_utility.raise_error;
186 end if;
187 end if;
188
189 if l_bal_allocation_id is null then
190 hr_kflex_utility.ins_or_sel_keyflex_comb
191 (p_appl_short_name => 'PAY'
192 ,p_flex_code => 'COST'
193 ,p_flex_num => l_flex_num
194 ,p_segment1 => p_balance_segment1
195 ,p_segment2 => p_balance_segment2
196 ,p_segment3 => p_balance_segment3
197 ,p_segment4 => p_balance_segment4
198 ,p_segment5 => p_balance_segment5
199 ,p_segment6 => p_balance_segment6
200 ,p_segment7 => p_balance_segment7
201 ,p_segment8 => p_balance_segment8
202 ,p_segment9 => p_balance_segment9
203 ,p_segment10 => p_balance_segment10
204 ,p_segment11 => p_balance_segment11
205 ,p_segment12 => p_balance_segment12
206 ,p_segment13 => p_balance_segment13
207 ,p_segment14 => p_balance_segment14
208 ,p_segment15 => p_balance_segment15
209 ,p_segment16 => p_balance_segment16
210 ,p_segment17 => p_balance_segment17
211 ,p_segment18 => p_balance_segment18
212 ,p_segment19 => p_balance_segment19
213 ,p_segment20 => p_balance_segment20
214 ,p_segment21 => p_balance_segment21
215 ,p_segment22 => p_balance_segment22
216 ,p_segment23 => p_balance_segment23
217 ,p_segment24 => p_balance_segment24
218 ,p_segment25 => p_balance_segment25
219 ,p_segment26 => p_balance_segment26
220 ,p_segment27 => p_balance_segment27
221 ,p_segment28 => p_balance_segment28
222 ,p_segment29 => p_balance_segment29
223 ,p_segment30 => p_balance_segment30
224 ,p_concat_segments_in => p_balance_concat_segments
225 ,p_ccid => l_bal_allocation_id
226 ,p_concat_segments_out => l_temp
227 );
228 end if;
229
230 -- Call the hr_kflex_untility for optional costing if that info is supplied
231 -- In case if p_cost_allocation_keyflex_id is supplied then there is no need
232 -- to get the costing id again.
233
234 if l_cost_allocation_id is null and
235 (p_cost_segment1 is not null or p_cost_segment2 is not null or
236 p_cost_segment3 is not null or p_cost_segment4 is not null or
237 p_cost_segment5 is not null or p_cost_segment6 is not null or
238 p_cost_segment7 is not null or p_cost_segment8 is not null or
239 p_cost_segment9 is not null or p_cost_segment10 is not null or
240 p_cost_segment11 is not null or p_cost_segment12 is not null or
241 p_cost_segment13 is not null or p_cost_segment14 is not null or
242 p_cost_segment15 is not null or p_cost_segment16 is not null or
243 p_cost_segment17 is not null or p_cost_segment18 is not null or
244 p_cost_segment19 is not null or p_cost_segment20 is not null or
245 p_cost_segment21 is not null or p_cost_segment22 is not null or
246 p_cost_segment23 is not null or p_cost_segment24 is not null or
247 p_cost_segment25 is not null or p_cost_segment26 is not null or
248 p_cost_segment27 is not null or p_cost_segment28 is not null or
249 p_cost_segment29 is not null or p_cost_segment30 is not null) then
250
251 hr_kflex_utility.ins_or_sel_keyflex_comb
252 (p_appl_short_name => 'PAY'
253 ,p_flex_code => 'COST'
254 ,p_flex_num => l_flex_num
255 ,p_segment1 => p_cost_segment1
256 ,p_segment2 => p_cost_segment2
257 ,p_segment3 => p_cost_segment3
258 ,p_segment4 => p_cost_segment4
259 ,p_segment5 => p_cost_segment5
260 ,p_segment6 => p_cost_segment6
261 ,p_segment7 => p_cost_segment7
262 ,p_segment8 => p_cost_segment8
263 ,p_segment9 => p_cost_segment9
264 ,p_segment10 => p_cost_segment10
265 ,p_segment11 => p_cost_segment11
266 ,p_segment12 => p_cost_segment12
267 ,p_segment13 => p_cost_segment13
268 ,p_segment14 => p_cost_segment14
269 ,p_segment15 => p_cost_segment15
270 ,p_segment16 => p_cost_segment16
271 ,p_segment17 => p_cost_segment17
272 ,p_segment18 => p_cost_segment18
273 ,p_segment19 => p_cost_segment19
274 ,p_segment20 => p_cost_segment20
275 ,p_segment21 => p_cost_segment21
276 ,p_segment22 => p_cost_segment22
277 ,p_segment23 => p_cost_segment23
278 ,p_segment24 => p_cost_segment24
279 ,p_segment25 => p_cost_segment25
280 ,p_segment26 => p_cost_segment26
281 ,p_segment27 => p_cost_segment27
282 ,p_segment28 => p_cost_segment28
283 ,p_segment29 => p_cost_segment29
284 ,p_segment30 => p_cost_segment30
285 ,p_concat_segments_in => p_cost_concat_segments
286 ,p_ccid => l_cost_allocation_id
287 ,p_concat_segments_out => l_temp
288 );
289 end if;
290 end if;
291 --
292 begin
293 if p_qualifying_length_of_service is not null
294 and (p_qualifying_length_of_service < 0
295 or to_number(p_qualifying_length_of_service,'9999.99')
296 <> to_number(p_qualifying_length_of_service)) then
297 fnd_message.set_name('PAY', 'PAY_33097_QUALI_LOS_CHECK');
298 fnd_message.raise_error;
299 end if;
300 exception
301 when others then
302 fnd_message.set_name('PAY', 'PAY_33097_QUALI_LOS_CHECK');
303 fnd_message.raise_error;
304 end;
305 --
306 -- Assign values of those parameters who need to be defaulted on basis of
307 -- element type. These are assigned to variable as these are used as
308 -- in/out parameters in chk_defaults procedure.
309 --
310 l_standard_link_flag := p_standard_link_flag;
311 l_qualifying_age := p_qualifying_age;
312 l_qualifying_length_of_service := p_qualifying_length_of_service;
313 l_qualifying_units := p_qualifying_units;
314 -- Defaults the values
318 ,p_qualifying_length_of_service => l_qualifying_length_of_service
315 pay_pel_bus.chk_defaults
316 (p_element_type_id => p_element_type_id
317 ,p_qualifying_age => l_qualifying_age
319 ,p_qualifying_units => l_qualifying_units
320 ,p_multiply_value_flag => l_multiply_value_flag
321 ,p_standard_link_flag => l_standard_link_flag
322 ,p_effective_date => l_effective_date
323 );
324
325 --
326 -- Process Logic
327 --
328 pay_pel_ins.ins(
329 p_effective_date => l_effective_date
330 ,p_element_type_id => p_element_type_id
331 ,p_business_group_id => p_business_group_id
332 ,p_costable_type => p_costable_type
333 ,p_link_to_all_payrolls_flag => p_link_to_all_payrolls_flag
334 ,p_multiply_value_flag => l_multiply_value_flag
335 ,p_standard_link_flag => l_standard_link_flag
336 ,p_transfer_to_gl_flag => p_transfer_to_gl_flag
337 ,p_payroll_id => p_payroll_id
338 ,p_job_id => p_job_id
339 ,p_position_id => p_position_id
340 ,p_people_group_id => p_people_group_id
341 ,p_cost_allocation_keyflex_id => l_cost_allocation_id
342 ,p_organization_id => p_organization_id
343 ,p_location_id => p_location_id
344 ,p_grade_id => p_grade_id
345 ,p_balancing_keyflex_id => l_bal_allocation_id
346 ,p_element_set_id => p_element_set_id
347 ,p_pay_basis_id => p_pay_basis_id
348 ,p_comments => p_comments
349 ,p_employment_category => p_employment_category
350 ,p_qualifying_age => l_qualifying_age
351 ,p_qualifying_length_of_service => l_qualifying_length_of_service
352 ,p_qualifying_units => l_qualifying_units
353 ,p_attribute_category => p_attribute_category
354 ,p_attribute1 => p_attribute1
355 ,p_attribute2 => p_attribute2
356 ,p_attribute3 => p_attribute3
357 ,p_attribute4 => p_attribute4
358 ,p_attribute5 => p_attribute5
359 ,p_attribute6 => p_attribute6
360 ,p_attribute7 => p_attribute7
361 ,p_attribute8 => p_attribute8
362 ,p_attribute9 => p_attribute9
363 ,p_attribute10 => p_attribute10
364 ,p_attribute11 => p_attribute11
365 ,p_attribute12 => p_attribute12
366 ,p_attribute13 => p_attribute13
367 ,p_attribute14 => p_attribute14
368 ,p_attribute15 => p_attribute15
369 ,p_attribute16 => p_attribute16
370 ,p_attribute17 => p_attribute17
371 ,p_attribute18 => p_attribute18
372 ,p_attribute19 => p_attribute19
373 ,p_attribute20 => p_attribute20
374 ,p_element_link_id => l_element_link_id
375 ,p_object_version_number => l_object_version_number
376 ,p_effective_start_date => l_effective_start_date
377 ,p_effective_end_date => l_effective_end_date
378 ,p_comment_id => l_comment_id
379 );
380
381 -- The following three procedures are called to create the subsequent entries
382 -- once element_link_id is created.
383
384 -- Creates link input values for the element link created
385 pay_pel_bus.chk_link_input_values
386 (p_element_type_id => p_element_type_id
387 ,p_element_link_id => l_element_link_id
388 ,p_effective_date => l_effective_date
389 );
390
391 --
392 -- Set out variables
393 --
394 p_element_link_id := l_element_link_id;
395 p_comment_id := l_comment_id;
396 p_object_version_number := l_object_version_number;
397 p_effective_start_date := l_effective_start_date;
398 p_effective_end_date := l_effective_end_date;
399 p_standard_link_flag := l_standard_link_flag;
400 p_cost_allocation_keyflex_id := l_cost_allocation_id;
401 p_balancing_keyflex_id := l_bal_allocation_id;
402
403 hr_utility.set_location(' Leaving:'||l_proc, 70);
404 end create_element_link;
405
406 end pay_element_link_internal;