[Home] [Help]
PACKAGE BODY: APPS.PSP_ENC_CREATE_LINES
Source
1 PACKAGE BODY PSP_ENC_CREATE_LINES AS
2 /* $Header: PSPENLNB.pls 120.60.12010000.7 2008/11/05 10:20:08 amakrish ship $ */
3
4 --For Enh Bug 2259310 -Changed the name of the procedure and
5 --the parameter from 100_percent_end_date to enc_org_end_Date
6
7 Procedure Obtain_Enc_Org_End_Date
8 (
9 p_enc_org_end_date OUT NOCOPY DATE,
10 p_business_group_id IN NUMBER,
11 p_set_of_books_id IN NUMBER,
12 p_return_status OUT NOCOPY VARCHAR2);
13
14 --For Enh Bug 2259310
15 --Redefined the parameter listing for the procedure
16 ---Renamed the procedure name from OBTAIN_ENC_PERIOD_EXTN to OBTAIN_ENC_POETA_END_DATE
17
18 Procedure Obtain_Enc_Poeta_End_Date
19 (p_ls_start_date IN DATE,
20 p_ls_end_date IN DATE,
21 p_poeta_end_date IN DATE,
22 p_enc_end_date OUT NOCOPY DATE,
23 p_return_status OUT NOCOPY VARCHAR2);
24
25 PROCEDURE create_lines( p_assignment_id IN NUMBER,
26 p_payroll_id IN NUMBER,
27 p_element_type_id IN NUMBER,
28 p_last_paid_date IN DATE,
29 p_return_status OUT NOCOPY VARCHAR2);
30
31 --For Enh Bug 2259310 -Added new parameters.
32 PROCEDURE insert_into_enc_lines(
33 L_ENC_ELEMENT_TYPE_ID IN NUMBER,
34 L_ENCUMBRANCE_DATE IN DATE,
35 L_DR_CR_FLAG IN VARCHAR2,
36 L_ENCUMBRANCE_AMOUNT IN NUMBER,
37 L_ENC_LINE_TYPE IN VARCHAR2,
38 L_SCHEDULE_LINE_ID IN NUMBER,
39 L_ORG_SCHEDULE_ID IN NUMBER,
40 L_DEFAULT_ORG_ACCOUNT_ID IN NUMBER,
41 L_SUSPENSE_ORG_ACCOUNT_ID IN NUMBER,
42 L_ELEMENT_ACCOUNT_ID IN NUMBER,
43 L_GL_PROJECT_FLAG IN VARCHAR2,
44 L_PERSON_ID IN NUMBER,
45 L_ASSIGNMENT_ID IN NUMBER,
46 L_AWARD_ID IN NUMBER,
47 L_TASK_ID IN NUMBER,
48 L_EXPENDITURE_TYPE IN VARCHAR2,
49 L_EXPENDITURE_ORGANIZATION_ID IN NUMBER,
50 L_PROJECT_ID IN NUMBER,
51 L_GL_CODE_COMBINATION_ID IN NUMBER,
52 L_TIME_PERIOD_ID IN NUMBER,
53 L_PAYROLL_ID IN NUMBER,
54 l_business_group_id IN NUMBER,
55 L_SET_OF_BOOKS_ID IN NUMBER,
56 L_SUSPENSE_REASON_CODE IN VARCHAR2,
57 L_DEFAULT_REASON_CODE IN VARCHAR2,
58 L_CHANGE_FLAG IN VARCHAR2,
59 L_ENC_START_DATE IN DATE, --Added the new parameter
60 L_ENC_END_DATE IN DATE, --Added the new parameter
61 p_attribute_category IN VARCHAR2, -- Introduced DFF parameters for bug fix 2908859
62 p_attribute1 IN VARCHAR2,
63 p_attribute2 IN VARCHAR2,
64 p_attribute3 IN VARCHAR2,
65 p_attribute4 IN VARCHAR2,
66 p_attribute5 IN VARCHAR2,
67 p_attribute6 IN VARCHAR2,
68 p_attribute7 IN VARCHAR2,
69 p_attribute8 IN VARCHAR2,
70 p_attribute9 IN VARCHAR2,
71 p_attribute10 IN VARCHAR2,
72 p_orig_gl_code_combination_id IN NUMBER,
73 p_orig_project_id IN NUMBER,
74 p_orig_task_id IN NUMBER,
75 p_orig_award_id IN NUMBER,
76 p_orig_expenditure_org_id IN NUMBER,
77 p_orig_expenditure_type IN VARCHAR2,
78 p_hierarchy_code IN VARCHAR2,
79 p_return_status OUT NOCOPY VARCHAR2);
80
81 PROCEDURE Create_Controls(p_payroll_action_id IN NUMBER,
82 p_payroll_id IN NUMBER,
83 p_time_period_id IN NUMBER,
84 p_business_group_id IN NUMBER,
85 p_set_of_books_id IN NUMBER,
86 p_enc_control_id OUT NOCOPY NUMBER,
87 p_return_status OUT NOCOPY VARCHAR2);
88
89 TYPE poeta_gl_hier_rectype IS RECORD
90 (
91 R_ENC_START_DATE DATE,
92 R_ENC_END_DATE DATE,
93 R_AMOUNT NUMBER,-- Changed Datatype from number(15,2) to number For Bug 2916848
94 R_SUSP_FLAG VARCHAR2(1) DEFAULT 'N'
95 );
96
97 r_poeta_gl_hier poeta_gl_hier_rectype;
98 TYPE r_poeta_gl_hier_tab IS TABLE OF r_poeta_gl_hier%TYPE INDEX BY BINARY_INTEGER;
99 --t_poeta_gl_hier_array r_poeta_gl_hier_tab;
100
101 --For Enh Bug 2259310 -Added new Procedures
102 Procedure determine_pro_rata_dates ( p_assignment_id IN NUMBER,
103 p_ls_start_date IN DATE,
104 p_ls_end_date IN DATE,
105 p_poeta_start_date IN DATE,
106 p_poeta_end_date IN DATE,
107 p_asg_start_date IN DATE,
108 p_asg_end_date IN DATE,
109 p_asg_amount IN NUMBER,
110 p_poeta_gl_hier_array IN OUT NOCOPY r_poeta_gl_hier_tab,
111 p_return_status OUT NOCOPY VARCHAR2);
112
113 Procedure insert_enc_lines_from_arrays(
114 p_payroll_id IN NUMBER,
115 p_business_group_id IN NUMBER,
116 p_set_of_books_id IN NUMBER,
117 p_enc_line_type IN VARCHAR2,
118 p_return_status OUT NOCOPY VARCHAR2);
119
120 -- Introduced the following for bug fix 3462452
121 PROCEDURE sub_slice_asg_chunk (p_assignment_id IN NUMBER,
122 p_element_type_id IN NUMBER,
123 p_business_group_id IN NUMBER,
124 p_set_of_books_id IN NUMBER,
125 p_return_status OUT NOCOPY VARCHAR2);
126 -- End of bug fix 3462452
127
128 PROCEDURE verify_changes(p_payroll_id IN NUMBER,
129 p_assignment_id IN NUMBER,
130 p_business_group_id IN NUMBER,
131 p_set_of_books_id IN NUMBER,
132 p_enc_line_type IN VARCHAR2,
133 l_retcode OUT NOCOPY VARCHAR2);
134
135 PROCEDURE create_liq_lines (p_payroll_action_id IN NUMBER,
136 p_payroll_id IN NUMBER,
137 p_assignment_id IN NUMBER,
138 p_enc_begin_date IN DATE,
139 p_business_group_id IN NUMBER,
140 p_set_of_books_id IN NUMBER,
141 p_return_status OUT NOCOPY VARCHAR2);
142
143 PROCEDURE create_sum_lines (p_payroll_action_id IN NUMBER,
144 p_payroll_id IN NUMBER,
145 p_assignment_id IN NUMBER,
146 p_business_group_id IN NUMBER,
147 p_set_of_books_id IN NUMBER,
148 p_return_status OUT NOCOPY VARCHAR2);
149
150 PROCEDURE enc_pre_process (p_payroll_action_id IN NUMBER,
151 p_payroll_id IN NUMBER,
152 p_process_mode IN VARCHAR2,
153 p_return_status OUT NOCOPY VARCHAR2);
154
155 PROCEDURE load_sch_hierarchy (p_assignment_id IN NUMBER,
156 p_payroll_id IN NUMBER,
157 p_element_type_id IN NUMBER,
158 p_business_group_id IN NUMBER,
159 p_set_of_books_id IN NUMBER,
160 p_return_status OUT NOCOPY VARCHAR2);
161
162 PROCEDURE add_cel_warnings(p_start_date IN DATE DEFAULT NULL,
163 p_end_date IN DATE DEFAULT NULL,
164 p_hierarchy_code IN VARCHAR2 DEFAULT NULL,
165 p_warning_code IN VARCHAR2 DEFAULT NULL,
166 p_gl_ccid IN NUMBER DEFAULT NULL,
167 p_project_id IN NUMBER DEFAULT NULL,
168 p_task_id IN NUMBER DEFAULT NULL,
169 p_award_id IN NUMBER DEFAULT NULL,
170 p_exp_org_id IN NUMBER DEFAULT NULL,
171 p_exp_type IN VARCHAR2 DEFAULT NULL,
172 p_effective_date IN DATE DEFAULT NULL,
173 p_error_status IN VARCHAR2 DEFAULT NULL,
174 p_percent IN NUMBER DEFAULT NULL);
175
176 PROCEDURE delete_previous_error_log(p_assignment_id IN NUMBER,
177 p_payroll_id IN NUMBER,
178 p_payroll_action_id IN NUMBER);
179
180 PROCEDURE update_hierarchy_dates (p_assignment_id IN NUMBER,
181 p_payroll_id IN NUMBER,
182 p_payroll_action_id IN NUMBER,
183 p_return_status OUT NOCOPY VARCHAR2);
184
185 PROCEDURE clear_sch_hierarchy;
186
187 -- Define Global Variables
188 g_Eff_Date_Value NUMBER;
189 g_Org_def_labor_schedule VARCHAR2(3) DEFAULT psp_general.get_specific_profile('PSP_DEFAULT_SCHEDULE');
190 g_Org_def_account VARCHAR2(3) DEFAULT psp_general.get_specific_profile('PSP_DEFAULT_ACCOUNT');
191 g_dr_cr_flag VARCHAR2(1); /* DEFAULT 'D'; commented for 2530853 */
192 g_enc_line_type VARCHAR2(1);
193 g_business_group_id NUMBER;
194 g_set_of_books_id NUMBER;
195 g_error_api_path VARCHAR2(230);
196 g_msg VARCHAR2(230);
197 g_dr_ctr NUMBER DEFAULT 0; -- Keep track of no of Dr transactions
198 g_cr_ctr NUMBER DEFAULT 0; -- Keep track of no of Cr transactions
199 g_ge_pointer NUMBER;
200 g_et_pointer NUMBER;
201 g_ec_pointer NUMBER;
202 g_asg_pointer NUMBER;
203 g_odls_pointer NUMBER;
204 g_da_pointer NUMBER;
205 g_sa_pointer NUMBER;
206 g_error_message VARCHAR2(4000);
207 g_warning_message VARCHAR2(4000);
208
209 -------For Enh Bug 2259310 : Added new variables----------------------------------------
210 g_enc_org_end_date DATE;
211 g_enc_lines_counter NUMBER DEFAULT 1;
212 g_currency_code PSP_PAYROLL_CONTROLS.CURRENCY_CODE%TYPE; -- For Bug 2916848 Ilo Mrc Ehnc.
213 g_precision NUMBER; -- For Bug 2916848 Ilo Mrc Ehnc.
214 g_ext_precision NUMBER; -- For Bug 2916848 Ilo Mrc Ehnc.
215
216 -- Introduced the following for bug fix 3462452
217 --g_debug BOOLEAN DEFAULT hr_utility.debug_enabled;
218 g_package_name VARCHAR2(31) DEFAULT 'PSP_ENC_CREATE_LINES.';
219 -- End of bug fix 3462452
220
221 g_dff_grouping_option CHAR(1); -- Introduced for bug fix 2908859
222 g_request_id NUMBER(15);
223 g_payroll_action_id NUMBER(15);
224 g_actual_term_date DATE;
225 g_ge_autopop VARCHAR2(1);
226 g_et_autopop VARCHAR2(1);
227 g_eg_autopop VARCHAR2(1);
228 g_as_autopop VARCHAR2(1);
229 g_ds_autopop VARCHAR2(1);
230 g_da_autopop VARCHAR2(1);
231 g_sa_autopop VARCHAR2(1);
232 g_orig_pointer NUMBER(15);
233 g_pateo_end_date DATE;
234 g_employee_hours VARCHAR2(1);
235 g_uom VARCHAR2(1);
236 g_exchange_rate_type VARCHAR2(30);
237
238 /******************************************
239 t_num_15_type : Used for declaring array of numbers with width 15. It covers the columns with length 9, 10 and 15.
240 t_num_10d2_type : Used for declaring array of numbers with width (10,2).
241 t_varchar_50_type : Used for declaring array of varchar2 with width 50. It covers the columns with length 1, 2, 30 and 50.
242 t_date_type : Used for declaring array of dates
243 *******************************************/
244 TYPE t_num_15_type IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
245 TYPE t_varchar_50_type IS TABLE OF VARCHAR2(50) INDEX BY BINARY_INTEGER;
246 TYPE t_varchar_150_type IS TABLE OF VARCHAR2(150) INDEX BY BINARY_INTEGER; -- Introduced for bug fix 2908859
247 TYPE t_num_10d2_type IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
248 -- Changed datatype to Number from number(15,2)of variable t_num_10d2_type for bug 2916848 Ilo Mrc Ehnc
249 TYPE t_date_type IS TABLE OF DATE INDEX BY BINARY_INTEGER;
250 TYPE t_num_15d2_type IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
251 -- Changed datatype to Number from number(15,2)of variable t_num_15d2_type for bug 2916848 Ilo Mrc Ehnc.
252
253 TYPE enc_period_rectype IS RECORD
254 (
255 r_period_ind t_num_15_type, -- period indicator used for fetching asg chunk start and end date
256 r_period_start_date t_date_type,
257 r_period_end_date t_date_type,
258 r_asg_start_date t_date_type,
259 r_asg_end_date t_date_type,
260 r_effective_date t_date_type,
261 r_time_period_id t_num_15_type,
262 r_process_flag t_varchar_50_type, -- Introduced for bug fix 3462452
263 -- Introduced the following for bug fix 3488734
264 r_schedule_percent t_num_15d2_type, -- balance percent to be posted for this asg chunk
265 r_encumbrance_amount t_num_15d2_type, -- encumbrance amount for that assignment chunk
266 r_period_amount t_num_15d2_type, -- encumbrance amount for that payroll period
267 r_reason_code t_varchar_50_type);
268
269 r_enc_period enc_period_rectype;
270
271 TYPE r_orig_ci IS RECORD
272 (gl_code_combination_id t_num_15_type,
273 project_id t_num_15_type,
274 task_id t_num_15_type,
275 award_id t_num_15_type,
276 expenditure_organization_id t_num_15_type,
277 expenditure_type t_varchar_50_type);
278
279 orig_ci r_orig_ci;
280
281 TYPE enc_lines_rec_col IS RECORD
282 (
283 R_ENC_ELEMENT_TYPE_ID t_num_15_type,
284 R_ENCUMBRANCE_DATE t_date_type,
285 R_DR_CR_FLAG t_varchar_50_type,
286 R_ENCUMBRANCE_AMOUNT t_num_10d2_type,
287 R_ENC_LINE_TYPE t_varchar_50_type,
288 R_SCHEDULE_LINE_ID t_num_15_type,
289 R_ORG_SCHEDULE_ID t_num_15_type,
290 R_DEFAULT_ORG_ACCOUNT_ID t_num_15_type,
291 R_SUSPENSE_ORG_ACCOUNT_ID t_num_15_type,
292 R_ELEMENT_ACCOUNT_ID t_num_15_type,
293 R_GL_PROJECT_FLAG t_varchar_50_type,
294 R_PERSON_ID t_num_15_type,
295 R_ASSIGNMENT_ID t_num_15_type,
296 R_AWARD_ID t_num_15_type,
297 R_TASK_ID t_num_15_type,
298 R_EXPENDITURE_TYPE t_varchar_50_type,
299 R_EXPENDITURE_ORGANIZATION_ID t_num_15_type,
300 R_PROJECT_ID t_num_15_type,
301 R_GL_CODE_COMBINATION_ID t_num_15_type,
302 R_TIME_PERIOD_ID t_num_15_type,
303 R_DEFAULT_REASON_CODE t_varchar_50_type,
304 R_SUSPENSE_REASON_CODE t_varchar_50_type,
305 R_ENC_CONTROL_ID t_num_15_type,
306 R_CHANGE_FLAG t_varchar_50_type,
307 R_ENC_START_DATE t_date_type,
308 R_ENC_END_DATE t_date_type,
309 r_attribute_category t_varchar_50_type, -- Introduced DFF variables for bug fix 2908859
310 r_attribute1 t_varchar_150_type,
311 r_attribute2 t_varchar_150_type,
312 r_attribute3 t_varchar_150_type,
313 r_attribute4 t_varchar_150_type,
314 r_attribute5 t_varchar_150_type,
315 r_attribute6 t_varchar_150_type,
316 r_attribute7 t_varchar_150_type,
317 r_attribute8 t_varchar_150_type,
318 r_attribute9 t_varchar_150_type,
319 r_attribute10 t_varchar_150_type,
320 r_ORIG_GL_CODE_COMBINATION_ID t_num_15_type,
321 r_ORIG_PROJECT_ID t_num_15_type,
322 r_ORIG_AWARD_ID t_num_15_type,
323 r_ORIG_TASK_ID t_num_15_type,
324 r_ORIG_EXPENDITURE_TYPE t_varchar_50_type,
325 r_ORIG_EXPENDITURE_ORG_ID t_num_15_type,
326 r_hierarchy_code t_varchar_50_type,
327 r_hierarchy_start_date t_date_type,
328 r_hierarchy_end_date t_date_type
329 );
330 t_enc_lines_array enc_lines_rec_col;
331 t_enc_lines_array2 enc_lines_rec_col;
332
333 ----For Enh Bug 2259310 Enc Control tab has been converted from array of records to Records of array for using
334 ----bulk binding features of Oracle 8i.
335
336 TYPE ENC_CONTROL_RECTYPE IS RECORD (
337 R_TIME_PERIOD_ID t_num_15_type,
338 R_ENC_CONTROL_ID t_num_15_type,
339 R_NO_OF_DR t_num_15_type,
340 R_NO_OF_CR t_num_15_type,
341 R_TOTAL_DR_AMOUNT t_num_15d2_type,
342 R_TOTAL_CR_AMOUNT t_num_15d2_type,
343 R_GL_DR_AMOUNT t_num_15d2_type,
344 R_GL_CR_AMOUNT t_num_15d2_type,
345 R_OGM_DR_AMOUNT t_num_15d2_type,
346 R_OGM_CR_AMOUNT t_num_15d2_type,
347 R_UOM t_varchar_50_type);
348
349 ENC_CONTROL_TAB ENC_CONTROL_RECTYPE;
350
351 TYPE r_schedule_line_type IS RECORD
352 (line_account_id t_num_15_type,
353 gl_code_combination_id t_num_15_type,
354 project_id t_num_15_type,
355 task_id t_num_15_type,
356 award_id t_num_15_type,
357 expenditure_type t_varchar_150_type,
358 expenditure_organization_id t_num_15_type,
359 start_date_active t_date_type,
360 end_date_active t_date_type,
361 poeta_start_date t_date_type,
362 poeta_end_date t_date_type,
363 percent t_num_10d2_type,
364 attribute_category t_varchar_150_type,
365 attribute1 t_varchar_150_type,
366 attribute2 t_varchar_150_type,
367 attribute3 t_varchar_150_type,
368 attribute4 t_varchar_150_type,
369 attribute5 t_varchar_150_type,
370 attribute6 t_varchar_150_type,
371 attribute7 t_varchar_150_type,
372 attribute8 t_varchar_150_type,
373 attribute9 t_varchar_150_type,
374 attribute10 t_varchar_150_type,
375 acct_type t_varchar_150_type);
376 r_gee r_schedule_line_type;
377 r_et r_schedule_line_type;
378 r_ec r_schedule_line_type;
379 r_asg r_schedule_line_type;
380 r_odls r_schedule_line_type;
381 r_da r_schedule_line_type;
382 r_sa r_schedule_line_type;
383
384 TYPE r_warning_rec IS RECORD
385 (start_date t_date_type,
386 end_date t_date_type,
387 hierarchy_code t_varchar_50_type,
388 warning_code t_varchar_150_type,
389 gl_ccid t_num_15_type,
390 project_id t_num_15_type,
391 task_id t_num_15_type,
392 award_id t_num_15_type,
393 exp_org_id t_num_15_type,
394 exp_type t_varchar_150_type,
395 effective_date t_date_type,
396 error_status t_varchar_150_type,
397 percent t_num_10d2_type);
398 cel_warnings r_warning_rec;
399
400 /* Following variables are added for bug 2374680 */
401 g_assignment_number VARCHAR2(30);
402 g_employee_number VARCHAR2(30);
403
404 /* Following procedure is added for bug 2374680. */
405 PROCEDURE Get_assign_number
406 (p_assignment_id IN NUMBER,
407 p_effective_date IN DATE,
408 p_assignment_number OUT NOCOPY VARCHAR2,
409 p_employee_number OUT NOCOPY VARCHAR2 ) IS
410
411 CURSOR assign_num_cur IS
412 SELECT paf.assignment_number,
413 ppf.employee_number
414 FROM
415 per_assignments_f paf,per_people_f ppf
416 WHERE paf.assignment_id =p_assignment_id
417 AND paf.person_id =ppf.person_id
418 AND p_effective_date between paf.effective_start_date and paf.effective_end_date
419 AND p_effective_date between ppf.effective_start_date and ppf.effective_end_date;
420
421 BEGIN
422 OPEN assign_num_cur;
423 FETCH assign_num_cur INTO p_assignment_number,p_employee_number;
424 CLOSE assign_num_cur;
425
426 END get_assign_number;
427
428 ---------------------- O B T A I N ENC ORG E N D D A T E -----------------------
429
430 Procedure obtain_enc_org_end_date( p_enc_org_end_date OUT NOCOPY DATE,
431 p_business_group_id IN NUMBER,
432 p_set_of_books_id IN NUMBER,
433 p_return_status OUT NOCOPY VARCHAR2) IS
434 /*****************************************************************************
435 This procedure calculates the 100% time period end date by finding the end date. It
436 picks the latest date from the table.
437 The end-date is returned through the OUT variable.
438 --Added new column peed.enc_end_date_id for Enhancement ENC redesign
439 --For Bug 2259310 : Changed the name of the procedure and variables and an update statement has been added
440 As part of the same enhancement the form has been changed. There is no longer organization for which the end date
441 is obtained.
442 ******************************************************************************/
443
444 CURSOR time_pct_def_cur
445 IS
446 SELECT peed.period_end_date,
447 peed.enc_end_date_id,
448 NVL(peed.prev_enc_end_date, fnd_date.canonical_to_date('4712/12/31')) prev_enc_end_date
449 FROM psp_enc_end_dates peed
450 WHERE
451 --- removed sysdate check for Bug fix 2597666
452 peed.business_group_id = p_business_group_id
453 AND peed.set_of_books_id = p_set_of_books_id
454 AND peed.default_org_flag = 'Y';
455
456 l_count NUMBER :=0;
457 --For Enhancement Enc Redesign :Bug 2259310 Added the following variable and cursors
458 l_enc_end_date_id NUMBER;
459 l_prev_enc_end_date DATE;
460
461 CURSOR c_cnt_default_org
462 IS
463 SELECT COUNT(1)
464 FROM psp_enc_end_dates peed
465 WHERE
466 -- removed sysdate check for Bug Fix 2597666
467 peed.business_group_id = p_business_group_id
468 AND peed.set_of_books_id = p_set_of_books_id
469 AND peed.default_org_flag= 'Y';
470
471
472 Begin
473 p_enc_org_end_date := NULL;
474 -- check for Generic Encumbrance Period
475
476 p_return_status := fnd_api.g_ret_sts_success;
477
478 -- moved the select to Cursor
479 OPEN c_cnt_default_org;
480 FETCH c_cnt_default_org INTO l_count;
481 CLOSE c_cnt_default_org;
482
483 IF l_count = 0 THEN
484 fnd_message.set_name('PSP', 'PSP_ENC_GEN_PERIOD_NOT_FOUND');
485 fnd_msg_pub.add;
486 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
487 END IF;
488
489 OPEN time_pct_def_cur;
490 FETCH time_pct_def_cur INTO p_enc_org_end_date, l_enc_end_date_id, l_prev_enc_end_date;
491 IF ( time_pct_def_cur%ROWCOUNT> 1) THEN
492 p_enc_org_end_date := NULL;
493 fnd_message.set_name('PSP', 'PSP_ENC_MUL_END_DATES');
494 fnd_msg_pub.add;
495 g_error_message := fnd_message.get;
496 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
497 END IF;
498 CLOSE time_pct_def_cur;
499
500 --For Enhancement Enc Redesign:Bug 2259310 : Updating the Organization End date
501 IF (l_prev_enc_end_date <> p_enc_org_end_date) THEN
502 UPDATE psp_enc_end_dates peed
503 SET peed.prev_enc_end_date = p_enc_org_end_date
504 WHERE peed.enc_end_date_id = l_enc_end_date_id;
505 END IF;
506 Exception
507
508 WHEN OTHERS THEN
509 IF (g_error_message IS NULL) THEN
510 g_error_message := 'OBTAIN_ENC_ORG_END_DATE: ' || SQLERRM;
511 END IF;
512 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'OBTAIN_ENC_ORG_END_DATE');
513 p_return_status := fnd_api.g_ret_sts_unexp_error;
514 return;
515 End obtain_enc_org_end_date;
516
517 ---------------------- O B T A I N E N C P O E T A E N D D A T E -----------------------
518 -- Enhancement Enc Redesign : Renamed Obtain_enc_period_extn to Obtain_enc_peota_end_date
519 -- For Enhancement Enc Redesign :Bug 2259310 : The procedure determines the Encumbrance end date
520 -- when the CI is POETA, i.e the date
521 -- till which the POETA shall be encumbered. It is called from the Hierarchies.
522
523 Procedure obtain_enc_poeta_end_date ( p_ls_start_date IN DATE,
524 p_ls_end_date IN DATE,
525 p_poeta_end_date IN DATE,
526 p_enc_end_date OUT NOCOPY DATE, --Is used for Enc End date
527 p_return_status OUT NOCOPY VARCHAR2
528 )
529 IS
530 l_enc_end_date DATE DEFAULT g_enc_org_end_date;
531 BEGIN
532
533 /* Enc End date Changes*/
534 IF p_ls_start_date <= g_enc_org_end_date THEN
535 IF p_ls_end_date <= g_enc_org_end_date THEN
536 l_enc_end_date:= g_enc_org_end_date;
537 ELSE
538 IF p_ls_end_date < p_poeta_end_date THEN
539 l_enc_end_date := p_ls_end_date;
540 ELSIF p_ls_end_date >= p_poeta_end_date AND p_poeta_end_date > g_enc_org_end_date THEN
541 l_enc_end_date:= p_poeta_end_date;
542 END IF;
543 END IF;
544 ELSE
545 l_enc_end_date := NULL;
546 END IF;
547 --Assigning values to the out parameters
548 p_enc_end_date := LEAST(l_enc_end_date, NVL(g_actual_term_date, l_enc_end_date));
549 p_return_status := fnd_api.g_ret_sts_success;
550
551 EXCEPTION
552 WHEN OTHERS THEN
553 IF (g_error_message IS NULL) THEN
554 g_error_message := 'OBTAIN_ENC_POETA_END_DATE: ' || SQLERRM;
555 END IF;
556 g_error_api_path := SUBSTR(' OBTAIN_ENC_POETA_END_DATE:'||g_error_api_path,1,230);
557 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', ' OBTAIN_ENC_POETA_END_DATE ');
558 p_return_status := fnd_api.g_ret_sts_unexp_error;
559 END obtain_enc_poeta_end_date;
560
561
562
563
564 ---------------------- D E T E R M I N E E N C A M O U N T -----------------------
565 /***********************************************************************************************
566 This procedures calculates the Encumbrance Amount for a particular assignment
567 and Earnings Element. The parameters accepted are the Assignment ID and the
568 Element_Type_ID and active assignment chunks dates
569 that are to be used for calculating the encumbrance amount.
570 The function does the following:
571 -- Checks if the Element_Type_ID refers to the REGULAR SALARY seeded element.
572 -- If it does, then obtain the amount from the Salary Administration (in Oracle Apps)
573 window. If there is no amount specified in the salary administration window, then
574 proceed to next step. If there is an amount, then it pro-rates the amount to
575 the window period of the active assignment chunk dates.
576 -- If the earnings element is not REGULAR SALARY, then call the userhook. Whatever
577 amount is returned by userhook is considered as the pro-rated amount for the
578 assignment dates.
579 --IF no amount is returned by the userhook then go to the Element
580 entries window (in Oracle Apps). Obtain the amount specified against
581 the earnings element and then it pro-rates the amount to
582 the window period of the active assignment chunk dates.
583
584 Logic for Regular Salary element:
585 -- First, I will check if the element has a value in the PER_PAY_PROPOSALS.
586 -- If it does, then I will return the encumbrance amount on a per payroll period basis.
587 -- If the amount has not been defined, then I will look into the PAY_PAYWSMEE_ELEMENT_ENTRIES
588 -- table to obtain the amount.
589
590 -- Obtain the number of pay periods in a fiscal year. This will then be used to divide the
591 -- annual salary to arrive at the salary per pay period.
592
593 -- Salary information present and the number of periods per fiscal year is greater than zero.
594 -- Hence, calculate the amount per pay period.
595 -- When the proposed salary is an hourly wage. Multiply this by 8 hours a day, 5 days a week, and 48 weeks in a year
596 --For Enhancement Enc Redesign, Bug 2259310, Prorating the Amount
597 ********************************************************************************************************/
598
599 -- Implemented the following logic for determine_enc_amount procedure as part of bug fix 3488734
600 PROCEDURE determine_enc_amount (p_person_id IN NUMBER,
601 p_assignment_id IN NUMBER,
602 p_element_type_id IN NUMBER,
603 p_payroll_id IN NUMBER,
604 p_business_group_id IN NUMBER,
605 p_set_of_books_id IN NUMBER,
606 p_return_status OUT NOCOPY VARCHAR2) IS
607
608 TYPE salary_proposal_rectype IS RECORD
609 (r_change_date t_date_type,
610 r_proposed_salary t_num_15d2_type,
611 r_pay_basis t_varchar_50_type,
612 r_pay_annualization_factor t_num_15_type,
613 r_effective_start_date t_date_type,
614 r_effective_end_date t_date_type);
615
616 r_salary_proposal salary_proposal_rectype;
617
618 TYPE element_entry_rectype IS RECORD
619 (r_element_start_date t_date_type,
620 r_element_end_date t_date_type,
621 r_pay_amount t_num_15d2_type);
622
623 r_element_entry element_entry_rectype;
624
625 l_min_start_date DATE DEFAULT r_enc_period.r_asg_start_date(1);
626 l_max_end_date DATE DEFAULT r_enc_period.r_asg_end_date(r_enc_period.r_asg_end_date.COUNT);
627
628 -- Introduced the following for bug fix 3673723
629 TYPE element_period_amount IS RECORD
630 (r_time_period_id t_num_15_type,
631 r_period_amount t_num_15d2_type);
632
633 r_element_period_amount element_period_amount;
634
635 CURSOR element_period_amount_cur IS
636 SELECT time_period_id,
637 SUM(period_amount)
638 FROM (SELECT ((MAX(fnd_number.canonical_to_number(NVL(peev.screen_entry_value, 0))) *
639 SUM(psp_general.business_days( GREATEST(ptp.start_date, paf.effective_start_date, peev.effective_start_date),
640 LEAST(ptp.end_date, paf.effective_end_date, peev.effective_end_date),p_assignment_id)) ) /
641 DECODE(psp_general.business_days(MAX(ptp.start_date), MAX(ptp.end_date),p_assignment_id), 0, 1,
642 psp_general.business_days(MAX(ptp.start_date), MAX(ptp.end_date),p_assignment_id)) ) period_amount,
643 ptp.time_period_id
644 FROM pay_element_entry_values_f peev,
645 pay_input_values_f piv,
646 pay_element_entries_f pee,
647 pay_element_links_f pel,
648 pay_element_types_f pet,
649 psp_enc_elements peel,
650 per_assignments_f paf,
651 per_assignment_status_types past,
652 per_time_periods ptp
653 WHERE peev.element_entry_id = pee.element_entry_id
654 AND peev.effective_start_date <= paf.effective_end_date
655 AND peev.effective_end_date >= paf.effective_start_date
656 AND pel.element_link_id = pee.element_link_id
657 AND pel.element_type_id = p_element_type_id
658 AND pel.effective_start_date <= paf.effective_end_date
659 AND pel.effective_end_date >= paf.effective_start_date
660 AND pet.effective_start_date <= paf.effective_end_date
661 AND pet.effective_end_date >= paf.effective_start_date
662 AND pee.assignment_id = p_assignment_id
663 AND pee.effective_start_date <= paf.effective_end_date
664 AND pee.effective_end_date >= paf.effective_start_date
665 AND peev.input_value_id = piv.input_value_id
666 AND piv.input_value_id = peel.input_value_id
667 AND pet.element_type_id = p_element_type_id
668 AND piv.effective_start_date <= paf.effective_end_date
669 AND piv.effective_end_date >= paf.effective_start_date
670 AND piv.effective_start_date <= peev.effective_end_date
671 AND piv.effective_end_date >= peev.effective_start_date
672 AND pee.effective_start_date <= peev.effective_end_date
673 AND pee.effective_end_date >= peev.effective_start_date
674 AND ptp.start_date <= paf.effective_end_date
675 AND ptp.end_date >= paf.effective_start_date
676 AND pel.effective_start_date <= pee.effective_end_date
677 AND pel.effective_end_date >= pee.effective_start_date
678 AND pet.effective_start_date <= pel.effective_end_date
679 AND pet.effective_end_date >= pel.effective_start_date
680 AND paf.assignment_id = p_assignment_id
681 AND paf.effective_start_date <= l_max_end_date
682 AND paf.effective_end_date >= l_min_start_date
683 AND past.assignment_status_type_id = paf.assignment_status_type_id
684 AND past.per_system_status = 'ACTIVE_ASSIGN'
685 AND pel.business_group_id = p_business_group_id
686 AND peel.business_group_id = p_business_group_id
687 AND peel.set_of_books_id = p_set_of_books_id
688 AND ptp.payroll_id = p_payroll_id
689 AND ptp.time_period_id >= r_enc_period.r_time_period_id(1)
690 AND SUBSTR(piv.uom, 1, 1) = g_uom
691 GROUP BY ptp.time_period_id,
692 peev.effective_start_date,
693 peev.effective_end_date)
694 GROUP BY time_period_id;
695 -- End of changes for bug fix 3673723
696
697 CURSOR get_proposal_salary_csr IS
698 SELECT ppp.change_date,
699 ppp.proposed_salary_n proposed_salary,
700 NVL(ppb.pay_basis, ' ') pay_basis,
701 ppb.pay_annualization_factor,
702 paf.effective_start_date,
703 paf.effective_end_date
704 FROM per_pay_proposals ppp,
705 pay_input_values_f piv,
706 per_pay_bases ppb,
707 per_all_assignments_f paf,
708 per_assignment_status_types past
709 WHERE paf.assignment_id =p_assignment_id
710 AND ( ppp.change_date BETWEEN paf.effective_start_date AND paf.effective_end_date
711 OR ppp.change_date = (SELECT MAX(ppp1.change_date)
712 FROM per_pay_proposals ppp1
713 WHERE ppp1.assignment_id = p_assignment_id
714 AND ppp1.approved = 'Y'
715 AND ppp1.change_date <= paf.effective_start_date))
716 AND paf.pay_basis_id = ppb.pay_basis_id
717 AND ppp.assignment_id = p_assignment_id
718 AND past.assignment_status_type_id = paf.assignment_status_type_id
719 AND past.per_system_status = 'ACTIVE_ASSIGN'
720 AND piv.element_type_id +0 = p_element_type_id
721 AND ppp.approved = 'Y'
722 AND ((ppp.change_date >= (SELECT NVL(MAX(ppp1.change_date), l_min_start_date)
723 FROM per_pay_proposals ppp1
724 WHERE ppp1.assignment_id = p_assignment_id
725 AND ppp1.approved = 'Y'
726 AND ppp1.change_date <= l_min_start_date))
727 AND (ppp.change_date <= (SELECT NVL(MIN(ppp1.change_date), l_max_end_date + 1)
728 FROM per_pay_proposals ppp1
729 WHERE ppp1.assignment_id = p_assignment_id
730 AND ppp1.approved = 'Y'
731 AND ppp1.change_date >= l_max_end_date)))
732 AND ppb.input_value_id = piv.input_value_id
733 AND ppp.change_date BETWEEN piv.effective_start_date AND piv.effective_end_date
734 ORDER BY paf.effective_end_date DESC, ppp.change_date DESC;
735
736 CURSOR get_no_per_fiscal_year_csr IS
737 SELECT number_per_fiscal_year
738 FROM per_time_period_types ptpt
739 WHERE period_type = (SELECT ppf.period_type
740 FROM pay_payrolls_f ppf
741 WHERE ppf.payroll_id = p_payroll_id
742 /* Added for Bug 3869766 */
743 AND rownum = 1);
744
745 CURSOR get_element_entry IS
746 SELECT DISTINCT GREATEST(paf.effective_start_date, peev.effective_start_date) element_start_date,
747 LEAST(paf.effective_end_date, peev.effective_end_date) element_end_date,
748 fnd_number.canonical_to_number(NVL(peev.screen_entry_value, 0)) pay_amount
749 FROM pay_element_entry_values_f peev,
750 pay_input_values_f piv,
751 pay_element_entries_f pee,
752 pay_element_links_f pel,
753 pay_element_types_f pet,
754 psp_enc_elements peel,
755 per_assignments_f paf,
756 per_assignment_status_types past
757 WHERE peev.element_entry_id = pee.element_entry_id
758 AND peev.effective_start_date <= paf.effective_end_date
759 AND peev.effective_end_date >= paf.effective_start_date
760 AND pel.element_link_id = pee.element_link_id
761 AND pel.element_type_id = p_element_type_id
762 AND pel.effective_start_date <= paf.effective_end_date
763 AND pel.effective_end_date >= paf.effective_start_date
764 AND pet.effective_start_date <= paf.effective_end_date
765 AND pet.effective_end_date >= paf.effective_start_date
766 AND pee.assignment_id = p_assignment_id
767 AND pee.effective_start_date <= paf.effective_end_date
768 AND pee.effective_end_date >= paf.effective_start_date
769 AND peev.input_value_id = piv.input_value_id
770 AND piv.input_value_id = peel.input_value_id
771 AND pet.element_type_id = p_element_type_id
772 AND piv.effective_start_date <= paf.effective_end_date
773 AND piv.effective_end_date >= paf.effective_start_date
774 AND piv.effective_start_date <= peev.effective_end_date
775 AND piv.effective_end_date >= peev.effective_start_date
776 AND pee.effective_start_date <= peev.effective_end_date
777 AND pee.effective_end_date >= peev.effective_start_date
778 AND pel.effective_start_date <= pee.effective_end_date
779 AND pel.effective_end_date >= pee.effective_start_date
780 AND pet.effective_start_date <= pel.effective_end_date
781 AND pet.effective_end_date >= pel.effective_start_date
782 AND paf.assignment_id = p_assignment_id
783 AND paf.effective_start_date <= l_max_end_date
784 AND paf.effective_end_date >= l_min_start_date
785 AND past.assignment_status_type_id = paf.assignment_status_type_id
786 AND past.per_system_status = 'ACTIVE_ASSIGN'
787 AND SUBSTR(piv.uom, 1, 1) = g_uom
788 AND pel.business_group_id = p_business_group_id
789 AND peel.business_group_id = p_business_group_id
790 AND peel.set_of_books_id = p_set_of_books_id ;
791
792 CURSOR get_input_formula_cur IS
793 SELECT NVL(input_value_id, -1),
794 formula_id
795 FROM psp_enc_elements pee
796 WHERE element_type_id = p_element_type_id
797 AND ( formula_id IS NOT NULL
798 OR EXISTS (SELECT 1
799 FROM pay_input_values_f piv
800 WHERE piv.input_value_id = pee.input_value_id
801 AND SUBSTR(piv.uom, 1, 1) = g_uom));
802
803 l_num_per_fiscal_year NUMBER;
804 l_time_period_id NUMBER;
805 l_enc_amount NUMBER;
806 l_pay_amount NUMBER;
807 l_period_enc_amount NUMBER;
808 l_element_start_date DATE;
809 l_element_end_date DATE;
810 l_start_date DATE;
811 l_end_date DATE;
812 l_period_start_date DATE;
813 l_period_end_date DATE;
814 l_asg_start_date DATE;
815 l_asg_end_date DATE;
816 l_bus_working_days NUMBER DEFAULT 0;
817 l_bus_days_in_sched NUMBER DEFAULT 0;
818 l_temp_salary NUMBER DEFAULT 0;
819 l_change_date DATE;
820 l_inputs ff_exec.inputs_t;
821 l_outputs ff_exec.outputs_t;
822 l_input_value_id NUMBER(15);
823 l_formula_id NUMBER(15);
824
825 -- Introduced for bug fix 3551561
826 l_change_end_date DATE DEFAULT fnd_date.canonical_to_date('4712/12/31');
827 l_prev_change_end_date DATE;
828 l_prev_change_date DATE;
829 -- End of bug fix 3551561
830 l_annualization_factor NUMBER;
831 l_pay_basis VARCHAR2(30);
832 l_prev_time_period_id NUMBER DEFAULT -1;
833 l_period_counter NUMBER; -- Introduced for bug fix 3673723
834 l_tmp_counter NUMBER;
835 l_calculate_period_amt BOOLEAN;
836 l_effective_date DATE;
837
838 DIVIDE_BY_ZERO EXCEPTION;
839
840 l_proc_name VARCHAR2(61) DEFAULT g_package_name || 'DETERMINE_ENC_AMOUNT';
841 l_proc_step NUMBER(20, 10);
842
843 t_ff_start_date t_date_type;
844 t_ff_end_date t_date_type;
845
846 CURSOR formula_date_cur IS
847 SELECT GREATEST(pee.effective_start_date, paf.effective_start_date, ff.effective_start_date) start_date,
848 LEAST(pee.effective_end_date, paf.effective_end_date, ff.effective_end_date) end_date
849 FROM ff_formulas_f ff,
850 per_assignments_f paf,
851 pay_element_entries_f pee
852 WHERE formula_id = l_formula_id
853 AND paf.assignment_id = p_assignment_id
854 AND pee.assignment_id = p_assignment_id
855 AND pee.element_type_id = p_element_type_id
856 AND paf.effective_start_date <= l_max_end_date
857 AND paf.effective_end_date >= l_min_start_date
858 AND pee.effective_start_date <= l_max_end_date
859 AND pee.effective_end_date >= l_min_start_date
860 AND ff.effective_start_date <= l_max_end_date
861 AND ff.effective_end_date >= l_min_start_date
862 AND paf.effective_start_date <= pee.effective_end_date
863 AND paf.effective_end_date >= pee.effective_start_date
864 AND paf.effective_start_date <= ff.effective_end_date
865 AND paf.effective_end_date >= ff.effective_start_date
866 AND pee.effective_start_date <= ff.effective_end_date
867 AND pee.effective_end_date >= ff.effective_start_date;
868
869 BEGIN
870 l_proc_step:= 10;
871 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering ' || l_proc_name);
872 hr_utility.trace('p_assignment_id: ' || fnd_number.number_to_canonical(p_assignment_id) ||
873 ' p_element_type_id: ' || fnd_number.number_to_canonical(p_element_type_id) ||
874 ' p_payroll_id: ' || fnd_number.number_to_canonical(p_payroll_id) ||
875 ' p_business_group_id: ' || fnd_number.number_to_canonical(p_business_group_id) ||
876 ' p_set_of_books_id: ' || fnd_number.number_to_canonical(p_set_of_books_id) ||
877 ' l_bus_working_days: ' || fnd_number.number_to_canonical(l_bus_working_days) ||
878 ' r_enc_period.r_time_period_id.COUNT: ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id.COUNT));
879
880 IF (r_enc_period.r_time_period_id.COUNT = 0) THEN
881 RETURN;
882 END IF;
883
884 l_proc_step:= 20;
885 l_calculate_period_amt := TRUE;
886
887 OPEN get_input_formula_cur;
888 FETCH get_input_formula_cur INTO l_input_value_id, l_formula_id;
889 CLOSE get_input_formula_cur;
890
891 IF (l_formula_id IS NOT NULL) THEN
892 OPEN formula_date_cur;
893 FETCH formula_date_cur BULK COLLECT INTO t_ff_start_date, t_ff_end_date;
894 CLOSE formula_date_cur;
895
896 hr_utility.trace('t_ff_start_date.COUNT: ' || t_ff_start_date.COUNT);
897 END IF;
898
899 OPEN get_no_per_fiscal_year_csr;
900 FETCH get_no_per_fiscal_year_csr INTO l_num_per_fiscal_year;
901 IF get_no_per_fiscal_year_csr%NOTFOUND THEN
902 l_num_per_fiscal_year := 0;
903 END IF;
904 CLOSE get_no_per_fiscal_year_csr;
905
906 l_proc_step:= 30;
907
908 OPEN get_proposal_salary_csr;
909 FETCH get_proposal_salary_csr BULK COLLECT INTO r_salary_proposal.r_change_date, r_salary_proposal.r_proposed_salary,
910 r_salary_proposal.r_pay_basis, r_salary_proposal.r_pay_annualization_factor,
911 r_salary_proposal.r_effective_start_date, r_salary_proposal.r_effective_end_date;
912 CLOSE get_proposal_salary_csr;
913
914 l_proc_step:= 40;
915
916 OPEN get_element_entry;
917 FETCH get_element_entry BULK COLLECT INTO r_element_entry.r_element_start_date, r_element_entry.r_element_end_date,
918 r_element_entry.r_pay_amount;
919 CLOSE get_element_entry;
920
921 l_proc_step:= 50;
922
923 hr_utility.trace('l_num_per_fiscal_year: ' || fnd_number.number_to_canonical(l_num_per_fiscal_year) ||
924 ' r_salary_proposal.r_change_date.COUNT: ' || fnd_number.number_to_canonical(r_salary_proposal.r_change_date.COUNT) ||
925 ' r_element_entry.r_element_start_date.COUNT: ' || fnd_number.number_to_canonical(r_element_entry.r_element_start_date.COUNT));
926 hr_utility.trace('Calculating Assignment Chunk Amounts...');
927
928 FOR I IN 1..r_enc_period.r_time_period_id.COUNT
929 LOOP
930 IF (r_enc_period.r_process_flag(I) <> 'I') THEN
931 l_period_start_date := r_enc_period.r_period_start_date(I);
932 l_period_end_date := r_enc_period.r_period_end_date(I);
933 l_asg_start_date := r_enc_period.r_asg_start_date(I);
934 l_asg_end_date := r_enc_period.r_asg_end_date(I);
935 l_end_date := l_asg_end_date;
936 l_bus_working_days := psp_general.business_days(l_period_start_date, l_period_end_date,p_assignment_id);
937 l_enc_amount := 0;
938 l_proc_step:= 60 + (I / 100000);
939
940 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
941 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
942 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
943 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
944 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
945 ' l_bus_working_days: ' || fnd_number.number_to_canonical(l_bus_working_days));
946
947 IF (l_bus_working_days = 0) THEN
948 fnd_message.set_name('PSP', 'PSP_ENC_ZERO_WORK_DAYS_PERIOD');
949 fnd_message.set_token('START_DATE', l_period_start_date);
950 fnd_message.set_token('END_DATE', l_period_end_date);
951 g_error_message := fnd_message.get;
952 RAISE DIVIDE_BY_ZERO;
953 END IF;
954
955 l_enc_amount := psp_st_ext.get_enc_amount (p_assignment_id => p_assignment_id,
956 p_element_type_id => p_element_type_id,
957 p_time_period_id => r_enc_period.r_time_period_id(I),
958 p_asg_start_date => l_asg_start_date,
959 p_asg_end_date => l_asg_end_date);
960 hr_utility.trace('l_enc_amount: ' || fnd_number.number_to_canonical(l_enc_amount));
961
962 IF (l_enc_amount = 0) THEN
963 IF (l_formula_id IS NOT NULL) THEN
964 IF ( (t_ff_start_date.COUNT > 0) AND
965 (l_asg_start_date <= t_ff_end_date(t_ff_end_date.COUNT)) AND
966 (l_asg_end_date >= t_ff_start_date(1))) THEN
967 FOR ff_recno IN 1..t_ff_start_date.COUNT
968 LOOP
969 l_asg_start_date := r_enc_period.r_asg_start_date(I);
970 l_asg_end_date := r_enc_period.r_asg_end_date(I);
971 hr_utility.trace('l_asg_start_date: ' || l_asg_start_date || ' l_asg_end_date: ' || l_asg_end_date || ' t_ff_start_date(ff_recno): ' || t_ff_start_date(ff_recno) || ' t_ff_end_date(ff_recno): ' || t_ff_end_date(ff_recno));
972 IF l_asg_start_date <= t_ff_end_date(ff_recno) AND
973 l_asg_end_date >= t_ff_start_date(ff_recno) THEN
974 l_asg_start_date := GREATEST(l_asg_start_date, t_ff_start_date(ff_recno));
975 l_asg_end_date := LEAST(l_asg_end_date, t_ff_end_date(ff_recno));
976 l_inputs.DELETE;
977 l_outputs.DELETE;
978
979 ff_exec.init_formula(l_formula_id, l_asg_start_date, l_inputs,l_outputs);
980 hr_utility.trace('Initiated Formula l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) || ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date));
981
982 hr_utility.trace('l_inputs.COUNT: ' || l_inputs.COUNT);
983 FOR recno IN 1..l_inputs.COUNT
984 LOOP
985 IF (l_inputs(recno).name ='PERSON_ID') THEN
986 l_inputs(recno).value := fnd_number.number_to_canonical(p_person_id);
987 hr_utility.trace('Assigned person_id');
988 ELSIF (l_inputs(recno).name ='ASSIGNMENT_ID') THEN
989 l_inputs(recno).value := fnd_number.number_to_canonical(p_assignment_id);
990 hr_utility.trace('Assigned assignment_id');
991 ELSIF l_inputs(recno).name='ELEMENT_TYPE_ID' THEN
992 l_inputs(recno).value := fnd_number.number_to_canonical(p_element_type_id);
993 hr_utility.trace('Assigned element_type_id');
994 ELSIF l_inputs(recno).name='PAYROLL_ID' THEN
995 l_inputs(recno).value := fnd_number.number_to_canonical(p_payroll_id);
996 hr_utility.trace('Assigned payroll_id');
997 ELSIF l_inputs(recno).name='TIME_PERIOD_ID' THEN
998 l_inputs(recno).value := fnd_number.number_to_canonical(r_enc_period.r_time_period_id(I));
999 hr_utility.trace('Assigned time_period_id');
1000 ELSIF l_inputs(recno).name='ASG_START_DATE' THEN
1001 l_inputs(recno).value := fnd_date.date_to_canonical(l_asg_start_date);
1002 hr_utility.trace('Assigned asg_start_date');
1003 ELSIF l_inputs(recno).name='ASG_END_DATE' THEN
1004 l_inputs(recno).value := fnd_date.date_to_canonical(l_asg_end_date);
1005 hr_utility.trace('Assigned asg_end_date');
1006 ELSIF l_inputs(recno).name='BUS_DAYS_IN_CHUNK' THEN
1007 l_inputs(recno).value := fnd_number.number_to_canonical(psp_general.business_days(l_asg_start_date, l_asg_end_date,p_assignment_id));
1008 hr_utility.trace('Assigned business days in chunk');
1009 ELSIF l_inputs(recno).name='PERIOD_START_DATE' THEN
1010 l_inputs(recno).value := fnd_date.date_to_canonical(l_period_start_date);
1011 hr_utility.trace('Assigned period_start_date');
1012 ELSIF l_inputs(recno).name='PERIOD_END_DATE' THEN
1013 l_inputs(recno).value := fnd_date.date_to_canonical(l_period_end_date);
1014 hr_utility.trace('Assigned period_end_date');
1015 ELSIF l_inputs(recno).name='BUS_DAYS_IN_PERIOD' THEN
1016 l_inputs(recno).value := fnd_number.number_to_canonical(psp_general.business_days(l_period_start_date, l_period_end_date,p_assignment_id));
1017 hr_utility.trace('Assigned business days in period');
1018 ELSIF l_inputs(recno).name='UOM' THEN
1019 l_inputs(recno).value := g_uom;
1020 hr_utility.trace('Assigned UOM');
1021
1022 END IF;
1023 END LOOP;
1024
1025 hr_utility.trace('Before executing fast formula');
1026 ff_exec.run_formula(l_inputs, l_outputs);
1027 l_enc_amount := l_enc_amount + fnd_number.canonical_to_number(l_outputs(1).value); -- Bug 7536024
1028 hr_utility.trace('After executing fast formula; l_enc_amount: ' || l_enc_amount);
1029 END IF;
1030 END LOOP;
1031 END IF;
1032 l_calculate_period_amt := FALSE;
1033 l_proc_step:= 90;
1034 ELSE
1035 IF (psp_general.business_days(l_asg_start_date, l_asg_end_date,p_assignment_id) > 0) THEN
1036 FOR J IN 1..r_salary_proposal.r_change_date.COUNT
1037 LOOP
1038 IF (l_asg_start_date <= r_salary_proposal.r_effective_end_date(J) AND
1039 l_asg_end_date >= r_salary_proposal.r_effective_start_date(J)) THEN
1040 l_change_date := r_salary_proposal.r_change_date(J);
1041 l_end_date := LEAST(l_end_date, l_asg_end_date);
1042 l_temp_salary := r_salary_proposal.r_proposed_salary(J);
1043 l_annualization_factor := r_salary_proposal.r_pay_annualization_factor(J);
1044 l_pay_basis := r_salary_proposal.r_pay_basis(J);
1045 l_proc_step:= 70 + (J / 100000);
1046
1047 hr_utility.trace('J: ' || fnd_number.number_to_canonical(J) ||
1048 ' l_change_date: ' || fnd_date.date_to_canonical(l_change_date) ||
1049 ' l_temp_salary: ' || fnd_number.number_to_canonical(l_temp_salary) ||
1050 ' l_annualization_factor: ' || fnd_number.number_to_canonical(l_annualization_factor) ||
1051 ' l_pay_basis: ' || l_pay_basis);
1052
1053 IF (l_change_date <= l_end_date) THEN
1054 IF (l_num_per_fiscal_year <> 0 AND (l_pay_basis IN ('ANNUAL','MONTHLY','HOURLY'))) THEN
1055 l_temp_salary := round((l_temp_salary * l_annualization_factor / l_num_per_fiscal_year), g_ext_precision);
1056 END IF;
1057
1058 l_start_date := GREATEST(l_change_date, l_asg_start_date);
1059 l_bus_days_in_sched := NVL(PSP_GENERAL.BUSINESS_DAYS(l_start_date, l_end_date,p_assignment_id), 0);
1060 l_enc_amount := l_enc_amount + ROUND(((l_temp_salary * l_bus_days_in_sched) / ( l_bus_working_days )), g_ext_precision);
1061
1062 hr_utility.trace('l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
1063 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
1064 ' l_bus_days_in_sched: ' || fnd_number.number_to_canonical(l_bus_days_in_sched) ||
1065 ' l_enc_amount: ' || fnd_number.number_to_canonical(l_enc_amount));
1066
1067 l_end_date := GREATEST(l_start_date, l_change_date) - 1;
1068
1069 EXIT WHEN l_change_date < l_asg_start_date;
1070 END IF;
1071 END IF;
1072 END LOOP;
1073
1074 l_proc_step:= 80;
1075
1076 IF l_enc_amount = 0 THEN
1077 FOR J IN 1..r_element_entry.r_element_start_date.COUNT
1078 LOOP
1079 l_element_start_date := r_element_entry.r_element_start_date(J);
1080 l_element_end_date := r_element_entry.r_element_end_date(J);
1081 l_pay_amount := r_element_entry.r_pay_amount(J);
1082 l_proc_step:= 100 + (J / 100000);
1083
1084 IF (l_element_end_date >= l_asg_start_date) AND (l_element_start_date <= l_asg_end_date) THEN
1085 l_start_date := GREATEST(l_asg_start_date, l_element_start_date);
1086 l_end_date := LEAST(l_asg_end_date, l_element_end_date);
1087 l_bus_days_in_sched := NVL(PSP_GENERAL.BUSINESS_DAYS(l_start_date, l_end_date,p_assignment_id), 0);
1088 l_enc_amount := l_enc_amount + ROUND(((l_pay_amount * l_bus_days_in_sched)/( l_bus_working_days )),g_ext_precision);
1089 END IF;
1090
1091 hr_utility.trace('l_element_start_date: ' || fnd_date.date_to_canonical(l_element_start_date) ||
1092 ' l_element_end_date: ' || fnd_date.date_to_canonical(l_element_end_date) ||
1093 ' l_pay_amount: ' || fnd_number.number_to_canonical(l_pay_amount) ||
1094 ' l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
1095 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
1096 ' l_bus_days_in_sched: ' || fnd_number.number_to_canonical(l_bus_days_in_sched) ||
1097 ' l_enc_amount: ' || fnd_number.number_to_canonical(l_enc_amount));
1098
1099 EXIT WHEN l_element_start_date > l_asg_end_date;
1100 END LOOP;
1101 END IF;
1102 ELSE
1103 l_enc_amount := 0;
1104 END IF;
1105 END IF;
1106 ELSE
1107 l_calculate_period_amt := FALSE;
1108 END IF;
1109 IF (r_enc_period.r_process_flag(I) IN ('DA', 'SA')) THEN
1110 r_enc_period.r_encumbrance_amount(I) := r_enc_period.r_encumbrance_amount(I) + ROUND(((l_enc_amount * r_enc_period.r_schedule_percent(I))/100), g_ext_precision);
1111 ELSE
1112 r_enc_period.r_encumbrance_amount(I) := r_enc_period.r_encumbrance_amount(I) + ROUND(l_enc_amount, g_ext_precision);
1113 END IF;
1114 ELSE
1115 r_enc_period.r_encumbrance_amount(I) := 0;
1116 END IF;
1117 END LOOP;
1118
1119 l_proc_step:= 110;
1120 hr_utility.trace('Calculating Period Amounts...');
1121
1122 IF (l_calculate_period_amt) THEN
1123 -- Modified period amount calculation for bug fix 3673723
1124 -- For element entry value based period amount calculation, changed to time period reference.
1125 -- Introduced the following for bug fix 3673723
1126 OPEN element_period_amount_cur;
1127 FETCH element_period_amount_cur BULK COLLECT INTO r_element_period_amount.r_time_period_id, r_element_period_amount.r_period_amount;
1128 CLOSE element_period_amount_cur;
1129 -- End of changes for bug fix 3673723
1130
1131 FOR I IN 1..r_enc_period.r_time_period_id.COUNT
1132 LOOP
1133 l_time_period_id := r_enc_period.r_time_period_id(I);
1134 l_proc_step:= 120 + (I / 100000);
1135
1136 IF (l_time_period_id <> l_prev_time_period_id) THEN
1137 l_period_start_date := r_enc_period.r_period_start_date(I);
1138 l_period_end_date := r_enc_period.r_period_end_date(I);
1139 l_change_end_date := l_period_end_date;
1140 l_enc_amount := 0;
1141 l_bus_working_days := psp_general.business_days(l_period_start_date, l_period_end_date,p_assignment_id);
1142 l_end_date := l_period_end_date;
1143 l_period_counter := 0;
1144
1145 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
1146 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
1147 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
1148 ' l_bus_working_days: ' || fnd_number.number_to_canonical(l_bus_working_days));
1149
1150 IF (l_bus_working_days > 0) THEN
1151 FOR J IN 1..r_salary_proposal.r_change_date.COUNT
1152 LOOP
1153 IF (J > l_period_counter) THEN -- Introduced for bug fix 3673723
1154 l_change_date := r_salary_proposal.r_change_date(J);
1155
1156 -- Introduced for bug fix 3551561
1157 IF (J > 1) THEN
1158 l_change_end_date := l_prev_change_date - 1;
1159 IF (l_change_end_date < l_change_date) THEN
1160 l_change_end_date := l_prev_change_end_date;
1161 END IF;
1162 END IF;
1163 -- End of changes for bug fix 3551561
1164
1165 l_end_date := LEAST(l_end_date, r_salary_proposal.r_effective_end_date(J), l_period_end_date);
1166 l_temp_salary := r_salary_proposal.r_proposed_salary(J);
1167 l_annualization_factor := r_salary_proposal.r_pay_annualization_factor(J);
1168 l_pay_basis := r_salary_proposal.r_pay_basis(J);
1169 l_proc_step:= 130 + (J / 100000);
1170
1171 hr_utility.trace('J: ' || fnd_number.number_to_canonical(J) ||
1172 ' l_change_date: ' || fnd_date.date_to_canonical(l_change_date) ||
1173 ' l_change_end_date: ' || fnd_date.date_to_canonical(l_change_end_date) ||
1174 ' l_temp_salary: ' || fnd_number.number_to_canonical(l_temp_salary) ||
1175 ' l_annualization_factor: ' || fnd_number.number_to_canonical(l_annualization_factor) ||
1176 ' l_pay_basis: ' || l_pay_basis);
1177
1178 -- IF (l_change_date <= l_end_date) THEN Commented for bug fix 3551561
1179 IF (l_change_end_date >= l_period_start_date) AND (l_change_date <= l_period_end_date) THEN
1180 IF (l_num_per_fiscal_year <> 0 AND (l_pay_basis IN ('ANNUAL','MONTHLY','HOURLY'))) THEN
1181 l_temp_salary := round((l_temp_salary * l_annualization_factor / l_num_per_fiscal_year), g_ext_precision);
1182 END IF;
1183
1184 /***** Commented for bug fix 3551561
1185 l_start_date := GREATEST(l_change_date, r_salary_proposal.r_effective_start_date(J), l_period_start_date);
1186 l_bus_days_in_sched := NVL(PSP_GENERAL.BUSINESS_DAYS(l_start_date, l_end_date), 0);
1187 l_enc_amount := l_enc_amount + ROUND(((l_temp_salary * l_bus_days_in_sched) / ( l_bus_working_days )), g_ext_precision);
1188 End of comment for bug fix 3551561 *****/
1189 -- Introduced for bug fix 3551561
1190
1191 l_bus_days_in_sched := 0;
1192 l_period_counter := J;
1193 LOOP -- Introduced for bug fix 3673723
1194 l_start_date := GREATEST(l_period_start_date,
1195 r_salary_proposal.r_effective_start_date(l_period_counter), l_change_date);
1196 l_end_date := LEAST(l_period_end_date,
1197 r_salary_proposal.r_effective_end_date(l_period_counter), l_change_end_date);
1198 l_bus_days_in_sched := l_bus_days_in_sched + NVL(psp_general.business_days(l_start_date, l_end_date,p_assignment_id), 0);
1199 EXIT WHEN l_period_counter = r_salary_proposal.r_change_date.COUNT;
1200 EXIT WHEN l_change_date <> r_salary_proposal.r_change_date(l_period_counter + 1);
1201 l_period_counter := l_period_counter + 1;
1202 END LOOP; -- Introduced for bug fix 3673723
1203
1204 l_enc_amount := l_enc_amount + ROUND(((l_temp_salary * l_bus_days_in_sched)/( l_bus_working_days )), g_ext_precision);
1205 -- End of changes for bug fix 3551561
1206 hr_utility.trace('l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
1207 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
1208 ' l_bus_days_in_sched: ' || fnd_number.number_to_canonical(l_bus_days_in_sched) ||
1209 ' l_enc_amount: ' || fnd_number.number_to_canonical(l_enc_amount));
1210 -- l_end_date := GREATEST(l_start_date, l_change_date) - 1; Commented for bug fix 3551561
1211 l_prev_change_end_date := l_change_end_date;
1212 END IF;
1213 l_prev_change_date := l_change_date;
1214 EXIT WHEN l_change_end_date < l_period_start_date; -- Modified to change_end_date for bug fix 3551561
1215 END IF; -- Introduced for bug fix 3673723 (J > l_period_counter condn.)
1216 END LOOP;
1217
1218 l_proc_step:= 150;
1219
1220 -- Introduced the following for bug fix 3673723
1221 IF (l_enc_amount = 0) THEN
1222 FOR J IN 1..r_element_period_amount.r_time_period_id.COUNT
1223 LOOP
1224 IF (r_element_period_amount.r_time_period_id (J) = l_time_period_id) THEN
1225 l_enc_amount := r_element_period_amount.r_period_amount(J);
1226 EXIT;
1227 END IF;
1228 END LOOP;
1229 END IF;
1230 -- End of changes for bug fix 3673723
1231
1232 r_enc_period.r_period_amount(I) := ROUND(l_enc_amount, g_ext_precision);
1233 ELSE
1234 r_enc_period.r_period_amount(I) := 0;
1235 END IF;
1236 l_prev_time_period_id := l_time_period_id;
1237 ELSE
1238 r_enc_period.r_period_amount(I) := r_enc_period.r_period_amount(I - 1);
1239 END IF;
1240 END LOOP;
1241 ELSE
1242 hr_utility.trace('Period amounts based on formula/user hook amounts');
1243 l_enc_amount := 0;
1244 l_period_counter := 1;
1245 l_tmp_counter := 1;
1246 LOOP
1247 EXIT WHEN l_tmp_counter > r_enc_period.r_time_period_id.COUNT;
1248 hr_utility.trace('l_tmp_counter: ' || l_tmp_counter || ' EM: ' || r_enc_period.r_encumbrance_amount(l_tmp_counter));
1249 IF (l_tmp_counter = 1) THEN
1250 l_time_period_id := r_enc_period.r_time_period_id(l_tmp_counter);
1251 END IF;
1252 IF (r_enc_period.r_time_period_id(l_tmp_counter) = l_time_period_id) THEN
1253 IF (r_enc_period.r_schedule_percent(l_tmp_counter) IN (0, 100)) THEN
1254 l_enc_amount := l_enc_amount + r_enc_period.r_encumbrance_amount(l_tmp_counter);
1255 END IF;
1256 ELSE
1257 r_element_period_amount.r_period_amount(l_period_counter) := l_enc_amount;
1258 r_element_period_amount.r_time_period_id(l_period_counter) := l_time_period_id;
1259 l_enc_amount := 0;
1260 IF (r_enc_period.r_schedule_percent(l_tmp_counter) IN (0, 100)) THEN
1261 l_enc_amount := r_enc_period.r_encumbrance_amount(l_tmp_counter);
1262 END IF;
1263 l_time_period_id := r_enc_period.r_time_period_id(l_tmp_counter);
1264 l_period_counter := l_period_counter + 1;
1265 END IF;
1266 IF (l_tmp_counter = r_enc_period.r_time_period_id.COUNT) THEN
1267 r_element_period_amount.r_period_amount(l_period_counter) := l_enc_amount;
1268 r_element_period_amount.r_time_period_id(l_period_counter) := l_time_period_id;
1269 END IF;
1270 l_tmp_counter := l_tmp_counter + 1;
1271 END LOOP;
1272 l_period_counter := 1;
1273 FOR J IN 1..r_enc_period.r_time_period_id.COUNT
1274 LOOP
1275 hr_utility.trace('l_period_counter: ' || l_period_counter);
1276 IF (r_enc_period.r_time_period_id(J) <> r_element_period_amount.r_time_period_id(l_period_counter)) THEN
1277 l_period_counter := l_period_counter + 1;
1278 END IF;
1279 r_enc_period.r_period_amount(J) := r_element_period_amount.r_period_amount(l_period_counter);
1280 END LOOP;
1281 END IF;
1282
1283 l_proc_step:= 170;
1284
1285 hr_utility.trace('Dumping Assignment Chunks after determining Assignment chunk and Period chunk amounts');
1286 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
1287 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
1288 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
1289 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
1290 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
1291 LPAD('Encumbrance Amount', 18, ' ') || ' ' || LPAD('Period Amount', 18, ' ') || ' ' ||
1292 RPAD('Reason Code', 50, ' '));
1293
1294 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
1295 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
1296 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
1297 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
1298 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
1299 LPAD('-', 18, '-') || ' ' || LPAD('-', 18, '-') || ' ' ||
1300 RPAD('-', 50, '-'));
1301
1302 FOR recno IN 1..r_enc_period.r_time_period_id.COUNT
1303 LOOP
1304 hr_utility.trace(LPAD(recno, 13, ' ') || ' ' ||
1305 LPAD(r_enc_period.r_time_period_id(recno), 14, ' ') || ' ' ||
1306 RPAD(TO_CHAR(r_enc_period.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
1307 RPAD(TO_CHAR(r_enc_period.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
1308 RPAD(TO_CHAR(r_enc_period.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
1309 RPAD(TO_CHAR(r_enc_period.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
1310 RPAD(TO_CHAR(r_enc_period.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
1311 RPAD(r_enc_period.r_process_flag(recno), 12, ' ') || ' ' ||
1312 LPAD(r_enc_period.r_schedule_percent(recno), 16, ' ') || ' ' ||
1313 LPAD(r_enc_period.r_encumbrance_amount(recno), 18, ' ') || ' ' ||
1314 LPAD(r_enc_period.r_period_amount(recno), 18, ' ') || ' ' ||
1315 RPAD(r_enc_period.r_reason_code(recno), 50, ' '));
1316 END LOOP;
1317 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving ' || l_proc_name);
1318
1319 p_return_status := fnd_api.g_ret_sts_success;
1320 EXCEPTION
1321 WHEN DIVIDE_BY_ZERO THEN
1322 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', ' DETERMINE_ENC_AMOUNT ');
1323 fnd_file.put_line(fnd_file.log, fnd_number.number_to_canonical(l_proc_step) || ': ' || l_proc_name);
1324 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving ' || l_proc_name);
1325 p_return_status := fnd_api.g_ret_sts_unexp_error;
1326 WHEN OTHERS THEN
1327 IF (g_error_message IS NULL) THEN
1328 g_error_message := l_proc_name || ': ' || SQLERRM;
1329 END IF;
1330 fnd_msg_pub.add_exc_msg('PSP', 'DETERMINE_ENC_AMOUNT');
1331 fnd_file.put_line(fnd_file.log, fnd_number.number_to_canonical(l_proc_step) || ': ' || l_proc_name);
1332 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving ' || l_proc_name);
1333 p_return_status := fnd_api.g_ret_sts_unexp_error;
1334 END determine_enc_amount;
1335 -- End of changes for bug fix 3488734
1336
1337 ---------------------- C R E A T E L I N E S -------------------------------------
1338
1339 /*************************************************************************
1340 This procedure accepts the Assignment ID, Last Payroll Run date, Max. Encumbrance Date, Earnings Amount,
1341 Element Type ID as input parameters. This procedure determines the different accounts that need to be
1342 charged and the amounts that need to be charged until a particular Date. The logic
1343 used to arrive at the charging instructions is derived from CREATE_DISTRIBUTION_LINES
1344 in Oracle Labor Distribution.
1345 Finally, the procedure creates encumbrance lines in PSP_ENC_LINES.
1346 *************************************************************************/
1347
1348 /**********************************************************************************
1349 CODING LOGIC
1350 --> Retrieve the date ranges for which encumbrance has to be done:
1351 --When Called in Create Mode all time periods beyond the max. encumbrance period are considered.
1352 --When called in Update/Quick Update Mode periods between last payroll run date and max. encumbered date
1353 for that assignment are considered.
1354 --All the active assignment chunks are Bulk Collected inot r_enc_period RECORD.
1355 --> Next, go through a loop (for each record of r_enc_period) to calculate the encumbrance amount for each active assignment chunk within a period
1356 in the payroll.
1357 --> For each active assignment chunk, calculate the daily rate (from Encumbrance amount and business days)
1358 --> Then, go through a loop to find the schedule for that assignment chunk by going through the schedule
1359 hierarchy.
1360 --> Once the schedule has been determined, then create encumbrance lines
1361 --> Exit out of the First Loop when the assignment start date > Enumbrance End date Calculated within each
1362 Hierarchy for each CI. For GL Encumrbance End date = Org. Default End Date for POETA it is computed
1363 thorugh procedure Obtain_Enc_Poeta_Enc_date.
1364 --> Close First Loop
1365
1366
1367 ***********************************************************************************/
1368
1369 PROCEDURE create_lines( p_assignment_id IN NUMBER,
1370 p_payroll_id IN NUMBER,
1371 p_element_type_id IN NUMBER,
1372 p_last_paid_date IN DATE,
1373 p_return_status OUT NOCOPY VARCHAR2) IS
1374 CURSOR enc_period_cur IS
1375 SELECT ptp.time_period_id,
1376 ptp.start_date,
1377 ptp.end_date,
1378 GREATEST(ptp.start_date, paf.effective_start_date),
1379 LEAST(ptp.end_date, paf.effective_end_date),
1380 DECODE(g_Eff_Date_Value, 1, ptp.end_date,
1381 2, ptp.start_date,
1382 3, ptp.regular_payment_date,
1383 4, ptp.default_dd_date,
1384 5, ptp.cut_off_date) effective_date,
1385 'Y',
1386 0,
1387 NULL
1388 FROM per_time_periods ptp,
1389 per_all_assignments_f paf,
1390 per_assignment_status_types past
1391 WHERE ptp.payroll_id = p_payroll_id
1392 AND paf.assignment_id = p_assignment_id
1393 AND ptp.start_date <= paf.effective_end_date
1394 AND ptp.end_date >= paf.effective_start_date
1395 AND past.assignment_status_type_id = paf.assignment_status_type_id
1396 AND past.per_system_status = 'ACTIVE_ASSIGN'
1397 AND paf.payroll_id=p_payroll_id
1398 AND ptp.start_date >= p_last_paid_date
1399 AND paf.effective_start_date <= g_enc_org_end_date
1400 AND (g_actual_term_date IS NULL OR ptp.start_date <= g_actual_term_date)
1401 AND (g_pateo_end_date IS NULL OR ptp.start_date <= g_pateo_end_date)
1402 ORDER BY 1, 4;
1403
1404 CURSOR c_person_id IS
1405 SELECT paf.person_id
1406 FROM per_all_assignments_f paf
1407 WHERE paf.assignment_id =p_assignment_id
1408 AND ROWNUM=1;
1409
1410 l_project_number pa_projects_all.segment1%TYPE;
1411 l_task_number pa_tasks.task_number%TYPE;
1412 l_award_number gms_awards_all.award_number%TYPE;
1413 l_exp_org_name hr_organization_units.name%TYPE;
1414 l_gl_description VARCHAR2(4000);
1415 l_time_period_id NUMBER;
1416 l_return_status VARCHAR2(1);
1417 l_person_id NUMBER;
1418 l_effective_date DATE;
1419 l_msg_count NUMBER;
1420 l_msg_data VARCHAR2(2000);
1421 l_period_start_date DATE;
1422 l_period_end_date DATE;
1423 l_earnings_amount NUMBER;
1424 l_asg_start_date DATE;
1425 l_asg_end_date DATE;
1426 l_process_flag VARCHAR2(10);
1427 r_enc_period_tmp enc_period_rectype;
1428 l_prev_time_period_id NUMBER;
1429 l_enc_element_type_id NUMBER;
1430 l_period_ind NUMBER;
1431 l_running_total NUMBER;
1432 l_prev_enc_lines_counter NUMBER;
1433 l_proc_name VARCHAR2(61);
1434 l_proc_step NUMBER(20, 10);
1435 l_schedule_line_id NUMBER(15);
1436 l_element_account_id NUMBER(15);
1437 l_org_schedule_id NUMBER(15);
1438 l_default_account_id NUMBER(15);
1439 l_suspense_account_id NUMBER(15);
1440 l_gl_code_combination_id NUMBER(15);
1441 l_project_id NUMBER(15);
1442 l_task_id NUMBER(15);
1443 l_award_id NUMBER(15);
1444 l_expenditure_type VARCHAR2(30);
1445 l_expenditure_org_id NUMBER(15);
1446 l_orig_gl_code_combination_id NUMBER(15);
1447 l_orig_project_id NUMBER(15);
1448 l_orig_task_id NUMBER(15);
1449 l_orig_award_id NUMBER(15);
1450 l_orig_expenditure_type VARCHAR2(30);
1451 l_orig_expenditure_org_id NUMBER(15);
1452 l_attribute_category VARCHAR2(30);
1453 l_attribute1 VARCHAR2(150);
1454 l_attribute2 VARCHAR2(150);
1455 l_attribute3 VARCHAR2(150);
1456 l_attribute4 VARCHAR2(150);
1457 l_attribute5 VARCHAR2(150);
1458 l_attribute6 VARCHAR2(150);
1459 l_attribute7 VARCHAR2(150);
1460 l_attribute8 VARCHAR2(150);
1461 l_attribute9 VARCHAR2(150);
1462 l_attribute10 VARCHAR2(150);
1463 l_reason_code VARCHAR2(50);
1464 l_schedule_percent NUMBER;
1465 l_dist_amount NUMBER;
1466 l_bus_days_in_chunk NUMBER;
1467 l_start_date_active DATE;
1468 l_end_date_active DATE;
1469 l_poeta_start_date DATE;
1470 l_poeta_end_date DATE;
1471 no_global_acct_exists EXCEPTION;
1472 suspense_ac_invalid EXCEPTION;
1473 suspense_autopop_failed EXCEPTION;
1474 l_autopop_status VARCHAR2(1);
1475 l_autopop_error VARCHAR2(50);
1476 l_new_expenditure_type VARCHAR2(30);
1477 l_new_gl_code_combination_id NUMBER(15);
1478 l_acct_type VARCHAR2(1);
1479 l_orig_pointer NUMBER(15);
1480 l_chunk_pointer NUMBER(15);
1481 l_enc_period_count NUMBER(15);
1482 l_organization_id NUMBER(15);
1483 l_ignore_start NUMBER(15);
1484 l_ignore_end NUMBER(15);
1485 l_organization_name VARCHAR2(240);
1486 l_min_start_date DATE;
1487 l_max_end_date DATE;
1488
1489 CURSOR asg_number_cur IS
1490 SELECT organization_id
1491 FROM per_all_assignments_f
1492 WHERE assignment_id = p_assignment_id
1493 AND payroll_id = p_payroll_id
1494 AND effective_end_date >= l_asg_start_date
1495 AND ROWNUM = 1;
1496
1497 CURSOR org_name_cur IS
1498 SELECT name
1499 FROM hr_organization_units
1500 WHERE organization_id = l_organization_id;
1501
1502 CURSOR project_number_cur IS
1503 SELECT SEGMENT1
1504 FROM pa_projects_all
1505 WHERE project_id = l_project_id;
1506
1507 CURSOR award_number_cur IS
1508 SELECT award_number
1509 FROM gms_awards_all
1510 WHERE award_id = l_award_id;
1511
1512 CURSOR task_number_cur Is
1513 SELECT task_number
1514 FROM pa_tasks
1515 WHERE task_id = l_task_id;
1516
1517 CURSOR exp_org_name_cur IS
1518 SELECT name
1519 FROM hr_organization_units
1520 WHERE organization_id = l_expenditure_org_id;
1521
1522 PROCEDURE process_all_hier (p_chunk_pointer IN NUMBER,
1523 p_asg_start_date IN DATE,
1524 p_asg_end_date IN DATE,
1525 p_encumbrance_amount IN NUMBER,
1526 p_process_flag IN VARCHAR2) IS
1527 l_da_reason_code VARCHAR2(50);
1528 l_sa_reason_code VARCHAR2(50);
1529 l_gl_project_flag VARCHAR2(1);
1530 l_linkage_status VARCHAR2(50);
1531 l_patc_status VARCHAR2(50);
1532 l_billable_flag VARCHAR2(1);
1533 l_bus_days_in_period NUMBER;
1534 l_bus_days_in_sched NUMBER;
1535 l_msg_count NUMBER;
1536 l_msg_data VARCHAR2(2000);
1537 l_msg_app VARCHAR2(2000);
1538 l_msg_type VARCHAR2(2000);
1539 l_msg_token1 VARCHAR2(2000);
1540 l_msg_token2 VARCHAR2(2000);
1541 l_msg_token3 VARCHAR2(2000);
1542 l_award_status VARCHAR2(2000);
1543 l_last_enc_date DATE;
1544 l_daily_rate NUMBER;
1545 t_poeta_gl_hier_array r_poeta_gl_hier_tab;
1546 l_org_id NUMBER(15);
1547 BEGIN
1548 IF (p_process_flag = 'DA') THEN
1549 l_da_reason_code := l_reason_code;
1550 END IF;
1551
1552 IF (p_process_flag = 'SA') THEN
1553 l_sa_reason_code := l_reason_code;
1554 END IF;
1555
1556 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering process_all_hier');
1557 hr_utility.trace(' p_chunk_pointer: ' || p_chunk_pointer ||
1558 ' p_asg_start_date: ' || TO_CHAR(p_asg_start_date, 'DD-MON-RRRR') ||
1559 ' p_asg_end_date: ' || TO_CHAR(p_asg_end_date, 'DD-MON-RRRR') ||
1560 ' p_process_flag: ' || p_process_flag);
1561
1562 l_last_enc_date := NVL(g_actual_term_date, g_enc_org_end_date);
1563
1564 IF ((p_process_flag <> 'SA') AND (l_project_id IS NOT NULL)) THEN
1565 l_patc_status := NULL;
1566 l_linkage_status:= NULL;
1567 l_billable_flag := NULL;
1568 l_award_status := NULL;
1569
1570 obtain_enc_poeta_end_date (p_ls_start_date => l_start_date_active,
1571 p_ls_end_date => l_end_date_active,
1572 p_poeta_end_date => l_poeta_end_date,
1573 p_enc_end_date => l_last_enc_date,
1574 p_return_status => l_return_status);
1575 IF l_return_status <> fnd_api.g_ret_sts_success THEN
1576 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1577 END IF;
1578 END IF;
1579 hr_utility.trace(' l_last_enc_date: ' || TO_CHAR(l_last_enc_date, 'DD-MON-RRRR'));
1580
1581 IF (r_enc_period.r_asg_start_date(p_chunk_pointer) <= l_last_enc_date) THEN
1582 l_start_date_active := GREATEST(l_start_date_active, p_asg_start_date);
1583 l_end_date_active := LEAST(l_end_date_active, p_asg_end_date, l_last_enc_date);
1584 l_daily_rate := round((r_enc_period.r_encumbrance_amount(p_chunk_pointer) * l_schedule_percent/100),g_ext_precision);
1585 l_daily_rate := NVL(p_encumbrance_amount, l_daily_rate);
1586 hr_utility.trace(' l_start_date_active: ' || TO_CHAR(l_start_date_active, 'DD-MON-RRRR') ||
1587 ' l_end_date_active: ' || TO_CHAR(l_end_date_active, 'DD-MON-RRRR') ||
1588 ' l_poeta_start_date: ' || TO_CHAR(l_poeta_start_date, 'DD-MON-RRRR') ||
1589 ' l_poeta_end_date: ' || TO_CHAR(l_poeta_end_date, 'DD-MON-RRRR') ||
1590 ' l_daily_rate: ' || l_daily_rate);
1591 determine_pro_rata_dates (p_assignment_id => p_assignment_id,
1592 p_ls_start_date => l_start_date_active,
1593 p_ls_end_date => l_end_date_active,
1594 p_poeta_start_date => l_poeta_start_date,
1595 p_poeta_end_date => l_poeta_end_date,
1596 p_asg_start_date => p_asg_start_date,
1597 p_asg_end_date => p_asg_end_date,
1598 p_asg_amount => l_daily_rate,
1599 p_poeta_gl_hier_array => t_poeta_gl_hier_array,
1600 p_return_status => l_return_status);
1601 IF l_return_status <> fnd_api.g_ret_sts_success THEN
1602 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1603 END IF;
1604
1605 hr_utility.trace(' t_poeta_gl_hier_array.COUNT: ' || t_poeta_gl_hier_array.COUNT);
1606 FOR I IN 1..t_poeta_gl_hier_array.COUNT
1607 LOOP
1608 hr_utility.trace(' t_poeta_gl_hier_array(' || I || ').r_enc_start_date: ' || TO_CHAR(t_poeta_gl_hier_array(I).r_enc_start_date, 'DD-MON-RRRR') ||
1609 ' t_poeta_gl_hier_array(' || I || ').r_enc_end_date: ' || TO_CHAR(t_poeta_gl_hier_array(I).r_enc_end_date, 'DD-MON-RRRR') ||
1610 ' t_poeta_gl_hier_array(' || I || ').r_amount: ' || t_poeta_gl_hier_array(I).r_amount ||
1611 ' t_poeta_gl_hier_array(' || I || ').r_susp_flag: ' || t_poeta_gl_hier_array(I).r_susp_flag);
1612 IF t_poeta_gl_hier_array(I).r_susp_flag <> 'Y' THEN
1613 l_dist_amount := t_poeta_gl_hier_array(I).r_amount;
1614 l_effective_date := r_enc_period.r_effective_date(p_chunk_pointer);
1615 l_gl_project_flag := 'G';
1616
1617 IF l_gl_code_combination_id IS NOT NULL THEN
1618 insert_into_enc_lines(
1619 p_element_type_id,
1620 l_effective_date,
1621 g_dr_cr_flag ,
1622 ROUND(l_dist_amount, g_precision),
1623 g_enc_line_type,
1624 l_schedule_line_id,
1625 l_org_schedule_id,
1626 l_default_account_id,
1627 l_suspense_account_id,
1628 l_element_account_id,
1629 l_gl_project_flag,
1630 l_person_id,
1631 p_assignment_id,
1632 l_award_id,
1633 l_task_id,
1634 l_expenditure_type,
1635 l_expenditure_org_id,
1636 l_project_id,
1637 l_gl_code_combination_id,
1638 r_enc_period.r_time_period_id(p_chunk_pointer),
1639 p_payroll_id,
1640 g_business_group_id,
1641 g_set_of_books_id,
1642 l_sa_reason_code,
1643 l_da_reason_code,
1644 'N',
1645 t_poeta_gl_hier_array(i).r_enc_start_date,
1646 t_poeta_gl_hier_array(i).r_enc_end_date,
1647 l_attribute_category,
1648 l_attribute1,
1649 l_attribute2,
1650 l_attribute3,
1651 l_attribute4,
1652 l_attribute5,
1653 l_attribute6,
1654 l_attribute7,
1655 l_attribute8,
1656 l_attribute9,
1657 l_attribute10,
1658 l_orig_gl_code_combination_id,
1659 l_orig_project_id,
1660 l_orig_task_id,
1661 l_orig_award_id,
1662 l_orig_expenditure_org_id,
1663 l_orig_expenditure_type,
1664 l_process_flag,
1665 l_return_status);
1666 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1667 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1668 END IF;
1669 ELSE
1670 psp_general.poeta_effective_date (t_poeta_gl_hier_array(I).r_enc_end_date,
1671 l_project_id,
1672 l_award_id,
1673 l_task_id,
1674 l_effective_date,
1675 l_return_status);
1676 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1677 fnd_message.set_name('PSP', 'PSP_POETA_EFFECTIVE_DATE_ERROR');
1678 g_error_message := fnd_message.get;
1679 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1680 END IF;
1681
1682 -- R12 moac uptake. Set the MOAC Context to Single
1683 l_org_id := psp_general.get_transaction_org_id( l_project_id, l_expenditure_org_id);
1684 mo_global.set_policy_context('S', l_org_id);
1685
1686 pa_transactions_pub.validate_transaction
1687 (x_project_id => l_project_id,
1688 x_task_id => l_task_id,
1689 x_ei_date => l_effective_date,
1690 x_expenditure_type => l_expenditure_type,
1691 x_non_labor_resource => NULL,
1692 x_person_id => l_person_id,
1693 x_incurred_by_org_id => l_expenditure_org_id,
1694 x_calling_module => 'PSPENLNB',
1695 x_msg_application => l_msg_app,
1696 x_msg_type => l_msg_type,
1697 x_msg_token1 => l_msg_token1,
1698 x_msg_token2 => l_msg_token2,
1699 x_msg_token3 => l_msg_token3,
1700 x_msg_count => l_msg_count,
1701 x_msg_data => l_patc_status,
1702 x_billable_flag => l_billable_flag,
1703 p_sys_link_function => 'ST'); --Bug 5639589: Added parameter
1704
1705
1706 IF l_patc_status IS NULL THEN
1707 gms_transactions_pub.validate_transaction
1708 (l_project_id,
1709 l_task_id,
1710 l_award_id,
1711 l_expenditure_type,
1712 l_effective_date,
1713 'PSPENLNB',
1714 l_award_status);
1715
1716 IF l_award_status IS NOT NULL THEN
1717 l_patc_status := SUBSTR(l_award_status,1,50);
1718 END IF;
1719 END IF;
1720 -- Set the MOAC Context to Multiple
1721 mo_global.set_policy_context('M', null);
1722
1723 IF (l_patc_status IS NOT NULL ) THEN
1724 IF (p_process_flag = 'SA') THEN
1725 OPEN project_number_cur;
1726 FETCH project_number_cur INTO l_project_number;
1727 CLOSE project_number_cur;
1728
1729 OPEN award_number_cur;
1730 FETCH award_number_cur INTO l_award_number;
1731 CLOSE award_number_cur;
1732
1733 OPEN task_number_cur;
1734 FETCH task_number_cur INTO l_task_number;
1735 CLOSE task_number_cur;
1736
1737 OPEN exp_org_name_cur;
1738 FETCH exp_org_name_cur INTO l_exp_org_name;
1739 CLOSE exp_org_name_cur;
1740
1741 IF (l_patc_status IS NOT NULL) THEN
1742 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_INV_PATEO');
1743 fnd_message.set_token('PJ', l_project_number);
1744 fnd_message.set_token('TK', l_task_number);
1745 fnd_message.set_token('AW', l_award_number);
1746 fnd_message.set_token('EO', l_exp_org_name);
1747 fnd_message.set_token('ET', l_expenditure_type);
1748 fnd_message.set_token('START_DATE', t_poeta_gl_hier_array(i).r_enc_start_date);
1749 fnd_message.set_token('END_DATE', t_poeta_gl_hier_array(i).r_enc_end_date);
1750 fnd_message.set_token('ERROR_STATUS', l_patc_status);
1751 ELSE
1752 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_END_PATEO');
1753 fnd_message.set_token('PJ', l_project_number);
1754 fnd_message.set_token('TK', l_task_number);
1755 fnd_message.set_token('AW', l_award_number);
1756 fnd_message.set_token('EO', l_exp_org_name);
1757 fnd_message.set_token('ET', l_expenditure_type);
1758 fnd_message.set_token('START_DATE', t_poeta_gl_hier_array(i).r_enc_start_date);
1759 fnd_message.set_token('END_DATE', t_poeta_gl_hier_array(i).r_enc_end_date);
1760 fnd_message.set_token('EFFECTIVE_DATE', l_poeta_end_date);
1761 END IF;
1762 g_error_message := fnd_message.get;
1763 fnd_file.put_line(fnd_file.log, g_error_message);
1764 RAISE SUSPENSE_AC_INVALID;
1765 END IF;
1766
1767 IF ((t_poeta_gl_hier_array(I).r_enc_start_date <= g_enc_org_end_date) AND
1768 (psp_general.business_days(t_poeta_gl_hier_array(I).r_enc_start_date,
1769 t_poeta_gl_hier_array(I).r_enc_end_date) > 0)) THEN
1770 orig_ci.gl_code_combination_id(g_orig_pointer) := l_gl_code_combination_id;
1771 orig_ci.project_id(g_orig_pointer) := l_project_id;
1772 orig_ci.task_id(g_orig_pointer) := l_task_id;
1773 orig_ci.award_id(g_orig_pointer) := l_award_id;
1774 orig_ci.expenditure_organization_id(g_orig_pointer) := l_expenditure_org_id;
1775 orig_ci.expenditure_type(g_orig_pointer) := l_expenditure_type;
1776 g_orig_pointer := g_orig_pointer + 1;
1777 l_enc_period_count := r_enc_period.r_time_period_id.COUNT + 1;
1778 r_enc_period.r_period_ind(l_enc_period_count) := r_enc_period.r_period_ind(p_chunk_pointer);
1779 r_enc_period.r_period_start_date(l_enc_period_count) := r_enc_period.r_period_start_date(p_chunk_pointer);
1780 r_enc_period.r_period_end_date(l_enc_period_count) := r_enc_period.r_period_end_date(p_chunk_pointer);
1781 r_enc_period.r_asg_start_date(l_enc_period_count) := t_poeta_gl_hier_array(I).r_enc_start_date;
1782 r_enc_period.r_asg_end_date(l_enc_period_count) := t_poeta_gl_hier_array(I).r_enc_end_date;
1783 r_enc_period.r_effective_date(l_enc_period_count) := r_enc_period.r_effective_date(p_chunk_pointer);
1784 r_enc_period.r_time_period_id(l_enc_period_count) := r_enc_period.r_time_period_id(p_chunk_pointer);
1785 r_enc_period.r_process_flag(l_enc_period_count) := 'SA';
1786 r_enc_period.r_schedule_percent(l_enc_period_count) := 100;
1787 r_enc_period.r_encumbrance_amount(l_enc_period_count) :=
1788 ROUND(((l_daily_rate * psp_general.business_days(t_poeta_gl_hier_array(I).r_enc_start_date, LEAST(t_poeta_gl_hier_array(I).r_enc_end_date, g_enc_org_end_date),p_assignment_id)) /
1789 psp_general.business_days(t_poeta_gl_hier_array(I).r_enc_start_date, t_poeta_gl_hier_array(I).r_enc_end_date,p_assignment_id)),g_ext_precision);
1790 r_enc_period.r_period_amount(l_enc_period_count) := r_enc_period.r_period_amount(p_chunk_pointer);
1791 r_enc_period.r_reason_code(l_enc_period_count) := l_patc_status;
1792 END IF;
1793 add_cel_warnings(p_start_date => t_poeta_gl_hier_array(I).r_enc_start_date,
1794 p_end_date => t_poeta_gl_hier_array(I).r_enc_end_date,
1795 p_hierarchy_code => 'SA',
1796 p_warning_code => 'INVALID_CI',
1797 p_project_id => l_project_id,
1798 p_task_id => l_task_id,
1799 p_award_id => l_award_id,
1800 p_exp_org_id => l_expenditure_org_id,
1801 p_exp_type => l_expenditure_type,
1802 p_effective_date => l_poeta_end_date,
1803 p_error_status => l_patc_status);
1804 ELSE
1805 l_gl_project_flag := 'P';
1806 insert_into_enc_lines
1807 (p_element_type_id,
1808 l_effective_date,
1809 g_dr_cr_flag,
1810 ROUND(l_dist_amount,g_precision),
1811 g_enc_line_type,
1812 l_schedule_line_id,
1813 l_org_schedule_id,
1814 l_default_account_id,
1815 l_suspense_account_id,
1816 l_element_account_id,
1817 l_gl_project_flag,
1818 l_person_id,
1819 p_assignment_id,
1820 l_award_id,
1821 l_task_id,
1822 l_expenditure_type,
1823 l_expenditure_org_id,
1824 l_project_id,
1825 l_gl_code_combination_id,
1826 r_enc_period.r_time_period_id(p_chunk_pointer),
1827 p_payroll_id,
1828 g_business_group_id,
1829 g_set_of_books_id,
1830 l_sa_reason_code,
1831 l_da_reason_code,
1832 'N',
1833 t_poeta_gl_hier_array(i).r_enc_start_date,
1834 t_poeta_gl_hier_array(i).r_enc_end_date,
1835 l_attribute_category,
1836 l_attribute1,
1837 l_attribute2,
1838 l_attribute3,
1839 l_attribute4,
1840 l_attribute5,
1841 l_attribute6,
1842 l_attribute7,
1843 l_attribute8,
1844 l_attribute9,
1845 l_attribute10,
1846 l_orig_gl_code_combination_id,
1847 l_orig_project_id,
1848 l_orig_task_id,
1849 l_orig_award_id,
1850 l_orig_expenditure_org_id,
1851 l_orig_expenditure_type,
1852 l_process_flag,
1853 l_return_status);
1854 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1855 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1856 END IF;
1857 END IF;
1858 END IF;
1859 ELSE
1860 l_dist_amount := t_poeta_gl_hier_array(i).r_amount;
1861
1862 psp_general.poeta_effective_date (t_poeta_gl_hier_array(I).r_enc_end_date,
1863 l_project_id,
1864 l_award_id,
1865 l_task_id,
1866 l_effective_date,
1867 l_return_status);
1868 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1869 fnd_message.set_name('PSP', 'PSP_POETA_EFFECTIVE_DATE_ERROR');
1870 g_error_message := fnd_message.get;
1871 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1872 END IF;
1873
1874 -- R12 moac uptake. Set the MOAC Context to Single
1875 l_org_id := psp_general.get_transaction_org_id( l_project_id, l_expenditure_org_id);
1876 mo_global.set_policy_context('S', l_org_id);
1877
1878 pa_transactions_pub.validate_transaction
1879 (x_project_id => l_project_id,
1880 x_task_id => l_task_id,
1881 x_ei_date => t_poeta_gl_hier_array(I).r_enc_end_date,
1882 x_expenditure_type => l_expenditure_type,
1883 x_non_labor_resource => NULL,
1884 x_person_id => l_person_id,
1885 x_incurred_by_org_id => l_expenditure_org_id,
1886 x_calling_module => 'PSPENLNB',
1887 x_msg_application => l_msg_app,
1888 x_msg_type => l_msg_type,
1889 x_msg_token1 => l_msg_token1,
1890 x_msg_token2 => l_msg_token2,
1891 x_msg_token3 => l_msg_token3,
1892 x_msg_count => l_msg_count,
1893 x_msg_data => l_patc_status,
1894 x_billable_flag => l_billable_flag,
1895 p_sys_link_function => 'ST'); --Bug 5639589: Added parameter
1896
1897
1898 IF l_patc_status IS NULL THEN
1899 gms_transactions_pub.validate_transaction
1900 (l_project_id,
1901 l_task_id,
1902 l_award_id,
1903 l_expenditure_type,
1904 t_poeta_gl_hier_array(I).r_enc_end_date,
1905 'PSPENLNB',
1906 l_award_status);
1907
1908 IF l_award_status IS NOT NULL THEN
1909 l_patc_status := SUBSTR(l_award_status,1,50);
1910 END IF;
1911 END IF;
1912 -- Set the MOAC Context to Multiple
1913 mo_global.set_policy_context('M', null);
1914
1915 IF (p_process_flag = 'SA') THEN
1916 OPEN project_number_cur;
1917 FETCH project_number_cur INTO l_project_number;
1918 CLOSE project_number_cur;
1919
1920 OPEN award_number_cur;
1921 FETCH award_number_cur INTO l_award_number;
1922 CLOSE award_number_cur;
1923
1924 OPEN task_number_cur;
1925 FETCH task_number_cur INTO l_task_number;
1926 CLOSE task_number_cur;
1927
1928 OPEN exp_org_name_cur;
1929 FETCH exp_org_name_cur INTO l_exp_org_name;
1930 CLOSE exp_org_name_cur;
1931
1932 IF (l_patc_status IS NOT NULL) THEN
1933 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_INV_PATEO');
1934 fnd_message.set_token('PJ', l_project_number);
1935 fnd_message.set_token('TK', l_task_number);
1936 fnd_message.set_token('AW', l_award_number);
1937 fnd_message.set_token('EO', l_exp_org_name);
1938 fnd_message.set_token('ET', l_expenditure_type);
1939 fnd_message.set_token('START_DATE', t_poeta_gl_hier_array(i).r_enc_start_date);
1940 fnd_message.set_token('END_DATE', t_poeta_gl_hier_array(i).r_enc_end_date);
1941 fnd_message.set_token('ERROR_STATUS', l_patc_status);
1942 ELSE
1943 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_END_PATEO');
1944 fnd_message.set_token('PJ', l_project_number);
1945 fnd_message.set_token('TK', l_task_number);
1946 fnd_message.set_token('AW', l_award_number);
1947 fnd_message.set_token('EO', l_exp_org_name);
1948 fnd_message.set_token('ET', l_expenditure_type);
1949 fnd_message.set_token('START_DATE', t_poeta_gl_hier_array(i).r_enc_start_date);
1950 fnd_message.set_token('END_DATE', t_poeta_gl_hier_array(i).r_enc_end_date);
1951 fnd_message.set_token('EFFECTIVE_DATE', l_poeta_end_date);
1952 END IF;
1953 g_error_message := fnd_message.get;
1954 fnd_file.put_line(fnd_file.log, g_error_message);
1955 RAISE SUSPENSE_AC_INVALID;
1956 END IF;
1957
1958 IF ((t_poeta_gl_hier_array(I).r_enc_start_date <= g_enc_org_end_date) AND
1959 (psp_general.business_days(t_poeta_gl_hier_array(I).r_enc_start_date,
1960 t_poeta_gl_hier_array(I).r_enc_end_date,p_assignment_id) > 0)) THEN
1961 orig_ci.gl_code_combination_id(g_orig_pointer) := l_gl_code_combination_id;
1962 orig_ci.project_id(g_orig_pointer) := l_project_id;
1963 orig_ci.task_id(g_orig_pointer) := l_task_id;
1964 orig_ci.award_id(g_orig_pointer) := l_award_id;
1965 orig_ci.expenditure_organization_id(g_orig_pointer) := l_expenditure_org_id;
1966 orig_ci.expenditure_type(g_orig_pointer) := l_expenditure_type;
1967 g_orig_pointer := g_orig_pointer + 1;
1968 l_enc_period_count := r_enc_period.r_time_period_id.COUNT + 1;
1969 r_enc_period.r_period_ind(l_enc_period_count) := r_enc_period.r_period_ind(p_chunk_pointer);
1970 r_enc_period.r_period_start_date(l_enc_period_count) := r_enc_period.r_period_start_date(p_chunk_pointer);
1971 r_enc_period.r_period_end_date(l_enc_period_count) := r_enc_period.r_period_end_date(p_chunk_pointer);
1972 r_enc_period.r_asg_start_date(l_enc_period_count) := t_poeta_gl_hier_array(I).r_enc_start_date;
1973 r_enc_period.r_asg_end_date(l_enc_period_count) := LEAST(t_poeta_gl_hier_array(I).r_enc_end_date, g_enc_org_end_date);
1974 r_enc_period.r_effective_date(l_enc_period_count) := r_enc_period.r_effective_date(p_chunk_pointer);
1975 r_enc_period.r_time_period_id(l_enc_period_count) := r_enc_period.r_time_period_id(p_chunk_pointer);
1976 r_enc_period.r_process_flag(l_enc_period_count) := 'SA';
1977 r_enc_period.r_schedule_percent(l_enc_period_count) := 100;
1978 r_enc_period.r_encumbrance_amount(l_enc_period_count) :=
1979 ROUND(((l_daily_rate * psp_general.business_days(t_poeta_gl_hier_array(I).r_enc_start_date, LEAST(t_poeta_gl_hier_array(I).r_enc_end_date, g_enc_org_end_date),p_assignment_id)) /
1980 psp_general.business_days(t_poeta_gl_hier_array(I).r_enc_start_date, t_poeta_gl_hier_array(I).r_enc_end_date,p_assignment_id)),g_ext_precision);
1981 r_enc_period.r_period_amount(l_enc_period_count) := r_enc_period.r_period_amount(p_chunk_pointer);
1982 r_enc_period.r_reason_code(l_enc_period_count) := l_patc_status;
1983 END IF;
1984
1985 add_cel_warnings(p_start_date => t_poeta_gl_hier_array(I).r_enc_start_date,
1986 p_end_date => t_poeta_gl_hier_array(I).r_enc_end_date,
1987 p_hierarchy_code => 'SA',
1988 p_warning_code => 'INVALID_CI',
1989 p_project_id => l_project_id,
1990 p_task_id => l_task_id,
1991 p_award_id => l_award_id,
1992 p_exp_org_id => l_expenditure_org_id,
1993 p_exp_type => l_expenditure_type,
1994 p_effective_date => l_poeta_end_date,
1995 p_error_status => l_patc_status);
1996 END IF;
1997 END LOOP;
1998 END IF;
1999 t_poeta_gl_hier_array.DELETE;
2000 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving process_all_hier');
2001 END process_all_hier;
2002
2003 PROCEDURE log_gl_hours_message IS
2004 BEGIN
2005 add_cel_warnings(p_start_date => l_asg_start_date,
2006 p_hierarchy_code => 'GL',
2007 p_end_date => l_asg_end_date,
2008 p_warning_code => 'GL',
2009 p_percent => ROUND(((l_earnings_amount*l_schedule_percent)/100), g_precision));
2010 END log_gl_hours_message;
2011
2012 BEGIN
2013 l_proc_step := 10;
2014 l_proc_name := 'CREATE_LINES';
2015
2016 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering ' || l_proc_name);
2017 hr_utility.trace('p_assignment_id: ' || fnd_number.number_to_canonical(p_assignment_id) ||
2018 ' p_payroll_id: ' || fnd_number.number_to_canonical(p_payroll_id) ||
2019 ' p_element_type_id: ' || fnd_number.number_to_canonical(p_element_type_id) ||
2020 ' p_last_paid_date: ' || fnd_date.date_to_canonical(p_last_paid_date));
2021
2022 p_return_status := fnd_api.g_ret_sts_success;
2023
2024 OPEN c_person_id;
2025 FETCH c_person_id INTO l_person_id;
2026 CLOSE c_person_id;
2027
2028 hr_utility.trace('l_person_id: ' || fnd_number.number_to_canonical(l_person_id));
2029 l_proc_step := 20;
2030 g_pateo_end_date := NULL;
2031
2032 OPEN enc_period_cur;
2033 FETCH enc_period_cur BULK COLLECT INTO r_enc_period.r_time_period_id,
2034 r_enc_period.r_period_start_date, r_enc_period.r_period_end_date,
2035 r_enc_period.r_asg_start_date, r_enc_period.r_asg_end_date,
2036 r_enc_period.r_effective_date, r_enc_period.r_process_flag,
2037 r_enc_period.r_schedule_percent, r_enc_period.r_reason_code;
2038 CLOSE enc_period_cur;
2039
2040 hr_utility.trace('r_enc_period.r_time_period_id.COUNT: ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id.COUNT));
2041 l_proc_step := 30;
2042
2043 IF (r_enc_period.r_time_period_id.COUNT > 0) THEN
2044 load_sch_hierarchy(p_assignment_id, p_payroll_id, p_element_type_id, g_business_group_id, g_set_of_books_id, p_return_status);
2045 IF (p_return_status <> fnd_api.g_ret_sts_success) THEN
2046 RAISE fnd_api.g_exc_unexpected_error;
2047 END IF;
2048 END IF;
2049
2050 OPEN enc_period_cur;
2051 FETCH enc_period_cur BULK COLLECT INTO r_enc_period.r_time_period_id,
2052 r_enc_period.r_period_start_date, r_enc_period.r_period_end_date,
2053 r_enc_period.r_asg_start_date, r_enc_period.r_asg_end_date,
2054 r_enc_period.r_effective_date, r_enc_period.r_process_flag,
2055 r_enc_period.r_schedule_percent, r_enc_period.r_reason_code;
2056 CLOSE enc_period_cur;
2057
2058 hr_utility.trace('Cutting down periods beyond MAX(poeta_end_date); r_enc_period.r_time_period_id.COUNT: ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id.COUNT));
2059
2060 l_proc_step := 40;
2061
2062 IF (r_enc_period.r_time_period_id.COUNT > 0) THEN
2063 sub_slice_asg_chunk(p_assignment_id, p_element_type_id, g_business_group_id, g_set_of_books_id, p_return_status);
2064 IF (p_return_status <> fnd_api.g_ret_sts_success) THEN
2065 RAISE fnd_api.g_exc_unexpected_error;
2066 END IF;
2067 END IF;
2068
2069 hr_utility.trace('r_enc_period.r_time_period_id.COUNT: ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id.COUNT));
2070 l_proc_step := 50;
2071
2072 IF (r_enc_period.r_time_period_id.COUNT > 0) THEN
2073 determine_enc_amount(p_person_id => l_person_id,
2074 p_assignment_id => p_assignment_id,
2075 p_element_type_id => p_element_type_id,
2076 p_business_group_id => g_business_group_id,
2077 p_set_of_books_id => g_set_of_books_id,
2078 p_payroll_id => p_payroll_id,
2079 p_return_status => l_return_status);
2080 IF l_return_status <> fnd_api.g_ret_sts_success THEN
2081 RAISE fnd_api.g_exc_unexpected_error;
2082 END IF;
2083 END IF;
2084
2085 l_proc_step := 60;
2086 g_et_pointer := 1;
2087 g_ec_pointer := 1;
2088 g_asg_pointer := 1;
2089 g_ge_pointer := 1;
2090 g_odls_pointer := 1;
2091 g_da_pointer := 1;
2092 g_sa_pointer := 1;
2093 g_orig_pointer := 1;
2094 l_orig_pointer := 1;
2095 l_chunk_pointer := 1;
2096 l_prev_enc_lines_counter := t_enc_lines_array.r_time_period_id.COUNT + 1;
2097 l_min_start_date := fnd_date.canonical_to_date('1800/01/01');
2098 l_max_end_date := LEAST(NVL(g_actual_term_date, g_enc_org_end_date), g_enc_org_end_date);
2099 l_ignore_start := -1;
2100 l_ignore_end := -1;
2101
2102 IF (r_enc_period.r_asg_end_date.COUNT > 0) THEN
2103 l_min_start_date := r_enc_period.r_asg_start_date(1);
2104 l_max_end_date := LEAST(r_enc_period.r_asg_end_date(r_enc_period.r_asg_end_date.COUNT),
2105 l_max_end_date);
2106
2107 IF ( (l_min_start_date > r_enc_period.r_period_start_date(1)) AND
2108 (psp_general.business_days(r_enc_period.r_period_start_date(1),
2109 r_enc_period.r_period_end_date(1),p_assignment_id) <>
2110 psp_general.business_days(l_min_start_date,
2111 r_enc_period.r_period_end_date(1),p_assignment_id))) THEN
2112 l_ignore_start := r_enc_period.r_time_period_id(1);
2113 END IF;
2114
2115 IF ( (l_max_end_date < r_enc_period.r_period_end_date(r_enc_period.r_asg_end_date.COUNT)) AND
2116 (psp_general.business_days(r_enc_period.r_period_start_date(r_enc_period.r_asg_end_date.COUNT),
2117 r_enc_period.r_period_end_date(r_enc_period.r_asg_end_date.COUNT)) <>
2118 psp_general.business_days(r_enc_period.r_period_start_date(r_enc_period.r_asg_end_date.COUNT), l_max_end_date))) THEN
2119 l_ignore_end := r_enc_period.r_time_period_id(r_enc_period.r_asg_end_date.COUNT);
2120 END IF;
2121 hr_utility.trace('l_ignore_start: ' || l_ignore_start);
2122 hr_utility.trace('l_ignore_end: ' || l_ignore_end);
2123 END IF;
2124
2125 LOOP
2126 EXIT WHEN (l_chunk_pointer > r_enc_period.r_time_period_id.COUNT);
2127 l_asg_start_date := r_enc_period.r_asg_start_date(l_chunk_pointer);
2128 l_asg_end_date := r_enc_period.r_asg_end_date(l_chunk_pointer);
2129 l_period_start_date := r_enc_period.r_period_start_date(l_chunk_pointer);
2130 l_period_end_date := r_enc_period.r_period_end_date(l_chunk_pointer);
2131 l_time_period_id := r_enc_period.r_time_period_id(l_chunk_pointer);
2132 l_process_flag := r_enc_period.r_process_flag(l_chunk_pointer);
2133 l_earnings_amount := r_enc_period.r_encumbrance_amount(l_chunk_pointer);
2134 l_period_ind := r_enc_period.r_period_ind(l_chunk_pointer);
2135 l_effective_date := r_enc_period.r_effective_date(l_chunk_pointer);
2136 l_reason_code := r_enc_period.r_reason_code(l_chunk_pointer);
2137
2138 l_bus_days_in_chunk := psp_general.business_days(l_asg_start_date, l_asg_end_date,p_assignment_id);
2139 l_dist_amount := 0;
2140 l_schedule_line_id := NULL;
2141 l_org_schedule_id := NULL;
2142 l_element_account_id := NULL;
2143 l_default_account_id := NULL;
2144 l_suspense_account_id := NULL;
2145
2146 hr_utility.trace('Processing chunk: CP: ' || l_chunk_pointer || ' TP: ' || l_time_period_id ||
2147 ' PSD: ' || TO_CHAR(l_period_start_date, 'DD-MON-RRRR') || ' PED: ' || TO_CHAR(l_period_end_date, 'DD-MON-RRRR') ||
2148 ' ASD: ' || TO_CHAR(l_asg_start_date, 'DD-MON-RRRR') || ' AED: ' || TO_CHAR(l_asg_end_date, 'DD-MON-RRRR') ||
2149 ' PF: ' || l_process_flag || ' EA: ' || l_earnings_amount || ' ED: ' || TO_CHAR(l_effective_date, 'DD-MON-RRRR') ||
2150 ' BD: ' || l_bus_days_in_chunk);
2151
2152 hr_utility.trace('l_chunk_pointer: ' || fnd_number.number_to_canonical(l_chunk_pointer) ||
2153 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
2154 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
2155 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
2156 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
2157 ' l_effective_date: ' || fnd_date.date_to_canonical(l_effective_date) ||
2158 ' l_time_period_id: ' || fnd_number.number_to_canonical(l_time_period_id) ||
2159 ' l_prev_time_period_id: ' || fnd_number.number_to_canonical(l_prev_time_period_id) ||
2160 ' l_process_flag: ' || l_process_flag ||
2161 ' l_earnings_amount: ' || fnd_number.number_to_canonical(l_earnings_amount) ||
2162 ' r_enc_period.r_period_amount(l_chunk_pointer): ' || fnd_number.number_to_canonical(r_enc_period.r_period_amount(l_chunk_pointer)) ||
2163 ' l_period_ind: ' || fnd_number.number_to_canonical(l_period_ind) ||
2164 ' g_enc_lines_counter: ' || fnd_number.number_to_canonical(g_enc_lines_counter));
2165
2166 l_proc_step := 70 + (l_chunk_pointer / 100000);
2167
2168 IF (l_earnings_amount <> 0) AND (l_bus_days_in_chunk > 0) THEN
2169 IF (l_process_flag = 'ET') THEN
2170 FOR recno IN 1..r_et.line_account_id.COUNT
2171 LOOP
2172 IF ((l_asg_start_date <= r_et.end_date_active(recno))
2173 AND (l_asg_end_date >= r_et.start_date_active(recno))) THEN
2174 g_et_pointer := recno;
2175 l_schedule_line_id := r_et.line_account_id(recno);
2176 l_gl_code_combination_id := r_et.gl_code_combination_id(recno);
2177 l_project_id := r_et.project_id(recno);
2178 l_task_id := r_et.task_id(recno);
2179 l_award_id := r_et.award_id(recno);
2180 l_schedule_percent := r_et.percent(recno);
2181 l_expenditure_type := r_et.expenditure_type(recno);
2182 l_expenditure_org_id := r_et.expenditure_organization_id(recno);
2183 l_start_date_active := r_et.start_date_active(recno);
2184 l_end_date_active := r_et.end_date_active(recno);
2185 l_poeta_start_date := r_et.poeta_start_date(recno);
2186 l_poeta_end_date := r_et.poeta_end_date(recno);
2187 l_attribute_category := r_et.attribute_category(recno);
2188 l_attribute1 := r_et.attribute1(recno);
2189 l_attribute2 := r_et.attribute2(recno);
2190 l_attribute3 := r_et.attribute3(recno);
2191 l_attribute4 := r_et.attribute4(recno);
2192 l_attribute5 := r_et.attribute5(recno);
2193 l_attribute6 := r_et.attribute6(recno);
2194 l_attribute7 := r_et.attribute7(recno);
2195 l_attribute8 := r_et.attribute8(recno);
2196 l_attribute9 := r_et.attribute9(recno);
2197 l_attribute10 := r_et.attribute10(recno);
2198 l_acct_type := r_et.acct_type(recno);
2199
2200 IF (g_uom = 'H' AND l_gl_code_combination_id IS NOT NULL) THEN
2201 log_gl_hours_message;
2202 ELSE
2203
2204 IF (g_et_autopop = 'Y') THEN
2205 psp_autopop.main(p_acct_type => l_acct_type,
2206 p_person_id => l_person_id,
2207 p_assignment_id => p_assignment_id,
2208 p_element_type_id => p_element_type_id,
2209 p_project_id => l_project_id,
2210 p_expenditure_organization_id => l_expenditure_org_id,
2211 p_task_id => l_task_id,
2212 p_award_id => l_award_id,
2213 p_expenditure_type => l_expenditure_type,
2214 p_gl_code_combination_id => l_gl_code_combination_id,
2215 p_payroll_date => l_asg_end_date, --- replaced l_effective_date..5592784
2216 p_set_of_books_id => g_set_of_books_id,
2217 p_business_group_id => g_business_group_id,
2218 ret_expenditure_type => l_new_expenditure_type,
2219 ret_gl_code_combination_id => l_new_gl_code_combination_id,
2220 retcode => l_autopop_status);
2221
2222 IF (l_autopop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
2223 (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2224 l_autopop_error := 'AUTO_POP_EXP_ERROR';
2225 IF (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2226 l_autopop_error := 'AUTO_POP_NO_VALUE';
2227 END IF;
2228 IF (l_asg_start_date <= g_enc_org_end_date) THEN
2229 orig_ci.gl_code_combination_id(g_orig_pointer) := l_gl_code_combination_id;
2230 orig_ci.project_id(g_orig_pointer) := l_project_id;
2231 orig_ci.task_id(g_orig_pointer) := l_task_id;
2232 orig_ci.award_id(g_orig_pointer) := l_award_id;
2233 orig_ci.expenditure_organization_id(g_orig_pointer) := l_expenditure_org_id;
2234 orig_ci.expenditure_type(g_orig_pointer) := l_expenditure_type;
2235 g_orig_pointer := g_orig_pointer + 1;
2236 l_enc_period_count := r_enc_period.r_time_period_id.COUNT + 1;
2237 r_enc_period.r_period_ind(l_enc_period_count) := r_enc_period.r_period_ind(l_chunk_pointer);
2238 r_enc_period.r_period_start_date(l_enc_period_count) := r_enc_period.r_period_start_date(l_chunk_pointer);
2239 r_enc_period.r_period_end_date(l_enc_period_count) := r_enc_period.r_period_end_date(l_chunk_pointer);
2240 r_enc_period.r_asg_start_date(l_enc_period_count) := r_enc_period.r_asg_start_date(l_chunk_pointer);
2241 r_enc_period.r_asg_end_date(l_enc_period_count) := LEAST(r_enc_period.r_asg_end_date(l_chunk_pointer), g_enc_org_end_date);
2242 r_enc_period.r_effective_date(l_enc_period_count) := r_enc_period.r_effective_date(l_chunk_pointer);
2243 r_enc_period.r_time_period_id(l_enc_period_count) := r_enc_period.r_time_period_id(l_chunk_pointer);
2244 r_enc_period.r_process_flag(l_enc_period_count) := 'SA';
2245 r_enc_period.r_schedule_percent(l_enc_period_count) := 100;
2246 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND(r_enc_period.r_encumbrance_amount(l_chunk_pointer) *
2247 (psp_general.business_days(l_asg_start_date, r_enc_period.r_asg_end_date(l_enc_period_count)) / l_bus_days_in_chunk));
2248 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND((r_enc_period.r_encumbrance_amount(l_chunk_pointer) * l_schedule_percent/100),g_ext_precision);
2249 r_enc_period.r_period_amount(l_enc_period_count) := r_enc_period.r_period_amount(l_chunk_pointer);
2250 r_enc_period.r_reason_code(l_enc_period_count) := l_autopop_error;
2251 END IF;
2252 add_cel_warnings(p_start_date => r_enc_period.r_asg_start_date(l_chunk_pointer),
2253 p_hierarchy_code => 'SA',
2254 p_end_date => r_enc_period.r_asg_end_date(l_chunk_pointer),
2255 p_warning_code => 'AUTOPOP',
2256 p_gl_ccid => l_gl_code_combination_id,
2257 p_project_id => l_project_id,
2258 p_task_id => l_task_id,
2259 p_award_id => l_award_id,
2260 p_exp_org_id => l_expenditure_org_id,
2261 p_exp_type => l_expenditure_type,
2262 p_effective_date => l_effective_date,
2263 p_error_status => l_autopop_error);
2264 hr_utility.trace('Posting to suspense account');
2265 ELSE
2266 IF (l_acct_type = 'E') THEN
2267 psp_enc_pre_process.validate_poeta (p_project_id => l_project_id,
2268 p_task_id => l_task_id,
2269 p_award_id => l_award_id,
2270 p_expenditure_type => l_new_expenditure_type,
2271 p_expenditure_organization_id => l_expenditure_org_id,
2272 p_payroll_id => p_payroll_id,
2273 p_start_date => l_poeta_start_date,
2274 p_end_date => l_poeta_end_date,
2275 p_return_status => p_return_status);
2276 IF p_return_status <> fnd_api.g_ret_sts_success THEN
2277 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2278 END IF;
2279 l_expenditure_type := l_new_expenditure_type;
2280 ELSE
2281 l_gl_code_combination_id := l_new_gl_code_combination_id;
2282 END IF;
2283 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2284 END IF;
2285 ELSE
2286 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2287 END IF;
2288 END IF;
2289 END IF;
2290 END LOOP;
2291 ELSIF (l_process_flag = 'EG') THEN
2292 FOR recno IN 1..r_ec.line_account_id.COUNT
2293 LOOP
2294 IF ((l_asg_start_date <= r_ec.end_date_active(recno))
2295 AND (l_asg_end_date >= r_ec.start_date_active(recno))) THEN
2296 g_ec_pointer := recno;
2297 l_schedule_line_id := r_ec.line_account_id(recno);
2298 l_gl_code_combination_id := r_ec.gl_code_combination_id(recno);
2299 l_project_id := r_ec.project_id(recno);
2300 l_task_id := r_ec.task_id(recno);
2301 l_award_id := r_ec.award_id(recno);
2302 l_schedule_percent := r_ec.percent(recno);
2303 l_expenditure_type := r_ec.expenditure_type(recno);
2304 l_expenditure_org_id := r_ec.expenditure_organization_id(recno);
2305 l_start_date_active := r_ec.start_date_active(recno);
2306 l_end_date_active := r_ec.end_date_active(recno);
2307 l_poeta_start_date := r_ec.poeta_start_date(recno);
2308 l_poeta_end_date := r_ec.poeta_end_date(recno);
2309 l_attribute_category := r_ec.attribute_category(recno);
2310 l_attribute1 := r_ec.attribute1(recno);
2311 l_attribute2 := r_ec.attribute2(recno);
2312 l_attribute3 := r_ec.attribute3(recno);
2313 l_attribute4 := r_ec.attribute4(recno);
2314 l_attribute5 := r_ec.attribute5(recno);
2315 l_attribute6 := r_ec.attribute6(recno);
2316 l_attribute7 := r_ec.attribute7(recno);
2317 l_attribute8 := r_ec.attribute8(recno);
2318 l_attribute9 := r_ec.attribute9(recno);
2319 l_attribute10 := r_ec.attribute10(recno);
2320 l_acct_type := r_ec.acct_type(recno);
2321
2322 IF (g_uom = 'H' AND l_gl_code_combination_id IS NOT NULL) THEN
2323 log_gl_hours_message;
2324 ELSE
2325 IF (g_eg_autopop = 'Y') THEN
2326 psp_autopop.main(p_acct_type => l_acct_type,
2327 p_person_id => l_person_id,
2328 p_assignment_id => p_assignment_id,
2329 p_element_type_id => p_element_type_id,
2330 p_project_id => l_project_id,
2331 p_expenditure_organization_id => l_expenditure_org_id,
2332 p_task_id => l_task_id,
2333 p_award_id => l_award_id,
2334 p_expenditure_type => l_expenditure_type,
2335 p_gl_code_combination_id => l_gl_code_combination_id,
2336 p_payroll_date => l_asg_end_date, --- replaced l_effective_date..5592784
2337 p_set_of_books_id => g_set_of_books_id,
2338 p_business_group_id => g_business_group_id,
2339 ret_expenditure_type => l_new_expenditure_type,
2340 ret_gl_code_combination_id => l_new_gl_code_combination_id,
2341 retcode => l_autopop_status);
2342
2343 IF (l_autopop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
2344 (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2345 l_autopop_error := 'AUTO_POP_EXP_ERROR';
2346 IF (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2347 l_autopop_error := 'AUTO_POP_NO_VALUE';
2348 END IF;
2349 IF (l_asg_start_date <= g_enc_org_end_date) THEN
2350 orig_ci.gl_code_combination_id(g_orig_pointer) := l_gl_code_combination_id;
2351 orig_ci.project_id(g_orig_pointer) := l_project_id;
2352 orig_ci.task_id(g_orig_pointer) := l_task_id;
2353 orig_ci.award_id(g_orig_pointer) := l_award_id;
2354 orig_ci.expenditure_organization_id(g_orig_pointer) := l_expenditure_org_id;
2355 orig_ci.expenditure_type(g_orig_pointer) := l_expenditure_type;
2356 g_orig_pointer := g_orig_pointer + 1;
2357 l_enc_period_count := r_enc_period.r_time_period_id.COUNT + 1;
2358 r_enc_period.r_period_ind(l_enc_period_count) := r_enc_period.r_period_ind(l_chunk_pointer);
2359 r_enc_period.r_period_start_date(l_enc_period_count) := r_enc_period.r_period_start_date(l_chunk_pointer);
2360 r_enc_period.r_period_end_date(l_enc_period_count) := r_enc_period.r_period_end_date(l_chunk_pointer);
2361 r_enc_period.r_asg_start_date(l_enc_period_count) := r_enc_period.r_asg_start_date(l_chunk_pointer);
2362 r_enc_period.r_asg_end_date(l_enc_period_count) := LEAST(r_enc_period.r_asg_end_date(l_chunk_pointer), g_enc_org_end_date);
2363 r_enc_period.r_effective_date(l_enc_period_count) := r_enc_period.r_effective_date(l_chunk_pointer);
2364 r_enc_period.r_time_period_id(l_enc_period_count) := r_enc_period.r_time_period_id(l_chunk_pointer);
2365 r_enc_period.r_process_flag(l_enc_period_count) := 'SA';
2366 r_enc_period.r_schedule_percent(l_enc_period_count) := 100;
2367 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND(r_enc_period.r_encumbrance_amount(l_chunk_pointer) *
2368 (psp_general.business_days(l_asg_start_date, r_enc_period.r_asg_end_date(l_enc_period_count)) / l_bus_days_in_chunk));
2369 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND((r_enc_period.r_encumbrance_amount(l_chunk_pointer) * l_schedule_percent/100),g_ext_precision);
2370 r_enc_period.r_period_amount(l_enc_period_count) := r_enc_period.r_period_amount(l_chunk_pointer);
2371 r_enc_period.r_reason_code(l_enc_period_count) := l_autopop_error;
2372 END IF;
2373 add_cel_warnings(p_start_date => r_enc_period.r_asg_start_date(l_chunk_pointer),
2374 p_hierarchy_code => 'SA',
2375 p_end_date => r_enc_period.r_asg_end_date(l_chunk_pointer),
2376 p_warning_code => 'AUTOPOP',
2377 p_gl_ccid => l_gl_code_combination_id,
2378 p_project_id => l_project_id,
2379 p_task_id => l_task_id,
2380 p_award_id => l_award_id,
2381 p_exp_org_id => l_expenditure_org_id,
2382 p_exp_type => l_expenditure_type,
2383 p_effective_date => l_effective_date,
2384 p_error_status => l_autopop_error);
2385 hr_utility.trace('Posting to suspense account');
2386 ELSE
2387 IF (l_acct_type = 'E') THEN
2388 psp_enc_pre_process.validate_poeta (p_project_id => l_project_id,
2389 p_task_id => l_task_id,
2390 p_award_id => l_award_id,
2391 p_expenditure_type => l_new_expenditure_type,
2392 p_expenditure_organization_id => l_expenditure_org_id,
2393 p_payroll_id => p_payroll_id,
2394 p_start_date => l_poeta_start_date,
2395 p_end_date => l_poeta_end_date,
2396 p_return_status => p_return_status);
2397 IF p_return_status <> fnd_api.g_ret_sts_success THEN
2398 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2399 END IF;
2400 l_expenditure_type := l_new_expenditure_type;
2401 ELSE
2402 l_gl_code_combination_id := l_new_gl_code_combination_id;
2403 END IF;
2404 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2405 END IF;
2406 ELSE
2407 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2408 END IF;
2409 END IF;
2410 END IF;
2411 END LOOP;
2412 ELSIF (l_process_flag = 'A') THEN
2413 FOR recno IN 1..r_asg.line_account_id.COUNT
2414 LOOP
2415 IF ((l_asg_start_date <= r_asg.end_date_active(recno))
2416 AND (l_asg_end_date >= r_asg.start_date_active(recno))) THEN
2417 g_asg_pointer := recno;
2418 l_schedule_line_id := r_asg.line_account_id(recno);
2419 l_gl_code_combination_id := r_asg.gl_code_combination_id(recno);
2420 l_project_id := r_asg.project_id(recno);
2421 l_task_id := r_asg.task_id(recno);
2422 l_award_id := r_asg.award_id(recno);
2423 l_schedule_percent := r_asg.percent(recno);
2424 l_expenditure_type := r_asg.expenditure_type(recno);
2425 l_expenditure_org_id := r_asg.expenditure_organization_id(recno);
2426 l_start_date_active := r_asg.start_date_active(recno);
2427 l_end_date_active := r_asg.end_date_active(recno);
2428 l_poeta_start_date := r_asg.poeta_start_date(recno);
2429 l_poeta_end_date := r_asg.poeta_end_date(recno);
2430 l_attribute_category := r_asg.attribute_category(recno);
2431 l_attribute1 := r_asg.attribute1(recno);
2432 l_attribute2 := r_asg.attribute2(recno);
2433 l_attribute3 := r_asg.attribute3(recno);
2434 l_attribute4 := r_asg.attribute4(recno);
2435 l_attribute5 := r_asg.attribute5(recno);
2436 l_attribute6 := r_asg.attribute6(recno);
2437 l_attribute7 := r_asg.attribute7(recno);
2438 l_attribute8 := r_asg.attribute8(recno);
2439 l_attribute9 := r_asg.attribute9(recno);
2440 l_attribute10 := r_asg.attribute10(recno);
2441 l_acct_type := r_asg.acct_type(recno);
2442
2443 IF (g_uom = 'H' AND l_gl_code_combination_id IS NOT NULL) THEN
2444 log_gl_hours_message;
2445 ELSE
2446 IF (g_as_autopop = 'Y') THEN
2447 psp_autopop.main(p_acct_type => l_acct_type,
2448 p_person_id => l_person_id,
2449 p_assignment_id => p_assignment_id,
2450 p_element_type_id => p_element_type_id,
2451 p_project_id => l_project_id,
2452 p_expenditure_organization_id => l_expenditure_org_id,
2453 p_task_id => l_task_id,
2454 p_award_id => l_award_id,
2455 p_expenditure_type => l_expenditure_type,
2456 p_gl_code_combination_id => l_gl_code_combination_id,
2457 p_payroll_date => l_asg_end_date, --- replaced l_effective_date..5592784
2458 p_set_of_books_id => g_set_of_books_id,
2459 p_business_group_id => g_business_group_id,
2460 ret_expenditure_type => l_new_expenditure_type,
2461 ret_gl_code_combination_id => l_new_gl_code_combination_id,
2462 retcode => l_autopop_status);
2463
2464 IF (l_autopop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
2465 (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2466 l_autopop_error := 'AUTO_POP_EXP_ERROR';
2467 IF (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2468 l_autopop_error := 'AUTO_POP_NO_VALUE';
2469 END IF;
2470 IF (l_asg_start_date <= g_enc_org_end_date) THEN
2471 orig_ci.gl_code_combination_id(g_orig_pointer) := l_gl_code_combination_id;
2472 orig_ci.project_id(g_orig_pointer) := l_project_id;
2473 orig_ci.task_id(g_orig_pointer) := l_task_id;
2474 orig_ci.award_id(g_orig_pointer) := l_award_id;
2475 orig_ci.expenditure_organization_id(g_orig_pointer) := l_expenditure_org_id;
2476 orig_ci.expenditure_type(g_orig_pointer) := l_expenditure_type;
2477 g_orig_pointer := g_orig_pointer + 1;
2478 l_enc_period_count := r_enc_period.r_time_period_id.COUNT + 1;
2479 r_enc_period.r_period_ind(l_enc_period_count) := r_enc_period.r_period_ind(l_chunk_pointer);
2480 r_enc_period.r_period_start_date(l_enc_period_count) := r_enc_period.r_period_start_date(l_chunk_pointer);
2481 r_enc_period.r_period_end_date(l_enc_period_count) := r_enc_period.r_period_end_date(l_chunk_pointer);
2482 r_enc_period.r_asg_start_date(l_enc_period_count) := r_enc_period.r_asg_start_date(l_chunk_pointer);
2483 r_enc_period.r_asg_end_date(l_enc_period_count) := LEAST(r_enc_period.r_asg_end_date(l_chunk_pointer), g_enc_org_end_date);
2484 r_enc_period.r_effective_date(l_enc_period_count) := r_enc_period.r_effective_date(l_chunk_pointer);
2485 r_enc_period.r_time_period_id(l_enc_period_count) := r_enc_period.r_time_period_id(l_chunk_pointer);
2486 r_enc_period.r_process_flag(l_enc_period_count) := 'SA';
2487 r_enc_period.r_schedule_percent(l_enc_period_count) := 100;
2488 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND(r_enc_period.r_encumbrance_amount(l_chunk_pointer) *
2489 (psp_general.business_days(l_asg_start_date, r_enc_period.r_asg_end_date(l_enc_period_count)) / l_bus_days_in_chunk));
2490 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND((r_enc_period.r_encumbrance_amount(l_chunk_pointer) * l_schedule_percent/100),g_ext_precision);
2491 r_enc_period.r_period_amount(l_enc_period_count) := r_enc_period.r_period_amount(l_chunk_pointer);
2492 r_enc_period.r_reason_code(l_enc_period_count) := l_autopop_error;
2493 END IF;
2494 add_cel_warnings(p_start_date => r_enc_period.r_asg_start_date(l_chunk_pointer),
2495 p_hierarchy_code => 'SA',
2496 p_end_date => r_enc_period.r_asg_end_date(l_chunk_pointer),
2497 p_warning_code => 'AUTOPOP',
2498 p_gl_ccid => l_gl_code_combination_id,
2499 p_project_id => l_project_id,
2500 p_task_id => l_task_id,
2501 p_award_id => l_award_id,
2502 p_exp_org_id => l_expenditure_org_id,
2503 p_exp_type => l_expenditure_type,
2504 p_effective_date => l_effective_date,
2505 p_error_status => l_autopop_error);
2506 hr_utility.trace('Posting to suspense account');
2507 ELSE
2508 IF (l_acct_type = 'E') THEN
2509 psp_enc_pre_process.validate_poeta (p_project_id => l_project_id,
2510 p_task_id => l_task_id,
2511 p_award_id => l_award_id,
2512 p_expenditure_type => l_new_expenditure_type,
2513 p_expenditure_organization_id => l_expenditure_org_id,
2514 p_payroll_id => p_payroll_id,
2515 p_start_date => l_poeta_start_date,
2516 p_end_date => l_poeta_end_date,
2517 p_return_status => p_return_status);
2518 IF p_return_status <> fnd_api.g_ret_sts_success THEN
2519 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2520 END IF;
2521 l_expenditure_type := l_new_expenditure_type;
2522 ELSE
2523 l_gl_code_combination_id := l_new_gl_code_combination_id;
2524 END IF;
2525 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2526 END IF;
2527 ELSE
2528 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2529 END IF;
2530 END IF;
2531 End IF;
2532 END LOOP;
2533 ELSIF (l_process_flag = 'GE') THEN
2534 FOR recno IN 1..r_gee.line_account_id.COUNT
2535 LOOP
2536 g_ge_pointer := recno;
2537 EXIT WHEN ((l_asg_start_date <= r_gee.end_date_active(recno))
2538 AND (l_asg_end_date >= r_gee.start_date_active(recno)));
2539 END LOOP;
2540 FOR recno IN g_ge_pointer..r_gee.line_account_id.COUNT
2541 LOOP
2542 EXIT WHEN (NOT ((l_asg_start_date <= r_gee.end_date_active(recno))
2543 AND (l_asg_end_date >= r_gee.start_date_active(recno))));
2544
2545 g_ge_pointer := recno;
2546 l_element_account_id := r_gee.line_account_id(recno);
2547 l_gl_code_combination_id := r_gee.gl_code_combination_id(recno);
2548 l_project_id := r_gee.project_id(recno);
2549 l_task_id := r_gee.task_id(recno);
2550 l_award_id := r_gee.award_id(recno);
2551 l_schedule_percent := r_gee.percent(recno);
2552 l_expenditure_type := r_gee.expenditure_type(recno);
2553 l_expenditure_org_id := r_gee.expenditure_organization_id(recno);
2554 l_start_date_active := r_gee.start_date_active(recno);
2555 l_end_date_active := r_gee.end_date_active(recno);
2556 l_poeta_start_date := r_gee.poeta_start_date(recno);
2557 l_poeta_end_date := r_gee.poeta_end_date(recno);
2558 l_attribute_category := r_gee.attribute_category(recno);
2559 l_attribute1 := r_gee.attribute1(recno);
2560 l_attribute2 := r_gee.attribute2(recno);
2561 l_attribute3 := r_gee.attribute3(recno);
2562 l_attribute4 := r_gee.attribute4(recno);
2563 l_attribute5 := r_gee.attribute5(recno);
2564 l_attribute6 := r_gee.attribute6(recno);
2565 l_attribute7 := r_gee.attribute7(recno);
2566 l_attribute8 := r_gee.attribute8(recno);
2567 l_attribute9 := r_gee.attribute9(recno);
2568 l_attribute10 := r_gee.attribute10(recno);
2569 l_acct_type := r_gee.acct_type(recno);
2570
2571 IF (g_uom = 'H' AND l_gl_code_combination_id IS NOT NULL) THEN
2572 log_gl_hours_message;
2573 ELSE
2574
2575 IF (g_ge_autopop = 'Y') THEN
2576 psp_autopop.main(p_acct_type => l_acct_type,
2577 p_person_id => l_person_id,
2578 p_assignment_id => p_assignment_id,
2579 p_element_type_id => p_element_type_id,
2580 p_project_id => l_project_id,
2581 p_expenditure_organization_id => l_expenditure_org_id,
2582 p_task_id => l_task_id,
2583 p_award_id => l_award_id,
2584 p_expenditure_type => l_expenditure_type,
2585 p_gl_code_combination_id => l_gl_code_combination_id,
2586 p_payroll_date => l_asg_end_date, --- replaced l_effective_date..5592784
2587 p_set_of_books_id => g_set_of_books_id,
2588 p_business_group_id => g_business_group_id,
2589 ret_expenditure_type => l_new_expenditure_type,
2590 ret_gl_code_combination_id => l_new_gl_code_combination_id,
2591 retcode => l_autopop_status);
2592
2593 IF (l_autopop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
2594 (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2595 l_autopop_error := 'AUTO_POP_EXP_ERROR';
2596 IF (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2597 l_autopop_error := 'AUTO_POP_NO_VALUE';
2598 END IF;
2599 IF (l_asg_start_date <= g_enc_org_end_date) THEN
2600 orig_ci.gl_code_combination_id(g_orig_pointer) := l_gl_code_combination_id;
2601 orig_ci.project_id(g_orig_pointer) := l_project_id;
2602 orig_ci.task_id(g_orig_pointer) := l_task_id;
2603 orig_ci.award_id(g_orig_pointer) := l_award_id;
2604 orig_ci.expenditure_organization_id(g_orig_pointer) := l_expenditure_org_id;
2605 orig_ci.expenditure_type(g_orig_pointer) := l_expenditure_type;
2606 g_orig_pointer := g_orig_pointer + 1;
2607 l_enc_period_count := r_enc_period.r_time_period_id.COUNT + 1;
2608 r_enc_period.r_period_ind(l_enc_period_count) := r_enc_period.r_period_ind(l_chunk_pointer);
2609 r_enc_period.r_period_start_date(l_enc_period_count) := r_enc_period.r_period_start_date(l_chunk_pointer);
2610 r_enc_period.r_period_end_date(l_enc_period_count) := r_enc_period.r_period_end_date(l_chunk_pointer);
2611 r_enc_period.r_asg_start_date(l_enc_period_count) := r_enc_period.r_asg_start_date(l_chunk_pointer);
2612 r_enc_period.r_asg_end_date(l_enc_period_count) := LEAST(r_enc_period.r_asg_end_date(l_chunk_pointer), g_enc_org_end_date);
2613 r_enc_period.r_effective_date(l_enc_period_count) := r_enc_period.r_effective_date(l_chunk_pointer);
2614 r_enc_period.r_time_period_id(l_enc_period_count) := r_enc_period.r_time_period_id(l_chunk_pointer);
2615 r_enc_period.r_process_flag(l_enc_period_count) := 'SA';
2616 r_enc_period.r_schedule_percent(l_enc_period_count) := 100;
2617 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND(r_enc_period.r_encumbrance_amount(l_chunk_pointer) *
2618 (psp_general.business_days(l_asg_start_date, r_enc_period.r_asg_end_date(l_enc_period_count)) / l_bus_days_in_chunk));
2619 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND((r_enc_period.r_encumbrance_amount(l_chunk_pointer) * l_schedule_percent/100),g_ext_precision);
2620 r_enc_period.r_period_amount(l_enc_period_count) := r_enc_period.r_period_amount(l_chunk_pointer);
2621 r_enc_period.r_reason_code(l_enc_period_count) := l_autopop_error;
2622 END IF;
2623 add_cel_warnings(p_start_date => r_enc_period.r_asg_start_date(l_chunk_pointer),
2624 p_hierarchy_code => 'SA',
2625 p_end_date => r_enc_period.r_asg_end_date(l_chunk_pointer),
2626 p_warning_code => 'AUTOPOP',
2627 p_gl_ccid => l_gl_code_combination_id,
2628 p_project_id => l_project_id,
2629 p_task_id => l_task_id,
2630 p_award_id => l_award_id,
2631 p_exp_org_id => l_expenditure_org_id,
2632 p_exp_type => l_expenditure_type,
2633 p_effective_date => l_effective_date,
2634 p_error_status => l_autopop_error);
2635 hr_utility.trace('Posting to suspense account');
2636 ELSE
2637 IF (l_acct_type = 'E') THEN
2638 psp_enc_pre_process.validate_poeta (p_project_id => l_project_id,
2639 p_task_id => l_task_id,
2640 p_award_id => l_award_id,
2641 p_expenditure_type => l_new_expenditure_type,
2642 p_expenditure_organization_id => l_expenditure_org_id,
2643 p_payroll_id => p_payroll_id,
2644 p_start_date => l_poeta_start_date,
2645 p_end_date => l_poeta_end_date,
2646 p_return_status => p_return_status);
2647 IF p_return_status <> fnd_api.g_ret_sts_success THEN
2648 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2649 END IF;
2650 l_expenditure_type := l_new_expenditure_type;
2651 ELSE
2652 l_gl_code_combination_id := l_new_gl_code_combination_id;
2653 END IF;
2654 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2655 END IF;
2656 ELSE
2657 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2658 END IF;
2659 END IF;
2660 END LOOP;
2661 ELSIF (l_process_flag = 'DS') THEN
2662 FOR recno IN 1..r_odls.line_account_id.COUNT
2663 LOOP
2664 g_odls_pointer := recno;
2665 EXIT WHEN ((l_asg_start_date <= r_odls.end_date_active(recno))
2666 AND (l_asg_end_date >= r_odls.start_date_active(recno)));
2667 END LOOP;
2668 FOR recno IN g_odls_pointer..r_odls.line_account_id.COUNT
2669 LOOP
2670 EXIT WHEN (NOT ((l_asg_start_date <= r_odls.end_date_active(recno))
2671 AND (l_asg_end_date >= r_odls.start_date_active(recno))));
2672
2673 g_odls_pointer := recno;
2674 l_org_schedule_id := r_odls.line_account_id(recno);
2675 l_gl_code_combination_id := r_odls.gl_code_combination_id(recno);
2676 l_project_id := r_odls.project_id(recno);
2677 l_task_id := r_odls.task_id(recno);
2678 l_award_id := r_odls.award_id(recno);
2679 l_schedule_percent := r_odls.percent(recno);
2680 l_expenditure_type := r_odls.expenditure_type(recno);
2681 l_expenditure_org_id := r_odls.expenditure_organization_id(recno);
2682 l_start_date_active := r_odls.start_date_active(recno);
2683 l_end_date_active := r_odls.end_date_active(recno);
2684 l_poeta_start_date := r_odls.poeta_start_date(recno);
2685 l_poeta_end_date := r_odls.poeta_end_date(recno);
2686 l_attribute_category := r_odls.attribute_category(recno);
2687 l_attribute1 := r_odls.attribute1(recno);
2688 l_attribute2 := r_odls.attribute2(recno);
2689 l_attribute3 := r_odls.attribute3(recno);
2690 l_attribute4 := r_odls.attribute4(recno);
2691 l_attribute5 := r_odls.attribute5(recno);
2692 l_attribute6 := r_odls.attribute6(recno);
2693 l_attribute7 := r_odls.attribute7(recno);
2694 l_attribute8 := r_odls.attribute8(recno);
2695 l_attribute9 := r_odls.attribute9(recno);
2696 l_attribute10 := r_odls.attribute10(recno);
2697 l_acct_type := r_odls.acct_type(recno);
2698
2699 IF (g_uom = 'H' AND l_gl_code_combination_id IS NOT NULL) THEN
2700 log_gl_hours_message;
2701 ELSE
2702 IF (g_ds_autopop = 'Y') THEN
2703 psp_autopop.main(p_acct_type => l_acct_type,
2704 p_person_id => l_person_id,
2705 p_assignment_id => p_assignment_id,
2706 p_element_type_id => p_element_type_id,
2707 p_project_id => l_project_id,
2708 p_expenditure_organization_id => l_expenditure_org_id,
2709 p_task_id => l_task_id,
2710 p_award_id => l_award_id,
2711 p_expenditure_type => l_expenditure_type,
2712 p_gl_code_combination_id => l_gl_code_combination_id,
2713 p_payroll_date => l_asg_end_date, --- replaced l_effective_date..5592784
2714 p_set_of_books_id => g_set_of_books_id,
2715 p_business_group_id => g_business_group_id,
2716 ret_expenditure_type => l_new_expenditure_type,
2717 ret_gl_code_combination_id => l_new_gl_code_combination_id,
2718 retcode => l_autopop_status);
2719
2720 IF (l_autopop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
2721 (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2722 l_autopop_error := 'AUTO_POP_EXP_ERROR';
2723 IF (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2724 l_autopop_error := 'AUTO_POP_NO_VALUE';
2725 END IF;
2726 IF (l_asg_start_date <= g_enc_org_end_date) THEN
2727 orig_ci.gl_code_combination_id(g_orig_pointer) := l_gl_code_combination_id;
2728 orig_ci.project_id(g_orig_pointer) := l_project_id;
2729 orig_ci.task_id(g_orig_pointer) := l_task_id;
2730 orig_ci.award_id(g_orig_pointer) := l_award_id;
2731 orig_ci.expenditure_organization_id(g_orig_pointer) := l_expenditure_org_id;
2732 orig_ci.expenditure_type(g_orig_pointer) := l_expenditure_type;
2733 g_orig_pointer := g_orig_pointer + 1;
2734 l_enc_period_count := r_enc_period.r_time_period_id.COUNT + 1;
2735 r_enc_period.r_period_ind(l_enc_period_count) := r_enc_period.r_period_ind(l_chunk_pointer);
2736 r_enc_period.r_period_start_date(l_enc_period_count) := r_enc_period.r_period_start_date(l_chunk_pointer);
2737 r_enc_period.r_period_end_date(l_enc_period_count) := r_enc_period.r_period_end_date(l_chunk_pointer);
2738 r_enc_period.r_asg_start_date(l_enc_period_count) := r_enc_period.r_asg_start_date(l_chunk_pointer);
2739 r_enc_period.r_asg_end_date(l_enc_period_count) := LEAST(r_enc_period.r_asg_end_date(l_chunk_pointer), g_enc_org_end_date);
2740 r_enc_period.r_effective_date(l_enc_period_count) := r_enc_period.r_effective_date(l_chunk_pointer);
2741 r_enc_period.r_time_period_id(l_enc_period_count) := r_enc_period.r_time_period_id(l_chunk_pointer);
2742 r_enc_period.r_process_flag(l_enc_period_count) := 'SA';
2743 r_enc_period.r_schedule_percent(l_enc_period_count) := 100;
2744 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND(r_enc_period.r_encumbrance_amount(l_chunk_pointer) *
2745 (psp_general.business_days(l_asg_start_date, r_enc_period.r_asg_end_date(l_enc_period_count)) / l_bus_days_in_chunk));
2746 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND((r_enc_period.r_encumbrance_amount(l_chunk_pointer) * l_schedule_percent/100),g_ext_precision);
2747 r_enc_period.r_period_amount(l_enc_period_count) := r_enc_period.r_period_amount(l_chunk_pointer);
2748 r_enc_period.r_reason_code(l_enc_period_count) := l_autopop_error;
2749 END IF;
2750 add_cel_warnings(p_start_date => r_enc_period.r_asg_start_date(l_chunk_pointer),
2751 p_hierarchy_code => 'SA',
2752 p_end_date => r_enc_period.r_asg_end_date(l_chunk_pointer),
2753 p_warning_code => 'AUTOPOP',
2754 p_gl_ccid => l_gl_code_combination_id,
2755 p_project_id => l_project_id,
2756 p_task_id => l_task_id,
2757 p_award_id => l_award_id,
2758 p_exp_org_id => l_expenditure_org_id,
2759 p_exp_type => l_expenditure_type,
2760 p_effective_date => l_effective_date,
2761 p_error_status => l_autopop_error);
2762 hr_utility.trace('Posting to suspense account');
2763 ELSE
2764 IF (l_acct_type = 'E') THEN
2765 psp_enc_pre_process.validate_poeta (p_project_id => l_project_id,
2766 p_task_id => l_task_id,
2767 p_award_id => l_award_id,
2768 p_expenditure_type => l_new_expenditure_type,
2769 p_expenditure_organization_id => l_expenditure_org_id,
2770 p_payroll_id => p_payroll_id,
2771 p_start_date => l_poeta_start_date,
2772 p_end_date => l_poeta_end_date,
2773 p_return_status => p_return_status);
2774 IF p_return_status <> fnd_api.g_ret_sts_success THEN
2775 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2776 END IF;
2777 l_expenditure_type := l_new_expenditure_type;
2778 ELSE
2779 l_gl_code_combination_id := l_new_gl_code_combination_id;
2780 END IF;
2781 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2782 END IF;
2783 ELSE
2784 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2785 END IF;
2786 END IF;
2787 END LOOP;
2788 ELSIF (l_process_flag = 'DA') THEN
2789 FOR recno IN 1..r_da.line_account_id.COUNT
2790 LOOP
2791 g_da_pointer := recno;
2792 EXIT WHEN ((l_asg_start_date <= r_da.end_date_active(recno))
2793 AND (l_asg_end_date >= r_da.start_date_active(recno)));
2794 END LOOP;
2795
2796 FOR recno IN g_da_pointer..r_da.line_account_id.COUNT
2797 LOOP
2798 EXIT WHEN (NOT ((l_asg_start_date <= r_da.end_date_active(recno))
2799 AND (l_asg_end_date >= r_da.start_date_active(recno))));
2800
2801 g_da_pointer := recno;
2802 l_default_account_id := r_da.line_account_id(recno);
2803 l_gl_code_combination_id := r_da.gl_code_combination_id(recno);
2804 l_project_id := r_da.project_id(recno);
2805 l_task_id := r_da.task_id(recno);
2806 l_award_id := r_da.award_id(recno);
2807 l_schedule_percent := r_da.percent(recno);
2808 l_expenditure_type := r_da.expenditure_type(recno);
2809 l_expenditure_org_id := r_da.expenditure_organization_id(recno);
2810 l_start_date_active := r_da.start_date_active(recno);
2811 l_end_date_active := r_da.end_date_active(recno);
2812 l_poeta_start_date := r_da.poeta_start_date(recno);
2813 l_poeta_end_date := r_da.poeta_end_date(recno);
2814 l_attribute_category := r_da.attribute_category(recno);
2815 l_attribute1 := r_da.attribute1(recno);
2816 l_attribute2 := r_da.attribute2(recno);
2817 l_attribute3 := r_da.attribute3(recno);
2818 l_attribute4 := r_da.attribute4(recno);
2819 l_attribute5 := r_da.attribute5(recno);
2820 l_attribute6 := r_da.attribute6(recno);
2821 l_attribute7 := r_da.attribute7(recno);
2822 l_attribute8 := r_da.attribute8(recno);
2823 l_attribute9 := r_da.attribute9(recno);
2824 l_attribute10 := r_da.attribute10(recno);
2825 l_acct_type := r_da.acct_type(recno);
2826
2827 IF (g_uom = 'H' AND l_gl_code_combination_id IS NOT NULL) THEN
2828 log_gl_hours_message;
2829 ELSE
2830
2831 IF (g_da_autopop = 'Y') THEN
2832 psp_autopop.main(p_acct_type => l_acct_type,
2833 p_person_id => l_person_id,
2834 p_assignment_id => p_assignment_id,
2835 p_element_type_id => p_element_type_id,
2836 p_project_id => l_project_id,
2837 p_expenditure_organization_id => l_expenditure_org_id,
2838 p_task_id => l_task_id,
2839 p_award_id => l_award_id,
2840 p_expenditure_type => l_expenditure_type,
2841 p_gl_code_combination_id => l_gl_code_combination_id,
2842 p_payroll_date => l_asg_end_date, --- replaced l_effective_date..5592784
2843 p_set_of_books_id => g_set_of_books_id,
2844 p_business_group_id => g_business_group_id,
2845 ret_expenditure_type => l_new_expenditure_type,
2846 ret_gl_code_combination_id => l_new_gl_code_combination_id,
2847 retcode => l_autopop_status);
2848
2849 IF (l_autopop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
2850 (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2851 l_autopop_error := 'AUTO_POP_EXP_ERROR';
2852 IF (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2853 l_autopop_error := 'AUTO_POP_NO_VALUE';
2854 END IF;
2855 IF (l_asg_start_date <= g_enc_org_end_date) THEN
2856 orig_ci.gl_code_combination_id(g_orig_pointer) := l_gl_code_combination_id;
2857 orig_ci.project_id(g_orig_pointer) := l_project_id;
2858 orig_ci.task_id(g_orig_pointer) := l_task_id;
2859 orig_ci.award_id(g_orig_pointer) := l_award_id;
2860 orig_ci.expenditure_organization_id(g_orig_pointer) := l_expenditure_org_id;
2861 orig_ci.expenditure_type(g_orig_pointer) := l_expenditure_type;
2862 g_orig_pointer := g_orig_pointer + 1;
2863 l_enc_period_count := r_enc_period.r_time_period_id.COUNT + 1;
2864 r_enc_period.r_period_ind(l_enc_period_count) := r_enc_period.r_period_ind(l_chunk_pointer);
2865 r_enc_period.r_period_start_date(l_enc_period_count) := r_enc_period.r_period_start_date(l_chunk_pointer);
2866 r_enc_period.r_period_end_date(l_enc_period_count) := r_enc_period.r_period_end_date(l_chunk_pointer);
2867 r_enc_period.r_asg_start_date(l_enc_period_count) := LEAST(r_enc_period.r_asg_start_date(l_chunk_pointer), g_enc_org_end_date);
2868 r_enc_period.r_asg_end_date(l_enc_period_count) := r_enc_period.r_asg_end_date(l_chunk_pointer);
2869 r_enc_period.r_effective_date(l_enc_period_count) := r_enc_period.r_effective_date(l_chunk_pointer);
2870 r_enc_period.r_time_period_id(l_enc_period_count) := r_enc_period.r_time_period_id(l_chunk_pointer);
2871 r_enc_period.r_process_flag(l_enc_period_count) := 'SA';
2872 r_enc_period.r_schedule_percent(l_enc_period_count) := 100;
2873 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND(r_enc_period.r_encumbrance_amount(l_chunk_pointer) *
2874 (psp_general.business_days(l_asg_start_date, r_enc_period.r_asg_end_date(l_enc_period_count)) / l_bus_days_in_chunk));
2875 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND((r_enc_period.r_encumbrance_amount(l_chunk_pointer) * l_schedule_percent/100),g_ext_precision);
2876 r_enc_period.r_period_amount(l_enc_period_count) := r_enc_period.r_period_amount(l_chunk_pointer);
2877 r_enc_period.r_reason_code(l_enc_period_count) := l_autopop_error;
2878 END IF;
2879 add_cel_warnings(p_start_date => r_enc_period.r_asg_start_date(l_chunk_pointer),
2880 p_hierarchy_code => 'SA',
2881 p_end_date => r_enc_period.r_asg_end_date(l_chunk_pointer),
2882 p_warning_code => 'AUTOPOP',
2883 p_gl_ccid => l_gl_code_combination_id,
2884 p_project_id => l_project_id,
2885 p_task_id => l_task_id,
2886 p_award_id => l_award_id,
2887 p_exp_org_id => l_expenditure_org_id,
2888 p_exp_type => l_expenditure_type,
2889 p_effective_date => l_effective_date,
2890 p_error_status => l_autopop_error);
2891 hr_utility.trace('Posting to suspense account');
2892 ELSE
2893 IF (l_acct_type = 'E') THEN
2894 psp_enc_pre_process.validate_poeta (p_project_id => l_project_id,
2895 p_task_id => l_task_id,
2896 p_award_id => l_award_id,
2897 p_expenditure_type => l_new_expenditure_type,
2898 p_expenditure_organization_id => l_expenditure_org_id,
2899 p_payroll_id => p_payroll_id,
2900 p_start_date => l_poeta_start_date,
2901 p_end_date => l_poeta_end_date,
2902 p_return_status => p_return_status);
2903 IF p_return_status <> fnd_api.g_ret_sts_success THEN
2904 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2905 END IF;
2906 l_expenditure_type := l_new_expenditure_type;
2907 ELSE
2908 l_gl_code_combination_id := l_new_gl_code_combination_id;
2909 END IF;
2910 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2911 END IF;
2912 ELSE
2913 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2914 END IF;
2915 END IF;
2916 END LOOP;
2917 ELSIF (l_process_flag = 'SA') THEN
2918 IF (l_reason_code NOT IN ('LDM_BAL_NOT_100_PERCENT', 'LDM_NO_CI_FOUND')) THEN
2919 l_orig_gl_code_combination_id := orig_ci.gl_code_combination_id(l_orig_pointer);
2920 l_orig_project_id := orig_ci.project_id(l_orig_pointer);
2921 l_orig_task_id := orig_ci.task_id(l_orig_pointer);
2922 l_orig_award_id := orig_ci.award_id(l_orig_pointer);
2923 l_orig_expenditure_org_id := orig_ci.expenditure_organization_id(l_orig_pointer);
2924 l_orig_expenditure_type := orig_ci.expenditure_type(l_orig_pointer);
2925 l_orig_pointer := l_orig_pointer + 1;
2926 END IF;
2927
2928 FOR recno IN 1..r_sa.line_account_id.COUNT
2929 LOOP
2930 g_sa_pointer := recno;
2931 EXIT WHEN ((l_asg_start_date <= r_sa.end_date_active(recno))
2932 AND (l_asg_end_date >= r_sa.start_date_active(recno)));
2933 IF ((recno = r_sa.line_account_id.COUNT) AND
2934 (l_asg_start_date <= g_enc_org_end_date)) THEN
2935 OPEN asg_number_cur;
2936 FETCH asg_number_cur INTO l_organization_id;
2937 CLOSE asg_number_cur;
2938
2939 OPEN org_name_cur;
2940 FETCH org_name_cur INTO l_organization_name;
2941 CLOSE org_name_cur;
2942
2943 fnd_message.set_name('PSP', 'PSP_LD_SUSPENSE_AC_NOT_EXIST');
2944 fnd_message.set_token('ORG_NAME', l_organization_name);
2945 fnd_message.set_token('PAYROLL_DATE', l_asg_start_date);
2946 g_error_message := fnd_message.get;
2947 RAISE no_global_acct_exists;
2948 END IF;
2949 END LOOP;
2950
2951 FOR recno IN g_sa_pointer..r_sa.line_account_id.COUNT
2952 LOOP
2953 EXIT WHEN (NOT ((l_asg_start_date <= r_sa.end_date_active(recno))
2954 AND (l_asg_end_date >= r_sa.start_date_active(recno))));
2955
2956 g_sa_pointer := recno;
2957 l_suspense_account_id := r_sa.line_account_id(recno);
2958 l_gl_code_combination_id := r_sa.gl_code_combination_id(recno);
2959 l_project_id := r_sa.project_id(recno);
2960 l_task_id := r_sa.task_id(recno);
2961 l_award_id := r_sa.award_id(recno);
2962 l_schedule_percent := r_sa.percent(recno);
2963 l_expenditure_type := r_sa.expenditure_type(recno);
2964 l_expenditure_org_id := r_sa.expenditure_organization_id(recno);
2965 l_start_date_active := r_sa.start_date_active(recno);
2966 l_end_date_active := r_sa.end_date_active(recno);
2967 l_poeta_start_date := r_sa.poeta_start_date(recno);
2968 l_poeta_end_date := r_sa.poeta_end_date(recno);
2969 l_attribute_category := r_sa.attribute_category(recno);
2970 l_attribute1 := r_sa.attribute1(recno);
2971 l_attribute2 := r_sa.attribute2(recno);
2972 l_attribute3 := r_sa.attribute3(recno);
2973 l_attribute4 := r_sa.attribute4(recno);
2974 l_attribute5 := r_sa.attribute5(recno);
2975 l_attribute6 := r_sa.attribute6(recno);
2976 l_attribute7 := r_sa.attribute7(recno);
2977 l_attribute8 := r_sa.attribute8(recno);
2978 l_attribute9 := r_sa.attribute9(recno);
2979 l_attribute10 := r_sa.attribute10(recno);
2980 l_acct_type := r_sa.acct_type(recno);
2981
2982 IF (g_uom = 'H' AND l_gl_code_combination_id IS NOT NULL) THEN
2983 log_gl_hours_message;
2984 ELSE
2985
2986 IF (g_sa_autopop = 'Y') THEN
2987 psp_autopop.main(p_acct_type => l_acct_type,
2988 p_person_id => l_person_id,
2989 p_assignment_id => p_assignment_id,
2990 p_element_type_id => p_element_type_id,
2991 p_project_id => l_project_id,
2992 p_expenditure_organization_id => l_expenditure_org_id,
2993 p_task_id => l_task_id,
2994 p_award_id => l_award_id,
2995 p_expenditure_type => l_expenditure_type,
2996 p_gl_code_combination_id => l_gl_code_combination_id,
2997 p_payroll_date => l_asg_end_date, --- replaced l_effective_date..5592784
2998 p_set_of_books_id => g_set_of_books_id,
2999 p_business_group_id => g_business_group_id,
3000 ret_expenditure_type => l_new_expenditure_type,
3001 ret_gl_code_combination_id => l_new_gl_code_combination_id,
3002 retcode => l_autopop_status);
3003
3004 IF (l_autopop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
3005 (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
3006 l_autopop_error := 'AUTO_POP_EXP_ERROR';
3007 IF (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
3008 l_autopop_error := 'AUTO_POP_NO_VALUE';
3009 END IF;
3010 IF (l_acct_type = 'E') THEN
3011 OPEN project_number_cur;
3012 FETCH project_number_cur INTO l_project_number;
3013 CLOSE project_number_cur;
3014
3015 OPEN award_number_cur;
3016 FETCH award_number_cur INTO l_award_number;
3017 CLOSE award_number_cur;
3018
3019 OPEN task_number_cur;
3020 FETCH task_number_cur INTO l_task_number;
3021 CLOSE task_number_cur;
3022
3023 OPEN exp_org_name_cur;
3024 FETCH exp_org_name_cur INTO l_exp_org_name;
3025 CLOSE exp_org_name_cur;
3026
3027 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_INV_PATEO');
3028 fnd_message.set_token('PJ', l_project_number);
3029 fnd_message.set_token('TK', l_task_number);
3030 fnd_message.set_token('AW', l_award_number);
3031 fnd_message.set_token('EO', l_exp_org_name);
3032 fnd_message.set_token('ET', l_expenditure_type);
3033 ELSE
3034 l_gl_description := psp_general.get_gl_values(g_set_of_books_id, l_gl_code_combination_id);
3035 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_INV_GL');
3036 fnd_message.set_token('GL', l_gl_description);
3037 END IF;
3038 fnd_message.set_token('START_DATE', l_asg_start_date);
3039 fnd_message.set_token('END_DATE', l_asg_end_date);
3040 fnd_message.set_token('ERROR_STATUS', l_autopop_error);
3041 g_error_message := fnd_message.get;
3042 RAISE SUSPENSE_AUTOPOP_FAILED;
3043 ELSE
3044 IF (l_acct_type = 'E') THEN
3045 psp_enc_pre_process.validate_poeta (p_project_id => l_project_id,
3046 p_task_id => l_task_id,
3047 p_award_id => l_award_id,
3048 p_expenditure_type => l_new_expenditure_type,
3049 p_expenditure_organization_id => l_expenditure_org_id,
3050 p_payroll_id => p_payroll_id,
3051 p_start_date => l_poeta_start_date,
3052 p_end_date => l_poeta_end_date,
3053 p_return_status => p_return_status);
3054 IF p_return_status <> fnd_api.g_ret_sts_success THEN
3055 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3056 END IF;
3057 l_expenditure_type := l_new_expenditure_type;
3058 ELSE
3059 l_gl_code_combination_id := l_new_gl_code_combination_id;
3060 END IF;
3061 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
3062 END IF;
3063 ELSE
3064 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
3065 END IF;
3066 END IF;
3067 END LOOP;
3068 ELSIF (l_process_flag = 'I') THEN
3069 hr_utility.trace('Ignoring chunk starting beyond org end date');
3070 END IF;
3071 END IF;
3072
3073 l_chunk_pointer := l_chunk_pointer + 1;
3074 END LOOP;
3075
3076 orig_ci.gl_code_combination_id.DELETE;
3077 orig_ci.project_id.DELETE;
3078 orig_ci.task_id.DELETE;
3079 orig_ci.award_id.DELETE;
3080 orig_ci.expenditure_organization_id.DELETE;
3081 orig_ci.expenditure_type.DELETE;
3082
3083 hr_utility.trace('Prev Enc Lines: ' || l_prev_enc_lines_counter);
3084 hr_utility.trace('G Enc Lines: ' || g_enc_lines_counter);
3085 hr_utility.trace('Enc Lines: ' || t_enc_lines_array.r_time_period_id.COUNT);
3086 l_time_period_id := -1;
3087 IF ((g_enc_lines_counter - l_prev_enc_lines_counter) > 0) THEN
3088 FOR recno IN 1..r_enc_period.r_time_period_id.COUNT
3089 LOOP
3090 IF (l_time_period_id <> r_enc_period.r_time_period_id(recno)) AND
3091 (r_enc_period.r_time_period_id(recno) NOT IN (l_ignore_start, l_ignore_end)) AND
3092 (g_enc_org_end_date > r_enc_period.r_period_start_date(recno)) THEN
3093 l_proc_step := 90 + (recno / 100000);
3094 l_running_total := 0;
3095 l_chunk_pointer := 1;
3096 l_time_period_id := r_enc_period.r_time_period_id(recno);
3097 FOR recno2 IN l_prev_enc_lines_counter..(g_enc_lines_counter-1)
3098 LOOP
3099 l_proc_step := 100 + (recno2 / 100000);
3100 IF (t_enc_lines_array.r_time_period_id(recno2) = l_time_period_id) THEN
3101 l_running_total := l_running_total + t_enc_lines_array.r_encumbrance_amount(recno2);
3102 l_chunk_pointer := recno2;
3103 hr_utility.trace('Encumbrance Amount: ' || t_enc_lines_array.r_encumbrance_amount(recno2));
3104 END IF;
3105 END LOOP;
3106
3107 IF (l_running_total > 0) AND (l_running_total <> r_enc_period.r_period_amount(recno)) THEN
3108 t_enc_lines_array.r_encumbrance_amount(l_chunk_pointer) :=
3109 t_enc_lines_array.r_encumbrance_amount(l_chunk_pointer) +
3110 (r_enc_period.r_period_amount(recno) - l_running_total);
3111 END IF;
3112
3113 hr_utility.trace('l_time_period_id: ' || l_time_period_id ||
3114 ' l_running_total: ' || fnd_number.number_to_canonical(l_running_total) ||
3115 ' r_enc_period.r_period_amount(recno): ' || fnd_number.number_to_canonical(r_enc_period.r_period_amount(recno)) ||
3116 ' t_enc_lines_array.r_encumbrance_amount(l_chunk_pointer): ' || fnd_number.number_to_canonical(t_enc_lines_array.r_encumbrance_amount(l_chunk_pointer)));
3117 END IF;
3118 END LOOP;
3119 END IF;
3120
3121 r_enc_period.r_time_period_id.DELETE;
3122 r_enc_period.r_period_start_date.DELETE;
3123 r_enc_period.r_period_end_date.DELETE;
3124 r_enc_period.r_asg_start_date.DELETE;
3125 r_enc_period.r_asg_end_date.DELETE;
3126 r_enc_period.r_process_flag.DELETE;
3127 r_enc_period.r_period_ind.DELETE;
3128 r_enc_period.r_schedule_percent.DELETE;
3129 r_enc_period.r_encumbrance_amount.DELETE;
3130 r_enc_period.r_period_amount.DELETE;
3131 r_enc_period.r_reason_code.DELETE;
3132
3133 l_proc_step := 210;
3134 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving ' || l_proc_name);
3135 EXCEPTION
3136 WHEN suspense_autopop_failed THEN
3137 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'CREATE_LINES ');
3138 p_return_status := fnd_api.g_ret_sts_unexp_error;
3139 fnd_file.put_line(fnd_file.log, 'l_reason_code: ' || l_reason_code);
3140 fnd_file.put_line(fnd_file.log, fnd_number.number_to_canonical(l_proc_step) || ': ' || l_proc_name);
3141 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving ' || l_proc_name);
3142 WHEN OTHERS THEN
3143 IF (g_error_message IS NULL) THEN
3144 g_error_message := l_proc_name || ': ' || SQLERRM;
3145 END IF;
3146 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'CREATE_LINES');
3147 p_return_status := fnd_api.g_ret_sts_unexp_error;
3148 fnd_file.put_line(fnd_file.log, fnd_number.number_to_canonical(l_proc_step) || ': ' || l_proc_name);
3149 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving ' || l_proc_name);
3150 END create_lines;
3151
3152 ---------------------- I N S E R T S T A T E M E N T ------------------------------------
3153 PROCEDURE insert_into_enc_lines(
3154 L_ENC_ELEMENT_TYPE_ID IN NUMBER,
3155 L_ENCUMBRANCE_DATE IN DATE,
3156 L_DR_CR_FLAG IN VARCHAR2,
3157 L_ENCUMBRANCE_AMOUNT IN NUMBER,
3158 L_ENC_LINE_TYPE IN VARCHAR2,
3159 L_SCHEDULE_LINE_ID IN NUMBER,
3160 L_ORG_SCHEDULE_ID IN NUMBER,
3161 L_DEFAULT_ORG_ACCOUNT_ID IN NUMBER,
3162 L_SUSPENSE_ORG_ACCOUNT_ID IN NUMBER,
3163 L_ELEMENT_ACCOUNT_ID IN NUMBER,
3164 L_GL_PROJECT_FLAG IN VARCHAR2,
3165 L_PERSON_ID IN NUMBER,
3166 L_ASSIGNMENT_ID IN NUMBER,
3167 L_AWARD_ID IN NUMBER,
3168 L_TASK_ID IN NUMBER,
3169 L_EXPENDITURE_TYPE IN VARCHAR2,
3170 L_EXPENDITURE_ORGANIZATION_ID IN NUMBER,
3171 L_PROJECT_ID IN NUMBER,
3172 L_GL_CODE_COMBINATION_ID IN NUMBER,
3173 L_TIME_PERIOD_ID IN NUMBER,
3174 L_PAYROLL_ID IN NUMBER,
3175 L_BUSINESS_GROUP_ID IN NUMBER,
3176 L_SET_OF_BOOKS_ID IN NUMBER,
3177 L_SUSPENSE_REASON_CODE IN VARCHAR2,
3178 L_DEFAULT_REASON_CODE IN VARCHAR2,
3179 L_CHANGE_FLAG IN VARCHAR2,
3180 L_ENC_START_DATE IN DATE,
3181 L_ENC_END_DATE IN DATE,
3182 p_attribute_category IN VARCHAR2, -- Introduced DFF parameters for bug fix 2908859
3183 p_attribute1 IN VARCHAR2,
3184 p_attribute2 IN VARCHAR2,
3185 p_attribute3 IN VARCHAR2,
3186 p_attribute4 IN VARCHAR2,
3187 p_attribute5 IN VARCHAR2,
3188 p_attribute6 IN VARCHAR2,
3189 p_attribute7 IN VARCHAR2,
3190 p_attribute8 IN VARCHAR2,
3191 p_attribute9 IN VARCHAR2,
3192 p_attribute10 IN VARCHAR2,
3193 p_orig_gl_code_combination_id IN NUMBER,
3194 p_orig_project_id IN NUMBER,
3195 p_orig_task_id IN NUMBER,
3196 p_orig_award_id IN NUMBER,
3197 p_orig_expenditure_org_id IN NUMBER,
3198 p_orig_expenditure_type IN VARCHAR2,
3199 p_hierarchy_code IN VARCHAR2,
3200 p_return_status OUT NOCOPY VARCHAR2) IS
3201 l_enc_line_id NUMBER;
3202 l_row_id VARCHAR2(30);
3203 i NUMBER := 0;
3204 l_time_period_id_found VARCHAR2(10) := 'FALSE';
3205 l_rec_no NUMBER := 0;
3206 l_enc_control_id NUMBER;
3207 l_return_status VARCHAR2(1);
3208 BEGIN
3209 --For Enh. Bug 2259310 : Changed the enc_control_tab from array of records to records of array and hence the change
3210 --in the way each element of record to be accessed.
3211 --Instead of calling INSERT_ROW of PSP_ENC_LINES for each CI of an assignment, all the lines are collated into an
3212 --array for an assignment and inserted using Oracle 8i feature
3213
3214 /* added to skip creation of lines with zero dollars Bug 1671971:- Subha */
3215 IF l_encumbrance_amount <> 0 THEN
3216
3217 -- The following code is used to populate number_of_dr,number_of_cr,total_dr_amount,
3218 -- total_cr_amount,gl_dr_amount,gl_cr_amount,ogm_dr_amount,ogm_cr_amount of
3219 -- psp_enc_controls table.
3220
3221 -- Check for dr_cr_flag and increment the counter and amount accordingly.
3222 FOR I IN 1..enc_control_tab.r_enc_control_id.COUNT
3223 loop
3224 IF (enc_control_tab.r_time_period_id(i) = l_time_period_id
3225 AND enc_control_tab.r_uom(i) = g_uom) THEN
3226 l_time_period_id_found := 'TRUE';
3227 l_rec_no := i;
3228 l_enc_control_id := enc_control_tab.r_enc_control_id(l_rec_no);
3229 EXIT;
3230 end if;
3231 end loop;
3232
3233 IF l_time_period_id_found = 'FALSE' THEN
3234 create_controls(g_payroll_action_id, l_payroll_id,
3235 l_time_period_id, l_business_group_id, l_set_of_books_id,
3236 l_enc_control_id, l_return_status);
3237
3238 l_rec_no := enc_control_tab.r_enc_control_id.COUNT + 1;
3239 enc_control_tab.r_time_period_id(l_rec_no) := l_time_period_id;
3240 enc_control_tab.r_uom(l_rec_no) := g_uom;
3241 /***** Commented the following for Create and Update multi thread enh.
3242 -- Get a number for enc control id
3243 BEGIN
3244 SELECT psp_enc_controls_s.nextval
3245 INTO l_enc_control_id
3246 FROM DUAL;
3247 END;
3248 End of comment for Create and Update multi thread enh. *****/
3249 enc_control_tab.r_enc_control_id(l_rec_no) := l_enc_control_id;
3250 enc_control_tab.r_no_of_dr(l_rec_no) := 0;
3251 enc_control_tab.r_total_dr_amount(l_rec_no) := 0;
3252 enc_control_tab.r_gl_dr_amount(l_rec_no) := 0;
3253 enc_control_tab.r_ogm_dr_amount(l_rec_no) :=0;
3254 enc_control_tab.r_no_of_cr(l_rec_no) :=0;
3255 enc_control_tab.r_total_cr_amount(l_rec_no) := 0;
3256 enc_control_tab.r_gl_cr_amount(l_rec_no) := 0;
3257 enc_control_tab.r_ogm_cr_amount(l_rec_no) :=0;
3258 END IF;
3259
3260 IF l_dr_cr_flag = 'D' THEN
3261 g_dr_ctr := NVL(g_dr_ctr,0) + 1;
3262 enc_control_tab.r_no_of_dr(l_rec_no) := NVL(enc_control_tab.r_no_of_dr(l_rec_no),0) + 1;
3263 enc_control_tab.r_total_dr_amount(l_rec_no) := NVL(enc_control_tab.r_total_dr_amount(l_rec_no),0) + NVL(l_encumbrance_amount,0);
3264
3265 IF l_gl_project_flag = 'G' THEN
3266 enc_control_tab.r_gl_dr_amount(l_rec_no) := NVL(enc_control_tab.r_gl_dr_amount(l_rec_no),0) + NVL(l_encumbrance_amount,0);
3267 ELSIF l_gl_project_flag = 'P' THEN
3268 enc_control_tab.r_ogm_dr_amount(l_rec_no) := NVL(enc_control_tab.r_ogm_dr_amount(l_rec_no),0) + NVL(l_encumbrance_amount,0);
3269 END IF;
3270
3271 ELSIF l_dr_cr_flag = 'C' THEN
3272 g_cr_ctr := NVL(g_cr_ctr,0) + 1;
3273 enc_control_tab.r_no_of_cr(l_rec_no) := NVL(enc_control_tab.r_no_of_cr(l_rec_no),0) + 1;
3274 enc_control_tab.r_total_cr_amount(l_rec_no) := NVL(enc_control_tab.r_total_cr_amount(l_rec_no),0) + NVL(l_encumbrance_amount,0);
3275
3276 IF l_gl_project_flag = 'G' THEN
3277 enc_control_tab.r_gl_cr_amount(l_rec_no) := NVL(enc_control_tab.r_gl_cr_amount(l_rec_no),0) + NVL(l_encumbrance_amount,0);
3278 ELSIF l_gl_project_flag = 'P' THEN
3279 enc_control_tab.r_ogm_cr_amount(l_rec_no) := NVL(enc_control_tab.r_ogm_cr_amount(l_rec_no),0) + NVL(l_encumbrance_amount,0);
3280 END IF;
3281 END IF;
3282
3283 --Introduced For Enh. Bug 2259310
3284 -- Insert into enc lines record
3285 t_enc_lines_array.r_enc_element_type_id(g_enc_lines_counter) := l_enc_element_type_id;
3286 t_enc_lines_array.r_encumbrance_date(g_enc_lines_counter) := l_encumbrance_date;
3287 t_enc_lines_array.r_dr_cr_flag(g_enc_lines_counter) := l_dr_cr_flag;
3288 t_enc_lines_array.r_encumbrance_amount(g_enc_lines_counter) := l_encumbrance_amount;
3289 t_enc_lines_array.r_enc_line_type(g_enc_lines_counter) := l_enc_line_type;
3290 t_enc_lines_array.r_schedule_line_id(g_enc_lines_counter) := l_schedule_line_id;
3291 t_enc_lines_array.r_org_schedule_id(g_enc_lines_counter) := l_org_schedule_id;
3292 t_enc_lines_array.r_default_org_account_id(g_enc_lines_counter) := l_default_org_account_id;
3293 t_enc_lines_array.r_suspense_org_account_id(g_enc_lines_counter) := l_suspense_org_account_id;
3294 t_enc_lines_array.r_element_account_id(g_enc_lines_counter) := l_element_account_id;
3295 t_enc_lines_array.r_gl_project_flag(g_enc_lines_counter) := l_gl_project_flag;
3296 t_enc_lines_array.r_person_id(g_enc_lines_counter) := l_person_id;
3297 t_enc_lines_array.r_assignment_id(g_enc_lines_counter) := l_assignment_id;
3298 t_enc_lines_array.r_award_id(g_enc_lines_counter) := l_award_id;
3299 t_enc_lines_array.r_task_id(g_enc_lines_counter) := l_task_id;
3300 t_enc_lines_array.r_expenditure_type(g_enc_lines_counter) := l_expenditure_type;
3301 t_enc_lines_array.r_expenditure_organization_id(g_enc_lines_counter) := l_expenditure_organization_id;
3302 t_enc_lines_array.r_project_id(g_enc_lines_counter) := l_project_id;
3303 t_enc_lines_array.r_gl_code_combination_id(g_enc_lines_counter) := l_gl_code_combination_id;
3304 t_enc_lines_array.r_time_period_id(g_enc_lines_counter) := l_time_period_id;
3305 t_enc_lines_array.r_default_reason_code(g_enc_lines_counter) := l_default_reason_code;
3306 t_enc_lines_array.r_suspense_reason_code(g_enc_lines_counter) := l_suspense_reason_code;
3307 t_enc_lines_array.r_enc_control_id(g_enc_lines_counter) := l_enc_control_id;
3308 t_enc_lines_array.r_change_flag(g_enc_lines_counter) := l_change_flag;
3309 t_enc_lines_array.r_enc_start_date(g_enc_lines_counter) := l_enc_start_date;
3310 t_enc_lines_array.r_enc_end_date(g_enc_lines_counter) := l_enc_end_date;
3311 t_enc_lines_array.r_attribute_category(g_enc_lines_counter) := NVL(p_attribute_category, 'NULL_VALUE'); -- Introduced DFF columns for bug fix 2908859
3312 t_enc_lines_array.r_attribute1(g_enc_lines_counter) := NVL(p_attribute1, 'NULL_VALUE');
3313 t_enc_lines_array.r_attribute2(g_enc_lines_counter) := NVL(p_attribute2, 'NULL_VALUE');
3314 t_enc_lines_array.r_attribute3(g_enc_lines_counter) := NVL(p_attribute3, 'NULL_VALUE');
3315 t_enc_lines_array.r_attribute4(g_enc_lines_counter) := NVL(p_attribute4, 'NULL_VALUE');
3316 t_enc_lines_array.r_attribute5(g_enc_lines_counter) := NVL(p_attribute5, 'NULL_VALUE');
3317 t_enc_lines_array.r_attribute6(g_enc_lines_counter) := NVL(p_attribute6, 'NULL_VALUE');
3318 t_enc_lines_array.r_attribute7(g_enc_lines_counter) := NVL(p_attribute7, 'NULL_VALUE');
3319 t_enc_lines_array.r_attribute8(g_enc_lines_counter) := NVL(p_attribute8, 'NULL_VALUE');
3320 t_enc_lines_array.r_attribute9(g_enc_lines_counter) := NVL(p_attribute9, 'NULL_VALUE');
3321 t_enc_lines_array.r_attribute10(g_enc_lines_counter) := NVL(p_attribute10, 'NULL_VALUE');
3322 t_enc_lines_array.r_orig_gl_code_combination_id(g_enc_lines_counter) := p_orig_gl_code_combination_id;
3323 t_enc_lines_array.r_orig_project_id(g_enc_lines_counter) := p_orig_project_id;
3324 t_enc_lines_array.r_orig_award_id(g_enc_lines_counter) := p_orig_award_id;
3325 t_enc_lines_array.r_orig_task_id(g_enc_lines_counter) := p_orig_task_id;
3326 t_enc_lines_array.r_orig_expenditure_type(g_enc_lines_counter) := p_orig_expenditure_type;
3327 t_enc_lines_array.r_orig_expenditure_org_id(g_enc_lines_counter) := p_orig_expenditure_org_id;
3328 t_enc_lines_array.r_hierarchy_code(g_enc_lines_counter) := p_hierarchy_code;
3329
3330 g_enc_lines_counter := g_enc_lines_counter +1;
3331 END IF; /* skip inserting lines of zero dollars */
3332 p_return_status := fnd_api.g_ret_sts_success;
3333 EXCEPTION
3334 WHEN OTHERS THEN
3335 IF (g_error_message IS NULL) THEN
3336 g_error_message := 'INSERT_INTO_ENC_LINES: ' || SQLERRM;
3337 END IF;
3338 fnd_msg_pub.add_exc_msg('PSP_ENC_LINES','INSERT_INTO_ENC_LINES');
3339 p_return_status := fnd_api.g_ret_sts_unexp_error;
3340 END insert_into_enc_lines;
3341
3342 --------------------------- INSERT INTO CONTROL TABLES --------------------------------------
3343 PROCEDURE Create_Controls(p_payroll_action_id IN NUMBER,
3344 p_payroll_id IN NUMBER,
3345 p_time_period_id IN NUMBER,
3346 p_business_group_id IN NUMBER,
3347 p_set_of_books_id IN NUMBER,
3348 p_enc_control_id OUT NOCOPY NUMBER,
3349 p_return_status OUT NOCOPY VARCHAR2) IS
3350
3351 l_action_code VARCHAR2(2);-- DEFAULT 'N';
3352 --Added the following variables for the Enhancement -Enc Redesign: Enh. Bug 2259310
3353 l_batch_name VARCHAR2(30) DEFAULT 'ENC'||TO_CHAR(TRUNC(SYSDATE));
3354 l_last_update_date DATE DEFAULT SYSDATE;
3355 l_last_updated_by NUMBER DEFAULT NVL(FND_GLOBAL.USER_ID, -1);
3356 l_last_updated_login NUMBER DEFAULT NVL(FND_GLOBAL.LOGIN_ID, -1);
3357 CURSOR get_enc_control_id_cur IS
3358 SELECT enc_control_id
3359 FROM psp_enc_controls
3360 WHERE payroll_action_id = p_payroll_action_id
3361 AND payroll_id = p_payroll_id
3362 AND time_period_id = p_time_period_id
3363 AND uom = g_uom;
3364 BEGIN
3365 /* Added IF conditon below for Restart update/Quick Update Encumbrance Lines Enh. */
3366 -- IF g_enc_line_type IN ('U','Q') THEN
3367 l_action_code := 'IC';
3368 -- END IF;
3369
3370 OPEN get_enc_control_id_cur;
3371 FETCH get_enc_control_id_cur INTO p_enc_control_id;
3372 CLOSE get_enc_control_id_cur;
3373
3374 -- FORALL i IN 1 ..enc_control_tab.r_time_period_id.COUNT
3375 IF (p_enc_control_id IS NULL) THEN
3376 SELECT psp_enc_controls_s.NEXTVAL INTO p_enc_control_id FROM DUAL;
3377
3378 INSERT INTO PSP_ENC_CONTROLS
3379 (time_period_id, enc_control_id,
3380 number_of_dr, number_of_cr,
3381 total_dr_amount, total_cr_amount,
3382 gl_dr_amount, gl_cr_amount,
3383 ogm_dr_amount, ogm_cr_amount,
3384 payroll_id, set_of_books_id,
3385 encumbrance_date, action_code,
3386 last_update_date, last_updated_by,
3387 creation_date, created_by,
3388 last_update_login, batch_name,
3389 business_group_id, action_type,
3390 payroll_action_id, uom)
3391 VALUES (p_time_period_id, p_enc_control_id,
3392 0, 0,
3393 0, 0,
3394 0, 0,
3395 0, 0,
3396 p_payroll_id, p_set_of_books_id,
3397 l_last_update_date, l_action_code,
3398 l_last_update_date, l_last_updated_by,
3399 l_last_update_date, l_last_updated_by,
3400 l_last_updated_login, l_batch_name,
3401 p_business_group_id, 'U',
3402 p_payroll_action_id, g_uom);
3403 /* Commented for Create and Update multi thread enh.
3404 VALUES (enc_control_tab.R_TIME_PERIOD_ID(i), enc_control_tab.R_ENC_CONTROL_ID(i),
3405 enc_control_tab.R_NO_OF_DR(i), enc_control_tab.R_NO_OF_CR(i),
3406 round(enc_control_tab.R_TOTAL_DR_AMOUNT(i),g_precision),-- intoduced Rounding for Bug 2916848 Ilo Ehnc.
3407 round(enc_control_tab.R_TOTAL_CR_AMOUNT(i),g_precision),-- intoduced Rounding for Bug 2916848 Ilo Ehnc.
3408 round(enc_control_tab.R_GL_DR_AMOUNT(i),g_precision),-- intoduced Rounding for Bug 2916848 Ilo Ehnc.
3409 round(enc_control_tab.R_GL_CR_AMOUNT(i),g_precision),-- intoduced Rounding for Bug 2916848 Ilo Ehnc.
3410 round(enc_control_tab.R_OGM_DR_AMOUNT(i),g_precision),-- intoduced Rounding for Bug 2916848 Ilo Ehnc.
3411 round(enc_control_tab.R_OGM_CR_AMOUNT(i),g_precision),-- intoduced Rounding for Bug 2916848 Ilo Ehnc.
3412 p_payroll_id, p_set_of_books_id,
3413 l_last_update_date, l_action_code,
3414 l_last_update_date, l_last_updated_by,
3415 l_last_update_date, l_last_updated_by,
3416 l_last_updated_login, l_batch_name,
3417 p_business_group_id, g_enc_line_type,
3418 p_payroll_action_id);
3419 End of comment for Create and Update Multi thread enh. *****/
3420 END IF;
3421
3422 enc_control_tab.r_time_period_id.delete;
3423 enc_control_tab.r_enc_control_id.delete;
3424 enc_control_tab.r_no_of_dr.delete;
3425 enc_control_tab.r_no_of_cr.delete;
3426 enc_control_tab.r_total_dr_amount.delete;
3427 enc_control_tab.r_total_cr_amount.delete;
3428 enc_control_tab.r_gl_dr_amount.delete;
3429 enc_control_tab.r_gl_cr_amount.delete;
3430 enc_control_tab.r_ogm_dr_amount.delete;
3431 enc_control_tab.r_ogm_cr_amount.delete;
3432 enc_control_tab.r_uom.delete;
3433
3434 COMMIT;
3435 p_return_status := fnd_api.g_ret_sts_success;
3436 EXCEPTION
3437 WHEN OTHERS THEN
3438 IF (g_error_message IS NULL) THEN
3439 g_error_message := 'CREATE_CONTROLS: ' || SQLERRM;
3440 END IF;
3441 p_return_status := fnd_api.g_ret_sts_unexp_error;
3442 fnd_message.set_name('PSP','PSP_ENC_INSERT_CONTROLS');
3443 FND_MSG_PUB.ADD;
3444 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3445 END create_controls;
3446
3447 /**********************************************************
3448 Created By: lveerubh
3449
3450 Date Created By:08-MAR-2002
3451
3452 Purpose: To Determine the Prorata dates. This procedure is called from each of the hierachy.
3453 It determines the spilt of the active assignment chunk into Suspense posting and Schdedule posting
3454 And for each such dates arrived calculates the pro-rated amount. All the dates along with amount and
3455 flag to indicate suspense posting is populated in an array t_peot_gl_hier_array.
3456 Introduced as part of Enhnacement Enc Redesign : Bug 2259310.
3457
3458 Who When What
3459 lveerubh 08-MAR-2002 Created the procedure
3460 lveerubh 20-APR-2002 For Bug 2317856
3461 ***************************************************************/
3462 PROCEDURE determine_pro_rata_dates ( p_assignment_id IN NUMBER,
3463 p_ls_start_date IN DATE,
3464 p_ls_end_date IN DATE,
3465 p_poeta_start_date IN DATE,
3466 p_poeta_end_date IN DATE,
3467 p_asg_start_date IN DATE,
3468 p_asg_end_date IN DATE,
3469 p_asg_amount IN NUMBER,
3470 p_poeta_gl_hier_array IN OUT NOCOPY r_poeta_gl_hier_tab,
3471 p_return_status OUT NOCOPY VARCHAR2
3472 )
3473 IS
3474
3475 -- p_ls_start_date : GREATEST(Labor Schedule Start date , Assignment start date)
3476 -- p_ls_end_date : LEAST(Labor Schedule End date , Assignment end date)
3477
3478 l_start_date date := p_ls_start_date;
3479 l_end_date date := p_ls_end_date;
3480 i NUMBER := 1;
3481 l_bus_days_in_period NUMBER;
3482 l_bus_days_in_schedules NUMBER;
3483 l_susp_date DATE DEFAULT fnd_date.canonical_to_date('1800/01/01');
3484
3485
3486 DIVIDE_BY_ZERO EXCEPTION;
3487
3488 BEGIN
3489 /************
3490 The procedure has been functionally changed for bug 2317856
3491 --Step 1:
3492 --Obtain the start date = MAX (labor schedule start date, poeta start date) and
3493 --end date = min (labor schedule end date, poeta end date).
3494 --Note here that assignment start date and assignment end date checks are not being considered
3495 --for the following reason:
3496 --The posting to Enc lines has to be for the entire period of active assignment chunk.
3497 --Hence this procedure is calculating the date rage for which the POETA or GL needs to be posted
3498 --with the active assignment chunk.
3499 ******************/
3500
3501 --For Bug 2317856
3502 --Frame of reference would be asg start date and asg end date
3503 --No suspense postings for part which does not have LS or after which LS ends
3504 --IF poeta ends before l_start_date then period for which the LS is applicable within asg. chunk shall go to suspense
3505 --l_start_date and l_end_date are equivalent to greatest of ASD and LSD , least of AED and LED respectively.
3506
3507 --For Bug 2317856 :
3508 --1.Adding the extra check of poeta_end_date <l_start_date
3509 --2. Changed the p_asg_start_date and p_asg_end_date to l_start_date and l_end_date respectively
3510 --3. As the amount needs to be prorated hence cannot return in the IF or ELSIF
3511 --4. Moved the subslicing of l_start_Date and l_end_date periods into IF -ELSIF-ELSE condition. Thus moving the
3512 -- END IF down.
3513 --For Bug 2325710 : Introduced the p_poeta_start_date > l_end_date condition for suspense posting
3514 IF ((p_poeta_start_date = l_susp_date) OR (p_poeta_end_date <l_start_date ) OR (p_poeta_start_date > l_end_date)) THEN
3515 p_poeta_gl_hier_array(i).r_amount := round(p_asg_amount,g_ext_precision);
3516 -- Introduced rounding for Bug 2916848 Ilo Mrc Ehnc
3517 p_poeta_gl_hier_array(i).r_enc_start_date := l_start_date;
3518 p_poeta_gl_hier_array(i).r_enc_end_date := l_end_date;
3519 p_poeta_gl_hier_array(i).r_susp_flag := 'Y';
3520 /*******************************************
3521 p_return_status := fnd_api.g_ret_sts_success;
3522 RETURN;
3523 END IF;
3524 IF l_start_date < NVL(p_poeta_start_date,l_start_date) THEN
3525 l_start_date := NVL(p_poeta_start_date,l_start_date);
3526 END IF;
3527
3528 --End Date
3529 IF l_end_date > NVL(p_poeta_end_date,l_end_date) THEN
3530 l_end_date := NVL(p_poeta_end_date,l_end_date);
3531 END IF;
3532 IF p_asg_start_date < l_start_date THEN --(ASD <PSD )
3533 t_poeta_gl_hier_array(i).r_enc_start_date := p_asg_start_date;
3534 t_poeta_gl_hier_array(i).r_enc_end_date := l_start_date-1;
3535 t_poeta_gl_hier_array(i).r_susp_flag := 'Y';
3536 i := i+1;
3537 IF l_end_date < p_asg_end_date THEN -- (PED<AED)
3538 t_poeta_gl_hier_array(i).r_enc_start_date := l_start_date;
3539 t_poeta_gl_hier_array(i).r_enc_end_date := l_end_date ;
3540 i := i +1;
3541 t_poeta_gl_hier_array(i).r_enc_start_date := l_end_date+1;
3542 t_poeta_gl_hier_array(i).r_enc_end_date := p_asg_end_date ;
3543 t_poeta_gl_hier_array(i).r_susp_flag := 'Y';
3544 ELSE-- (AED<=PED)
3545 t_poeta_gl_hier_array(i).r_enc_start_date := l_start_date;
3546 t_poeta_gl_hier_array(i).r_enc_end_date := p_asg_end_date ;
3547 END IF;
3548 ELSE --(ASD>= PSD)
3549 t_poeta_gl_hier_array(i).r_enc_start_date := p_asg_start_date;
3550 IF l_end_date < p_asg_end_date THEN --(PED<AED)
3551 t_poeta_gl_hier_array(i).r_enc_end_date := l_end_date ;
3552 i := i +1;
3553 t_poeta_gl_hier_array(i).r_enc_start_date := l_end_date+1;
3554 t_poeta_gl_hier_array(i).r_enc_end_date := p_asg_end_date ;
3555 t_poeta_gl_hier_array(i).r_susp_flag := 'Y';
3556 ELSE --(AED<= PED)
3557 t_poeta_gl_hier_array(i).r_enc_end_date := p_asg_end_date ;
3558 END IF;
3559 END IF;
3560 *****************************************/
3561 --Introduced for GL Validation -2317856
3562 ELSIF (p_poeta_start_date IS NULL) THEN
3563 p_poeta_gl_hier_array(i).r_amount := round(p_asg_amount,g_ext_precision);
3564 -- Introduced rounding for bug 2916848 Ilo Mrc Ehnc.
3565 p_poeta_gl_hier_array(i).r_enc_start_date := l_start_date;
3566 p_poeta_gl_hier_array(i).r_enc_end_date := l_end_date;
3567 p_poeta_gl_hier_array(i).r_susp_flag := 'N'; -- Introduced for bug fix 3085980
3568 ELSE
3569 /**Populating the t_poeta_gl_hier_array for using in the schedule hierarchy - FOR POETA processing **/
3570 --For Bug 2317856
3571 --1. Changed p_asg_start_date to l_start_date and p_asg_end_date to l_end_date
3572 --2. l_start_daet and l_end_Date are compared with POETA start and end date respectively
3573 -- Where SD : GREATEST(Labor Schedule Start date , Assignment start date)
3574 -- ED: LEAST(Labor Schedule End date , Assignment end date)
3575 -- PSD :POETA start date, PED:POETA End date
3576
3577 IF l_start_date < p_poeta_start_date THEN --(SD <PSD )
3578 p_poeta_gl_hier_array(i).r_enc_start_date := l_start_date;
3579 p_poeta_gl_hier_array(i).r_enc_end_date := p_poeta_start_date-1;
3580 p_poeta_gl_hier_array(i).r_susp_flag := 'Y';
3581 i := i+1;
3582 IF l_end_date > p_poeta_end_date THEN -- (PED<ED)
3583 p_poeta_gl_hier_array(i).r_enc_start_date := p_poeta_start_date;
3584 p_poeta_gl_hier_array(i).r_enc_end_date := p_poeta_end_date ;
3585 p_poeta_gl_hier_array(i).r_susp_flag := 'N'; -- Introduced for bug fix 3085980
3586 i := i +1;
3587 p_poeta_gl_hier_array(i).r_enc_start_date := p_poeta_end_date+1;
3588 p_poeta_gl_hier_array(i).r_enc_end_date := l_end_date ;
3589 p_poeta_gl_hier_array(i).r_susp_flag := 'Y';
3590 ELSE-- (ED<=PED)
3591 p_poeta_gl_hier_array(i).r_enc_start_date := p_poeta_start_date;
3592 p_poeta_gl_hier_array(i).r_enc_end_date := l_end_date ;
3593 p_poeta_gl_hier_array(i).r_susp_flag := 'N'; -- Introduced for bug fix 3085980
3594 END IF;
3595 ELSE --(SD>= PSD)
3596 p_poeta_gl_hier_array(i).r_enc_start_date := l_start_date;
3597 p_poeta_gl_hier_array(i).r_susp_flag := 'N'; -- Introduced for bug fix 3085980
3598 IF l_end_date > p_poeta_end_date THEN --(PED<ED)
3599 p_poeta_gl_hier_array(i).r_enc_end_date := p_poeta_end_date ;
3600 i := i +1;
3601 p_poeta_gl_hier_array(i).r_enc_start_date := p_poeta_end_date+1;
3602 p_poeta_gl_hier_array(i).r_enc_end_date := l_end_date ;
3603 p_poeta_gl_hier_array(i).r_susp_flag := 'Y';
3604 ELSE --(ED<= PED)
3605 p_poeta_gl_hier_array(i).r_enc_end_date := l_end_date ;
3606 END IF;
3607 END IF;
3608 END IF; --Main IF :2317856
3609
3610 l_bus_days_in_period := PSP_GENERAL.BUSINESS_DAYS(p_asg_start_date, p_asg_end_date,p_assignment_id);
3611 IF l_bus_days_in_period = 0 THEN
3612 fnd_message.set_name('PSP', 'PSP_ENC_ZERO_WORK_DAYS_PERIOD');
3613 fnd_message.set_token('START_DATE', p_asg_start_date);
3614 fnd_message.set_token('END_DATE', p_asg_end_date);
3615 g_error_message := fnd_message.get;
3616 RAISE DIVIDE_BY_ZERO;
3617 END IF;
3618
3619 For j in 1 .. p_poeta_gl_hier_array.COUNT
3620 LOOP
3621 l_bus_days_in_schedules := PSP_GENERAL.BUSINESS_DAYS(p_poeta_gl_hier_array(j).r_enc_start_date, p_poeta_gl_hier_array(j).r_enc_end_date,p_assignment_id);
3622 p_poeta_gl_hier_array(j).r_amount :=
3623 round(((p_asg_amount * l_bus_days_in_schedules) / l_bus_days_in_period),g_ext_precision);
3624 -- Introduced rounding for Bug 2916848 Ilo Mrc Ehnc.
3625 END LOOP;
3626 p_return_status := fnd_api.g_ret_sts_success;
3627
3628 EXCEPTION
3629 WHEN DIVIDE_BY_ZERO THEN
3630 g_error_api_path := SUBSTR(' DETERMINE_PRO_RATA_DATES'||g_error_api_path,1,230);
3631 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', ' DETERMINE_PRO_RATA_DATES ');
3632 p_return_status := fnd_api.g_ret_sts_unexp_error;
3633
3634 WHEN OTHERS THEN
3635 IF (g_error_message IS NULL) THEN
3636 g_error_message := 'DETERMINE_PRO_RATA_DATES: ' || SQLERRM;
3637 END IF;
3638 g_error_api_path := SUBSTR(' DETERMINE_PRO_RATA_DATES'||g_error_api_path,1,230);
3639 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', ' DETERMINE_PRO_RATA_DATES ');
3640 p_return_status := fnd_api.g_ret_sts_unexp_error;
3641
3642 END determine_pro_rata_dates;
3643
3644 /**************************************************************************************************************************
3645 Created By: lveerubh
3646
3647 Date Created By:08-MAR-2002
3648
3649 Purpose: To insert into psp_enc_lines from Array. This procedure has been introduced to bulk insert
3650 into psp_enc_lines from the record of collection t_enc_lines_array.
3651 Introduced as part of Enhnacement Enc Redesign : Bug 2259310.
3652 Who When What
3653 lveerubh 08-MAR-2002 Created the procedure
3654 ********************************************************************************************************************************/
3655 PROCEDURE insert_enc_lines_from_arrays( p_payroll_id IN NUMBER,
3656 p_business_group_id IN NUMBER,
3657 p_set_of_books_id IN NUMBER,
3658 p_enc_line_type IN VARCHAR2,
3659 p_return_status OUT NOCOPY VARCHAR2)
3660 IS
3661 l_last_update_date DATE DEFAULT SYSDATE;
3662 l_last_updated_by NUMBER DEFAULT NVL(FND_GLOBAL.USER_ID, -1);
3663 l_last_update_login NUMBER DEFAULT NVL(FND_GLOBAL.LOGIN_ID, -1);
3664 BEGIN
3665 FORALL i IN 1 .. t_enc_lines_array2.r_enc_element_type_id.COUNT
3666 insert into psp_enc_lines
3667 (
3668 enc_element_type_id,
3669 enc_line_id,
3670 business_group_id,
3671 encumbrance_date,
3672 dr_cr_flag,
3673 encumbrance_amount,
3674 enc_line_type,
3675 schedule_line_id,
3676 org_schedule_id,
3677 default_org_account_id,
3678 suspense_org_account_id,
3679 element_account_id,
3680 gl_project_flag,
3681 person_id,
3682 assignment_id,
3683 award_id,
3684 task_id,
3685 expenditure_type,
3686 expenditure_organization_id,
3687 project_id,
3688 gl_code_combination_id,
3689 time_period_id,
3690 payroll_id,
3691 set_of_books_id,
3692 default_reason_code,
3693 suspense_reason_code,
3694 status_code,
3695 enc_control_id,
3696 change_flag,
3697 enc_start_date,
3698 enc_end_date,
3699 last_update_date,
3700 last_updated_by,
3701 last_update_login,
3702 created_by,
3703 creation_date,
3704 attribute_category, -- Introduced DFF columns for bug fix 2908859
3705 attribute1,
3706 attribute2,
3707 attribute3,
3708 attribute4,
3709 attribute5,
3710 attribute6,
3711 attribute7,
3712 attribute8,
3713 attribute9,
3714 attribute10,
3715 payroll_action_id,
3716 orig_gl_code_combination_id,
3717 orig_project_id,
3718 orig_task_id,
3719 orig_award_id,
3720 orig_expenditure_org_id,
3721 orig_expenditure_type,
3722 hierarchy_code
3723 )
3724 values (
3725 t_enc_lines_array2.r_enc_element_type_id(i)
3726 ,PSP_ENC_LINES_S.NEXTVAL
3727 ,p_business_group_id
3728 , t_enc_lines_array2.r_encumbrance_date(i)
3729 , t_enc_lines_array2.r_dr_cr_flag(i)
3730 ,round( t_enc_lines_array2.r_encumbrance_amount(i),g_precision) -- introduced rounding for BUg 2916848 Ilo Ehnc.
3731 , t_enc_lines_array2.r_enc_line_type(i)
3732 , t_enc_lines_array2.r_schedule_line_id(i)
3733 , t_enc_lines_array2.r_org_schedule_id(i)
3734 , t_enc_lines_array2.r_default_org_account_id(i)
3735 , t_enc_lines_array2.r_suspense_org_account_id(i)
3736 , t_enc_lines_array2.r_element_account_id(i)
3737 , t_enc_lines_array2.r_gl_project_flag(i)
3738 , t_enc_lines_array2.r_person_id(i)
3739 , t_enc_lines_array2.r_assignment_id(i)
3740 , t_enc_lines_array2.r_award_id(i)
3741 , t_enc_lines_array2.r_task_id(i)
3742 , t_enc_lines_array2.r_expenditure_type(i)
3743 , t_enc_lines_array2.r_expenditure_organization_id(i)
3744 , t_enc_lines_array2.r_project_id(i)
3745 , t_enc_lines_array2.r_gl_code_combination_id(i)
3746 , t_enc_lines_array2.r_time_period_id(i)
3747 , p_payroll_id
3748 , p_set_of_books_id
3749 , t_enc_lines_array2.r_default_reason_code(i)
3750 , t_enc_lines_array2.r_suspense_reason_code(i)
3751 , p_enc_line_type --status_code
3752 , t_enc_lines_array2.r_enc_control_id(i)
3753 , t_enc_lines_array2.r_change_flag(i)
3754 , t_enc_lines_array2.r_enc_start_date(i)
3755 , t_enc_lines_array2.r_enc_end_date(i)
3756 , l_last_update_date
3757 , l_last_updated_by
3758 , l_last_update_login
3759 , l_last_updated_by
3760 , l_last_update_date
3761 , DECODE(t_enc_lines_array2.r_attribute_category(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute_category(i))
3762 , DECODE(t_enc_lines_array2.r_attribute1(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute1(i))
3763 , DECODE(t_enc_lines_array2.r_attribute2(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute2(i))
3764 , DECODE(t_enc_lines_array2.r_attribute3(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute3(i))
3765 , DECODE(t_enc_lines_array2.r_attribute4(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute4(i))
3766 , DECODE(t_enc_lines_array2.r_attribute5(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute5(i))
3767 , DECODE(t_enc_lines_array2.r_attribute6(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute6(i))
3768 , DECODE(t_enc_lines_array2.r_attribute7(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute7(i))
3769 , DECODE(t_enc_lines_array2.r_attribute8(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute8(i))
3770 , DECODE(t_enc_lines_array2.r_attribute9(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute9(i))
3771 , DECODE(t_enc_lines_array2.r_attribute10(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute10(i))
3772 , g_payroll_action_id
3773 , t_enc_lines_array2.r_orig_gl_code_combination_id(i)
3774 , t_enc_lines_array2.r_orig_project_id(i)
3775 , t_enc_lines_array2.r_orig_task_id(i)
3776 , t_enc_lines_array2.r_orig_award_id(i)
3777 , t_enc_lines_array2.r_orig_expenditure_org_id(i)
3778 , t_enc_lines_array2.r_orig_expenditure_type(i)
3779 , t_enc_lines_array2.r_hierarchy_code(i)
3780 );
3781
3782 DELETE psp_enc_lines
3783 WHERE payroll_id = p_payroll_id
3784 AND business_group_id = p_business_group_id
3785 AND set_of_books_id = p_set_of_books_id
3786 AND encumbrance_amount = 0;
3787
3788 t_enc_lines_array2.r_enc_element_type_id.delete;
3789 t_enc_lines_array2.r_encumbrance_date.delete;
3790 t_enc_lines_array2.r_dr_cr_flag.delete;
3791 t_enc_lines_array2.r_encumbrance_amount.delete;
3792 t_enc_lines_array2.r_enc_line_type.delete;
3793 t_enc_lines_array2.r_schedule_line_id.delete;
3794 t_enc_lines_array2.r_org_schedule_id.delete;
3795 t_enc_lines_array2.r_default_org_account_id.delete;
3796 t_enc_lines_array2.r_suspense_org_account_id.delete;
3797 t_enc_lines_array2.r_element_account_id.delete;
3798 t_enc_lines_array2.r_gl_project_flag.delete;
3799 t_enc_lines_array2.r_person_id.delete;
3800 t_enc_lines_array2.r_assignment_id.delete;
3801 t_enc_lines_array2.r_award_id.delete;
3802 t_enc_lines_array2.r_task_id.delete;
3803 t_enc_lines_array2.r_expenditure_type.delete;
3804 t_enc_lines_array2.r_expenditure_organization_id.delete;
3805 t_enc_lines_array2.r_project_id.delete;
3806 t_enc_lines_array2.r_gl_code_combination_id.delete;
3807 t_enc_lines_array2.r_time_period_id.delete;
3808 t_enc_lines_array2.r_default_reason_code.delete;
3809 t_enc_lines_array2.r_suspense_reason_code.delete;
3810 t_enc_lines_array2.r_enc_control_id.delete;
3811 t_enc_lines_array2.r_change_flag.delete;
3812 t_enc_lines_array2.r_enc_start_date.delete;
3813 t_enc_lines_array2.r_enc_end_date.delete;
3814 t_enc_lines_array2.r_attribute_category.delete;
3815 t_enc_lines_array2.r_attribute1.delete;
3816 t_enc_lines_array2.r_attribute2.delete;
3817 t_enc_lines_array2.r_attribute3.delete;
3818 t_enc_lines_array2.r_attribute4.delete;
3819 t_enc_lines_array2.r_attribute5.delete;
3820 t_enc_lines_array2.r_attribute6.delete;
3821 t_enc_lines_array2.r_attribute7.delete;
3822 t_enc_lines_array2.r_attribute8.delete;
3823 t_enc_lines_array2.r_attribute9.delete;
3824 t_enc_lines_array2.r_attribute10.delete;
3825 t_enc_lines_array2.r_orig_gl_code_combination_id.delete;
3826 t_enc_lines_array2.r_orig_project_id.delete;
3827 t_enc_lines_array2.r_orig_award_id.delete;
3828 t_enc_lines_array2.r_orig_task_id.delete;
3829 t_enc_lines_array2.r_orig_expenditure_type.delete;
3830 t_enc_lines_array2.r_orig_expenditure_org_id.delete;
3831 t_enc_lines_array2.r_hierarchy_code.delete;
3832
3833 p_return_status := fnd_api.g_ret_sts_success;
3834
3835 EXCEPTION
3836 WHEN OTHERS THEN
3837 IF (g_error_message IS NULL) THEN
3838 g_error_message := 'INSERT_ENC_LINES_FROM_ARRAYS: ' || SQLERRM;
3839 END IF;
3840 g_error_api_path := SUBSTR(' INSERT_ENC_LINES_FROM_ARRAYS:'||g_error_api_path,1,230);
3841 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', ' INSERT_ENC_LINES_FROM_ARRAYS');
3842 p_return_status := fnd_api.g_ret_sts_unexp_error;
3843 END insert_enc_lines_from_arrays;
3844
3845 -- Introduced the following procedure for bug fix 3462452
3846 PROCEDURE sub_slice_asg_chunk (p_assignment_id IN NUMBER,
3847 p_element_type_id IN NUMBER,
3848 p_business_group_id IN NUMBER,
3849 p_set_of_books_id IN NUMBER,
3850 p_return_status OUT NOCOPY VARCHAR2) IS
3851 TYPE r_sch_hier_type IS RECORD
3852 (start_date t_date_type,
3853 end_date t_date_type,
3854 schedule_percent t_num_15_type);
3855 r_sch_rec r_sch_hier_type;
3856
3857 l_return_status VARCHAR2(1);
3858 l_start_date DATE;
3859 l_end_date DATE;
3860 l_min_start_date DATE DEFAULT r_enc_period.r_asg_start_date(1);
3861 l_max_end_date DATE DEFAULT r_enc_period.r_asg_end_date(r_enc_period.r_asg_end_date.COUNT);
3862 l_schedule_percent NUMBER;
3863 l_new_start_date DATE;
3864 l_new_end_date DATE;
3865 l_process_flag VARCHAR2(10);
3866 l_period_start_date DATE;
3867 l_period_end_date DATE;
3868 l_asg_start_date DATE;
3869 l_asg_end_date DATE;
3870 l_rec_no NUMBER DEFAULT 1;
3871 l_sub_slice_counter NUMBER;
3872 l_run_id NUMBER;
3873 l_period_count NUMBER;
3874 l_schedule_hierarchy_id NUMBER;
3875 l_sch_pointer NUMBER;
3876 l_proc_name VARCHAR2(61) DEFAULT g_package_name || 'SUB_SLICE_ASG_CHUNK';
3877 l_reason_code VARCHAR2(50);
3878 l_proc_step NUMBER(20,10);
3879
3880 r_enc_period_tmp1 enc_period_rectype;
3881
3882 --CURSOR global_element_cur (p_period_start_date IN DATE,
3883 -- p_period_end_date IN DATE,
3884 -- p_asg_start_date IN DATE,
3885 -- p_asg_end_date IN DATE) IS
3886 CURSOR global_element_cur IS
3887 SELECT GREATEST(l_min_start_date, start_date_active) start_date_active,
3888 LEAST(l_max_end_date, end_date_active) end_date_active,
3889 SUM(percent) schedule_percent
3890 FROM psp_element_type_accounts
3891 WHERE business_group_id = p_business_group_id
3892 AND set_of_books_id = p_set_of_books_id
3893 AND element_type_id = p_element_type_id
3894 AND ( gl_code_combination_id IS NOT NULL
3895 OR award_id IS NOT NULL)
3896 AND start_date_active <= l_max_end_date
3897 AND end_date_active >= l_min_start_date
3898 GROUP BY GREATEST(l_min_start_date, start_date_active),
3899 LEAST(l_max_end_date, end_date_active)
3900 ORDER BY start_date_active;
3901
3902 --CURSOR odls_cur (p_asg_start_date IN DATE,
3903 -- p_asg_end_date IN DATE) IS
3904 CURSOR odls_cur IS
3905 SELECT GREATEST(l_min_start_date, paf.effective_start_date, schedule_begin_date) schedule_begin_date,
3906 LEAST(l_max_end_date, paf.effective_end_date, schedule_end_date) schedule_end_date,
3907 SUM(schedule_percent) schedule_percent
3908 FROM per_assignments_f paf,
3909 psp_default_labor_schedules pdls
3910 WHERE paf.assignment_id = p_assignment_id
3911 AND l_min_start_date <= paf.effective_end_date
3912 AND l_max_end_date >= paf.effective_start_date
3913 AND paf.organization_id = pdls.organization_id
3914 AND pdls.business_group_id = p_business_group_id
3915 AND pdls.set_of_books_id = p_set_of_books_id
3916 AND ( gl_code_combination_id IS NOT NULL
3917 OR award_id IS NOT NULL)
3918 AND schedule_begin_date <= l_max_end_date
3919 AND schedule_end_date >= l_min_start_date
3920 GROUP BY GREATEST(l_min_start_date, paf.effective_start_date, schedule_begin_date),
3921 LEAST(l_max_end_date, paf.effective_end_date, schedule_end_date)
3922 ORDER BY 1;
3923
3924 CURSOR ls_hier_cur (p_scheduling_types_code IN VARCHAR2) IS
3925 SELECT psh.schedule_hierarchy_id
3926 FROM psp_schedule_hierarchy psh
3927 WHERE psh.business_group_id = p_business_group_id
3928 AND psh.set_of_books_id = p_set_of_books_id
3929 AND psh.scheduling_types_code = p_scheduling_types_code
3930 AND ( (p_scheduling_types_code = 'ET' AND psh.element_type_id = p_element_type_id)
3931 OR (p_scheduling_types_code = 'A'))
3932 AND psh.assignment_id = p_assignment_id;
3933
3934 /***** Modified the following cursor for 11510_CU2 consolidated performance fixes.
3935 CURSOR eg_hier_cur IS
3936 SELECT DISTINCT schedule_hierarchy_id
3937 FROM psp_schedule_hierarchy psh,
3938 psp_element_groups peg,
3939 psp_group_element_list pgel
3940 WHERE psh.business_group_id = p_business_group_id
3941 AND psh.set_of_books_id = p_set_of_books_id
3942 AND peg.business_group_id = p_business_group_id
3943 AND peg.set_of_books_id = p_set_of_books_id
3944 AND psh.scheduling_types_code = 'EG'
3945 AND psh.element_group_id = peg.element_group_id
3946 AND peg.end_date_active >= r_enc_period.r_period_start_date(1)
3947 AND peg.start_date_active <= r_enc_period.r_period_end_date(l_period_count)
3948 AND pgel.element_type_id = p_element_type_id
3949 AND psh.assignment_id = p_assignment_id;
3950 End of comment for 11510_CU2 consloidated performance fixes. *****/
3951
3952 -- Modified cursor for 11510_CU2 consloidated performance fixes.
3953 CURSOR eg_hier_cur IS
3954 SELECT schedule_hierarchy_id
3955 FROM psp_schedule_hierarchy psh
3956 WHERE EXISTS (SELECT 1
3957 FROM psp_element_groups peg,
3958 psp_group_element_list pgel
3959 WHERE peg.business_group_id = p_business_group_id
3960 AND peg.set_of_books_id = p_set_of_books_id
3961 AND peg.end_date_active >= r_enc_period.r_period_start_date(1)
3962 AND peg.start_date_active <= r_enc_period.r_period_end_date(l_period_count)
3963 AND peg.element_group_id = psh.element_group_id
3964 AND pgel.element_type_id = p_element_type_id)
3965 AND psh.business_group_id = p_business_group_id
3966 AND psh.set_of_books_id = p_set_of_books_id
3967 AND psh.scheduling_types_code = 'EG'
3968 AND psh.assignment_id = p_assignment_id;
3969
3970
3971 CURSOR ls_matrix_cur IS
3972 SELECT GREATEST(l_min_start_date, period_start_date) period_start_date,
3973 LEAST(l_max_end_date, period_end_date) period_end_date,
3974 SUM(period_schedule_percent) schedule_percent
3975 FROM psp_matrix_driver pmd
3976 WHERE run_id = l_run_id
3977 AND period_start_date <= l_max_end_date
3978 AND period_end_date >= l_min_start_date
3979 GROUP BY GREATEST(l_min_start_date, period_start_date),
3980 LEAST(l_max_end_date, period_end_date)
3981 ORDER BY 1;
3982
3983 CURSOR eg_matrix_cur IS
3984 SELECT GREATEST(l_min_start_date, peg.start_date_active, period_start_date) period_start_date,
3985 LEAST(l_max_end_date, peg.end_date_active, period_end_date) period_end_date,
3986 SUM(period_schedule_percent) schedule_percent
3987 FROM psp_matrix_driver pmd,
3988 psp_schedule_lines psl,
3989 psp_schedule_hierarchy psh,
3990 psp_element_groups peg
3991 WHERE run_id = l_run_id
3992 AND psl.schedule_line_id = pmd.schedule_line_id
3993 AND psl.schedule_hierarchy_id = psh.schedule_hierarchy_id
3994 AND psh.element_group_id = peg.element_group_id
3995 AND peg.start_date_active <= l_max_end_date
3996 AND peg.end_date_active >= l_min_start_date
3997 AND period_start_date <= l_max_end_date
3998 AND period_end_date >= l_min_start_date
3999 AND ( gl_code_combination_id IS NOT NULL
4000 OR award_id IS NOT NULL)
4001 GROUP BY GREATEST(l_min_start_date, peg.start_date_active, period_start_date),
4002 LEAST(l_max_end_date, peg.end_date_active, period_end_date)
4003 ORDER BY 1;
4004
4005 -- Introduced the following for bug fix 3970852
4006 TYPE t_date IS TABLE OF DATE INDEX BY BINARY_INTEGER;
4007 TYPE t_char IS TABLE OF CHAR INDEX BY BINARY_INTEGER;
4008 initial_dates t_date;
4009 date_type t_char;
4010
4011 TYPE schedule_chunk_rec IS RECORD
4012 (schedule_begin_date t_date,
4013 schedule_end_date t_date);
4014 schedule_chunk schedule_chunk_rec;
4015
4016 CURSOR sched_lines(schedule_hierarchy_id NUMBER) IS
4017 SELECT schedule_line_id l_id,
4018 schedule_begin_date sbd,
4019 schedule_end_date sed,
4020 schedule_percent sp
4021 FROM psp_schedule_lines
4022 WHERE schedule_hierarchy_id = schedule_hierarchy_id
4023 AND ( gl_code_combination_id IS NOT NULL
4024 OR award_id IS NOT NULL)
4025 AND schedule_end_date >= l_min_start_date
4026 AND schedule_begin_date <= l_max_end_date;
4027
4028 CURSOR dates(p_schedule_hierarchy_id NUMBER) IS
4029 SELECT schedule_begin_date dat , 'B'
4030 FROM psp_schedule_lines
4031 WHERE schedule_hierarchy_id = p_schedule_hierarchy_id
4032 AND ( gl_code_combination_id IS NOT NULL
4033 OR award_id IS NOT NULL)
4034 AND schedule_end_date >= l_min_start_date
4035 AND schedule_begin_date <= l_max_end_date
4036 UNION
4037 SELECT schedule_end_date dat , 'E'
4038 FROM psp_schedule_lines
4039 WHERE schedule_hierarchy_id = p_schedule_hierarchy_id
4040 AND ( gl_code_combination_id IS NOT NULL
4041 OR award_id IS NOT NULL)
4042 AND schedule_end_date >= l_min_start_date
4043 AND schedule_begin_date <= l_max_end_date
4044 ORDER BY 1, 2 ;
4045
4046 recno INTEGER;
4047 -- End of bug fix 3970852
4048 BEGIN
4049 psp_matrix_driver_pkg.set_runid;
4050 l_run_id := psp_matrix_driver_pkg.get_run_id;
4051
4052 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering ' || l_proc_name);
4053 hr_utility.trace('p_assignment_id: ' || fnd_number.number_to_canonical(p_assignment_id) ||
4054 ' p_element_type_id: ' || fnd_number.number_to_canonical(p_element_type_id) ||
4055 ' p_business_group_id: ' || fnd_number.number_to_canonical(p_business_group_id) ||
4056 ' p_set_of_books_id: ' || fnd_number.number_to_canonical(p_set_of_books_id) ||
4057 ' r_enc_period.r_time_period_id.COUNT: ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id.COUNT));
4058 hr_utility.trace('Dumping Assignment Chunk Before Global Element Processing ...');
4059 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
4060 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
4061 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
4062 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
4063 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
4064 RPAD('Reason Code', 50, ' '));
4065
4066 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
4067 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
4068 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
4069 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
4070 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
4071 RPAD('-', 50, '-'));
4072
4073 FOR recno IN 1..r_enc_period.r_time_period_id.COUNT
4074 LOOP
4075 hr_utility.trace(LPAD(recno, 13, ' ') || ' ' ||
4076 LPAD(r_enc_period.r_time_period_id(recno), 14, ' ') || ' ' ||
4077 RPAD(TO_CHAR(r_enc_period.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
4078 RPAD(TO_CHAR(r_enc_period.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
4079 RPAD(TO_CHAR(r_enc_period.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
4080 RPAD(TO_CHAR(r_enc_period.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
4081 RPAD(TO_CHAR(r_enc_period.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
4082 RPAD(r_enc_period.r_process_flag(recno), 12, ' ') || ' ' ||
4083 LPAD(r_enc_period.r_schedule_percent(recno), 16, ' ') || ' ' ||
4084 RPAD(r_enc_period.r_reason_code(recno), 50, ' '));
4085 END LOOP;
4086 hr_utility.trace('Global Element Processing');
4087
4088 l_proc_step := 10;
4089 l_sch_pointer := 1;
4090
4091 OPEN global_element_cur;
4092 FETCH global_element_cur BULK COLLECT INTO r_sch_rec.start_date, r_sch_rec.end_date, r_sch_rec.schedule_percent;
4093 CLOSE global_element_cur;
4094
4095 hr_utility.trace('r_sch_rec.start_date.COUNT: ' || r_sch_rec.start_date.COUNT);
4096 hr_utility.trace('Schedule Chunk Details');
4097 hr_utility.trace(RPAD('Start Date', 15, ' ') || ' ' ||
4098 RPAD('End Date', 15, ' ') || ' ' || LPAD('Schedule Percent', 16, ' '));
4099
4100 hr_utility.trace(RPAD('-', 15, '-') || ' ' ||
4101 RPAD('-', 15, '-') || ' ' || RPAD('-', 16, '-'));
4102
4103 FOR recno IN 1..r_sch_rec.start_date.COUNT
4104 LOOP
4105 hr_utility.trace(RPAD(TO_CHAR(r_sch_rec.start_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
4106 RPAD(TO_CHAR(r_sch_rec.end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
4107 LPAD(r_sch_rec.schedule_percent(recno), 16, ' '));
4108 END LOOP;
4109
4110 FOR I IN 1..r_enc_period.r_time_period_id.COUNT
4111 LOOP
4112 l_period_start_date := r_enc_period.r_period_start_date(I);
4113 l_period_end_date := r_enc_period.r_period_end_date(I);
4114 l_asg_start_date := r_enc_period.r_asg_start_date(I);
4115 l_asg_end_date := r_enc_period.r_asg_end_date(I);
4116 l_sub_slice_counter := 1;
4117 l_proc_step := 20 + (I / 100000);
4118
4119 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
4120 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
4121 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
4122 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
4123 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
4124 ' r_enc_period.r_time_period_id(I): ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id(I)) ||
4125 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no));
4126
4127 IF (r_sch_rec.end_date.COUNT > 0) THEN
4128 FOR ge_recno IN l_sch_pointer..r_sch_rec.start_date.COUNT
4129 LOOP
4130 l_start_date:= r_sch_rec.start_date(ge_recno);
4131 l_end_date:= r_sch_rec.end_date(ge_recno);
4132 l_schedule_percent:= r_sch_rec.schedule_percent(ge_recno);
4133 l_proc_step := 30 + (ge_recno / 100000);
4134 -- OPEN global_element_cur(l_period_start_date, l_period_end_date, l_asg_start_date, l_asg_end_date);
4135 -- FETCH global_element_cur INTO l_start_date, l_end_date, l_schedule_percent;
4136
4137 hr_utility.trace('l_sub_slice_counter: ' || fnd_number.number_to_canonical(l_sub_slice_counter) ||
4138 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no) ||
4139 ' l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
4140 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
4141 ' l_schedule_percent: ' || fnd_number.number_to_canonical(l_schedule_percent));
4142 -- hr_utility.trace('global_element_cur%ROWCOUNT: ' || fnd_number.number_to_canonical(global_element_cur%ROWCOUNT));
4143
4144 -- IF (global_element_cur%NOTFOUND) THEN
4145 IF (l_start_date > l_asg_end_date) THEN
4146 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4147 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4148 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4149 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4150 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4151 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4152 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4153 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
4154 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4155 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4156 l_rec_no := l_rec_no + 1;
4157 EXIT;
4158 END IF;
4159 -- CLOSE global_element_cur;
4160 -- EXIT;
4161 -- END IF;
4162 -- CLOSE global_element_cur;
4163
4164 IF (l_end_date >= l_asg_start_date) AND (l_start_date <= l_asg_end_date) THEN
4165 IF (l_asg_start_date = l_start_date AND l_asg_end_date = l_end_date) THEN
4166 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4167 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4168 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4169 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4170 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4171 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4172 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4173 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'GE';
4174 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4175 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4176 l_rec_no := l_rec_no + 1;
4177 IF (l_schedule_percent < 100) THEN
4178 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4179 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4180 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4181 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4182 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4183 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4184 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4185 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
4186 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
4187 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4188 l_rec_no := l_rec_no + 1;
4189 END IF;
4190 EXIT;
4191 ELSE
4192 IF (l_start_date > GREATEST(l_period_start_date, l_asg_start_date)) THEN
4193 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date);
4194 l_new_end_date := l_start_date - 1;
4195 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4196 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4197 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4198 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
4199 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
4200 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4201 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4202 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
4203 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4204 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4205 l_rec_no := l_rec_no + 1;
4206 l_asg_start_date := l_start_date;
4207 END IF;
4208
4209 IF (l_end_date < LEAST(l_period_end_date, l_asg_end_date)) THEN
4210 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date, l_start_date);
4211 l_new_end_date := l_end_date;
4212 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4213 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4214 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4215 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
4216 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
4217 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4218 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4219 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'GE';
4220 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4221 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4222 l_rec_no := l_rec_no + 1;
4223 IF (l_schedule_percent < 100) THEN
4224 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4225 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4226 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4227 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
4228 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
4229 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4230 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4231 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
4232 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
4233 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4234 l_rec_no := l_rec_no + 1;
4235 END IF;
4236 l_asg_start_date := l_end_date + 1;
4237 IF (ge_recno = r_sch_rec.start_date.COUNT) AND
4238 (l_asg_start_date <= l_asg_end_date) THEN
4239 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4240 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4241 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4242 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4243 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4244 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4245 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4246 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
4247 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4248 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4249 l_rec_no := l_rec_no + 1;
4250 END IF;
4251 ELSE
4252 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4253 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4254 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4255 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4256 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4257 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4258 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4259 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'GE';
4260 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4261 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4262 l_rec_no := l_rec_no + 1;
4263 IF (l_schedule_percent < 100) THEN
4264 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4265 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4266 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4267 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4268 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4269 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4270 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4271 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
4272 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
4273 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4274 l_rec_no := l_rec_no + 1;
4275 END IF;
4276 l_asg_start_date := l_end_date + 1;
4277 END IF;
4278 END IF;
4279 l_sub_slice_counter := 2;
4280 ELSE
4281 IF (ge_recno = r_sch_rec.start_date.COUNT) THEN
4282 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4283 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4284 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4285 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4286 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4287 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4288 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4289 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
4290 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4291 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4292 l_rec_no := l_rec_no + 1;
4293 END IF;
4294 END IF;
4295 l_sch_pointer := ge_recno;
4296 EXIT WHEN l_asg_start_date > l_asg_end_date;
4297 END LOOP;
4298 ELSE
4299 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4300 r_enc_period_tmp1.r_period_start_date(l_rec_no) := r_enc_period.r_period_start_date(I);
4301 r_enc_period_tmp1.r_period_end_date(l_rec_no) := r_enc_period.r_period_end_date(I);
4302 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := r_enc_period.r_asg_start_date(I);
4303 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := r_enc_period.r_asg_end_date(I);
4304 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4305 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4306 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
4307 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4308 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4309 l_rec_no := l_rec_no + 1;
4310 END IF;
4311 END LOOP;
4312
4313 r_sch_rec.start_date.delete;
4314 r_sch_rec.end_date.delete;
4315 r_sch_rec.schedule_percent.delete;
4316 r_enc_period.r_time_period_id.DELETE;
4317 r_enc_period.r_period_start_date.DELETE;
4318 r_enc_period.r_period_end_date.DELETE;
4319 r_enc_period.r_asg_start_date.DELETE;
4320 r_enc_period.r_asg_end_date.DELETE;
4321 r_enc_period.r_process_flag.DELETE;
4322 r_enc_period.r_period_ind.DELETE;
4323 r_enc_period.r_schedule_percent.DELETE;
4324 r_enc_period.r_encumbrance_amount.DELETE;
4325 r_enc_period.r_period_amount.DELETE;
4326 r_enc_period.r_reason_code.DELETE;
4327 r_enc_period.r_effective_date.DELETE;
4328 l_rec_no := 1;
4329 l_proc_step := 40;
4330
4331 hr_utility.trace('Dumping Assignment Chunk After Global Element Processing ...');
4332 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
4333 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
4334 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
4335 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
4336 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
4337 RPAD('Reason Code', 50, ' '));
4338
4339 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
4340 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
4341 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
4342 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
4343 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
4344 RPAD('-', 50, '-'));
4345
4346 FOR recno IN 1..r_enc_period_tmp1.r_time_period_id.COUNT
4347 LOOP
4348 hr_utility.trace(LPAD(recno, 13, ' ') || ' ' ||
4349 LPAD(r_enc_period_tmp1.r_time_period_id(recno), 14, ' ') || ' ' ||
4350 RPAD(TO_CHAR(r_enc_period_tmp1.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
4351 RPAD(TO_CHAR(r_enc_period_tmp1.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
4352 RPAD(TO_CHAR(r_enc_period_tmp1.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
4353 RPAD(TO_CHAR(r_enc_period_tmp1.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
4354 RPAD(TO_CHAR(r_enc_period_tmp1.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
4355 RPAD(r_enc_period_tmp1.r_process_flag(recno), 12, ' ') || ' ' ||
4356 LPAD(r_enc_period_tmp1.r_schedule_percent(recno), 16, ' ') || ' ' ||
4357 RPAD(r_enc_period_tmp1.r_reason_code(recno), 50, ' '));
4358 END LOOP;
4359 hr_utility.trace('Element Type Processing ...');
4360
4361 OPEN ls_hier_cur('ET');
4362 FETCH ls_hier_cur INTO l_schedule_hierarchy_id;
4363 CLOSE ls_hier_cur;
4364
4365 /***** Commented for bug fix 3970852 to resolve issues when schedule dates equal default end date
4366 psp_matrix_driver_pkg.clear_table('REFRESH');
4367 psp_matrix_driver_pkg.purge_table;
4368 psp_matrix_driver_pkg.load_table(l_schedule_hierarchy_id);
4369
4370 DELETE psp_matrix_driver
4371 WHERE run_id = l_run_id
4372 AND (period_start_date > l_max_end_date
4373 OR period_end_date < l_min_start_date
4374 OR period_schedule_percent = 0);
4375
4376 UPDATE psp_matrix_driver pmd
4377 SET period_end_date = period_end_date - 1
4378 WHERE run_id = l_run_id
4379 AND period_start_date < period_end_date
4380 AND period_start_date = (SELECT MIN(psl1.schedule_begin_date)
4381 FROM psp_schedule_lines psl1
4382 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
4383 AND EXISTS (SELECT 1
4384 FROM psp_schedule_lines psl1
4385 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
4386 AND psl1.schedule_begin_date = pmd.period_end_date
4387 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
4388
4389 UPDATE psp_matrix_driver pmd
4390 SET period_end_date = period_end_date - 1
4391 WHERE run_id = l_run_id
4392 AND period_start_date < period_end_date
4393 AND NOT (NOT EXISTS (SELECT 1
4394 FROM psp_schedule_lines psl1
4395 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
4396 AND psl1.schedule_begin_date = pmd.period_end_date
4397 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
4398 AND EXISTS (SELECT 1
4399 FROM psp_schedule_lines psl1
4400 WHERE psl1.schedule_end_date = pmd.period_end_date
4401 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id))
4402 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
4403 FROM psp_schedule_lines psl1
4404 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
4405
4406 UPDATE psp_matrix_driver pmd
4407 SET period_start_date = period_start_date + 1
4408 WHERE run_id = l_run_id
4409 AND period_start_date < period_end_date
4410 AND NOT EXISTS (SELECT 1
4411 FROM psp_schedule_lines psl1
4412 WHERE psl1.schedule_begin_date = pmd.period_start_date
4413 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
4414 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
4415 FROM psp_schedule_lines psl1
4416 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
4417
4418 UPDATE psp_matrix_driver pmd
4419 SET period_start_date = period_start_date + 1
4420 WHERE run_id = l_run_id
4421 AND period_start_date < period_end_date
4422 AND EXISTS (SELECT 1
4423 FROM psp_schedule_lines psl1
4424 WHERE psl1.schedule_begin_date = pmd.period_start_date
4425 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
4426 AND EXISTS (SELECT 1
4427 FROM psp_schedule_lines psl1
4428 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
4429 AND psl1.schedule_end_date = pmd.period_start_date
4430 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
4431 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
4432 FROM psp_schedule_lines psl1
4433 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
4434 End of comment for bug fix 3970852 *****/
4435
4436 -- Introduced the following to prepare schedule chunk dates instead of load_table for bug fix 3970852
4437 recno := 1;
4438
4439 OPEN dates(l_schedule_hierarchy_id);
4440 FETCH dates BULK COLLECT INTO initial_dates, date_type;
4441 CLOSE dates;
4442
4443 FOR rowno IN 1..(initial_dates.COUNT - 1)
4444 LOOP
4445 IF (date_type(rowno) = 'B' AND date_type(rowno+1) = 'B') THEN
4446 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno);
4447 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1) - 1;
4448 recno := recno+1;
4449 ELSIF (date_type(rowno) = 'B' AND date_type(rowno+1) = 'E') THEN
4450 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno);
4451 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1);
4452 recno := recno+1;
4453 ELSIF (date_type(rowno) = 'E' AND date_type(rowno+1) = 'E') THEN
4454 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno) + 1;
4455 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1);
4456 recno := recno+1;
4457 ELSIF (date_type(rowno) = 'E' AND date_type(rowno+1) = 'B') THEN
4458 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno) + 1;
4459 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1) -1;
4460 recno := recno+1;
4461 END IF;
4462 END LOOP;
4463
4464 FORALL rowno IN 1..schedule_chunk.schedule_begin_date.COUNT
4465 INSERT INTO psp_matrix_driver
4466 (RUN_ID, SCHEDULE_LINE_ID,
4467 PERIOD_START_DATE,
4468 PERIOD_END_DATE,
4469 PERIOD_SCHEDULE_PERCENT)
4470 SELECT l_run_id, schedule_line_id,
4471 GREATEST(l_min_start_date, schedule_chunk.schedule_begin_date(rowno)),
4472 LEAST(l_max_end_date, schedule_chunk.schedule_end_date(rowno)),
4473 schedule_percent
4474 FROM psp_schedule_lines psl
4475 WHERE schedule_hierarchy_id = l_schedule_hierarchy_id
4476 AND schedule_end_date >= l_min_start_date
4477 AND schedule_begin_date <= l_max_end_date
4478 AND ( gl_code_combination_id IS NOT NULL
4479 OR award_id IS NOT NULL)
4480 AND psl.schedule_begin_date <= schedule_chunk.schedule_end_date(rowno)
4481 AND psl.schedule_end_date >= schedule_chunk.schedule_begin_date(rowno);
4482
4483 initial_dates.delete;
4484 date_type.delete;
4485 schedule_chunk.schedule_end_date.delete;
4486 schedule_chunk.schedule_begin_date.delete;
4487 -- End of bug fix 3970852
4488
4489 l_sch_pointer := 1;
4490 OPEN ls_matrix_cur;
4491 FETCH ls_matrix_cur BULK COLLECT INTO r_sch_rec.start_date, r_sch_rec.end_date, r_sch_rec.schedule_percent;
4492 CLOSE ls_matrix_cur;
4493
4494 hr_utility.trace('r_sch_rec.start_date.COUNT: ' || r_sch_rec.start_date.COUNT);
4495 hr_utility.trace('Schedule Chunk Details');
4496 hr_utility.trace(RPAD('Start Date', 15, ' ') || ' ' ||
4497 RPAD('End Date', 15, ' ') || ' ' || LPAD('Schedule Percent', 16, ' '));
4498 hr_utility.trace(RPAD('-', 15, '-') || ' ' ||
4499 RPAD('-', 15, '-') || ' ' || RPAD('-', 16, '-'));
4500
4501 FOR recno IN 1..r_sch_rec.start_date.COUNT
4502 LOOP
4503 hr_utility.trace(RPAD(TO_CHAR(r_sch_rec.start_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
4504 RPAD(TO_CHAR(r_sch_rec.end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
4505 LPAD(r_sch_rec.schedule_percent(recno), 16, ' '));
4506 END LOOP;
4507
4508 FOR I IN 1..r_enc_period_tmp1.r_time_period_id.COUNT
4509 LOOP
4510 l_period_start_date := r_enc_period_tmp1.r_period_start_date(I);
4511 l_period_end_date := r_enc_period_tmp1.r_period_end_date(I);
4512 l_asg_start_date := r_enc_period_tmp1.r_asg_start_date(I);
4513 l_asg_end_date := r_enc_period_tmp1.r_asg_end_date(I);
4514 l_process_flag := r_enc_period_tmp1.r_process_flag(I);
4515 l_sub_slice_counter := 1;
4516 l_proc_step := 50 + (I / 100000);
4517
4518 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
4519 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
4520 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
4521 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
4522 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
4523 ' r_enc_period_tmp1.r_time_period_id(I): ' || fnd_number.number_to_canonical(r_enc_period_tmp1.r_time_period_id(I)) ||
4524 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no));
4525
4526 IF (l_process_flag = 'Y') AND (r_sch_rec.end_date.COUNT > 0) THEN
4527 FOR et_recno IN l_sch_pointer..r_sch_rec.start_date.COUNT
4528 LOOP
4529 l_start_date:= r_sch_rec.start_date(et_recno);
4530 l_end_date:= r_sch_rec.end_date(et_recno);
4531 l_schedule_percent:= r_sch_rec.schedule_percent(et_recno);
4532 l_proc_step := 60 + (et_recno / 100000);
4533
4534 hr_utility.trace(' l_sub_slice_counter: ' || fnd_number.number_to_canonical(l_sub_slice_counter) ||
4535 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no) ||
4536 ' l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
4537 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
4538 ' l_schedule_percent: ' || fnd_number.number_to_canonical(l_schedule_percent));
4539
4540 -- OPEN ls_matrix_cur;
4541 -- FETCH ls_matrix_cur INTO l_start_date, l_end_date, l_schedule_percent;
4542 -- IF (ls_matrix_cur%NOTFOUND) THEN
4543 IF (l_start_date > l_asg_end_date) THEN
4544 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4545 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4546 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4547 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
4548 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
4549 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4550 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4551 r_enc_period.r_process_flag(l_rec_no) := 'Y';
4552 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
4553 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4554 l_rec_no := l_rec_no + 1;
4555 EXIT;
4556 END IF;
4557 -- CLOSE ls_matrix_cur;
4558 -- EXIT;
4559 -- END IF;
4560 -- CLOSE ls_matrix_cur;
4561
4562 IF (l_end_date >= l_asg_start_date) AND (l_start_date <= l_asg_end_date) THEN
4563 IF (l_asg_start_date = l_start_date AND l_asg_end_date = l_end_date) THEN
4564 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4565 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4566 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4567 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
4568 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
4569 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4570 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4571 r_enc_period.r_process_flag(l_rec_no) := 'ET';
4572 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
4573 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4574 l_rec_no := l_rec_no + 1;
4575 IF (l_schedule_percent < 100) THEN
4576 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4577 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4578 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4579 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
4580 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
4581 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4582 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4583 r_enc_period.r_process_flag(l_rec_no) := 'BAL';
4584 r_enc_period.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
4585 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4586 l_rec_no := l_rec_no + 1;
4587 END IF;
4588 EXIT;
4589 ELSE
4590 IF (l_start_date > GREATEST(l_period_start_date, l_asg_start_date)) THEN
4591 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date);
4592 l_new_end_date := l_start_date - 1;
4593 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4594 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4595 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4596 r_enc_period.r_asg_start_date(l_rec_no) := l_new_start_date;
4597 r_enc_period.r_asg_end_date(l_rec_no) := l_new_end_date;
4598 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4599 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4600 r_enc_period.r_process_flag(l_rec_no) := 'Y';
4601 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
4602 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4603 l_rec_no := l_rec_no + 1;
4604 l_asg_start_date := l_start_date;
4605 END IF;
4606
4607 IF (l_end_date < LEAST(l_period_end_date, l_asg_end_date)) THEN
4608 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date, l_start_date);
4609 l_new_end_date := l_end_date;
4610 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4611 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4612 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4613 r_enc_period.r_asg_start_date(l_rec_no) := l_new_start_date;
4614 r_enc_period.r_asg_end_date(l_rec_no) := l_new_end_date;
4615 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4616 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4617 r_enc_period.r_process_flag(l_rec_no) := 'ET';
4618 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
4619 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4620 l_rec_no := l_rec_no + 1;
4621 IF (l_schedule_percent < 100) THEN
4622 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4623 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4624 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4625 r_enc_period.r_asg_start_date(l_rec_no) := l_new_start_date;
4626 r_enc_period.r_asg_end_date(l_rec_no) := l_new_end_date;
4627 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4628 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4629 r_enc_period.r_process_flag(l_rec_no) := 'BAL';
4630 r_enc_period.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
4631 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4632 l_rec_no := l_rec_no + 1;
4633 END IF;
4634 l_asg_start_date := l_end_date + 1;
4635 IF (et_recno = r_sch_rec.start_date.COUNT) AND
4636 (l_asg_start_date <= l_asg_end_date) THEN
4637 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4638 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4639 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4640 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
4641 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
4642 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4643 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4644 r_enc_period.r_process_flag(l_rec_no) := 'Y';
4645 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
4646 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4647 l_rec_no := l_rec_no + 1;
4648 END IF;
4649 ELSE
4650 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4651 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4652 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4653 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
4654 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
4655 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4656 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4657 r_enc_period.r_process_flag(l_rec_no) := 'ET';
4658 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
4659 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4660 l_rec_no := l_rec_no + 1;
4661 IF (l_schedule_percent < 100) THEN
4662 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4663 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4664 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4665 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
4666 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
4667 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4668 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4669 r_enc_period.r_process_flag(l_rec_no) := 'BAL';
4670 r_enc_period.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
4671 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4672 l_rec_no := l_rec_no + 1;
4673 END IF;
4674 l_asg_start_date := l_end_date + 1;
4675 END IF;
4676 END IF;
4677 l_sub_slice_counter := 2;
4678 ELSE
4679 IF (et_recno = r_sch_rec.start_date.COUNT) THEN
4680 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4681 r_enc_period.r_period_start_date(l_rec_no) := r_enc_period_tmp1.r_period_start_date(I);
4682 r_enc_period.r_period_end_date(l_rec_no) := r_enc_period_tmp1.r_period_end_date(I);
4683 r_enc_period.r_asg_start_date(l_rec_no) := r_enc_period_tmp1.r_asg_start_date(I);
4684 r_enc_period.r_asg_end_date(l_rec_no) := r_enc_period_tmp1.r_asg_end_date(I);
4685 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4686 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4687 r_enc_period.r_process_flag(l_rec_no) := r_enc_period_tmp1.r_process_flag(I);
4688 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
4689 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4690 l_rec_no := l_rec_no + 1;
4691 END IF;
4692 END IF;
4693 l_sch_pointer := et_recno;
4694 EXIT WHEN l_asg_start_date > l_asg_end_date;
4695 END LOOP;
4696 ELSE
4697 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4698 r_enc_period.r_period_start_date(l_rec_no) := r_enc_period_tmp1.r_period_start_date(I);
4699 r_enc_period.r_period_end_date(l_rec_no) := r_enc_period_tmp1.r_period_end_date(I);
4700 r_enc_period.r_asg_start_date(l_rec_no) := r_enc_period_tmp1.r_asg_start_date(I);
4701 r_enc_period.r_asg_end_date(l_rec_no) := r_enc_period_tmp1.r_asg_end_date(I);
4702 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4703 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4704 r_enc_period.r_process_flag(l_rec_no) := r_enc_period_tmp1.r_process_flag(I);
4705 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
4706 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4707 l_rec_no := l_rec_no + 1;
4708 END IF;
4709 END LOOP;
4710
4711 r_sch_rec.start_date.delete;
4712 r_sch_rec.end_date.delete;
4713 r_sch_rec.schedule_percent.delete;
4714 r_enc_period_tmp1.r_time_period_id.DELETE;
4715 r_enc_period_tmp1.r_period_start_date.DELETE;
4716 r_enc_period_tmp1.r_period_end_date.DELETE;
4717 r_enc_period_tmp1.r_asg_start_date.DELETE;
4718 r_enc_period_tmp1.r_asg_end_date.DELETE;
4719 r_enc_period_tmp1.r_process_flag.DELETE;
4720 r_enc_period_tmp1.r_period_ind.DELETE;
4721 r_enc_period_tmp1.r_schedule_percent.DELETE;
4722 r_enc_period_tmp1.r_encumbrance_amount.DELETE;
4723 r_enc_period_tmp1.r_period_amount.DELETE;
4724 r_enc_period_tmp1.r_reason_code.DELETE;
4725 r_enc_period_tmp1.r_effective_date.DELETE;
4726 l_rec_no := 1;
4727 l_proc_step := 70;
4728
4729 hr_utility.trace('Dumping Assignment Chunk After Element Type Processing ...');
4730 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
4731 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
4732 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
4733 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
4734 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
4735 RPAD('Reason Code', 50, ' '));
4736 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
4737 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
4738 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
4739 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
4740 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
4741 RPAD('-', 50, '-'));
4742
4743 FOR recno IN 1..r_enc_period.r_time_period_id.COUNT
4744 LOOP
4745 hr_utility.trace(LPAD(r_enc_period.r_period_ind(recno), 13, ' ') || ' ' ||
4746 LPAD(r_enc_period.r_time_period_id(recno), 14, ' ') || ' ' ||
4747 RPAD(TO_CHAR(r_enc_period.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
4748 RPAD(TO_CHAR(r_enc_period.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
4749 RPAD(TO_CHAR(r_enc_period.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
4750 RPAD(TO_CHAR(r_enc_period.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
4751 RPAD(TO_CHAR(r_enc_period.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
4752 RPAD(r_enc_period.r_process_flag(recno), 12, ' ') || ' ' ||
4753 LPAD(r_enc_period.r_schedule_percent(recno), 16, ' ') || ' ' ||
4754 RPAD(r_enc_period.r_reason_code(recno), 50, ' '));
4755 END LOOP;
4756 hr_utility.trace('Element Group Processing ...');
4757
4758 psp_matrix_driver_pkg.clear_table('REFRESH');
4759 psp_matrix_driver_pkg.purge_table;
4760 l_period_count := r_enc_period.r_time_period_id.COUNT;
4761 OPEN eg_hier_cur;
4762 LOOP
4763 FETCH eg_hier_cur INTO l_schedule_hierarchy_id;
4764 EXIT WHEN eg_hier_cur%NOTFOUND;
4765
4766 /***** Commented for bug fix 3970852 to resolve issues when schedule dates equal default end date
4767 psp_matrix_driver_pkg.load_table(l_schedule_hierarchy_id);
4768
4769 DELETE psp_matrix_driver
4770 WHERE run_id = l_run_id
4771 AND (period_start_date > l_max_end_date
4772 OR period_end_date < l_min_start_date
4773 OR period_schedule_percent = 0);
4774
4775 UPDATE psp_matrix_driver pmd
4776 SET period_end_date = period_end_date - 1
4777 WHERE run_id = l_run_id
4778 AND period_start_date < period_end_date
4779 AND period_start_date = (SELECT MIN(psl1.schedule_begin_date)
4780 FROM psp_schedule_lines psl1
4781 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
4782 AND EXISTS (SELECT 1
4783 FROM psp_schedule_lines psl1
4784 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
4785 AND psl1.schedule_begin_date = pmd.period_end_date
4786 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
4787
4788 UPDATE psp_matrix_driver pmd
4789 SET period_end_date = period_end_date - 1
4790 WHERE run_id = l_run_id
4791 AND period_start_date < period_end_date
4792 AND NOT (NOT EXISTS (SELECT 1
4793 FROM psp_schedule_lines psl1
4794 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
4795 AND psl1.schedule_begin_date = pmd.period_end_date
4796 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
4797 AND EXISTS (SELECT 1
4798 FROM psp_schedule_lines psl1
4799 WHERE psl1.schedule_end_date = pmd.period_end_date
4800 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id))
4801 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
4802 FROM psp_schedule_lines psl1
4803 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
4804
4805 UPDATE psp_matrix_driver pmd
4806 SET period_start_date = period_start_date + 1
4807 WHERE run_id = l_run_id
4808 AND period_start_date < period_end_date
4809 AND NOT EXISTS (SELECT 1
4810 FROM psp_schedule_lines psl1
4811 WHERE psl1.schedule_begin_date = pmd.period_start_date
4812 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
4813 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
4814 FROM psp_schedule_lines psl1
4815 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
4816
4817 UPDATE psp_matrix_driver pmd
4818 SET period_start_date = period_start_date + 1
4819 WHERE run_id = l_run_id
4820 AND period_start_date < period_end_date
4821 AND EXISTS (SELECT 1
4822 FROM psp_schedule_lines psl1
4823 WHERE psl1.schedule_begin_date = pmd.period_start_date
4824 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
4825 AND EXISTS (SELECT 1
4826 FROM psp_schedule_lines psl1
4827 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
4828 AND psl1.schedule_end_date = pmd.period_start_date
4829 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
4830 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
4831 FROM psp_schedule_lines psl1
4832 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
4833 End of comment for bug fix 3970852 *****/
4834
4835 -- Introduced the following to prepare schedule chunk dates instead of load_table for bug fix 3970852
4836 recno := 1;
4837
4838 OPEN dates(l_schedule_hierarchy_id);
4839 FETCH dates BULK COLLECT INTO initial_dates, date_type;
4840 CLOSE dates;
4841
4842 FOR rowno IN 1..(initial_dates.COUNT - 1)
4843 LOOP
4844 IF (date_type(rowno) = 'B' AND date_type(rowno+1) = 'B') THEN
4845 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno);
4846 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1) - 1;
4847 recno := recno+1;
4848 ELSIF (date_type(rowno) = 'B' AND date_type(rowno+1) = 'E') THEN
4849 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno);
4850 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1);
4851 recno := recno+1;
4852 ELSIF (date_type(rowno) = 'E' AND date_type(rowno+1) = 'E') THEN
4853 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno) + 1;
4854 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1);
4855 recno := recno+1;
4856 ELSIF (date_type(rowno) = 'E' AND date_type(rowno+1) = 'B') THEN
4857 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno) + 1;
4858 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1) -1;
4859 recno := recno+1;
4860 END IF;
4861 END LOOP;
4862
4863 FORALL rowno IN 1..schedule_chunk.schedule_begin_date.COUNT
4864 INSERT INTO psp_matrix_driver
4865 (RUN_ID, SCHEDULE_LINE_ID,
4866 PERIOD_START_DATE,
4867 PERIOD_END_DATE,
4868 PERIOD_SCHEDULE_PERCENT)
4869 SELECT l_run_id, schedule_line_id,
4870 GREATEST(l_min_start_date, schedule_chunk.schedule_begin_date(rowno)),
4871 LEAST(l_max_end_date, schedule_chunk.schedule_end_date(rowno)),
4872 schedule_percent
4873 FROM psp_schedule_lines psl
4874 WHERE schedule_hierarchy_id = l_schedule_hierarchy_id
4875 AND schedule_end_date >= l_min_start_date
4876 AND schedule_begin_date <= l_max_end_date
4877 AND ( gl_code_combination_id IS NOT NULL
4878 OR award_id IS NOT NULL)
4879 AND psl.schedule_begin_date <= schedule_chunk.schedule_end_date(rowno)
4880 AND psl.schedule_end_date >= schedule_chunk.schedule_begin_date(rowno);
4881
4882 initial_dates.delete;
4883 date_type.delete;
4884 schedule_chunk.schedule_end_date.delete;
4885 schedule_chunk.schedule_begin_date.delete;
4886 -- End of bug fix 3970852
4887 END LOOP;
4888 CLOSE eg_hier_cur;
4889
4890 l_sch_pointer := 1;
4891 OPEN eg_matrix_cur;
4892 FETCH eg_matrix_cur BULK COLLECT INTO r_sch_rec.start_date, r_sch_rec.end_date, r_sch_rec.schedule_percent;
4893 CLOSE eg_matrix_cur;
4894
4895 hr_utility.trace('r_sch_rec.start_date.COUNT: ' || r_sch_rec.start_date.COUNT);
4896 hr_utility.trace('Schedule Chunk Details');
4897 hr_utility.trace(RPAD('Start Date', 15, ' ') || ' ' ||
4898 RPAD('End Date', 15, ' ') || ' ' || LPAD('Schedule Percent', 16, ' '));
4899 hr_utility.trace(RPAD('-', 15, '-') || ' ' ||
4900 RPAD('-', 15, '-') || ' ' || RPAD('-', 16, '-'));
4901
4902 FOR recno IN 1..r_sch_rec.start_date.COUNT
4903 LOOP
4904 hr_utility.trace(RPAD(TO_CHAR(r_sch_rec.start_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
4905 RPAD(TO_CHAR(r_sch_rec.end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
4906 LPAD(r_sch_rec.schedule_percent(recno), 16, ' '));
4907 END LOOP;
4908
4909 FOR I IN 1..r_enc_period.r_time_period_id.COUNT
4910 LOOP
4911 l_period_start_date := r_enc_period.r_period_start_date(I);
4912 l_period_end_date := r_enc_period.r_period_end_date(I);
4913 l_asg_start_date := r_enc_period.r_asg_start_date(I);
4914 l_asg_end_date := r_enc_period.r_asg_end_date(I);
4915 l_process_flag := r_enc_period.r_process_flag(I);
4916 l_sub_slice_counter := 1;
4917 l_proc_step := 80 + (I / 100000);
4918
4919 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
4920 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
4921 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
4922 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
4923 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
4924 ' r_enc_period.r_time_period_id(I): ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id(I)) ||
4925 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no));
4926
4927 IF (l_process_flag = 'Y') AND (r_sch_rec.end_date.COUNT > 0) THEN
4928 FOR eg_recno IN l_sch_pointer..r_sch_rec.start_date.COUNT
4929 LOOP
4930 l_start_date:= r_sch_rec.start_date(eg_recno);
4931 l_end_date:= r_sch_rec.end_date(eg_recno);
4932 l_schedule_percent:= r_sch_rec.schedule_percent(eg_recno);
4933 l_proc_step := 90 + (eg_recno / 100000);
4934
4935 hr_utility.trace(' l_sub_slice_counter: ' || fnd_number.number_to_canonical(l_sub_slice_counter) ||
4936 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no) ||
4937 ' l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
4938 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
4939 ' l_schedule_percent: ' || fnd_number.number_to_canonical(l_schedule_percent));
4940
4941 -- OPEN eg_matrix_cur;
4942 -- FETCH eg_matrix_cur INTO l_start_date, l_end_date, l_schedule_percent;
4943 -- IF (eg_matrix_cur%NOTFOUND) THEN
4944 IF (l_start_date > l_asg_end_date) THEN
4945 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
4946 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4947 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4948 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4949 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4950 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4951 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4952 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
4953 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4954 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4955 l_rec_no := l_rec_no + 1;
4956 EXIT;
4957 END IF;
4958 -- CLOSE eg_matrix_cur;
4959 -- EXIT;
4960 -- END IF;
4961 -- CLOSE eg_matrix_cur;
4962
4963 IF (l_end_date >= l_asg_start_date) AND (l_start_date <= l_asg_end_date) THEN
4964 IF (l_asg_start_date = l_start_date AND l_asg_end_date = l_end_date) THEN
4965 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
4966 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4967 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4968 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4969 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4970 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4971 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4972 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'EG';
4973 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4974 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4975 l_rec_no := l_rec_no + 1;
4976 IF (l_schedule_percent < 100) THEN
4977 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
4978 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4979 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4980 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4981 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4982 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4983 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4984 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
4985 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
4986 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4987 l_rec_no := l_rec_no + 1;
4988 END IF;
4989 EXIT;
4990 ELSE
4991 IF (l_start_date > GREATEST(l_period_start_date, l_asg_start_date)) THEN
4992 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date);
4993 l_new_end_date := l_start_date - 1;
4994 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
4995 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4996 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4997 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
4998 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
4999 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5000 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5001 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
5002 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5003 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5004 l_rec_no := l_rec_no + 1;
5005 l_asg_start_date := l_start_date;
5006 END IF;
5007
5008 IF (l_end_date < LEAST(l_period_end_date, l_asg_end_date)) THEN
5009 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date, l_start_date);
5010 l_new_end_date := l_end_date;
5011 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5012 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5013 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5014 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
5015 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
5016 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5017 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5018 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'EG';
5019 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5020 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5021 l_rec_no := l_rec_no + 1;
5022 IF (l_schedule_percent < 100) THEN
5023 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5024 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5025 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5026 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
5027 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
5028 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5029 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5030 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
5031 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5032 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5033 l_rec_no := l_rec_no + 1;
5034 END IF;
5035 l_asg_start_date := l_end_date + 1;
5036 IF (eg_recno = r_sch_rec.start_date.COUNT) AND
5037 (l_asg_start_date <= l_asg_end_date) THEN
5038 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5039 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5040 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5041 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5042 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5043 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5044 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5045 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
5046 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5047 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5048 l_rec_no := l_rec_no + 1;
5049 END IF;
5050 ELSE
5051 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5052 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5053 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5054 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5055 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5056 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5057 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5058 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'EG';
5059 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5060 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5061 l_rec_no := l_rec_no + 1;
5062 IF (l_schedule_percent < 100) THEN
5063 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5064 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5065 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5066 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5067 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5068 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5069 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5070 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
5071 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5072 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5073 l_rec_no := l_rec_no + 1;
5074 END IF;
5075 l_asg_start_date := l_end_date + 1;
5076 END IF;
5077 END IF;
5078 l_sub_slice_counter := 2;
5079 ELSE
5080 IF (eg_recno = r_sch_rec.start_date.COUNT) THEN
5081 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5082 r_enc_period_tmp1.r_period_start_date(l_rec_no) := r_enc_period.r_period_start_date(I);
5083 r_enc_period_tmp1.r_period_end_date(l_rec_no) := r_enc_period.r_period_end_date(I);
5084 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := r_enc_period.r_asg_start_date(I);
5085 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := r_enc_period.r_asg_end_date(I);
5086 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5087 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5088 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
5089 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5090 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5091 l_rec_no := l_rec_no + 1;
5092 END IF;
5093 END IF;
5094 l_sch_pointer := eg_recno;
5095 EXIT WHEN l_asg_start_date > l_asg_end_date;
5096 END LOOP;
5097 ELSE
5098 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5099 r_enc_period_tmp1.r_period_start_date(l_rec_no) := r_enc_period.r_period_start_date(I);
5100 r_enc_period_tmp1.r_period_end_date(l_rec_no) := r_enc_period.r_period_end_date(I);
5101 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := r_enc_period.r_asg_start_date(I);
5102 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := r_enc_period.r_asg_end_date(I);
5103 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5104 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5105 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
5106 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5107 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5108 l_rec_no := l_rec_no + 1;
5109 END IF;
5110 END LOOP;
5111
5112 r_enc_period.r_time_period_id.DELETE;
5113 r_enc_period.r_period_start_date.DELETE;
5114 r_enc_period.r_period_end_date.DELETE;
5115 r_enc_period.r_asg_start_date.DELETE;
5116 r_enc_period.r_asg_end_date.DELETE;
5117 r_enc_period.r_process_flag.DELETE;
5118 r_enc_period.r_period_ind.DELETE;
5119 r_enc_period.r_schedule_percent.DELETE;
5120 r_enc_period.r_encumbrance_amount.DELETE;
5121 r_enc_period.r_period_amount.DELETE;
5122 r_enc_period.r_reason_code.DELETE;
5123 r_enc_period.r_effective_date.DELETE;
5124 l_rec_no := 1;
5125 l_proc_step := 100;
5126
5127 hr_utility.trace('Dumping Assignment Chunk After Element Group Processing ...');
5128 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
5129 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
5130 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
5131 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
5132 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
5133 RPAD('Reason Code', 50, ' '));
5134 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
5135 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
5136 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
5137 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
5138 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
5139 RPAD('-', 50, '-'));
5140
5141 FOR recno IN 1..r_enc_period_tmp1.r_time_period_id.COUNT
5142 LOOP
5143 hr_utility.trace(LPAD(r_enc_period_tmp1.r_period_ind(recno), 13, ' ') || ' ' ||
5144 LPAD(r_enc_period_tmp1.r_time_period_id(recno), 14, ' ') || ' ' ||
5145 RPAD(TO_CHAR(r_enc_period_tmp1.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
5146 RPAD(TO_CHAR(r_enc_period_tmp1.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
5147 RPAD(TO_CHAR(r_enc_period_tmp1.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
5148 RPAD(TO_CHAR(r_enc_period_tmp1.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
5149 RPAD(TO_CHAR(r_enc_period_tmp1.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
5150 RPAD(r_enc_period_tmp1.r_process_flag(recno), 12, ' ') || ' ' ||
5151 LPAD(r_enc_period_tmp1.r_schedule_percent(recno), 16, ' ') || ' ' ||
5152 RPAD(r_enc_period_tmp1.r_reason_code(recno), 50, ' '));
5153 END LOOP;
5154 hr_utility.trace('Assignment Processing ...');
5155
5156 psp_matrix_driver_pkg.clear_table('REFRESH');
5157 psp_matrix_driver_pkg.purge_table;
5158 l_period_count := r_enc_period.r_time_period_id.COUNT;
5159 OPEN ls_hier_cur('A');
5160 FETCH ls_hier_cur INTO l_schedule_hierarchy_id;
5161 CLOSE ls_hier_cur;
5162
5163 /***** Commented for bug fix 3970852 to resolve issues when schedule dates equal default end date
5164 psp_matrix_driver_pkg.clear_table('REFRESH');
5165 psp_matrix_driver_pkg.purge_table;
5166 psp_matrix_driver_pkg.load_table(l_schedule_hierarchy_id);
5167
5168 DELETE psp_matrix_driver
5169 WHERE run_id = l_run_id
5170 AND (period_start_date > l_max_end_date
5171 OR period_end_date < l_min_start_date
5172 OR period_schedule_percent = 0);
5173
5174 UPDATE psp_matrix_driver pmd
5175 SET period_end_date = period_end_date - 1
5176 WHERE run_id = l_run_id
5177 AND period_start_date < period_end_date
5178 AND period_start_date = (SELECT MIN(psl1.schedule_begin_date)
5179 FROM psp_schedule_lines psl1
5180 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
5181 AND EXISTS (SELECT 1
5182 FROM psp_schedule_lines psl1
5183 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
5184 AND psl1.schedule_begin_date = pmd.period_end_date
5185 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
5186
5187 UPDATE psp_matrix_driver pmd
5188 SET period_end_date = period_end_date - 1
5189 WHERE run_id = l_run_id
5190 AND period_start_date < period_end_date
5191 AND NOT (NOT EXISTS (SELECT 1
5192 FROM psp_schedule_lines psl1
5193 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
5194 AND psl1.schedule_begin_date = pmd.period_end_date
5195 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
5196 AND EXISTS (SELECT 1
5197 FROM psp_schedule_lines psl1
5198 WHERE psl1.schedule_end_date = pmd.period_end_date
5199 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id))
5200 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
5201 FROM psp_schedule_lines psl1
5202 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
5203
5204 UPDATE psp_matrix_driver pmd
5205 SET period_start_date = period_start_date + 1
5206 WHERE run_id = l_run_id
5207 AND period_start_date < period_end_date
5208 AND NOT EXISTS (SELECT 1
5209 FROM psp_schedule_lines psl1
5210 WHERE psl1.schedule_begin_date = pmd.period_start_date
5211 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
5212 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
5213 FROM psp_schedule_lines psl1
5214 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
5215
5216 UPDATE psp_matrix_driver pmd
5217 SET period_start_date = period_start_date + 1
5218 WHERE run_id = l_run_id
5219 AND period_start_date < period_end_date
5220 AND EXISTS (SELECT 1
5221 FROM psp_schedule_lines psl1
5222 WHERE psl1.schedule_begin_date = pmd.period_start_date
5223 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
5224 AND EXISTS (SELECT 1
5225 FROM psp_schedule_lines psl1
5226 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
5227 AND psl1.schedule_end_date = pmd.period_start_date
5228 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
5229 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
5230 FROM psp_schedule_lines psl1
5231 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
5232 End of comment for bug fix 3970852 *****/
5233
5234 -- Introduced the following to prepare schedule chunk dates instead of load_table for bug fix 3970852
5235 recno := 1;
5236
5237 OPEN dates(l_schedule_hierarchy_id);
5238 FETCH dates BULK COLLECT INTO initial_dates, date_type;
5239 CLOSE dates;
5240
5241 FOR rowno IN 1..(initial_dates.COUNT - 1)
5242 LOOP
5243 IF (date_type(rowno) = 'B' AND date_type(rowno+1) = 'B') THEN
5244 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno);
5245 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1) - 1;
5246 recno := recno+1;
5247 ELSIF (date_type(rowno) = 'B' AND date_type(rowno+1) = 'E') THEN
5248 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno);
5249 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1);
5250 recno := recno+1;
5251 ELSIF (date_type(rowno) = 'E' AND date_type(rowno+1) = 'E') THEN
5252 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno) + 1;
5253 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1);
5254 recno := recno+1;
5255 ELSIF (date_type(rowno) = 'E' AND date_type(rowno+1) = 'B') THEN
5256 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno) + 1;
5257 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1) -1;
5258 recno := recno+1;
5259 END IF;
5260 END LOOP;
5261
5262 FORALL rowno IN 1..schedule_chunk.schedule_begin_date.COUNT
5263 INSERT INTO psp_matrix_driver
5264 (RUN_ID, SCHEDULE_LINE_ID,
5265 PERIOD_START_DATE, PERIOD_END_DATE,
5266 PERIOD_SCHEDULE_PERCENT)
5267 SELECT l_run_id, schedule_line_id,
5268 GREATEST(l_min_start_date, schedule_chunk.schedule_begin_date(rowno)),
5269 LEAST(l_max_end_date, schedule_chunk.schedule_end_date(rowno)),
5270 schedule_percent
5271 FROM psp_schedule_lines psl
5272 WHERE schedule_hierarchy_id = l_schedule_hierarchy_id
5273 AND schedule_end_date >= l_min_start_date
5274 AND schedule_begin_date <= l_max_end_date
5275 AND ( gl_code_combination_id IS NOT NULL
5276 OR award_id IS NOT NULL)
5277 AND psl.schedule_begin_date <= schedule_chunk.schedule_end_date(rowno)
5278 AND psl.schedule_end_date >= schedule_chunk.schedule_begin_date(rowno);
5279
5280 initial_dates.delete;
5281 date_type.delete;
5282 schedule_chunk.schedule_end_date.delete;
5283 schedule_chunk.schedule_begin_date.delete;
5284 -- End of bug fix 3970852
5285
5286 l_sch_pointer := 1;
5287 OPEN ls_matrix_cur;
5288 FETCH ls_matrix_cur BULK COLLECT INTO r_sch_rec.start_date, r_sch_rec.end_date, r_sch_rec.schedule_percent;
5289 CLOSE ls_matrix_cur;
5290
5291 hr_utility.trace('r_sch_rec.start_date.COUNT: ' || r_sch_rec.start_date.COUNT);
5292 hr_utility.trace('Schedule Chunk Details');
5293 hr_utility.trace(RPAD('Start Date', 15, ' ') || ' ' ||
5294 RPAD('End Date', 15, ' ') || ' ' || LPAD('Schedule Percent', 16, ' '));
5295
5296 hr_utility.trace(RPAD('-', 15, '-') || ' ' ||
5297 RPAD('-', 15, '-') || ' ' || RPAD('-', 16, '-'));
5298
5299 FOR recno IN 1..r_sch_rec.start_date.COUNT
5300 LOOP
5301 hr_utility.trace(RPAD(TO_CHAR(r_sch_rec.start_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
5302 RPAD(TO_CHAR(r_sch_rec.end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
5303 LPAD(r_sch_rec.schedule_percent(recno), 16, ' '));
5304 END LOOP;
5305
5306 FOR I IN 1..r_enc_period_tmp1.r_time_period_id.COUNT
5307 LOOP
5308 l_period_start_date := r_enc_period_tmp1.r_period_start_date(I);
5309 l_period_end_date := r_enc_period_tmp1.r_period_end_date(I);
5310 l_asg_start_date := r_enc_period_tmp1.r_asg_start_date(I);
5311 l_asg_end_date := r_enc_period_tmp1.r_asg_end_date(I);
5312 l_process_flag := r_enc_period_tmp1.r_process_flag(I);
5313 l_sub_slice_counter := 1;
5314 l_proc_step := 110 + (I / 100000);
5315
5316 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
5317 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
5318 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
5319 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
5320 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
5321 ' r_enc_period_tmp1.r_time_period_id(I): ' || fnd_number.number_to_canonical(r_enc_period_tmp1.r_time_period_id(I)) ||
5322 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no));
5323
5324 IF (l_process_flag = 'Y') AND (r_sch_rec.end_date.COUNT > 0) THEN
5325 FOR asg_recno IN l_sch_pointer..r_sch_rec.start_date.COUNT
5326 LOOP
5327 l_start_date:= r_sch_rec.start_date(asg_recno);
5328 l_end_date:= r_sch_rec.end_date(asg_recno);
5329 l_schedule_percent:= r_sch_rec.schedule_percent(asg_recno);
5330 l_proc_step := 120 + (l_rec_no / 100000);
5331
5332 hr_utility.trace(' l_sub_slice_counter: ' || fnd_number.number_to_canonical(l_sub_slice_counter) ||
5333 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no) ||
5334 ' l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
5335 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
5336 ' l_schedule_percent: ' || fnd_number.number_to_canonical(l_schedule_percent));
5337 -- OPEN ls_matrix_cur;
5338 -- FETCH ls_matrix_cur INTO l_start_date, l_end_date, l_schedule_percent;
5339 -- IF (ls_matrix_cur%NOTFOUND) THEN
5340 IF (l_start_date > l_asg_end_date) THEN
5341 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5342 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5343 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5344 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
5345 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
5346 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5347 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5348 r_enc_period.r_process_flag(l_rec_no) := 'Y';
5349 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
5350 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5351 l_rec_no := l_rec_no + 1;
5352 EXIT;
5353 END IF;
5354 -- CLOSE ls_matrix_cur;
5355 -- EXIT;
5356 -- END IF;
5357 -- CLOSE ls_matrix_cur;
5358
5359 IF (l_end_date >= l_asg_start_date) AND (l_start_date <= l_asg_end_date) THEN
5360 IF (l_asg_start_date = l_start_date AND l_asg_end_date = l_end_date) THEN
5361 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5362 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5363 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5364 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
5365 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
5366 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5367 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5368 r_enc_period.r_process_flag(l_rec_no) := 'A';
5369 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
5370 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5371 l_rec_no := l_rec_no + 1;
5372 IF (l_schedule_percent < 100) THEN
5373 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5374 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5375 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5376 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
5377 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
5378 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5379 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5380 r_enc_period.r_process_flag(l_rec_no) := 'BAL';
5381 r_enc_period.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5382 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5383 l_rec_no := l_rec_no + 1;
5384 END IF;
5385 EXIT;
5386 ELSE
5387 IF (l_start_date > GREATEST(l_period_start_date, l_asg_start_date)) THEN
5388 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date);
5389 l_new_end_date := l_start_date - 1;
5390 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5391 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5392 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5393 r_enc_period.r_asg_start_date(l_rec_no) := l_new_start_date;
5394 r_enc_period.r_asg_end_date(l_rec_no) := l_new_end_date;
5395 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5396 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5397 r_enc_period.r_process_flag(l_rec_no) := 'Y';
5398 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
5399 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5400 l_rec_no := l_rec_no + 1;
5401 l_asg_start_date := l_start_date;
5402 END IF;
5403
5404 IF (l_end_date < LEAST(l_period_end_date, l_asg_end_date)) THEN
5405 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date, l_start_date);
5406 l_new_end_date := l_end_date;
5407 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5408 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5409 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5410 r_enc_period.r_asg_start_date(l_rec_no) := l_new_start_date;
5411 r_enc_period.r_asg_end_date(l_rec_no) := l_new_end_date;
5412 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5413 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5414 r_enc_period.r_process_flag(l_rec_no) := 'A';
5415 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
5416 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5417 l_rec_no := l_rec_no + 1;
5418 IF (l_schedule_percent < 100) THEN
5419 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5420 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5421 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5422 r_enc_period.r_asg_start_date(l_rec_no) := l_new_start_date;
5423 r_enc_period.r_asg_end_date(l_rec_no) := l_new_end_date;
5424 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5425 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5426 r_enc_period.r_process_flag(l_rec_no) := 'BAL';
5427 r_enc_period.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5428 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5429 l_rec_no := l_rec_no + 1;
5430 END IF;
5431 l_asg_start_date := l_end_date + 1;
5432 IF (asg_recno = r_sch_rec.start_date.COUNT) AND
5433 (l_asg_start_date <= l_asg_end_date) THEN
5434 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5435 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5436 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5437 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
5438 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
5439 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5440 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5441 r_enc_period.r_process_flag(l_rec_no) := 'Y';
5442 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
5443 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5444 l_rec_no := l_rec_no + 1;
5445 END IF;
5446 ELSE
5447 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5448 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5449 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5450 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
5451 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
5452 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5453 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5454 r_enc_period.r_process_flag(l_rec_no) := 'A';
5455 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
5456 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5457 l_rec_no := l_rec_no + 1;
5458 IF (l_schedule_percent < 100) THEN
5459 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5460 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5461 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5462 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
5463 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
5464 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5465 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5466 r_enc_period.r_process_flag(l_rec_no) := 'BAL';
5467 r_enc_period.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5468 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5469 l_rec_no := l_rec_no + 1;
5470 END IF;
5471 l_asg_start_date := l_end_date + 1;
5472 END IF;
5473 END IF;
5474 l_sub_slice_counter := 2;
5475 ELSE
5476 IF (asg_recno = r_sch_rec.start_date.COUNT) THEN
5477 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5478 r_enc_period.r_period_start_date(l_rec_no) := r_enc_period_tmp1.r_period_start_date(I);
5479 r_enc_period.r_period_end_date(l_rec_no) := r_enc_period_tmp1.r_period_end_date(I);
5480 r_enc_period.r_asg_start_date(l_rec_no) := r_enc_period_tmp1.r_asg_start_date(I);
5481 r_enc_period.r_asg_end_date(l_rec_no) := r_enc_period_tmp1.r_asg_end_date(I);
5482 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5483 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5484 r_enc_period.r_process_flag(l_rec_no) := r_enc_period_tmp1.r_process_flag(I);
5485 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
5486 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5487 l_rec_no := l_rec_no + 1;
5488 END IF;
5489 END IF;
5490 l_sch_pointer := asg_recno;
5491 EXIT WHEN l_asg_start_date > l_asg_end_date;
5492 END LOOP;
5493 ELSE
5494 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5495 r_enc_period.r_period_start_date(l_rec_no) := r_enc_period_tmp1.r_period_start_date(I);
5496 r_enc_period.r_period_end_date(l_rec_no) := r_enc_period_tmp1.r_period_end_date(I);
5497 r_enc_period.r_asg_start_date(l_rec_no) := r_enc_period_tmp1.r_asg_start_date(I);
5498 r_enc_period.r_asg_end_date(l_rec_no) := r_enc_period_tmp1.r_asg_end_date(I);
5499 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5500 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5501 r_enc_period.r_process_flag(l_rec_no) := r_enc_period_tmp1.r_process_flag(I);
5502 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
5503 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5504 l_rec_no := l_rec_no + 1;
5505 END IF;
5506 END LOOP;
5507
5508 r_sch_rec.start_date.delete;
5509 r_sch_rec.end_date.delete;
5510 r_sch_rec.schedule_percent.delete;
5511 r_enc_period_tmp1.r_time_period_id.DELETE;
5512 r_enc_period_tmp1.r_period_start_date.DELETE;
5513 r_enc_period_tmp1.r_period_end_date.DELETE;
5514 r_enc_period_tmp1.r_asg_start_date.DELETE;
5515 r_enc_period_tmp1.r_asg_end_date.DELETE;
5516 r_enc_period_tmp1.r_process_flag.DELETE;
5517 r_enc_period_tmp1.r_period_ind.DELETE;
5518 r_enc_period_tmp1.r_schedule_percent.DELETE;
5519 r_enc_period_tmp1.r_encumbrance_amount.DELETE;
5520 r_enc_period_tmp1.r_period_amount.DELETE;
5521 r_enc_period_tmp1.r_reason_code.DELETE;
5522 r_enc_period_tmp1.r_effective_date.DELETE;
5523 l_rec_no := 1;
5524 l_proc_step := 130;
5525
5526 -- psp_matrix_driver_pkg.clear_table('REFRESH'); Commented for bug fix 3970852
5527 -- psp_matrix_driver_pkg.purge_table; Commented for bug fix 3970852
5528
5529 hr_utility.trace('Dumping Assignment Chunk After Assignment Processing ...');
5530 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
5531 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
5532 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
5533 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
5534 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
5535 RPAD('Reason Code', 50, ' '));
5536 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
5537 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
5538 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
5539 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
5540 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
5541 RPAD('-', 50, '-'));
5542
5543 FOR recno IN 1..r_enc_period.r_time_period_id.COUNT
5544 LOOP
5545 hr_utility.trace(LPAD(r_enc_period.r_period_ind(recno), 13, ' ') || ' ' ||
5546 LPAD(r_enc_period.r_time_period_id(recno), 14, ' ') || ' ' ||
5547 RPAD(TO_CHAR(r_enc_period.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
5548 RPAD(TO_CHAR(r_enc_period.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
5549 RPAD(TO_CHAR(r_enc_period.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
5550 RPAD(TO_CHAR(r_enc_period.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
5551 RPAD(TO_CHAR(r_enc_period.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
5552 RPAD(r_enc_period.r_process_flag(recno), 12, ' ') || ' ' ||
5553 LPAD(r_enc_period.r_schedule_percent(recno), 16, ' ') || ' ' ||
5554 RPAD(r_enc_period.r_reason_code(recno), 50, ' '));
5555 END LOOP;
5556
5557 IF (g_org_def_labor_schedule = 'Y') THEN
5558 hr_utility.trace('Organization Default LS Processing');
5559
5560 l_sch_pointer := 1;
5561 OPEN odls_cur;
5562 FETCH odls_cur BULK COLLECT INTO r_sch_rec.start_date, r_sch_rec.end_date, r_sch_rec.schedule_percent;
5563 CLOSE odls_cur;
5564
5565 hr_utility.trace('r_sch_rec.start_date.COUNT: ' || r_sch_rec.start_date.COUNT);
5566 hr_utility.trace('Schedule Chunk Details');
5567 hr_utility.trace(RPAD('Start Date', 15, ' ') || ' ' ||
5568 RPAD('End Date', 15, ' ') || ' ' || LPAD('Schedule Percent', 16, ' '));
5569 hr_utility.trace(RPAD('-', 15, '-') || ' ' ||
5570 RPAD('-', 15, '-') || ' ' || RPAD('-', 16, '-'));
5571
5572 FOR recno IN 1..r_sch_rec.start_date.COUNT
5573 LOOP
5574 hr_utility.trace(RPAD(TO_CHAR(r_sch_rec.start_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
5575 RPAD(TO_CHAR(r_sch_rec.end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
5576 LPAD(r_sch_rec.schedule_percent(recno), 16, ' '));
5577 END LOOP;
5578
5579 FOR I IN 1..r_enc_period.r_time_period_id.COUNT
5580 LOOP
5581 l_period_start_date := r_enc_period.r_period_start_date(I);
5582 l_period_end_date := r_enc_period.r_period_end_date(I);
5583 l_asg_start_date := r_enc_period.r_asg_start_date(I);
5584 l_asg_end_date := r_enc_period.r_asg_end_date(I);
5585 l_process_flag := r_enc_period.r_process_flag(I);
5586 l_sub_slice_counter := 1;
5587 l_proc_step := 150 + (I / 100000);
5588
5589 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
5590 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
5591 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
5592 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
5593 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
5594 ' r_enc_period.r_time_period_id(I): ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id(I)) ||
5595 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no));
5596
5597 IF (l_process_flag = 'Y') AND (r_sch_rec.end_date.COUNT > 0) THEN
5598 FOR odls_recno IN l_sch_pointer..r_sch_rec.start_date.COUNT
5599 LOOP
5600 l_start_date:= r_sch_rec.start_date(odls_recno);
5601 l_end_date:= r_sch_rec.end_date(odls_recno);
5602 l_schedule_percent:= r_sch_rec.schedule_percent(odls_recno);
5603 l_proc_step := 160 + (l_rec_no / 100000);
5604 -- OPEN odls_cur(l_asg_start_date, l_asg_end_date);
5605 -- FETCH odls_cur INTO l_start_date, l_end_date, l_schedule_percent;
5606
5607 hr_utility.trace('l_sub_slice_counter: ' || fnd_number.number_to_canonical(l_sub_slice_counter) ||
5608 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no) ||
5609 ' l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
5610 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
5611 ' l_schedule_percent: ' || fnd_number.number_to_canonical(l_schedule_percent));
5612 -- hr_utility.trace('odls_cur%ROWCOUNT: ' || fnd_number.number_to_canonical(odls_cur%ROWCOUNT));
5613
5614 -- IF (odls_cur%NOTFOUND) THEN
5615 IF (l_start_date > l_asg_end_date) THEN
5616 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5617 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5618 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5619 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5620 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5621 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5622 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5623 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
5624 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5625 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5626 l_rec_no := l_rec_no + 1;
5627 EXIT;
5628 END IF;
5629 -- CLOSE odls_cur;
5630 -- EXIT;
5631 -- END IF;
5632 -- CLOSE odls_cur;
5633
5634 IF (l_end_date >= l_asg_start_date) AND (l_start_date <= l_asg_end_date) THEN
5635 IF (l_asg_start_date = l_start_date AND l_asg_end_date = l_end_date) THEN
5636 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5637 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5638 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5639 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5640 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5641 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5642 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5643 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'DS';
5644 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5645 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5646 l_rec_no := l_rec_no + 1;
5647 IF (l_schedule_percent < 100) THEN
5648 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5649 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5650 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5651 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5652 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5653 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5654 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5655 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
5656 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5657 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5658 l_rec_no := l_rec_no + 1;
5659 END IF;
5660 EXIT;
5661 ELSE
5662 IF (l_start_date > GREATEST(l_period_start_date, l_asg_start_date)) THEN
5663 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date);
5664 l_new_end_date := l_start_date - 1;
5665 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5666 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5667 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5668 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
5669 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
5670 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5671 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5672 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
5673 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5674 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5675 l_rec_no := l_rec_no + 1;
5676 l_asg_start_date := l_start_date;
5677 END IF;
5678
5679 IF (l_end_date < LEAST(l_period_end_date, l_asg_end_date)) THEN
5680 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date, l_start_date);
5681 l_new_end_date := l_end_date;
5682 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5683 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5684 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5685 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
5686 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
5687 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5688 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5689 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'DS';
5690 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5691 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5692 l_rec_no := l_rec_no + 1;
5693 IF (l_schedule_percent < 100) THEN
5694 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5695 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5696 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5697 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
5698 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
5699 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5700 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5701 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
5702 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5703 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5704 l_rec_no := l_rec_no + 1;
5705 END IF;
5706 l_asg_start_date := l_end_date + 1;
5707 IF (odls_recno = r_sch_rec.start_date.COUNT) AND
5708 (l_asg_start_date <= l_asg_end_date) THEN
5709 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5710 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5711 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5712 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5713 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5714 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5715 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5716 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
5717 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5718 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5719 l_rec_no := l_rec_no + 1;
5720 END IF;
5721 /***** Commented the following code for bug fix 3672723 as it was causing duplicate posting for same assignment chunks
5722 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5723 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5724 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5725 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5726 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5727 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5728 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
5729 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5730 l_rec_no := l_rec_no + 1;
5731 End of Comment for bug fix 3673723 *****/
5732 ELSE
5733 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5734 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5735 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5736 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5737 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5738 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5739 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5740 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'DS';
5741 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5742 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5743 l_rec_no := l_rec_no + 1;
5744 IF (l_schedule_percent < 100) THEN
5745 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5746 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5747 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5748 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5749 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5750 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5751 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5752 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
5753 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5754 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5755 l_rec_no := l_rec_no + 1;
5756 END IF;
5757 l_asg_start_date := l_end_date + 1;
5758 END IF;
5759 END IF;
5760 l_sub_slice_counter := 2;
5761 ELSE
5762 IF (odls_recno = r_sch_rec.start_date.COUNT) THEN
5763 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5764 r_enc_period_tmp1.r_period_start_date(l_rec_no) := r_enc_period.r_period_start_date(I);
5765 r_enc_period_tmp1.r_period_end_date(l_rec_no) := r_enc_period.r_period_end_date(I);
5766 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := r_enc_period.r_asg_start_date(I);
5767 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := r_enc_period.r_asg_end_date(I);
5768 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5769 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5770 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
5771 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5772 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5773 l_rec_no := l_rec_no + 1;
5774 END IF;
5775 END IF;
5776 l_sch_pointer := odls_recno;
5777 EXIT WHEN l_asg_start_date > l_asg_end_date;
5778 END LOOP;
5779 ELSE
5780 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5781 r_enc_period_tmp1.r_period_start_date(l_rec_no) := r_enc_period.r_period_start_date(I);
5782 r_enc_period_tmp1.r_period_end_date(l_rec_no) := r_enc_period.r_period_end_date(I);
5783 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := r_enc_period.r_asg_start_date(I);
5784 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := r_enc_period.r_asg_end_date(I);
5785 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5786 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5787 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
5788 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5789 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5790 l_rec_no := l_rec_no + 1;
5791 END IF;
5792 END LOOP;
5793
5794 r_sch_rec.start_date.delete;
5795 r_sch_rec.end_date.delete;
5796 r_sch_rec.schedule_percent.delete;
5797 r_enc_period.r_time_period_id.DELETE;
5798 r_enc_period.r_period_start_date.DELETE;
5799 r_enc_period.r_period_end_date.DELETE;
5800 r_enc_period.r_asg_start_date.DELETE;
5801 r_enc_period.r_asg_end_date.DELETE;
5802 r_enc_period.r_process_flag.DELETE;
5803 r_enc_period.r_period_ind.DELETE;
5804 r_enc_period.r_schedule_percent.DELETE;
5805 r_enc_period.r_encumbrance_amount.DELETE;
5806 r_enc_period.r_period_amount.DELETE;
5807 r_enc_period.r_reason_code.DELETE;
5808 r_enc_period.r_effective_date.DELETE;
5809 l_rec_no := 1;
5810 l_proc_step := 170;
5811
5812 hr_utility.trace('Dumping Assignment Chunk After Organization Default Schedules Processing ...');
5813 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
5814 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
5815 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
5816 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
5817 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
5818 RPAD('Reason Code', 50, ' '));
5819 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
5820 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
5821 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
5822 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
5823 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
5824 RPAD('-', 50, '-'));
5825
5826 FOR recno IN 1..r_enc_period_tmp1.r_time_period_id.COUNT
5827 LOOP
5828 hr_utility.trace(LPAD(r_enc_period_tmp1.r_period_ind(recno), 13, ' ') || ' ' ||
5829 LPAD(r_enc_period_tmp1.r_time_period_id(recno), 14, ' ') || ' ' ||
5830 RPAD(TO_CHAR(r_enc_period_tmp1.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
5831 RPAD(TO_CHAR(r_enc_period_tmp1.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
5832 RPAD(TO_CHAR(r_enc_period_tmp1.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
5833 RPAD(TO_CHAR(r_enc_period_tmp1.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
5834 RPAD(TO_CHAR(r_enc_period_tmp1.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
5835 RPAD(r_enc_period_tmp1.r_process_flag(recno), 12, ' ') || ' ' ||
5836 LPAD(r_enc_period_tmp1.r_schedule_percent(recno), 16, ' ') || ' ' ||
5837 RPAD(r_enc_period_tmp1.r_reason_code(recno), 50, ' '));
5838 END LOOP;
5839
5840 FOR I IN 1..r_enc_period_tmp1.r_time_period_id.COUNT
5841 LOOP
5842 r_enc_period.r_period_ind(I) := r_enc_period_tmp1.r_period_ind(I);
5843 r_enc_period.r_period_start_date(I) := r_enc_period_tmp1.r_period_start_date(I);
5844 r_enc_period.r_period_end_date(I) := r_enc_period_tmp1.r_period_end_date(I);
5845 r_enc_period.r_asg_start_date(I) := r_enc_period_tmp1.r_asg_start_date(I);
5846 r_enc_period.r_asg_end_date(I) := r_enc_period_tmp1.r_asg_end_date(I);
5847 r_enc_period.r_time_period_id(I) := r_enc_period_tmp1.r_time_period_id(I);
5848 r_enc_period.r_effective_date(I) := r_enc_period_tmp1.r_effective_date(I);
5849 r_enc_period.r_process_flag(I) := r_enc_period_tmp1.r_process_flag(I);
5850 r_enc_period.r_schedule_percent(I) := r_enc_period_tmp1.r_schedule_percent(I);
5851 r_enc_period.r_reason_code(I) := r_enc_period_tmp1.r_reason_code(I);
5852 END LOOP;
5853 END IF;
5854
5855 IF (g_org_def_account = 'Y') THEN
5856 hr_utility.trace('Organization Default Account Processing');
5857
5858 l_sch_pointer := 1;
5859 FOR I IN 1..r_enc_period.r_time_period_id.COUNT
5860 LOOP
5861 l_period_start_date := r_enc_period.r_period_start_date(I);
5862 l_period_end_date := r_enc_period.r_period_end_date(I);
5863 l_asg_start_date := r_enc_period.r_asg_start_date(I);
5864 l_asg_end_date := r_enc_period.r_asg_end_date(I);
5865 l_process_flag := r_enc_period.r_process_flag(I);
5866 l_sub_slice_counter := 1;
5867 l_proc_step := 180 + (I / 100000);
5868
5869 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
5870 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
5871 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
5872 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
5873 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
5874 ' r_enc_period.r_time_period_id(I): ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id(I)) ||
5875 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no));
5876
5877 IF (l_process_flag IN ('BAL', 'Y')) AND (r_da.end_date_active.COUNT > 0) THEN
5878 FOR da_recno IN l_sch_pointer..r_da.start_date_active.COUNT
5879 LOOP
5880 l_start_date:= r_da.start_date_active(da_recno);
5881 l_end_date:= r_da.end_date_active(da_recno);
5882 IF (l_process_flag = 'BAL') THEN
5883 l_schedule_percent := r_enc_period.r_schedule_percent(I);
5884 ELSE
5885 l_schedule_percent:= r_da.percent(da_recno);
5886 END IF;
5887 l_proc_step := 190 + (l_rec_no / 100000);
5888
5889 hr_utility.trace(' l_sub_slice_counter: ' || fnd_number.number_to_canonical(l_sub_slice_counter) ||
5890 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no) ||
5891 ' l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
5892 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
5893 ' l_schedule_percent: ' || fnd_number.number_to_canonical(l_schedule_percent));
5894
5895 IF (l_start_date > l_asg_end_date) THEN
5896 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5897 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5898 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5899 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5900 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5901 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5902 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5903 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
5904 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5905 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5906 l_rec_no := l_rec_no + 1;
5907 EXIT;
5908 END IF;
5909
5910 IF (l_end_date >= l_asg_start_date) AND (l_start_date <= l_asg_end_date) THEN
5911 IF (l_process_flag = 'BAL') THEN
5912 l_reason_code := '1';
5913 l_schedule_percent := r_enc_period.r_schedule_percent(I);
5914 fnd_message.set_name('PSP', 'PSP_DEFAULT_REASON_1');
5915 fnd_message.set_token('START_DATE', l_asg_start_date);
5916 fnd_message.set_token('END_DATE', l_asg_end_date);
5917 fnd_message.set_token('PERCENT', r_enc_period.r_schedule_percent(I));
5918 g_warning_message := fnd_message.get;
5919 add_cel_warnings(p_start_date => l_asg_start_date,
5920 p_hierarchy_code => 'DA',
5921 p_end_date => l_asg_end_date,
5922 p_warning_code => 'BAL',
5923 p_percent => r_enc_period.r_schedule_percent(I));
5924 ELSE
5925 l_reason_code := '3';
5926 fnd_message.set_name('PSP', 'PSP_DEFAULT_REASON_3');
5927 fnd_message.set_token('START_DATE', l_asg_start_date);
5928 fnd_message.set_token('END_DATE', l_asg_end_date);
5929 g_warning_message := fnd_message.get;
5930 add_cel_warnings(p_start_date => l_asg_start_date,
5931 p_hierarchy_code => 'DA',
5932 p_end_date => l_asg_end_date,
5933 p_warning_code => 'NO_CI');
5934 END IF;
5935 IF (l_asg_start_date = l_start_date AND l_asg_end_date = l_end_date) THEN
5936 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5937 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5938 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5939 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5940 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5941 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5942 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5943 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'DA';
5944 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := l_schedule_percent;
5945 r_enc_period_tmp1.r_reason_code(l_rec_no) := l_reason_code;
5946 l_rec_no := l_rec_no + 1;
5947 ELSE
5948 IF (l_start_date > GREATEST(l_period_start_date, l_asg_start_date)) THEN
5949 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date);
5950 l_new_end_date := l_start_date - 1;
5951 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5952 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5953 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5954 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
5955 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
5956 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5957 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5958 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
5959 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5960 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5961 l_rec_no := l_rec_no + 1;
5962 l_asg_start_date := l_start_date;
5963 END IF;
5964
5965 IF (l_end_date < LEAST(l_period_end_date, l_asg_end_date)) THEN
5966 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date, l_start_date);
5967 l_new_end_date := l_end_date;
5968 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5969 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5970 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5971 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
5972 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
5973 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5974 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5975 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'DA';
5976 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := l_schedule_percent;
5977 r_enc_period_tmp1.r_reason_code(l_rec_no) := l_reason_code;
5978 l_rec_no := l_rec_no + 1;
5979 l_asg_start_date := l_end_date + 1;
5980 IF (da_recno = r_da.start_date_active.COUNT) AND
5981 (l_asg_start_date <= l_asg_end_date) THEN
5982 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5983 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5984 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5985 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5986 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5987 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5988 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5989 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
5990 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5991 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5992 l_rec_no := l_rec_no + 1;
5993 END IF;
5994 ELSE
5995 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5996 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5997 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5998 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5999 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
6000 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
6001 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
6002 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'DA';
6003 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := l_schedule_percent;
6004 r_enc_period_tmp1.r_reason_code(l_rec_no) := l_reason_code;
6005 l_rec_no := l_rec_no + 1;
6006 l_asg_start_date := l_end_date + 1;
6007 END IF;
6008 END IF;
6009 l_sub_slice_counter := 2;
6010 ELSE
6011 IF (da_recno = r_da.start_date_active.COUNT) THEN
6012 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
6013 r_enc_period_tmp1.r_period_start_date(l_rec_no) := r_enc_period.r_period_start_date(I);
6014 r_enc_period_tmp1.r_period_end_date(l_rec_no) := r_enc_period.r_period_end_date(I);
6015 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := r_enc_period.r_asg_start_date(I);
6016 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := r_enc_period.r_asg_end_date(I);
6017 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
6018 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
6019 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
6020 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
6021 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
6022 l_rec_no := l_rec_no + 1;
6023 END IF;
6024 END IF;
6025 l_sch_pointer := da_recno;
6026 EXIT WHEN l_asg_start_date > l_asg_end_date;
6027 END LOOP;
6028 ELSE
6029 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
6030 r_enc_period_tmp1.r_period_start_date(l_rec_no) := r_enc_period.r_period_start_date(I);
6031 r_enc_period_tmp1.r_period_end_date(l_rec_no) := r_enc_period.r_period_end_date(I);
6032 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := r_enc_period.r_asg_start_date(I);
6033 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := r_enc_period.r_asg_end_date(I);
6034 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
6035 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
6036 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
6037 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
6038 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
6039 l_rec_no := l_rec_no + 1;
6040 END IF;
6041 END LOOP;
6042 hr_utility.trace('Dumping Assignment Chunk After Organization Default Account Processing ...');
6043 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
6044 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
6045 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
6046 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
6047 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
6048 RPAD('Reason Code', 50, ' '));
6049 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
6050 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
6051 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
6052 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
6053 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
6054 RPAD('-', 50, '-'));
6055
6056 FOR recno IN 1..r_enc_period_tmp1.r_time_period_id.COUNT
6057 LOOP
6058 hr_utility.trace(LPAD(r_enc_period_tmp1.r_period_ind(recno), 13, ' ') || ' ' ||
6059 LPAD(r_enc_period_tmp1.r_time_period_id(recno), 14, ' ') || ' ' ||
6060 RPAD(TO_CHAR(r_enc_period_tmp1.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
6061 RPAD(TO_CHAR(r_enc_period_tmp1.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
6062 RPAD(TO_CHAR(r_enc_period_tmp1.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
6063 RPAD(TO_CHAR(r_enc_period_tmp1.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
6064 RPAD(TO_CHAR(r_enc_period_tmp1.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
6065 RPAD(r_enc_period_tmp1.r_process_flag(recno), 12, ' ') || ' ' ||
6066 LPAD(r_enc_period_tmp1.r_schedule_percent(recno), 16, ' ') || ' ' ||
6067 RPAD(r_enc_period_tmp1.r_reason_code(recno), 50, ' '));
6068 END LOOP;
6069 ELSE
6070 FOR I IN 1..r_enc_period.r_time_period_id.COUNT
6071 LOOP
6072 r_enc_period_tmp1.r_period_ind(I) := r_enc_period.r_period_ind(I);
6073 r_enc_period_tmp1.r_period_start_date(I) := r_enc_period.r_period_start_date(I);
6074 r_enc_period_tmp1.r_period_end_date(I) := r_enc_period.r_period_end_date(I);
6075 r_enc_period_tmp1.r_asg_start_date(I) := r_enc_period.r_asg_start_date(I);
6076 r_enc_period_tmp1.r_asg_end_date(I) := r_enc_period.r_asg_end_date(I);
6077 r_enc_period_tmp1.r_time_period_id(I) := r_enc_period.r_time_period_id(I);
6078 r_enc_period_tmp1.r_process_flag(I) := r_enc_period.r_process_flag(I);
6079 r_enc_period_tmp1.r_schedule_percent(I) := r_enc_period.r_schedule_percent(I);
6080 r_enc_period_tmp1.r_reason_code(I) := r_enc_period.r_reason_code(I);
6081 r_enc_period_tmp1.r_effective_date(I) := r_enc_period.r_effective_date(I);
6082 END LOOP;
6083 END IF;
6084
6085 r_enc_period.r_time_period_id.DELETE;
6086 r_enc_period.r_period_start_date.DELETE;
6087 r_enc_period.r_period_end_date.DELETE;
6088 r_enc_period.r_asg_start_date.DELETE;
6089 r_enc_period.r_asg_end_date.DELETE;
6090 r_enc_period.r_process_flag.DELETE;
6091 r_enc_period.r_period_ind.DELETE;
6092 r_enc_period.r_schedule_percent.DELETE;
6093 r_enc_period.r_encumbrance_amount.DELETE;
6094 r_enc_period.r_period_amount.DELETE;
6095 r_enc_period.r_reason_code.DELETE;
6096 r_enc_period.r_effective_date.DELETE;
6097
6098 l_rec_no := 1;
6099 l_proc_step := 200;
6100
6101 hr_utility.trace('Organization Suspense Account Processing');
6102
6103 l_sch_pointer := 1;
6104 FOR I IN 1..r_enc_period_tmp1.r_time_period_id.COUNT
6105 LOOP
6106 l_period_start_date := r_enc_period_tmp1.r_period_start_date(I);
6107 l_period_end_date := r_enc_period_tmp1.r_period_end_date(I);
6108 l_asg_start_date := r_enc_period_tmp1.r_asg_start_date(I);
6109 l_asg_end_date := r_enc_period_tmp1.r_asg_end_date(I);
6110 l_process_flag := r_enc_period_tmp1.r_process_flag(I);
6111 l_sub_slice_counter := 1;
6112 l_proc_step := 210 + (I / 100000);
6113
6114 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
6115 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
6116 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
6117 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
6118 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
6119 ' r_enc_period_tmp1.r_time_period_id(I): ' || fnd_number.number_to_canonical(r_enc_period_tmp1.r_time_period_id(I)) ||
6120 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no));
6121
6122 IF (l_process_flag IN ('BAL', 'Y')) AND (l_sch_pointer <= r_sa.end_date_active.COUNT) THEN
6123 IF (l_asg_start_date <= g_enc_org_end_date) THEN
6124 FOR sa_recno IN l_sch_pointer..r_sa.start_date_active.COUNT
6125 LOOP
6126 l_start_date:= r_sa.start_date_active(sa_recno);
6127 l_end_date:= r_sa.end_date_active(sa_recno);
6128 IF (l_process_flag = 'BAL') THEN
6129 l_schedule_percent := r_enc_period_tmp1.r_schedule_percent(I);
6130 ELSE
6131 l_schedule_percent:= r_sa.percent(sa_recno);
6132 END IF;
6133 l_proc_step := 220 + (l_rec_no / 100000);
6134
6135 hr_utility.trace('l_sub_slice_counter: ' || fnd_number.number_to_canonical(l_sub_slice_counter) ||
6136 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no) ||
6137 ' l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
6138 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
6139 ' l_schedule_percent: ' || fnd_number.number_to_canonical(l_schedule_percent));
6140
6141 IF (r_sa.start_date_active(sa_recno) > l_asg_end_date) THEN
6142 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6143 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
6144 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
6145 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
6146 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
6147 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6148 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6149 r_enc_period.r_process_flag(l_rec_no) := r_enc_period_tmp1.r_process_flag(I);
6150 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
6151 r_enc_period.r_reason_code(l_rec_no) := l_reason_code;
6152 l_rec_no := l_rec_no + 1;
6153 EXIT;
6154 END IF;
6155
6156 IF (l_end_date >= l_asg_start_date) AND (l_start_date <= l_asg_end_date) THEN
6157 IF (l_process_flag = 'BAL') THEN
6158 l_reason_code := 'LDM_BAL_NOT_100_PERCENT';
6159 add_cel_warnings(p_start_date => l_asg_start_date,
6160 p_hierarchy_code => 'SA',
6161 p_end_date => l_asg_end_date,
6162 p_warning_code => 'BAL',
6163 p_percent => r_enc_period_tmp1.r_schedule_percent(I));
6164 ELSE
6165 l_reason_code := 'LDM_NO_CI_FOUND';
6166 add_cel_warnings(p_start_date => l_asg_start_date,
6167 p_hierarchy_code => 'SA',
6168 p_end_date => l_asg_end_date,
6169 p_warning_code => 'NO_CI');
6170 END IF;
6171 IF (l_asg_start_date = l_start_date AND l_asg_end_date = l_end_date) THEN
6172 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6173 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
6174 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
6175 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
6176 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
6177 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6178 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6179 r_enc_period.r_process_flag(l_rec_no) := 'SA';
6180 r_enc_period.r_schedule_percent(l_rec_no) := l_schedule_percent;
6181 r_enc_period.r_reason_code(l_rec_no) := l_reason_code;
6182 l_rec_no := l_rec_no + 1;
6183 ELSE
6184 IF (l_start_date > GREATEST(l_period_start_date, l_asg_start_date)) THEN
6185 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date);
6186 l_new_end_date := l_start_date - 1;
6187 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6188 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
6189 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
6190 r_enc_period.r_asg_start_date(l_rec_no) := l_new_start_date;
6191 r_enc_period.r_asg_end_date(l_rec_no) := l_new_end_date;
6192 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6193 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6194 r_enc_period.r_process_flag(l_rec_no) := l_process_flag;
6195 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
6196 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
6197 l_rec_no := l_rec_no + 1;
6198 l_asg_start_date := l_start_date;
6199 END IF;
6200 IF (l_end_date < LEAST(l_period_end_date, l_asg_end_date)) THEN
6201 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date, l_start_date);
6202 l_new_end_date := l_end_date;
6203 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6204 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
6205 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
6206 r_enc_period.r_asg_start_date(l_rec_no) := l_new_start_date;
6207 r_enc_period.r_asg_end_date(l_rec_no) := l_new_end_date;
6208 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6209 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6210 r_enc_period.r_process_flag(l_rec_no) := 'SA';
6211 r_enc_period.r_schedule_percent(l_rec_no) := l_schedule_percent;
6212 r_enc_period.r_reason_code(l_rec_no) := l_reason_code;
6213 l_rec_no := l_rec_no + 1;
6214 l_asg_start_date := l_end_date + 1;
6215 IF (sa_recno = r_sa.start_date_active.COUNT) AND
6216 (l_asg_start_date <= l_asg_end_date) THEN
6217 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6218 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
6219 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
6220 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
6221 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
6222 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6223 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6224 r_enc_period.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
6225 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
6226 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
6227 l_rec_no := l_rec_no + 1;
6228 END IF;
6229 ELSE
6230 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6231 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
6232 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
6233 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
6234 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
6235 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6236 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6237 r_enc_period.r_process_flag(l_rec_no) := 'SA';
6238 r_enc_period.r_schedule_percent(l_rec_no) := l_schedule_percent;
6239 r_enc_period.r_reason_code(l_rec_no) := l_reason_code;
6240 l_rec_no := l_rec_no + 1;
6241 l_asg_start_date := l_end_date + 1;
6242 END IF;
6243 END IF;
6244 l_sub_slice_counter := 2;
6245 ELSE
6246 IF (sa_recno = r_sa.start_date_active.COUNT) THEN
6247 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6248 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
6249 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
6250 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
6251 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
6252 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6253 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6254 r_enc_period.r_process_flag(l_rec_no) := r_enc_period_tmp1.r_process_flag(I);
6255 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
6256 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
6257 l_rec_no := l_rec_no + 1;
6258 END IF;
6259 END IF;
6260 l_sch_pointer := sa_recno;
6261 EXIT WHEN l_asg_start_date > l_asg_end_date;
6262 END LOOP;
6263 ELSE
6264 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6265 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
6266 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
6267 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
6268 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
6269 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6270 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6271 r_enc_period.r_process_flag(l_rec_no) := 'I';
6272 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
6273 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
6274 l_rec_no := l_rec_no + 1;
6275 END IF;
6276 ELSE
6277 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6278 r_enc_period.r_period_start_date(l_rec_no) := r_enc_period_tmp1.r_period_start_date(I);
6279 r_enc_period.r_period_end_date(l_rec_no) := r_enc_period_tmp1.r_period_end_date(I);
6280 r_enc_period.r_asg_start_date(l_rec_no) := r_enc_period_tmp1.r_asg_start_date(I);
6281 r_enc_period.r_asg_end_date(l_rec_no) := r_enc_period_tmp1.r_asg_end_date(I);
6282 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6283 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6284 r_enc_period.r_process_flag(l_rec_no) := r_enc_period_tmp1.r_process_flag(I);
6285 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
6286 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
6287 l_rec_no := l_rec_no + 1;
6288 END IF;
6289 END LOOP;
6290
6291 r_enc_period_tmp1.r_time_period_id.DELETE;
6292 r_enc_period_tmp1.r_period_start_date.DELETE;
6293 r_enc_period_tmp1.r_period_end_date.DELETE;
6294 r_enc_period_tmp1.r_asg_start_date.DELETE;
6295 r_enc_period_tmp1.r_asg_end_date.DELETE;
6296 r_enc_period_tmp1.r_process_flag.DELETE;
6297 r_enc_period_tmp1.r_period_ind.DELETE;
6298 r_enc_period_tmp1.r_schedule_percent.DELETE;
6299 r_enc_period_tmp1.r_encumbrance_amount.DELETE;
6300 r_enc_period_tmp1.r_period_amount.DELETE;
6301 r_enc_period_tmp1.r_reason_code.DELETE;
6302 r_enc_period_tmp1.r_effective_date.DELETE;
6303 l_proc_step := 230;
6304
6305 hr_utility.trace('Dumping Assignment Chunk After Suspense Account Processing ...');
6306 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
6307 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
6308 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
6309 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
6310 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
6311 RPAD('Reason Code', 50, ' '));
6312 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
6313 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
6314 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
6315 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
6316 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
6317 RPAD('-', 50, '-'));
6318
6319 FOR recno IN 1..r_enc_period.r_time_period_id.COUNT
6320 LOOP
6321 hr_utility.trace(LPAD(r_enc_period.r_period_ind(recno), 13, ' ') || ' ' ||
6322 LPAD(r_enc_period.r_time_period_id(recno), 14, ' ') || ' ' ||
6323 RPAD(TO_CHAR(r_enc_period.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
6324 RPAD(TO_CHAR(r_enc_period.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
6325 RPAD(TO_CHAR(r_enc_period.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
6326 RPAD(TO_CHAR(r_enc_period.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
6327 RPAD(TO_CHAR(r_enc_period.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
6328 RPAD(r_enc_period.r_process_flag(recno), 12, ' ') || ' ' ||
6329 LPAD(r_enc_period.r_schedule_percent(recno), 16, ' ') || ' ' ||
6330 RPAD(r_enc_period.r_reason_code(recno), 50, ' '));
6331 r_enc_period.r_encumbrance_amount(recno) := 0;
6332 END LOOP;
6333 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving ' || l_proc_name);
6334
6335 p_return_status := fnd_api.g_ret_sts_success;
6336 EXCEPTION
6337 WHEN OTHERS THEN
6338 IF (g_error_message IS NULL) THEN
6339 g_error_message := l_proc_name || ': ' || SQLERRM;
6340 END IF;
6341 g_error_api_path := SUBSTR(' SUB_SLICE_ASG_CHUNK:'||g_error_api_path,1,230);
6342 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', ' SUB_SLICE_ASG_CHUNK');
6343 p_return_status := fnd_api.g_ret_sts_unexp_error;
6344 fnd_file.put_line(fnd_file.log, fnd_number.number_to_canonical(l_proc_step) || ': ' || l_proc_name);
6345 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving ' || l_proc_name);
6346 END sub_slice_asg_chunk;
6347 -- End of bug fix 3462452
6348
6349 PROCEDURE cel_init(p_payroll_action_id IN NUMBER) IS
6350 BEGIN
6351 -- spc_track_cel('Init', NULL, 'Start');
6352 NULL;
6353 -- spc_track_cel('Init', NULL, 'End');
6354 EXCEPTION
6355 WHEN OTHERS THEN
6356 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'CEL_INIT: SQLCODE: ' || fnd_number.number_to_canonical(SQLCODE) || ' SQLERRM: ' || SQLERRM);
6357 psp_message_s.print_error(p_mode => FND_FILE.LOG,
6358 p_print_header => FND_API.G_TRUE);
6359 END cel_init;
6360
6361 PROCEDURE cel_range_code (pactid IN NUMBER,
6362 sqlstr OUT NOCOPY VARCHAR2) IS
6363 l_payroll_id NUMBER(15);
6364 l_process_mode VARCHAR2(15);
6365 l_process_code VARCHAR2(15);
6366 l_return_status VARCHAR2(1);
6367 l_last_update_date DATE;
6368 l_last_updated_by NUMBER;
6369 l_last_updated_login NUMBER;
6370 l_request_id NUMBER;
6371 l_business_group_id NUMBER(15);
6372 l_set_of_books_id NUMBER(15);
6373 NO_UPDATE_REC_FOUND EXCEPTION;
6374
6375 CURSOR action_parameters_cur IS
6376 SELECT fnd_number.canonical_to_number(NVL(argument11, -1)),
6377 argument12
6378 FROM fnd_concurrent_requests
6379 WHERE request_id = l_request_id;
6380
6381 CURSOR enc_payrolls_cur IS
6382 SELECT pep.payroll_id
6383 FROM psp_enc_payrolls pep
6384 WHERE pep.business_group_id = l_business_group_id
6385 AND pep.set_of_books_id = l_set_of_books_id;
6386 BEGIN
6387 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering CEL_RANGE_CODE pactid: ' || pactid);
6388
6389 l_last_update_date := SYSDATE;
6390 l_last_updated_by := NVL(FND_GLOBAL.USER_ID, -1);
6391 l_last_updated_login := NVL(FND_GLOBAL.LOGIN_ID, -1);
6392 l_request_id := fnd_global.conc_request_id;
6393 l_set_of_books_id := FND_PROFILE.VALUE('GL_SET_OF_BKS_ID');
6394 l_business_group_id := FND_PROFILE.VALUE('PER_BUSINESS_GROUP_ID');
6395
6396 OPEN action_parameters_cur;
6397 FETCH action_parameters_cur INTO l_payroll_id, l_process_mode;
6398 CLOSE action_parameters_cur;
6399
6400 IF (l_payroll_id = -1) THEN
6401 l_payroll_id := NULL;
6402 END IF;
6403 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_payroll_id: ' || l_payroll_id || '
6404 process_mode: ' || l_process_mode);
6405
6406 l_process_code := 'CEL';
6407 IF (l_process_mode = 'TERMINATE') THEN
6408 l_process_code := 'LET';
6409 END IF;
6410
6411 INSERT INTO psp_enc_processes
6412 (request_id, process_code, payroll_action_id,
6413 process_status, process_phase, business_group_id,
6414 set_of_books_id, creation_date, created_by,
6415 last_update_date, last_updated_by, last_update_login)
6416 VALUES
6417 (l_request_id, l_process_code, pactid,
6418 'I', NULL, l_business_group_id,
6419 l_set_of_books_id, l_last_update_date, l_last_updated_by,
6420 l_last_update_date, l_last_updated_by, l_last_updated_login);
6421
6422 IF ((l_payroll_id IS NOT NULL) OR (l_process_mode = 'TERMINATE')) THEN
6423 enc_pre_process(pactid, l_payroll_id, l_process_mode, l_return_status);
6424
6425 IF l_return_status <> fnd_api.g_ret_sts_success THEN
6426 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6427 END IF;
6428 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Completed enc_pre_process for l_payroll_id: ' || l_payroll_id || ' process_mode: ' || l_process_mode);
6429 ELSE
6430 OPEN enc_payrolls_cur;
6431 LOOP
6432 FETCH enc_payrolls_cur INTO l_payroll_id;
6433 EXIT WHEN enc_payrolls_cur%NOTFOUND;
6434
6435 enc_pre_process(pactid, l_payroll_id, l_process_mode, l_return_status);
6436 IF l_return_status <> fnd_api.g_ret_sts_success THEN
6437 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6438 END IF;
6439 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Completed enc_pre_process for l_payroll_id: ' || l_payroll_id || ' process_mode: ' || l_process_mode);
6440 END LOOP;
6441 CLOSE enc_payrolls_cur;
6442 l_payroll_id := NULL;
6443 END IF;
6444
6445 sqlstr := 'SELECT DISTINCT assignment_id FROM psp_enc_changed_assignments WHERE ';
6446 IF (l_payroll_id IS NOT NULL) THEN
6447 sqlstr := sqlstr || 'payroll_id = ' || fnd_number.number_to_canonical(l_payroll_id) || ' AND ';
6448 END IF;
6449
6450 sqlstr := sqlstr || 'payroll_action_id = :payroll_action_id ORDER BY assignment_id';
6451
6452 INSERT INTO psp_enc_process_assignments
6453 (payroll_action_id, assignment_id, payroll_id,
6454 assignment_status, creation_date, created_by,
6455 last_update_date, last_updated_by, last_update_login)
6456 SELECT DISTINCT pactid, assignment_id, payroll_id,
6457 'I', l_last_update_date, l_last_updated_by,
6458 l_last_update_date, l_last_updated_by, l_last_updated_login
6459 FROM psp_enc_changed_assignments
6460 WHERE payroll_action_id = pactid;
6461
6462 IF (SQL%ROWCOUNT = 0) THEN
6463 fnd_message.set_name('PSP', 'PSP_ENC_NO_LIN_UPD');
6464 g_warning_message := fnd_message.get;
6465 fnd_file.put_line(fnd_file.log, g_warning_message);
6466 psp_general.add_report_error
6467 (p_request_id => l_request_id,
6468 p_message_level => 'N',
6469 p_source_id => NULL,
6470 p_source_name => NULL,
6471 p_error_message => g_warning_message,
6472 p_payroll_action_id => pactid,
6473 p_return_status => l_return_status);
6474 RAISE NO_UPDATE_REC_FOUND;
6475 END IF;
6476
6477 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' sqlstr: ' || sqlstr);
6478 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving CEL_RANGE_CODE pactid: ' || pactid);
6479 EXCEPTION
6480 WHEN NO_UPDATE_REC_FOUND THEN
6481 psp_message_s.print_error (p_mode => FND_FILE.LOG, p_print_header => FND_API.G_FALSE);
6482 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving CEL_RANGE_CODE pactid: ' || pactid);
6483 WHEN OTHERS THEN
6484 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'CEL_RANGE_CODE: SQLCODE: ' || fnd_number.number_to_canonical(SQLCODE) || ' SQLERRM: ' || SQLERRM);
6485 psp_message_s.print_error(p_mode => FND_FILE.LOG,
6486 p_print_header => FND_API.G_TRUE);
6487 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving CEL_RANGE_CODE pactid: ' || pactid);
6488 END cel_range_code;
6489
6490 PROCEDURE cel_asg_action_code (p_pactid IN NUMBER,
6491 start_asg IN NUMBER,
6492 end_asg IN NUMBER,
6493 p_chunk_num IN NUMBER) IS
6494 CURSOR get_assignments_cur IS
6495 SELECT DISTINCT assignment_id
6496 FROM psp_enc_changed_assignments
6497 WHERE assignment_id BETWEEN start_asg AND end_asg
6498 AND payroll_action_id = p_pactid;
6499
6500 TYPE t_number_15 IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
6501 t_asg_array t_number_15;
6502 l_asg_action_id NUMBER(15);
6503 BEGIN
6504 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering CEL_ASG_ACTION_CODE p_pactid: ' || p_pactid || '
6505 start_asg: ' || start_asg || '
6506 end_asg: ' || end_asg || '
6507 p_chunk_num: ' || p_chunk_num);
6508
6509 OPEN get_assignments_cur;
6510 FETCH get_assignments_cur BULK COLLECT INTO t_asg_array;
6511 CLOSE get_assignments_cur;
6512
6513 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' t_asg_array.COUNT: ' || t_asg_array.COUNT);
6514 FOR recno IN 1..t_asg_array.COUNT
6515 LOOP
6516 SELECT pay_assignment_actions_s.NEXTVAL INTO l_asg_action_id FROM DUAL;
6517 hr_nonrun_asact.insact(l_asg_action_id,
6518 pactid => p_pactid,
6519 chunk => p_chunk_num,
6520 object_id => t_asg_array(recno),
6521 object_type => 'ASG',
6522 p_transient_action => TRUE);
6523 END LOOP;
6524 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving CEL_ASG_ACTION_CODE payroll_action_id: ' || p_pactid || '
6525 start_asg: ' || start_asg || '
6526 end_asg: ' || end_asg || '
6527 p_chunk_num: ' || p_chunk_num);
6528 END cel_asg_action_code;
6529
6530 PROCEDURE cel_archive (p_payroll_action_id IN NUMBER,
6531 p_chunk_number IN NUMBER) IS
6532 l_business_group_id NUMBER(15);
6533 l_set_of_books_id NUMBER(15);
6534 l_assignment_id NUMBER(15);
6535 l_payroll_id NUMBER(15);
6536 l_person_id NUMBER(15);
6537 l_organization_id NUMBER(15);
6538 l_assignment_number per_all_assignments_f.assignment_number%TYPE;
6539 l_payroll_name pay_all_payrolls_f.payroll_name%TYPE;
6540 l_full_name per_all_people_f.full_name%TYPE;
6541 l_organization_name hr_organization_units.name%TYPE;
6542 l_process_mode VARCHAR2(15);
6543 l_enc_begin_date DATE;
6544 l_min_asg_id NUMBER(15);
6545 l_max_asg_id NUMBER(15);
6546 l_enc_period_end_date DATE;
6547 l_enc_period_date DATE;
6548 l_element_type_id NUMBER;
6549 l_element_name pay_element_types_f.element_name%TYPE;
6550 l_return_status VARCHAR2(1);
6551 l_enc_org_end_date DATE;
6552 l_max_enc_date DATE;
6553 l_enc_create NUMBER;
6554 l_new_cust NUMBER;
6555 l_pre_process_mode VARCHAR2(1);
6556 l_profile_value BOOLEAN;
6557 l_max_enc_lines_date DATE;
6558 l_enc_create_lines NUMBER;
6559 l_max_enc_hist_date DATE;
6560 l_enclines_check BOOLEAN;
6561 l_enclines_index NUMBER;
6562 l_liq_only_count NUMBER(15);
6563 l_liq_all_count NUMBER(15);
6564 l_money_value NUMBER(15);
6565 l_hours_value NUMBER(15);
6566
6567 CURSOR payroll_id_cur IS
6568 SELECT fnd_number.canonical_to_number(NVL(argument11, -1)),
6569 argument12
6570 FROM fnd_concurrent_requests fcr,
6571 psp_enc_processes pep
6572 WHERE pep.payroll_action_id = p_payroll_action_id
6573 AND fcr.request_id = pep.request_id;
6574
6575 CURSOR get_asg_id_cur IS
6576 SELECT MIN(object_id),
6577 MAX(object_id)
6578 FROM pay_temp_object_actions
6579 WHERE payroll_action_id = p_payroll_action_id
6580 AND chunk_number = p_chunk_number;
6581
6582 CURSOR get_payroll_asg_cur IS
6583 SELECT DISTINCT payroll_id,
6584 assignment_id,
6585 change_date
6586 FROM psp_enc_changed_assignments peca
6587 WHERE assignment_id BETWEEN l_min_asg_id AND l_max_asg_id
6588 AND ( (l_process_mode = 'TERMINATE' AND change_type = 'TR')
6589 OR (l_process_mode = 'REGULAR' AND change_type <> 'TR'))
6590 AND payroll_id = NVL(l_payroll_id, payroll_id)
6591 /*AND NOT EXISTS (SELECT 1
6592 FROM psp_enc_process_assignments pepa
6593 WHERE pepa.assignment_id = peca.assignment_id
6594 AND pepa.payroll_action_id = p_payroll_action_id
6595 AND pepa.assignment_status <> 'B')*/;
6596
6597 CURSOR earnings_element_cur(p_Assignment_ID NUMBER) IS
6598 SELECT DISTINCT
6599 pet.element_type_id,
6600 pc.costing_debit_or_credit
6601 FROM PAY_ELEMENT_ENTRIES_F pee,
6602 PAY_ELEMENT_LINKS_F pel,
6603 PAY_ELEMENT_TYPES_F pet,
6604 PER_ASSIGNMENTS_F pa,
6605 PAY_ELEMENT_CLASSIFICATIONS pc
6606 WHERE pee.assignment_id = p_assignment_id
6607 AND pa.assignment_id = p_assignment_id
6608 AND pee.effective_end_date >= pa.effective_start_date
6609 AND pee.effective_start_date <= pa.effective_end_date
6610 AND pee.element_link_id = pel.element_link_id
6611 AND pel.effective_end_date >= pa.effective_start_date
6612 AND pel.effective_start_date <= pa.effective_end_date
6613 AND pee.entry_type = 'E'
6614 AND pel.element_type_id = pet.element_type_id
6615 AND pet.effective_end_date >= pa.effective_start_date
6616 AND pet.effective_start_date <=pa.effective_end_date
6617 AND pel.business_group_id = l_business_group_id
6618 AND pet.element_type_id IN ( SELECT element_type_id
6619 FROM psp_enc_elements
6620 WHERE business_group_id = l_business_group_id
6621 AND set_of_books_id = l_set_of_books_id)
6622 AND pet.classification_id = pc.classification_id
6623 ORDER BY pet.element_type_id;
6624
6625 CURSOR c_max_enc_date (p_assignment_id NUMBER,
6626 p_element_type_id NUMBER,
6627 p_enc_begin_date DATE) IS
6628 SELECT COUNT(1),
6629 NVL(MAX(pelh.encumbrance_date),p_enc_begin_date)
6630 FROM psp_enc_lines_history pelh
6631 WHERE pelh.assignment_id = l_assignment_id
6632 AND pelh.enc_element_type_id = p_element_type_id
6633 AND pelh.payroll_id = l_payroll_id;
6634
6635 /* Bug 5642002: Replaced earned date with period end date */
6636 CURSOR c_last_pay_run (p_assignment_id NUMBER)IS
6637 SELECT /*+ use_nl(PTP) */ Max(ptp.end_date)
6638 FROM pay_payroll_actions ppa,
6639 pay_assignment_actions paa,
6640 per_time_periods ptp
6641 WHERE ppa.payroll_action_id = paa.payroll_action_id (+)
6642 AND ppa.business_group_id = l_business_group_id
6643 AND ppa.payroll_id = l_payroll_id
6644 AND NVL(paa.assignment_id, p_assignment_id) = p_assignment_id
6645 AND ppa.action_type IN ( 'R','Q')
6646 AND NVL(paa.action_status, ppa.action_status) = 'C'
6647 and ppa.date_earned between ptp.start_date and ptp.end_date
6648 and ptp.payroll_id = ppa.payroll_id;
6649
6650 CURSOR c_tp_start_date IS
6651 SELECT MIN(ptp.start_date)
6652 FROM per_time_periods ptp
6653 WHERE ptp.payroll_id = l_payroll_id;
6654
6655 CURSOR c_obtain_eff_date_option IS
6656 SELECT NVL(parameter_value,1)
6657 FROM psp_enc_setup_options peso
6658 WHERE peso.setup_parameter ='EFFECTIVE_DATE'
6659 AND peso.business_group_id = l_business_group_id
6660 AND peso.set_of_books_id = l_set_of_books_id;
6661
6662 CURSOR c_max_enc_lines_date (p_assignment_id NUMBER,
6663 p_element_type_id NUMBER,
6664 p_enc_begin_date DATE) IS
6665 SELECT COUNT(1), NVL(MAX(pel.encumbrance_date),p_enc_begin_date)
6666 FROM psp_enc_lines pel
6667 WHERE pel.enc_element_type_id = p_element_type_id
6668 AND pel.assignment_id = p_assignment_id
6669 AND pel.payroll_id = l_payroll_id;
6670
6671 CURSOR cel_request_id_cur IS
6672 SELECT request_id
6673 FROM pay_payroll_actions
6674 WHERE payroll_action_id = p_payroll_action_id;
6675
6676 CURSOR asg_number_cur (p_effective_date IN DATE) IS
6677 SELECT assignment_number,
6678 person_id,
6679 organization_id
6680 FROM per_all_assignments_f
6681 WHERE assignment_id = l_assignment_id
6682 AND payroll_id = l_payroll_id
6683 AND effective_end_date >= p_effective_date
6684 AND ROWNUM = 1;
6685
6686 CURSOR payroll_name_cur IS
6687 SELECT payroll_name
6688 FROM pay_all_payrolls_f
6689 WHERE payroll_id = l_payroll_id
6690 AND business_group_id = g_business_group_id
6691 AND gl_set_of_books_id = g_set_of_books_id;
6692
6693 CURSOR person_name_cur (p_effective_date IN DATE) IS
6694 SELECT full_name
6695 FROM per_all_people_f
6696 WHERE person_id = l_person_id
6697 AND effective_end_date >= p_effective_date
6698 AND ROWNUM = 1;
6699
6700 CURSOR org_name_cur IS
6701 SELECT name
6702 FROM hr_organization_units
6703 WHERE organization_id = l_organization_id;
6704
6705 CURSOR element_name_cur IS
6706 SELECT element_name
6707 FROM pay_element_types_f
6708 WHERE element_type_id = l_element_type_id
6709 AND ROWNUM = 1;
6710
6711 CURSOR emphours_config_cur IS
6712 SELECT pcv_information2 employee_hours
6713 FROM pqp_configuration_values
6714 WHERE pcv_information_category = 'PSP_IMPORT_EMPLOYEE_HOURS'
6715 AND legislation_code IS NULL
6716 AND NVL(business_group_id, l_business_group_id) = l_business_group_id;
6717
6718 CURSOR autopop_config_cur IS
6719 SELECT pcv_information1 global_element_autopop,
6720 pcv_information2 element_type_autopop,
6721 pcv_information3 element_class_autopop,
6722 pcv_information4 assignment_autopop,
6723 pcv_information5 default_schedule_autopop,
6724 pcv_information6 default_account_autopop,
6725 pcv_information7 suspense_account
6726 FROM pqp_configuration_values
6727 WHERE pcv_information_category = 'PSP_ENABLE_AUTOPOPULATION'
6728 AND legislation_code IS NULL
6729 AND NVL(business_group_id, l_business_group_id) = l_business_group_id
6730 ORDER BY business_group_id;
6731
6732 CURSOR liq_only_asg_cur IS
6733 SELECT COUNT(1)
6734 FROM psp_enc_changed_assignments
6735 WHERE assignment_id = l_assignment_id
6736 AND payroll_id = l_payroll_id
6737 AND payroll_action_id = p_payroll_action_id
6738 AND change_type <> 'LQ';
6739
6740 CURSOR liq_all_cur IS
6741 SELECT COUNT(1)
6742 FROM psp_enc_changed_assignments
6743 WHERE assignment_id = l_assignment_id
6744 AND payroll_id = l_payroll_id
6745 AND payroll_action_id = p_payroll_action_id
6746 AND change_type = 'ZZ';
6747
6748 CURSOR money_value_cur (p_element_type_id IN NUMBER) IS
6749 SELECT COUNT(1)
6750 FROM psp_enc_elements pee
6751 WHERE element_type_id = p_element_type_id
6752 AND ( formula_id IS NOT NULL
6753 OR EXISTS (SELECT 1
6754 FROM pay_input_values_f piv
6755 WHERE piv.input_value_id = pee.input_value_id
6756 AND SUBSTR(piv.uom, 1, 1) <> 'H'));
6757
6758 CURSOR hours_value_cur (p_element_type_id IN NUMBER) IS
6759 SELECT COUNT(1)
6760 FROM psp_enc_elements pee
6761 WHERE element_type_id = p_element_type_id
6762 AND ( formula_id IS NOT NULL
6763 OR EXISTS (SELECT 1
6764 FROM pay_input_values_f piv
6765 WHERE piv.input_value_id = pee.input_value_id
6766 AND SUBSTR(piv.uom, 1, 1) = 'H'));
6767
6768
6769 TYPE payid_tab IS TABLE OF per_all_assignments_f.payroll_id%TYPE INDEX BY BINARY_INTEGER;
6770 TYPE asgid_tab IS TABLE OF per_all_assignments_f.assignment_id%TYPE INDEX BY BINARY_INTEGER;
6771 TYPE term_date_tab IS TABLE OF DATE INDEX BY BINARY_INTEGER;
6772 TYPE t_asg_id_rec IS RECORD
6773 (payroll_array payid_tab,
6774 asg_array asgid_tab,
6775 term_date_array term_date_tab);
6776 t_assignments t_asg_id_rec;
6777
6778 TYPE enclinesasg_tab IS TABLE OF psp_enc_lines.assignment_id%TYPE INDEX BY BINARY_INTEGER;
6779 TYPE enclinesele_tab IS TABLE OF psp_enc_lines.enc_element_type_id%TYPE INDEX BY BINARY_INTEGER;
6780 TYPE enclinesdat_tab IS TABLE OF psp_enc_lines.encumbrance_date%TYPE INDEX BY BINARY_INTEGER;
6781 TYPE t_enclines_rec IS RECORD
6782 (asg_array enclinesasg_tab,
6783 ele_array enclinesele_tab,
6784 dat_array enclinesdat_tab);
6785 t_enclines t_enclines_rec;
6786
6787 PROCEDURE log_cel_warnings IS
6788 CURSOR project_number_cur (p_project_id IN NUMBER) IS
6789 SELECT SEGMENT1
6790 FROM pa_projects_all
6791 WHERE project_id = p_project_id;
6792
6793 CURSOR award_number_cur (p_award_id IN NUMBER) IS
6794 SELECT award_number
6795 FROM gms_awards_all
6796 WHERE award_id = p_award_id;
6797
6798 CURSOR task_number_cur (p_task_id IN NUMBER) IS
6799 SELECT task_number
6800 FROM pa_tasks
6801 WHERE task_id = p_task_id;
6802
6803 CURSOR exp_org_name_cur (p_expenditure_org_id IN NUMBER) IS
6804 SELECT name
6805 FROM hr_organization_units
6806 WHERE organization_id = p_expenditure_org_id;
6807
6808 l_project_number pa_projects_all.segment1%TYPE;
6809 l_task_number pa_tasks.task_number%TYPE;
6810 l_award_number gms_awards_all.award_number%TYPE;
6811 l_exp_org_name hr_organization_units.name%TYPE;
6812 l_gl_description VARCHAR2(1000);
6813 BEGIN
6814 FOR recno IN 1..cel_warnings.start_date.COUNT
6815 LOOP
6816 OPEN asg_number_cur(cel_warnings.start_date(recno));
6817 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
6818 CLOSE asg_number_cur;
6819
6820 OPEN payroll_name_cur;
6821 FETCH payroll_name_cur INTO l_payroll_name;
6822 CLOSE payroll_name_cur;
6823
6824 OPEN person_name_cur(cel_warnings.start_date(recno));
6825 FETCH person_name_cur INTO l_full_name;
6826 CLOSE person_name_cur;
6827
6828 OPEN org_name_cur;
6829 FETCH org_name_cur INTO l_organization_name;
6830 CLOSE org_name_cur;
6831
6832 OPEN element_name_cur;
6833 FETCH element_name_cur INTO l_element_name;
6834 CLOSE element_name_cur;
6835
6836 IF (cel_warnings.warning_code(recno) = 'BAL') THEN
6837 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_BALNOT100');
6838 fnd_message.set_token('START_DATE', cel_warnings.start_date(recno));
6839 fnd_message.set_token('END_DATE', cel_warnings.end_date(recno));
6840 fnd_message.set_token('PERCENT', cel_warnings.percent(recno));
6841 g_warning_message := fnd_message.get;
6842 ELSIF (cel_warnings.warning_code(recno) = 'GL') THEN
6843 fnd_message.set_name('PSP', 'PSP_CANNOT_ENC_HOURS_TO_GL');
6844 fnd_message.set_token('START_DATE', cel_warnings.start_date(recno));
6845 fnd_message.set_token('END_DATE', cel_warnings.end_date(recno));
6846 fnd_message.set_token('HOURS', cel_warnings.percent(recno));
6847 g_warning_message := fnd_message.get;
6848 ELSIF (cel_warnings.warning_code(recno) = 'AUTOPOP') AND
6849 (cel_warnings.gl_ccid(recno) IS NOT NULL) THEN
6850 l_gl_description := psp_general.get_gl_values(g_set_of_books_id, cel_warnings.gl_ccid(recno));
6851 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_AUTOPOP');
6852 fnd_message.set_token('START_DATE', cel_warnings.start_date(recno));
6853 fnd_message.set_token('END_DATE', cel_warnings.end_date(recno));
6854 fnd_message.set_token('GL', l_gl_description);
6855 fnd_message.set_token('AUTOPOP_STATUS', cel_warnings.error_status(recno));
6856 g_warning_message := fnd_message.get;
6857 ELSIF (cel_warnings.warning_code(recno) = 'AUTOPOP') AND (cel_warnings.gl_ccid(recno) IS NULL) THEN
6858 OPEN project_number_cur(cel_warnings.project_id(recno));
6859 FETCH project_number_cur INTO l_project_number;
6860 CLOSE project_number_cur;
6861
6862 OPEN award_number_cur(cel_warnings.award_id(recno));
6863 FETCH award_number_cur INTO l_award_number;
6864 CLOSE award_number_cur;
6865
6866 OPEN task_number_cur(cel_warnings.task_id(recno));
6867 FETCH task_number_cur INTO l_task_number;
6868 CLOSE task_number_cur;
6869
6870 OPEN exp_org_name_cur(cel_warnings.exp_org_id(recno));
6871 FETCH exp_org_name_cur INTO l_exp_org_name;
6872 CLOSE exp_org_name_cur;
6873
6874 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_AP_PATEO');
6875 fnd_message.set_token('START_DATE', cel_warnings.start_date(recno));
6876 fnd_message.set_token('END_DATE', cel_warnings.end_date(recno));
6877 fnd_message.set_token('PJ', l_project_number);
6878 fnd_message.set_token('TK', l_task_number);
6879 fnd_message.set_token('AW', l_award_number);
6880 fnd_message.set_token('EO', l_exp_org_name);
6881 fnd_message.set_token('ET', cel_warnings.exp_type(recno));
6882 fnd_message.set_token('AUTOPOP_STATUS', cel_warnings.error_status(recno));
6883 g_warning_message := fnd_message.get;
6884 ELSIF (cel_warnings.warning_code(recno) = 'NO_CI') THEN
6885 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_NOCI');
6886 fnd_message.set_token('START_DATE', cel_warnings.start_date(recno));
6887 fnd_message.set_token('END_DATE', cel_warnings.end_date(recno));
6888 g_warning_message := fnd_message.get;
6889 ELSIF (cel_warnings.warning_code(recno) = 'INVALID_CI') THEN
6890 OPEN project_number_cur(cel_warnings.project_id(recno));
6891 FETCH project_number_cur INTO l_project_number;
6892 CLOSE project_number_cur;
6893
6894 OPEN award_number_cur(cel_warnings.award_id(recno));
6895 FETCH award_number_cur INTO l_award_number;
6896 CLOSE award_number_cur;
6897
6898 OPEN task_number_cur(cel_warnings.task_id(recno));
6899 FETCH task_number_cur INTO l_task_number;
6900 CLOSE task_number_cur;
6901
6902 OPEN exp_org_name_cur(cel_warnings.exp_org_id(recno));
6903 FETCH exp_org_name_cur INTO l_exp_org_name;
6904 CLOSE exp_org_name_cur;
6905
6906 IF (cel_warnings.error_status(recno) IS NOT NULL) THEN
6907 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_INV_PATEO');
6908 fnd_message.set_token('PJ', l_project_number);
6909 fnd_message.set_token('TK', l_task_number);
6910 fnd_message.set_token('AW', l_award_number);
6911 fnd_message.set_token('EO', l_exp_org_name);
6912 fnd_message.set_token('ET', cel_warnings.exp_type(recno));
6913 fnd_message.set_token('START_DATE', cel_warnings.start_date(recno));
6914 fnd_message.set_token('END_DATE', cel_warnings.end_date(recno));
6915 fnd_message.set_token('ERROR_STATUS', cel_warnings.error_status(recno));
6916 ELSE
6917 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_END_PATEO');
6918 fnd_message.set_token('PJ', l_project_number);
6919 fnd_message.set_token('TK', l_task_number);
6920 fnd_message.set_token('AW', l_award_number);
6921 fnd_message.set_token('EO', l_exp_org_name);
6922 fnd_message.set_token('ET', cel_warnings.exp_type(recno));
6923 fnd_message.set_token('START_DATE', cel_warnings.start_date(recno));
6924 fnd_message.set_token('END_DATE', cel_warnings.end_date(recno));
6925 fnd_message.set_token('EFFECTIVE_DATE', cel_warnings.effective_date(recno));
6926 END IF;
6927 g_warning_message := fnd_message.get;
6928 END IF;
6929
6930 psp_general.add_report_error
6931 (p_request_id => g_request_id,
6932 p_message_level => 'W',
6933 p_source_id => l_assignment_id,
6934 p_source_name => l_assignment_number,
6935 p_parent_source_id => l_person_id,
6936 p_parent_source_name => l_full_name,
6937 p_error_message => g_warning_message,
6938 p_payroll_action_id => p_payroll_action_id,
6939 p_value1 => l_payroll_id,
6940 p_information1 => l_payroll_name,
6941 p_value2 => l_organization_id,
6942 p_value3 => l_element_type_id,
6943 p_information2 => l_organization_name,
6944 p_information3 => l_element_name,
6945 p_information4 => fnd_date.date_to_canonical(cel_warnings.start_date(recno)),
6946 p_information5 => fnd_date.date_to_canonical(cel_warnings.end_date(recno)),
6947 p_information6 => cel_warnings.hierarchy_code(recno),
6948 p_information7 => cel_warnings.error_status(recno),
6949 p_return_status => l_return_status);
6950 END LOOP;
6951 cel_warnings.start_date.DELETE;
6952 cel_warnings.end_date.DELETE;
6953 cel_warnings.warning_code.DELETE;
6954 cel_warnings.project_id.DELETE;
6955 cel_warnings.task_id.DELETE;
6956 cel_warnings.award_id.DELETE;
6957 cel_warnings.exp_org_id.DELETE;
6958 cel_warnings.exp_type.DELETE;
6959 cel_warnings.effective_date.DELETE;
6960 cel_warnings.error_status.DELETE;
6961 cel_warnings.percent.DELETE;
6962 END log_cel_warnings;
6963 BEGIN
6964 SAVEPOINT CEL_ARCHIVE;
6965 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Entering CEL_ARCHIVE (payroll_action_id: ' || p_payroll_action_id || ' chunk_number: ' || p_chunk_number ||')');
6966
6967 l_set_of_books_id := FND_PROFILE.VALUE('GL_SET_OF_BKS_ID');
6968 l_business_group_id := FND_PROFILE.VALUE('PER_BUSINESS_GROUP_ID');
6969 g_set_of_books_id := l_set_of_books_id;
6970 g_business_group_id := l_business_group_id;
6971 g_enc_line_type := 'U';
6972 g_package_name := 'PSP_ENC_CREATE_LINES.';
6973 g_payroll_action_id := p_payroll_action_id;
6974 g_dff_grouping_option := psp_general.get_enc_dff_grouping_option(l_business_group_id);
6975
6976 OPEN cel_request_id_cur;
6977 FETCH cel_request_id_cur INTO g_request_id;
6978 CLOSE cel_request_id_cur;
6979
6980 OPEN emphours_config_cur;
6981 FETCH emphours_config_cur INTO g_employee_hours;
6982 IF (emphours_config_cur%ROWCOUNT = 0) THEN
6983 g_employee_hours := 'N';
6984 END IF;
6985 CLOSE emphours_config_cur;
6986
6987 OPEN autopop_config_cur;
6988 FETCH autopop_config_cur INTO g_ge_autopop, g_et_autopop, g_eg_autopop, g_as_autopop, g_ds_autopop, g_da_autopop, g_sa_autopop;
6989 IF (autopop_config_cur%ROWCOUNT = 0) THEN
6990 g_ge_autopop := 'N';
6991 g_et_autopop := 'N';
6992 g_eg_autopop := 'N';
6993 g_as_autopop := 'N';
6994 g_ds_autopop := 'N';
6995 g_da_autopop := 'N';
6996 g_sa_autopop := 'N';
6997 END IF;
6998 CLOSE autopop_config_cur;
6999
7000 OPEN c_obtain_eff_date_option;
7001 FETCH c_obtain_eff_date_option INTO g_Eff_Date_Value;
7002 CLOSE c_obtain_eff_date_option;
7003
7004 OPEN payroll_id_cur;
7005 FETCH payroll_id_cur INTO l_payroll_id, l_process_mode;
7006 CLOSE payroll_id_cur;
7007 IF (l_payroll_id = -1) THEN
7008 l_payroll_id := NULL;
7009 END IF;
7010
7011 l_enc_create_lines := 1;
7012 l_enclines_index := 1;
7013 l_enc_create := 1;
7014 l_pre_process_mode:= 'R';
7015 g_currency_code := psp_general.get_currency_code(l_business_group_id);
7016 psp_general.get_currency_precision(g_currency_code,g_precision,g_ext_precision);
7017 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' g_enc_line_type: U
7018 g_request_id: ' || g_request_id || '
7019 g_payroll_action_id: ' || g_payroll_action_id || '
7020 g_currency_code: ' || g_currency_code || '
7021 g_ge_autopop: ' || g_ge_autopop || ' g_et_autopop: ' || g_et_autopop ||
7022 ' g_eg_autopop: ' || g_eg_autopop || ' g_as_autopop: ' || g_as_autopop ||
7023 ' g_ds_autopop: ' || g_ds_autopop || ' g_da_autopop: ' || g_da_autopop ||
7024 ' g_sa_autopop: ' || g_sa_autopop);
7025
7026 OPEN c_obtain_eff_date_option;
7027 FETCH c_obtain_eff_date_option INTO g_eff_date_value;
7028 CLOSE c_obtain_eff_date_option;
7029
7030 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' g_eff_date_value: ' || g_eff_date_value);
7031
7032 obtain_enc_org_end_date(p_enc_org_end_date => l_enc_org_end_date,
7033 p_business_group_id => l_business_group_id,
7034 p_set_of_books_id => l_set_of_books_id,
7035 p_return_status => l_return_status);
7036 IF l_return_status <> fnd_api.g_ret_sts_success THEN
7037 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7038 END IF;
7039 g_enc_org_end_date := l_enc_org_end_date ;
7040 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' g_enc_org_end_date: ' || fnd_date.date_to_canonical(g_enc_org_end_date));
7041
7042 OPEN get_asg_id_cur;
7043 FETCH get_asg_id_cur INTO l_min_asg_id, l_max_asg_id;
7044 CLOSE get_asg_id_cur;
7045 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_min_asg_id: ' || l_min_asg_id || ' l_max_asg_id: ' || l_max_asg_id);
7046
7047 OPEN get_payroll_asg_cur;
7048 FETCH get_payroll_asg_cur BULK COLLECT INTO t_assignments.payroll_array, t_assignments.asg_array, t_assignments.term_date_array;
7049 CLOSE get_payroll_asg_cur;
7050
7051 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' t_assignments.asg_array.COUNT: ' || t_assignments.asg_array.COUNT);
7052 FOR recno IN 1 ..t_assignments.asg_array.COUNT
7053 LOOP
7054 l_assignment_id := t_assignments.asg_array(recno);
7055 l_payroll_id := t_assignments.payroll_array(recno);
7056 g_enc_lines_counter := 1;
7057 g_actual_term_date := t_assignments.term_date_array(recno);
7058 -- l_enc_begin_date := NULL;
7059
7060 OPEN liq_only_asg_cur;
7061 FETCH liq_only_asg_cur INTO l_liq_only_count;
7062 CLOSE liq_only_asg_cur;
7063
7064 OPEN liq_all_cur;
7065 FETCH liq_all_cur INTO l_liq_all_count;
7066 CLOSE liq_all_cur;
7067
7068 IF ((l_liq_all_count =0) AND (l_liq_only_count > 0)) THEN
7069 delete_previous_error_log(p_assignment_id => l_assignment_id,
7070 p_payroll_id => l_payroll_id,
7071 p_payroll_action_id => p_payroll_action_id);
7072
7073 /* commented for bug 5581265: Need to consider date earn at each assignment level instead of payroll */
7074 -- IF ((recno = 1) OR (l_payroll_id <> t_assignments.payroll_array(recno-1))) THEN
7075 l_enc_begin_date := NULL;
7076
7077 OPEN c_last_pay_run(t_assignments.asg_array(recno));
7078 FETCH c_last_pay_run INTO l_enc_begin_date;
7079 CLOSE c_last_pay_run;
7080
7081 IF l_enc_begin_date IS NULL THEN
7082 OPEN c_tp_start_date;
7083 FETCH c_tp_start_date INTO l_enc_begin_date;
7084 CLOSE c_tp_start_date;
7085 END IF;
7086 -- END IF;
7087
7088 OPEN earnings_element_cur(l_assignment_id);
7089 LOOP
7090 FETCH earnings_element_cur INTO l_element_type_id, g_dr_cr_flag;
7091 EXIT WHEN earnings_element_cur%NOTFOUND ;
7092
7093 OPEN money_value_cur(l_element_type_id);
7094 FETCH money_value_cur INTO l_money_value;
7095 CLOSE money_value_cur;
7096
7097 IF (l_money_value > 0) THEN
7098 g_uom := 'M';
7099
7100 OPEN c_max_enc_date(l_assignment_id, l_element_type_id, l_enc_begin_date);
7101 FETCH c_max_enc_date INTO l_enc_create, l_max_enc_hist_date;
7102 CLOSE c_max_enc_date;
7103
7104 OPEN c_max_enc_lines_date(l_assignment_id, l_element_type_id, l_enc_begin_date);
7105 FETCH c_max_enc_lines_date INTO l_enc_create_lines, l_max_enc_lines_date;
7106 CLOSE c_max_enc_lines_date;
7107
7108 l_max_enc_date := GREATEST(l_max_enc_lines_date, l_max_enc_hist_date);
7109
7110 IF l_enc_create = 0 AND l_enc_create_lines = 0 THEN
7111 l_enc_create :=1;
7112 END IF;
7113 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' g_actual_term_date: ' || fnd_date.date_to_canonical(g_actual_term_date) || '
7114 l_max_enc_date: ' || fnd_date.date_to_canonical(l_max_enc_date) || '
7115 l_enc_create: ' || l_enc_create);
7116
7117 IF l_enc_create > 0 THEN
7118 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' p_chunk_number: ' || p_chunk_number || '
7119 p_assignment_id => ' || l_assignment_id || '
7120 p_payroll_id => ' || l_payroll_id || '
7121 p_element_type_id => ' || l_element_type_id || '
7122 p_business_group_id => ' || l_business_group_id || '
7123 p_set_of_books_id => ' || l_set_of_books_id || '
7124 p_last_paid_date => ' || l_enc_begin_date || '
7125 p_max_enc_date => ' || l_max_enc_date);
7126 create_lines( p_assignment_id => l_assignment_id,
7127 p_payroll_id => l_payroll_id,
7128 p_element_type_id => l_element_type_id,
7129 -- p_business_group_id => l_business_group_id,
7130 -- p_set_of_books_id => l_set_of_books_id,
7131 p_last_paid_date => l_enc_begin_date,
7132 -- p_max_enc_date => l_max_enc_date,
7133 p_return_status => l_return_status);
7134 IF l_return_status <> fnd_api.g_ret_sts_success THEN
7135 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7136 END IF;
7137 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Completed create_lines for l_assignment_id: ' || l_assignment_id || ' payroll_id: ' || l_payroll_id || ' element_type_id: ' || l_element_type_id);
7138 log_cel_warnings;
7139 END IF;
7140 END IF;
7141 IF (g_employee_hours = 'Y') THEN
7142 OPEN hours_value_cur(l_element_type_id);
7143 FETCH hours_value_cur INTO l_hours_value;
7144 CLOSE hours_value_cur;
7145
7146 IF (l_hours_value > 0) THEN
7147 g_uom := 'H';
7148 psp_general.get_currency_precision('STAT',g_precision,g_ext_precision);
7149 OPEN c_max_enc_date(l_assignment_id, l_element_type_id, l_enc_begin_date);
7150 FETCH c_max_enc_date INTO l_enc_create, l_max_enc_hist_date;
7151 CLOSE c_max_enc_date;
7152
7153 OPEN c_max_enc_lines_date(l_assignment_id, l_element_type_id, l_enc_begin_date);
7154 FETCH c_max_enc_lines_date INTO l_enc_create_lines, l_max_enc_lines_date;
7155 CLOSE c_max_enc_lines_date;
7156
7157 l_max_enc_date := GREATEST(l_max_enc_lines_date, l_max_enc_hist_date);
7158
7159 IF l_enc_create = 0 AND l_enc_create_lines = 0 THEN
7160 l_enc_create :=1;
7161 END IF;
7162 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' g_actual_term_date: ' || fnd_date.date_to_canonical(g_actual_term_date) || '
7163 l_max_enc_date: ' || fnd_date.date_to_canonical(l_max_enc_date) || '
7164 l_enc_create: ' || l_enc_create);
7165
7166 IF l_enc_create > 0 THEN
7167 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' p_chunk_number: ' || p_chunk_number || '
7168 p_assignment_id => ' || l_assignment_id || '
7169 p_payroll_id => ' || l_payroll_id || '
7170 p_element_type_id => ' || l_element_type_id || '
7171 p_business_group_id => ' || l_business_group_id || '
7172 p_set_of_books_id => ' || l_set_of_books_id || '
7173 p_last_paid_date => ' || l_enc_begin_date || '
7174 p_max_enc_date => ' || l_max_enc_date);
7175 create_lines( p_assignment_id => l_assignment_id,
7176 p_payroll_id => l_payroll_id,
7177 p_element_type_id => l_element_type_id,
7178 -- p_business_group_id => l_business_group_id,
7179 -- p_set_of_books_id => l_set_of_books_id,
7180 p_last_paid_date => l_enc_begin_date,
7181 -- p_max_enc_date => l_max_enc_date,
7182 p_return_status => l_return_status);
7183 IF l_return_status <> fnd_api.g_ret_sts_success THEN
7184 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7185 END IF;
7186 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Completed create_lines for l_assignment_id: ' || l_assignment_id || ' payroll_id: ' || l_payroll_id || ' element_type_id: ' || l_element_type_id);
7187 log_cel_warnings;
7188 END IF;
7189 END IF;
7190 END IF;
7191
7192 END LOOP;
7193
7194 IF (earnings_element_cur%ROWCOUNT = 0) THEN
7195 fnd_file.put_line(fnd_file.log, 'No element found for encumbrance.');
7196 END IF;
7197 CLOSE earnings_element_cur;
7198
7199 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' t_enc_lines_array.r_enc_element_type_id.COUNT: ' || t_enc_lines_array.r_enc_element_type_id.COUNT);
7200 verify_changes(p_payroll_id => l_payroll_id,
7201 p_assignment_id => l_assignment_id,
7202 p_business_group_id => l_business_group_id,
7203 p_set_of_books_id => l_set_of_books_id,
7204 p_enc_line_type => 'U',
7205 l_retcode => l_return_status);
7206
7207 IF l_return_status <> fnd_api.g_ret_sts_success THEN
7208 RAISE fnd_api.g_exc_unexpected_error;
7209 END IF;
7210 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Completed verify_changes for l_assignment_id: ' || l_assignment_id || ' payroll_id: ' || l_payroll_id);
7211 ELSE
7212 IF (l_liq_all_count > 0) THEN
7213 UPDATE psp_enc_lines_history pelh
7214 SET change_flag = 'N'
7215 WHERE assignment_id = l_assignment_id
7216 AND payroll_id = l_payroll_id
7217 AND change_flag = 'U'
7218 AND EXISTS (SELECT 1
7219 FROM psp_enc_summary_lines pesl
7220 WHERE pesl.assignment_id = l_assignment_id
7221 AND pesl.payroll_id = l_payroll_id
7222 AND status_code = 'A'
7223 AND pesl.enc_summary_line_id = pelh.enc_summary_line_id);
7224 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Updated lines to be liquidated');
7225 DELETE psp_enc_changed_assignments
7226 WHERE assignment_id = l_assignment_id
7227 AND payroll_id = l_payroll_id
7228 AND change_type = 'ZZ';
7229 ELSE
7230 UPDATE psp_enc_lines_history pelh
7231 SET change_flag = 'N'
7232 WHERE assignment_id = l_assignment_id
7233 AND payroll_id = l_payroll_id
7234 AND change_flag = 'U'
7235 AND EXISTS (SELECT 1
7236 FROM psp_enc_summary_lines pesl
7237 WHERE pesl.assignment_id = l_assignment_id
7238 AND pesl.payroll_id = l_payroll_id
7239 AND status_code = 'A'
7240 AND pesl.enc_summary_line_id = pelh.enc_summary_line_id
7241 AND pesl.effective_date <= (NVL((SELECT MAX (ptp.end_date)--MAX(ppa.date_earned): Bug 5642002: Replaced earned date with period end date
7242 FROM pay_payroll_actions ppa,
7243 pay_assignment_actions paa,
7244 per_time_periods ptp
7245 WHERE ppa.payroll_action_id = paa.payroll_action_id (+)
7246 AND ppa.payroll_id = l_payroll_id
7247 AND ppa.action_type IN( 'R','Q')
7248 AND NVL(paa.action_status, ppa.action_status) = 'C'
7249 and ppa.date_earned between ptp.start_date and ptp.end_date
7250 and ptp.payroll_id = ppa.payroll_id),l_enc_begin_date)) );
7251
7252 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Updated lines to be liquidated by regular liquidation');
7253 UPDATE psp_enc_lines_history pelh
7254 SET change_flag = 'U'
7255 WHERE assignment_id = l_assignment_id
7256 AND payroll_id = l_payroll_id
7257 AND change_flag = 'N'
7258 AND EXISTS (SELECT 1
7259 FROM psp_enc_summary_lines pesl
7260 WHERE pesl.assignment_id = l_assignment_id
7261 AND pesl.payroll_id = l_payroll_id
7262 AND status_code = 'A'
7263 AND pesl.enc_summary_line_id = pelh.enc_summary_line_id
7264 AND pesl.effective_date > (NVL((SELECT MAX (ptp.end_date)--MAX(ppa.date_earned): Bug 5642002: Replaced earned date with period end date
7265 FROM pay_payroll_actions ppa,
7266 pay_assignment_actions paa,
7267 per_time_periods ptp
7268 WHERE ppa.payroll_action_id = paa.payroll_action_id (+)
7269 AND ppa.payroll_id = l_payroll_id
7270 AND ppa.action_type IN( 'R','Q')
7271 AND NVL(paa.action_status, ppa.action_status) = 'C'
7272 and ppa.date_earned between ptp.start_date and ptp.end_date
7273 and ptp.payroll_id = ppa.payroll_id),l_enc_begin_date)) );
7274
7275 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Updated lines not to be liquidated by regular liquidation');
7276 END IF;
7277 END IF;
7278
7279 create_liq_lines (p_payroll_action_id => p_payroll_action_id,
7280 p_payroll_id => l_payroll_id,
7281 p_assignment_id => l_assignment_id,
7282 p_enc_begin_date => l_enc_begin_date,
7283 p_business_group_id => l_business_group_id,
7284 p_set_of_books_id => l_set_of_books_id,
7285 p_return_status => l_return_status);
7286
7287 IF l_return_status <> fnd_api.g_ret_sts_success THEN
7288 RAISE fnd_api.g_exc_unexpected_error;
7289 END IF;
7290 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Completed create_liq_lines for l_assignment_id: ' || l_assignment_id || ' payroll_id: ' || l_payroll_id);
7291
7292 create_sum_lines (p_payroll_action_id => p_payroll_action_id,
7293 p_payroll_id => l_payroll_id,
7294 p_assignment_id => l_assignment_id,
7295 p_business_group_id => l_business_group_id,
7296 p_set_of_books_id => l_set_of_books_id,
7297 p_return_status => l_return_status);
7298
7299 IF l_return_status <> fnd_api.g_ret_sts_success THEN
7300 RAISE fnd_api.g_exc_unexpected_error;
7301 END IF;
7302 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Completed create_sum_lines for l_assignment_id: ' || l_assignment_id || ' payroll_id: ' || l_payroll_id);
7303
7304 update_hierarchy_dates (p_payroll_action_id => p_payroll_action_id,
7305 p_payroll_id => l_payroll_id,
7306 p_assignment_id => l_assignment_id,
7307 p_return_status => l_return_status);
7308
7309 IF l_return_status <> fnd_api.g_ret_sts_success THEN
7310 RAISE fnd_api.g_exc_unexpected_error;
7311 END IF;
7312 END LOOP;
7313
7314 FORALL recno IN 1..t_assignments.asg_array.COUNT
7315 UPDATE psp_enc_process_assignments pepa
7316 SET assignment_status = 'B'
7317 WHERE pepa.payroll_action_id = p_payroll_action_id
7318 AND pepa.assignment_id = t_assignments.asg_array(recno)
7319 AND pepa.payroll_id = t_assignments.payroll_array(recno)
7320 AND NOT EXISTS (SELECT 1
7321 FROM psp_enc_summary_lines pesl
7322 WHERE pesl.payroll_action_id = p_payroll_action_id
7323 AND pesl.assignment_id = t_assignments.asg_array(recno)
7324 AND pesl.payroll_id = t_assignments.payroll_array(recno));
7325
7326 FORALL recno IN 1..t_assignments.asg_array.COUNT
7327 UPDATE psp_enc_process_assignments pepa
7328 SET assignment_status = 'S'
7329 WHERE pepa.payroll_action_id = p_payroll_action_id
7330 AND pepa.assignment_id = t_assignments.asg_array(recno)
7331 AND pepa.payroll_id = t_assignments.payroll_array(recno)
7332 AND EXISTS (SELECT 1
7333 FROM psp_enc_summary_lines pesl
7334 WHERE pesl.payroll_action_id = p_payroll_action_id
7335 AND pesl.assignment_id = t_assignments.asg_array(recno)
7336 AND pesl.payroll_id = t_assignments.payroll_array(recno));
7337
7338 FORALL recno IN 1..t_assignments.asg_array.COUNT
7339 UPDATE psp_enc_process_assignments pepa
7340 SET assignment_status = 'L'
7341 WHERE pepa.payroll_action_id = p_payroll_action_id
7342 AND pepa.assignment_id = t_assignments.asg_array(recno)
7343 AND pepa.payroll_id = t_assignments.payroll_array(recno)
7344 AND EXISTS (SELECT 1
7345 FROM psp_enc_summary_lines pesl
7346 WHERE pesl.payroll_action_id = p_payroll_action_id
7347 AND pesl.superceded_line_id IS NOT NULL
7348 AND pesl.assignment_id = t_assignments.asg_array(recno)
7349 AND pesl.payroll_id = t_assignments.payroll_array(recno));
7350
7351 t_assignments.payroll_array.delete;
7352 t_assignments.asg_array.delete;
7353
7354 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving CEL_ARCHIVE (payroll_action_id: ' || p_payroll_action_id || ' chunk_number: ' || p_chunk_number ||')');
7355 EXCEPTION
7356 WHEN OTHERS THEN
7357 log_cel_warnings;
7358 IF (g_error_message IS NOT NULL) THEN
7359 IF (l_assignment_id IS NOT NULL) THEN
7360 OPEN asg_number_cur(l_enc_begin_date);
7361 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
7362 CLOSE asg_number_cur;
7363
7364 OPEN payroll_name_cur;
7365 FETCH payroll_name_cur INTO l_payroll_name;
7366 CLOSE payroll_name_cur;
7367
7368 OPEN person_name_cur(l_enc_begin_date);
7369 FETCH person_name_cur INTO l_full_name;
7370 CLOSE person_name_cur;
7371
7372 OPEN org_name_cur;
7373 FETCH org_name_cur INTO l_organization_name;
7374 CLOSE org_name_cur;
7375
7376 OPEN element_name_cur;
7377 FETCH element_name_cur INTO l_element_name;
7378 CLOSE element_name_cur;
7379
7380 psp_general.add_report_error
7381 (p_request_id => g_request_id,
7382 p_message_level => 'E',
7383 p_source_id => l_assignment_id,
7384 p_source_name => l_assignment_number,
7385 p_parent_source_id => l_person_id,
7386 p_parent_source_name => l_full_name,
7387 p_error_message => g_error_message,
7388 p_payroll_action_id => p_payroll_action_id,
7389 p_value1 => l_payroll_id,
7390 p_information1 => l_payroll_name,
7391 p_value2 => l_organization_id,
7392 p_information2 => l_organization_name,
7393 p_value3 => l_element_type_id,
7394 p_information3 => l_element_name,
7395 p_return_status => l_return_status);
7396 ELSE
7397 psp_general.add_report_error
7398 (p_request_id => g_request_id,
7399 p_message_level => 'E',
7400 p_source_id => NULL,
7401 p_source_name => NULL,
7402 p_parent_source_id => NULL,
7403 p_parent_source_name => NULL,
7404 p_error_message => g_error_message,
7405 p_payroll_action_id => p_payroll_action_id,
7406 p_value1 => NULL,
7407 p_information1 => NULL,
7408 p_return_status => l_return_status);
7409 END IF;
7410 END IF;
7411 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'CEL_ARCHIVE: SQLCODE: ' || fnd_number.number_to_canonical(SQLCODE) || ' SQLERRM: ' || SQLERRM);
7412 psp_message_s.print_error(p_mode => FND_FILE.LOG, p_print_header => FND_API.G_TRUE);
7413 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving CEL_ARCHIVE (payroll_action_id: ' || p_payroll_action_id || ' chunk_number: ' || p_chunk_number ||')');
7414 ROLLBACK TO CEL_ARCHIVE;
7415 RAISE;
7416 END cel_archive;
7417
7418 procedure cel_deinit(p_payroll_action_id in number) IS
7419 PRAGMA AUTONOMOUS_TRANSACTION;
7420 l_last_update_date DATE;
7421 l_last_updated_by NUMBER;
7422 l_request_id NUMBER(15);
7423 l_business_group_id NUMBER(15);
7424 l_set_of_books_id NUMBER(15);
7425 l_error_count NUMBER;
7426 l_process_mode VARCHAR2(30);
7427 l_process_phase VARCHAR2(30);
7428 call_status BOOLEAN;
7429 rphase VARCHAR2(30);
7430 rstatus VARCHAR2(30);
7431 dphase VARCHAR2(30);
7432 dstatus VARCHAR2(30);
7433 message VARCHAR2(240);
7434 l_xml_layout BOOLEAN;
7435 l_st_count NUMBER(15);
7436
7437 CURSOR payroll_id_cur IS
7438 SELECT argument12
7439 FROM fnd_concurrent_requests fcr,
7440 psp_enc_processes pep
7441 WHERE pep.payroll_action_id = p_payroll_action_id
7442 AND fcr.request_id = pep.request_id;
7443
7444 CURSOR process_phase_cur IS
7445 SELECT process_phase
7446 FROM psp_enc_processes
7447 WHERE payroll_action_id = p_payroll_action_id
7448 AND process_code = 'ST';
7449
7450 CURSOR error_check_cur IS
7451 SELECT COUNT(1)
7452 FROM psp_report_errors
7453 WHERE payroll_action_id = p_payroll_action_id
7454 AND request_id >= l_request_id
7455 AND message_level = 'E';
7456
7457 CURSOR st_count_cur Is
7458 SELECT COUNT(1)
7459 FROM psp_enc_summary_lines
7460 WHERE payroll_action_id = p_payroll_action_id
7461 AND status_code = 'N';
7462 BEGIN
7463 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Entering CEL_DEINIT payroll_action_id: ' || p_payroll_action_id);
7464 l_last_update_date := SYSDATE;
7465 l_last_updated_by:= NVL(FND_GLOBAL.USER_ID, -1);
7466 l_request_id := fnd_global.conc_request_id;
7467
7468 OPEN payroll_id_cur;
7469 FETCH payroll_id_cur INTO l_process_mode;
7470 CLOSE payroll_id_cur;
7471
7472 OPEN process_phase_cur;
7473 FETCH process_phase_cur INTO l_process_phase;
7474 CLOSE process_phase_cur;
7475 l_process_phase := NVL(l_process_phase, 'deinit');
7476
7477 IF NOT (l_process_mode = 'TERMINATE' AND l_process_phase = 'deinit_st') THEN
7478 OPEN error_check_cur;
7479 FETCH error_check_cur INTO l_error_count;
7480 CLOSE error_check_cur;
7481
7482 IF (l_error_count > 0) THEN
7483 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Create and Update Encumbrance process has errors. Please review the Run Results Report for more details.');
7484 l_business_group_id := fnd_profile.value('PER_BUSINESS_GROUP_ID');
7485 l_set_of_books_id := fnd_profile.value('GL_SET_OF_BKS_ID');
7486 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Before submitting Encumbrance Run Results Report');
7487 l_xml_layout := fnd_request.add_layout('PSP','PSPENRSRTF','en','US','PDF');
7488 l_request_id := fnd_request.submit_request('PSP',
7489 'PSPENRSLT',
7490 '',
7491 '',
7492 FALSE,
7493 TO_CHAR(p_payroll_action_id),
7494 TO_CHAR(fnd_global.conc_request_id),
7495 TO_CHAR(l_business_group_id),
7496 TO_CHAR(l_set_of_books_id));
7497
7498 IF l_request_id = 0 THEN
7499 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Encumbrance Run Results Report submission failed');
7500 fnd_message.set_name('PSP','PSP_TR_GL_IMP_FAILED');
7501 fnd_msg_pub.add;
7502 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7503 END IF;
7504 COMMIT;
7505 RAISE fnd_api.g_exc_unexpected_error;
7506 END IF;
7507
7508 UPDATE psp_enc_process_assignments pepa
7509 SET assignment_status = 'B'
7510 WHERE payroll_action_id = p_payroll_action_id
7511 AND NOT EXISTS (SELECT 1
7512 FROM psp_enc_summary_lines pesl
7513 WHERE pesl.payroll_action_id = p_payroll_action_id
7514 AND pesl.assignment_id = pepa.assignment_id
7515 AND pesl.payroll_id = pepa.payroll_id
7516 AND pesl.status_code = 'N');
7517
7518 UPDATE psp_enc_process_assignments pepa
7519 SET assignment_status = 'S'
7520 WHERE payroll_action_id = p_payroll_action_id
7521 AND EXISTS (SELECT 1
7522 FROM psp_enc_summary_lines pesl
7523 WHERE pesl.payroll_action_id = p_payroll_action_id
7524 AND pesl.assignment_id = pepa.assignment_id
7525 AND pesl.payroll_id = pepa.payroll_id
7526 AND pesl.status_code = 'N'
7527 AND pesl.superceded_line_id IS NULL);
7528
7529 UPDATE psp_enc_process_assignments pepa
7530 SET assignment_status = 'L'
7531 WHERE payroll_action_id = p_payroll_action_id
7532 AND EXISTS (SELECT 1
7533 FROM psp_enc_summary_lines pesl
7534 WHERE pesl.payroll_action_id = p_payroll_action_id
7535 AND pesl.assignment_id = pepa.assignment_id
7536 AND pesl.payroll_id = pepa.payroll_id
7537 AND pesl.status_code = 'N'
7538 AND pesl.superceded_line_id IS NOT NULL);
7539
7540 fnd_stats.gather_table_stats('PSP', 'PSP_ENC_CONTROLS');
7541 fnd_stats.gather_table_stats('PSP', 'PSP_ENC_LINES');
7542 fnd_stats.gather_table_stats('PSP', 'PSP_ENC_SUMMARY_LINES');
7543 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Completed Gather Statistics');
7544
7545 DELETE FROM psp_enc_controls pec
7546 WHERE pec.payroll_action_id = p_payroll_action_id
7547 AND NOT EXISTS (SELECT 1
7548 FROM psp_enc_lines pel
7549 WHERE pel.enc_control_id = pec.enc_control_id);
7550 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted lines in psp_enc_controls which doesnt have a line in psp_enc_lines');
7551
7552 UPDATE psp_enc_controls pec
7553 SET (action_code,
7554 number_of_dr, number_of_cr,
7555 total_dr_amount, total_cr_amount,
7556 gl_dr_amount, gl_cr_amount,
7557 ogm_dr_amount, ogm_cr_amount) =
7558 (SELECT 'N',
7559 SUM(fnd_number.canonical_to_number(DECODE(pel.dr_cr_flag, 'D', 1, 0))), SUM(fnd_number.canonical_to_number(DECODE(pel.dr_cr_flag, 'C', 1, 0))),
7560 SUM(fnd_number.canonical_to_number(DECODE(pel.dr_cr_flag, 'D', pel.encumbrance_amount, 0))), SUM(fnd_number.canonical_to_number(DECODE(pel.dr_cr_flag, 'C', pel.encumbrance_amount, 0))),
7561 SUM(fnd_number.canonical_to_number(DECODE(pel.gl_project_flag, 'G', DECODE(pel.dr_cr_flag, 'D', pel.encumbrance_amount, 0), 0))),
7562 SUM(fnd_number.canonical_to_number(DECODE(pel.gl_project_flag, 'G', DECODE(pel.dr_cr_flag, 'C', pel.encumbrance_amount, 0), 0))),
7563 SUM(fnd_number.canonical_to_number(DECODE(pel.gl_project_flag, 'P', DECODE(pel.dr_cr_flag, 'D', pel.encumbrance_amount, 0), 0))),
7564 SUM(fnd_number.canonical_to_number(DECODE(pel.gl_project_flag, 'P', DECODE(pel.dr_cr_flag, 'C', pel.encumbrance_amount, 0), 0)))
7565 FROM psp_enc_lines pel
7566 WHERE pel.enc_control_id = pec.enc_control_id)
7567 WHERE payroll_action_id = p_payroll_action_id;
7568 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated summary columns in psp_enc_controls');
7569
7570 IF (l_process_mode = 'TERMINATE') THEN
7571 UPDATE psp_enc_changed_assignments peca
7572 SET payroll_action_id = p_payroll_action_id
7573 WHERE EXISTS (SELECT 1
7574 FROM psp_enc_changed_assignments peca2
7575 WHERE peca2.assignment_id = peca.assignment_id
7576 AND peca2.change_type = 'TR');
7577 END IF;
7578
7579 INSERT INTO psp_enc_changed_asg_history
7580 (request_id, assignment_id, payroll_id, change_type, processing_module, created_by,
7581 creation_date, processed_flag, reference_id, action_type, payroll_action_id, change_date)
7582 SELECT l_request_id, peca.assignment_id, peca.payroll_id, peca.change_type,
7583 'U', l_last_updated_by, l_last_update_date, NULL, NVL(peca.reference_id, 0),
7584 NVL(peca.action_type, 'U'), p_payroll_action_id, change_date
7585 FROM psp_enc_changed_assignments peca
7586 WHERE payroll_action_id = p_payroll_action_id;
7587 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Copied change assignment records to psp_enc_changed_asg_history');
7588
7589 DELETE psp_enc_changed_assignments peca
7590 WHERE peca.payroll_action_id = p_payroll_action_id;
7591 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted processed change assignment records in psp_enc_change_assignments');
7592
7593 UPDATE psp_enc_processes
7594 SET process_status = 'P'
7595 WHERE payroll_action_id = p_payroll_action_id;
7596 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process_status in psp_enc_processes');
7597
7598 UPDATE psp_enc_processes
7599 SET process_status = 'B',
7600 process_phase = 'no_summarize_transfer'
7601 WHERE payroll_action_id = p_payroll_action_id
7602 AND NOT EXISTS (SELECT 1
7603 FROM psp_enc_summary_lines pesl
7604 WHERE pesl.payroll_action_id = p_payroll_action_id
7605 AND pesl.status_code = 'N');
7606
7607 UPDATE psp_enc_processes
7608 SET process_phase = 'summarize_transfer'
7609 WHERE payroll_action_id = p_payroll_action_id
7610 AND EXISTS (SELECT 1
7611 FROM psp_enc_summary_lines pesl
7612 WHERE pesl.payroll_action_id = p_payroll_action_id
7613 AND pesl.status_code = 'N'
7614 AND pesl.superceded_line_id IS NULL);
7615
7616 UPDATE psp_enc_processes
7617 SET process_phase = 'liquidate'
7618 WHERE payroll_action_id = p_payroll_action_id
7619 AND EXISTS (SELECT 1
7620 FROM psp_enc_summary_lines pesl
7621 WHERE pesl.payroll_action_id = p_payroll_action_id
7622 AND pesl.status_code = 'N'
7623 AND pesl.superceded_line_id is NOT NULL);
7624 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process_phase in psp_enc_processes');
7625 END IF;
7626
7627 l_business_group_id := fnd_profile.value('PER_BUSINESS_GROUP_ID');
7628 l_set_of_books_id := fnd_profile.value('GL_SET_OF_BKS_ID');
7629 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Before submitting Encumbrance Run Results Report');
7630 l_xml_layout := fnd_request.add_layout('PSP','PSPENRSRTF','en','US','PDF');
7631 l_request_id := fnd_request.submit_request('PSP',
7632 'PSPENRSLT',
7633 '',
7634 '',
7635 FALSE,
7636 TO_CHAR(p_payroll_action_id),
7637 TO_CHAR(fnd_global.conc_request_id),
7638 TO_CHAR(l_business_group_id),
7639 TO_CHAR(l_set_of_books_id));
7640
7641 IF l_request_id = 0 THEN
7642 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Encumbrance Run Results Report submission failed');
7643 fnd_message.set_name('PSP','PSP_TR_GL_IMP_FAILED');
7644 fnd_msg_pub.add;
7645 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7646 END IF;
7647 COMMIT;
7648
7649 IF (l_process_mode = 'TERMINATE') THEN
7650 OPEN st_count_cur;
7651 FETCH st_count_cur INTO l_st_count;
7652 CLOSE st_count_cur;
7653
7654 IF (l_st_count > 0) THEN
7655 l_business_group_id := fnd_profile.value('PER_BUSINESS_GROUP_ID');
7656 l_set_of_books_id := fnd_profile.value('GL_SET_OF_BKS_ID');
7657
7658 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Before submitting Encumbrance Summarize and Transfer');
7659 l_request_id := fnd_request.submit_request('PSP',
7660 'PSPENSTR',
7661 '',
7662 '',
7663 FALSE,
7664 TO_CHAR(p_payroll_action_id),
7665 TO_CHAR(l_business_group_id),
7666 TO_CHAR(l_set_of_books_id));
7667
7668 IF l_request_id = 0 THEN
7669 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Encumbrance Summarize and Transfer submission failed');
7670 fnd_message.set_name('PSP','PSP_TR_GL_IMP_FAILED');
7671 fnd_msg_pub.add;
7672 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7673 END IF;
7674
7675 UPDATE psp_enc_processes
7676 SET process_phase = 'deinit_st'
7677 WHERE payroll_action_id = p_payroll_action_id
7678 AND process_code = 'ST';
7679 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process_phase in psp_enc_processes');
7680
7681 COMMIT;
7682
7683 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Waiting for Encumbrance Summarize and Transfer request to complete');
7684 call_status := fnd_concurrent.wait_for_request(l_request_id, 10, 0, rphase, rstatus, dphase, dstatus, message);
7685
7686 IF call_status = FALSE THEN
7687 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Encumbrance Summarize and Transfer failed');
7688 fnd_message.set_name('PSP','PSP_ENC_STR_FAILED');
7689 fnd_msg_pub.add;
7690 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7691 END IF;
7692 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Encumbrance Summarize and Transfer completed');
7693 ELSE
7694 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Encumbrance Summarize and Transfer not required as there arent any new summary lines');
7695 END IF;
7696 END IF;
7697
7698 COMMIT;
7699 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving CEL_DEINIT payroll_action_id: ' || p_payroll_action_id);
7700 END cel_deinit;
7701
7702 PROCEDURE verify_changes(p_payroll_id IN NUMBER,
7703 p_assignment_id IN NUMBER,
7704 p_business_group_id IN NUMBER,
7705 p_set_of_books_id IN NUMBER,
7706 p_enc_line_type IN VARCHAR2,
7707 l_retcode OUT NOCOPY VARCHAR2) IS
7708 TYPE time_period_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
7709 TYPE encumbrance_date_tl IS TABLE OF DATE INDEX BY BINARY_INTEGER;
7710 TYPE dr_cr_flag_tl IS TABLE OF VARCHAR2(1) INDEX BY BINARY_INTEGER;
7711 TYPE encumbrance_amount_tl IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
7712 TYPE gl_project_flag_tl IS TABLE OF VARCHAR2(15) INDEX BY BINARY_INTEGER;
7713 TYPE schedule_line_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
7714 TYPE org_schedule_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
7715 TYPE default_org_account_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
7716 TYPE suspense_org_account_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
7717 TYPE element_account_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
7718 TYPE project_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
7719 TYPE task_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
7720 TYPE award_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
7721 TYPE expenditure_type_tl IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;
7722 TYPE exp_organization_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
7723 TYPE gl_code_combination_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
7724 TYPE attribute_category_tl IS TABLE OF VARCHAR2(150) INDEX BY BINARY_INTEGER;
7725 TYPE attribute_tl IS TABLE OF VARCHAR2(150) INDEX BY BINARY_INTEGER;
7726 TYPE hierarchy_code_tl IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;
7727 TYPE enc_summary_line_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
7728 TYPE enc_element_type_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
7729
7730 l_time_period_id_tl time_period_id_tl;
7731 l_encumbrance_date_tl encumbrance_date_tl;
7732 l_dr_cr_flag_tl dr_cr_flag_tl;
7733 l_encumbrance_amount_tl encumbrance_amount_tl;
7734 l_gl_project_flag_tl gl_project_flag_tl;
7735 l_schedule_line_id_tl schedule_line_id_tl;
7736 l_org_schedule_id_tl org_schedule_id_tl;
7737 l_default_org_account_id_tl default_org_account_id_tl;
7738 l_suspense_org_account_id_tl suspense_org_account_id_tl;
7739 l_element_account_id_tl element_account_id_tl;
7740 l_project_id_tl project_id_tl;
7741 l_task_id_tl task_id_tl;
7742 l_award_id_tl award_id_tl;
7743 l_expenditure_type_tl expenditure_type_tl;
7744 l_exp_organization_id_tl exp_organization_id_tl;
7745 l_gl_code_combination_id_tl gl_code_combination_id_tl;
7746 l_attribute_category_tl attribute_category_tl;
7747 l_attribute1_tl attribute_tl;
7748 l_attribute2_tl attribute_tl;
7749 l_attribute3_tl attribute_tl;
7750 l_attribute4_tl attribute_tl;
7751 l_attribute5_tl attribute_tl;
7752 l_attribute6_tl attribute_tl;
7753 l_attribute7_tl attribute_tl;
7754 l_attribute8_tl attribute_tl;
7755 l_attribute9_tl attribute_tl;
7756 l_attribute10_tl attribute_tl;
7757 l_default_reason_tl attribute_tl;
7758 l_suspense_reason_tl attribute_tl;
7759 l_hierarchy_code_tl hierarchy_code_tl;
7760 l_enc_summary_line_id_tl enc_summary_line_id_tl;
7761 l_enc_element_type_id_tl enc_element_type_id_tl;
7762
7763 CURSOR enc_lines_history_cur IS
7764 SELECT DISTINCT pelh.time_period_id ,
7765 pelh.encumbrance_date ,
7766 pelh.dr_cr_flag,
7767 pelh.encumbrance_amount ,
7768 pelh.gl_project_flag,
7769 pelh.enc_element_type_id,
7770 NVL(pelh.schedule_line_id,-99) ,
7771 NVL(pelh.org_schedule_id, -99) ,
7772 NVL(pelh.default_org_account_id, -99),
7773 NVL(pelh.suspense_org_account_id, -99),
7774 NVL(pelh.element_account_id, -99) ,
7775 NVL(pelh.project_id, -99),
7776 NVL(pelh.task_id, -99) ,
7777 NVL(pelh.award_id, -99),
7778 NVL(pelh.expenditure_type, '-99') ,
7779 NVL(pelh.expenditure_organization_id, -99) ,
7780 NVL(pelh.gl_code_combination_id, -99),
7781 NVL(pelh.attribute_category,'NULL_VALUE'),
7782 NVL(pelh.attribute1, 'NULL_VALUE'),
7783 NVL(pelh.attribute2, 'NULL_VALUE'),
7784 NVL(pelh.attribute3, 'NULL_VALUE'),
7785 NVL(pelh.attribute4, 'NULL_VALUE'),
7786 NVL(pelh.attribute5, 'NULL_VALUE'),
7787 NVL(pelh.attribute6, 'NULL_VALUE'),
7788 NVL(pelh.attribute7, 'NULL_VALUE'),
7789 NVL(pelh.attribute8, 'NULL_VALUE'),
7790 NVL(pelh.attribute9, 'NULL_VALUE'),
7791 NVL(pelh.attribute10, 'NULL_VALUE'),
7792 NVL(pelh.default_reason_code, 'NULL'),
7793 NVL(pelh.suspense_reason_code, 'NULL'),
7794 hierarchy_code
7795 FROM psp_enc_lines_history pelh
7796 WHERE pelh.change_flag = 'U'
7797 AND payroll_id = p_payroll_id
7798 AND assignment_id = p_assignment_id;
7799
7800 CURSOR modified_summary_lines_cur IS
7801 SELECT DISTINCT enc_summary_line_id
7802 FROM psp_enc_lines_history
7803 WHERE change_flag = 'N'
7804 AND payroll_id = p_payroll_id
7805 AND assignment_id = p_assignment_id;
7806
7807 l_enc_lines_no NUMBER(15);
7808 l_delete_flag CHAR(1);
7809 l_return_status VARCHAR2(1);
7810 BEGIN
7811 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering verify_changes
7812 p_payroll_id: ' || p_payroll_id || ' p_assignment_id: ' || p_assignment_id || '
7813 p_business_group_id: ' || p_business_group_id || ' p_set_of_books_id: ' || p_set_of_books_id || '
7814 p_enc_line_type: ' || p_enc_line_type);
7815
7816 UPDATE psp_enc_lines_history
7817 SET change_flag = 'N'
7818 WHERE assignment_id = p_assignment_id
7819 AND payroll_id = p_payroll_id
7820 AND change_flag = 'U'
7821 AND status_code = 'A';
7822
7823 IF (g_dff_grouping_option = 'N') THEN
7824 FORALL recno IN 1 .. t_enc_lines_array.r_time_period_id.COUNT
7825 UPDATE psp_enc_lines_history pelh
7826 SET change_flag='U'
7827 WHERE time_period_id = t_enc_lines_array.r_time_period_id(recno)
7828 AND change_flag = 'N'
7829 AND pelh.encumbrance_date = t_enc_lines_array.r_encumbrance_date(recno)
7830 AND pelh.enc_element_type_id = t_enc_lines_array.r_enc_element_type_id(recno)
7831 AND pelh.dr_cr_flag = t_enc_lines_array.r_dr_cr_flag(recno)
7832 AND pelh.encumbrance_amount = ROUND( t_enc_lines_array.r_encumbrance_amount(recno),g_precision)
7833 AND pelh.gl_project_flag = t_enc_lines_array.r_gl_project_flag(recno)
7834 AND pelh.hierarchy_code = t_enc_lines_array.r_hierarchy_code(recno)
7835 AND NVL(pelh.project_id, -99) = NVL(t_enc_lines_array.r_project_id(recno), -99)
7836 AND NVL(pelh.task_id, -99) = NVL(t_enc_lines_array.r_task_id(recno), -99)
7837 AND NVL(pelh.award_id, -99) = NVL(t_enc_lines_array.r_award_id(recno), -99)
7838 AND NVL(pelh.expenditure_type, '-99') = NVL(t_enc_lines_array.r_expenditure_type(recno), '-99')
7839 AND NVL(pelh.expenditure_organization_id, -99) = NVL(t_enc_lines_array.r_expenditure_organization_id(recno), -99)
7840 AND NVL(pelh.gl_code_combination_id, -99) = NVL(t_enc_lines_array.r_gl_code_combination_id(recno), -99)
7841 AND NVL(suspense_reason_code, 'NULL') = NVL(t_enc_lines_array.r_suspense_reason_code(recno), 'NULL')
7842 AND NVL(default_reason_code, 'NULL') = NVL(t_enc_lines_array.r_default_reason_code(recno), 'NULL')
7843 AND pelh.assignment_id = p_assignment_id
7844 AND pelh.payroll_id = p_payroll_id;
7845 ELSE
7846 FORALL recno IN 1 .. t_enc_lines_array.r_time_period_id.COUNT
7847 UPDATE psp_enc_lines_history pelh
7848 SET change_flag='U'
7849 WHERE time_period_id = t_enc_lines_array.r_time_period_id(recno)
7850 AND change_flag = 'N'
7851 AND pelh.encumbrance_date = t_enc_lines_array.r_encumbrance_date(recno)
7852 AND pelh.enc_element_type_id = t_enc_lines_array.r_enc_element_type_id(recno)
7853 AND pelh.dr_cr_flag = t_enc_lines_array.r_dr_cr_flag(recno)
7854 AND pelh.encumbrance_amount = ROUND( t_enc_lines_array.r_encumbrance_amount(recno),g_precision)
7855 AND pelh.gl_project_flag = t_enc_lines_array.r_gl_project_flag(recno)
7856 AND pelh.hierarchy_code = t_enc_lines_array.r_hierarchy_code(recno)
7857 AND NVL(pelh.project_id, -99) = NVL(t_enc_lines_array.r_project_id(recno), -99)
7858 AND NVL(pelh.task_id, -99) = NVL(t_enc_lines_array.r_task_id(recno), -99)
7859 AND NVL(pelh.award_id, -99) = NVL(t_enc_lines_array.r_award_id(recno), -99)
7860 AND NVL(pelh.expenditure_type, '-99') = NVL(t_enc_lines_array.r_expenditure_type(recno), '-99')
7861 AND NVL(pelh.expenditure_organization_id, -99) = NVL(t_enc_lines_array.r_expenditure_organization_id(recno), -99)
7862 AND NVL(pelh.gl_code_combination_id, -99) = NVL(t_enc_lines_array.r_gl_code_combination_id(recno), -99)
7863 AND NVL(suspense_reason_code, 'NULL') = NVL(t_enc_lines_array.r_suspense_reason_code(recno), 'NULL')
7864 AND NVL(default_reason_code, 'NULL') = NVL(t_enc_lines_array.r_default_reason_code(recno), 'NULL')
7865 AND pelh.assignment_id = p_assignment_id
7866 AND pelh.payroll_id = p_payroll_id
7867 AND NVL(pelh.attribute_category, 'NULL_VALUE') = t_enc_lines_array.r_attribute_category(recno)
7868 AND NVL(pelh.attribute1, 'NULL_VALUE') = t_enc_lines_array.r_attribute1(recno)
7869 AND NVL(pelh.attribute2, 'NULL_VALUE') = t_enc_lines_array.r_attribute2(recno)
7870 AND NVL(pelh.attribute3, 'NULL_VALUE') = t_enc_lines_array.r_attribute3(recno)
7871 AND NVL(pelh.attribute4, 'NULL_VALUE') = t_enc_lines_array.r_attribute4(recno)
7872 AND NVL(pelh.attribute5, 'NULL_VALUE') = t_enc_lines_array.r_attribute5(recno)
7873 AND NVL(pelh.attribute6, 'NULL_VALUE') = t_enc_lines_array.r_attribute6(recno)
7874 AND NVL(pelh.attribute7, 'NULL_VALUE') = t_enc_lines_array.r_attribute7(recno)
7875 AND NVL(pelh.attribute8, 'NULL_VALUE') = t_enc_lines_array.r_attribute8(recno)
7876 AND NVL(pelh.attribute9, 'NULL_VALUE') = t_enc_lines_array.r_attribute9(recno)
7877 AND NVL(pelh.attribute10, 'NULL_VALUE') = t_enc_lines_array.r_attribute10(recno);
7878 END IF;
7879
7880 OPEN modified_summary_lines_cur;
7881 FETCH modified_summary_lines_cur BULK COLLECT INTO l_enc_summary_line_id_tl;
7882 CLOSE modified_summary_lines_cur;
7883
7884 hr_utility.trace('l_enc_summary_line_id_tl.COUNT: ' || l_enc_summary_line_id_tl.COUNT);
7885
7886 FORALL recno IN 1..l_enc_summary_line_id_tl.COUNT
7887 UPDATE psp_enc_lines_history pelh
7888 SET change_flag='N'
7889 WHERE enc_summary_line_id = l_enc_summary_line_id_tl(recno)
7890 AND change_flag='U';
7891
7892 l_enc_summary_line_id_tl.DELETE;
7893
7894 OPEN enc_lines_history_cur;
7895 FETCH enc_lines_history_cur BULK COLLECT INTO
7896 l_time_period_id_tl,l_encumbrance_date_tl,l_dr_cr_flag_tl,l_encumbrance_amount_tl,
7897 l_gl_project_flag_tl,l_enc_element_type_id_tl,l_schedule_line_id_tl,l_org_schedule_id_tl,
7898 l_default_org_account_id_tl,l_suspense_org_account_id_tl,l_element_account_id_tl,
7899 l_project_id_tl,l_task_id_tl,l_award_id_tl,l_expenditure_type_tl,l_exp_organization_id_tl,
7900 l_gl_code_combination_id_tl, l_attribute_category_tl,
7901 l_attribute1_tl,l_attribute2_tl,l_attribute3_tl,l_attribute4_tl,l_attribute5_tl,
7902 l_attribute6_tl,l_attribute7_tl,l_attribute8_tl,l_attribute9_tl,l_attribute10_tl,
7903 l_default_reason_tl, l_suspense_reason_tl, l_hierarchy_code_tl;
7904 CLOSE enc_lines_history_cur;
7905
7906 l_enc_lines_no := 1;
7907 IF (g_dff_grouping_option = 'N') THEN
7908 FOR recno1 IN 1..t_enc_lines_array.r_time_period_id.COUNT
7909 LOOP
7910 l_delete_flag := 'N';
7911 FOR recno2 IN 1 .. l_time_period_id_tl.COUNT
7912 LOOP
7913 IF (t_enc_lines_array.r_time_period_id(recno1) = l_time_period_id_tl(recno2)
7914 AND t_enc_lines_array.r_encumbrance_date(recno1) = l_encumbrance_date_tl(recno2)
7915 AND t_enc_lines_array.r_dr_cr_flag(recno1) = l_dr_cr_flag_tl(recno2)
7916 AND ROUND(t_enc_lines_array.r_encumbrance_amount(recno1), g_precision) = l_encumbrance_amount_tl(recno2)
7917 AND t_enc_lines_array.r_gl_project_flag(recno1) = l_gl_project_flag_tl(recno2)
7918 AND t_enc_lines_array.r_enc_element_type_id(recno1) = l_enc_element_type_id_tl(recno2)
7919 AND t_enc_lines_array.r_hierarchy_code(recno1) = l_hierarchy_code_tl(recno2)
7920 AND NVL(t_enc_lines_array.r_default_reason_code(recno1), 'NULL') = NVL(l_default_reason_tl(recno2), 'NULL')
7921 AND NVL(t_enc_lines_array.r_suspense_reason_code(recno1), 'NULL') = NVL(l_suspense_reason_tl(recno2), 'NULL')
7922 AND NVL(t_enc_lines_array.r_project_id(recno1), -99) = l_project_id_tl(recno2)
7923 AND NVL(t_enc_lines_array.r_task_id(recno1), -99) = l_task_id_tl(recno2)
7924 AND NVL(t_enc_lines_array.r_award_id(recno1), -99) = l_award_id_tl(recno2)
7925 AND NVL(t_enc_lines_array.r_expenditure_type(recno1), '-99') = l_expenditure_type_tl(recno2)
7926 AND NVL(t_enc_lines_array.r_expenditure_organization_id(recno1), -99) = l_exp_organization_id_tl(recno2)
7927 AND NVL(t_enc_lines_array.r_gl_code_combination_id(recno1), -99) = l_gl_code_combination_id_tl(recno2)) THEN
7928 l_delete_flag := 'Y';
7929 EXIT;
7930 END IF;
7931 END LOOP;
7932
7933 IF (l_delete_flag = 'N') THEN
7934 t_enc_lines_array2.r_enc_element_type_id(l_enc_lines_no) := t_enc_lines_array.r_enc_element_type_id(recno1);
7935 t_enc_lines_array2.r_encumbrance_date(l_enc_lines_no) := t_enc_lines_array.r_encumbrance_date(recno1);
7936 t_enc_lines_array2.r_dr_cr_flag(l_enc_lines_no) := t_enc_lines_array.r_dr_cr_flag(recno1);
7937 t_enc_lines_array2.r_encumbrance_amount(l_enc_lines_no) := t_enc_lines_array.r_encumbrance_amount(recno1);
7938 t_enc_lines_array2.r_enc_line_type(l_enc_lines_no) := t_enc_lines_array.r_enc_line_type(recno1);
7939 t_enc_lines_array2.r_schedule_line_id(l_enc_lines_no) := t_enc_lines_array.r_schedule_line_id(recno1);
7940 t_enc_lines_array2.r_org_schedule_id(l_enc_lines_no) := t_enc_lines_array.r_org_schedule_id(recno1);
7941 t_enc_lines_array2.r_default_org_account_id(l_enc_lines_no) := t_enc_lines_array.r_default_org_account_id(recno1);
7942 t_enc_lines_array2.r_suspense_org_account_id(l_enc_lines_no) := t_enc_lines_array.r_suspense_org_account_id(recno1);
7943 t_enc_lines_array2.r_element_account_id(l_enc_lines_no) := t_enc_lines_array.r_element_account_id(recno1);
7944 t_enc_lines_array2.r_gl_project_flag(l_enc_lines_no) := t_enc_lines_array.r_gl_project_flag(recno1);
7945 t_enc_lines_array2.r_person_id(l_enc_lines_no) := t_enc_lines_array.r_person_id(recno1);
7946 t_enc_lines_array2.r_assignment_id(l_enc_lines_no) := t_enc_lines_array.r_assignment_id(recno1);
7947 t_enc_lines_array2.r_award_id(l_enc_lines_no) := t_enc_lines_array.r_award_id(recno1);
7948 t_enc_lines_array2.r_task_id(l_enc_lines_no) := t_enc_lines_array.r_task_id(recno1);
7949 t_enc_lines_array2.r_expenditure_type(l_enc_lines_no) := t_enc_lines_array.r_expenditure_type(recno1);
7950 t_enc_lines_array2.r_expenditure_organization_id(l_enc_lines_no) := t_enc_lines_array.r_expenditure_organization_id(recno1);
7951 t_enc_lines_array2.r_project_id(l_enc_lines_no) := t_enc_lines_array.r_project_id(recno1);
7952 t_enc_lines_array2.r_gl_code_combination_id(l_enc_lines_no) := t_enc_lines_array.r_gl_code_combination_id(recno1);
7953 t_enc_lines_array2.r_time_period_id(l_enc_lines_no) := t_enc_lines_array.r_time_period_id(recno1);
7954 t_enc_lines_array2.r_default_reason_code(l_enc_lines_no) := t_enc_lines_array.r_default_reason_code(recno1);
7955 t_enc_lines_array2.r_suspense_reason_code(l_enc_lines_no) := t_enc_lines_array.r_suspense_reason_code(recno1);
7956 t_enc_lines_array2.r_enc_control_id(l_enc_lines_no) := t_enc_lines_array.r_enc_control_id(recno1);
7957 t_enc_lines_array2.r_change_flag(l_enc_lines_no) := t_enc_lines_array.r_change_flag(recno1);
7958 t_enc_lines_array2.r_enc_start_date(l_enc_lines_no) := t_enc_lines_array.r_enc_start_date(recno1);
7959 t_enc_lines_array2.r_enc_end_date(l_enc_lines_no) := t_enc_lines_array.r_enc_end_date(recno1);
7960 t_enc_lines_array2.r_attribute_category(l_enc_lines_no) := t_enc_lines_array.r_attribute_category(recno1);
7961 t_enc_lines_array2.r_attribute1(l_enc_lines_no) := t_enc_lines_array.r_attribute1(recno1);
7962 t_enc_lines_array2.r_attribute2(l_enc_lines_no) := t_enc_lines_array.r_attribute2(recno1);
7963 t_enc_lines_array2.r_attribute3(l_enc_lines_no) := t_enc_lines_array.r_attribute3(recno1);
7964 t_enc_lines_array2.r_attribute4(l_enc_lines_no) := t_enc_lines_array.r_attribute4(recno1);
7965 t_enc_lines_array2.r_attribute5(l_enc_lines_no) := t_enc_lines_array.r_attribute5(recno1);
7966 t_enc_lines_array2.r_attribute6(l_enc_lines_no) := t_enc_lines_array.r_attribute6(recno1);
7967 t_enc_lines_array2.r_attribute7(l_enc_lines_no) := t_enc_lines_array.r_attribute7(recno1);
7968 t_enc_lines_array2.r_attribute8(l_enc_lines_no) := t_enc_lines_array.r_attribute8(recno1);
7969 t_enc_lines_array2.r_attribute9(l_enc_lines_no) := t_enc_lines_array.r_attribute9(recno1);
7970 t_enc_lines_array2.r_attribute10(l_enc_lines_no) := t_enc_lines_array.r_attribute10(recno1);
7971 t_enc_lines_array2.r_orig_gl_code_combination_id(l_enc_lines_no) := t_enc_lines_array.r_orig_gl_code_combination_id(recno1);
7972 t_enc_lines_array2.r_orig_project_id(l_enc_lines_no) := t_enc_lines_array.r_orig_project_id(recno1);
7973 t_enc_lines_array2.r_orig_award_id(l_enc_lines_no) := t_enc_lines_array.r_orig_award_id(recno1);
7974 t_enc_lines_array2.r_orig_task_id(l_enc_lines_no) := t_enc_lines_array.r_orig_task_id(recno1);
7975 t_enc_lines_array2.r_orig_expenditure_type(l_enc_lines_no) := t_enc_lines_array.r_orig_expenditure_type(recno1);
7976 t_enc_lines_array2.r_orig_expenditure_org_id(l_enc_lines_no) := t_enc_lines_array.r_orig_expenditure_org_id(recno1);
7977 t_enc_lines_array2.r_hierarchy_code(l_enc_lines_no) := t_enc_lines_array.r_hierarchy_code(recno1);
7978 l_enc_lines_no := l_enc_lines_no + 1;
7979 END IF;
7980 END LOOP;
7981 ELSE
7982 FOR recno1 IN 1..t_enc_lines_array.r_time_period_id.COUNT
7983 LOOP
7984 l_delete_flag := 'N';
7985 FOR recno2 IN 1 .. l_time_period_id_tl.COUNT
7986 LOOP
7987 IF (t_enc_lines_array.r_time_period_id(recno1) = l_time_period_id_tl(recno2)
7988 AND t_enc_lines_array.r_encumbrance_date(recno1) = l_encumbrance_date_tl(recno2)
7989 AND t_enc_lines_array.r_dr_cr_flag(recno1) = l_dr_cr_flag_tl(recno2)
7990 AND t_enc_lines_array.r_enc_element_type_id(recno1) = l_enc_element_type_id_tl(recno2)
7991 AND ROUND(t_enc_lines_array.r_encumbrance_amount(recno1), g_precision) = l_encumbrance_amount_tl(recno2)
7992 AND t_enc_lines_array.r_gl_project_flag(recno1) = l_gl_project_flag_tl(recno2)
7993 AND t_enc_lines_array.r_hierarchy_code(recno1) = l_hierarchy_code_tl(recno2)
7994 AND NVL(t_enc_lines_array.r_default_reason_code(recno1), 'NULL') = NVL(l_default_reason_tl(recno2), 'NULL')
7995 AND NVL(t_enc_lines_array.r_suspense_reason_code(recno1), 'NULL') = NVL(l_suspense_reason_tl(recno2), 'NULL')
7996 AND NVL(t_enc_lines_array.r_project_id(recno1), -99) = l_project_id_tl(recno2)
7997 AND NVL(t_enc_lines_array.r_task_id(recno1), -99) = l_task_id_tl(recno2)
7998 AND NVL(t_enc_lines_array.r_award_id(recno1), -99) = l_award_id_tl(recno2)
7999 AND NVL(t_enc_lines_array.r_expenditure_type(recno1), '-99') = l_expenditure_type_tl(recno2)
8000 AND NVL(t_enc_lines_array.r_expenditure_organization_id(recno1), -99) = l_exp_organization_id_tl(recno2)
8001 AND NVL(t_enc_lines_array.r_gl_code_combination_id(recno1), -99) = l_gl_code_combination_id_tl(recno2)
8002 AND t_enc_lines_array.r_attribute_category(recno1) = l_attribute_category_tl(recno2)
8003 AND t_enc_lines_array.r_attribute1(recno1) = l_attribute1_tl(recno2)
8004 AND t_enc_lines_array.r_attribute2(recno1) = l_attribute2_tl(recno2)
8005 AND t_enc_lines_array.r_attribute3(recno1) = l_attribute3_tl(recno2)
8006 AND t_enc_lines_array.r_attribute4(recno1) = l_attribute4_tl(recno2)
8007 AND t_enc_lines_array.r_attribute5(recno1) = l_attribute5_tl(recno2)
8008 AND t_enc_lines_array.r_attribute6(recno1) = l_attribute6_tl(recno2)
8009 AND t_enc_lines_array.r_attribute7(recno1) = l_attribute7_tl(recno2)
8010 AND t_enc_lines_array.r_attribute8(recno1) = l_attribute8_tl(recno2)
8011 AND t_enc_lines_array.r_attribute9(recno1) = l_attribute9_tl(recno2)
8012 AND t_enc_lines_array.r_attribute10(recno1) = l_attribute10_tl(recno2)) THEN
8013 l_delete_flag := 'Y';
8014 EXIT;
8015 END IF;
8016 END LOOP;
8017
8018 IF (l_delete_flag = 'N') THEN
8019 t_enc_lines_array2.r_enc_element_type_id(l_enc_lines_no) := t_enc_lines_array.r_enc_element_type_id(recno1);
8020 t_enc_lines_array2.r_encumbrance_date(l_enc_lines_no) := t_enc_lines_array.r_encumbrance_date(recno1);
8021 t_enc_lines_array2.r_dr_cr_flag(l_enc_lines_no) := t_enc_lines_array.r_dr_cr_flag(recno1);
8022 t_enc_lines_array2.r_encumbrance_amount(l_enc_lines_no) := t_enc_lines_array.r_encumbrance_amount(recno1);
8023 t_enc_lines_array2.r_enc_line_type(l_enc_lines_no) := t_enc_lines_array.r_enc_line_type(recno1);
8024 t_enc_lines_array2.r_schedule_line_id(l_enc_lines_no) := t_enc_lines_array.r_schedule_line_id(recno1);
8025 t_enc_lines_array2.r_org_schedule_id(l_enc_lines_no) := t_enc_lines_array.r_org_schedule_id(recno1);
8026 t_enc_lines_array2.r_default_org_account_id(l_enc_lines_no) := t_enc_lines_array.r_default_org_account_id(recno1);
8027 t_enc_lines_array2.r_suspense_org_account_id(l_enc_lines_no) := t_enc_lines_array.r_suspense_org_account_id(recno1);
8028 t_enc_lines_array2.r_element_account_id(l_enc_lines_no) := t_enc_lines_array.r_element_account_id(recno1);
8029 t_enc_lines_array2.r_gl_project_flag(l_enc_lines_no) := t_enc_lines_array.r_gl_project_flag(recno1);
8030 t_enc_lines_array2.r_person_id(l_enc_lines_no) := t_enc_lines_array.r_person_id(recno1);
8031 t_enc_lines_array2.r_assignment_id(l_enc_lines_no) := t_enc_lines_array.r_assignment_id(recno1);
8032 t_enc_lines_array2.r_award_id(l_enc_lines_no) := t_enc_lines_array.r_award_id(recno1);
8033 t_enc_lines_array2.r_task_id(l_enc_lines_no) := t_enc_lines_array.r_task_id(recno1);
8034 t_enc_lines_array2.r_expenditure_type(l_enc_lines_no) := t_enc_lines_array.r_expenditure_type(recno1);
8035 t_enc_lines_array2.r_expenditure_organization_id(l_enc_lines_no) := t_enc_lines_array.r_expenditure_organization_id(recno1);
8036 t_enc_lines_array2.r_project_id(l_enc_lines_no) := t_enc_lines_array.r_project_id(recno1);
8037 t_enc_lines_array2.r_gl_code_combination_id(l_enc_lines_no) := t_enc_lines_array.r_gl_code_combination_id(recno1);
8038 t_enc_lines_array2.r_time_period_id(l_enc_lines_no) := t_enc_lines_array.r_time_period_id(recno1);
8039 t_enc_lines_array2.r_default_reason_code(l_enc_lines_no) := t_enc_lines_array.r_default_reason_code(recno1);
8040 t_enc_lines_array2.r_suspense_reason_code(l_enc_lines_no) := t_enc_lines_array.r_suspense_reason_code(recno1);
8041 t_enc_lines_array2.r_enc_control_id(l_enc_lines_no) := t_enc_lines_array.r_enc_control_id(recno1);
8042 t_enc_lines_array2.r_change_flag(l_enc_lines_no) := t_enc_lines_array.r_change_flag(recno1);
8043 t_enc_lines_array2.r_enc_start_date(l_enc_lines_no) := t_enc_lines_array.r_enc_start_date(recno1);
8044 t_enc_lines_array2.r_enc_end_date(l_enc_lines_no) := t_enc_lines_array.r_enc_end_date(recno1);
8045 t_enc_lines_array2.r_attribute_category(l_enc_lines_no) := t_enc_lines_array.r_attribute_category(recno1);
8046 t_enc_lines_array2.r_attribute1(l_enc_lines_no) := t_enc_lines_array.r_attribute1(recno1);
8047 t_enc_lines_array2.r_attribute2(l_enc_lines_no) := t_enc_lines_array.r_attribute2(recno1);
8048 t_enc_lines_array2.r_attribute3(l_enc_lines_no) := t_enc_lines_array.r_attribute3(recno1);
8049 t_enc_lines_array2.r_attribute4(l_enc_lines_no) := t_enc_lines_array.r_attribute4(recno1);
8050 t_enc_lines_array2.r_attribute5(l_enc_lines_no) := t_enc_lines_array.r_attribute5(recno1);
8051 t_enc_lines_array2.r_attribute6(l_enc_lines_no) := t_enc_lines_array.r_attribute6(recno1);
8052 t_enc_lines_array2.r_attribute7(l_enc_lines_no) := t_enc_lines_array.r_attribute7(recno1);
8053 t_enc_lines_array2.r_attribute8(l_enc_lines_no) := t_enc_lines_array.r_attribute8(recno1);
8054 t_enc_lines_array2.r_attribute9(l_enc_lines_no) := t_enc_lines_array.r_attribute9(recno1);
8055 t_enc_lines_array2.r_attribute10(l_enc_lines_no) := t_enc_lines_array.r_attribute10(recno1);
8056 t_enc_lines_array2.r_orig_gl_code_combination_id(l_enc_lines_no) := t_enc_lines_array.r_orig_gl_code_combination_id(recno1);
8057 t_enc_lines_array2.r_orig_project_id(l_enc_lines_no) := t_enc_lines_array.r_orig_project_id(recno1);
8058 t_enc_lines_array2.r_orig_award_id(l_enc_lines_no) := t_enc_lines_array.r_orig_award_id(recno1);
8059 t_enc_lines_array2.r_orig_task_id(l_enc_lines_no) := t_enc_lines_array.r_orig_task_id(recno1);
8060 t_enc_lines_array2.r_orig_expenditure_type(l_enc_lines_no) := t_enc_lines_array.r_orig_expenditure_type(recno1);
8061 t_enc_lines_array2.r_orig_expenditure_org_id(l_enc_lines_no) := t_enc_lines_array.r_orig_expenditure_org_id(recno1);
8062 t_enc_lines_array2.r_hierarchy_code(l_enc_lines_no) := t_enc_lines_array.r_hierarchy_code(recno1);
8063 l_enc_lines_no := l_enc_lines_no + 1;
8064 END IF;
8065 END LOOP;
8066 END IF;
8067
8068 t_enc_lines_array.r_enc_element_type_id.DELETE;
8069 t_enc_lines_array.r_encumbrance_date.DELETE;
8070 t_enc_lines_array.r_dr_cr_flag.DELETE;
8071 t_enc_lines_array.r_encumbrance_amount.DELETE;
8072 t_enc_lines_array.r_enc_line_type.DELETE;
8073 t_enc_lines_array.r_schedule_line_id.DELETE;
8074 t_enc_lines_array.r_org_schedule_id.DELETE;
8075 t_enc_lines_array.r_default_org_account_id.DELETE;
8076 t_enc_lines_array.r_suspense_org_account_id.DELETE;
8077 t_enc_lines_array.r_element_account_id.DELETE;
8078 t_enc_lines_array.r_gl_project_flag.DELETE;
8079 t_enc_lines_array.r_person_id.DELETE;
8080 t_enc_lines_array.r_assignment_id.DELETE;
8081 t_enc_lines_array.r_award_id.DELETE;
8082 t_enc_lines_array.r_task_id.DELETE;
8083 t_enc_lines_array.r_expenditure_type.DELETE;
8084 t_enc_lines_array.r_expenditure_organization_id.DELETE;
8085 t_enc_lines_array.r_project_id.DELETE;
8086 t_enc_lines_array.r_gl_code_combination_id.DELETE;
8087 t_enc_lines_array.r_time_period_id.DELETE;
8088 t_enc_lines_array.r_default_reason_code.DELETE;
8089 t_enc_lines_array.r_suspense_reason_code.DELETE;
8090 t_enc_lines_array.r_enc_control_id.DELETE;
8091 t_enc_lines_array.r_change_flag.DELETE;
8092 t_enc_lines_array.r_enc_start_date.DELETE;
8093 t_enc_lines_array.r_enc_end_date.DELETE;
8094 t_enc_lines_array.r_attribute_category.DELETE;
8095 t_enc_lines_array.r_attribute1.DELETE;
8096 t_enc_lines_array.r_attribute2.DELETE;
8097 t_enc_lines_array.r_attribute3.DELETE;
8098 t_enc_lines_array.r_attribute4.DELETE;
8099 t_enc_lines_array.r_attribute5.DELETE;
8100 t_enc_lines_array.r_attribute6.DELETE;
8101 t_enc_lines_array.r_attribute7.DELETE;
8102 t_enc_lines_array.r_attribute8.DELETE;
8103 t_enc_lines_array.r_attribute9.DELETE;
8104 t_enc_lines_array.r_attribute10.DELETE;
8105 t_enc_lines_array.r_orig_gl_code_combination_id.DELETE;
8106 t_enc_lines_array.r_orig_project_id.DELETE;
8107 t_enc_lines_array.r_orig_award_id.DELETE;
8108 t_enc_lines_array.r_orig_task_id.DELETE;
8109 t_enc_lines_array.r_orig_expenditure_type.DELETE;
8110 t_enc_lines_array.r_orig_expenditure_org_id.DELETE;
8111 t_enc_lines_array.r_hierarchy_code.DELETE;
8112 t_enc_lines_array.r_hierarchy_start_date.DELETE;
8113 t_enc_lines_array.r_hierarchy_end_date.DELETE;
8114
8115 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' t_enc_lines_array2.r_enc_element_type_id.COUNT: ' || t_enc_lines_array2.r_enc_element_type_id.COUNT);
8116
8117 --IF (t_enc_lines_array2.r_enc_element_type_id.COUNT = 0) THEN
8118 --delete_previous_error_log(p_assignment_id => p_assignment_id,
8119 --p_payroll_id => p_payroll_id,
8120 --p_payroll_action_id => g_payroll_action_id);
8121 --END IF;
8122
8123 insert_enc_lines_from_arrays (p_payroll_id => p_payroll_id,
8124 p_business_group_id => p_business_group_id,
8125 p_set_of_books_id => p_set_of_books_id,
8126 p_enc_line_type => 'U',
8127 p_return_status => l_return_status);
8128
8129 IF l_return_status <> fnd_api.g_ret_sts_success THEN
8130 RAISE fnd_api.g_exc_unexpected_error;
8131 END IF;
8132
8133 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving verify_changes
8134 p_payroll_id: ' || p_payroll_id || ' p_assignment_id: ' || p_assignment_id || '
8135 p_business_group_id: ' || p_business_group_id || ' p_set_of_books_id: ' || p_set_of_books_id || '
8136 p_enc_line_type: ' || p_enc_line_type);
8137 l_retcode := FND_API.G_RET_STS_SUCCESS;
8138 EXCEPTION
8139 WHEN OTHERS THEN
8140 IF (g_error_message IS NULL) THEN
8141 g_error_message := 'VERIFY_CHANGES: ' || SQLERRM;
8142 END IF;
8143 g_error_api_path := SUBSTR('VERIFY_CHANGES:' || g_error_api_path,1,230);
8144 fnd_msg_pub.add_exc_msg('PSP_ENC_UPDATE_LINES', 'VERIFY_CHANGES');
8145 l_retcode := fnd_api.g_ret_sts_unexp_error;
8146 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving verify_changes
8147 p_payroll_id: ' || p_payroll_id || '
8148 p_assignment_id: ' || p_assignment_id || '
8149 p_business_group_id: ' || p_business_group_id || '
8150 p_set_of_books_id: ' || p_set_of_books_id || '
8151 p_enc_line_type: ' || p_enc_line_type);
8152 END verify_changes;
8153
8154 PROCEDURE create_liq_lines (p_payroll_action_id IN NUMBER,
8155 p_payroll_id IN NUMBER,
8156 p_assignment_id IN NUMBER,
8157 p_enc_begin_date IN DATE,
8158 p_business_group_id IN NUMBER,
8159 p_set_of_books_id IN NUMBER,
8160 p_return_status OUT NOCOPY VARCHAR2) IS
8161 l_last_updated_by NUMBER(15);
8162 l_last_update_login NUMBER(15);
8163 BEGIN
8164 l_last_updated_by := fnd_global.user_id;
8165 l_last_update_login := fnd_global.login_id;
8166
8167 INSERT INTO psp_enc_summary_lines
8168 (enc_summary_line_id, business_group_id, set_of_books_id,
8169 enc_control_id, time_period_id, person_id,
8170 assignment_id, effective_date, gl_code_combination_id,
8171 project_id, task_id, award_id,
8172 expenditure_organization_id, expenditure_type,
8173 summary_amount, dr_cr_flag, status_code,
8174 payroll_id, gl_project_flag, superceded_line_id,
8175 attribute_category, attribute1, attribute2,
8176 attribute3, attribute4, attribute5,
8177 attribute6, attribute7, attribute8,
8178 attribute9, attribute10, payroll_action_id,
8179 proposed_termination_date, last_update_date, last_updated_by,
8180 last_update_login, created_by, creation_date,
8181 update_flag, org_id)
8182 SELECT psp_enc_summary_lines_s.NEXTVAL,
8183 p_business_group_id,
8184 p_set_of_books_id,
8185 pesl.enc_control_id,
8186 pesl.time_period_id,
8187 pesl.person_id,
8188 pesl.assignment_id,
8189 pesl.effective_date,
8190 pesl.gl_code_combination_id,
8191 pesl.project_id,
8192 pesl.task_id,
8193 pesl.award_id,
8194 pesl.expenditure_organization_id,
8195 pesl.expenditure_type,
8196 DECODE(pesl.gl_project_flag, 'G', pesl.summary_amount, -pesl.summary_amount),
8197 DECODE(pesl.dr_cr_flag, 'C', 'D', 'D', 'C') dr_cr_flag,
8198 'N',
8199 pesl.payroll_id,
8200 pesl.gl_project_flag,
8201 pesl.enc_summary_line_id,
8202 DECODE(g_dff_grouping_option, 'Y', pesl.attribute_category, NULL) attribute_category,
8203 DECODE(g_dff_grouping_option, 'Y', pesl.attribute1, NULL) attribute1,
8204 DECODE(g_dff_grouping_option, 'Y', pesl.attribute2, NULL) attribute2,
8205 DECODE(g_dff_grouping_option, 'Y', pesl.attribute3, NULL) attribute3,
8206 DECODE(g_dff_grouping_option, 'Y', pesl.attribute4, NULL) attribute4,
8207 DECODE(g_dff_grouping_option, 'Y', pesl.attribute5, NULL) attribute5,
8208 DECODE(g_dff_grouping_option, 'Y', pesl.attribute6, NULL) attribute6,
8209 DECODE(g_dff_grouping_option, 'Y', pesl.attribute7, NULL) attribute7,
8210 DECODE(g_dff_grouping_option, 'Y', pesl.attribute8, NULL) attribute8,
8211 DECODE(g_dff_grouping_option, 'Y', pesl.attribute9, NULL) attribute9,
8212 DECODE(g_dff_grouping_option, 'Y', pesl.attribute10, NULL) attribute10,
8213 p_payroll_action_id,
8214 g_actual_term_date,
8215 SYSDATE,
8216 l_last_updated_by,
8217 l_last_update_login,
8218 l_last_updated_by,
8219 SYSDATE,
8220 DECODE(SIGN(TRUNC(effective_date)-TRUNC(p_enc_begin_date)), 1, 'U', 'L'),
8221 pesl.org_id
8222 FROM psp_enc_summary_lines pesl
8223 WHERE pesl.assignment_id = p_assignment_id
8224 AND pesl.payroll_id = p_payroll_id
8225 AND pesl.status_code = 'A'
8226 AND pesl.enc_summary_line_id IN (SELECT pelh.enc_summary_line_id
8227 FROM psp_enc_lines_history pelh
8228 WHERE pelh.change_flag = 'N'
8229 AND pelh.assignment_id = p_assignment_id
8230 AND pelh.payroll_id = p_payroll_id);
8231 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' No of liquidation lines created: ' || SQL%ROWCOUNT);
8232
8233 p_return_status := fnd_api.g_ret_sts_success;
8234 EXCEPTION
8235 WHEN OTHERS THEN
8236 IF (g_error_message IS NULL) THEN
8237 g_error_message := 'CREATE_LIQ_LINES: ' || SQLERRM;
8238 END IF;
8239 g_error_api_path := SUBSTR('CREATE_LIQ_LINES:' || g_error_api_path,1,230);
8240 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'CREATE_LIQ_LINES');
8241 p_return_status := fnd_api.g_ret_sts_unexp_error;
8242 END create_liq_lines;
8243
8244 PROCEDURE create_sum_lines (p_payroll_action_id IN NUMBER,
8245 p_payroll_id IN NUMBER,
8246 p_assignment_id IN NUMBER,
8247 p_business_group_id IN NUMBER,
8248 p_set_of_books_id IN NUMBER,
8249 p_return_status OUT NOCOPY VARCHAR2) IS
8250 l_last_updated_by NUMBER(15);
8251 l_last_update_login NUMBER(15);
8252
8253 CURSOR sum_lines_cur IS
8254 SELECT pel.enc_control_id,
8255 pel.time_period_id,
8256 pel.person_id,
8257 pel.encumbrance_date,
8258 pel.gl_code_combination_id,
8259 pel.project_id,
8260 pel.task_id,
8261 pel.award_id,
8262 pel.expenditure_type,
8263 pel.expenditure_organization_id,
8264 SUM(pel.encumbrance_amount),
8265 pel.dr_cr_flag,
8266 pel.gl_project_flag,
8267 DECODE(g_dff_grouping_option, 'Y', pel.attribute_category, NULL) attribute_category,
8268 DECODE(g_dff_grouping_option, 'Y', pel.attribute1, NULL) attribute1,
8269 DECODE(g_dff_grouping_option, 'Y', pel.attribute2, NULL) attribute2,
8270 DECODE(g_dff_grouping_option, 'Y', pel.attribute3, NULL) attribute3,
8271 DECODE(g_dff_grouping_option, 'Y', pel.attribute4, NULL) attribute4,
8272 DECODE(g_dff_grouping_option, 'Y', pel.attribute5, NULL) attribute5,
8273 DECODE(g_dff_grouping_option, 'Y', pel.attribute6, NULL) attribute6,
8274 DECODE(g_dff_grouping_option, 'Y', pel.attribute7, NULL) attribute7,
8275 DECODE(g_dff_grouping_option, 'Y', pel.attribute8, NULL) attribute8,
8276 DECODE(g_dff_grouping_option, 'Y', pel.attribute9, NULL) attribute9,
8277 DECODE(g_dff_grouping_option, 'Y', pel.attribute10, NULL) attribute10,
8278 pa.org_id
8279 FROM PSP_ENC_LINES pel,
8280 PSP_ORGANIZATION_ACCOUNTS pos,
8281 pa_projects_all pa
8282 WHERE pel.ENCUMBRANCE_AMOUNT <> 0
8283 AND pel.assignment_id = p_assignment_id
8284 AND pel.payroll_id = p_payroll_id
8285 AND pel.suspense_org_account_id = pos.organization_account_id(+)
8286 AND pa.project_id (+) = pel.project_id
8287 AND pel.payroll_action_id = p_payroll_action_id
8288 GROUP BY pel.enc_control_id,
8289 pel.time_period_id,
8290 pel.person_id,
8291 pel.encumbrance_date,
8292 pel.gl_code_combination_id,
8293 pel.project_id,
8294 pel.task_id,
8295 pel.award_id,
8296 pel.expenditure_type,
8297 pel.expenditure_organization_id,
8298 pel.dr_cr_flag,
8299 pel.gl_project_flag,
8300 DECODE(g_dff_grouping_option, 'Y', pel.attribute_category, NULL),
8301 DECODE(g_dff_grouping_option, 'Y', pel.attribute1, NULL),
8302 DECODE(g_dff_grouping_option, 'Y', pel.attribute2, NULL),
8303 DECODE(g_dff_grouping_option, 'Y', pel.attribute3, NULL),
8304 DECODE(g_dff_grouping_option, 'Y', pel.attribute4, NULL),
8305 DECODE(g_dff_grouping_option, 'Y', pel.attribute5, NULL),
8306 DECODE(g_dff_grouping_option, 'Y', pel.attribute6, NULL),
8307 DECODE(g_dff_grouping_option, 'Y', pel.attribute7, NULL),
8308 DECODE(g_dff_grouping_option, 'Y', pel.attribute8, NULL),
8309 DECODE(g_dff_grouping_option, 'Y', pel.attribute9, NULL),
8310 DECODE(g_dff_grouping_option, 'Y', pel.attribute10, NULL),
8311 pa.org_id;
8312
8313 TYPE sum_lines_rec is RECORD
8314 (enc_summary_line_id t_num_15_type,
8315 enc_control_id t_num_15_type,
8316 time_period_id t_num_15_type,
8317 person_id t_num_15_type,
8318 effective_date t_date_type,
8319 gl_code_combination_id t_num_15_type,
8320 project_id t_num_15_type,
8321 task_id t_num_15_type,
8322 award_id t_num_15_type,
8323 expenditure_organization_id t_num_15_type,
8324 expenditure_type t_varchar_50_type,
8325 summary_amount t_num_10d2_type,
8326 dr_cr_flag t_varchar_50_type,
8327 gl_project_flag t_varchar_50_type,
8328 attribute_category t_varchar_50_type,
8329 attribute1 t_varchar_150_type,
8330 attribute2 t_varchar_150_type,
8331 attribute3 t_varchar_150_type,
8332 attribute4 t_varchar_150_type,
8333 attribute5 t_varchar_150_type,
8334 attribute6 t_varchar_150_type,
8335 attribute7 t_varchar_150_type,
8336 attribute8 t_varchar_150_type,
8337 attribute9 t_varchar_150_type,
8338 attribute10 t_varchar_150_type,
8339 org_id t_num_15_type);
8340 t_sum_lines sum_lines_rec;
8341 BEGIN
8342 l_last_updated_by := fnd_global.user_id;
8343 l_last_update_login := fnd_global.login_id;
8344
8345 OPEN sum_lines_cur;
8346 FETCH sum_lines_cur BULK COLLECT INTO t_sum_lines.enc_control_id,
8347 t_sum_lines.time_period_id, t_sum_lines.person_id,
8348 t_sum_lines.effective_date, t_sum_lines.gl_code_combination_id,
8349 t_sum_lines.project_id, t_sum_lines.task_id,
8350 t_sum_lines.award_id, t_sum_lines.expenditure_type,
8351 t_sum_lines.expenditure_organization_id,t_sum_lines.summary_amount,
8352 t_sum_lines.dr_cr_flag, t_sum_lines.gl_project_flag,
8353 t_sum_lines.attribute_category, t_sum_lines.attribute1,
8354 t_sum_lines.attribute2, t_sum_lines.attribute3,
8355 t_sum_lines.attribute4, t_sum_lines.attribute5,
8356 t_sum_lines.attribute6, t_sum_lines.attribute7,
8357 t_sum_lines.attribute8, t_sum_lines.attribute9,
8358 t_sum_lines.attribute10, t_sum_lines.org_id;
8359 CLOSE sum_lines_cur;
8360
8361 FOR recno IN 1..t_sum_lines.enc_control_id.COUNT
8362 LOOP
8363 SELECT psp_enc_summary_lines_s.NEXTVAL INTO t_sum_lines.enc_summary_line_id(recno) FROM DUAL;
8364 END LOOP;
8365
8366 FORALL recno IN 1..t_sum_lines.enc_control_id.COUNT
8367 INSERT INTO psp_enc_summary_lines
8368 (enc_summary_line_id, business_group_id, enc_control_id,
8369 time_period_id, person_id, assignment_id,
8370 effective_date, set_of_books_id, gl_code_combination_id,
8371 project_id, task_id, award_id,
8372 expenditure_organization_id, expenditure_type, summary_amount,
8373 dr_cr_flag, status_code, payroll_id,
8374 gl_project_flag,
8375 attribute_category, attribute1, attribute2,
8376 attribute3, attribute4, attribute5,
8377 attribute6, attribute7, attribute8,
8378 attribute9, attribute10, payroll_action_id,
8379 proposed_termination_date, last_update_date, last_updated_by,
8380 last_update_login, created_by, creation_date,
8381 org_id)
8382 VALUES (t_sum_lines.enc_summary_line_id(recno), p_business_group_id,
8383 t_sum_lines.enc_control_id(recno), t_sum_lines.time_period_id(recno),
8384 t_sum_lines.person_id(recno), p_assignment_id,
8385 t_sum_lines.effective_date(recno), p_set_of_books_id,
8386 t_sum_lines.gl_code_combination_id(recno), t_sum_lines.project_id(recno),
8387 t_sum_lines.task_id(recno), t_sum_lines.award_id(recno),
8388 t_sum_lines.expenditure_organization_id(recno), t_sum_lines.expenditure_type(recno),
8389 t_sum_lines.summary_amount(recno), t_sum_lines.dr_cr_flag(recno),
8390 'N', p_payroll_id, t_sum_lines.gl_project_flag(recno),
8391 t_sum_lines.attribute_category(recno), t_sum_lines.attribute1(recno),
8392 t_sum_lines.attribute2(recno), t_sum_lines.attribute3(recno),
8393 t_sum_lines.attribute4(recno), t_sum_lines.attribute5(recno),
8394 t_sum_lines.attribute6(recno), t_sum_lines.attribute7(recno),
8395 t_sum_lines.attribute8(recno), t_sum_lines.attribute9(recno),
8396 t_sum_lines.attribute10(recno), p_payroll_action_id,
8397 g_actual_term_date, SYSDATE,
8398 l_last_updated_by, l_last_update_login,
8399 l_last_updated_by, SYSDATE,
8400 t_sum_lines.org_id(recno));
8401 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' No of Summary lines created (t_sum_lines.enc_control_id.COUNT): ' || t_sum_lines.enc_control_id.COUNT);
8402
8403 IF (g_dff_grouping_option = 'Y') THEN
8404 FORALL recno IN 1..t_sum_lines.enc_summary_line_id.COUNT
8405 UPDATE psp_enc_lines pel
8406 SET enc_summary_line_id = t_sum_lines.enc_summary_line_id(recno)
8407 WHERE payroll_action_id = p_payroll_action_id
8408 AND pel.assignment_id = p_assignment_id
8409 AND pel.payroll_id = p_payroll_id
8410 AND pel.enc_control_id = t_sum_lines.enc_control_id(recno)
8411 AND pel.time_period_id = t_sum_lines.time_period_id(recno)
8412 AND pel.person_id = t_sum_lines.person_id(recno)
8413 AND pel.encumbrance_date = t_sum_lines.effective_date(recno)
8414 AND NVL(pel.gl_code_combination_id, -99) = NVL(t_sum_lines.gl_code_combination_id(recno), -99)
8415 AND NVL(pel.project_id, -99) = NVL(t_sum_lines.project_id(recno), -99)
8416 AND NVL(pel.task_id, -99) = NVL(t_sum_lines.task_id(recno), -99)
8417 AND NVL(pel.award_id, -99) = NVL(t_sum_lines.award_id(recno), -99)
8418 AND NVL(pel.expenditure_type, 'NULL') = NVL(t_sum_lines.expenditure_type(recno), 'NULL')
8419 AND NVL(pel.expenditure_organization_id, -99) = NVL(t_sum_lines.expenditure_organization_id(recno), -99)
8420 AND pel.dr_cr_flag = t_sum_lines.dr_cr_flag(recno)
8421 AND pel.gl_project_flag = t_sum_lines.gl_project_flag(recno)
8422 AND NVL(pel.attribute_category, 'NULL') = NVL(t_sum_lines.attribute_category(recno), 'NULL')
8423 AND NVL(pel.attribute1, 'NULL') = NVL(t_sum_lines.attribute1(recno), 'NULL')
8424 AND NVL(pel.attribute2, 'NULL') = NVL(t_sum_lines.attribute2(recno), 'NULL')
8425 AND NVL(pel.attribute3, 'NULL') = NVL(t_sum_lines.attribute3(recno), 'NULL')
8426 AND NVL(pel.attribute4, 'NULL') = NVL(t_sum_lines.attribute4(recno), 'NULL')
8427 AND NVL(pel.attribute5, 'NULL') = NVL(t_sum_lines.attribute5(recno), 'NULL')
8428 AND NVL(pel.attribute6, 'NULL') = NVL(t_sum_lines.attribute6(recno), 'NULL')
8429 AND NVL(pel.attribute7, 'NULL') = NVL(t_sum_lines.attribute7(recno), 'NULL')
8430 AND NVL(pel.attribute8, 'NULL') = NVL(t_sum_lines.attribute8(recno), 'NULL')
8431 AND NVL(pel.attribute9, 'NULL') = NVL(t_sum_lines.attribute9(recno), 'NULL')
8432 AND NVL(pel.attribute10, 'NULL') = NVL(t_sum_lines.attribute10(recno), 'NULL');
8433 ELSE
8434 FORALL recno IN 1..t_sum_lines.enc_summary_line_id.COUNT
8435 UPDATE psp_enc_lines pel
8436 SET enc_summary_line_id = t_sum_lines.enc_summary_line_id(recno)
8437 WHERE payroll_action_id = p_payroll_action_id
8438 AND pel.assignment_id = p_assignment_id
8439 AND pel.payroll_id = p_payroll_id
8440 AND pel.enc_control_id = t_sum_lines.enc_control_id(recno)
8441 AND pel.time_period_id = t_sum_lines.time_period_id(recno)
8442 AND pel.person_id = t_sum_lines.person_id(recno)
8443 AND pel.encumbrance_date = t_sum_lines.effective_date(recno)
8444 AND NVL(pel.gl_code_combination_id, -99) = NVL(t_sum_lines.gl_code_combination_id(recno), -99)
8445 AND NVL(pel.project_id, -99) = NVL(t_sum_lines.project_id(recno), -99)
8446 AND NVL(pel.task_id, -99) = NVL(t_sum_lines.task_id(recno), -99)
8447 AND NVL(pel.award_id, -99) = NVL(t_sum_lines.award_id(recno), -99)
8448 AND NVL(pel.expenditure_type, 'NULL') = NVL(t_sum_lines.expenditure_type(recno), 'NULL')
8449 AND NVL(pel.expenditure_organization_id, -99) = NVL(t_sum_lines.expenditure_organization_id(recno), -99)
8450 AND pel.dr_cr_flag = t_sum_lines.dr_cr_flag(recno)
8451 AND pel.gl_project_flag = t_sum_lines.gl_project_flag(recno);
8452 END IF;
8453 p_return_status := fnd_api.g_ret_sts_success;
8454 EXCEPTION
8455 WHEN OTHERS THEN
8456 IF (g_error_message IS NULL) THEN
8457 g_error_message := 'CREATE_SUM_LINES: ' || SQLERRM;
8458 END IF;
8459 g_error_api_path := SUBSTR('CREATE_SUM_LINES:' || g_error_api_path,1,230);
8460 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'CREATE_SUM_LINES');
8461 p_return_status := fnd_api.g_ret_sts_unexp_error;
8462 END create_sum_lines;
8463
8464 PROCEDURE enc_pre_process (p_payroll_action_id IN NUMBER,
8465 p_payroll_id IN NUMBER,
8466 p_process_mode IN VARCHAR2,
8467 p_return_status OUT NOCOPY VARCHAR2) IS
8468 l_new_cust NUMBER;
8469 l_pre_process_mode CHAR(1);
8470 l_inc_exc_flag CHAR(1);
8471 l_business_group_id NUMBER(15);
8472 l_set_of_books_id NUMBER(15);
8473 l_request_id NUMBER(15);
8474 l_count NUMBER(15);
8475 l_enc_begin_date DATE;
8476 l_return_status VARCHAR2(1);
8477 l_assignment_id NUMBER(15);
8478 l_payroll_action_id NUMBER(15);
8479 l_payroll_id NUMBER(15);
8480 l_person_id NUMBER(15);
8481 l_organization_id NUMBER(15);
8482 l_assignment_number per_all_assignments_f.assignment_number%TYPE;
8483 l_payroll_name pay_all_payrolls_f.payroll_name%TYPE;
8484 l_full_name per_all_people_f.full_name%TYPE;
8485 l_organization_name hr_organization_units.name%TYPE;
8486 l_process_description fnd_concurrent_programs_tl.user_concurrent_program_name%TYPE;
8487 l_process_mode VARCHAR2(15);
8488 l_person_id1 NUMBER(15);
8489 l_termination_date1 DATE;
8490 l_person_id2 NUMBER(15);
8491 l_termination_date2 DATE;
8492 l_person_id3 NUMBER(15);
8493 l_termination_date3 DATE;
8494 l_person_id4 NUMBER(15);
8495 l_termination_date4 DATE;
8496 l_person_id5 NUMBER(15);
8497 l_termination_date5 DATE;
8498
8499 CURSOR new_cust_cur IS
8500 SELECT COUNT(1)
8501 FROM psp_enc_controls
8502 WHERE ROWNUM = 1;
8503
8504 CURSOR action_parameters_cur IS
8505 SELECT fnd_number.canonical_to_number(NVL(argument13, '-1')),
8506 fnd_date.canonical_to_date(NVL(argument14, fnd_date.date_to_canonical(TRUNC(SYSDATE)))),
8507 fnd_number.canonical_to_number(NVL(argument15, '-1')),
8508 fnd_date.canonical_to_date(NVL(argument16, fnd_date.date_to_canonical(TRUNC(SYSDATE)))),
8509 fnd_number.canonical_to_number(NVL(argument17, '-1')),
8510 fnd_date.canonical_to_date(NVL(argument18, fnd_date.date_to_canonical(TRUNC(SYSDATE)))),
8511 fnd_number.canonical_to_number(NVL(argument19, '-1')),
8512 fnd_date.canonical_to_date(NVL(argument20, fnd_date.date_to_canonical(TRUNC(SYSDATE)))),
8513 fnd_number.canonical_to_number(NVL(argument21, '-1')),
8514 fnd_date.canonical_to_date(NVL(argument22, fnd_date.date_to_canonical(TRUNC(SYSDATE))))
8515 FROM psp_enc_processes pep,
8516 fnd_concurrent_requests fcr
8517 WHERE pep.payroll_action_id = p_payroll_action_id
8518 AND fcr.request_id = pep.request_id;
8519
8520 CURSOR enc_payroll_cur IS
8521 SELECT pep.inc_exc_flag
8522 FROM psp_enc_payrolls pep
8523 WHERE pep.payroll_id = p_payroll_id
8524 AND pep.business_group_id = l_business_group_id
8525 AND pep.set_of_books_id = l_set_of_books_id;
8526
8527 /* Bug 5642002: Replaced earned date with period end date */
8528 CURSOR c_last_pay_run IS
8529 SELECT /*+ use_nl(PTP) */ Max(ptp.end_date)
8530 FROM pay_payroll_actions ppa,
8531 pay_assignment_actions paa,
8532 per_time_periods ptp
8533 WHERE ppa.payroll_action_id = paa.payroll_action_id (+)
8534 AND ppa.business_group_id = l_business_group_id
8535 AND ppa.payroll_id = p_payroll_id
8536 AND ppa.action_type IN ( 'R','Q')
8537 AND NVL(paa.action_status, ppa.action_status) = 'C'
8538 and ppa.date_earned between ptp.start_date and ptp.end_date
8539 and ptp.payroll_id = ppa.payroll_id;
8540
8541 CURSOR c_tp_start_date IS
8542 SELECT MIN(ptp.start_date)
8543 FROM per_time_periods ptp
8544 WHERE ptp.payroll_id= p_payroll_id;
8545
8546 CURSOR asg_number_cur (p_start_date IN DATE) IS
8547 SELECT assignment_number,
8548 person_id,
8549 organization_id
8550 FROM per_all_assignments_f
8551 WHERE assignment_id = l_assignment_id
8552 AND payroll_id = NVL(l_payroll_id, p_payroll_id)
8553 AND effective_end_date >= p_start_date
8554 AND ROWNUM = 1;
8555
8556 CURSOR payroll_name_cur IS
8557 SELECT payroll_name
8558 FROM pay_all_payrolls_f
8559 WHERE payroll_id = p_payroll_id
8560 AND business_group_id = g_business_group_id
8561 AND gl_set_of_books_id = g_set_of_books_id
8562 AND ROWNUM = 1;
8563
8564 CURSOR person_name_cur (p_start_date IN DATE) IS
8565 SELECT full_name
8566 FROM per_all_people_f
8567 WHERE person_id = l_person_id
8568 AND effective_end_date >= p_start_date
8569 AND ROWNUM = 1;
8570
8571 CURSOR org_name_cur IS
8572 SELECT name
8573 FROM hr_organization_units
8574 WHERE organization_id = l_organization_id;
8575
8576 CURSOR process_descr_cur IS
8577 SELECT pep.request_id || ': ' || fcpt.user_concurrent_program_name
8578 FROM psp_enc_processes pep,
8579 fnd_concurrent_requests fcr,
8580 fnd_concurrent_programs_tl fcpt
8581 WHERE EXISTS (SELECT 1
8582 FROM psp_enc_summary_lines pesl
8583 WHERE pesl.payroll_action_id = pep.payroll_action_id
8584 AND pesl.payroll_action_id = l_payroll_action_id)
8585 AND fcr.request_id = pep.request_id
8586 AND fcpt.concurrent_program_id = fcr.concurrent_program_id
8587 AND fcpt.language = USERENV('LANG')
8588 ORDER BY DECODE(pep.process_code, 'LET', 1, 'ST', 2, 3);
8589
8590 CURSOR in_process_term_cur (p_person_id IN NUMBER) IS
8591 SELECT DISTINCT assignment_id,
8592 payroll_id,
8593 payroll_action_id
8594 FROM psp_enc_summary_lines pesl
8595 WHERE pesl.person_id = p_person_id
8596 AND pesl.status_code = 'N';
8597
8598 CURSOR in_process_asg_cur IS
8599 SELECT pepa.assignment_id,
8600 pepa.payroll_action_id
8601 FROM psp_enc_process_assignments pepa
8602 WHERE pepa.payroll_id = p_payroll_id
8603 AND pepa.assignment_status NOT IN ('B', 'P');
8604
8605 l_prev_enc_end_date PSP_ENC_END_DATES_V.prev_enc_end_date%TYPE; -- Bug 7188209
8606
8607 BEGIN
8608 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering ENC_PRE_PROCESS
8609 p_payroll_action_id: ' || p_payroll_action_id || '
8610 p_payroll_id: ' || p_payroll_id || '
8611 p_process_mode: ' || p_process_mode);
8612
8613 l_request_id := FND_GLOBAL. CONC_REQUEST_ID;
8614 l_set_of_books_id := FND_PROFILE.VALUE('GL_SET_OF_BKS_ID');
8615 l_business_group_id := FND_PROFILE.VALUE('PER_BUSINESS_GROUP_ID');
8616 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_request_id: ' || l_request_id ||'
8617 l_set_of_books_id: ' || l_set_of_books_id || '
8618 l_business_group_id: ' || l_business_group_id);
8619
8620 IF (p_process_mode = 'REGULAR') THEN
8621 OPEN new_cust_cur;
8622 FETCH new_cust_cur INTO l_new_cust;
8623 CLOSE new_cust_cur;
8624
8625 OPEN c_last_pay_run;
8626 FETCH c_last_pay_run INTO l_enc_begin_date;
8627 CLOSE c_last_pay_run;
8628
8629 IF (l_enc_begin_date IS NULL) THEN
8630 OPEN c_tp_start_date;
8631 FETCH c_tp_start_date INTO l_enc_begin_date;
8632 CLOSE c_tp_start_date;
8633 END IF;
8634 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_enc_begin_date: ' || fnd_date.date_to_canonical(l_enc_begin_date));
8635
8636 l_pre_process_mode := 'R';
8637 IF (l_new_cust = 0 AND psp_general.start_capturing_updates(l_business_group_id) = 'N') THEN
8638 l_pre_process_mode := 'F';
8639 END IF;
8640
8641 psp_enc_pre_process.poeta_pre_process
8642 (p_pre_process_mode => l_pre_process_mode,
8643 p_payroll_id => p_payroll_id,
8644 p_business_group_id => l_business_group_id,
8645 p_set_of_books_id => l_set_of_books_id,
8646 p_return_status => l_return_status);
8647 IF l_return_status <> fnd_api.g_ret_sts_success THEN
8648 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8649 END IF;
8650 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Completed psp_enc_pre_process.poeta_pre_process');
8651
8652 IF (l_pre_process_mode <>'F') THEN
8653 psp_enc_pre_process.labor_schedule_pre_process
8654 (p_enc_line_type => 'U',
8655 p_payroll_id => p_payroll_id,
8656 p_return_status => l_return_status);
8657
8658 IF l_return_status <> fnd_api.g_ret_sts_success THEN
8659 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8660 END IF;
8661 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Completed psp_enc_pre_process.labor_schedule_pre_process');
8662 END IF;
8663
8664 OPEN enc_payroll_cur;
8665 FETCH enc_payroll_cur INTO l_inc_exc_flag;
8666 CLOSE enc_payroll_cur;
8667 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_inc_exc_flag: ' || l_inc_exc_flag);
8668
8669 -- Bug 7188209
8670 select prev_enc_end_date into l_prev_enc_end_date
8671 from PSP_ENC_END_DATES_V
8672 where business_group_id = l_business_group_id
8673 and set_of_books_id = l_set_of_books_id;
8674 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_prev_enc_end_date = ' || l_prev_enc_end_date);
8675
8676
8677 IF l_inc_exc_flag = 'Y' THEN
8678
8679 INSERT INTO psp_enc_changed_assignments
8680 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
8681 SELECT DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'CR', p_payroll_action_id
8682 FROM per_assignments_f pa
8683 WHERE pa.payroll_id = p_payroll_id
8684 AND pa.assignment_type = 'E'
8685 AND pa.business_group_id = l_business_group_id
8686 -- AND pa.effective_end_date >= l_enc_begin_date
8687 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
8688 AND pa.effective_end_date >= (NVL((SELECT /*+ use_nl(PTP) */ Max(ptp.end_date)
8689 FROM pay_payroll_actions ppa,
8690 pay_assignment_actions paa,
8691 per_time_periods ptp
8692 WHERE paa.assignment_id(+) = pa.assignment_id
8693 AND ppa.payroll_action_id = paa.payroll_action_id (+)
8694 AND ppa.business_group_id = pa.business_group_id
8695 AND ppa.payroll_id = pa.payroll_id
8696 AND ppa.action_type IN ( 'R','Q')
8697 AND paa.action_status(+) = 'C'
8698 and ppa.date_earned between ptp.start_date and ptp.end_date
8699 and ptp.payroll_id = ppa.payroll_id),l_enc_begin_date))
8700 AND NOT EXISTS (SELECT pepa.assignment_id
8701 FROM psp_enc_payroll_assignments pepa,
8702 psp_enc_payrolls pep
8703 WHERE pepa.enc_payroll_id = pep.enc_payroll_id
8704 AND pepa.business_group_id = l_business_group_id
8705 AND pepa.set_of_books_id = l_set_of_books_id
8706 AND pepa.business_group_id = pep.business_group_id
8707 AND pepa.set_of_books_id = pep.set_of_books_id
8708 AND pep.payroll_id = p_payroll_id
8709 AND pepa.assignment_id = pa.assignment_id)
8710 AND NOT EXISTS (SELECT 1
8711 FROM psp_enc_changed_assignments peca
8712 WHERE peca.assignment_id = pa.assignment_id
8713 AND peca.payroll_id = p_payroll_id)
8714 AND NOT EXISTS (SELECT 1
8715 FROM psp_enc_summary_lines pesl
8716 WHERE pesl.assignment_id = pa.assignment_id
8717 AND pesl.status_code IN ('A', 'N')
8718 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
8719 AND pesl.effective_date > (NVL((SELECT /*+ use_nl(PTP) */ Max(ptp.end_date)
8720 FROM pay_payroll_actions ppa,
8721 pay_assignment_actions paa,
8722 per_time_periods ptp
8723 WHERE paa.assignment_id(+) = pesl.assignment_id
8724 AND ppa.payroll_action_id = paa.payroll_action_id (+)
8725 AND ppa.business_group_id = pesl.business_group_id
8726 AND ppa.payroll_id = pesl.payroll_id
8727 AND ppa.action_type IN ( 'R','Q')
8728 AND paa.action_status(+) = 'C'
8729 and ppa.date_earned between ptp.start_date and ptp.end_date
8730 and ptp.payroll_id = ppa.payroll_id),l_enc_begin_date))
8731 AND pesl.payroll_id = p_payroll_id);
8732
8733 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '10-A Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
8734
8735
8736 -- Added this INSERT for bug 7188209
8737
8738 INSERT INTO psp_enc_changed_assignments
8739 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
8740 SELECT DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'CR', p_payroll_action_id
8741 FROM per_assignments_f pa
8742 WHERE pa.payroll_id = p_payroll_id
8743 AND pa.assignment_type = 'E'
8744 AND pa.business_group_id = l_business_group_id
8745 AND pa.effective_end_date >= (NVL((SELECT /*+ use_nl(PTP) */ Max(ptp.end_date)
8746 FROM pay_payroll_actions ppa,
8747 pay_assignment_actions paa,
8748 per_time_periods ptp
8749 WHERE paa.assignment_id(+) = pa.assignment_id
8750 and ppa.payroll_action_id = paa.payroll_action_id (+)
8751 and ppa.business_group_id = pa.business_group_id
8752 AND ppa.payroll_id = pa.payroll_id
8753 AND ppa.action_type IN ( 'R','Q')
8754 AND paa.action_status(+) = 'C'
8755 and ppa.date_earned between ptp.start_date and ptp.end_date
8756 and ptp.payroll_id = ppa.payroll_id),l_enc_begin_date))
8757 AND NOT EXISTS (SELECT pepa.assignment_id
8758 FROM psp_enc_payroll_assignments pepa,
8759 psp_enc_payrolls pep
8760 WHERE pepa.enc_payroll_id = pep.enc_payroll_id
8761 AND pepa.business_group_id = l_business_group_id
8762 AND pepa.set_of_books_id = l_set_of_books_id
8763 AND pepa.business_group_id = pep.business_group_id
8764 AND pepa.set_of_books_id = pep.set_of_books_id
8765 AND pep.payroll_id = p_payroll_id
8766 AND pepa.assignment_id = pa.assignment_id)
8767 AND NOT EXISTS (SELECT 1
8768 FROM psp_enc_changed_assignments peca
8769 WHERE peca.assignment_id = pa.assignment_id
8770 AND peca.payroll_id = p_payroll_id)
8771 AND NOT EXISTS (SELECT 1
8772 FROM psp_enc_summary_lines pesl
8773 WHERE pesl.assignment_id = pa.assignment_id
8774 AND pesl.status_code IN ('A', 'N')
8775 AND pesl.effective_date > l_prev_enc_end_date
8776 AND pesl.payroll_id = p_payroll_id);
8777
8778 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '10-B Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
8779
8780 INSERT INTO psp_enc_changed_assignments
8781 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
8782 SELECT DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'ZZ', p_payroll_action_id
8783 FROM per_assignments_f pa
8784 WHERE pa.payroll_id = p_payroll_id
8785 AND pa.assignment_type = 'E'
8786 AND pa.business_group_id = l_business_group_id
8787 AND pa.effective_end_date >= l_enc_begin_date
8788 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
8789 AND pa.effective_end_date >= (NVL((SELECT /*+ use_nl(PTP) */ Max(ptp.end_date)
8790 FROM pay_payroll_actions ppa,
8791 pay_assignment_actions paa,
8792 per_time_periods ptp
8793 WHERE paa.assignment_id(+) = pa.assignment_id
8794 AND ppa.payroll_action_id = paa.payroll_action_id (+)
8795 AND ppa.business_group_id = pa.business_group_id
8796 AND ppa.payroll_id = pa.payroll_id
8797 AND ppa.action_type IN ( 'R','Q')
8798 AND paa.action_status(+) = 'C'
8799 and ppa.date_earned between ptp.start_date and ptp.end_date
8800 and ptp.payroll_id = ppa.payroll_id),l_enc_begin_date))
8801 AND EXISTS (SELECT pepa.assignment_id
8802 FROM psp_enc_payroll_assignments pepa,
8803 psp_enc_payrolls pep
8804 WHERE pepa.enc_payroll_id = pep.enc_payroll_id
8805 AND pepa.business_group_id = l_business_group_id
8806 AND pepa.set_of_books_id = l_set_of_books_id
8807 AND pepa.business_group_id = pep.business_group_id
8808 AND pepa.set_of_books_id = pep.set_of_books_id
8809 AND pep.payroll_id = p_payroll_id
8810 AND pepa.assignment_id = pa.assignment_id)
8811 AND EXISTS (SELECT 1
8812 FROM psp_enc_summary_lines pesl
8813 WHERE pesl.assignment_id = pa.assignment_id
8814 AND pesl.status_code = 'A'
8815 AND pesl.payroll_id = p_payroll_id)
8816 AND NOT EXISTS (SELECT 1
8817 FROM psp_enc_summary_lines pesl
8818 WHERE pesl.assignment_id = pa.assignment_id
8819 AND pesl.status_code = 'N'
8820 AND pesl.payroll_id = p_payroll_id);
8821
8822 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '20 Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
8823
8824 ELSE
8825
8826 INSERT INTO psp_enc_changed_assignments
8827 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
8828 SELECT DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'CR', p_payroll_action_id
8829 FROM psp_enc_payroll_assignments pepa,
8830 psp_enc_payrolls pep,
8831 per_assignments_f pa
8832 WHERE pa.payroll_id = p_payroll_id
8833 AND pepa.business_group_id = l_business_group_id
8834 AND pepa.set_of_books_id = l_set_of_books_id
8835 AND pepa.assignment_id = pa.assignment_id
8836 AND pa.effective_end_date >= l_enc_begin_date
8837 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
8838 AND pa.effective_end_date >= (NVL((SELECT /*+ use_nl(PTP) */ Max(ptp.end_date)
8839 FROM pay_payroll_actions ppa,
8840 pay_assignment_actions paa,
8841 per_time_periods ptp
8842 WHERE paa.assignment_id(+) = pa.assignment_id
8843 AND ppa.payroll_action_id = paa.payroll_action_id (+)
8844 AND ppa.business_group_id = pa.business_group_id
8845 AND ppa.payroll_id = pa.payroll_id
8846 AND ppa.action_type IN ( 'R','Q')
8847 AND paa.action_status(+) = 'C'
8848 and ppa.date_earned between ptp.start_date and ptp.end_date
8849 and ptp.payroll_id = ppa.payroll_id),l_enc_begin_date))
8850 AND pep.payroll_id = p_payroll_id
8851 AND pep.enc_payroll_id = pepa.enc_payroll_id
8852 AND NOT EXISTS (SELECT 1
8853 FROM psp_enc_changed_assignments peca
8854 WHERE peca.assignment_id = pepa.assignment_id
8855 AND peca.payroll_id = p_payroll_id)
8856 AND NOT EXISTS (SELECT 1
8857 FROM psp_enc_summary_lines pesl
8858 WHERE pesl.assignment_id = pa.assignment_id
8859 AND pesl.status_code IN ('A', 'N')
8860 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
8861 AND pesl.effective_date > (NVL((SELECT /*+ use_nl(PTP) */ Max(ptp.end_date)
8862 FROM pay_payroll_actions ppa,
8863 pay_assignment_actions paa,
8864 per_time_periods ptp
8865 WHERE paa.assignment_id(+) = pesl.assignment_id
8866 AND ppa.payroll_action_id = paa.payroll_action_id (+)
8867 AND ppa.time_period_id = ptp.time_period_id
8868 AND ppa.business_group_id = pesl.business_group_id
8869 AND ppa.payroll_id = pesl.payroll_id
8870 AND ppa.action_type IN ( 'R','Q')
8871 AND paa.action_status(+) = 'C'),l_enc_begin_date)) );
8872
8873 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '30-A Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
8874
8875 -- Added for bug 7188209
8876 INSERT INTO psp_enc_changed_assignments
8877 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
8878 SELECT DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'CR', p_payroll_action_id
8879 FROM psp_enc_payroll_assignments pepa,
8880 psp_enc_payrolls pep,
8881 per_assignments_f pa
8882 WHERE pa.payroll_id = p_payroll_id
8883 AND pepa.business_group_id = l_business_group_id
8884 AND pepa.set_of_books_id = l_set_of_books_id
8885 AND pepa.assignment_id = pa.assignment_id
8886 AND pa.effective_end_date >= (NVL((SELECT /*+ use_nl(PTP) */ Max(ptp.end_date)
8887 FROM pay_payroll_actions ppa,
8888 pay_assignment_actions paa,
8889 per_time_periods ptp
8890 WHERE paa.assignment_id(+)= pa.assignment_id
8891 and ppa.payroll_action_id = paa.payroll_action_id (+)
8892 and ppa.business_group_id = pa.business_group_id
8893 AND ppa.payroll_id = pa.payroll_id
8894 AND ppa.action_type IN ( 'R','Q')
8895 AND paa.action_status(+) = 'C'
8896 and ppa.date_earned between ptp.start_date and ptp.end_date
8897 and ptp.payroll_id = ppa.payroll_id),l_enc_begin_date))
8898 AND pep.payroll_id = p_payroll_id
8899 AND pep.enc_payroll_id = pepa.enc_payroll_id
8900 AND NOT EXISTS (SELECT 1
8901 FROM psp_enc_changed_assignments peca
8902 WHERE peca.assignment_id = pepa.assignment_id
8903 AND peca.payroll_id = p_payroll_id)
8904 AND NOT EXISTS (SELECT 1
8905 FROM psp_enc_summary_lines pesl
8906 WHERE pesl.assignment_id = pa.assignment_id
8907 AND pesl.status_code IN ('A', 'N')
8908 AND pesl.effective_date > l_prev_enc_end_date);
8909
8910 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '30-B Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
8911
8912 INSERT INTO psp_enc_changed_assignments
8913 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
8914 SELECT DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'ZZ', p_payroll_action_id
8915 FROM per_assignments_f pa
8916 WHERE pa.payroll_id = p_payroll_id
8917 AND pa.assignment_type = 'E'
8918 AND pa.business_group_id = l_business_group_id
8919 AND pa.effective_end_date >= l_enc_begin_date
8920 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
8921 AND pa.effective_end_date >= (NVL((SELECT /*+ use_nl(PTP) */ Max(ptp.end_date)
8922 FROM pay_payroll_actions ppa,
8923 pay_assignment_actions paa,
8924 per_time_periods ptp
8925 WHERE paa.assignment_id(+) = pa.assignment_id
8926 AND ppa.payroll_action_id = paa.payroll_action_id (+)
8927 AND ppa.business_group_id = pa.business_group_id
8928 AND ppa.payroll_id = pa.payroll_id
8929 AND ppa.action_type IN ( 'R','Q')
8930 AND paa.action_status(+) = 'C'
8931 and ppa.date_earned between ptp.start_date and ptp.end_date
8932 and ptp.payroll_id = ppa.payroll_id),l_enc_begin_date))
8933 AND NOT EXISTS (SELECT pepa.assignment_id
8934 FROM psp_enc_payroll_assignments pepa,
8935 psp_enc_payrolls pep
8936 WHERE pepa.enc_payroll_id = pep.enc_payroll_id
8937 AND pepa.business_group_id = l_business_group_id
8938 AND pepa.set_of_books_id = l_set_of_books_id
8939 AND pepa.business_group_id = pep.business_group_id
8940 AND pepa.set_of_books_id = pep.set_of_books_id
8941 AND pep.payroll_id = p_payroll_id
8942 AND pepa.assignment_id = pa.assignment_id)
8943 AND EXISTS (SELECT 1
8944 FROM psp_enc_summary_lines pesl
8945 WHERE pesl.assignment_id = pa.assignment_id
8946 AND pesl.status_code = 'A'
8947 AND pesl.payroll_id = p_payroll_id)
8948 AND NOT EXISTS (SELECT 1
8949 FROM psp_enc_summary_lines pesl
8950 WHERE pesl.assignment_id = pa.assignment_id
8951 AND pesl.status_code = 'N'
8952 AND pesl.payroll_id = p_payroll_id);
8953 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '40 Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
8954 END IF;
8955
8956 INSERT INTO psp_enc_changed_assignments
8957 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
8958 SELECT DISTINCT l_request_id, p_payroll_id, assignment_id, 'LQ', p_payroll_action_id
8959 FROM psp_enc_summary_lines pesl
8960 WHERE payroll_id = p_payroll_id
8961 AND business_group_id = l_business_group_id
8962 AND status_code = 'A'
8963 AND effective_date <= l_enc_begin_date
8964 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
8965 AND pesl.effective_date <= (NVL((SELECT /*+ use_nl(PTP) */ Max(ptp.end_date)
8966 FROM pay_payroll_actions ppa,
8967 pay_assignment_actions paa,
8968 per_time_periods ptp
8969 WHERE paa.assignment_id(+) = pesl.assignment_id
8970 AND ppa.payroll_action_id = paa.payroll_action_id (+)
8971 AND ppa.business_group_id = pesl.business_group_id
8972 AND ppa.payroll_id = pesl.payroll_id
8973 AND ppa.action_type IN ( 'R','Q')
8974 AND paa.action_status(+) = 'C'
8975 and ppa.date_earned between ptp.start_date and ptp.end_date
8976 and ptp.payroll_id = ppa.payroll_id),l_enc_begin_date))
8977 AND NOT EXISTS (SELECT 1
8978 FROM psp_enc_changed_assignments peca
8979 WHERE peca.assignment_id = pesl.assignment_id
8980 AND peca.payroll_id = p_payroll_id)
8981 AND NOT EXISTS (SELECT 1
8982 FROM psp_enc_summary_lines pesl2
8983 WHERE pesl2.assignment_id = pesl.assignment_id
8984 AND pesl2.status_code = 'N'
8985 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
8986 AND pesl2.effective_date <= (NVL((SELECT /*+ use_nl(PTP) */ Max(ptp.end_date)
8987 FROM pay_payroll_actions ppa,
8988 pay_assignment_actions paa,
8989 per_time_periods ptp
8990 WHERE paa.assignment_id(+) = pesl2.assignment_id
8991 AND ppa.payroll_action_id = paa.payroll_action_id (+)
8992 AND ppa.business_group_id = pesl2.business_group_id
8993 AND ppa.payroll_id = pesl2.payroll_id
8994 AND ppa.action_type IN ( 'R','Q')
8995 AND paa.action_status(+) = 'C'
8996 and ppa.date_earned between ptp.start_date and ptp.end_date
8997 and ptp.payroll_id = ppa.payroll_id),l_enc_begin_date))
8998 AND pesl2.payroll_id = p_payroll_id);
8999
9000 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '50 Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
9001
9002 UPDATE psp_enc_changed_assignments peca
9003 SET payroll_action_id = p_payroll_action_id
9004 WHERE payroll_action_id IS NULL
9005 AND payroll_id = NVL(p_payroll_id, payroll_id)
9006 AND NOT EXISTS (SELECT 1
9007 FROM psp_enc_process_assignments pepa
9008 WHERE pepa.assignment_id = peca.assignment_id
9009 AND pepa.assignment_status NOT IN ('B', 'P')
9010 AND pepa.payroll_id = peca.payroll_id);
9011 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Marked ' || SQL%ROWCOUNT || ' assignments in psp_enc_changed_assignments to be processed by this Create and Update process');
9012
9013 DELETE FROM psp_enc_changed_assignments
9014 WHERE payroll_action_id = p_payroll_action_id
9015 AND payroll_id = p_payroll_id
9016 AND request_id = l_request_id
9017 and assignment_id IN(SELECT assignment_id from PSP_ENC_PAYROLL_ASSIGNMENT_V
9018 WHERE payroll_id = p_payroll_id
9019 AND exclude = 'Y'
9020 MINUS
9021 SELECT ASSIGNMENT_ID FROM psp_enc_changed_asg_history
9022 WHERE payroll_id = p_payroll_id);
9023
9024 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Deleted ' || SQL%ROWCOUNT || ' fresh excluded assignments in psp_enc_changed_assignments not to be processed by this Create and Update process');
9025
9026 OPEN in_process_asg_cur;
9027 LOOP
9028 FETCH in_process_asg_cur INTO l_assignment_id, l_payroll_action_id;
9029 EXIT WHEN in_process_asg_cur%NOTFOUND;
9030
9031 OPEN process_descr_cur;
9032 FETCH process_descr_cur INTO l_process_description;
9033 CLOSE process_descr_cur;
9034
9035 fnd_message.set_name('PSP', 'PSP_ENC_ASG_IN_PROCESS');
9036 fnd_message.set_token('PROCESS_DESCRIPTION', l_process_description);
9037 g_warning_message := fnd_message.get;
9038
9039 OPEN asg_number_cur (l_enc_begin_date);
9040 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
9041 CLOSE asg_number_cur;
9042
9043 OPEN payroll_name_cur;
9044 FETCH payroll_name_cur INTO l_payroll_name;
9045 CLOSE payroll_name_cur;
9046
9047 OPEN person_name_cur (l_enc_begin_date);
9048 FETCH person_name_cur INTO l_full_name;
9049 CLOSE person_name_cur;
9050
9051 OPEN org_name_cur;
9052 FETCH org_name_cur INTO l_organization_name;
9053 CLOSE org_name_cur;
9054
9055 psp_general.add_report_error
9056 (p_request_id => l_request_id,
9057 p_message_level => 'N',
9058 p_source_id => l_assignment_id,
9059 p_source_name => l_assignment_number,
9060 p_parent_source_id => l_person_id,
9061 p_parent_source_name => l_full_name,
9062 p_error_message => g_warning_message,
9063 p_payroll_action_id => p_payroll_action_id,
9064 p_value1 => p_payroll_id,
9065 p_information1 => l_payroll_name,
9066 p_value2 => l_organization_id,
9067 p_information2 => l_organization_name,
9068 p_return_status => l_return_status);
9069 END LOOP;
9070 CLOSE in_process_asg_cur;
9071 ELSE
9072 OPEN action_parameters_cur;
9073 FETCH action_parameters_cur INTO l_person_id1, l_termination_date1,
9074 l_person_id2, l_termination_date2, l_person_id3, l_termination_date3,
9075 l_person_id4, l_termination_date4, l_person_id5, l_termination_date5;
9076 CLOSE action_parameters_cur;
9077 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_person_id1: ' || l_person_id1 || ' l_termination_date1: ' || fnd_date.date_to_canonical(l_termination_date1) || '
9078 l_person_id2: ' || l_person_id2 || ' l_termination_date2: ' || fnd_date.date_to_canonical(l_termination_date2) || '
9079 l_person_id3: ' || l_person_id3 || ' l_termination_date3: ' || fnd_date.date_to_canonical(l_termination_date3) || '
9080 l_person_id4: ' || l_person_id4 || ' l_termination_date4: ' || fnd_date.date_to_canonical(l_termination_date4) || '
9081 l_person_id5: ' || l_person_id5 || ' l_termination_date5: ' || fnd_date.date_to_canonical(l_termination_date5));
9082
9083 INSERT INTO PSP_ENC_CHANGED_ASSIGNMENTS
9084 (request_id, assignment_id, payroll_id, change_type, payroll_action_id, change_date)
9085 SELECT DISTINCT l_request_id,
9086 pesl.assignment_id,
9087 pesl.payroll_id,
9088 'TR',
9089 p_payroll_action_id,
9090 l_termination_date1
9091 FROM psp_enc_summary_lines pesl
9092 WHERE pesl.person_id = l_person_id1
9093 AND pesl.effective_date >= l_termination_date1
9094 AND pesl.award_id IS NOT NULL
9095 AND pesl.status_code = 'A'
9096 AND NOT EXISTS (SELECT 1
9097 FROM psp_enc_summary_lines pesl2
9098 WHERE pesl2.person_id = l_person_id1
9099 AND pesl2.status_code = 'N');
9100 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Inserted termination assignments into psp_enc_changed_assignments ' || SQL%ROWCOUNT);
9101 IF (SQL%ROWCOUNT = 0) THEN
9102 OPEN in_process_term_cur(l_person_id1);
9103 LOOP
9104 FETCH in_process_term_cur INTO l_assignment_id, l_payroll_id, l_payroll_action_id;
9105 EXIT WHEN in_process_term_cur%NOTFOUND;
9106
9107 OPEN process_descr_cur;
9108 FETCH process_descr_cur INTO l_process_description;
9109 CLOSE process_descr_cur;
9110
9111 fnd_message.set_name('PSP', 'PSP_ENC_ASG_IN_PROCESS');
9112 fnd_message.set_token('PROCESS_DESCRIPTION', l_process_description);
9113 g_warning_message := fnd_message.get;
9114
9115 OPEN asg_number_cur (l_termination_date1);
9116 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
9117 CLOSE asg_number_cur;
9118
9119 OPEN payroll_name_cur;
9120 FETCH payroll_name_cur INTO l_payroll_name;
9121 CLOSE payroll_name_cur;
9122
9123 OPEN person_name_cur (l_termination_date1);
9124 FETCH person_name_cur INTO l_full_name;
9125 CLOSE person_name_cur;
9126
9127 OPEN org_name_cur;
9128 FETCH org_name_cur INTO l_organization_name;
9129 CLOSE org_name_cur;
9130
9131 psp_general.add_report_error
9132 (p_request_id => l_request_id,
9133 p_message_level => 'N',
9134 p_source_id => l_assignment_id,
9135 p_source_name => l_assignment_number,
9136 p_parent_source_id => l_person_id,
9137 p_parent_source_name => l_full_name,
9138 p_error_message => g_warning_message,
9139 p_payroll_action_id => p_payroll_action_id,
9140 p_value1 => l_payroll_id,
9141 p_information1 => l_payroll_name,
9142 p_value2 => l_organization_id,
9143 p_information2 => l_organization_name,
9144 p_return_status => l_return_status);
9145 END LOOP;
9146 CLOSE in_process_term_cur;
9147 END IF;
9148
9149 IF (l_person_id2 > 0) THEN
9150 INSERT INTO PSP_ENC_CHANGED_ASSIGNMENTS
9151 (request_id, assignment_id, payroll_id, change_type, payroll_action_id, change_date)
9152 SELECT DISTINCT l_request_id,
9153 pesl.assignment_id,
9154 pesl.payroll_id,
9155 'TR',
9156 p_payroll_action_id,
9157 l_termination_date2
9158 FROM psp_enc_summary_lines pesl
9159 WHERE pesl.person_id = l_person_id2
9160 AND pesl.effective_date >= l_termination_date2
9161 AND pesl.award_id IS NOT NULL
9162 AND pesl.status_code = 'A'
9163 AND NOT EXISTS (SELECT 1
9164 FROM psp_enc_summary_lines pesl2
9165 WHERE pesl2.person_id = l_person_id2
9166 AND pesl2.status_code = 'N');
9167 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Inserted termination assignments into psp_enc_changed_assignments ' || SQL%ROWCOUNT);
9168 IF (SQL%ROWCOUNT = 0) THEN
9169 OPEN in_process_term_cur(l_person_id2);
9170 LOOP
9171 FETCH in_process_term_cur INTO l_assignment_id, l_payroll_id, l_payroll_action_id;
9172 EXIT WHEN in_process_term_cur%NOTFOUND;
9173
9174 OPEN process_descr_cur;
9175 FETCH process_descr_cur INTO l_process_description;
9176 CLOSE process_descr_cur;
9177
9178 fnd_message.set_name('PSP', 'PSP_ENC_ASG_IN_PROCESS');
9179 fnd_message.set_token('PROCESS_DESCRIPTION', l_process_description);
9180 g_warning_message := fnd_message.get;
9181
9182 OPEN asg_number_cur (l_termination_date2);
9183 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
9184 CLOSE asg_number_cur;
9185
9186 OPEN payroll_name_cur;
9187 FETCH payroll_name_cur INTO l_payroll_name;
9188 CLOSE payroll_name_cur;
9189
9190 OPEN person_name_cur (l_termination_date2);
9191 FETCH person_name_cur INTO l_full_name;
9192 CLOSE person_name_cur;
9193
9194 OPEN org_name_cur;
9195 FETCH org_name_cur INTO l_organization_name;
9196 CLOSE org_name_cur;
9197
9198 psp_general.add_report_error
9199 (p_request_id => l_request_id,
9200 p_message_level => 'N',
9201 p_source_id => l_assignment_id,
9202 p_source_name => l_assignment_number,
9203 p_parent_source_id => l_person_id,
9204 p_parent_source_name => l_full_name,
9205 p_error_message => g_warning_message,
9206 p_payroll_action_id => p_payroll_action_id,
9207 p_value1 => l_payroll_id,
9208 p_information1 => l_payroll_name,
9209 p_value2 => l_organization_id,
9210 p_information2 => l_organization_name,
9211 p_return_status => l_return_status);
9212 END LOOP;
9213 CLOSE in_process_term_cur;
9214 END IF;
9215 END IF;
9216
9217 IF (l_person_id3 > 0) THEN
9218 INSERT INTO PSP_ENC_CHANGED_ASSIGNMENTS
9219 (request_id, assignment_id, payroll_id, change_type, payroll_action_id, change_date)
9220 SELECT DISTINCT l_request_id,
9221 pesl.assignment_id,
9222 pesl.payroll_id,
9223 'TR',
9224 p_payroll_action_id,
9225 l_termination_date3
9226 FROM psp_enc_summary_lines pesl
9227 WHERE pesl.person_id = l_person_id3
9228 AND pesl.effective_date >= l_termination_date3
9229 AND pesl.award_id IS NOT NULL
9230 AND pesl.status_code = 'A'
9231 AND NOT EXISTS (SELECT 1
9232 FROM psp_enc_summary_lines pesl2
9233 WHERE pesl2.person_id = l_person_id3
9234 AND pesl2.status_code = 'N');
9235 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Inserted termination assignments into psp_enc_changed_assignments ' || SQL%ROWCOUNT);
9236 IF (SQL%ROWCOUNT = 0) THEN
9237 OPEN in_process_term_cur(l_person_id3);
9238 LOOP
9239 FETCH in_process_term_cur INTO l_assignment_id, l_payroll_id, l_payroll_action_id;
9240 EXIT WHEN in_process_term_cur%NOTFOUND;
9241
9242 OPEN process_descr_cur;
9243 FETCH process_descr_cur INTO l_process_description;
9244 CLOSE process_descr_cur;
9245
9246 fnd_message.set_name('PSP', 'PSP_ENC_ASG_IN_PROCESS');
9247 fnd_message.set_token('PROCESS_DESCRIPTION', l_process_description);
9248 g_warning_message := fnd_message.get;
9249
9250 OPEN asg_number_cur (l_termination_date3);
9251 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
9252 CLOSE asg_number_cur;
9253
9254 OPEN payroll_name_cur;
9255 FETCH payroll_name_cur INTO l_payroll_name;
9256 CLOSE payroll_name_cur;
9257
9258 OPEN person_name_cur (l_termination_date3);
9259 FETCH person_name_cur INTO l_full_name;
9260 CLOSE person_name_cur;
9261
9262 OPEN org_name_cur;
9263 FETCH org_name_cur INTO l_organization_name;
9264 CLOSE org_name_cur;
9265
9266 psp_general.add_report_error
9267 (p_request_id => l_request_id,
9268 p_message_level => 'N',
9269 p_source_id => l_assignment_id,
9270 p_source_name => l_assignment_number,
9271 p_parent_source_id => l_person_id,
9272 p_parent_source_name => l_full_name,
9273 p_error_message => g_warning_message,
9274 p_payroll_action_id => p_payroll_action_id,
9275 p_value1 => l_payroll_id,
9276 p_information1 => l_payroll_name,
9277 p_value2 => l_organization_id,
9278 p_information2 => l_organization_name,
9279 p_return_status => l_return_status);
9280 END LOOP;
9281 CLOSE in_process_term_cur;
9282 END IF;
9283 END IF;
9284
9285 IF (l_person_id4 > 0) THEN
9286 INSERT INTO PSP_ENC_CHANGED_ASSIGNMENTS
9287 (request_id, assignment_id, payroll_id, change_type, payroll_action_id, change_date)
9288 SELECT DISTINCT l_request_id,
9289 pesl.assignment_id,
9290 pesl.payroll_id,
9291 'TR',
9292 p_payroll_action_id,
9293 l_termination_date4
9294 FROM psp_enc_summary_lines pesl
9295 WHERE pesl.person_id = l_person_id4
9296 AND pesl.effective_date >= l_termination_date4
9297 AND pesl.award_id IS NOT NULL
9298 AND pesl.status_code = 'A'
9299 AND NOT EXISTS (SELECT 1
9300 FROM psp_enc_summary_lines pesl2
9301 WHERE pesl2.person_id = l_person_id4
9302 AND pesl2.status_code = 'N');
9303 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Inserted termination assignments into psp_enc_changed_assignments ' || SQL%ROWCOUNT);
9304 IF (SQL%ROWCOUNT = 0) THEN
9305 OPEN in_process_term_cur(l_person_id4);
9306 LOOP
9307 FETCH in_process_term_cur INTO l_assignment_id, l_payroll_id, l_payroll_action_id;
9308 EXIT WHEN in_process_term_cur%NOTFOUND;
9309
9310 OPEN process_descr_cur;
9311 FETCH process_descr_cur INTO l_process_description;
9312 CLOSE process_descr_cur;
9313
9314 fnd_message.set_name('PSP', 'PSP_ENC_ASG_IN_PROCESS');
9315 fnd_message.set_token('PROCESS_DESCRIPTION', l_process_description);
9316 g_warning_message := fnd_message.get;
9317
9318 OPEN asg_number_cur (l_termination_date4);
9319 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
9320 CLOSE asg_number_cur;
9321
9322 OPEN payroll_name_cur;
9323 FETCH payroll_name_cur INTO l_payroll_name;
9324 CLOSE payroll_name_cur;
9325
9326 OPEN person_name_cur (l_termination_date4);
9327 FETCH person_name_cur INTO l_full_name;
9328 CLOSE person_name_cur;
9329
9330 OPEN org_name_cur;
9331 FETCH org_name_cur INTO l_organization_name;
9332 CLOSE org_name_cur;
9333
9334 psp_general.add_report_error
9335 (p_request_id => l_request_id,
9336 p_message_level => 'N',
9337 p_source_id => l_assignment_id,
9338 p_source_name => l_assignment_number,
9339 p_parent_source_id => l_person_id,
9340 p_parent_source_name => l_full_name,
9341 p_error_message => g_warning_message,
9342 p_payroll_action_id => p_payroll_action_id,
9343 p_value1 => l_payroll_id,
9344 p_information1 => l_payroll_name,
9345 p_value2 => l_organization_id,
9346 p_information2 => l_organization_name,
9347 p_return_status => l_return_status);
9348 END LOOP;
9349 CLOSE in_process_term_cur;
9350 END IF;
9351 END IF;
9352
9353 IF (l_person_id5 > 0) THEN
9354 INSERT INTO PSP_ENC_CHANGED_ASSIGNMENTS
9355 (request_id, assignment_id, payroll_id, change_type, payroll_action_id, change_date)
9356 SELECT DISTINCT l_request_id,
9357 pesl.assignment_id,
9358 pesl.payroll_id,
9359 'TR',
9360 p_payroll_action_id,
9361 l_termination_date5
9362 FROM psp_enc_summary_lines pesl
9363 WHERE pesl.person_id = l_person_id5
9364 AND pesl.effective_date >= l_termination_date5
9365 AND pesl.award_id IS NOT NULL
9366 AND pesl.status_code = 'A'
9367 AND NOT EXISTS (SELECT 1
9368 FROM psp_enc_summary_lines pesl2
9369 WHERE pesl2.person_id = l_person_id5
9370 AND pesl2.status_code = 'N');
9371 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Inserted termination assignments into psp_enc_changed_assignments ' || SQL%ROWCOUNT);
9372 IF (SQL%ROWCOUNT = 0) THEN
9373 OPEN in_process_term_cur(l_person_id5);
9374 LOOP
9375 FETCH in_process_term_cur INTO l_assignment_id, l_payroll_id, l_payroll_action_id;
9376 EXIT WHEN in_process_term_cur%NOTFOUND;
9377
9378 OPEN process_descr_cur;
9379 FETCH process_descr_cur INTO l_process_description;
9380 CLOSE process_descr_cur;
9381
9382 fnd_message.set_name('PSP', 'PSP_ENC_ASG_IN_PROCESS');
9383 fnd_message.set_token('PROCESS_DESCRIPTION', l_process_description);
9384 g_warning_message := fnd_message.get;
9385
9386 OPEN asg_number_cur (l_termination_date5);
9387 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
9388 CLOSE asg_number_cur;
9389
9390 OPEN payroll_name_cur;
9391 FETCH payroll_name_cur INTO l_payroll_name;
9392 CLOSE payroll_name_cur;
9393
9394 OPEN person_name_cur (l_termination_date5);
9395 FETCH person_name_cur INTO l_full_name;
9396 CLOSE person_name_cur;
9397
9398 OPEN org_name_cur;
9399 FETCH org_name_cur INTO l_organization_name;
9400 CLOSE org_name_cur;
9401
9402 psp_general.add_report_error
9403 (p_request_id => l_request_id,
9404 p_message_level => 'N',
9405 p_source_id => l_assignment_id,
9406 p_source_name => l_assignment_number,
9407 p_parent_source_id => l_person_id,
9408 p_parent_source_name => l_full_name,
9409 p_error_message => g_warning_message,
9410 p_payroll_action_id => p_payroll_action_id,
9411 p_value1 => l_payroll_id,
9412 p_information1 => l_payroll_name,
9413 p_value2 => l_organization_id,
9414 p_information2 => l_organization_name,
9415 p_return_status => l_return_status);
9416 END LOOP;
9417 CLOSE in_process_term_cur;
9418 END IF;
9419 END IF;
9420 END IF;
9421
9422 COMMIT;
9423 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving ENC_PRE_PROCESS
9424 p_payroll_action_id: ' || p_payroll_action_id || '
9425 p_payroll_id: ' || p_payroll_id || '
9426 p_process_mode: ' || p_process_mode);
9427 p_return_status := fnd_api.g_ret_sts_success;
9428 EXCEPTION
9429 WHEN OTHERS THEN
9430 IF (g_error_message IS NULL) THEN
9431 g_error_message := 'PSP_ENC_PROCESS: ' || SQLERRM;
9432 END IF;
9433 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'ENC_PRE_PROCESS: SQLCODE: ' || fnd_number.number_to_canonical(SQLCODE) || ' SQLERRM: ' || SQLERRM);
9434 psp_message_s.print_error(p_mode => FND_FILE.LOG, p_print_header => FND_API.G_TRUE);
9435 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving ENC_PRE_PROCESS
9436 p_payroll_action_id: ' || p_payroll_action_id || '
9437 p_payroll_id: ' || p_payroll_id || '
9438 p_process_mode: ' || p_process_mode);
9439 p_return_status := fnd_api.g_ret_sts_unexp_error;
9440 END enc_pre_process;
9441
9442 PROCEDURE rollback_cel (errbuf OUT NOCOPY VARCHAR2,
9443 retcode OUT NOCOPY VARCHAR2,
9444 p_payroll_action_id IN NUMBER,
9445 p_person_id1 IN NUMBER,
9446 p_assignment_id1 IN NUMBER,
9447 p_person_id2 IN NUMBER,
9448 p_assignment_id2 IN NUMBER,
9449 p_person_id3 IN NUMBER,
9450 p_assignment_id3 IN NUMBER,
9451 p_person_id4 IN NUMBER,
9452 p_assignment_id4 IN NUMBER,
9453 p_person_id5 IN NUMBER,
9454 p_assignment_id5 IN NUMBER) IS
9455 TYPE t_number_15 IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
9456 TYPE r_superceded_lines_rec IS RECORD
9457 (enc_summary_line_id t_number_15);
9458 t_superceded_lines r_superceded_lines_rec;
9459
9460 l_assignments t_number_15;
9461 l_assignments_tmp t_number_15;
9462
9463 l_assignment_id NUMBER(15);
9464 l_payroll_id NUMBER(15);
9465 l_asg_counter NUMBER(15);
9466
9467 CURSOR asg_cur (p_person_id IN NUMBER,
9468 p_assignment_id IN NUMBER) IS
9469 SELECT DISTINCT pepa.assignment_id
9470 FROM psp_enc_process_assignments pepa,
9471 per_all_assignments_f paf
9472 WHERE pepa.payroll_action_id = p_payroll_action_id
9473 AND paf.person_id = p_person_id
9474 AND paf.assignment_id = pepa.assignment_id
9475 AND ( p_assignment_id IS NULL
9476 OR pepa.assignment_id = p_assignment_id);
9477
9478 CURSOR superceded_line_cur (p_assignment_id IN NUMBER) IS
9479 SELECT superceded_line_id
9480 FROM psp_enc_summary_lines pesl
9481 WHERE pesl.payroll_action_id = p_payroll_action_id
9482 AND pesl.superceded_line_id IS NOT NULL
9483 AND assignment_id = p_assignment_id;
9484
9485 l_request_id NUMBER(15);
9486 BEGIN
9487 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Entering ROLLBACK_CEL p_payroll_action_id: ' || p_payroll_action_id);
9488 l_request_id := fnd_global.conc_request_id;
9489
9490 IF (p_person_id1 IS NULL) THEN
9491 OPEN superceded_line_cur(NULL);
9492 FETCH superceded_line_cur BULK COLLECT INTO t_superceded_lines.enc_summary_line_id;
9493 CLOSE superceded_line_cur;
9494
9495 FORALL recno IN 1..t_superceded_lines.enc_summary_line_id.COUNT
9496 UPDATE psp_enc_lines_history
9497 SET change_flag = 'N'
9498 WHERE enc_summary_line_id = t_superceded_lines.enc_summary_line_id(recno);
9499 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Reverted respective superceded lines in psp_enc_lines_history');
9500
9501 DELETE psp_enc_summary_lines
9502 WHERE payroll_action_id = p_payroll_action_id;
9503 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_summary_lines');
9504
9505 DELETE psp_enc_lines
9506 WHERE payroll_action_id = p_payroll_action_id;
9507 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_lines');
9508
9509 DELETE psp_enc_controls
9510 WHERE payroll_action_id = p_payroll_action_id;
9511 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_controls');
9512
9513 DELETE psp_report_errors
9514 WHERE payroll_action_id = p_payroll_action_id;
9515 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_report_errors');
9516
9517 UPDATE psp_enc_processes
9518 SET process_status = 'B',
9519 process_phase = 'rollback'
9520 WHERE payroll_action_id = p_payroll_action_id;
9521 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process status to ''Rollback'' in psp_enc_processes');
9522
9523 UPDATE psp_enc_process_assignments
9524 SET assignment_status = 'B'
9525 WHERE payroll_action_id = p_payroll_action_id;
9526 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process status to ''Rollback'' in psp_enc_process_assignments');
9527
9528 UPDATE psp_enc_changed_assignments
9529 SET payroll_action_id = NULL
9530 WHERE payroll_action_id = p_payroll_action_id;
9531 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated payroll_action_id in psp_enc_changed_assignments');
9532
9533 INSERT INTO psp_enc_changed_assignments
9534 (request_id, assignment_id, payroll_id, change_type,
9535 processed_flag, reference_id, action_type, change_date)
9536 SELECT l_request_id, pecah.assignment_id, pecah.payroll_id, pecah.change_type,
9537 NULL, NVL(pecah.reference_id, 0), pecah.action_type, change_date
9538 FROM psp_enc_changed_asg_history pecah
9539 WHERE payroll_action_id = p_payroll_action_id
9540 AND action_type NOT IN ('CR', 'LQ', 'TR');
9541 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Copied change assignment records to psp_enc_changed_assignments');
9542
9543 DELETE psp_enc_changed_asg_history
9544 WHERE payroll_action_id = p_payroll_action_id;
9545 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Copied change assignment records to psp_enc_changed_assignments');
9546 ELSE
9547 OPEN asg_cur(p_person_id1, p_assignment_id1);
9548 FETCH asg_cur BULK COLLECT INTO l_assignments;
9549 CLOSE asg_cur;
9550
9551 IF (p_person_id2 IS NOT NULL) THEN
9552 OPEN asg_cur(p_person_id2, p_assignment_id2);
9553 FETCH asg_cur BULK COLLECT INTO l_assignments_tmp;
9554 CLOSE asg_cur;
9555
9556 l_asg_counter := l_assignments.COUNT + 1;
9557 FOR recno IN 1..l_assignments_tmp.COUNT
9558 LOOP
9559 l_assignments(l_asg_counter) := l_assignments_tmp(recno);
9560 l_asg_counter := l_asg_counter + 1;
9561 END LOOP;
9562 l_assignments_tmp.DELETE;
9563 END IF;
9564
9565 IF (p_person_id3 IS NOT NULL) THEN
9566 OPEN asg_cur(p_person_id3, p_assignment_id3);
9567 FETCH asg_cur BULK COLLECT INTO l_assignments_tmp;
9568 CLOSE asg_cur;
9569
9570 l_asg_counter := l_assignments.COUNT + 1;
9571 FOR recno IN 1..l_assignments_tmp.COUNT
9572 LOOP
9573 l_assignments(l_asg_counter) := l_assignments_tmp(recno);
9574 l_asg_counter := l_asg_counter + 1;
9575 END LOOP;
9576 l_assignments_tmp.DELETE;
9577 END IF;
9578
9579 IF (p_person_id4 IS NOT NULL) THEN
9580 OPEN asg_cur(p_person_id4, p_assignment_id4);
9581 FETCH asg_cur BULK COLLECT INTO l_assignments_tmp;
9582 CLOSE asg_cur;
9583
9584 l_asg_counter := l_assignments.COUNT + 1;
9585 FOR recno IN 1..l_assignments_tmp.COUNT
9586 LOOP
9587 l_assignments(l_asg_counter) := l_assignments_tmp(recno);
9588 l_asg_counter := l_asg_counter + 1;
9589 END LOOP;
9590 l_assignments_tmp.DELETE;
9591 END IF;
9592
9593 IF (p_person_id5 IS NOT NULL) THEN
9594 OPEN asg_cur(p_person_id5, p_assignment_id5);
9595 FETCH asg_cur BULK COLLECT INTO l_assignments_tmp;
9596 CLOSE asg_cur;
9597
9598 l_asg_counter := l_assignments.COUNT + 1;
9599 FOR recno IN 1..l_assignments_tmp.COUNT
9600 LOOP
9601 l_assignments(l_asg_counter) := l_assignments_tmp(recno);
9602 l_asg_counter := l_asg_counter + 1;
9603 END LOOP;
9604 l_assignments_tmp.DELETE;
9605 END IF;
9606
9607 FOR recno IN 1..l_assignments.COUNT
9608 LOOP
9609 OPEN superceded_line_cur(l_assignments(recno));
9610 FETCH superceded_line_cur BULK COLLECT INTO t_superceded_lines.enc_summary_line_id;
9611 CLOSE superceded_line_cur;
9612
9613 FORALL recno IN 1..t_superceded_lines.enc_summary_line_id.COUNT
9614 UPDATE psp_enc_lines_history
9615 SET change_flag = 'N'
9616 WHERE enc_summary_line_id = t_superceded_lines.enc_summary_line_id(recno);
9617 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Reverted respective superceded lines in psp_enc_lines_history');
9618
9619 DELETE psp_enc_summary_lines
9620 WHERE payroll_action_id = p_payroll_action_id
9621 AND assignment_id = l_assignments(recno);
9622 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_summary_lines');
9623
9624 DELETE psp_enc_lines
9625 WHERE payroll_action_id = p_payroll_action_id
9626 AND assignment_id = l_assignments(recno);
9627 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_lines');
9628
9629 DELETE psp_enc_controls pec
9630 WHERE payroll_action_id = p_payroll_action_id
9631 AND NOT EXISTS (SELECT 1
9632 FROM psp_enc_lines pel
9633 WHERE payroll_action_id = p_payroll_action_id
9634 AND pel.enc_control_id = pec.enc_control_id);
9635 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_controls');
9636
9637 DELETE psp_report_errors
9638 WHERE payroll_action_id = p_payroll_action_id
9639 AND source_id = l_assignments(recno);
9640 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_report_errors');
9641
9642 UPDATE psp_enc_process_assignments
9643 SET assignment_status = 'B'
9644 WHERE payroll_action_id = p_payroll_action_id
9645 AND assignment_id = l_assignments(recno);
9646 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated assignment status to ''Rollback'' in psp_enc_process_assignments');
9647
9648 UPDATE psp_enc_changed_assignments
9649 SET payroll_action_id = NULL
9650 WHERE payroll_action_id = p_payroll_action_id
9651 AND assignment_id = l_assignments(recno);
9652 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated payroll_action_id in psp_enc_changed_assignments');
9653
9654 INSERT INTO psp_enc_changed_assignments
9655 (request_id, assignment_id, payroll_id, change_type,
9656 processed_flag, reference_id, action_type, change_date)
9657 SELECT l_request_id, pecah.assignment_id, pecah.payroll_id, pecah.change_type,
9658 NULL, NVL(pecah.reference_id, 0), pecah.action_type, change_date
9659 FROM psp_enc_changed_asg_history pecah
9660 WHERE payroll_action_id = p_payroll_action_id
9661 AND assignment_id = l_assignments(recno)
9662 AND action_type NOT IN ('CR', 'LQ', 'TR');
9663 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Copied change assignment records to psp_enc_changed_assignments');
9664
9665 DELETE psp_enc_changed_asg_history
9666 WHERE payroll_action_id = p_payroll_action_id
9667 AND assignment_id = l_assignments(recno);
9668 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Copied change assignment records to psp_enc_changed_assignments');
9669 END LOOP;
9670
9671 UPDATE psp_enc_processes
9672 SET process_status = 'B',
9673 process_phase = 'rollback'
9674 WHERE payroll_action_id = p_payroll_action_id
9675 AND NOT EXISTS (SELECT 1
9676 FROM psp_enc_summary_lines
9677 WHERE payroll_action_id = p_payroll_action_id);
9678 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process status to ''Rollback'' in psp_enc_processes');
9679 END IF;
9680
9681 COMMIT;
9682 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving ROLLBACK_CEL p_payroll_action_id: ' || p_payroll_action_id);
9683 retcode := fnd_api.g_ret_sts_success;
9684 EXCEPTION
9685 WHEN OTHERS THEN
9686 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'ROLLBACK_CEL: SQLCODE: ' || fnd_number.number_to_canonical(SQLCODE) || ' SQLERRM: ' || SQLERRM);
9687 psp_message_s.print_error(p_mode => FND_FILE.LOG, p_print_header => FND_API.G_TRUE);
9688 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving ROLLBACK_CEL p_payroll_action_id: ' || p_payroll_action_id);
9689 retcode := fnd_api.g_ret_sts_unexp_error;
9690 END rollback_cel;
9691
9692 PROCEDURE load_sch_hierarchy (p_assignment_id IN NUMBER,
9693 p_payroll_id IN NUMBER,
9694 p_element_type_id IN NUMBER,
9695 p_business_group_id IN NUMBER,
9696 p_set_of_books_id IN NUMBER,
9697 p_return_status OUT NOCOPY VARCHAR2) IS
9698 l_proc_name VARCHAR2(61) DEFAULT g_package_name || 'LOAD_SCH_HIERARCHY';
9699 l_proc_step NUMBER(20,10);
9700 r_sa_tmp r_schedule_line_type;
9701 r_gsa r_schedule_line_type;
9702 l_min_start_date DATE;
9703 l_max_end_date DATE;
9704
9705 CURSOR global_element_cur IS
9706 SELECT peta.element_account_id,
9707 peta.gl_code_combination_id,
9708 peta.project_id,
9709 peta.task_id,
9710 peta.award_id,
9711 peta.expenditure_type,
9712 peta.expenditure_organization_id,
9713 peta.start_date_active,
9714 peta.end_date_active,
9715 peta.poeta_start_date,
9716 peta.poeta_end_date,
9717 peta.percent,
9718 DECODE(g_dff_grouping_option, 'Y', peta.attribute_category, NULL),
9719 DECODE(g_dff_grouping_option, 'Y', peta.attribute1, NULL),
9720 DECODE(g_dff_grouping_option, 'Y', peta.attribute2, NULL),
9721 DECODE(g_dff_grouping_option, 'Y', peta.attribute3, NULL),
9722 DECODE(g_dff_grouping_option, 'Y', peta.attribute4, NULL),
9723 DECODE(g_dff_grouping_option, 'Y', peta.attribute5, NULL),
9724 DECODE(g_dff_grouping_option, 'Y', peta.attribute6, NULL),
9725 DECODE(g_dff_grouping_option, 'Y', peta.attribute7, NULL),
9726 DECODE(g_dff_grouping_option, 'Y', peta.attribute8, NULL),
9727 DECODE(g_dff_grouping_option, 'Y', peta.attribute9, NULL),
9728 DECODE(g_dff_grouping_option, 'Y', peta.attribute10, NULL),
9729 DECODE(peta.expenditure_type, NULL, 'N', 'E') acct_type
9730 FROM psp_element_type_accounts peta
9731 WHERE peta.element_type_id = p_element_type_id
9732 AND peta.business_group_id = p_business_group_id
9733 AND peta.set_of_books_id = p_set_of_books_id
9734 AND ( peta.gl_code_combination_id IS NOT NULL
9735 OR peta.award_id IS NOT NULL)
9736 AND peta.end_date_active >= l_min_start_date
9737 AND peta.start_date_active <= g_enc_org_end_date
9738 ORDER BY peta.start_date_active, peta.end_date_active;
9739
9740 CURSOR sch_lines_element_type_cur IS
9741 SELECT psl.schedule_line_id,
9742 psl.gl_code_combination_id,
9743 psl.project_id,
9744 psl.task_id,
9745 psl.award_id,
9746 psl.expenditure_type,
9747 psl.expenditure_organization_id,
9748 psl.schedule_begin_date,
9749 psl.schedule_end_date,
9750 psl.poeta_start_date,
9751 psl.poeta_end_date,
9752 psl.schedule_percent,
9753 DECODE(g_dff_grouping_option, 'Y', psl.attribute_category, NULL),
9754 DECODE(g_dff_grouping_option, 'Y', psl.attribute1, NULL),
9755 DECODE(g_dff_grouping_option, 'Y', psl.attribute2, NULL),
9756 DECODE(g_dff_grouping_option, 'Y', psl.attribute3, NULL),
9757 DECODE(g_dff_grouping_option, 'Y', psl.attribute4, NULL),
9758 DECODE(g_dff_grouping_option, 'Y', psl.attribute5, NULL),
9759 DECODE(g_dff_grouping_option, 'Y', psl.attribute6, NULL),
9760 DECODE(g_dff_grouping_option, 'Y', psl.attribute7, NULL),
9761 DECODE(g_dff_grouping_option, 'Y', psl.attribute8, NULL),
9762 DECODE(g_dff_grouping_option, 'Y', psl.attribute9, NULL),
9763 DECODE(g_dff_grouping_option, 'Y', psl.attribute10, NULL),
9764 DECODE(psl.expenditure_type, NULL, 'N', 'E') acct_type
9765 FROM psp_schedule_hierarchy psh,
9766 psp_schedule_lines psl
9767 WHERE psh.assignment_id = p_assignment_id
9768 AND psh.element_type_id = p_element_type_id
9769 AND psh.business_group_id = p_business_group_id
9770 AND psh.set_of_books_id = p_set_of_books_id
9771 AND psh.schedule_hierarchy_id = psl.schedule_hierarchy_id
9772 AND ( psl.gl_code_combination_id IS NOT NULL
9773 OR psl.award_id IS NOT NULL )
9774 AND psl.schedule_begin_date <= g_enc_org_end_date
9775 AND psl.schedule_end_date >= l_min_start_date
9776 AND psl.default_flag IS NULL
9777 ORDER BY psl.schedule_begin_date, psl.schedule_end_date;
9778
9779 CURSOR sch_lines_element_class_cur IS
9780 SELECT psl.schedule_line_id,
9781 psl.gl_code_combination_id,
9782 psl.project_id,
9783 psl.task_id,
9784 psl.award_id,
9785 psl.expenditure_type,
9786 psl.expenditure_organization_id,
9787 psl.schedule_begin_date,
9788 psl.schedule_end_date,
9789 psl.poeta_start_date,
9790 psl.poeta_end_date,
9791 psl.schedule_percent,
9792 DECODE(g_dff_grouping_option, 'Y', psl.attribute_category, NULL),
9793 DECODE(g_dff_grouping_option, 'Y', psl.attribute1, NULL),
9794 DECODE(g_dff_grouping_option, 'Y', psl.attribute2, NULL),
9795 DECODE(g_dff_grouping_option, 'Y', psl.attribute3, NULL),
9796 DECODE(g_dff_grouping_option, 'Y', psl.attribute4, NULL),
9797 DECODE(g_dff_grouping_option, 'Y', psl.attribute5, NULL),
9798 DECODE(g_dff_grouping_option, 'Y', psl.attribute6, NULL),
9799 DECODE(g_dff_grouping_option, 'Y', psl.attribute7, NULL),
9800 DECODE(g_dff_grouping_option, 'Y', psl.attribute8, NULL),
9801 DECODE(g_dff_grouping_option, 'Y', psl.attribute9, NULL),
9802 DECODE(g_dff_grouping_option, 'Y', psl.attribute10, NULL),
9803 DECODE(psl.expenditure_type, NULL, 'N', 'E') acct_type
9804 FROM psp_element_types pet,
9805 psp_group_element_list pgel,
9806 psp_schedule_hierarchy psh,
9807 psp_schedule_lines psl
9808 WHERE pet.element_type_id = p_element_type_id
9809 AND pet.business_group_id = p_business_group_id
9810 AND pet.set_of_books_id = p_set_of_books_id
9811 AND pet.start_date_active <= g_enc_org_end_date
9812 AND pet.end_date_active >= l_min_start_date
9813 AND pet.element_type_id = pgel.element_type_id
9814 AND psh.business_group_id = p_business_group_id
9815 AND psh.set_of_books_id = p_set_of_books_id
9816 AND pgel.element_group_id = psh.element_group_id
9817 AND psh.assignment_id = p_assignment_id
9818 AND psh.schedule_hierarchy_id = psl.schedule_hierarchy_id
9819 AND ( psl.gl_code_combination_id IS NOT NULL
9820 OR psl.award_id IS NOT NULL)
9821 AND psl.schedule_begin_date <= pet.end_date_active
9822 AND psl.schedule_end_date >= pet.start_date_active
9823 AND psl.default_flag IS NULL
9824 ORDER BY psl.schedule_begin_date, psl.schedule_end_date;
9825
9826 CURSOR sch_lines_assignment_cur IS
9827 SELECT psl.schedule_line_id,
9828 psl.gl_code_combination_id,
9829 psl.project_id,
9830 psl.task_id,
9831 psl.award_id,
9832 psl.expenditure_type,
9833 psl.expenditure_organization_id,
9834 psl.schedule_begin_date,
9835 psl.schedule_end_date,
9836 psl.poeta_start_date,
9837 psl.poeta_end_date,
9838 psl.schedule_percent,
9839 DECODE(g_dff_grouping_option, 'Y', psl.attribute_category, NULL),
9840 DECODE(g_dff_grouping_option, 'Y', psl.attribute1, NULL),
9841 DECODE(g_dff_grouping_option, 'Y', psl.attribute2, NULL),
9842 DECODE(g_dff_grouping_option, 'Y', psl.attribute3, NULL),
9843 DECODE(g_dff_grouping_option, 'Y', psl.attribute4, NULL),
9844 DECODE(g_dff_grouping_option, 'Y', psl.attribute5, NULL),
9845 DECODE(g_dff_grouping_option, 'Y', psl.attribute6, NULL),
9846 DECODE(g_dff_grouping_option, 'Y', psl.attribute7, NULL),
9847 DECODE(g_dff_grouping_option, 'Y', psl.attribute8, NULL),
9848 DECODE(g_dff_grouping_option, 'Y', psl.attribute9, NULL),
9849 DECODE(g_dff_grouping_option, 'Y', psl.attribute10, NULL),
9850 DECODE(psl.expenditure_type, NULL, 'N', 'E') acct_type
9851 FROM psp_schedule_hierarchy psh,
9852 psp_schedule_lines psl
9853 WHERE psh.scheduling_types_code = 'A'
9854 AND psh.element_group_id IS NULL
9855 AND psh.element_type_id IS NULL
9856 AND psh.assignment_id = p_assignment_id
9857 AND psh.business_group_id = p_business_group_id
9858 AND psh.set_of_books_id = p_set_of_books_id
9859 AND psh.schedule_hierarchy_id = psl.schedule_hierarchy_id
9860 AND ( psl.gl_code_combination_id IS NOT NULL
9861 OR psl.award_id IS NOT NULL)
9862 AND psl.schedule_begin_date <= g_enc_org_end_date
9863 AND psl.schedule_end_date >= l_min_start_date
9864 AND psl.default_flag IS NULL
9865 ORDER BY psl.schedule_begin_date, psl.schedule_end_date;
9866
9867 CURSOR asg_org_cur IS
9868 SELECT organization_id,
9869 effective_start_date,
9870 NVL(LEAD(effective_start_date - 1) OVER (ORDER BY effective_end_date), LEAST(l_max_end_date, effective_end_date))
9871 FROM per_assignments_f paf
9872 WHERE assignment_id = p_assignment_id
9873 AND payroll_id = p_payroll_id
9874 AND effective_start_date <= LEAST(l_max_end_date, g_enc_org_end_date)
9875 ANd effective_end_date >= l_min_start_date
9876 AND effective_start_date = (SELECT MIN(paf2.effective_start_date)
9877 FROM per_assignments_f paf2
9878 WHERE paf2.assignment_id = p_assignment_id
9879 AND paf2.payroll_id = paf.payroll_id
9880 AND paf2.organization_id = paf.organization_id
9881 AND paf2.effective_start_date >= paf.effective_start_date);
9882
9883 TYPE r_asg_org_type IS RECORD
9884 (organization_id t_num_15_type,
9885 start_date t_date_type,
9886 end_date t_date_type);
9887 r_asg_org r_asg_org_type;
9888
9889 CURSOR org_labor_schedule_cur (p_organization_id IN NUMBER,
9890 p_org_start_date IN DATE,
9891 p_org_end_date IN DATE) IS
9892 SELECT pdls.org_schedule_id,
9893 pdls.gl_code_combination_id,
9894 pdls.project_id,
9895 pdls.task_id,
9896 pdls.award_id,
9897 pdls.expenditure_type,
9898 pdls.expenditure_organization_id,
9899 GREATEST(pdls.schedule_begin_date, p_org_start_date),
9900 LEAST(pdls.schedule_end_date, p_org_end_date),
9901 pdls.poeta_start_date,
9902 pdls.poeta_end_date,
9903 pdls.schedule_percent,
9904 DECODE(g_dff_grouping_option, 'Y', pdls.attribute_category, NULL),
9905 DECODE(g_dff_grouping_option, 'Y', pdls.attribute1, NULL),
9906 DECODE(g_dff_grouping_option, 'Y', pdls.attribute2, NULL),
9907 DECODE(g_dff_grouping_option, 'Y', pdls.attribute3, NULL),
9908 DECODE(g_dff_grouping_option, 'Y', pdls.attribute4, NULL),
9909 DECODE(g_dff_grouping_option, 'Y', pdls.attribute5, NULL),
9910 DECODE(g_dff_grouping_option, 'Y', pdls.attribute6, NULL),
9911 DECODE(g_dff_grouping_option, 'Y', pdls.attribute7, NULL),
9912 DECODE(g_dff_grouping_option, 'Y', pdls.attribute8, NULL),
9913 DECODE(g_dff_grouping_option, 'Y', pdls.attribute9, NULL),
9914 DECODE(g_dff_grouping_option, 'Y', pdls.attribute10, NULL),
9915 DECODE(pdls.expenditure_type, NULL, 'N', 'E') acct_type
9916 FROM psp_default_labor_schedules pdls
9917 WHERE pdls.business_group_id = p_business_group_id
9918 AND pdls.set_of_books_id = p_set_of_books_id
9919 AND pdls.organization_id = p_organization_id
9920 AND ( pdls.gl_code_combination_id IS NOT NULL
9921 OR pdls.award_id IS NOT NULL)
9922 AND pdls.schedule_begin_date <= p_org_end_date
9923 AND pdls.schedule_end_date >= p_org_start_date
9924 ORDER BY GREATEST(pdls.schedule_begin_date, p_org_start_date), LEAST(pdls.schedule_end_date, p_org_end_date);
9925
9926 CURSOR default_account_cur (p_organization_id IN NUMBER,
9927 p_org_start_date IN DATE,
9928 p_org_end_date IN DATE) IS
9929 SELECT poa.organization_account_id,
9930 poa.gl_code_combination_id,
9931 poa.project_id,
9932 poa.task_id,
9933 poa.award_id,
9934 poa.expenditure_type,
9935 poa.expenditure_organization_id,
9936 GREATEST(poa.start_date_active, p_org_start_date),
9937 LEAST(poa.end_date_active, p_org_end_date),
9938 poa.poeta_start_date,
9939 poa.poeta_end_date,
9940 100 percent,
9941 DECODE(g_dff_grouping_option, 'Y', poa.attribute_category, NULL),
9942 DECODE(g_dff_grouping_option, 'Y', poa.attribute1, NULL),
9943 DECODE(g_dff_grouping_option, 'Y', poa.attribute2, NULL),
9944 DECODE(g_dff_grouping_option, 'Y', poa.attribute3, NULL),
9945 DECODE(g_dff_grouping_option, 'Y', poa.attribute4, NULL),
9946 DECODE(g_dff_grouping_option, 'Y', poa.attribute5, NULL),
9947 DECODE(g_dff_grouping_option, 'Y', poa.attribute6, NULL),
9948 DECODE(g_dff_grouping_option, 'Y', poa.attribute7, NULL),
9949 DECODE(g_dff_grouping_option, 'Y', poa.attribute8, NULL),
9950 DECODE(g_dff_grouping_option, 'Y', poa.attribute9, NULL),
9951 DECODE(g_dff_grouping_option, 'Y', poa.attribute10, NULL),
9952 DECODE(poa.expenditure_type, NULL, 'N', 'E') acct_type
9953 FROM psp_organization_accounts poa
9954 WHERE poa.organization_id = p_organization_id
9955 AND poa.business_group_id = p_business_group_id
9956 AND poa.set_of_books_id = p_set_of_books_id
9957 AND poa.account_type_code = 'D'
9958 AND poa.start_date_active <= p_org_end_date
9959 AND poa.end_date_active >= p_org_start_date
9960 AND ( poa.gl_code_combination_id IS NOT NULL
9961 OR poa.award_id IS NOT NULL)
9962 ORDER BY GREATEST(poa.start_date_active, p_org_start_date), LEAST(poa.end_date_active, p_org_end_date);
9963
9964
9965 CURSOR suspense_account_cur (p_organization_id IN NUMBER,
9966 p_org_start_date IN DATE,
9967 p_org_end_date IN DATE) IS
9968 SELECT poa.organization_account_id,
9969 poa.gl_code_combination_id,
9970 poa.project_id,
9971 poa.task_id,
9972 poa.award_id,
9973 poa.expenditure_type,
9974 poa.expenditure_organization_id,
9975 GREATEST(poa.start_date_active, p_org_start_date),
9976 LEAST(poa.end_date_active, p_org_end_date),
9977 poa.poeta_start_date,
9978 poa.poeta_end_date,
9979 100 percent,
9980 DECODE(g_dff_grouping_option, 'Y', poa.attribute_category, NULL),
9981 DECODE(g_dff_grouping_option, 'Y', poa.attribute1, NULL),
9982 DECODE(g_dff_grouping_option, 'Y', poa.attribute2, NULL),
9983 DECODE(g_dff_grouping_option, 'Y', poa.attribute3, NULL),
9984 DECODE(g_dff_grouping_option, 'Y', poa.attribute4, NULL),
9985 DECODE(g_dff_grouping_option, 'Y', poa.attribute5, NULL),
9986 DECODE(g_dff_grouping_option, 'Y', poa.attribute6, NULL),
9987 DECODE(g_dff_grouping_option, 'Y', poa.attribute7, NULL),
9988 DECODE(g_dff_grouping_option, 'Y', poa.attribute8, NULL),
9989 DECODE(g_dff_grouping_option, 'Y', poa.attribute9, NULL),
9990 DECODE(g_dff_grouping_option, 'Y', poa.attribute10, NULL),
9991 DECODE(poa.expenditure_type, NULL, 'N', 'E') acct_type
9992 FROM psp_organization_accounts poa
9993 WHERE poa.organization_id = p_organization_id
9994 AND poa.business_group_id = p_business_group_id
9995 AND poa.set_of_books_id = p_set_of_books_id
9996 AND poa.account_type_code = 'S'
9997 AND poa.start_date_active <= p_org_end_date
9998 AND poa.end_date_active >= p_org_start_date
9999 AND ( poa.gl_code_combination_id IS NOT NULL
10000 OR poa.award_id IS NOT NULL)
10001 ORDER BY GREATEST(poa.start_date_active, p_org_start_date), LEAST(poa.end_date_active, p_org_end_date);
10002
10003
10004 CURSOR generic_suspense_cur IS
10005 SELECT poa.organization_account_id,
10006 poa.gl_code_combination_id,
10007 poa.project_id,
10008 poa.task_id,
10009 poa.award_id,
10010 poa.expenditure_type,
10011 poa.expenditure_organization_id,
10012 poa.start_date_active,
10013 poa.end_date_active,
10014 poa.poeta_start_date,
10015 poa.poeta_end_date,
10016 100 percent,
10017 DECODE(g_dff_grouping_option, 'Y', poa.attribute_category, NULL),
10018 DECODE(g_dff_grouping_option, 'Y', poa.attribute1, NULL),
10019 DECODE(g_dff_grouping_option, 'Y', poa.attribute2, NULL),
10020 DECODE(g_dff_grouping_option, 'Y', poa.attribute3, NULL),
10021 DECODE(g_dff_grouping_option, 'Y', poa.attribute4, NULL),
10022 DECODE(g_dff_grouping_option, 'Y', poa.attribute5, NULL),
10023 DECODE(g_dff_grouping_option, 'Y', poa.attribute6, NULL),
10024 DECODE(g_dff_grouping_option, 'Y', poa.attribute7, NULL),
10025 DECODE(g_dff_grouping_option, 'Y', poa.attribute8, NULL),
10026 DECODE(g_dff_grouping_option, 'Y', poa.attribute9, NULL),
10027 DECODE(g_dff_grouping_option, 'Y', poa.attribute10, NULL),
10028 DECODE(poa.expenditure_type, NULL, 'N', 'E') acct_type
10029 FROM psp_organization_accounts poa
10030 WHERE poa.business_group_id = p_business_group_id
10031 AND poa.set_of_books_id = p_set_of_books_id
10032 AND poa.account_type_code = 'G'
10033 AND poa.start_date_active <= g_enc_org_end_date
10034 AND poa.end_date_active >= l_min_start_date
10035 AND ( poa.gl_code_combination_id IS NOT NULL
10036 OR poa.award_id IS NOT NULL)
10037 ORDER BY poa.start_date_active, poa.end_date_active;
10038 BEGIN
10039 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering LOAD_SCH_HIERARCHY p_assignment_id: ' || fnd_number.number_to_canonical(p_assignment_id) || '
10040 p_element_type_id: ' || fnd_number.number_to_canonical(p_element_type_id) || '
10041 p_business_group_id: ' || fnd_number.number_to_canonical(p_business_group_id) || '
10042 p_set_of_books_id: ' || fnd_number.number_to_canonical(p_set_of_books_id));
10043
10044 clear_sch_hierarchy;
10045
10046 l_min_start_date := r_enc_period.r_asg_start_date(1);
10047 l_max_end_date := r_enc_period.r_asg_end_date(r_enc_period.r_period_end_date.COUNT);
10048
10049 OPEN global_element_cur;
10050 FETCH global_element_cur BULK COLLECT INTO r_gee.line_account_id,
10051 r_gee.gl_code_combination_id, r_gee.project_id,
10052 r_gee.task_id, r_gee.award_id,
10053 r_gee.expenditure_type, r_gee.expenditure_organization_id,
10054 r_gee.start_date_active, r_gee.end_date_active,
10055 r_gee.poeta_start_date, r_gee.poeta_end_date,
10056 r_gee.percent, r_gee.attribute_category,
10057 r_gee.attribute1, r_gee.attribute2,
10058 r_gee.attribute3, r_gee.attribute4,
10059 r_gee.attribute5, r_gee.attribute6,
10060 r_gee.attribute7, r_gee.attribute8,
10061 r_gee.attribute9, r_gee.attribute10, r_gee.acct_type;
10062 CLOSE global_element_cur;
10063 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_gee.line_account_id.COUNT: ' || r_gee.line_account_id.COUNT);
10064
10065 OPEN sch_lines_element_type_cur;
10066 FETCH sch_lines_element_type_cur BULK COLLECT INTO r_et.line_account_id,
10067 r_et.gl_code_combination_id, r_et.project_id,
10068 r_et.task_id, r_et.award_id,
10069 r_et.expenditure_type, r_et.expenditure_organization_id,
10070 r_et.start_date_active, r_et.end_date_active,
10071 r_et.poeta_start_date, r_et.poeta_end_date,
10072 r_et.percent, r_et.attribute_category,
10073 r_et.attribute1, r_et.attribute2,
10074 r_et.attribute3, r_et.attribute4,
10075 r_et.attribute5, r_et.attribute6,
10076 r_et.attribute7, r_et.attribute8,
10077 r_et.attribute9, r_et.attribute10, r_et.acct_type;
10078 CLOSE sch_lines_element_type_cur;
10079 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_et.line_account_id.COUNT: ' || r_et.line_account_id.COUNT);
10080
10081 OPEN sch_lines_element_class_cur;
10082 FETCH sch_lines_element_class_cur BULK COLLECT INTO r_ec.line_account_id,
10083 r_ec.gl_code_combination_id, r_ec.project_id,
10084 r_ec.task_id, r_ec.award_id,
10085 r_ec.expenditure_type, r_ec.expenditure_organization_id,
10086 r_ec.start_date_active, r_ec.end_date_active,
10087 r_ec.poeta_start_date, r_ec.poeta_end_date,
10088 r_ec.percent, r_ec.attribute_category,
10089 r_ec.attribute1, r_ec.attribute2,
10090 r_ec.attribute3, r_ec.attribute4,
10091 r_ec.attribute5, r_ec.attribute6,
10092 r_ec.attribute7, r_ec.attribute8,
10093 r_ec.attribute9, r_ec.attribute10, r_ec.acct_type;
10094 CLOSE sch_lines_element_class_cur;
10095 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_ec.line_account_id.COUNT: ' || r_ec.line_account_id.COUNT);
10096
10097 OPEN sch_lines_assignment_cur;
10098 FETCH sch_lines_assignment_cur BULK COLLECT INTO r_asg.line_account_id,
10099 r_asg.gl_code_combination_id, r_asg.project_id,
10100 r_asg.task_id, r_asg.award_id,
10101 r_asg.expenditure_type, r_asg.expenditure_organization_id,
10102 r_asg.start_date_active, r_asg.end_date_active,
10103 r_asg.poeta_start_date, r_asg.poeta_end_date,
10104 r_asg.percent, r_asg.attribute_category,
10105 r_asg.attribute1, r_asg.attribute2,
10106 r_asg.attribute3, r_asg.attribute4,
10107 r_asg.attribute5, r_asg.attribute6,
10108 r_asg.attribute7, r_asg.attribute8,
10109 r_asg.attribute9, r_asg.attribute10, r_asg.acct_type;
10110 CLOSE sch_lines_assignment_cur;
10111 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_asg.line_account_id.COUNT: ' || r_asg.line_account_id.COUNT);
10112
10113 OPEN asg_org_cur;
10114 FETCH asg_org_cur BULK COLLECT INTO r_asg_org.organization_id, r_asg_org.start_date, r_asg_org.end_date;
10115 CLOSE asg_org_cur;
10116
10117 g_odls_pointer := 0;
10118 g_da_pointer := 0;
10119 g_sa_pointer := 0;
10120
10121 FOR recno IN 1..r_asg_org.organization_id.COUNT
10122 LOOP
10123 OPEN org_labor_schedule_cur (r_asg_org.organization_id(recno),
10124 r_asg_org.start_date(recno), r_asg_org.end_date(recno));
10125 FETCH org_labor_schedule_cur BULK COLLECT INTO r_gsa.line_account_id,
10126 r_gsa.gl_code_combination_id, r_gsa.project_id,
10127 r_gsa.task_id, r_gsa.award_id,
10128 r_gsa.expenditure_type, r_gsa.expenditure_organization_id,
10129 r_gsa.start_date_active, r_gsa.end_date_active,
10130 r_gsa.poeta_start_date, r_gsa.poeta_end_date,
10131 r_gsa.percent, r_gsa.attribute_category,
10132 r_gsa.attribute1, r_gsa.attribute2,
10133 r_gsa.attribute3, r_gsa.attribute4,
10134 r_gsa.attribute5, r_gsa.attribute6,
10135 r_gsa.attribute7, r_gsa.attribute8,
10136 r_gsa.attribute9, r_gsa.attribute10, r_gsa.acct_type;
10137 CLOSE org_labor_schedule_cur;
10138
10139 FOR recno2 IN 1..r_gsa.line_account_id.COUNT
10140 LOOP
10141 g_odls_pointer := g_odls_pointer + 1;
10142 r_odls.line_account_id(g_odls_pointer) := r_gsa.line_account_id(recno2);
10143 r_odls.gl_code_combination_id(g_odls_pointer) := r_gsa.gl_code_combination_id(recno2);
10144 r_odls.project_id(g_odls_pointer) := r_gsa.project_id(recno2);
10145 r_odls.task_id(g_odls_pointer) := r_gsa.task_id(recno2);
10146 r_odls.award_id(g_odls_pointer) := r_gsa.award_id(recno2);
10147 r_odls.expenditure_type(g_odls_pointer) := r_gsa.expenditure_type(recno2);
10148 r_odls.expenditure_organization_id(g_odls_pointer) := r_gsa.expenditure_organization_id(recno2);
10149 r_odls.start_date_active(g_odls_pointer) := r_gsa.start_date_active(recno2);
10150 r_odls.end_date_active(g_odls_pointer) := r_gsa.end_date_active(recno2);
10151 r_odls.poeta_start_date(g_odls_pointer) := r_gsa.poeta_start_date(recno2);
10152 r_odls.poeta_end_date(g_odls_pointer) := r_gsa.poeta_end_date(recno2);
10153 r_odls.percent(g_odls_pointer) := r_gsa.percent(recno2);
10154 r_odls.attribute_category(g_odls_pointer) := r_gsa.attribute_category(recno2);
10155 r_odls.attribute1(g_odls_pointer) := r_gsa.attribute1(recno2);
10156 r_odls.attribute2(g_odls_pointer) := r_gsa.attribute2(recno2);
10157 r_odls.attribute3(g_odls_pointer) := r_gsa.attribute3(recno2);
10158 r_odls.attribute4(g_odls_pointer) := r_gsa.attribute4(recno2);
10159 r_odls.attribute5(g_odls_pointer) := r_gsa.attribute5(recno2);
10160 r_odls.attribute6(g_odls_pointer) := r_gsa.attribute6(recno2);
10161 r_odls.attribute7(g_odls_pointer) := r_gsa.attribute7(recno2);
10162 r_odls.attribute8(g_odls_pointer) := r_gsa.attribute8(recno2);
10163 r_odls.attribute9(g_odls_pointer) := r_gsa.attribute9(recno2);
10164 r_odls.attribute10(g_odls_pointer) := r_gsa.attribute10(recno2);
10165 r_odls.acct_type(g_odls_pointer) := r_gsa.acct_type(recno2);
10166 END LOOP;
10167
10168 r_gsa.line_account_id.DELETE;
10169 r_gsa.gl_code_combination_id.DELETE;
10170 r_gsa.project_id.DELETE;
10171 r_gsa.task_id.DELETE;
10172 r_gsa.award_id.DELETE;
10173 r_gsa.expenditure_type.DELETE;
10174 r_gsa.expenditure_organization_id.DELETE;
10175 r_gsa.start_date_active.DELETE;
10176 r_gsa.end_date_active.DELETE;
10177 r_gsa.poeta_start_date.DELETE;
10178 r_gsa.poeta_end_date.DELETE;
10179 r_gsa.percent.DELETE;
10180 r_gsa.attribute_category.DELETE;
10181 r_gsa.attribute1.DELETE;
10182 r_gsa.attribute2.DELETE;
10183 r_gsa.attribute3.DELETE;
10184 r_gsa.attribute4.DELETE;
10185 r_gsa.attribute5.DELETE;
10186 r_gsa.attribute6.DELETE;
10187 r_gsa.attribute7.DELETE;
10188 r_gsa.attribute8.DELETE;
10189 r_gsa.attribute9.DELETE;
10190 r_gsa.attribute10.DELETE;
10191 r_gsa.acct_type.DELETE;
10192
10193 OPEN default_account_cur (r_asg_org.organization_id(recno),
10194 r_asg_org.start_date(recno), r_asg_org.end_date(recno));
10195 FETCH default_account_cur BULK COLLECT INTO r_gsa.line_account_id,
10196 r_gsa.gl_code_combination_id, r_gsa.project_id,
10197 r_gsa.task_id, r_gsa.award_id,
10198 r_gsa.expenditure_type, r_gsa.expenditure_organization_id,
10199 r_gsa.start_date_active, r_gsa.end_date_active,
10200 r_gsa.poeta_start_date, r_gsa.poeta_end_date,
10201 r_gsa.percent, r_gsa.attribute_category,
10202 r_gsa.attribute1, r_gsa.attribute2,
10203 r_gsa.attribute3, r_gsa.attribute4,
10204 r_gsa.attribute5, r_gsa.attribute6,
10205 r_gsa.attribute7, r_gsa.attribute8,
10206 r_gsa.attribute9, r_gsa.attribute10, r_gsa.acct_type;
10207 CLOSE default_account_cur;
10208
10209 FOR recno2 IN 1..r_gsa.line_account_id.COUNT
10210 LOOP
10211 g_da_pointer := g_da_pointer + 1;
10212 r_da.line_account_id(g_da_pointer) := r_gsa.line_account_id(recno2);
10213 r_da.gl_code_combination_id(g_da_pointer) := r_gsa.gl_code_combination_id(recno2);
10214 r_da.project_id(g_da_pointer) := r_gsa.project_id(recno2);
10215 r_da.task_id(g_da_pointer) := r_gsa.task_id(recno2);
10216 r_da.award_id(g_da_pointer) := r_gsa.award_id(recno2);
10217 r_da.expenditure_type(g_da_pointer) := r_gsa.expenditure_type(recno2);
10218 r_da.expenditure_organization_id(g_da_pointer) := r_gsa.expenditure_organization_id(recno2);
10219 r_da.start_date_active(g_da_pointer) := r_gsa.start_date_active(recno2);
10220 r_da.end_date_active(g_da_pointer) := r_gsa.end_date_active(recno2);
10221 r_da.poeta_start_date(g_da_pointer) := r_gsa.poeta_start_date(recno2);
10222 r_da.poeta_end_date(g_da_pointer) := r_gsa.poeta_end_date(recno2);
10223 r_da.percent(g_da_pointer) := r_gsa.percent(recno2);
10224 r_da.attribute_category(g_da_pointer) := r_gsa.attribute_category(recno2);
10225 r_da.attribute1(g_da_pointer) := r_gsa.attribute1(recno2);
10226 r_da.attribute2(g_da_pointer) := r_gsa.attribute2(recno2);
10227 r_da.attribute3(g_da_pointer) := r_gsa.attribute3(recno2);
10228 r_da.attribute4(g_da_pointer) := r_gsa.attribute4(recno2);
10229 r_da.attribute5(g_da_pointer) := r_gsa.attribute5(recno2);
10230 r_da.attribute6(g_da_pointer) := r_gsa.attribute6(recno2);
10231 r_da.attribute7(g_da_pointer) := r_gsa.attribute7(recno2);
10232 r_da.attribute8(g_da_pointer) := r_gsa.attribute8(recno2);
10233 r_da.attribute9(g_da_pointer) := r_gsa.attribute9(recno2);
10234 r_da.attribute10(g_da_pointer) := r_gsa.attribute10(recno2);
10235 r_da.acct_type(g_da_pointer) := r_gsa.acct_type(recno2);
10236 END LOOP;
10237
10238 r_gsa.line_account_id.DELETE;
10239 r_gsa.gl_code_combination_id.DELETE;
10240 r_gsa.project_id.DELETE;
10241 r_gsa.task_id.DELETE;
10242 r_gsa.award_id.DELETE;
10243 r_gsa.expenditure_type.DELETE;
10244 r_gsa.expenditure_organization_id.DELETE;
10245 r_gsa.start_date_active.DELETE;
10246 r_gsa.end_date_active.DELETE;
10247 r_gsa.poeta_start_date.DELETE;
10248 r_gsa.poeta_end_date.DELETE;
10249 r_gsa.percent.DELETE;
10250 r_gsa.attribute_category.DELETE;
10251 r_gsa.attribute1.DELETE;
10252 r_gsa.attribute2.DELETE;
10253 r_gsa.attribute3.DELETE;
10254 r_gsa.attribute4.DELETE;
10255 r_gsa.attribute5.DELETE;
10256 r_gsa.attribute6.DELETE;
10257 r_gsa.attribute7.DELETE;
10258 r_gsa.attribute8.DELETE;
10259 r_gsa.attribute9.DELETE;
10260 r_gsa.attribute10.DELETE;
10261 r_gsa.acct_type.DELETE;
10262
10263 OPEN suspense_account_cur (r_asg_org.organization_id(recno),
10264 r_asg_org.start_date(recno), r_asg_org.end_date(recno));
10265 FETCH suspense_account_cur BULK COLLECT INTO r_gsa.line_account_id,
10266 r_gsa.gl_code_combination_id, r_gsa.project_id,
10267 r_gsa.task_id, r_gsa.award_id,
10268 r_gsa.expenditure_type, r_gsa.expenditure_organization_id,
10269 r_gsa.start_date_active, r_gsa.end_date_active,
10270 r_gsa.poeta_start_date, r_gsa.poeta_end_date,
10271 r_gsa.percent, r_gsa.attribute_category,
10272 r_gsa.attribute1, r_gsa.attribute2,
10273 r_gsa.attribute3, r_gsa.attribute4,
10274 r_gsa.attribute5, r_gsa.attribute6,
10275 r_gsa.attribute7, r_gsa.attribute8,
10276 r_gsa.attribute9, r_gsa.attribute10, r_gsa.acct_type;
10277 CLOSE suspense_account_cur;
10278
10279 FOR recno2 IN 1..r_gsa.line_account_id.COUNT
10280 LOOP
10281 g_sa_pointer := g_sa_pointer + 1;
10282 r_sa_tmp.line_account_id(g_sa_pointer) := r_gsa.line_account_id(recno2);
10283 r_sa_tmp.gl_code_combination_id(g_sa_pointer) := r_gsa.gl_code_combination_id(recno2);
10284 r_sa_tmp.project_id(g_sa_pointer) := r_gsa.project_id(recno2);
10285 r_sa_tmp.task_id(g_sa_pointer) := r_gsa.task_id(recno2);
10286 r_sa_tmp.award_id(g_sa_pointer) := r_gsa.award_id(recno2);
10287 r_sa_tmp.expenditure_type(g_sa_pointer) := r_gsa.expenditure_type(recno2);
10288 r_sa_tmp.expenditure_organization_id(g_sa_pointer) := r_gsa.expenditure_organization_id(recno2);
10289 r_sa_tmp.start_date_active(g_sa_pointer) := r_gsa.start_date_active(recno2);
10290 r_sa_tmp.end_date_active(g_sa_pointer) := r_gsa.end_date_active(recno2);
10291 r_sa_tmp.poeta_start_date(g_sa_pointer) := r_gsa.poeta_start_date(recno2);
10292 r_sa_tmp.poeta_end_date(g_sa_pointer) := r_gsa.poeta_end_date(recno2);
10293 r_sa_tmp.percent(g_sa_pointer) := r_gsa.percent(recno2);
10294 r_sa_tmp.attribute_category(g_sa_pointer) := r_gsa.attribute_category(recno2);
10295 r_sa_tmp.attribute1(g_sa_pointer) := r_gsa.attribute1(recno2);
10296 r_sa_tmp.attribute2(g_sa_pointer) := r_gsa.attribute2(recno2);
10297 r_sa_tmp.attribute3(g_sa_pointer) := r_gsa.attribute3(recno2);
10298 r_sa_tmp.attribute4(g_sa_pointer) := r_gsa.attribute4(recno2);
10299 r_sa_tmp.attribute5(g_sa_pointer) := r_gsa.attribute5(recno2);
10300 r_sa_tmp.attribute6(g_sa_pointer) := r_gsa.attribute6(recno2);
10301 r_sa_tmp.attribute7(g_sa_pointer) := r_gsa.attribute7(recno2);
10302 r_sa_tmp.attribute8(g_sa_pointer) := r_gsa.attribute8(recno2);
10303 r_sa_tmp.attribute9(g_sa_pointer) := r_gsa.attribute9(recno2);
10304 r_sa_tmp.attribute10(g_sa_pointer) := r_gsa.attribute10(recno2);
10305 r_sa_tmp.acct_type(g_sa_pointer) := r_gsa.acct_type(recno2);
10306 END LOOP;
10307
10308 r_gsa.line_account_id.DELETE;
10309 r_gsa.gl_code_combination_id.DELETE;
10310 r_gsa.project_id.DELETE;
10311 r_gsa.task_id.DELETE;
10312 r_gsa.award_id.DELETE;
10313 r_gsa.expenditure_type.DELETE;
10314 r_gsa.expenditure_organization_id.DELETE;
10315 r_gsa.start_date_active.DELETE;
10316 r_gsa.end_date_active.DELETE;
10317 r_gsa.poeta_start_date.DELETE;
10318 r_gsa.poeta_end_date.DELETE;
10319 r_gsa.percent.DELETE;
10320 r_gsa.attribute_category.DELETE;
10321 r_gsa.attribute1.DELETE;
10322 r_gsa.attribute2.DELETE;
10323 r_gsa.attribute3.DELETE;
10324 r_gsa.attribute4.DELETE;
10325 r_gsa.attribute5.DELETE;
10326 r_gsa.attribute6.DELETE;
10327 r_gsa.attribute7.DELETE;
10328 r_gsa.attribute8.DELETE;
10329 r_gsa.attribute9.DELETE;
10330 r_gsa.attribute10.DELETE;
10331 r_gsa.acct_type.DELETE;
10332 END LOOP;
10333 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_odls.line_account_id.COUNT: ' || r_odls.line_account_id.COUNT);
10334 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_da.line_account_id.COUNT: ' || r_da.line_account_id.COUNT);
10335 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_sa_tmp.line_account_id.COUNT: ' || r_sa_tmp.line_account_id.COUNT);
10336
10337 IF (r_sa_tmp.line_account_id.COUNT = 0) THEN
10338 OPEN generic_suspense_cur;
10339 FETCH generic_suspense_cur BULK COLLECT INTO r_sa.line_account_id,
10340 r_sa.gl_code_combination_id, r_sa.project_id,
10341 r_sa.task_id, r_sa.award_id,
10342 r_sa.expenditure_type, r_sa.expenditure_organization_id,
10343 r_sa.start_date_active, r_sa.end_date_active,
10344 r_sa.poeta_start_date, r_sa.poeta_end_date,
10345 r_sa.percent, r_sa.attribute_category,
10346 r_sa.attribute1, r_sa.attribute2,
10347 r_sa.attribute3, r_sa.attribute4,
10348 r_sa.attribute5, r_sa.attribute6,
10349 r_sa.attribute7, r_sa.attribute8,
10350 r_sa.attribute9, r_sa.attribute10, r_sa.acct_type;
10351 CLOSE generic_suspense_cur;
10352 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_sa.line_account_id.COUNT: ' || r_sa.line_account_id.COUNT);
10353 ELSE
10354 OPEN generic_suspense_cur;
10355 FETCH generic_suspense_cur BULK COLLECT INTO r_gsa.line_account_id,
10356 r_gsa.gl_code_combination_id, r_gsa.project_id,
10357 r_gsa.task_id, r_gsa.award_id,
10358 r_gsa.expenditure_type, r_gsa.expenditure_organization_id,
10359 r_gsa.start_date_active, r_gsa.end_date_active,
10360 r_gsa.poeta_start_date, r_gsa.poeta_end_date,
10361 r_gsa.percent, r_gsa.attribute_category,
10362 r_gsa.attribute1, r_gsa.attribute2,
10363 r_gsa.attribute3, r_gsa.attribute4,
10364 r_gsa.attribute5, r_gsa.attribute6,
10365 r_gsa.attribute7, r_gsa.attribute8,
10366 r_gsa.attribute9, r_gsa.attribute10, r_gsa.acct_type;
10367 CLOSE generic_suspense_cur;
10368 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_gsa.line_account_id.COUNT: ' || r_gsa.line_account_id.COUNT);
10369
10370 g_sa_pointer := 0;
10371 IF (r_sa_tmp.start_date_active(1) >= r_enc_period.r_asg_start_date(1)) THEN
10372 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) ||
10373 ' r_sa_tmp.start_date_active(1): ' || r_sa_tmp.start_date_active(1) ||
10374 ' r_enc_period.r_asg_start_date(1): ' || r_enc_period.r_asg_start_date(1));
10375 FOR gsa_rec_no IN 1..r_gsa.line_account_id.COUNT
10376 LOOP
10377 EXIT WHEN r_gsa.start_date_active(gsa_rec_no) >= r_sa_tmp.start_date_active(1);
10378
10379 g_sa_pointer := g_sa_pointer + 1;
10380 r_sa.line_account_id(g_sa_pointer) := r_gsa.line_account_id(gsa_rec_no);
10381 r_sa.gl_code_combination_id(g_sa_pointer) := r_gsa.gl_code_combination_id(gsa_rec_no);
10382 r_sa.project_id(g_sa_pointer) := r_gsa.project_id(gsa_rec_no);
10383 r_sa.task_id(g_sa_pointer) := r_gsa.task_id(gsa_rec_no);
10384 r_sa.award_id(g_sa_pointer) := r_gsa.award_id(gsa_rec_no);
10385 r_sa.expenditure_type(g_sa_pointer) := r_gsa.expenditure_type(gsa_rec_no);
10386 r_sa.expenditure_organization_id(g_sa_pointer) := r_gsa.expenditure_organization_id(gsa_rec_no);
10387 r_sa.start_date_active(g_sa_pointer) := GREATEST(r_gsa.start_date_active(gsa_rec_no), r_enc_period.r_asg_start_date(1));
10388 r_sa.end_date_active(g_sa_pointer) := LEAST(r_gsa.end_date_active(gsa_rec_no), r_sa_tmp.start_date_active(1)-1);
10389 r_sa.poeta_start_date(g_sa_pointer) := r_gsa.poeta_start_date(gsa_rec_no);
10390 r_sa.poeta_end_date(g_sa_pointer) := r_gsa.poeta_end_date(gsa_rec_no);
10391 r_sa.percent(g_sa_pointer) := r_gsa.percent(gsa_rec_no);
10392 r_sa.attribute_category(g_sa_pointer) := r_gsa.attribute_category(gsa_rec_no);
10393 r_sa.attribute1(g_sa_pointer) := r_gsa.attribute1(gsa_rec_no);
10394 r_sa.attribute2(g_sa_pointer) := r_gsa.attribute2(gsa_rec_no);
10395 r_sa.attribute3(g_sa_pointer) := r_gsa.attribute3(gsa_rec_no);
10396 r_sa.attribute4(g_sa_pointer) := r_gsa.attribute4(gsa_rec_no);
10397 r_sa.attribute5(g_sa_pointer) := r_gsa.attribute5(gsa_rec_no);
10398 r_sa.attribute6(g_sa_pointer) := r_gsa.attribute6(gsa_rec_no);
10399 r_sa.attribute7(g_sa_pointer) := r_gsa.attribute7(gsa_rec_no);
10400 r_sa.attribute8(g_sa_pointer) := r_gsa.attribute8(gsa_rec_no);
10401 r_sa.attribute9(g_sa_pointer) := r_gsa.attribute9(gsa_rec_no);
10402 r_sa.attribute10(g_sa_pointer) := r_gsa.attribute10(gsa_rec_no);
10403 r_sa.acct_type(g_sa_pointer) := r_gsa.acct_type(gsa_rec_no);
10404 END LOOP;
10405 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Identified Generic Suspense Lines for suspense gap before the first suspense line');
10406 END IF;
10407 g_sa_pointer := g_sa_pointer + 1;
10408 r_sa.line_account_id(g_sa_pointer) := r_sa_tmp.line_account_id(1);
10409 r_sa.gl_code_combination_id(g_sa_pointer) := r_sa_tmp.gl_code_combination_id(1);
10410 r_sa.project_id(g_sa_pointer) := r_sa_tmp.project_id(1);
10411 r_sa.task_id(g_sa_pointer) := r_sa_tmp.task_id(1);
10412 r_sa.award_id(g_sa_pointer) := r_sa_tmp.award_id(1);
10413 r_sa.expenditure_type(g_sa_pointer) := r_sa_tmp.expenditure_type(1);
10414 r_sa.expenditure_organization_id(g_sa_pointer) := r_sa_tmp.expenditure_organization_id(1);
10415 r_sa.start_date_active(g_sa_pointer) := r_sa_tmp.start_date_active(1);
10416 r_sa.end_date_active(g_sa_pointer) := r_sa_tmp.end_date_active(1);
10417 r_sa.poeta_start_date(g_sa_pointer) := r_sa_tmp.poeta_start_date(1);
10418 r_sa.poeta_end_date(g_sa_pointer) := r_sa_tmp.poeta_end_date(1);
10419 r_sa.percent(g_sa_pointer) := r_sa_tmp.percent(1);
10420 r_sa.attribute_category(g_sa_pointer) := r_sa_tmp.attribute_category(1);
10421 r_sa.attribute1(g_sa_pointer) := r_sa_tmp.attribute1(1);
10422 r_sa.attribute2(g_sa_pointer) := r_sa_tmp.attribute2(1);
10423 r_sa.attribute3(g_sa_pointer) := r_sa_tmp.attribute3(1);
10424 r_sa.attribute4(g_sa_pointer) := r_sa_tmp.attribute4(1);
10425 r_sa.attribute5(g_sa_pointer) := r_sa_tmp.attribute5(1);
10426 r_sa.attribute6(g_sa_pointer) := r_sa_tmp.attribute6(1);
10427 r_sa.attribute7(g_sa_pointer) := r_sa_tmp.attribute7(1);
10428 r_sa.attribute8(g_sa_pointer) := r_sa_tmp.attribute8(1);
10429 r_sa.attribute9(g_sa_pointer) := r_sa_tmp.attribute9(1);
10430 r_sa.attribute10(g_sa_pointer) := r_sa_tmp.attribute10(1);
10431 r_sa.acct_type(g_sa_pointer) := r_sa_tmp.acct_type(1);
10432 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Stamped first suspense line');
10433
10434 IF (r_sa_tmp.line_account_id.COUNT > 1) THEN
10435 FOR sa_recno IN 2..r_sa_tmp.line_account_id.COUNT
10436 LOOP
10437 IF (r_sa_tmp.start_date_active(sa_recno) > r_sa.end_date_active(g_sa_pointer)+1) THEN
10438 FOR gsa_rec_no IN 1..r_gsa.line_account_id.COUNT
10439 LOOP
10440 EXIT WHEN r_sa.end_date_active(g_sa_pointer)+1 >= r_sa_tmp.start_date_active(sa_recno);
10441 IF (r_gsa.end_date_active(gsa_rec_no) >= r_sa.end_date_active(g_sa_pointer)+1) THEN
10442 g_sa_pointer := g_sa_pointer + 1;
10443 r_sa.line_account_id(g_sa_pointer) := r_gsa.line_account_id(gsa_rec_no);
10444 r_sa.gl_code_combination_id(g_sa_pointer) := r_gsa.gl_code_combination_id(gsa_rec_no);
10445 r_sa.project_id(g_sa_pointer) := r_gsa.project_id(gsa_rec_no);
10446 r_sa.task_id(g_sa_pointer) := r_gsa.task_id(gsa_rec_no);
10447 r_sa.award_id(g_sa_pointer) := r_gsa.award_id(gsa_rec_no);
10448 r_sa.expenditure_type(g_sa_pointer) := r_gsa.expenditure_type(gsa_rec_no);
10449 r_sa.expenditure_organization_id(g_sa_pointer) := r_gsa.expenditure_organization_id(gsa_rec_no);
10450 r_sa.start_date_active(g_sa_pointer) := GREATEST(r_gsa.start_date_active(gsa_rec_no), r_sa.end_date_active(g_sa_pointer-1)+1);
10451 r_sa.end_date_active(g_sa_pointer) := LEAST(r_gsa.end_date_active(gsa_rec_no), r_sa_tmp.start_date_active(sa_recno)-1);
10452 r_sa.poeta_start_date(g_sa_pointer) := r_gsa.poeta_start_date(gsa_rec_no);
10453 r_sa.poeta_end_date(g_sa_pointer) := r_gsa.poeta_end_date(gsa_rec_no);
10454 r_sa.percent(g_sa_pointer) := r_gsa.percent(gsa_rec_no);
10455 r_sa.attribute_category(g_sa_pointer) := r_gsa.attribute_category(gsa_rec_no);
10456 r_sa.attribute1(g_sa_pointer) := r_gsa.attribute1(gsa_rec_no);
10457 r_sa.attribute2(g_sa_pointer) := r_gsa.attribute2(gsa_rec_no);
10458 r_sa.attribute3(g_sa_pointer) := r_gsa.attribute3(gsa_rec_no);
10459 r_sa.attribute4(g_sa_pointer) := r_gsa.attribute4(gsa_rec_no);
10460 r_sa.attribute5(g_sa_pointer) := r_gsa.attribute5(gsa_rec_no);
10461 r_sa.attribute6(g_sa_pointer) := r_gsa.attribute6(gsa_rec_no);
10462 r_sa.attribute7(g_sa_pointer) := r_gsa.attribute7(gsa_rec_no);
10463 r_sa.attribute8(g_sa_pointer) := r_gsa.attribute8(gsa_rec_no);
10464 r_sa.attribute9(g_sa_pointer) := r_gsa.attribute9(gsa_rec_no);
10465 r_sa.attribute10(g_sa_pointer) := r_gsa.attribute10(gsa_rec_no);
10466 r_sa.acct_type(g_sa_pointer) := r_gsa.acct_type(gsa_rec_no);
10467 hr_utility.trace(' Stamped generic suspense line between ' ||
10468 r_sa.start_date_active(g_sa_pointer) || ' AND ' ||
10469 r_sa.end_date_active(g_sa_pointer));
10470 END IF;
10471 END LOOP;
10472 END IF;
10473 hr_utility.trace(' Attempting to stamp org suspense');
10474 g_sa_pointer := g_sa_pointer + 1;
10475 r_sa.line_account_id(g_sa_pointer) := r_sa_tmp.line_account_id(sa_recno);
10476 r_sa.gl_code_combination_id(g_sa_pointer) := r_sa_tmp.gl_code_combination_id(sa_recno);
10477 r_sa.project_id(g_sa_pointer) := r_sa_tmp.project_id(sa_recno);
10478 r_sa.task_id(g_sa_pointer) := r_sa_tmp.task_id(sa_recno);
10479 r_sa.award_id(g_sa_pointer) := r_sa_tmp.award_id(sa_recno);
10480 r_sa.expenditure_type(g_sa_pointer) := r_sa_tmp.expenditure_type(sa_recno);
10481 r_sa.expenditure_organization_id(g_sa_pointer) := r_sa_tmp.expenditure_organization_id(sa_recno);
10482 r_sa.start_date_active(g_sa_pointer) := r_sa_tmp.start_date_active(sa_recno);
10483 r_sa.end_date_active(g_sa_pointer) := r_sa_tmp.end_date_active(sa_recno);
10484 r_sa.poeta_start_date(g_sa_pointer) := r_sa_tmp.poeta_start_date(sa_recno);
10485 r_sa.poeta_end_date(g_sa_pointer) := r_sa_tmp.poeta_end_date(sa_recno);
10486 r_sa.percent(g_sa_pointer) := r_sa_tmp.percent(sa_recno);
10487 r_sa.attribute_category(g_sa_pointer) := r_sa_tmp.attribute_category(sa_recno);
10488 r_sa.attribute1(g_sa_pointer) := r_sa_tmp.attribute1(sa_recno);
10489 r_sa.attribute2(g_sa_pointer) := r_sa_tmp.attribute2(sa_recno);
10490 r_sa.attribute3(g_sa_pointer) := r_sa_tmp.attribute3(sa_recno);
10491 r_sa.attribute4(g_sa_pointer) := r_sa_tmp.attribute4(sa_recno);
10492 r_sa.attribute5(g_sa_pointer) := r_sa_tmp.attribute5(sa_recno);
10493 r_sa.attribute6(g_sa_pointer) := r_sa_tmp.attribute6(sa_recno);
10494 r_sa.attribute7(g_sa_pointer) := r_sa_tmp.attribute7(sa_recno);
10495 r_sa.attribute8(g_sa_pointer) := r_sa_tmp.attribute8(sa_recno);
10496 r_sa.attribute9(g_sa_pointer) := r_sa_tmp.attribute9(sa_recno);
10497 r_sa.attribute10(g_sa_pointer) := r_sa_tmp.attribute10(sa_recno);
10498 r_sa.acct_type(g_sa_pointer) := r_sa_tmp.acct_type(sa_recno);
10499 hr_utility.trace(' Stamped org suspense line between ' ||
10500 r_sa.start_date_active(g_sa_pointer) || ' AND ' || r_sa.end_date_active(g_sa_pointer));
10501 END LOOP;
10502 END IF;
10503
10504 IF (r_sa.end_date_active(g_sa_pointer) < g_enc_org_end_date) THEN
10505 FOR gsa_rec_no IN 1..r_gsa.line_account_id.COUNT
10506 LOOP
10507 IF r_gsa.end_date_active(gsa_rec_no) > r_sa_tmp.end_date_active(r_sa_tmp.end_date_active.COUNT) THEN
10508 g_sa_pointer := g_sa_pointer + 1;
10509 r_sa.line_account_id(g_sa_pointer) := r_gsa.line_account_id(gsa_rec_no);
10510 r_sa.gl_code_combination_id(g_sa_pointer) := r_gsa.gl_code_combination_id(gsa_rec_no);
10511 r_sa.project_id(g_sa_pointer) := r_gsa.project_id(gsa_rec_no);
10512 r_sa.task_id(g_sa_pointer) := r_gsa.task_id(gsa_rec_no);
10513 r_sa.award_id(g_sa_pointer) := r_gsa.award_id(gsa_rec_no);
10514 r_sa.expenditure_type(g_sa_pointer) := r_gsa.expenditure_type(gsa_rec_no);
10515 r_sa.expenditure_organization_id(g_sa_pointer) := r_gsa.expenditure_organization_id(gsa_rec_no);
10516 r_sa.start_date_active(g_sa_pointer) := GREATEST(r_gsa.start_date_active(gsa_rec_no), r_sa_tmp.end_date_active(r_sa_tmp.end_date_active.COUNT)+1);
10517 r_sa.end_date_active(g_sa_pointer) := LEAST(r_gsa.end_date_active(gsa_rec_no), g_enc_org_end_date);
10518 r_sa.poeta_start_date(g_sa_pointer) := r_gsa.poeta_start_date(gsa_rec_no);
10519 r_sa.poeta_end_date(g_sa_pointer) := r_gsa.poeta_end_date(gsa_rec_no);
10520 r_sa.percent(g_sa_pointer) := r_gsa.percent(gsa_rec_no);
10521 r_sa.attribute_category(g_sa_pointer) := r_gsa.attribute_category(gsa_rec_no);
10522 r_sa.attribute1(g_sa_pointer) := r_gsa.attribute1(gsa_rec_no);
10523 r_sa.attribute2(g_sa_pointer) := r_gsa.attribute2(gsa_rec_no);
10524 r_sa.attribute3(g_sa_pointer) := r_gsa.attribute3(gsa_rec_no);
10525 r_sa.attribute4(g_sa_pointer) := r_gsa.attribute4(gsa_rec_no);
10526 r_sa.attribute5(g_sa_pointer) := r_gsa.attribute5(gsa_rec_no);
10527 r_sa.attribute6(g_sa_pointer) := r_gsa.attribute6(gsa_rec_no);
10528 r_sa.attribute7(g_sa_pointer) := r_gsa.attribute7(gsa_rec_no);
10529 r_sa.attribute8(g_sa_pointer) := r_gsa.attribute8(gsa_rec_no);
10530 r_sa.attribute9(g_sa_pointer) := r_gsa.attribute9(gsa_rec_no);
10531 r_sa.attribute10(g_sa_pointer) := r_gsa.attribute10(gsa_rec_no);
10532 r_sa.acct_type(g_sa_pointer) := r_gsa.acct_type(gsa_rec_no);
10533 END IF;
10534 END LOOP;
10535 r_sa_tmp.line_account_id.DELETE;
10536 r_sa_tmp.gl_code_combination_id.DELETE;
10537 r_sa_tmp.project_id.DELETE;
10538 r_sa_tmp.task_id.DELETE;
10539 r_sa_tmp.award_id.DELETE;
10540 r_sa_tmp.expenditure_type.DELETE;
10541 r_sa_tmp.expenditure_organization_id.DELETE;
10542 r_sa_tmp.start_date_active.DELETE;
10543 r_sa_tmp.end_date_active.DELETE;
10544 r_sa_tmp.poeta_start_date.DELETE;
10545 r_sa_tmp.poeta_end_date.DELETE;
10546 r_sa_tmp.percent.DELETE;
10547 r_sa_tmp.attribute_category.DELETE;
10548 r_sa_tmp.attribute1.DELETE;
10549 r_sa_tmp.attribute2.DELETE;
10550 r_sa_tmp.attribute3.DELETE;
10551 r_sa_tmp.attribute4.DELETE;
10552 r_sa_tmp.attribute5.DELETE;
10553 r_sa_tmp.attribute6.DELETE;
10554 r_sa_tmp.attribute7.DELETE;
10555 r_sa_tmp.attribute8.DELETE;
10556 r_sa_tmp.attribute9.DELETE;
10557 r_sa_tmp.attribute10.DELETE;
10558 r_sa_tmp.acct_type.DELETE;
10559 END IF;
10560 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_sa.line_account_id.COUNT: ' || r_sa.line_account_id.COUNT);
10561 END IF;
10562
10563 r_gsa.line_account_id.DELETE;
10564 r_gsa.gl_code_combination_id.DELETE;
10565 r_gsa.project_id.DELETE;
10566 r_gsa.task_id.DELETE;
10567 r_gsa.award_id.DELETE;
10568 r_gsa.expenditure_type.DELETE;
10569 r_gsa.expenditure_organization_id.DELETE;
10570 r_gsa.start_date_active.DELETE;
10571 r_gsa.end_date_active.DELETE;
10572 r_gsa.poeta_start_date.DELETE;
10573 r_gsa.poeta_end_date.DELETE;
10574 r_gsa.percent.DELETE;
10575 r_gsa.attribute_category.DELETE;
10576 r_gsa.attribute1.DELETE;
10577 r_gsa.attribute2.DELETE;
10578 r_gsa.attribute3.DELETE;
10579 r_gsa.attribute4.DELETE;
10580 r_gsa.attribute5.DELETE;
10581 r_gsa.attribute6.DELETE;
10582 r_gsa.attribute7.DELETE;
10583 r_gsa.attribute8.DELETE;
10584 r_gsa.attribute9.DELETE;
10585 r_gsa.attribute10.DELETE;
10586 r_gsa.acct_type.DELETE;
10587
10588 g_pateo_end_date := fnd_date.canonical_to_date('1800/01/01 00:00:00');
10589
10590 hr_utility.trace('
10591 Global Element Hierarchy');
10592 hr_utility.trace(LPAD('Element Account Id', 18, ' ') || ' ' ||
10593 RPAD('Start Date Active', 17, ' ') || ' ' || RPAD('End Date Active', 17, ' ') || ' ' ||
10594 RPAD('PATEO Start Date', 17, ' ') || ' ' || RPAD('PATEO End Date', 17, ' ') || ' ' ||
10595 LPAD('GL CC Id', 15, ' ') || ' ' || LPAD('Project Id', 15, ' ') || ' ' ||
10596 LPAD('Task Id', 15, ' ') || ' ' || LPAD('Award Id', 15, ' ') || ' ' ||
10597 LPAD('Expenditure Org Id', 18, ' ') || ' ' || RPAD('Expenditure Type', 30, ' ') || ' ' ||
10598 LPAD('Percent', 10, ' '));
10599
10600 hr_utility.trace(LPAD('-', 18, '-') || ' ' ||
10601 RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
10602 RPAD('-', 17, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' ||
10603 LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 18, '-') || ' ' ||
10604 RPAD('-', 30, '-') || ' ' || LPAD('-', 10, '-'));
10605
10606 FOR recno IN 1..r_gee.line_account_id.COUNT
10607 LOOP
10608 hr_utility.trace(LPAD(r_gee.line_account_id(recno), 17, ' ') || ' ' ||
10609 RPAD(TO_CHAR(r_gee.start_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
10610 RPAD(TO_CHAR(r_gee.end_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
10611 RPAD(NVL(TO_CHAR(r_gee.poeta_start_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
10612 RPAD(NVL(TO_CHAR(r_gee.poeta_end_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
10613 LPAD(NVL(r_gee.gl_code_combination_id(recno), '-1'), 15, ' ') || ' ' ||
10614 LPAD(NVL(r_gee.project_id(recno), '-1'), 15, ' ') || ' ' ||
10615 LPAD(NVL(r_gee.task_id(recno), '-1'), 15, ' ') || ' ' ||
10616 LPAD(NVL(r_gee.award_id(recno), '-1'), 15, ' ') || ' ' ||
10617 LPAD(NVL(r_gee.expenditure_organization_id(recno), '-1'), 18, ' ') || ' ' ||
10618 RPAD(NVL(r_gee.expenditure_type(recno), ' '), 30, ' ') || ' ' ||
10619 LPAD(r_gee.percent(recno), 10, ' '));
10620
10621 IF (r_gee.expenditure_type(recno) IS NOT NULL) THEN
10622 psp_enc_pre_process.validate_poeta (p_project_id => r_gee.project_id(recno),
10623 p_task_id => r_gee.task_id(recno),
10624 p_award_id => r_gee.award_id(recno),
10625 p_expenditure_type => r_gee.expenditure_type(recno),
10626 p_expenditure_organization_id => r_gee.expenditure_organization_id(recno),
10627 p_payroll_id => p_payroll_id,
10628 p_start_date => r_gee.poeta_start_date(recno),
10629 p_end_date => r_gee.poeta_end_date(recno),
10630 p_return_status => p_return_status);
10631
10632 IF p_return_status <> fnd_api.g_ret_sts_success THEN
10633 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10634 END IF;
10635 END IF;
10636 g_pateo_end_date := GREATEST(g_pateo_end_date, NVL(r_gee.poeta_end_date(recno), g_pateo_end_date));
10637 END LOOP;
10638
10639 hr_utility.trace('
10640 Element Type Hierarchy');
10641 hr_utility.trace(LPAD('Schedule Line Id', 17, ' ') || ' ' ||
10642 RPAD('Start Date Active', 17, ' ') || ' ' || RPAD('End Date Active', 17, ' ') || ' ' ||
10643 RPAD('PATEO Start Date', 17, ' ') || ' ' || RPAD('PATEO End Date', 17, ' ') || ' ' ||
10644 LPAD('GL CC Id', 15, ' ') || ' ' || LPAD('Project Id', 15, ' ') || ' ' ||
10645 LPAD('Task Id', 15, ' ') || ' ' || LPAD('Award Id', 15, ' ') || ' ' ||
10646 LPAD('Expenditure Org Id', 18, ' ') || ' ' || RPAD('Expenditure Type', 30, ' ') || ' ' ||
10647 LPAD('Percent', 10, ' '));
10648
10649 hr_utility.trace(LPAD('-', 17, '-') || ' ' ||
10650 RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
10651 RPAD('-', 17, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' ||
10652 LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 18, '-') || ' ' ||
10653 RPAD('-', 30, '-') || ' ' || LPAD('-', 10, '-'));
10654
10655 FOR recno IN 1..r_et.line_account_id.COUNT
10656 LOOP
10657 hr_utility.trace(LPAD(r_et.line_account_id(recno), 17, ' ') || ' ' ||
10658 RPAD(TO_CHAR(r_et.start_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
10659 RPAD(TO_CHAR(r_et.end_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
10660 RPAD(NVL(TO_CHAR(r_et.poeta_start_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
10661 RPAD(NVL(TO_CHAR(r_et.poeta_end_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
10662 LPAD(NVL(r_et.gl_code_combination_id(recno), '-1'), 15, ' ') || ' ' ||
10663 LPAD(NVL(r_et.project_id(recno), '-1'), 15, ' ') || ' ' ||
10664 LPAD(NVL(r_et.task_id(recno), '-1'), 15, ' ') || ' ' ||
10665 LPAD(NVL(r_et.award_id(recno), '-1'), 15, ' ') || ' ' ||
10666 LPAD(NVL(r_et.expenditure_organization_id(recno), '-1'), 18, ' ') || ' ' ||
10667 RPAD(NVL(r_et.expenditure_type(recno), ' '), 30, ' ') || ' ' ||
10668 LPAD(r_et.percent(recno), 10, ' '));
10669 IF (r_et.expenditure_type(recno) IS NOT NULL) THEN
10670 psp_enc_pre_process.validate_poeta (p_project_id => r_et.project_id(recno),
10671 p_task_id => r_et.task_id(recno),
10672 p_award_id => r_et.award_id(recno),
10673 p_expenditure_type => r_et.expenditure_type(recno),
10674 p_expenditure_organization_id => r_et.expenditure_organization_id(recno),
10675 p_payroll_id => p_payroll_id,
10676 p_start_date => r_et.poeta_start_date(recno),
10677 p_end_date => r_et.poeta_end_date(recno),
10678 p_return_status => p_return_status);
10679
10680 IF p_return_status <> fnd_api.g_ret_sts_success THEN
10681 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10682 END IF;
10683 END IF;
10684 g_pateo_end_date := GREATEST(g_pateo_end_date, NVL(r_et.poeta_end_date(recno), g_pateo_end_date));
10685 END LOOP;
10686
10687 hr_utility.trace('
10688 Element Class Hierarchy');
10689 hr_utility.trace(LPAD('Schedule Line Id', 17, ' ') || ' ' ||
10690 RPAD('Start Date Active', 17, ' ') || ' ' || RPAD('End Date Active', 17, ' ') || ' ' ||
10691 RPAD('PATEO Start Date', 17, ' ') || ' ' || RPAD('PATEO End Date', 17, ' ') || ' ' ||
10692 LPAD('GL CC Id', 15, ' ') || ' ' || LPAD('Project Id', 15, ' ') || ' ' ||
10693 LPAD('Task Id', 15, ' ') || ' ' || LPAD('Award Id', 15, ' ') || ' ' ||
10694 LPAD('Expenditure Org Id', 18, ' ') || ' ' || RPAD('Expenditure Type', 30, ' ') || ' ' ||
10695 LPAD('Percent', 10, ' '));
10696
10697 hr_utility.trace(LPAD('-', 17, '-') || ' ' ||
10698 RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
10699 RPAD('-', 17, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' ||
10700 LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 18, '-') || ' ' ||
10701 RPAD('-', 30, '-') || ' ' || LPAD('-', 10, '-'));
10702
10703 FOR recno IN 1..r_ec.line_account_id.COUNT
10704 LOOP
10705 hr_utility.trace(LPAD(r_ec.line_account_id(recno), 17, ' ') || ' ' ||
10706 RPAD(TO_CHAR(r_ec.start_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
10707 RPAD(TO_CHAR(r_ec.end_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
10708 RPAD(NVL(TO_CHAR(r_ec.poeta_start_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
10709 RPAD(NVL(TO_CHAR(r_ec.poeta_end_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
10710 LPAD(NVL(r_ec.gl_code_combination_id(recno), '-1'), 15, ' ') || ' ' ||
10711 LPAD(NVL(r_ec.project_id(recno), '-1'), 15, ' ') || ' ' ||
10712 LPAD(NVL(r_ec.task_id(recno), '-1'), 15, ' ') || ' ' ||
10713 LPAD(NVL(r_ec.award_id(recno), '-1'), 15, ' ') || ' ' ||
10714 LPAD(NVL(r_ec.expenditure_organization_id(recno), '-1'), 18, ' ') || ' ' ||
10715 RPAD(NVL(r_ec.expenditure_type(recno), ' '), 30, ' ') || ' ' ||
10716 LPAD(r_ec.percent(recno), 10, ' '));
10717 IF (r_ec.expenditure_type(recno) IS NOT NULL) THEN
10718 psp_enc_pre_process.validate_poeta (p_project_id => r_ec.project_id(recno),
10719 p_task_id => r_ec.task_id(recno),
10720 p_award_id => r_ec.award_id(recno),
10721 p_expenditure_type => r_ec.expenditure_type(recno),
10722 p_expenditure_organization_id => r_ec.expenditure_organization_id(recno),
10723 p_payroll_id => p_payroll_id,
10724 p_start_date => r_ec.poeta_start_date(recno),
10725 p_end_date => r_ec.poeta_end_date(recno),
10726 p_return_status => p_return_status);
10727
10728 IF p_return_status <> fnd_api.g_ret_sts_success THEN
10729 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10730 END IF;
10731 END IF;
10732 g_pateo_end_date := GREATEST(g_pateo_end_date, NVL(r_ec.poeta_end_date(recno), g_pateo_end_date));
10733 END LOOP;
10734
10735 hr_utility.trace('
10736 Assignment Hierarchy');
10737 hr_utility.trace(LPAD('Schedule Line Id', 17, ' ') || ' ' ||
10738 RPAD('Start Date Active', 17, ' ') || ' ' || RPAD('End Date Active', 17, ' ') || ' ' ||
10739 RPAD('PATEO Start Date', 17, ' ') || ' ' || RPAD('PATEO End Date', 17, ' ') || ' ' ||
10740 LPAD('GL CC Id', 15, ' ') || ' ' || LPAD('Project Id', 15, ' ') || ' ' ||
10741 LPAD('Task Id', 15, ' ') || ' ' || LPAD('Award Id', 15, ' ') || ' ' ||
10742 LPAD('Expenditure Org Id', 18, ' ') || ' ' || RPAD('Expenditure Type', 30, ' ') || ' ' ||
10743 LPAD('Percent', 10, ' '));
10744
10745 hr_utility.trace(LPAD('-', 17, '-') || ' ' ||
10746 RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
10747 RPAD('-', 17, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' ||
10748 LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 18, '-') || ' ' ||
10749 RPAD('-', 30, '-') || ' ' || LPAD('-', 10, '-'));
10750
10751 FOR recno IN 1..r_asg.line_account_id.COUNT
10752 LOOP
10753 hr_utility.trace(LPAD(r_asg.line_account_id(recno), 17, ' ') || ' ' ||
10754 RPAD(TO_CHAR(r_asg.start_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
10755 RPAD(TO_CHAR(r_asg.end_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
10756 RPAD(NVL(TO_CHAR(r_asg.poeta_start_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
10757 RPAD(NVL(TO_CHAR(r_asg.poeta_end_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
10758 LPAD(NVL(r_asg.gl_code_combination_id(recno), '-1'), 15, ' ') || ' ' ||
10759 LPAD(NVL(r_asg.project_id(recno), '-1'), 15, ' ') || ' ' ||
10760 LPAD(NVL(r_asg.task_id(recno), '-1'), 15, ' ') || ' ' ||
10761 LPAD(NVL(r_asg.award_id(recno), '-1'), 15, ' ') || ' ' ||
10762 LPAD(NVL(r_asg.expenditure_organization_id(recno), '-1'), 18, ' ') || ' ' ||
10763 RPAD(NVL(r_asg.expenditure_type(recno), ' '), 30, ' ') || ' ' ||
10764 LPAD(r_asg.percent(recno), 10, ' '));
10765 IF (r_asg.expenditure_type(recno) IS NOT NULL) THEN
10766 psp_enc_pre_process.validate_poeta (p_project_id => r_asg.project_id(recno),
10767 p_task_id => r_asg.task_id(recno),
10768 p_award_id => r_asg.award_id(recno),
10769 p_expenditure_type => r_asg.expenditure_type(recno),
10770 p_expenditure_organization_id => r_asg.expenditure_organization_id(recno),
10771 p_payroll_id => p_payroll_id,
10772 p_start_date => r_asg.poeta_start_date(recno),
10773 p_end_date => r_asg.poeta_end_date(recno),
10774 p_return_status => p_return_status);
10775
10776 IF p_return_status <> fnd_api.g_ret_sts_success THEN
10777 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10778 END IF;
10779 END IF;
10780 g_pateo_end_date := GREATEST(g_pateo_end_date, NVL(r_asg.poeta_end_date(recno), g_pateo_end_date));
10781 END LOOP;
10782
10783 hr_utility.trace('
10784 Organization Default Schedules Hierarchy');
10785 hr_utility.trace(LPAD('Schedule Line Id', 17, ' ') || ' ' ||
10786 RPAD('Start Date Active', 17, ' ') || ' ' || RPAD('End Date Active', 17, ' ') || ' ' ||
10787 RPAD('PATEO Start Date', 17, ' ') || ' ' || RPAD('PATEO End Date', 17, ' ') || ' ' ||
10788 LPAD('GL CC Id', 15, ' ') || ' ' || LPAD('Project Id', 15, ' ') || ' ' ||
10789 LPAD('Task Id', 15, ' ') || ' ' || LPAD('Award Id', 15, ' ') || ' ' ||
10790 LPAD('Expenditure Org Id', 18, ' ') || ' ' || RPAD('Expenditure Type', 30, ' ') || ' ' ||
10791 LPAD('Percent', 10, ' '));
10792
10793 hr_utility.trace(LPAD('-', 17, '-') || ' ' ||
10794 RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
10795 RPAD('-', 17, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' ||
10796 LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 18, '-') || ' ' ||
10797 RPAD('-', 30, '-') || ' ' || LPAD('-', 10, '-'));
10798
10799 FOR recno IN 1..r_odls.line_account_id.COUNT
10800 LOOP
10801 hr_utility.trace(LPAD(r_odls.line_account_id(recno), 17, ' ') || ' ' ||
10802 RPAD(TO_CHAR(r_odls.start_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
10803 RPAD(TO_CHAR(r_odls.end_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
10804 RPAD(NVL(TO_CHAR(r_odls.poeta_start_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
10805 RPAD(NVL(TO_CHAR(r_odls.poeta_end_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
10806 LPAD(NVL(r_odls.gl_code_combination_id(recno), '-1'), 15, ' ') || ' ' ||
10807 LPAD(NVL(r_odls.project_id(recno), '-1'), 15, ' ') || ' ' ||
10808 LPAD(NVL(r_odls.task_id(recno), '-1'), 15, ' ') || ' ' ||
10809 LPAD(NVL(r_odls.award_id(recno), '-1'), 15, ' ') || ' ' ||
10810 LPAD(NVL(r_odls.expenditure_organization_id(recno), '-1'), 18, ' ') || ' ' ||
10811 RPAD(NVL(r_odls.expenditure_type(recno), ' '), 30, ' ') || ' ' ||
10812 LPAD(r_odls.percent(recno), 10, ' '));
10813 IF (r_odls.expenditure_type(recno) IS NOT NULL) THEN
10814 psp_enc_pre_process.validate_poeta (p_project_id => r_odls.project_id(recno),
10815 p_task_id => r_odls.task_id(recno),
10816 p_award_id => r_odls.award_id(recno),
10817 p_expenditure_type => r_odls.expenditure_type(recno),
10818 p_expenditure_organization_id => r_odls.expenditure_organization_id(recno),
10819 p_payroll_id => p_payroll_id,
10820 p_start_date => r_odls.poeta_start_date(recno),
10821 p_end_date => r_odls.poeta_end_date(recno),
10822 p_return_status => p_return_status);
10823
10824 IF p_return_status <> fnd_api.g_ret_sts_success THEN
10825 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10826 END IF;
10827 END IF;
10828 g_pateo_end_date := GREATEST(g_pateo_end_date, NVL(r_odls.poeta_end_date(recno), g_pateo_end_date));
10829 END LOOP;
10830
10831 hr_utility.trace('
10832 Organization Default Account Hierarchy');
10833 hr_utility.trace(LPAD('Line Account Id', 17, ' ') || ' ' ||
10834 RPAD('Start Date Active', 17, ' ') || ' ' || RPAD('End Date Active', 17, ' ') || ' ' ||
10835 RPAD('PATEO Start Date', 17, ' ') || ' ' || RPAD('PATEO End Date', 17, ' ') || ' ' ||
10836 LPAD('GL CC Id', 15, ' ') || ' ' || LPAD('Project Id', 15, ' ') || ' ' ||
10837 LPAD('Task Id', 15, ' ') || ' ' || LPAD('Award Id', 15, ' ') || ' ' ||
10838 LPAD('Expenditure Org Id', 18, ' ') || ' ' || RPAD('Expenditure Type', 30, ' ') || ' ' ||
10839 LPAD('Percent', 10, ' '));
10840
10841 hr_utility.trace(LPAD('-', 17, '-') || ' ' ||
10842 RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
10843 RPAD('-', 17, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' ||
10844 LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 18, '-') || ' ' ||
10845 RPAD('-', 30, '-') || ' ' || LPAD('-', 10, '-'));
10846
10847 FOR recno IN 1..r_da.line_account_id.COUNT
10848 LOOP
10849 hr_utility.trace(LPAD(r_da.line_account_id(recno), 17, ' ') || ' ' ||
10850 RPAD(TO_CHAR(r_da.start_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
10851 RPAD(TO_CHAR(r_da.end_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
10852 RPAD(NVL(TO_CHAR(r_da.poeta_start_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
10853 RPAD(NVL(TO_CHAR(r_da.poeta_end_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
10854 LPAD(NVL(r_da.gl_code_combination_id(recno), '-1'), 15, ' ') || ' ' ||
10855 LPAD(NVL(r_da.project_id(recno), '-1'), 15, ' ') || ' ' ||
10856 LPAD(NVL(r_da.task_id(recno), '-1'), 15, ' ') || ' ' ||
10857 LPAD(NVL(r_da.award_id(recno), '-1'), 15, ' ') || ' ' ||
10858 LPAD(NVL(r_da.expenditure_organization_id(recno), '-1'), 18, ' ') || ' ' ||
10859 RPAD(NVL(r_da.expenditure_type(recno), ' '), 30, ' ') || ' ' ||
10860 LPAD(r_da.percent(recno), 10, ' '));
10861 IF (r_da.expenditure_type(recno) IS NOT NULL) THEN
10862 psp_enc_pre_process.validate_poeta (p_project_id => r_da.project_id(recno),
10863 p_task_id => r_da.task_id(recno),
10864 p_award_id => r_da.award_id(recno),
10865 p_expenditure_type => r_da.expenditure_type(recno),
10866 p_expenditure_organization_id => r_da.expenditure_organization_id(recno),
10867 p_payroll_id => p_payroll_id,
10868 p_start_date => r_da.poeta_start_date(recno),
10869 p_end_date => r_da.poeta_end_date(recno),
10870 p_return_status => p_return_status);
10871
10872 IF p_return_status <> fnd_api.g_ret_sts_success THEN
10873 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10874 END IF;
10875 END IF;
10876 g_pateo_end_date := GREATEST(g_pateo_end_date, NVL(r_da.poeta_end_date(recno), g_pateo_end_date));
10877 END LOOP;
10878
10879 hr_utility.trace('
10880 Suspense Account Hierarchy');
10881 hr_utility.trace(LPAD('Line Account Id', 17, ' ') || ' ' ||
10882 RPAD('Start Date Active', 17, ' ') || ' ' || RPAD('End Date Active', 17, ' ') || ' ' ||
10883 RPAD('PATEO Start Date', 17, ' ') || ' ' || RPAD('PATEO End Date', 17, ' ') || ' ' ||
10884 LPAD('GL CC Id', 15, ' ') || ' ' || LPAD('Project Id', 15, ' ') || ' ' ||
10885 LPAD('Task Id', 15, ' ') || ' ' || LPAD('Award Id', 15, ' ') || ' ' ||
10886 LPAD('Expenditure Org Id', 18, ' ') || ' ' || RPAD('Expenditure Type', 30, ' ') || ' ' ||
10887 LPAD('Percent', 10, ' '));
10888
10889 hr_utility.trace(LPAD('-', 17, '-') || ' ' ||
10890 RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
10891 RPAD('-', 17, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' ||
10892 LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 18, '-') || ' ' ||
10893 RPAD('-', 30, '-') || ' ' || LPAD('-', 10, '-'));
10894
10895 FOR recno IN 1..r_sa.line_account_id.COUNT
10896 LOOP
10897 hr_utility.trace(LPAD(r_sa.line_account_id(recno), 17, ' ') || ' ' ||
10898 RPAD(TO_CHAR(r_sa.start_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
10899 RPAD(TO_CHAR(r_sa.end_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
10900 RPAD(NVL(TO_CHAR(r_sa.poeta_start_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
10901 RPAD(NVL(TO_CHAR(r_sa.poeta_end_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
10902 LPAD(NVL(r_sa.gl_code_combination_id(recno), '-1'), 15, ' ') || ' ' ||
10903 LPAD(NVL(r_sa.project_id(recno), '-1'), 15, ' ') || ' ' ||
10904 LPAD(NVL(r_sa.task_id(recno), '-1'), 15, ' ') || ' ' ||
10905 LPAD(NVL(r_sa.award_id(recno), '-1'), 15, ' ') || ' ' ||
10906 LPAD(NVL(r_sa.expenditure_organization_id(recno), '-1'), 18, ' ') || ' ' ||
10907 RPAD(NVL(r_sa.expenditure_type(recno), ' '), 30, ' ') || ' ' ||
10908 LPAD(r_sa.percent(recno), 10, ' '));
10909 IF (r_sa.expenditure_type(recno) IS NOT NULL) THEN
10910 psp_enc_pre_process.validate_poeta (p_project_id => r_sa.project_id(recno),
10911 p_task_id => r_sa.task_id(recno),
10912 p_award_id => r_sa.award_id(recno),
10913 p_expenditure_type => r_sa.expenditure_type(recno),
10914 p_expenditure_organization_id => r_sa.expenditure_organization_id(recno),
10915 p_payroll_id => p_payroll_id,
10916 p_start_date => r_sa.poeta_start_date(recno),
10917 p_end_date => r_sa.poeta_end_date(recno),
10918 p_return_status => p_return_status);
10919
10920 IF p_return_status <> fnd_api.g_ret_sts_success THEN
10921 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
10922 END IF;
10923 END IF;
10924 g_pateo_end_date := GREATEST(g_pateo_end_date, NVL(r_sa.poeta_end_date(recno), g_pateo_end_date));
10925 END LOOP;
10926
10927 IF ((g_pateo_end_date = fnd_date.canonical_to_date('1800/01/01 00:00:00')) OR
10928 (g_pateo_end_date < g_enc_org_end_date)) THEN
10929 g_pateo_end_date := g_enc_org_end_date;
10930 END IF;
10931 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' g_pateo_end_date: ' || TO_CHAR(g_pateo_end_date, 'DD-MON-RRRR'));
10932
10933 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving LOAD_SCH_HIERARCHY');
10934 p_return_status := fnd_api.g_ret_sts_success;
10935 EXCEPTION
10936 WHEN OTHERS THEN
10937 IF (g_error_message IS NULL) THEN
10938 g_error_message := 'LOAD_SCH_HIERARCHY: ' || SQLERRM;
10939 END IF;
10940 g_error_api_path := SUBSTR(' LOAD_SCH_HIERARCHY:'||g_error_api_path,1,230);
10941 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', ' LOAD_SCH_HIERARCHY');
10942 p_return_status := fnd_api.g_ret_sts_unexp_error;
10943 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' ' || fnd_number.number_to_canonical(l_proc_step) || ': LOAD_SCH_HIERARCHY');
10944 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving LOAD_SCH_HIERARCHY');
10945 END load_sch_hierarchy;
10946
10947 PROCEDURE add_cel_warnings(p_start_date IN DATE DEFAULT NULL,
10948 p_end_date IN DATE DEFAULT NULL,
10949 p_hierarchy_code IN VARCHAR2 DEFAULT NULL,
10950 p_warning_code IN VARCHAR2 DEFAULT NULL,
10951 p_gl_ccid IN NUMBER DEFAULT NULL,
10952 p_project_id IN NUMBER DEFAULT NULL,
10953 p_task_id IN NUMBER DEFAULT NULL,
10954 p_award_id IN NUMBER DEFAULT NULL,
10955 p_exp_org_id IN NUMBER DEFAULT NULL,
10956 p_exp_type IN VARCHAR2 DEFAULT NULL,
10957 p_effective_date IN DATE DEFAULT NULL,
10958 p_error_status IN VARCHAR2 DEFAULT NULL,
10959 p_percent IN NUMBER DEFAULT NULL) IS
10960 l_warning_ind NUMBER(15);
10961 l_duplicate_ind NUMBER(15);
10962 BEGIN
10963 hr_utility.trace('Entering add_cel_warnings');
10964 l_warning_ind := cel_warnings.start_date.COUNT;
10965 hr_utility.trace('p_start_date: ' || p_start_date || ' p_end_date: ' || p_end_date ||
10966 ' p_hierarchy_code: ' || p_hierarchy_code || ' p_warning_code: ' || p_warning_code ||
10967 ' p_gl_ccid: ' || p_gl_ccid || ' p_project_id: ' || p_project_id || ' p_task_id: ' || p_task_id ||
10968 ' p_award_id:' || p_award_id || ' p_exp_org_id: ' || p_exp_org_id ||
10969 ' p_exp_type: ' || p_exp_type || ' p_effective_date: ' || p_effective_date ||
10970 ' p_error_status: ' || p_error_status || ' p_percent: ' || p_percent);
10971
10972 IF (p_warning_code = 'BAL') THEN
10973 LOOP
10974 EXIT WHEN l_warning_ind = 0;
10975 EXIT WHEN (( (cel_warnings.end_date(l_warning_ind) = (p_start_date -1) OR
10976 ( (cel_warnings.end_date(l_warning_ind) >= p_start_date) AND
10977 (cel_warnings.start_date(l_warning_ind) <= p_end_date)))) AND
10978 (cel_warnings.hierarchy_code(l_warning_ind) = p_hierarchy_code) AND
10979 (cel_warnings.warning_code(l_warning_ind) = 'BAL') AND
10980 (cel_warnings.percent(l_warning_ind) = p_percent));
10981 l_warning_ind := l_warning_ind - 1;
10982 END LOOP;
10983 hr_utility.trace('processing bal l_warning_ind: ' || l_warning_ind);
10984
10985 l_duplicate_ind := cel_warnings.start_date.COUNT;
10986 LOOP
10987 EXIT WHEN l_duplicate_ind = 0;
10988 EXIT WHEN (( (cel_warnings.end_date(l_duplicate_ind) = (p_start_date -1) OR
10989 ( (cel_warnings.end_date(l_duplicate_ind) >= p_start_date) AND
10990 (cel_warnings.start_date(l_duplicate_ind) <= p_end_date)))) AND
10991 (cel_warnings.hierarchy_code(l_duplicate_ind) <> p_hierarchy_code) AND
10992 (cel_warnings.warning_code(l_duplicate_ind) = 'BAL') AND
10993 (cel_warnings.percent(l_duplicate_ind) = p_percent));
10994 l_duplicate_ind := l_duplicate_ind - 1;
10995 END LOOP;
10996 hr_utility.trace('processing bal l_duplicate_ind: ' || l_duplicate_ind);
10997
10998 IF (l_warning_ind = 0) THEN
10999 l_warning_ind := cel_warnings.start_date.COUNT + 1;
11000 cel_warnings.start_date(l_warning_ind) := p_start_date;
11001 cel_warnings.end_date(l_warning_ind) := p_end_date;
11002 cel_warnings.hierarchy_code(l_warning_ind) := p_hierarchy_code;
11003 cel_warnings.warning_code(l_warning_ind) := p_warning_code;
11004 cel_warnings.gl_ccid(l_warning_ind) := NULL;
11005 cel_warnings.project_id(l_warning_ind) := NULL;
11006 cel_warnings.task_id(l_warning_ind) := NULL;
11007 cel_warnings.award_id(l_warning_ind) := NULL;
11008 cel_warnings.exp_org_id(l_warning_ind) := NULL;
11009 cel_warnings.exp_type(l_warning_ind) := NULL;
11010 cel_warnings.effective_date(l_warning_ind) := NULL;
11011 cel_warnings.error_status(l_warning_ind) := NULL;
11012 cel_warnings.percent(l_warning_ind) := p_percent;
11013 ELSE
11014 cel_warnings.end_date(l_warning_ind) := p_end_date;
11015 END IF;
11016
11017 IF (l_duplicate_ind > 0) THEN
11018 cel_warnings.end_date(l_duplicate_ind) := p_end_date;
11019 cel_warnings.start_date(l_warning_ind) := cel_warnings.start_date(l_duplicate_ind);
11020 END IF;
11021 ELSIF (p_warning_code = 'NO_CI') THEN
11022 LOOP
11023 EXIT WHEN l_warning_ind = 0;
11024 EXIT WHEN (( (cel_warnings.end_date(l_warning_ind) = (p_start_date -1) OR
11025 ( (cel_warnings.end_date(l_warning_ind) >= p_start_date) AND
11026 (cel_warnings.start_date(l_warning_ind) <= p_end_date)))) AND
11027 (cel_warnings.hierarchy_code(l_warning_ind) = p_hierarchy_code) AND
11028 (cel_warnings.warning_code(l_warning_ind) = 'NO_CI'));
11029 l_warning_ind := l_warning_ind - 1;
11030 END LOOP;
11031 hr_utility.trace('processing no_ci l_warning_ind: ' || l_warning_ind);
11032
11033 l_duplicate_ind := cel_warnings.start_date.COUNT;
11034 LOOP
11035 EXIT WHEN l_duplicate_ind = 0;
11036 EXIT WHEN (( (cel_warnings.end_date(l_duplicate_ind) = (p_start_date -1) OR
11037 ( (cel_warnings.end_date(l_duplicate_ind) >= p_start_date) AND
11038 (cel_warnings.start_date(l_duplicate_ind) <= p_end_date)))) AND
11039 (cel_warnings.hierarchy_code(l_duplicate_ind) <> p_hierarchy_code) AND
11040 (cel_warnings.warning_code(l_duplicate_ind) = 'NO_CI'));
11041 l_duplicate_ind := l_duplicate_ind - 1;
11042 END LOOP;
11043 hr_utility.trace('processing no_ci l_duplicate_ind: ' || l_duplicate_ind);
11044
11045 IF (l_warning_ind = 0) THEN
11046 l_warning_ind := cel_warnings.start_date.COUNT + 1;
11047 cel_warnings.start_date(l_warning_ind) := p_start_date;
11048 cel_warnings.end_date(l_warning_ind) := p_end_date;
11049 cel_warnings.hierarchy_code(l_warning_ind) := p_hierarchy_code;
11050 cel_warnings.warning_code(l_warning_ind) := p_warning_code;
11051 cel_warnings.gl_ccid(l_warning_ind) := NULL;
11052 cel_warnings.project_id(l_warning_ind) := NULL;
11053 cel_warnings.task_id(l_warning_ind) := NULL;
11054 cel_warnings.award_id(l_warning_ind) := NULL;
11055 cel_warnings.exp_org_id(l_warning_ind) := NULL;
11056 cel_warnings.exp_type(l_warning_ind) := NULL;
11057 cel_warnings.effective_date(l_warning_ind) := NULL;
11058 cel_warnings.error_status(l_warning_ind) := NULL;
11059 cel_warnings.percent(l_warning_ind) := NULL;
11060 ELSE
11061 cel_warnings.end_date(l_warning_ind) := p_end_date;
11062 END IF;
11063
11064 IF (l_duplicate_ind > 0) THEN
11065 cel_warnings.end_date(l_duplicate_ind) := p_end_date;
11066 cel_warnings.start_date(l_warning_ind) := cel_warnings.start_date(l_duplicate_ind);
11067 END IF;
11068 ELSIF (p_warning_code = 'INVALID_CI') THEN
11069 LOOP
11070 EXIT WHEN l_warning_ind = 0;
11071 EXIT WHEN (( (cel_warnings.end_date(l_warning_ind) = (p_start_date -1) OR
11072 ( (cel_warnings.end_date(l_warning_ind) >= p_start_date) AND
11073 (cel_warnings.start_date(l_warning_ind) <= p_end_date)))) AND
11074 (cel_warnings.hierarchy_code(l_warning_ind) = p_hierarchy_code) AND
11075 (cel_warnings.warning_code(l_warning_ind) = 'INVALID_CI') AND
11076 (cel_warnings.project_id(l_warning_ind) = p_project_id) AND
11077 (cel_warnings.task_id(l_warning_ind) = p_task_id) AND
11078 (cel_warnings.award_id(l_warning_ind) = p_award_id) AND
11079 (cel_warnings.exp_org_id(l_warning_ind) = p_exp_org_id) AND
11080 (cel_warnings.exp_type(l_warning_ind) = p_exp_type) AND
11081 (NVL(cel_warnings.error_status(l_warning_ind), 'NULL') = NVL(p_error_status, 'NULL')));
11082 l_warning_ind := l_warning_ind - 1;
11083 END LOOP;
11084 hr_utility.trace('processing invalid_ci l_warning_ind: ' || l_warning_ind);
11085
11086 IF (l_warning_ind = 0) THEN
11087 l_warning_ind := cel_warnings.start_date.COUNT + 1;
11088 cel_warnings.start_date(l_warning_ind) := p_start_date;
11089 cel_warnings.end_date(l_warning_ind) := p_end_date;
11090 cel_warnings.hierarchy_code(l_warning_ind) := p_hierarchy_code;
11091 cel_warnings.warning_code(l_warning_ind) := p_warning_code;
11092 cel_warnings.gl_ccid(l_warning_ind) := NULL;
11093 cel_warnings.project_id(l_warning_ind) := p_project_id;
11094 cel_warnings.task_id(l_warning_ind) := p_task_id;
11095 cel_warnings.award_id(l_warning_ind) := p_award_id;
11096 cel_warnings.exp_org_id(l_warning_ind) := p_exp_org_id;
11097 cel_warnings.exp_type(l_warning_ind) := p_exp_type;
11098 cel_warnings.effective_date(l_warning_ind) := p_effective_date;
11099 cel_warnings.error_status(l_warning_ind) := p_error_status;
11100 cel_warnings.percent(l_warning_ind) := NULL;
11101 ELSE
11102 cel_warnings.end_date(l_warning_ind) := p_end_date;
11103 END IF;
11104 ELSIF (p_warning_code = 'AUTOPOP') AND (p_gl_ccid IS NOT NULL) THEN
11105 LOOP
11106 EXIT WHEN l_warning_ind = 0;
11107 EXIT WHEN (( (cel_warnings.end_date(l_warning_ind) = (p_start_date -1) OR
11108 ( (cel_warnings.end_date(l_warning_ind) >= p_start_date) AND
11109 (cel_warnings.start_date(l_warning_ind) <= p_end_date)))) AND
11110 (cel_warnings.hierarchy_code(l_warning_ind) = p_hierarchy_code) AND
11111 (cel_warnings.warning_code(l_warning_ind) = 'AUTOPOP') AND
11112 (cel_warnings.gl_ccid(l_warning_ind) = p_gl_ccid) AND
11113 (NVL(cel_warnings.error_status(l_warning_ind), 'NULL') = NVL(p_error_status, 'NULL')));
11114 l_warning_ind := l_warning_ind - 1;
11115 END LOOP;
11116 hr_utility.trace('processing autopop l_warning_ind: ' || l_warning_ind);
11117
11118 IF (l_warning_ind = 0) THEN
11119 l_warning_ind := cel_warnings.start_date.COUNT + 1;
11120 cel_warnings.start_date(l_warning_ind) := p_start_date;
11121 cel_warnings.end_date(l_warning_ind) := p_end_date;
11122 cel_warnings.hierarchy_code(l_warning_ind) := p_hierarchy_code;
11123 cel_warnings.warning_code(l_warning_ind) := p_warning_code;
11124 cel_warnings.gl_ccid(l_warning_ind) := p_gl_ccid;
11125 cel_warnings.project_id(l_warning_ind) := NULL;
11126 cel_warnings.task_id(l_warning_ind) := NULL;
11127 cel_warnings.award_id(l_warning_ind) := NULL;
11128 cel_warnings.exp_org_id(l_warning_ind) := NULL;
11129 cel_warnings.exp_type(l_warning_ind) := NULL;
11130 cel_warnings.effective_date(l_warning_ind) := NULL;
11131 cel_warnings.error_status(l_warning_ind) := p_error_status;
11132 cel_warnings.percent(l_warning_ind) := NULL;
11133 ELSE
11134 cel_warnings.end_date(l_warning_ind) := p_end_date;
11135 END IF;
11136 ELSIF (p_warning_code = 'AUTOPOP') AND (p_gl_ccid IS NULL) THEN
11137 LOOP
11138 EXIT WHEN l_warning_ind = 0;
11139 EXIT WHEN (( (cel_warnings.end_date(l_warning_ind) = (p_start_date -1) OR
11140 ( (cel_warnings.end_date(l_warning_ind) >= p_start_date) AND
11141 (cel_warnings.start_date(l_warning_ind) <= p_end_date)))) AND
11142 (cel_warnings.hierarchy_code(l_warning_ind) = p_hierarchy_code) AND
11143 (cel_warnings.warning_code(l_warning_ind) = 'AUTOPOP') AND
11144 (cel_warnings.project_id(l_warning_ind) = p_project_id) AND
11145 (cel_warnings.task_id(l_warning_ind) = p_task_id) AND
11146 (cel_warnings.award_id(l_warning_ind) = p_award_id) AND
11147 (cel_warnings.exp_org_id(l_warning_ind) = p_exp_org_id) AND
11148 (cel_warnings.exp_type(l_warning_ind) = p_exp_type) AND
11149 (NVL(cel_warnings.error_status(l_warning_ind), 'NULL') = NVL(p_error_status, 'NULL')));
11150 l_warning_ind := l_warning_ind - 1;
11151 END LOOP;
11152 hr_utility.trace('processing autopop l_warning_ind: ' || l_warning_ind);
11153
11154 IF (l_warning_ind = 0) THEN
11155 l_warning_ind := cel_warnings.start_date.COUNT + 1;
11156 cel_warnings.start_date(l_warning_ind) := p_start_date;
11157 cel_warnings.end_date(l_warning_ind) := p_end_date;
11158 cel_warnings.hierarchy_code(l_warning_ind) := p_hierarchy_code;
11159 cel_warnings.warning_code(l_warning_ind) := p_warning_code;
11160 cel_warnings.gl_ccid(l_warning_ind) := NULL;
11161 cel_warnings.project_id(l_warning_ind) := p_project_id;
11162 cel_warnings.task_id(l_warning_ind) := p_task_id;
11163 cel_warnings.award_id(l_warning_ind) := p_award_id;
11164 cel_warnings.exp_org_id(l_warning_ind) := p_exp_org_id;
11165 cel_warnings.exp_type(l_warning_ind) := p_exp_type;
11166 cel_warnings.effective_date(l_warning_ind) := NULL;
11167 cel_warnings.error_status(l_warning_ind) := p_error_status;
11168 cel_warnings.percent(l_warning_ind) := NULL;
11169 ELSE
11170 cel_warnings.end_date(l_warning_ind) := p_end_date;
11171 END IF;
11172 ELSIF (p_warning_code = 'GL') THEN
11173 LOOP
11174 EXIT WHEN l_warning_ind = 0;
11175 EXIT WHEN (( (cel_warnings.end_date(l_warning_ind) = (p_start_date -1) OR
11176 ( (cel_warnings.end_date(l_warning_ind) >= p_start_date) AND
11177 (cel_warnings.start_date(l_warning_ind) <= p_end_date)))) AND
11178 (cel_warnings.hierarchy_code(l_warning_ind) = p_hierarchy_code) AND
11179 (cel_warnings.warning_code(l_warning_ind) = 'GL'));
11180 l_warning_ind := l_warning_ind - 1;
11181 END LOOP;
11182 hr_utility.trace('processing bal l_warning_ind: ' || l_warning_ind);
11183
11184 l_duplicate_ind := cel_warnings.start_date.COUNT;
11185 LOOP
11186 EXIT WHEN l_duplicate_ind = 0;
11187 EXIT WHEN (( (cel_warnings.end_date(l_duplicate_ind) = (p_start_date -1) OR
11188 ( (cel_warnings.end_date(l_duplicate_ind) >= p_start_date) AND
11189 (cel_warnings.start_date(l_duplicate_ind) <= p_end_date)))) AND
11190 (cel_warnings.hierarchy_code(l_duplicate_ind) <> p_hierarchy_code) AND
11191 (cel_warnings.warning_code(l_duplicate_ind) = 'GL'));
11192 l_duplicate_ind := l_duplicate_ind - 1;
11193 END LOOP;
11194 hr_utility.trace('processing bal l_duplicate_ind: ' || l_duplicate_ind);
11195
11196 IF (l_warning_ind = 0) THEN
11197 l_warning_ind := cel_warnings.start_date.COUNT + 1;
11198 cel_warnings.start_date(l_warning_ind) := p_start_date;
11199 cel_warnings.end_date(l_warning_ind) := p_end_date;
11200 cel_warnings.hierarchy_code(l_warning_ind) := p_hierarchy_code;
11201 cel_warnings.warning_code(l_warning_ind) := p_warning_code;
11202 cel_warnings.gl_ccid(l_warning_ind) := NULL;
11203 cel_warnings.project_id(l_warning_ind) := NULL;
11204 cel_warnings.task_id(l_warning_ind) := NULL;
11205 cel_warnings.award_id(l_warning_ind) := NULL;
11206 cel_warnings.exp_org_id(l_warning_ind) := NULL;
11207 cel_warnings.exp_type(l_warning_ind) := NULL;
11208 cel_warnings.effective_date(l_warning_ind) := NULL;
11209 cel_warnings.error_status(l_warning_ind) := NULL;
11210 cel_warnings.percent(l_warning_ind) := p_percent;
11211 ELSE
11212 cel_warnings.end_date(l_warning_ind) := p_end_date;
11213 cel_warnings.percent(l_warning_ind) := cel_warnings.percent(l_warning_ind) + p_percent;
11214 END IF;
11215
11216 IF (l_duplicate_ind > 0) THEN
11217 cel_warnings.end_date(l_duplicate_ind) := p_end_date;
11218 cel_warnings.start_date(l_warning_ind) := cel_warnings.start_date(l_duplicate_ind);
11219 cel_warnings.percent(l_warning_ind) := cel_warnings.percent(l_duplicate_ind) + p_percent;
11220 END IF;
11221 END IF;
11222 hr_utility.trace('cel_warnings.start_date.COUNT: ' || cel_warnings.start_date.COUNT);
11223 hr_utility.trace('Leaving add_cel_warnings');
11224 END add_cel_warnings;
11225
11226 PROCEDURE delete_previous_error_log(p_assignment_id IN NUMBER,
11227 p_payroll_id IN NUMBER,
11228 p_payroll_action_id IN NUMBER) IS
11229 PRAGMA AUTONOMOUS_TRANSACTION;
11230 BEGIN
11231 DELETE psp_report_errors
11232 WHERE source_id = p_assignment_id
11233 AND value1 = p_payroll_id
11234 AND payroll_action_id = p_payroll_action_id;
11235
11236 COMMIT;
11237 END delete_previous_error_log;
11238
11239 PROCEDURE update_hierarchy_dates (p_assignment_id IN NUMBER,
11240 p_payroll_id IN NUMBER,
11241 p_payroll_action_id IN NUMBER,
11242 p_return_status OUT NOCOPY VARCHAR2) IS
11243 CURSOR hierarchy_dates_cur IS
11244 SELECT DISTINCT enc_element_type_id,
11245 hierarchy_code,
11246 NVL(gl_code_combination_id, -99),
11247 NVL(project_id, -99),
11248 NVL(task_id, -99),
11249 NVL(award_id, -99),
11250 NVL(expenditure_organization_id, -99),
11251 NVL(expenditure_type, '-99'),
11252 enc_start_date,
11253 enc_end_date
11254 FROM psp_enc_lines
11255 WHERE payroll_action_id = p_payroll_action_id
11256 AND assignment_id = p_assignment_id
11257 AND payroll_id = p_payroll_id
11258 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
11259
11260 CURSOR history_dates_cur IS
11261 SELECT DISTINCT enc_element_type_id,
11262 hierarchy_code,
11263 NVL(gl_code_combination_id, -99),
11264 NVL(project_id, -99),
11265 NVL(task_id, -99),
11266 NVL(award_id, -99),
11267 NVL(expenditure_organization_id, -99),
11268 NVL(expenditure_type, '-99'),
11269 enc_start_date,
11270 enc_end_date
11271 FROM psp_enc_lines_history
11272 WHERE assignment_id = p_assignment_id
11273 AND payroll_id = p_payroll_id
11274 AND change_flag = 'N'
11275 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
11276
11277 TYPE r_enc_rec IS RECORD
11278 (element_type_id t_num_15_type,
11279 hierarchy_code t_varchar_50_type,
11280 gl_ccid t_num_15_type,
11281 project_id t_num_15_type,
11282 task_id t_num_15_type,
11283 award_id t_num_15_type,
11284 exp_org_id t_num_15_type,
11285 exp_type t_varchar_50_type,
11286 enc_start_date t_date_type,
11287 enc_end_date t_date_type);
11288
11289 t_enc_lines r_enc_rec;
11290 t_enc_nlines r_enc_rec;
11291 l_nlines_counter NUMBER(15);
11292 BEGIN
11293 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering UPDATE_HIERARCHY_DATES');
11294 OPEN hierarchy_dates_cur;
11295 FETCH hierarchy_dates_cur BULK COLLECT INTO t_enc_lines.element_type_id, t_enc_lines.hierarchy_code,
11296 t_enc_lines.gl_ccid, t_enc_lines.project_id, t_enc_lines.task_id,
11297 t_enc_lines.award_id, t_enc_lines.exp_org_id, t_enc_lines.exp_type,
11298 t_enc_lines.enc_start_date, t_enc_lines.enc_end_date;
11299 CLOSE hierarchy_dates_cur;
11300
11301 IF (t_enc_lines.element_type_id.COUNT > 0) THEN
11302 t_enc_nlines.element_type_id(1) := t_enc_lines.element_type_id(1);
11303 t_enc_nlines.hierarchy_code(1) := t_enc_lines.hierarchy_code(1);
11304 t_enc_nlines.gl_ccid(1) := t_enc_lines.gl_ccid(1);
11305 t_enc_nlines.project_id(1) := t_enc_lines.project_id(1);
11306 t_enc_nlines.task_id(1) := t_enc_lines.task_id(1);
11307 t_enc_nlines.award_id(1) := t_enc_lines.award_id(1);
11308 t_enc_nlines.exp_org_id(1) := t_enc_lines.exp_org_id(1);
11309 t_enc_nlines.exp_type(1) := t_enc_lines.exp_type(1);
11310 t_enc_nlines.enc_start_date(1) := t_enc_lines.enc_start_date(1);
11311 t_enc_nlines.enc_end_date(1) := t_enc_lines.enc_end_date(1);
11312 l_nlines_counter := 1;
11313 FOR recno IN 2..t_enc_lines.element_type_id.COUNT
11314 LOOP
11315 IF (t_enc_lines.element_type_id(recno) = t_enc_lines.element_type_id(recno-1) AND
11316 t_enc_lines.hierarchy_code(recno) = t_enc_lines.hierarchy_code(recno-1) AND
11317 t_enc_lines.gl_ccid(recno) = t_enc_lines.gl_ccid(recno-1) AND
11318 t_enc_lines.project_id(recno) = t_enc_lines.project_id(recno-1) AND
11319 t_enc_lines.task_id(recno) = t_enc_lines.task_id(recno-1) AND
11320 t_enc_lines.award_id(recno) = t_enc_lines.award_id(recno-1) AND
11321 t_enc_lines.exp_org_id(recno) = t_enc_lines.exp_org_id(recno-1) AND
11322 t_enc_lines.exp_type(recno) = t_enc_lines.exp_type(recno-1) AND
11323 t_enc_lines.enc_start_date(recno) -1 = t_enc_lines.enc_end_date(recno-1)) THEN
11324 t_enc_nlines.enc_end_date(l_nlines_counter) := t_enc_lines.enc_end_date(recno);
11325 ELSE
11326 l_nlines_counter := l_nlines_counter + 1;
11327 t_enc_nlines.element_type_id(l_nlines_counter) := t_enc_lines.element_type_id(recno);
11328 t_enc_nlines.hierarchy_code(l_nlines_counter) := t_enc_lines.hierarchy_code(recno);
11329 t_enc_nlines.gl_ccid(l_nlines_counter) := t_enc_lines.gl_ccid(recno);
11330 t_enc_nlines.project_id(l_nlines_counter) := t_enc_lines.project_id(recno);
11331 t_enc_nlines.task_id(l_nlines_counter) := t_enc_lines.task_id(recno);
11332 t_enc_nlines.award_id(l_nlines_counter) := t_enc_lines.award_id(recno);
11333 t_enc_nlines.exp_org_id(l_nlines_counter) := t_enc_lines.exp_org_id(recno);
11334 t_enc_nlines.exp_type(l_nlines_counter) := t_enc_lines.exp_type(recno);
11335 t_enc_nlines.enc_start_date(l_nlines_counter) := t_enc_lines.enc_start_date(recno);
11336 t_enc_nlines.enc_end_date(l_nlines_counter) := t_enc_lines.enc_end_date(recno);
11337 END IF;
11338 END LOOP;
11339
11340 FOR recno IN 1..t_enc_nlines.element_type_id.COUNT
11341 LOOP
11342 IF (t_enc_nlines.gl_ccid(recno) = -99) THEN
11343 t_enc_nlines.gl_ccid(recno) := NULL;
11344 ELSE
11345 t_enc_nlines.project_id(recno) := NULL;
11346 t_enc_nlines.task_id(recno) := NULL;
11347 t_enc_nlines.award_id(recno) := NULL;
11348 t_enc_nlines.exp_org_id(recno) := NULL;
11349 t_enc_nlines.exp_type(recno) := NULL;
11350 END IF;
11351 END LOOP;
11352
11353 FORALL recno IN 1..t_enc_nlines.element_type_id.COUNT
11354 UPDATE psp_enc_lines
11355 SET hierarchy_start_date = t_enc_nlines.enc_start_date(recno),
11356 hierarchy_end_date = t_enc_nlines.enc_end_date(recno)
11357 WHERE payroll_action_id = p_payroll_action_id
11358 AND assignment_id = p_assignment_id
11359 AND payroll_id = p_payroll_id
11360 AND enc_element_type_id = t_enc_nlines.element_type_id(recno)
11361 AND hierarchy_code = t_enc_nlines.hierarchy_code(recno)
11362 AND gl_code_combination_id IS NOT NULL
11363 AND t_enc_nlines.gl_ccid(recno) IS NOT NULL
11364 AND gl_code_combination_id = t_enc_nlines.gl_ccid(recno)
11365 AND enc_start_date <= t_enc_nlines.enc_end_date(recno)
11366 AND enc_end_date >= t_enc_nlines.enc_start_date(recno);
11367
11368 FORALL recno IN 1..t_enc_nlines.element_type_id.COUNT
11369 UPDATE psp_enc_lines
11370 SET hierarchy_start_date = t_enc_nlines.enc_start_date(recno),
11371 hierarchy_end_date = t_enc_nlines.enc_end_date(recno)
11372 WHERE payroll_action_id = p_payroll_action_id
11373 AND assignment_id = p_assignment_id
11374 AND payroll_id = p_payroll_id
11375 AND enc_element_type_id = t_enc_nlines.element_type_id(recno)
11376 AND hierarchy_code = t_enc_nlines.hierarchy_code(recno)
11377 AND award_id IS NOT NULL
11378 AND t_enc_nlines.award_id(recno) IS NOT NULL
11379 AND project_id = t_enc_nlines.project_id(recno)
11380 AND task_id = t_enc_nlines.task_id(recno)
11381 AND award_id = t_enc_nlines.award_id(recno)
11382 AND expenditure_organization_id = t_enc_nlines.exp_org_id(recno)
11383 AND expenditure_type = t_enc_nlines.exp_type(recno)
11384 AND enc_start_date <= t_enc_nlines.enc_end_date(recno)
11385 AND enc_end_date >= t_enc_nlines.enc_start_date(recno);
11386 END IF;
11387
11388 t_enc_lines.element_type_id.DELETE;
11389 t_enc_lines.hierarchy_code.DELETE;
11390 t_enc_lines.gl_ccid.DELETE;
11391 t_enc_lines.project_id.DELETE;
11392 t_enc_lines.task_id.DELETE;
11393 t_enc_lines.award_id.DELETE;
11394 t_enc_lines.exp_org_id.DELETE;
11395 t_enc_lines.exp_type.DELETE;
11396 t_enc_lines.enc_start_date.DELETE;
11397 t_enc_lines.enc_end_date.DELETE;
11398
11399 t_enc_nlines.element_type_id.DELETE;
11400 t_enc_nlines.hierarchy_code.DELETE;
11401 t_enc_nlines.gl_ccid.DELETE;
11402 t_enc_nlines.project_id.DELETE;
11403 t_enc_nlines.task_id.DELETE;
11404 t_enc_nlines.award_id.DELETE;
11405 t_enc_nlines.exp_org_id.DELETE;
11406 t_enc_nlines.exp_type.DELETE;
11407 t_enc_nlines.enc_start_date.DELETE;
11408 t_enc_nlines.enc_end_date.DELETE;
11409
11410 OPEN history_dates_cur;
11411 FETCH history_dates_cur BULK COLLECT INTO t_enc_lines.element_type_id, t_enc_lines.hierarchy_code,
11412 t_enc_lines.gl_ccid, t_enc_lines.project_id, t_enc_lines.task_id,
11413 t_enc_lines.award_id, t_enc_lines.exp_org_id, t_enc_lines.exp_type,
11414 t_enc_lines.enc_start_date, t_enc_lines.enc_end_date;
11415 CLOSE history_dates_cur;
11416
11417 IF (t_enc_lines.element_type_id.COUNT > 0) THEN
11418 t_enc_nlines.element_type_id(1) := t_enc_lines.element_type_id(1);
11419 t_enc_nlines.hierarchy_code(1) := t_enc_lines.hierarchy_code(1);
11420 t_enc_nlines.gl_ccid(1) := t_enc_lines.gl_ccid(1);
11421 t_enc_nlines.project_id(1) := t_enc_lines.project_id(1);
11422 t_enc_nlines.task_id(1) := t_enc_lines.task_id(1);
11423 t_enc_nlines.award_id(1) := t_enc_lines.award_id(1);
11424 t_enc_nlines.exp_org_id(1) := t_enc_lines.exp_org_id(1);
11425 t_enc_nlines.exp_type(1) := t_enc_lines.exp_type(1);
11426 t_enc_nlines.enc_start_date(1) := t_enc_lines.enc_start_date(1);
11427 t_enc_nlines.enc_end_date(1) := t_enc_lines.enc_end_date(1);
11428 l_nlines_counter := 1;
11429 FOR recno IN 2..t_enc_lines.element_type_id.COUNT
11430 LOOP
11431 IF (t_enc_lines.element_type_id(recno) = t_enc_lines.element_type_id(recno-1) AND
11432 t_enc_lines.hierarchy_code(recno) = t_enc_lines.hierarchy_code(recno-1) AND
11433 t_enc_lines.gl_ccid(recno) = t_enc_lines.gl_ccid(recno-1) AND
11434 t_enc_lines.project_id(recno) = t_enc_lines.project_id(recno-1) AND
11435 t_enc_lines.task_id(recno) = t_enc_lines.task_id(recno-1) AND
11436 t_enc_lines.award_id(recno) = t_enc_lines.award_id(recno-1) AND
11437 t_enc_lines.exp_org_id(recno) = t_enc_lines.exp_org_id(recno-1) AND
11438 t_enc_lines.exp_type(recno) = t_enc_lines.exp_type(recno-1) AND
11439 t_enc_lines.enc_start_date(recno) -1 = t_enc_lines.enc_end_date(recno-1)) THEN
11440 t_enc_nlines.enc_end_date(l_nlines_counter) := t_enc_lines.enc_end_date(recno);
11441 ELSE
11442 l_nlines_counter := l_nlines_counter + 1;
11443 t_enc_nlines.element_type_id(l_nlines_counter) := t_enc_lines.element_type_id(recno);
11444 t_enc_nlines.hierarchy_code(l_nlines_counter) := t_enc_lines.hierarchy_code(recno);
11445 t_enc_nlines.gl_ccid(l_nlines_counter) := t_enc_lines.gl_ccid(recno);
11446 t_enc_nlines.project_id(l_nlines_counter) := t_enc_lines.project_id(recno);
11447 t_enc_nlines.task_id(l_nlines_counter) := t_enc_lines.task_id(recno);
11448 t_enc_nlines.award_id(l_nlines_counter) := t_enc_lines.award_id(recno);
11449 t_enc_nlines.exp_org_id(l_nlines_counter) := t_enc_lines.exp_org_id(recno);
11450 t_enc_nlines.exp_type(l_nlines_counter) := t_enc_lines.exp_type(recno);
11451 t_enc_nlines.enc_start_date(l_nlines_counter) := t_enc_lines.enc_start_date(recno);
11452 t_enc_nlines.enc_end_date(l_nlines_counter) := t_enc_lines.enc_end_date(recno);
11453 END IF;
11454 END LOOP;
11455
11456 FOR recno IN 1..t_enc_nlines.element_type_id.COUNT
11457 LOOP
11458 IF (t_enc_nlines.gl_ccid(recno) = -99) THEN
11459 t_enc_nlines.gl_ccid(recno) := NULL;
11460 ELSE
11461 t_enc_nlines.project_id(recno) := NULL;
11462 t_enc_nlines.task_id(recno) := NULL;
11463 t_enc_nlines.award_id(recno) := NULL;
11464 t_enc_nlines.exp_org_id(recno) := NULL;
11465 t_enc_nlines.exp_type(recno) := NULL;
11466 END IF;
11467 END LOOP;
11468
11469 FORALL recno IN 1..t_enc_nlines.element_type_id.COUNT
11470 UPDATE psp_enc_lines_history
11471 SET hierarchy_start_date = t_enc_nlines.enc_start_date(recno),
11472 hierarchy_end_date = t_enc_nlines.enc_end_date(recno)
11473 WHERE assignment_id = p_assignment_id
11474 AND payroll_id = p_payroll_id
11475 AND change_flag = 'N'
11476 AND enc_element_type_id = t_enc_nlines.element_type_id(recno)
11477 AND hierarchy_code = t_enc_nlines.hierarchy_code(recno)
11478 AND gl_code_combination_id IS NOT NULL
11479 AND t_enc_nlines.gl_ccid(recno) IS NOT NULL
11480 AND gl_code_combination_id = t_enc_nlines.gl_ccid(recno)
11481 AND enc_start_date <= t_enc_nlines.enc_end_date(recno)
11482 AND enc_end_date >= t_enc_nlines.enc_start_date(recno);
11483
11484 FORALL recno IN 1..t_enc_nlines.element_type_id.COUNT
11485 UPDATE psp_enc_lines_history
11486 SET hierarchy_start_date = t_enc_nlines.enc_start_date(recno),
11487 hierarchy_end_date = t_enc_nlines.enc_end_date(recno)
11488 WHERE assignment_id = p_assignment_id
11489 AND payroll_id = p_payroll_id
11490 AND change_flag = 'N'
11491 AND enc_element_type_id = t_enc_nlines.element_type_id(recno)
11492 AND hierarchy_code = t_enc_nlines.hierarchy_code(recno)
11493 AND award_id IS NOT NULL
11494 AND t_enc_nlines.award_id(recno) IS NOT NULL
11495 AND project_id = t_enc_nlines.project_id(recno)
11496 AND task_id = t_enc_nlines.task_id(recno)
11497 AND award_id = t_enc_nlines.award_id(recno)
11498 AND expenditure_organization_id = t_enc_nlines.exp_org_id(recno)
11499 AND expenditure_type = t_enc_nlines.exp_type(recno)
11500 AND enc_start_date <= t_enc_nlines.enc_end_date(recno)
11501 AND enc_end_date >= t_enc_nlines.enc_start_date(recno);
11502 END IF;
11503 p_return_status := fnd_api.g_ret_sts_success;
11504 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving UPDATE_HIERARCHY_DATES');
11505 EXCEPTION
11506 WHEN OTHERS THEN
11507 IF (g_error_message IS NULL) THEN
11508 g_error_message := 'UPDATE_HIERARCHY_DATES: ' || SQLERRM;
11509 END IF;
11510 g_error_api_path := SUBSTR(' UPDATE_HIERARCHY_DATES:'||g_error_api_path,1,230);
11511 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', ' UPDATE_HIERARCHY_DATES');
11512 p_return_status := fnd_api.g_ret_sts_unexp_error;
11513 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving UPDATE_HIERARCHY_DATES');
11514 END update_hierarchy_dates;
11515
11516 PROCEDURE clear_sch_hierarchy IS
11517 BEGIN
11518 r_sa.line_account_id.DELETE;
11519 r_sa.gl_code_combination_id.DELETE;
11520 r_sa.project_id.DELETE;
11521 r_sa.task_id.DELETE;
11522 r_sa.award_id.DELETE;
11523 r_sa.expenditure_type.DELETE;
11524 r_sa.expenditure_organization_id.DELETE;
11525 r_sa.start_date_active.DELETE;
11526 r_sa.end_date_active.DELETE;
11527 r_sa.poeta_start_date.DELETE;
11528 r_sa.poeta_end_date.DELETE;
11529 r_sa.percent.DELETE;
11530 r_sa.attribute_category.DELETE;
11531 r_sa.attribute1.DELETE;
11532 r_sa.attribute2.DELETE;
11533 r_sa.attribute3.DELETE;
11534 r_sa.attribute4.DELETE;
11535 r_sa.attribute5.DELETE;
11536 r_sa.attribute6.DELETE;
11537 r_sa.attribute7.DELETE;
11538 r_sa.attribute8.DELETE;
11539 r_sa.attribute9.DELETE;
11540 r_sa.attribute10.DELETE;
11541 r_sa.acct_type.DELETE;
11542
11543 r_da.line_account_id.DELETE;
11544 r_da.gl_code_combination_id.DELETE;
11545 r_da.project_id.DELETE;
11546 r_da.task_id.DELETE;
11547 r_da.award_id.DELETE;
11548 r_da.expenditure_type.DELETE;
11549 r_da.expenditure_organization_id.DELETE;
11550 r_da.start_date_active.DELETE;
11551 r_da.end_date_active.DELETE;
11552 r_da.poeta_start_date.DELETE;
11553 r_da.poeta_end_date.DELETE;
11554 r_da.percent.DELETE;
11555 r_da.attribute_category.DELETE;
11556 r_da.attribute1.DELETE;
11557 r_da.attribute2.DELETE;
11558 r_da.attribute3.DELETE;
11559 r_da.attribute4.DELETE;
11560 r_da.attribute5.DELETE;
11561 r_da.attribute6.DELETE;
11562 r_da.attribute7.DELETE;
11563 r_da.attribute8.DELETE;
11564 r_da.attribute9.DELETE;
11565 r_da.attribute10.DELETE;
11566 r_da.acct_type.DELETE;
11567
11568 r_odls.line_account_id.DELETE;
11569 r_odls.gl_code_combination_id.DELETE;
11570 r_odls.project_id.DELETE;
11571 r_odls.task_id.DELETE;
11572 r_odls.award_id.DELETE;
11573 r_odls.expenditure_type.DELETE;
11574 r_odls.expenditure_organization_id.DELETE;
11575 r_odls.start_date_active.DELETE;
11576 r_odls.end_date_active.DELETE;
11577 r_odls.poeta_start_date.DELETE;
11578 r_odls.poeta_end_date.DELETE;
11579 r_odls.percent.DELETE;
11580 r_odls.attribute_category.DELETE;
11581 r_odls.attribute1.DELETE;
11582 r_odls.attribute2.DELETE;
11583 r_odls.attribute3.DELETE;
11584 r_odls.attribute4.DELETE;
11585 r_odls.attribute5.DELETE;
11586 r_odls.attribute6.DELETE;
11587 r_odls.attribute7.DELETE;
11588 r_odls.attribute8.DELETE;
11589 r_odls.attribute9.DELETE;
11590 r_odls.attribute10.DELETE;
11591 r_odls.acct_type.DELETE;
11592
11593 r_asg.line_account_id.DELETE;
11594 r_asg.gl_code_combination_id.DELETE;
11595 r_asg.project_id.DELETE;
11596 r_asg.task_id.DELETE;
11597 r_asg.award_id.DELETE;
11598 r_asg.expenditure_type.DELETE;
11599 r_asg.expenditure_organization_id.DELETE;
11600 r_asg.start_date_active.DELETE;
11601 r_asg.end_date_active.DELETE;
11602 r_asg.poeta_start_date.DELETE;
11603 r_asg.poeta_end_date.DELETE;
11604 r_asg.percent.DELETE;
11605 r_asg.attribute_category.DELETE;
11606 r_asg.attribute1.DELETE;
11607 r_asg.attribute2.DELETE;
11608 r_asg.attribute3.DELETE;
11609 r_asg.attribute4.DELETE;
11610 r_asg.attribute5.DELETE;
11611 r_asg.attribute6.DELETE;
11612 r_asg.attribute7.DELETE;
11613 r_asg.attribute8.DELETE;
11614 r_asg.attribute9.DELETE;
11615 r_asg.attribute10.DELETE;
11616 r_asg.acct_type.DELETE;
11617
11618 r_ec.line_account_id.DELETE;
11619 r_ec.gl_code_combination_id.DELETE;
11620 r_ec.project_id.DELETE;
11621 r_ec.task_id.DELETE;
11622 r_ec.award_id.DELETE;
11623 r_ec.expenditure_type.DELETE;
11624 r_ec.expenditure_organization_id.DELETE;
11625 r_ec.start_date_active.DELETE;
11626 r_ec.end_date_active.DELETE;
11627 r_ec.poeta_start_date.DELETE;
11628 r_ec.poeta_end_date.DELETE;
11629 r_ec.percent.DELETE;
11630 r_ec.attribute_category.DELETE;
11631 r_ec.attribute1.DELETE;
11632 r_ec.attribute2.DELETE;
11633 r_ec.attribute3.DELETE;
11634 r_ec.attribute4.DELETE;
11635 r_ec.attribute5.DELETE;
11636 r_ec.attribute6.DELETE;
11637 r_ec.attribute7.DELETE;
11638 r_ec.attribute8.DELETE;
11639 r_ec.attribute9.DELETE;
11640 r_ec.attribute10.DELETE;
11641 r_ec.acct_type.DELETE;
11642
11643 r_et.line_account_id.DELETE;
11644 r_et.gl_code_combination_id.DELETE;
11645 r_et.project_id.DELETE;
11646 r_et.task_id.DELETE;
11647 r_et.award_id.DELETE;
11648 r_et.expenditure_type.DELETE;
11649 r_et.expenditure_organization_id.DELETE;
11650 r_et.start_date_active.DELETE;
11651 r_et.end_date_active.DELETE;
11652 r_et.poeta_start_date.DELETE;
11653 r_et.poeta_end_date.DELETE;
11654 r_et.percent.DELETE;
11655 r_et.attribute_category.DELETE;
11656 r_et.attribute1.DELETE;
11657 r_et.attribute2.DELETE;
11658 r_et.attribute3.DELETE;
11659 r_et.attribute4.DELETE;
11660 r_et.attribute5.DELETE;
11661 r_et.attribute6.DELETE;
11662 r_et.attribute7.DELETE;
11663 r_et.attribute8.DELETE;
11664 r_et.attribute9.DELETE;
11665 r_et.attribute10.DELETE;
11666 r_et.acct_type.DELETE;
11667
11668 r_gee.line_account_id.DELETE;
11669 r_gee.gl_code_combination_id.DELETE;
11670 r_gee.project_id.DELETE;
11671 r_gee.task_id.DELETE;
11672 r_gee.award_id.DELETE;
11673 r_gee.expenditure_type.DELETE;
11674 r_gee.expenditure_organization_id.DELETE;
11675 r_gee.start_date_active.DELETE;
11676 r_gee.end_date_active.DELETE;
11677 r_gee.poeta_start_date.DELETE;
11678 r_gee.poeta_end_date.DELETE;
11679 r_gee.percent.DELETE;
11680 r_gee.attribute_category.DELETE;
11681 r_gee.attribute1.DELETE;
11682 r_gee.attribute2.DELETE;
11683 r_gee.attribute3.DELETE;
11684 r_gee.attribute4.DELETE;
11685 r_gee.attribute5.DELETE;
11686 r_gee.attribute6.DELETE;
11687 r_gee.attribute7.DELETE;
11688 r_gee.attribute8.DELETE;
11689 r_gee.attribute9.DELETE;
11690 r_gee.attribute10.DELETE;
11691 r_gee.acct_type.DELETE;
11692
11693 END clear_sch_hierarchy;
11694
11695 END PSP_ENC_CREATE_LINES;