[Home] [Help]
PACKAGE BODY: APPS.PSP_ENC_CREATE_LINES
Source
1 PACKAGE BODY PSP_ENC_CREATE_LINES AS
2 /* $Header: PSPENLNB.pls 120.83.12020000.9 2013/03/27 00:01:30 lkodaman 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 --13566809
405
406 TYPE p_asg_end_date_tab_type IS TABLE OF date INDEX BY VARCHAR2(100);
407 p_asg_end_date_tab p_asg_end_date_tab_type;
408
409 TYPE p_payroll_end_date_tab_type IS TABLE OF date INDEX BY VARCHAR2(100);
410 p_payroll_end_date_tab p_payroll_end_date_tab_type;
411
412
413 /* ***************************CACHING MECHANISM**********************************
414 Created By : Narayana
415
416 Date Created By : 19-Jun-2012
417
418 Purpose : 1)
419 In this mechanism we have used 2 functions GET_ASG_PAY_END_DATE and
420 get_payroll_pay_end_date. GET_ASG_PAY_END_DATE is used for both ORACLE
421 and NON ORACLE PAYROLL in order to increase the performance of the CUEL
422 process and this is used in the insert statement of PSP_ENC_CHANGED_ASSIGNMENTS.
423 For this we have created a temp table PSP_ASG_END_DATES in order
424 to hold assignment information until the CUEL process completes.
425
426 Before this process was introduced the cursor query of
427 ORACLE_PAYROLL_ASG_END_DATE (ORACLE PAYROLL CURSOR) is used in all the
428 insert statements and the query executes for every assignment multiple
429 times which is the actual cause for this performance issue. So instead
430 of executing the query multiple times for the same assignment we have
431 introduced the CACHING MECHANISM.
432
433 In this mechanism the query executes only once for an assignment and stores
434 the assignment information in the temp table and once again if the same
435 assignment is used for querying the data then the process picks up the
436 data from the temp table.
437
438 Similarly for OTHER PAYROLL we have introduced the same mechanism
439 with the help of NON_ORACLE_ASG_END_DATE (OTHER PAYROLL CURSOR).
440
441 And the variable g_payroll_mode helps to choose the cursors respectively
442 basing on the type of payroll which they have used.
443
444 2)
445 GET_PAYROLL_PAY_END_DATE function is introduced to avoid using the
446 same query of the cursor PAYROLL_PAY_END_DATE_CUR multiple times.
447 For this we have used a normal variable.
448
449
450 *************************************************************************************** */
451
452 function get_asg_pay_end_date(p_payroll_mode IN VARCHAR,
453 p_payroll_action_id IN NUMBER,
454 p_assignmnet_id IN NUMBER,
455 p_business_group_id IN NUMBER,
456 p_payroll_id IN NUMBER
457 ) return date IS
458
459 PRAGMA AUTONOMOUS_TRANSACTION;
460
461 cursor oracle_payroll_asg_end_date is
462 SELECT /*+ use_nl(PTP)
463 INDEX(ptp PER_TIME_PERIODS_N50)
464 INDEX(paa PAY_ASSIGNMENT_ACTIONS_N4)*/
465 Max(ptp.end_date)
466 FROM pay_payroll_actions ppa,
467 pay_assignment_actions paa,
468 per_time_periods ptp
469 WHERE paa.assignment_id = p_assignmnet_id
470 AND ppa.payroll_action_id = paa.payroll_action_id
471 AND ppa.business_group_id = p_business_group_id
472 AND ppa.payroll_id = p_payroll_id
473 AND ppa.action_type IN ( 'R','Q')
474 AND paa.action_status = 'C'
475 and ppa.date_earned between ptp.start_date and ptp.end_date
476 and ptp.payroll_id = ppa.payroll_id;
477
478
479 cursor non_oracle_asg_end_date is
480 SELECT /*+ use_nl(PTP)
481 INDEX(ptp PER_TIME_PERIODS_N50)
482 INDEX(paa PAY_ASSIGNMENT_ACTIONS_N4)*/
483 max (ptp.end_date)
484 FROM pay_payroll_actions ppa
485 , pay_assignment_actions paa
486 , per_time_periods ptp
487 WHERE paa.assignment_id (+) = p_assignmnet_id
488 AND ppa.payroll_action_id = paa.payroll_action_id (+)
489 AND ppa.business_group_id = p_business_group_id
490 AND ppa.payroll_id = p_payroll_id
491 AND ppa.action_type IN ('R', 'Q')
492 AND paa.action_status (+) = 'C'
493 AND ppa.date_earned
494 BETWEEN ptp.start_date
495 AND ptp.end_date
496 AND ptp.payroll_id = ppa.payroll_id;
497
498 cursor asgn_end_date_cur is
499 select assignment_id,asg_end_date
500 from psp_asg_end_dates
501 where assignment_id = p_assignmnet_id
502 and payroll_id = p_payroll_id
503 and bg_grp_id = p_business_group_id
504 and payroll_action_id = p_payroll_action_id;
505
506 l_asgn_end_date date := NULL;
507 l_assignment_id NUMBER;
508
509
510 begin
511
512
513 OPEN asgn_end_date_cur;
514 FETCH asgn_end_date_cur INTO l_assignment_id,l_asgn_end_date;
515 CLOSE asgn_end_date_cur;
516
517 IF l_asgn_end_date IS NULL AND l_assignment_id IS NULL THEN
518
519 -- fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) ||' fnd ::: If --- > assignment_id details is inserted in the table '||p_assignmnet_id);
520 -- hr_utility.trace(' hr:::If --- > assignment_id details is inserted in the table '||p_assignmnet_id);
521
522
523 IF p_payroll_mode = 'Y' OR p_payroll_mode IS NULL THEN
524
525 OPEN oracle_payroll_asg_end_date;
526 FETCH oracle_payroll_asg_end_date INTO l_asgn_end_date;
527 CLOSE oracle_payroll_asg_end_date;
528
529 ELSIF p_payroll_mode = 'N' THEN
530
531 OPEN non_oracle_asg_end_date;
532 FETCH non_oracle_asg_end_date INTO l_asgn_end_date;
533 CLOSE non_oracle_asg_end_date;
534
535 END IF;
536
537
538
539 insert into psp_asg_end_dates (PAYROLL_ACTION_ID ,ASSIGNMENT_ID ,PAYROLL_ID ,BG_GRP_ID ,ASG_END_DATE ) --jnerella 26/07/2012
540 values(p_payroll_action_id,p_assignmnet_id,p_payroll_id,p_business_group_id,l_asgn_end_date);
541 -- fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) ||' fnd:::If table --- > insert '||sql%rowcount);
542 -- hr_utility.trace(' hr:::If table --- > insert '||sql%rowcount);
543
544 commit;
545
546 return l_asgn_end_date;
547
548 ELSE
549
550 -- fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) ||' fnd:::Else --> assignment_id already exists in the table'||p_assignmnet_id);
551 -- hr_utility.trace(' hr::Else --> assignment_id already exists in the table'||p_assignmnet_id);
552 return l_asgn_end_date;
553
554 END IF;
555
556
557 end get_asg_pay_end_date;
558
559 --13566809
560
561 function get_payroll_pay_end_date(p_payroll_id IN NUMBER
562 ) return date IS
563
564 cursor payroll_pay_end_date_cur(p_payroll_id number) is
565 SELECT /*+ INDEX(ptp PER_TIME_PERIODS_N50)*/
566 max (ptp.end_date)
567 FROM pay_payroll_actions ppa
568 ,pay_assignment_actions paa
569 ,per_time_periods ptp
570 WHERE ppa.payroll_action_id = paa.payroll_action_id (+)
571 AND ppa.payroll_id = p_payroll_id
572 AND ppa.action_type IN ('R','Q')
573 AND nvl (paa.action_status,ppa.action_status) = 'C'
574 AND ppa.date_earned BETWEEN ptp.start_date AND ptp.end_date
575 AND ptp.payroll_id = ppa.payroll_id;
576
577 l_payroll_end_date date;
578
579 begin
580
581 if p_payroll_end_date_tab.exists(p_payroll_id)
582 then
583 /*fnd_file.put_line(fnd_file.log,'getting 1 end_date - payroll: '||p_payroll_id||' as '||p_payroll_end_date_tab(p_payroll_id)); */
584
585 return p_payroll_end_date_tab(p_payroll_id);
586 else
587
588 open payroll_pay_end_date_cur(p_payroll_id);
589 fetch payroll_pay_end_date_cur into l_payroll_end_date;
590 p_payroll_end_date_tab(p_payroll_id) := l_payroll_end_date;
591 close payroll_pay_end_date_cur;
592
593 /*fnd_file.put_line(fnd_file.log,'getting 2 end_date - payroll: '||p_payroll_id||' as '||p_payroll_end_date_tab(p_payroll_id)); */
594
595 return p_payroll_end_date_tab(p_payroll_id);
596
597 end if;
598
599
600 end get_payroll_pay_end_date;
601
602
603
604 /* Following procedure is added for bug 2374680. */
605 PROCEDURE Get_assign_number
606 (p_assignment_id IN NUMBER,
607 p_effective_date IN DATE,
608 p_assignment_number OUT NOCOPY VARCHAR2,
609 p_employee_number OUT NOCOPY VARCHAR2 ) IS
610
611 CURSOR assign_num_cur IS
612 SELECT paf.assignment_number,
613 ppf.employee_number
614 FROM
615 per_assignments_f paf,per_people_f ppf
616 WHERE paf.assignment_id =p_assignment_id
617 AND paf.person_id =ppf.person_id
618 AND p_effective_date between paf.effective_start_date and paf.effective_end_date
619 AND p_effective_date between ppf.effective_start_date and ppf.effective_end_date;
620
621 BEGIN
622 OPEN assign_num_cur;
623 FETCH assign_num_cur INTO p_assignment_number,p_employee_number;
624 CLOSE assign_num_cur;
625
626 END get_assign_number;
627
628 ---------------------- O B T A I N ENC ORG E N D D A T E -----------------------
629
630 Procedure obtain_enc_org_end_date( p_enc_org_end_date OUT NOCOPY DATE,
631 p_business_group_id IN NUMBER,
632 p_set_of_books_id IN NUMBER,
633 p_return_status OUT NOCOPY VARCHAR2) IS
634 /*****************************************************************************
635 This procedure calculates the 100% time period end date by finding the end date. It
636 picks the latest date from the table.
637 The end-date is returned through the OUT variable.
638 --Added new column peed.enc_end_date_id for Enhancement ENC redesign
639 --For Bug 2259310 : Changed the name of the procedure and variables and an update statement has been added
640 As part of the same enhancement the form has been changed. There is no longer organization for which the end date
641 is obtained.
642 ******************************************************************************/
643
644 CURSOR time_pct_def_cur
645 IS
646 SELECT peed.period_end_date,
647 peed.enc_end_date_id,
648 NVL(peed.prev_enc_end_date, fnd_date.canonical_to_date('4712/12/31')) prev_enc_end_date
649 FROM psp_enc_end_dates peed
650 WHERE
651 --- removed sysdate check for Bug fix 2597666
652 peed.business_group_id = p_business_group_id
653 AND peed.set_of_books_id = p_set_of_books_id
654 AND peed.default_org_flag = 'Y';
655
656 l_count NUMBER :=0;
657 --For Enhancement Enc Redesign :Bug 2259310 Added the following variable and cursors
658 l_enc_end_date_id NUMBER;
659 l_prev_enc_end_date DATE;
660
661 CURSOR c_cnt_default_org
662 IS
663 SELECT COUNT(1)
664 FROM psp_enc_end_dates peed
665 WHERE
666 -- removed sysdate check for Bug Fix 2597666
667 peed.business_group_id = p_business_group_id
668 AND peed.set_of_books_id = p_set_of_books_id
669 AND peed.default_org_flag= 'Y';
670
671
672 Begin
673 p_enc_org_end_date := NULL;
674 -- check for Generic Encumbrance Period
675
676 p_return_status := fnd_api.g_ret_sts_success;
677
678 -- moved the select to Cursor
679 OPEN c_cnt_default_org;
680 FETCH c_cnt_default_org INTO l_count;
681 CLOSE c_cnt_default_org;
682
683 IF l_count = 0 THEN
684 fnd_message.set_name('PSP', 'PSP_ENC_GEN_PERIOD_NOT_FOUND');
685 fnd_msg_pub.add;
686 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
687 END IF;
688
689 OPEN time_pct_def_cur;
690 FETCH time_pct_def_cur INTO p_enc_org_end_date, l_enc_end_date_id, l_prev_enc_end_date;
691 IF ( time_pct_def_cur%ROWCOUNT> 1) THEN
692 p_enc_org_end_date := NULL;
693 fnd_message.set_name('PSP', 'PSP_ENC_MUL_END_DATES');
694 fnd_msg_pub.add;
695 g_error_message := fnd_message.get;
696 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
697 END IF;
698 CLOSE time_pct_def_cur;
699
700 --For Enhancement Enc Redesign:Bug 2259310 : Updating the Organization End date
701 IF (l_prev_enc_end_date <> p_enc_org_end_date) THEN
702 UPDATE psp_enc_end_dates peed
703 SET peed.prev_enc_end_date = p_enc_org_end_date
704 WHERE peed.enc_end_date_id = l_enc_end_date_id;
705 END IF;
706 Exception
707
708 WHEN OTHERS THEN
709 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
710 IF (g_error_message IS NULL) THEN
711 g_error_message := 'OBTAIN_ENC_ORG_END_DATE: ' || SQLERRM;
712 END IF;
713 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'OBTAIN_ENC_ORG_END_DATE');
714 p_return_status := fnd_api.g_ret_sts_unexp_error;
715 return;
716 End obtain_enc_org_end_date;
717
718 ---------------------- O B T A I N E N C P O E T A E N D D A T E -----------------------
719 -- Enhancement Enc Redesign : Renamed Obtain_enc_period_extn to Obtain_enc_peota_end_date
720 -- For Enhancement Enc Redesign :Bug 2259310 : The procedure determines the Encumbrance end date
721 -- when the CI is POETA, i.e the date
722 -- till which the POETA shall be encumbered. It is called from the Hierarchies.
723
724 Procedure obtain_enc_poeta_end_date ( p_ls_start_date IN DATE,
725 p_ls_end_date IN DATE,
726 p_poeta_end_date IN DATE,
727 p_enc_end_date OUT NOCOPY DATE, --Is used for Enc End date
728 p_return_status OUT NOCOPY VARCHAR2
729 )
730 IS
731 l_enc_end_date DATE DEFAULT g_enc_org_end_date;
732 BEGIN
733
734 /* Enc End date Changes*/
735 IF p_ls_start_date <= g_enc_org_end_date THEN
736 IF p_ls_end_date <= g_enc_org_end_date THEN
737 l_enc_end_date:= g_enc_org_end_date;
738 ELSE
739 IF p_ls_end_date < p_poeta_end_date THEN
740 l_enc_end_date := p_ls_end_date;
741 ELSIF p_ls_end_date >= p_poeta_end_date AND p_poeta_end_date > g_enc_org_end_date THEN
742 l_enc_end_date:= p_poeta_end_date;
743 END IF;
744 END IF;
745 ELSE
746 l_enc_end_date := NULL;
747 END IF;
748 --Assigning values to the out parameters
749 p_enc_end_date := LEAST(l_enc_end_date, NVL(g_actual_term_date, l_enc_end_date));
750 p_return_status := fnd_api.g_ret_sts_success;
751
752 EXCEPTION
753 WHEN OTHERS THEN
754 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
755 IF (g_error_message IS NULL) THEN
756 g_error_message := 'OBTAIN_ENC_POETA_END_DATE: ' || SQLERRM;
757 END IF;
758 g_error_api_path := SUBSTR(' OBTAIN_ENC_POETA_END_DATE:'||g_error_api_path,1,230);
759 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', ' OBTAIN_ENC_POETA_END_DATE ');
760 p_return_status := fnd_api.g_ret_sts_unexp_error;
761 END obtain_enc_poeta_end_date;
762
763
764
765
766 ---------------------- D E T E R M I N E E N C A M O U N T -----------------------
767 /***********************************************************************************************
768 This procedures calculates the Encumbrance Amount for a particular assignment
769 and Earnings Element. The parameters accepted are the Assignment ID and the
770 Element_Type_ID and active assignment chunks dates
771 that are to be used for calculating the encumbrance amount.
772 The function does the following:
773 -- Checks if the Element_Type_ID refers to the REGULAR SALARY seeded element.
774 -- If it does, then obtain the amount from the Salary Administration (in Oracle Apps)
775 window. If there is no amount specified in the salary administration window, then
776 proceed to next step. If there is an amount, then it pro-rates the amount to
777 the window period of the active assignment chunk dates.
778 -- If the earnings element is not REGULAR SALARY, then call the userhook. Whatever
779 amount is returned by userhook is considered as the pro-rated amount for the
780 assignment dates.
781 --IF no amount is returned by the userhook then go to the Element
782 entries window (in Oracle Apps). Obtain the amount specified against
783 the earnings element and then it pro-rates the amount to
784 the window period of the active assignment chunk dates.
785
786 Logic for Regular Salary element:
787 -- First, I will check if the element has a value in the PER_PAY_PROPOSALS.
788 -- If it does, then I will return the encumbrance amount on a per payroll period basis.
789 -- If the amount has not been defined, then I will look into the PAY_PAYWSMEE_ELEMENT_ENTRIES
790 -- table to obtain the amount.
791
792 -- Obtain the number of pay periods in a fiscal year. This will then be used to divide the
793 -- annual salary to arrive at the salary per pay period.
794
795 -- Salary information present and the number of periods per fiscal year is greater than zero.
796 -- Hence, calculate the amount per pay period.
797 -- 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
798 --For Enhancement Enc Redesign, Bug 2259310, Prorating the Amount
799 ********************************************************************************************************/
800
801 -- Implemented the following logic for determine_enc_amount procedure as part of bug fix 3488734
802 PROCEDURE determine_enc_amount (p_person_id IN NUMBER,
803 p_assignment_id IN NUMBER,
804 p_element_type_id IN NUMBER,
805 p_payroll_id IN NUMBER,
806 p_business_group_id IN NUMBER,
807 p_set_of_books_id IN NUMBER,
808 p_return_status OUT NOCOPY VARCHAR2) IS
809
810 TYPE salary_proposal_rectype IS RECORD
811 (r_change_date t_date_type,
812 r_proposed_salary t_num_15d2_type,
813 r_pay_basis t_varchar_50_type,
814 r_pay_annualization_factor t_num_15_type,
815 r_effective_start_date t_date_type,
816 r_effective_end_date t_date_type);
817
818 r_salary_proposal salary_proposal_rectype;
819
820 TYPE element_entry_rectype IS RECORD
821 (r_element_start_date t_date_type,
822 r_element_end_date t_date_type,
823 r_pay_amount t_num_15d2_type);
824
825 r_element_entry element_entry_rectype;
826
827 l_min_start_date DATE DEFAULT r_enc_period.r_asg_start_date(1);
828 l_max_end_date DATE DEFAULT r_enc_period.r_asg_end_date(r_enc_period.r_asg_end_date.COUNT);
829
830 -- Introduced the following for bug fix 3673723
831 TYPE element_period_amount IS RECORD
832 (r_time_period_id t_num_15_type,
833 r_period_amount t_num_15d2_type);
834
835 r_element_period_amount element_period_amount;
836
837 CURSOR element_period_amount_cur IS
838 SELECT time_period_id,
839 SUM(period_amount)
840 FROM (SELECT ((MAX(fnd_number.canonical_to_number(NVL(peev.screen_entry_value, 0))) *
841 SUM(psp_general.business_days( GREATEST(ptp.start_date, paf.effective_start_date, peev.effective_start_date),
842 LEAST(ptp.end_date, paf.effective_end_date, peev.effective_end_date),p_assignment_id)) ) /
843 DECODE(psp_general.business_days(MAX(ptp.start_date), MAX(ptp.end_date),p_assignment_id), 0, 1,
844 psp_general.business_days(MAX(ptp.start_date), MAX(ptp.end_date),p_assignment_id)) ) period_amount,
845 ptp.time_period_id
846 FROM pay_element_entry_values_f peev,
847 pay_input_values_f piv,
848 pay_element_entries_f pee,
849 pay_element_links_f pel,
850 pay_element_types_f pet,
851 psp_enc_elements peel,
852 per_assignments_f paf,
853 per_assignment_status_types past,
854 per_time_periods ptp
855 WHERE peev.element_entry_id = pee.element_entry_id
856 AND peev.effective_start_date <= paf.effective_end_date
857 AND peev.effective_end_date >= paf.effective_start_date
858 AND pel.element_link_id = pee.element_link_id
859 AND pel.element_type_id = p_element_type_id
860 AND pel.effective_start_date <= paf.effective_end_date
861 AND pel.effective_end_date >= paf.effective_start_date
862 AND pet.effective_start_date <= paf.effective_end_date
863 AND pet.effective_end_date >= paf.effective_start_date
864 AND pee.assignment_id = p_assignment_id
865 AND pee.effective_start_date <= paf.effective_end_date
866 AND pee.effective_end_date >= paf.effective_start_date
867 AND peev.input_value_id = piv.input_value_id
868 AND piv.input_value_id = peel.input_value_id
869 AND pet.element_type_id = p_element_type_id
870 AND piv.effective_start_date <= paf.effective_end_date
871 AND piv.effective_end_date >= paf.effective_start_date
872 AND piv.effective_start_date <= peev.effective_end_date
873 AND piv.effective_end_date >= peev.effective_start_date
874 AND pee.effective_start_date <= peev.effective_end_date
875 AND pee.effective_end_date >= peev.effective_start_date
876 AND ptp.start_date <= paf.effective_end_date
877 AND ptp.end_date >= paf.effective_start_date
878 AND pel.effective_start_date <= pee.effective_end_date
879 AND pel.effective_end_date >= pee.effective_start_date
880 AND pet.effective_start_date <= pel.effective_end_date
881 AND pet.effective_end_date >= pel.effective_start_date
882 AND paf.assignment_id = p_assignment_id
883 AND paf.effective_start_date <= l_max_end_date
884 AND paf.effective_end_date >= l_min_start_date
885 AND past.assignment_status_type_id = paf.assignment_status_type_id
886 AND past.per_system_status = 'ACTIVE_ASSIGN'
887 AND pel.business_group_id = p_business_group_id
888 AND peel.business_group_id = p_business_group_id
889 AND peel.set_of_books_id = p_set_of_books_id
890 AND ptp.payroll_id = p_payroll_id
891 AND ptp.time_period_id >= r_enc_period.r_time_period_id(1)
892 AND SUBSTR(piv.uom, 1, 1) = g_uom
893 GROUP BY ptp.time_period_id,
894 peev.effective_start_date,
895 peev.effective_end_date)
896 GROUP BY time_period_id;
897 -- End of changes for bug fix 3673723
898
899 CURSOR get_proposal_salary_csr IS
900 SELECT ppp.change_date,
901 ppp.proposed_salary_n proposed_salary,
902 NVL(ppb.pay_basis, ' ') pay_basis,
903 ppb.pay_annualization_factor,
904 paf.effective_start_date,
905 paf.effective_end_date
906 FROM per_pay_proposals ppp,
907 pay_input_values_f piv,
908 per_pay_bases ppb,
909 per_all_assignments_f paf,
910 per_assignment_status_types past
911 WHERE paf.assignment_id =p_assignment_id
912 AND ( ppp.change_date BETWEEN paf.effective_start_date AND paf.effective_end_date
913 OR ppp.change_date = (SELECT MAX(ppp1.change_date)
914 FROM per_pay_proposals ppp1
915 WHERE ppp1.assignment_id = p_assignment_id
916 AND ppp1.approved = 'Y'
917 AND ppp1.change_date <= paf.effective_start_date))
918 AND paf.pay_basis_id = ppb.pay_basis_id
919 AND ppp.assignment_id = p_assignment_id
920 AND past.assignment_status_type_id = paf.assignment_status_type_id
921 AND past.per_system_status = 'ACTIVE_ASSIGN'
922 AND piv.element_type_id +0 = p_element_type_id
923 AND ppp.approved = 'Y'
924 AND ((ppp.change_date >= (SELECT NVL(MAX(ppp1.change_date), l_min_start_date)
925 FROM per_pay_proposals ppp1
926 WHERE ppp1.assignment_id = p_assignment_id
927 AND ppp1.approved = 'Y'
928 AND ppp1.change_date <= l_min_start_date))
929 AND (ppp.change_date <= (SELECT NVL(MIN(ppp1.change_date), l_max_end_date + 1)
930 FROM per_pay_proposals ppp1
931 WHERE ppp1.assignment_id = p_assignment_id
932 AND ppp1.approved = 'Y'
933 AND ppp1.change_date >= l_max_end_date)))
934 AND ppb.input_value_id = piv.input_value_id
935 AND ppp.change_date BETWEEN piv.effective_start_date AND piv.effective_end_date
936 ORDER BY paf.effective_end_date DESC, ppp.change_date DESC;
937
938 CURSOR get_no_per_fiscal_year_csr IS
939 SELECT number_per_fiscal_year
940 FROM per_time_period_types ptpt
941 WHERE period_type = (SELECT ppf.period_type
942 FROM pay_payrolls_f ppf
943 WHERE ppf.payroll_id = p_payroll_id
944 /* Added for Bug 3869766 */
945 AND rownum = 1);
946
947 CURSOR get_element_entry IS
948 SELECT DISTINCT GREATEST(paf.effective_start_date, peev.effective_start_date) element_start_date,
949 LEAST(paf.effective_end_date, peev.effective_end_date) element_end_date,
950 fnd_number.canonical_to_number(NVL(peev.screen_entry_value, 0)) pay_amount
951 FROM pay_element_entry_values_f peev,
952 pay_input_values_f piv,
953 pay_element_entries_f pee,
954 pay_element_links_f pel,
955 pay_element_types_f pet,
956 psp_enc_elements peel,
957 per_assignments_f paf,
958 per_assignment_status_types past
959 WHERE peev.element_entry_id = pee.element_entry_id
960 AND peev.effective_start_date <= paf.effective_end_date
961 AND peev.effective_end_date >= paf.effective_start_date
962 AND pel.element_link_id = pee.element_link_id
963 AND pel.element_type_id = p_element_type_id
964 AND pel.effective_start_date <= paf.effective_end_date
965 AND pel.effective_end_date >= paf.effective_start_date
966 AND pet.effective_start_date <= paf.effective_end_date
967 AND pet.effective_end_date >= paf.effective_start_date
968 AND pee.assignment_id = p_assignment_id
969 AND pee.effective_start_date <= paf.effective_end_date
970 AND pee.effective_end_date >= paf.effective_start_date
971 AND peev.input_value_id = piv.input_value_id
972 AND piv.input_value_id = peel.input_value_id
973 AND pet.element_type_id = p_element_type_id
974 AND piv.effective_start_date <= paf.effective_end_date
975 AND piv.effective_end_date >= paf.effective_start_date
976 AND piv.effective_start_date <= peev.effective_end_date
977 AND piv.effective_end_date >= peev.effective_start_date
978 AND pee.effective_start_date <= peev.effective_end_date
979 AND pee.effective_end_date >= peev.effective_start_date
980 AND pel.effective_start_date <= pee.effective_end_date
981 AND pel.effective_end_date >= pee.effective_start_date
982 AND pet.effective_start_date <= pel.effective_end_date
983 AND pet.effective_end_date >= pel.effective_start_date
984 AND paf.assignment_id = p_assignment_id
985 AND paf.effective_start_date <= l_max_end_date
986 AND paf.effective_end_date >= l_min_start_date
987 AND past.assignment_status_type_id = paf.assignment_status_type_id
988 AND past.per_system_status = 'ACTIVE_ASSIGN'
989 AND SUBSTR(piv.uom, 1, 1) = g_uom
990 AND pel.business_group_id = p_business_group_id
991 AND peel.business_group_id = p_business_group_id
992 AND peel.set_of_books_id = p_set_of_books_id
993 ORDER BY element_start_date,element_end_date; -- Added for bug 12724506
994
995 CURSOR get_input_formula_cur IS
996 SELECT NVL(input_value_id, -1),
997 formula_id
998 FROM psp_enc_elements pee
999 WHERE element_type_id = p_element_type_id
1000 AND ( formula_id IS NOT NULL
1001 OR EXISTS (SELECT 1
1002 FROM pay_input_values_f piv
1003 WHERE piv.input_value_id = pee.input_value_id
1004 AND SUBSTR(piv.uom, 1, 1) = g_uom));
1005
1006 l_num_per_fiscal_year NUMBER;
1007 l_time_period_id NUMBER;
1008 l_enc_amount NUMBER;
1009 l_pay_amount NUMBER;
1010 l_period_enc_amount NUMBER;
1011 l_element_start_date DATE;
1012 l_element_end_date DATE;
1013 l_start_date DATE;
1014 l_end_date DATE;
1015 l_period_start_date DATE;
1016 l_period_end_date DATE;
1017 l_asg_start_date DATE;
1018 l_asg_end_date DATE;
1019 l_bus_working_days NUMBER DEFAULT 0;
1020 l_bus_days_in_sched NUMBER DEFAULT 0;
1021 l_temp_salary NUMBER DEFAULT 0;
1022 l_change_date DATE;
1023 l_inputs ff_exec.inputs_t;
1024 l_outputs ff_exec.outputs_t;
1025 l_input_value_id NUMBER(15);
1026 l_formula_id NUMBER(15);
1027
1028 -- Introduced for bug fix 3551561
1029 l_change_end_date DATE DEFAULT fnd_date.canonical_to_date('4712/12/31');
1030 l_prev_change_end_date DATE;
1031 l_prev_change_date DATE;
1032 -- End of bug fix 3551561
1033 l_annualization_factor NUMBER;
1034 l_pay_basis VARCHAR2(30);
1035 l_prev_time_period_id NUMBER DEFAULT -1;
1036 l_period_counter NUMBER; -- Introduced for bug fix 3673723
1037 l_tmp_counter NUMBER;
1038 l_calculate_period_amt BOOLEAN;
1039 l_effective_date DATE;
1040
1041 DIVIDE_BY_ZERO EXCEPTION;
1042
1043 l_proc_name VARCHAR2(61) DEFAULT g_package_name || 'DETERMINE_ENC_AMOUNT';
1044 l_proc_step NUMBER(20, 10);
1045
1046 t_ff_start_date t_date_type;
1047 t_ff_end_date t_date_type;
1048
1049 CURSOR formula_date_cur IS
1050 SELECT GREATEST(pee.effective_start_date, paf.effective_start_date, ff.effective_start_date) start_date,
1051 LEAST(pee.effective_end_date, paf.effective_end_date, ff.effective_end_date) end_date
1052 FROM ff_formulas_f ff,
1053 per_assignments_f paf,
1054 pay_element_entries_f pee
1055 WHERE formula_id = l_formula_id
1056 AND paf.assignment_id = p_assignment_id
1057 AND pee.assignment_id = p_assignment_id
1058 AND pee.element_type_id = p_element_type_id
1059 AND paf.effective_start_date <= l_max_end_date
1060 AND paf.effective_end_date >= l_min_start_date
1061 AND pee.effective_start_date <= l_max_end_date
1062 AND pee.effective_end_date >= l_min_start_date
1063 AND ff.effective_start_date <= l_max_end_date
1064 AND ff.effective_end_date >= l_min_start_date
1065 AND paf.effective_start_date <= pee.effective_end_date
1066 AND paf.effective_end_date >= pee.effective_start_date
1067 AND paf.effective_start_date <= ff.effective_end_date
1068 AND paf.effective_end_date >= ff.effective_start_date
1069 AND pee.effective_start_date <= ff.effective_end_date
1070 AND pee.effective_end_date >= ff.effective_start_date
1071 ORDER BY start_date,end_date; -- Added for bug 12724506
1072
1073 BEGIN
1074 l_proc_step:= 10;
1075 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering ' || l_proc_name);
1076 hr_utility.trace('p_assignment_id: ' || fnd_number.number_to_canonical(p_assignment_id) ||
1077 ' p_element_type_id: ' || fnd_number.number_to_canonical(p_element_type_id) ||
1078 ' p_payroll_id: ' || fnd_number.number_to_canonical(p_payroll_id) ||
1079 ' p_business_group_id: ' || fnd_number.number_to_canonical(p_business_group_id) ||
1080 ' p_set_of_books_id: ' || fnd_number.number_to_canonical(p_set_of_books_id) ||
1081 ' l_bus_working_days: ' || fnd_number.number_to_canonical(l_bus_working_days) ||
1082 ' r_enc_period.r_time_period_id.COUNT: ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id.COUNT));
1083
1084 IF (r_enc_period.r_time_period_id.COUNT = 0) THEN
1085 RETURN;
1086 END IF;
1087
1088 l_proc_step:= 20;
1089 l_calculate_period_amt := TRUE;
1090
1091 OPEN get_input_formula_cur;
1092 FETCH get_input_formula_cur INTO l_input_value_id, l_formula_id;
1093 CLOSE get_input_formula_cur;
1094
1095 IF (l_formula_id IS NOT NULL) THEN
1096 OPEN formula_date_cur;
1097 FETCH formula_date_cur BULK COLLECT INTO t_ff_start_date, t_ff_end_date;
1098 CLOSE formula_date_cur;
1099
1100 hr_utility.trace('t_ff_start_date.COUNT: ' || t_ff_start_date.COUNT);
1101 END IF;
1102
1103 OPEN get_no_per_fiscal_year_csr;
1104 FETCH get_no_per_fiscal_year_csr INTO l_num_per_fiscal_year;
1105 IF get_no_per_fiscal_year_csr%NOTFOUND THEN
1106 l_num_per_fiscal_year := 0;
1107 END IF;
1108 CLOSE get_no_per_fiscal_year_csr;
1109
1110 l_proc_step:= 30;
1111
1112 OPEN get_proposal_salary_csr;
1113 FETCH get_proposal_salary_csr BULK COLLECT INTO r_salary_proposal.r_change_date, r_salary_proposal.r_proposed_salary,
1114 r_salary_proposal.r_pay_basis, r_salary_proposal.r_pay_annualization_factor,
1115 r_salary_proposal.r_effective_start_date, r_salary_proposal.r_effective_end_date;
1116 CLOSE get_proposal_salary_csr;
1117
1118 l_proc_step:= 40;
1119
1120 OPEN get_element_entry;
1121 FETCH get_element_entry BULK COLLECT INTO r_element_entry.r_element_start_date, r_element_entry.r_element_end_date,
1122 r_element_entry.r_pay_amount;
1123 CLOSE get_element_entry;
1124
1125 l_proc_step:= 50;
1126
1127 hr_utility.trace('l_num_per_fiscal_year: ' || fnd_number.number_to_canonical(l_num_per_fiscal_year) ||
1128 ' r_salary_proposal.r_change_date.COUNT: ' || fnd_number.number_to_canonical(r_salary_proposal.r_change_date.COUNT) ||
1129 ' r_element_entry.r_element_start_date.COUNT: ' || fnd_number.number_to_canonical(r_element_entry.r_element_start_date.COUNT));
1130 hr_utility.trace('Calculating Assignment Chunk Amounts...');
1131
1132 FOR I IN 1..r_enc_period.r_time_period_id.COUNT
1133 LOOP
1134 IF (r_enc_period.r_process_flag(I) <> 'I') THEN
1135 l_period_start_date := r_enc_period.r_period_start_date(I);
1136 l_period_end_date := r_enc_period.r_period_end_date(I);
1137 l_asg_start_date := r_enc_period.r_asg_start_date(I);
1138 l_asg_end_date := r_enc_period.r_asg_end_date(I);
1139 l_end_date := l_asg_end_date;
1140 /* l_bus_working_days := psp_general.business_days(greatest(l_period_start_date,l_asg_start_date) -- Bug 9683158
1141 ,l_period_end_date
1142 ,p_assignment_id); */ -- Bug 11930831
1143
1144 /* l_bus_working_days := psp_general.business_days(greatest(l_period_start_date,l_asg_start_date), LEAST(l_period_end_date,l_asg_end_date), p_assignment_id); -- Bug 11930831
1145 */ -- Commented for the Bug 12647364
1146 l_bus_working_days := psp_general.business_days(l_period_start_date, l_period_end_date,p_assignment_id); -- Reverting the change done by 9683158 for the Bug 12647364
1147 l_enc_amount := 0;
1148 l_proc_step:= 60 + (I / 100000);
1149
1150 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
1151 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
1152 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
1153 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
1154 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
1155 ' l_bus_working_days: ' || fnd_number.number_to_canonical(l_bus_working_days));
1156
1157 IF (l_bus_working_days = 0) THEN
1158 fnd_message.set_name('PSP', 'PSP_ENC_ZERO_WORK_DAYS_PERIOD');
1159 fnd_message.set_token('START_DATE', l_period_start_date);
1160 fnd_message.set_token('END_DATE', l_period_end_date);
1161 g_error_message := fnd_message.get;
1162 RAISE DIVIDE_BY_ZERO;
1163 END IF;
1164
1165 l_enc_amount := psp_st_ext.get_enc_amount (p_assignment_id => p_assignment_id,
1166 p_element_type_id => p_element_type_id,
1167 p_time_period_id => r_enc_period.r_time_period_id(I),
1168 p_asg_start_date => l_asg_start_date,
1169 p_asg_end_date => l_asg_end_date);
1170 hr_utility.trace('l_enc_amount: ' || fnd_number.number_to_canonical(l_enc_amount));
1171
1172 IF (l_enc_amount = 0) THEN
1173 IF (l_formula_id IS NOT NULL) THEN
1174 IF ( (t_ff_start_date.COUNT > 0) AND
1175 (l_asg_start_date <= t_ff_end_date(t_ff_end_date.COUNT)) AND
1176 (l_asg_end_date >= t_ff_start_date(1))) THEN
1177 FOR ff_recno IN 1..t_ff_start_date.COUNT
1178 LOOP
1179 l_asg_start_date := r_enc_period.r_asg_start_date(I);
1180 l_asg_end_date := r_enc_period.r_asg_end_date(I);
1181 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));
1182 IF l_asg_start_date <= t_ff_end_date(ff_recno) AND
1183 l_asg_end_date >= t_ff_start_date(ff_recno) THEN
1184 l_asg_start_date := GREATEST(l_asg_start_date, t_ff_start_date(ff_recno));
1185 l_asg_end_date := LEAST(l_asg_end_date, t_ff_end_date(ff_recno));
1186 l_inputs.DELETE;
1187 l_outputs.DELETE;
1188
1189 ff_exec.init_formula(l_formula_id, l_asg_start_date, l_inputs,l_outputs);
1190 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));
1191
1192 hr_utility.trace('l_inputs.COUNT: ' || l_inputs.COUNT);
1193 FOR recno IN 1..l_inputs.COUNT
1194 LOOP
1195 IF (l_inputs(recno).name ='PERSON_ID') THEN
1196 l_inputs(recno).value := fnd_number.number_to_canonical(p_person_id);
1197 hr_utility.trace('Assigned person_id');
1198 ELSIF (l_inputs(recno).name ='ASSIGNMENT_ID') THEN
1199 l_inputs(recno).value := fnd_number.number_to_canonical(p_assignment_id);
1200 hr_utility.trace('Assigned assignment_id');
1201 ELSIF l_inputs(recno).name='ELEMENT_TYPE_ID' THEN
1202 l_inputs(recno).value := fnd_number.number_to_canonical(p_element_type_id);
1203 hr_utility.trace('Assigned element_type_id');
1204 ELSIF l_inputs(recno).name='PAYROLL_ID' THEN
1205 l_inputs(recno).value := fnd_number.number_to_canonical(p_payroll_id);
1206 hr_utility.trace('Assigned payroll_id');
1207 ELSIF l_inputs(recno).name='TIME_PERIOD_ID' THEN
1208 l_inputs(recno).value := fnd_number.number_to_canonical(r_enc_period.r_time_period_id(I));
1209 hr_utility.trace('Assigned time_period_id');
1210 ELSIF l_inputs(recno).name='ASG_START_DATE' THEN
1211 l_inputs(recno).value := fnd_date.date_to_canonical(l_asg_start_date);
1212 hr_utility.trace('Assigned asg_start_date');
1213 ELSIF l_inputs(recno).name='ASG_END_DATE' THEN
1214 l_inputs(recno).value := fnd_date.date_to_canonical(l_asg_end_date);
1215 hr_utility.trace('Assigned asg_end_date');
1216 ELSIF l_inputs(recno).name='BUS_DAYS_IN_CHUNK' THEN
1217 l_inputs(recno).value := fnd_number.number_to_canonical(psp_general.business_days(l_asg_start_date, l_asg_end_date,p_assignment_id));
1218 hr_utility.trace('Assigned business days in chunk');
1219 ELSIF l_inputs(recno).name='PERIOD_START_DATE' THEN
1220 l_inputs(recno).value := fnd_date.date_to_canonical(l_period_start_date);
1221 hr_utility.trace('Assigned period_start_date');
1222 ELSIF l_inputs(recno).name='PERIOD_END_DATE' THEN
1223 l_inputs(recno).value := fnd_date.date_to_canonical(l_period_end_date);
1224 hr_utility.trace('Assigned period_end_date');
1225 ELSIF l_inputs(recno).name='BUS_DAYS_IN_PERIOD' THEN
1226 l_inputs(recno).value := fnd_number.number_to_canonical(psp_general.business_days(l_period_start_date, l_period_end_date,p_assignment_id));
1227 hr_utility.trace('Assigned business days in period');
1228 ELSIF l_inputs(recno).name='UOM' THEN
1229 l_inputs(recno).value := g_uom;
1230 hr_utility.trace('Assigned UOM');
1231
1232 END IF;
1233 END LOOP;
1234
1235 hr_utility.trace('Before executing fast formula');
1236 ff_exec.run_formula(l_inputs, l_outputs);
1237 l_enc_amount := l_enc_amount + fnd_number.canonical_to_number(l_outputs(1).value); -- Bug 7536024
1238 hr_utility.trace('After executing fast formula; l_enc_amount: ' || l_enc_amount);
1239 END IF;
1240 END LOOP;
1241 END IF;
1242 l_calculate_period_amt := FALSE;
1243 l_proc_step:= 90;
1244 ELSE
1245 IF (psp_general.business_days(l_asg_start_date, l_asg_end_date,p_assignment_id) > 0) THEN
1246 FOR J IN 1..r_salary_proposal.r_change_date.COUNT
1247 LOOP
1248 IF (l_asg_start_date <= r_salary_proposal.r_effective_end_date(J) AND
1249 l_asg_end_date >= r_salary_proposal.r_effective_start_date(J)) THEN
1250 l_change_date := r_salary_proposal.r_change_date(J);
1251 l_end_date := LEAST(l_end_date, l_asg_end_date);
1252 l_temp_salary := r_salary_proposal.r_proposed_salary(J);
1253 l_annualization_factor := r_salary_proposal.r_pay_annualization_factor(J);
1254 l_pay_basis := r_salary_proposal.r_pay_basis(J);
1255 l_proc_step:= 70 + (J / 100000);
1256
1257 hr_utility.trace('J: ' || fnd_number.number_to_canonical(J) ||
1258 ' l_change_date: ' || fnd_date.date_to_canonical(l_change_date) ||
1259 ' l_temp_salary: ' || fnd_number.number_to_canonical(l_temp_salary) ||
1260 ' l_annualization_factor: ' || fnd_number.number_to_canonical(l_annualization_factor) ||
1261 ' l_pay_basis: ' || l_pay_basis);
1262
1263 IF (l_change_date <= l_end_date) THEN
1264 IF (l_num_per_fiscal_year <> 0 AND (l_pay_basis IN ('ANNUAL','MONTHLY','HOURLY'))) THEN
1265 l_temp_salary := round((l_temp_salary * l_annualization_factor / l_num_per_fiscal_year), g_ext_precision);
1266 END IF;
1267
1268 l_start_date := GREATEST(l_change_date, l_asg_start_date);
1269 l_bus_days_in_sched := NVL(PSP_GENERAL.BUSINESS_DAYS(l_start_date, l_end_date,p_assignment_id), 0);
1270 l_enc_amount := l_enc_amount + ROUND(((l_temp_salary * l_bus_days_in_sched) / ( l_bus_working_days )), g_ext_precision);
1271
1272 hr_utility.trace('l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
1273 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
1274 ' l_bus_days_in_sched: ' || fnd_number.number_to_canonical(l_bus_days_in_sched) ||
1275 ' l_enc_amount: ' || fnd_number.number_to_canonical(l_enc_amount));
1276
1277 l_end_date := GREATEST(l_start_date, l_change_date) - 1;
1278
1279 EXIT WHEN l_change_date < l_asg_start_date;
1280 END IF;
1281 END IF;
1282 END LOOP;
1283
1284 l_proc_step:= 80;
1285
1286 IF l_enc_amount = 0 THEN
1287 FOR J IN 1..r_element_entry.r_element_start_date.COUNT
1288 LOOP
1289 l_element_start_date := r_element_entry.r_element_start_date(J);
1290 l_element_end_date := r_element_entry.r_element_end_date(J);
1291 l_pay_amount := r_element_entry.r_pay_amount(J);
1292 l_proc_step:= 100 + (J / 100000);
1293
1294 IF (l_element_end_date >= l_asg_start_date) AND (l_element_start_date <= l_asg_end_date) THEN
1295 l_start_date := GREATEST(l_asg_start_date, l_element_start_date);
1296 l_end_date := LEAST(l_asg_end_date, l_element_end_date);
1297 l_bus_days_in_sched := NVL(PSP_GENERAL.BUSINESS_DAYS(l_start_date, l_end_date,p_assignment_id), 0);
1298 l_enc_amount := l_enc_amount + ROUND(((l_pay_amount * l_bus_days_in_sched)/( l_bus_working_days )),g_ext_precision);
1299 END IF;
1300
1301 hr_utility.trace('l_element_start_date: ' || fnd_date.date_to_canonical(l_element_start_date) ||
1302 ' l_element_end_date: ' || fnd_date.date_to_canonical(l_element_end_date) ||
1303 ' l_pay_amount: ' || fnd_number.number_to_canonical(l_pay_amount) ||
1304 ' l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
1305 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
1306 ' l_bus_days_in_sched: ' || fnd_number.number_to_canonical(l_bus_days_in_sched) ||
1307 ' l_enc_amount: ' || fnd_number.number_to_canonical(l_enc_amount));
1308
1309 EXIT WHEN l_element_start_date > l_asg_end_date;
1310 END LOOP;
1311 END IF;
1312 ELSE
1313 l_enc_amount := 0;
1314 END IF;
1315 END IF;
1316 ELSE
1317 l_calculate_period_amt := FALSE;
1318 END IF;
1319 IF (r_enc_period.r_process_flag(I) IN ('DA', 'SA')) THEN
1320 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);
1321 ELSE
1322 r_enc_period.r_encumbrance_amount(I) := r_enc_period.r_encumbrance_amount(I) + ROUND(l_enc_amount, g_ext_precision);
1323 END IF;
1324 ELSE
1325 r_enc_period.r_encumbrance_amount(I) := 0;
1326 END IF;
1327 END LOOP;
1328
1329 l_proc_step:= 110;
1330 hr_utility.trace('Calculating Period Amounts...');
1331
1332 IF (l_calculate_period_amt) THEN
1333 -- Modified period amount calculation for bug fix 3673723
1334 -- For element entry value based period amount calculation, changed to time period reference.
1335 -- Introduced the following for bug fix 3673723
1336 OPEN element_period_amount_cur;
1337 FETCH element_period_amount_cur BULK COLLECT INTO r_element_period_amount.r_time_period_id, r_element_period_amount.r_period_amount;
1338 CLOSE element_period_amount_cur;
1339 -- End of changes for bug fix 3673723
1340
1341 FOR I IN 1..r_enc_period.r_time_period_id.COUNT
1342 LOOP
1343 l_time_period_id := r_enc_period.r_time_period_id(I);
1344 l_proc_step:= 120 + (I / 100000);
1345
1346 IF (l_time_period_id <> l_prev_time_period_id) THEN
1347 l_asg_start_date := r_enc_period.r_asg_start_date(I); -- Bug 11930831
1348 l_period_start_date := r_enc_period.r_period_start_date(I);
1349 l_period_end_date := r_enc_period.r_period_end_date(I);
1350 l_change_end_date := l_period_end_date;
1351 l_enc_amount := 0;
1352 /* l_bus_working_days := psp_general.business_days(l_period_start_date, l_period_end_date, p_assignment_id);
1353 --Bug 11930831
1354 */
1355 l_bus_working_days := psp_general.business_days(greatest(l_period_start_date,l_asg_start_date), LEAST(l_period_end_date,l_asg_end_date), p_assignment_id); -- Bug 11930831
1356 l_end_date := l_period_end_date;
1357 l_period_counter := 0;
1358
1359 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
1360 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
1361 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
1362 ' l_bus_working_days: ' || fnd_number.number_to_canonical(l_bus_working_days));
1363
1364 IF (l_bus_working_days > 0) THEN
1365 FOR J IN 1..r_salary_proposal.r_change_date.COUNT
1366 LOOP
1367 IF (J > l_period_counter) THEN -- Introduced for bug fix 3673723
1368 l_change_date := r_salary_proposal.r_change_date(J);
1369
1370 -- Introduced for bug fix 3551561
1371 IF (J > 1) THEN
1372 l_change_end_date := l_prev_change_date - 1;
1373 IF (l_change_end_date < l_change_date) THEN
1374 l_change_end_date := l_prev_change_end_date;
1375 END IF;
1376 END IF;
1377 -- End of changes for bug fix 3551561
1378
1379 l_end_date := LEAST(l_end_date, r_salary_proposal.r_effective_end_date(J), l_period_end_date);
1380 l_temp_salary := r_salary_proposal.r_proposed_salary(J);
1381 l_annualization_factor := r_salary_proposal.r_pay_annualization_factor(J);
1382 l_pay_basis := r_salary_proposal.r_pay_basis(J);
1383 l_proc_step:= 130 + (J / 100000);
1384
1385 hr_utility.trace('J: ' || fnd_number.number_to_canonical(J) ||
1386 ' l_change_date: ' || fnd_date.date_to_canonical(l_change_date) ||
1387 ' l_change_end_date: ' || fnd_date.date_to_canonical(l_change_end_date) ||
1388 ' l_temp_salary: ' || fnd_number.number_to_canonical(l_temp_salary) ||
1389 ' l_annualization_factor: ' || fnd_number.number_to_canonical(l_annualization_factor) ||
1390 ' l_pay_basis: ' || l_pay_basis);
1391
1392 -- IF (l_change_date <= l_end_date) THEN Commented for bug fix 3551561
1393 IF (l_change_end_date >= l_period_start_date) AND (l_change_date <= l_period_end_date) THEN
1394 IF (l_num_per_fiscal_year <> 0 AND (l_pay_basis IN ('ANNUAL','MONTHLY','HOURLY'))) THEN
1395 l_temp_salary := round((l_temp_salary * l_annualization_factor / l_num_per_fiscal_year), g_ext_precision);
1396 END IF;
1397
1398 /***** Commented for bug fix 3551561
1399 l_start_date := GREATEST(l_change_date, r_salary_proposal.r_effective_start_date(J), l_period_start_date);
1400 l_bus_days_in_sched := NVL(PSP_GENERAL.BUSINESS_DAYS(l_start_date, l_end_date), 0);
1401 l_enc_amount := l_enc_amount + ROUND(((l_temp_salary * l_bus_days_in_sched) / ( l_bus_working_days )), g_ext_precision);
1402 End of comment for bug fix 3551561 *****/
1403 -- Introduced for bug fix 3551561
1404
1405 l_bus_days_in_sched := 0;
1406 l_period_counter := J;
1407 LOOP -- Introduced for bug fix 3673723
1408 l_start_date := GREATEST(l_period_start_date,
1409 r_salary_proposal.r_effective_start_date(l_period_counter), l_change_date);
1410 l_end_date := LEAST(l_period_end_date,
1411 r_salary_proposal.r_effective_end_date(l_period_counter), l_change_end_date);
1412 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);
1413 EXIT WHEN l_period_counter = r_salary_proposal.r_change_date.COUNT;
1414 EXIT WHEN l_change_date <> r_salary_proposal.r_change_date(l_period_counter + 1);
1415 l_period_counter := l_period_counter + 1;
1416 END LOOP; -- Introduced for bug fix 3673723
1417
1418 l_enc_amount := l_enc_amount + ROUND(((l_temp_salary * l_bus_days_in_sched)/( l_bus_working_days )), g_ext_precision);
1419 -- End of changes for bug fix 3551561
1420 hr_utility.trace('l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
1421 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
1422 ' l_bus_days_in_sched: ' || fnd_number.number_to_canonical(l_bus_days_in_sched) ||
1423 ' l_enc_amount: ' || fnd_number.number_to_canonical(l_enc_amount));
1424 -- l_end_date := GREATEST(l_start_date, l_change_date) - 1; Commented for bug fix 3551561
1425 l_prev_change_end_date := l_change_end_date;
1426 END IF;
1427 l_prev_change_date := l_change_date;
1428 EXIT WHEN l_change_end_date < l_period_start_date; -- Modified to change_end_date for bug fix 3551561
1429 END IF; -- Introduced for bug fix 3673723 (J > l_period_counter condn.)
1430 END LOOP;
1431
1432 l_proc_step:= 150;
1433
1434 -- Introduced the following for bug fix 3673723
1435 IF (l_enc_amount = 0) THEN
1436 FOR J IN 1..r_element_period_amount.r_time_period_id.COUNT
1437 LOOP
1438 IF (r_element_period_amount.r_time_period_id (J) = l_time_period_id) THEN
1439 l_enc_amount := r_element_period_amount.r_period_amount(J);
1440 EXIT;
1441 END IF;
1442 END LOOP;
1443 END IF;
1444 -- End of changes for bug fix 3673723
1445
1446 r_enc_period.r_period_amount(I) := ROUND(l_enc_amount, g_ext_precision);
1447 ELSE
1448 r_enc_period.r_period_amount(I) := 0;
1449 END IF;
1450 l_prev_time_period_id := l_time_period_id;
1451 ELSE
1452 r_enc_period.r_period_amount(I) := r_enc_period.r_period_amount(I - 1);
1453 END IF;
1454 END LOOP;
1455 ELSE
1456 hr_utility.trace('Period amounts based on formula/user hook amounts');
1457 l_enc_amount := 0;
1458 l_period_counter := 1;
1459 l_tmp_counter := 1;
1460 LOOP
1461 EXIT WHEN l_tmp_counter > r_enc_period.r_time_period_id.COUNT;
1462 hr_utility.trace('l_tmp_counter: ' || l_tmp_counter || ' EM: ' || r_enc_period.r_encumbrance_amount(l_tmp_counter));
1463 IF (l_tmp_counter = 1) THEN
1464 l_time_period_id := r_enc_period.r_time_period_id(l_tmp_counter);
1465 END IF;
1466 IF (r_enc_period.r_time_period_id(l_tmp_counter) = l_time_period_id) THEN
1467 IF (r_enc_period.r_schedule_percent(l_tmp_counter) IN (0, 100)) THEN
1468 l_enc_amount := l_enc_amount + r_enc_period.r_encumbrance_amount(l_tmp_counter);
1469 END IF;
1470 ELSE
1471 r_element_period_amount.r_period_amount(l_period_counter) := l_enc_amount;
1472 r_element_period_amount.r_time_period_id(l_period_counter) := l_time_period_id;
1473 l_enc_amount := 0;
1474 IF (r_enc_period.r_schedule_percent(l_tmp_counter) IN (0, 100)) THEN
1475 l_enc_amount := r_enc_period.r_encumbrance_amount(l_tmp_counter);
1476 END IF;
1477 l_time_period_id := r_enc_period.r_time_period_id(l_tmp_counter);
1478 l_period_counter := l_period_counter + 1;
1479 END IF;
1480 IF (l_tmp_counter = r_enc_period.r_time_period_id.COUNT) THEN
1481 r_element_period_amount.r_period_amount(l_period_counter) := l_enc_amount;
1482 r_element_period_amount.r_time_period_id(l_period_counter) := l_time_period_id;
1483 END IF;
1484 l_tmp_counter := l_tmp_counter + 1;
1485 END LOOP;
1486 l_period_counter := 1;
1487 FOR J IN 1..r_enc_period.r_time_period_id.COUNT
1488 LOOP
1489 hr_utility.trace('l_period_counter: ' || l_period_counter);
1490 IF (r_enc_period.r_time_period_id(J) <> r_element_period_amount.r_time_period_id(l_period_counter)) THEN
1491 l_period_counter := l_period_counter + 1;
1492 END IF;
1493 r_enc_period.r_period_amount(J) := r_element_period_amount.r_period_amount(l_period_counter);
1494 END LOOP;
1495 END IF;
1496
1497 l_proc_step:= 170;
1498
1499 hr_utility.trace('Dumping Assignment Chunks after determining Assignment chunk and Period chunk amounts');
1500 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
1501 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
1502 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
1503 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
1504 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
1505 LPAD('Encumbrance Amount', 18, ' ') || ' ' || LPAD('Period Amount', 18, ' ') || ' ' ||
1506 RPAD('Reason Code', 50, ' '));
1507
1508 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
1509 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
1510 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
1511 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
1512 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
1513 LPAD('-', 18, '-') || ' ' || LPAD('-', 18, '-') || ' ' ||
1514 RPAD('-', 50, '-'));
1515
1516 FOR recno IN 1..r_enc_period.r_time_period_id.COUNT
1517 LOOP
1518 hr_utility.trace(LPAD(recno, 13, ' ') || ' ' ||
1519 LPAD(r_enc_period.r_time_period_id(recno), 14, ' ') || ' ' ||
1520 RPAD(TO_CHAR(r_enc_period.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
1521 RPAD(TO_CHAR(r_enc_period.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
1522 RPAD(TO_CHAR(r_enc_period.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
1523 RPAD(TO_CHAR(r_enc_period.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
1524 RPAD(TO_CHAR(r_enc_period.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
1525 RPAD(r_enc_period.r_process_flag(recno), 12, ' ') || ' ' ||
1526 LPAD(r_enc_period.r_schedule_percent(recno), 16, ' ') || ' ' ||
1527 LPAD(r_enc_period.r_encumbrance_amount(recno), 18, ' ') || ' ' ||
1528 LPAD(r_enc_period.r_period_amount(recno), 18, ' ') || ' ' ||
1529 RPAD(r_enc_period.r_reason_code(recno), 50, ' '));
1530 END LOOP;
1531 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving ' || l_proc_name);
1532
1533 p_return_status := fnd_api.g_ret_sts_success;
1534 EXCEPTION
1535 WHEN DIVIDE_BY_ZERO THEN
1536 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', ' DETERMINE_ENC_AMOUNT ');
1537 fnd_file.put_line(fnd_file.log, fnd_number.number_to_canonical(l_proc_step) || ': ' || l_proc_name);
1538 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving ' || l_proc_name);
1539 p_return_status := fnd_api.g_ret_sts_unexp_error;
1540 WHEN OTHERS THEN
1541 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
1542 IF (g_error_message IS NULL) THEN
1543 g_error_message := l_proc_name || ': ' || SQLERRM;
1544 END IF;
1545 fnd_msg_pub.add_exc_msg('PSP', 'DETERMINE_ENC_AMOUNT');
1546 fnd_file.put_line(fnd_file.log, fnd_number.number_to_canonical(l_proc_step) || ': ' || l_proc_name);
1547 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving ' || l_proc_name);
1548 p_return_status := fnd_api.g_ret_sts_unexp_error;
1549 END determine_enc_amount;
1550 -- End of changes for bug fix 3488734
1551
1552 ---------------------- C R E A T E L I N E S -------------------------------------
1553
1554 /*************************************************************************
1555 This procedure accepts the Assignment ID, Last Payroll Run date, Max. Encumbrance Date, Earnings Amount,
1556 Element Type ID as input parameters. This procedure determines the different accounts that need to be
1557 charged and the amounts that need to be charged until a particular Date. The logic
1558 used to arrive at the charging instructions is derived from CREATE_DISTRIBUTION_LINES
1559 in Oracle Labor Distribution.
1560 Finally, the procedure creates encumbrance lines in PSP_ENC_LINES.
1561 *************************************************************************/
1562
1563 /**********************************************************************************
1564 CODING LOGIC
1565 --> Retrieve the date ranges for which encumbrance has to be done:
1566 --When Called in Create Mode all time periods beyond the max. encumbrance period are considered.
1567 --When called in Update/Quick Update Mode periods between last payroll run date and max. encumbered date
1568 for that assignment are considered.
1569 --All the active assignment chunks are Bulk Collected inot r_enc_period RECORD.
1570 --> 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
1571 in the payroll.
1572 --> For each active assignment chunk, calculate the daily rate (from Encumbrance amount and business days)
1573 --> Then, go through a loop to find the schedule for that assignment chunk by going through the schedule
1574 hierarchy.
1575 --> Once the schedule has been determined, then create encumbrance lines
1576 --> Exit out of the First Loop when the assignment start date > Enumbrance End date Calculated within each
1577 Hierarchy for each CI. For GL Encumrbance End date = Org. Default End Date for POETA it is computed
1578 thorugh procedure Obtain_Enc_Poeta_Enc_date.
1579 --> Close First Loop
1580
1581
1582 ***********************************************************************************/
1583
1584 PROCEDURE create_lines( p_assignment_id IN NUMBER,
1585 p_payroll_id IN NUMBER,
1586 p_element_type_id IN NUMBER,
1587 p_last_paid_date IN DATE,
1588 p_return_status OUT NOCOPY VARCHAR2) IS
1589 CURSOR enc_period_cur IS
1590 SELECT ptp.time_period_id,
1591 ptp.start_date,
1592 ptp.end_date,
1593 GREATEST(ptp.start_date, paf.effective_start_date),
1594 LEAST(ptp.end_date, paf.effective_end_date),
1595 DECODE(g_Eff_Date_Value, 1, ptp.end_date,
1596 2, ptp.start_date,
1597 3, ptp.regular_payment_date,
1598 4, ptp.default_dd_date,
1599 5, ptp.cut_off_date) effective_date,
1600 'Y',
1601 0,
1602 NULL
1603 FROM per_time_periods ptp,
1604 per_all_assignments_f paf,
1605 per_assignment_status_types past
1606 WHERE ptp.payroll_id = p_payroll_id
1607 AND paf.assignment_id = p_assignment_id
1608 AND ptp.start_date <= paf.effective_end_date
1609 AND ptp.end_date >= paf.effective_start_date
1610 AND past.assignment_status_type_id = paf.assignment_status_type_id
1611 AND past.per_system_status = 'ACTIVE_ASSIGN'
1612 AND paf.payroll_id=p_payroll_id
1613 AND ptp.start_date >= p_last_paid_date
1614 AND paf.effective_start_date <= g_enc_org_end_date
1615 AND (g_actual_term_date IS NULL OR ptp.start_date <= g_actual_term_date)
1616 AND (g_pateo_end_date IS NULL OR ptp.start_date <= g_pateo_end_date)
1617 ORDER BY 1, 4;
1618
1619 CURSOR c_person_id IS
1620 SELECT paf.person_id
1621 FROM per_all_assignments_f paf
1622 WHERE paf.assignment_id =p_assignment_id
1623 AND ROWNUM=1;
1624
1625 l_project_number pa_projects_all.segment1%TYPE;
1626 l_task_number VARCHAR2(300); -- pa_tasks.task_number%TYPE; Bug : 16391366 (27/03/2013)
1627 l_award_number gms_awards_all.award_number%TYPE;
1628 l_exp_org_name hr_organization_units.name%TYPE;
1629 l_gl_description VARCHAR2(4000);
1630 l_time_period_id NUMBER;
1631 l_return_status VARCHAR2(1);
1632 l_person_id NUMBER;
1633 l_effective_date DATE;
1634 l_msg_count NUMBER;
1635 l_msg_data VARCHAR2(2000);
1636 l_period_start_date DATE;
1637 l_period_end_date DATE;
1638 l_earnings_amount NUMBER;
1639 l_asg_start_date DATE;
1640 l_asg_end_date DATE;
1641 l_process_flag VARCHAR2(10);
1642 r_enc_period_tmp enc_period_rectype;
1643 l_prev_time_period_id NUMBER;
1644 l_enc_element_type_id NUMBER;
1645 l_period_ind NUMBER;
1646 l_running_total NUMBER;
1647 l_prev_enc_lines_counter NUMBER;
1648 l_proc_name VARCHAR2(61);
1649 l_proc_step NUMBER(20, 10);
1650 l_schedule_line_id NUMBER(15);
1651 l_element_account_id NUMBER(15);
1652 l_org_schedule_id NUMBER(15);
1653 l_default_account_id NUMBER(15);
1654 l_suspense_account_id NUMBER(15);
1655 l_gl_code_combination_id NUMBER(15);
1656 l_project_id NUMBER(15);
1657 l_task_id NUMBER(15);
1658 l_award_id NUMBER(15);
1659 l_expenditure_type VARCHAR2(30);
1660 l_expenditure_org_id NUMBER(15);
1661 l_orig_gl_code_combination_id NUMBER(15);
1662 l_orig_project_id NUMBER(15);
1663 l_orig_task_id NUMBER(15);
1664 l_orig_award_id NUMBER(15);
1665 l_orig_expenditure_type VARCHAR2(30);
1666 l_orig_expenditure_org_id NUMBER(15);
1667 l_attribute_category VARCHAR2(30);
1668 l_attribute1 VARCHAR2(150);
1669 l_attribute2 VARCHAR2(150);
1670 l_attribute3 VARCHAR2(150);
1671 l_attribute4 VARCHAR2(150);
1672 l_attribute5 VARCHAR2(150);
1673 l_attribute6 VARCHAR2(150);
1674 l_attribute7 VARCHAR2(150);
1675 l_attribute8 VARCHAR2(150);
1676 l_attribute9 VARCHAR2(150);
1677 l_attribute10 VARCHAR2(150);
1678 l_reason_code VARCHAR2(50);
1679 l_schedule_percent NUMBER;
1680 l_dist_amount NUMBER;
1681 l_bus_days_in_chunk NUMBER;
1682 l_start_date_active DATE;
1683 l_end_date_active DATE;
1684 l_poeta_start_date DATE;
1685 l_poeta_end_date DATE;
1686 no_global_acct_exists EXCEPTION;
1687 suspense_ac_invalid EXCEPTION;
1688 suspense_autopop_failed EXCEPTION;
1689 l_autopop_status VARCHAR2(1);
1690 l_autopop_error VARCHAR2(50);
1691 l_new_expenditure_type VARCHAR2(30);
1692 l_new_gl_code_combination_id NUMBER(15);
1693 l_acct_type VARCHAR2(1);
1694 l_orig_pointer NUMBER(15);
1695 l_chunk_pointer NUMBER(15);
1696 l_enc_period_count NUMBER(15);
1697 l_organization_id NUMBER(15);
1698 l_ignore_start NUMBER(15);
1699 l_ignore_end NUMBER(15);
1700 l_organization_name VARCHAR2(240);
1701 l_min_start_date DATE;
1702 l_max_end_date DATE;
1703
1704 CURSOR asg_number_cur IS
1705 SELECT organization_id
1706 FROM per_all_assignments_f
1707 WHERE assignment_id = p_assignment_id
1708 AND payroll_id = p_payroll_id
1709 AND effective_end_date >= l_asg_start_date
1710 AND ROWNUM = 1;
1711
1712 CURSOR org_name_cur IS
1713 SELECT name
1714 FROM hr_organization_units
1715 WHERE organization_id = l_organization_id;
1716
1717 CURSOR project_number_cur IS
1718 SELECT SEGMENT1
1719 FROM pa_projects_all
1720 WHERE project_id = l_project_id;
1721
1722 CURSOR award_number_cur IS
1723 SELECT award_number
1724 FROM gms_awards_all
1725 WHERE award_id = l_award_id;
1726
1727 CURSOR task_number_cur Is
1728 SELECT task_number
1729 FROM pa_tasks_expend_v -- Bug : 16391366 (20/03/2013)
1730 WHERE task_id = l_task_id;
1731
1732 CURSOR exp_org_name_cur IS
1733 SELECT name
1734 FROM hr_organization_units
1735 WHERE organization_id = l_expenditure_org_id;
1736
1737 PROCEDURE process_all_hier (p_chunk_pointer IN NUMBER,
1738 p_asg_start_date IN DATE,
1739 p_asg_end_date IN DATE,
1740 p_encumbrance_amount IN NUMBER,
1741 p_process_flag IN VARCHAR2) IS
1742 l_da_reason_code VARCHAR2(50);
1743 l_sa_reason_code VARCHAR2(50);
1744 l_gl_project_flag VARCHAR2(1);
1745 l_linkage_status VARCHAR2(50);
1746 l_patc_status VARCHAR2(50);
1747 l_billable_flag VARCHAR2(1);
1748 l_bus_days_in_period NUMBER;
1749 l_bus_days_in_sched NUMBER;
1750 l_msg_count NUMBER;
1751 l_msg_data VARCHAR2(2000);
1752 l_msg_app VARCHAR2(2000);
1753 l_msg_type VARCHAR2(2000);
1754 l_msg_token1 VARCHAR2(2000);
1755 l_msg_token2 VARCHAR2(2000);
1756 l_msg_token3 VARCHAR2(2000);
1757 l_award_status VARCHAR2(2000);
1758 l_last_enc_date DATE;
1759 l_daily_rate NUMBER;
1760 t_poeta_gl_hier_array r_poeta_gl_hier_tab;
1761 l_org_id NUMBER(15);
1762 BEGIN
1763 IF (p_process_flag = 'DA') THEN
1764 l_da_reason_code := l_reason_code;
1765 END IF;
1766
1767 IF (p_process_flag = 'SA') THEN
1768 l_sa_reason_code := l_reason_code;
1769 END IF;
1770
1771 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering process_all_hier');
1772 hr_utility.trace(' p_chunk_pointer: ' || p_chunk_pointer ||
1773 ' p_asg_start_date: ' || TO_CHAR(p_asg_start_date, 'DD-MON-RRRR') ||
1774 ' p_asg_end_date: ' || TO_CHAR(p_asg_end_date, 'DD-MON-RRRR') ||
1775 ' p_process_flag: ' || p_process_flag);
1776
1777 l_last_enc_date := NVL(g_actual_term_date, g_enc_org_end_date);
1778
1779 IF ((p_process_flag <> 'SA') AND (l_project_id IS NOT NULL)) THEN
1780 l_patc_status := NULL;
1781 l_linkage_status:= NULL;
1782 l_billable_flag := NULL;
1783 l_award_status := NULL;
1784
1785 obtain_enc_poeta_end_date (p_ls_start_date => l_start_date_active,
1786 p_ls_end_date => l_end_date_active,
1787 p_poeta_end_date => l_poeta_end_date,
1788 p_enc_end_date => l_last_enc_date,
1789 p_return_status => l_return_status);
1790 IF l_return_status <> fnd_api.g_ret_sts_success THEN
1791 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1792 END IF;
1793 END IF;
1794 hr_utility.trace(' l_last_enc_date: ' || TO_CHAR(l_last_enc_date, 'DD-MON-RRRR'));
1795
1796 IF (r_enc_period.r_asg_start_date(p_chunk_pointer) <= l_last_enc_date) THEN
1797 l_start_date_active := GREATEST(l_start_date_active, p_asg_start_date);
1798 l_end_date_active := LEAST(l_end_date_active, p_asg_end_date, l_last_enc_date);
1799 l_daily_rate := round((r_enc_period.r_encumbrance_amount(p_chunk_pointer) * l_schedule_percent/100),g_ext_precision);
1800 l_daily_rate := NVL(p_encumbrance_amount, l_daily_rate);
1801 hr_utility.trace(' l_start_date_active: ' || TO_CHAR(l_start_date_active, 'DD-MON-RRRR') ||
1802 ' l_end_date_active: ' || TO_CHAR(l_end_date_active, 'DD-MON-RRRR') ||
1803 ' l_poeta_start_date: ' || TO_CHAR(l_poeta_start_date, 'DD-MON-RRRR') ||
1804 ' l_poeta_end_date: ' || TO_CHAR(l_poeta_end_date, 'DD-MON-RRRR') ||
1805 ' l_daily_rate: ' || l_daily_rate);
1806 determine_pro_rata_dates (p_assignment_id => p_assignment_id,
1807 p_ls_start_date => l_start_date_active,
1808 p_ls_end_date => l_end_date_active,
1809 p_poeta_start_date => l_poeta_start_date,
1810 p_poeta_end_date => l_poeta_end_date,
1811 p_asg_start_date => p_asg_start_date,
1812 p_asg_end_date => p_asg_end_date,
1813 p_asg_amount => l_daily_rate,
1814 p_poeta_gl_hier_array => t_poeta_gl_hier_array,
1815 p_return_status => l_return_status);
1816 IF l_return_status <> fnd_api.g_ret_sts_success THEN
1817 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1818 END IF;
1819
1820 hr_utility.trace(' t_poeta_gl_hier_array.COUNT: ' || t_poeta_gl_hier_array.COUNT);
1821 FOR I IN 1..t_poeta_gl_hier_array.COUNT
1822 LOOP
1823 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') ||
1824 ' 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') ||
1825 ' t_poeta_gl_hier_array(' || I || ').r_amount: ' || t_poeta_gl_hier_array(I).r_amount ||
1826 ' t_poeta_gl_hier_array(' || I || ').r_susp_flag: ' || t_poeta_gl_hier_array(I).r_susp_flag);
1827 IF t_poeta_gl_hier_array(I).r_susp_flag <> 'Y' THEN
1828 l_dist_amount := t_poeta_gl_hier_array(I).r_amount;
1829 l_effective_date := r_enc_period.r_effective_date(p_chunk_pointer);
1830 l_gl_project_flag := 'G';
1831
1832 IF l_gl_code_combination_id IS NOT NULL THEN
1833 insert_into_enc_lines(
1834 p_element_type_id,
1835 l_effective_date,
1836 g_dr_cr_flag ,
1837 ROUND(l_dist_amount, g_precision),
1838 g_enc_line_type,
1839 l_schedule_line_id,
1840 l_org_schedule_id,
1841 l_default_account_id,
1842 l_suspense_account_id,
1843 l_element_account_id,
1844 l_gl_project_flag,
1845 l_person_id,
1846 p_assignment_id,
1847 l_award_id,
1848 l_task_id,
1849 l_expenditure_type,
1850 l_expenditure_org_id,
1851 l_project_id,
1852 l_gl_code_combination_id,
1853 r_enc_period.r_time_period_id(p_chunk_pointer),
1854 p_payroll_id,
1855 g_business_group_id,
1856 g_set_of_books_id,
1857 l_sa_reason_code,
1858 l_da_reason_code,
1859 'N',
1860 t_poeta_gl_hier_array(i).r_enc_start_date,
1861 t_poeta_gl_hier_array(i).r_enc_end_date,
1862 l_attribute_category,
1863 l_attribute1,
1864 l_attribute2,
1865 l_attribute3,
1866 l_attribute4,
1867 l_attribute5,
1868 l_attribute6,
1869 l_attribute7,
1870 l_attribute8,
1871 l_attribute9,
1872 l_attribute10,
1873 l_orig_gl_code_combination_id,
1874 l_orig_project_id,
1875 l_orig_task_id,
1876 l_orig_award_id,
1877 l_orig_expenditure_org_id,
1878 l_orig_expenditure_type,
1879 l_process_flag,
1880 l_return_status);
1881 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1882 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1883 END IF;
1884 ELSE
1885 psp_general.poeta_effective_date (t_poeta_gl_hier_array(I).r_enc_end_date,
1886 l_project_id,
1887 l_award_id,
1888 l_task_id,
1889 l_effective_date,
1890 l_return_status);
1891 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1892 fnd_message.set_name('PSP', 'PSP_POETA_EFFECTIVE_DATE_ERROR');
1893 g_error_message := fnd_message.get;
1894 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1895 END IF;
1896
1897 -- R12 moac uptake. Set the MOAC Context to Single
1898 l_org_id := psp_general.get_transaction_org_id( l_project_id, l_expenditure_org_id);
1899 mo_global.set_policy_context('S', l_org_id);
1900
1901 pa_transactions_pub.validate_transaction
1902 (x_project_id => l_project_id,
1903 x_task_id => l_task_id,
1904 x_ei_date => l_effective_date,
1905 x_expenditure_type => l_expenditure_type,
1906 x_non_labor_resource => NULL,
1907 x_person_id => l_person_id,
1908 x_incurred_by_org_id => l_expenditure_org_id,
1909 x_calling_module => 'PSPENLNB',
1910 x_msg_application => l_msg_app,
1911 x_msg_type => l_msg_type,
1912 x_msg_token1 => l_msg_token1,
1913 x_msg_token2 => l_msg_token2,
1914 x_msg_token3 => l_msg_token3,
1915 x_msg_count => l_msg_count,
1916 x_msg_data => l_patc_status,
1917 x_billable_flag => l_billable_flag,
1918 p_sys_link_function => 'ST'); --Bug 5639589: Added parameter
1919
1920
1921 IF l_patc_status IS NULL THEN
1922 gms_transactions_pub.validate_transaction
1923 (l_project_id,
1924 l_task_id,
1925 l_award_id,
1926 l_expenditure_type,
1927 l_effective_date,
1928 'PSPENLNB',
1929 l_award_status);
1930
1931 IF l_award_status IS NOT NULL THEN
1932 l_patc_status := SUBSTR(l_award_status,1,50);
1933
1934
1935 -- Bug 10074228 Added log message as CUEL process fails because of invalid award giving no details
1936
1937 fnd_file.put_line(fnd_file.log,'l_person_id: '||l_person_id||', p_assignment_id: '||p_assignment_id);
1938 fnd_file.put_line(fnd_file.log,'l_project_id: '||l_project_id||', l_task_id: '||l_task_id
1939 ||', l_award_id: '||l_award_id||', l_expenditure_type: '||l_expenditure_type||', l_effective_date: '||l_effective_date);
1940
1941
1942
1943 END IF;
1944 END IF;
1945 -- Set the MOAC Context to Multiple
1946 mo_global.set_policy_context('M', null);
1947
1948 IF (l_patc_status IS NOT NULL ) THEN
1949 IF (p_process_flag = 'SA') THEN
1950 OPEN project_number_cur;
1951 FETCH project_number_cur INTO l_project_number;
1952 CLOSE project_number_cur;
1953
1954 OPEN award_number_cur;
1955 FETCH award_number_cur INTO l_award_number;
1956 CLOSE award_number_cur;
1957
1958 OPEN task_number_cur;
1959 FETCH task_number_cur INTO l_task_number;
1960 CLOSE task_number_cur;
1961
1962 OPEN exp_org_name_cur;
1963 FETCH exp_org_name_cur INTO l_exp_org_name;
1964 CLOSE exp_org_name_cur;
1965
1966 IF (l_patc_status IS NOT NULL) THEN
1967 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_INV_PATEO');
1968 fnd_message.set_token('PJ', l_project_number);
1969 fnd_message.set_token('TK', l_task_number);
1970 fnd_message.set_token('AW', l_award_number);
1971 fnd_message.set_token('EO', l_exp_org_name);
1972 fnd_message.set_token('ET', l_expenditure_type);
1973 fnd_message.set_token('START_DATE', t_poeta_gl_hier_array(i).r_enc_start_date);
1974 fnd_message.set_token('END_DATE', t_poeta_gl_hier_array(i).r_enc_end_date);
1975 fnd_message.set_token('ERROR_STATUS', l_patc_status);
1976 ELSE
1977 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_END_PATEO');
1978 fnd_message.set_token('PJ', l_project_number);
1979 fnd_message.set_token('TK', l_task_number);
1980 fnd_message.set_token('AW', l_award_number);
1981 fnd_message.set_token('EO', l_exp_org_name);
1982 fnd_message.set_token('ET', l_expenditure_type);
1983 fnd_message.set_token('START_DATE', t_poeta_gl_hier_array(i).r_enc_start_date);
1984 fnd_message.set_token('END_DATE', t_poeta_gl_hier_array(i).r_enc_end_date);
1985 fnd_message.set_token('EFFECTIVE_DATE', l_poeta_end_date);
1986 END IF;
1987 g_error_message := fnd_message.get;
1988 fnd_file.put_line(fnd_file.log, g_error_message);
1989 RAISE SUSPENSE_AC_INVALID;
1990 END IF;
1991
1992 IF ((t_poeta_gl_hier_array(I).r_enc_start_date <= g_enc_org_end_date) AND
1993 (psp_general.business_days(t_poeta_gl_hier_array(I).r_enc_start_date,
1994 t_poeta_gl_hier_array(I).r_enc_end_date) > 0)) THEN
1995 orig_ci.gl_code_combination_id(g_orig_pointer) := l_gl_code_combination_id;
1996 orig_ci.project_id(g_orig_pointer) := l_project_id;
1997 orig_ci.task_id(g_orig_pointer) := l_task_id;
1998 orig_ci.award_id(g_orig_pointer) := l_award_id;
1999 orig_ci.expenditure_organization_id(g_orig_pointer) := l_expenditure_org_id;
2000 orig_ci.expenditure_type(g_orig_pointer) := l_expenditure_type;
2001 g_orig_pointer := g_orig_pointer + 1;
2002 l_enc_period_count := r_enc_period.r_time_period_id.COUNT + 1;
2003 r_enc_period.r_period_ind(l_enc_period_count) := r_enc_period.r_period_ind(p_chunk_pointer);
2004 r_enc_period.r_period_start_date(l_enc_period_count) := r_enc_period.r_period_start_date(p_chunk_pointer);
2005 r_enc_period.r_period_end_date(l_enc_period_count) := r_enc_period.r_period_end_date(p_chunk_pointer);
2006 r_enc_period.r_asg_start_date(l_enc_period_count) := t_poeta_gl_hier_array(I).r_enc_start_date;
2007 r_enc_period.r_asg_end_date(l_enc_period_count) := t_poeta_gl_hier_array(I).r_enc_end_date;
2008 r_enc_period.r_effective_date(l_enc_period_count) := r_enc_period.r_effective_date(p_chunk_pointer);
2009 r_enc_period.r_time_period_id(l_enc_period_count) := r_enc_period.r_time_period_id(p_chunk_pointer);
2010 r_enc_period.r_process_flag(l_enc_period_count) := 'SA';
2011 r_enc_period.r_schedule_percent(l_enc_period_count) := 100;
2012 r_enc_period.r_encumbrance_amount(l_enc_period_count) :=
2013 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)) /
2014 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);
2015 r_enc_period.r_period_amount(l_enc_period_count) := r_enc_period.r_period_amount(p_chunk_pointer);
2016 r_enc_period.r_reason_code(l_enc_period_count) := l_patc_status;
2017 END IF;
2018 add_cel_warnings(p_start_date => t_poeta_gl_hier_array(I).r_enc_start_date,
2019 p_end_date => t_poeta_gl_hier_array(I).r_enc_end_date,
2020 p_hierarchy_code => 'SA',
2021 p_warning_code => 'INVALID_CI',
2022 p_project_id => l_project_id,
2023 p_task_id => l_task_id,
2024 p_award_id => l_award_id,
2025 p_exp_org_id => l_expenditure_org_id,
2026 p_exp_type => l_expenditure_type,
2027 p_effective_date => l_poeta_end_date,
2028 p_error_status => l_patc_status);
2029 ELSE
2030 l_gl_project_flag := 'P';
2031 insert_into_enc_lines
2032 (p_element_type_id,
2033 l_effective_date,
2034 g_dr_cr_flag,
2035 ROUND(l_dist_amount,g_precision),
2036 g_enc_line_type,
2037 l_schedule_line_id,
2038 l_org_schedule_id,
2039 l_default_account_id,
2040 l_suspense_account_id,
2041 l_element_account_id,
2042 l_gl_project_flag,
2043 l_person_id,
2044 p_assignment_id,
2045 l_award_id,
2046 l_task_id,
2047 l_expenditure_type,
2048 l_expenditure_org_id,
2049 l_project_id,
2050 l_gl_code_combination_id,
2051 r_enc_period.r_time_period_id(p_chunk_pointer),
2052 p_payroll_id,
2053 g_business_group_id,
2054 g_set_of_books_id,
2055 l_sa_reason_code,
2056 l_da_reason_code,
2057 'N',
2058 t_poeta_gl_hier_array(i).r_enc_start_date,
2059 t_poeta_gl_hier_array(i).r_enc_end_date,
2060 l_attribute_category,
2061 l_attribute1,
2062 l_attribute2,
2063 l_attribute3,
2064 l_attribute4,
2065 l_attribute5,
2066 l_attribute6,
2067 l_attribute7,
2068 l_attribute8,
2069 l_attribute9,
2070 l_attribute10,
2071 l_orig_gl_code_combination_id,
2072 l_orig_project_id,
2073 l_orig_task_id,
2074 l_orig_award_id,
2075 l_orig_expenditure_org_id,
2076 l_orig_expenditure_type,
2077 l_process_flag,
2078 l_return_status);
2079 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2080 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2081 END IF;
2082 END IF;
2083 END IF;
2084 ELSE
2085 l_dist_amount := t_poeta_gl_hier_array(i).r_amount;
2086
2087 psp_general.poeta_effective_date (t_poeta_gl_hier_array(I).r_enc_end_date,
2088 l_project_id,
2089 l_award_id,
2090 l_task_id,
2091 l_effective_date,
2092 l_return_status);
2093 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2094 fnd_message.set_name('PSP', 'PSP_POETA_EFFECTIVE_DATE_ERROR');
2095 g_error_message := fnd_message.get;
2096 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2097 END IF;
2098
2099 -- R12 moac uptake. Set the MOAC Context to Single
2100 l_org_id := psp_general.get_transaction_org_id( l_project_id, l_expenditure_org_id);
2101 mo_global.set_policy_context('S', l_org_id);
2102
2103 pa_transactions_pub.validate_transaction
2104 (x_project_id => l_project_id,
2105 x_task_id => l_task_id,
2106 x_ei_date => t_poeta_gl_hier_array(I).r_enc_end_date,
2107 x_expenditure_type => l_expenditure_type,
2108 x_non_labor_resource => NULL,
2109 x_person_id => l_person_id,
2110 x_incurred_by_org_id => l_expenditure_org_id,
2111 x_calling_module => 'PSPENLNB',
2112 x_msg_application => l_msg_app,
2113 x_msg_type => l_msg_type,
2114 x_msg_token1 => l_msg_token1,
2115 x_msg_token2 => l_msg_token2,
2116 x_msg_token3 => l_msg_token3,
2117 x_msg_count => l_msg_count,
2118 x_msg_data => l_patc_status,
2119 x_billable_flag => l_billable_flag,
2120 p_sys_link_function => 'ST'); --Bug 5639589: Added parameter
2121
2122
2123 IF l_patc_status IS NULL THEN
2124 gms_transactions_pub.validate_transaction
2125 (l_project_id,
2126 l_task_id,
2127 l_award_id,
2128 l_expenditure_type,
2129 t_poeta_gl_hier_array(I).r_enc_end_date,
2130 'PSPENLNB',
2131 l_award_status);
2132
2133 IF l_award_status IS NOT NULL THEN
2134 l_patc_status := SUBSTR(l_award_status,1,50);
2135 -- Bug 10067650 Added log message as CUEL process fails because of invalid award giving no details
2136 fnd_file.put_line(fnd_file.log,'l_person_id: '||l_person_id||', p_assignment_id: '||p_assignment_id);
2137 fnd_file.put_line(fnd_file.log,'l_project_id: '||l_project_id||', l_task_id: '||l_task_id
2138 ||', l_award_id: '||l_award_id||', l_expenditure_type: '||l_expenditure_type||', l_effective_date: '||l_effective_date);
2139
2140 END IF;
2141 END IF;
2142 -- Set the MOAC Context to Multiple
2143 mo_global.set_policy_context('M', null);
2144
2145 IF (p_process_flag = 'SA') THEN
2146 OPEN project_number_cur;
2147 FETCH project_number_cur INTO l_project_number;
2148 CLOSE project_number_cur;
2149
2150 OPEN award_number_cur;
2151 FETCH award_number_cur INTO l_award_number;
2152 CLOSE award_number_cur;
2153
2154 OPEN task_number_cur;
2155 FETCH task_number_cur INTO l_task_number;
2156 CLOSE task_number_cur;
2157
2158 OPEN exp_org_name_cur;
2159 FETCH exp_org_name_cur INTO l_exp_org_name;
2160 CLOSE exp_org_name_cur;
2161
2162 IF (l_patc_status IS NOT NULL) THEN
2163 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_INV_PATEO');
2164 fnd_message.set_token('PJ', l_project_number);
2165 fnd_message.set_token('TK', l_task_number);
2166 fnd_message.set_token('AW', l_award_number);
2167 fnd_message.set_token('EO', l_exp_org_name);
2168 fnd_message.set_token('ET', l_expenditure_type);
2169 fnd_message.set_token('START_DATE', t_poeta_gl_hier_array(i).r_enc_start_date);
2170 fnd_message.set_token('END_DATE', t_poeta_gl_hier_array(i).r_enc_end_date);
2171 fnd_message.set_token('ERROR_STATUS', l_patc_status);
2172 ELSE
2173 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_END_PATEO');
2174 fnd_message.set_token('PJ', l_project_number);
2175 fnd_message.set_token('TK', l_task_number);
2176 fnd_message.set_token('AW', l_award_number);
2177 fnd_message.set_token('EO', l_exp_org_name);
2178 fnd_message.set_token('ET', l_expenditure_type);
2179 fnd_message.set_token('START_DATE', t_poeta_gl_hier_array(i).r_enc_start_date);
2180 fnd_message.set_token('END_DATE', t_poeta_gl_hier_array(i).r_enc_end_date);
2181 fnd_message.set_token('EFFECTIVE_DATE', l_poeta_end_date);
2182 END IF;
2183 g_error_message := fnd_message.get;
2184 fnd_file.put_line(fnd_file.log, g_error_message);
2185 RAISE SUSPENSE_AC_INVALID;
2186 END IF;
2187
2188 IF ((t_poeta_gl_hier_array(I).r_enc_start_date <= g_enc_org_end_date) AND
2189 (psp_general.business_days(t_poeta_gl_hier_array(I).r_enc_start_date,
2190 t_poeta_gl_hier_array(I).r_enc_end_date,p_assignment_id) > 0)) THEN
2191 orig_ci.gl_code_combination_id(g_orig_pointer) := l_gl_code_combination_id;
2192 orig_ci.project_id(g_orig_pointer) := l_project_id;
2193 orig_ci.task_id(g_orig_pointer) := l_task_id;
2194 orig_ci.award_id(g_orig_pointer) := l_award_id;
2195 orig_ci.expenditure_organization_id(g_orig_pointer) := l_expenditure_org_id;
2196 orig_ci.expenditure_type(g_orig_pointer) := l_expenditure_type;
2197 g_orig_pointer := g_orig_pointer + 1;
2198 l_enc_period_count := r_enc_period.r_time_period_id.COUNT + 1;
2199 r_enc_period.r_period_ind(l_enc_period_count) := r_enc_period.r_period_ind(p_chunk_pointer);
2200 r_enc_period.r_period_start_date(l_enc_period_count) := r_enc_period.r_period_start_date(p_chunk_pointer);
2201 r_enc_period.r_period_end_date(l_enc_period_count) := r_enc_period.r_period_end_date(p_chunk_pointer);
2202 r_enc_period.r_asg_start_date(l_enc_period_count) := t_poeta_gl_hier_array(I).r_enc_start_date;
2203 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);
2204 r_enc_period.r_effective_date(l_enc_period_count) := r_enc_period.r_effective_date(p_chunk_pointer);
2205 r_enc_period.r_time_period_id(l_enc_period_count) := r_enc_period.r_time_period_id(p_chunk_pointer);
2206 r_enc_period.r_process_flag(l_enc_period_count) := 'SA';
2207 r_enc_period.r_schedule_percent(l_enc_period_count) := 100;
2208 r_enc_period.r_encumbrance_amount(l_enc_period_count) :=
2209 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)) /
2210 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);
2211 r_enc_period.r_period_amount(l_enc_period_count) := r_enc_period.r_period_amount(p_chunk_pointer);
2212 r_enc_period.r_reason_code(l_enc_period_count) := l_patc_status;
2213 END IF;
2214
2215 add_cel_warnings(p_start_date => t_poeta_gl_hier_array(I).r_enc_start_date,
2216 p_end_date => t_poeta_gl_hier_array(I).r_enc_end_date,
2217 p_hierarchy_code => 'SA',
2218 p_warning_code => 'INVALID_CI',
2219 p_project_id => l_project_id,
2220 p_task_id => l_task_id,
2221 p_award_id => l_award_id,
2222 p_exp_org_id => l_expenditure_org_id,
2223 p_exp_type => l_expenditure_type,
2224 p_effective_date => l_poeta_end_date,
2225 p_error_status => l_patc_status);
2226 END IF;
2227 END LOOP;
2228 END IF;
2229 t_poeta_gl_hier_array.DELETE;
2230 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving process_all_hier');
2231 END process_all_hier;
2232
2233 PROCEDURE log_gl_hours_message IS
2234 BEGIN
2235 add_cel_warnings(p_start_date => l_asg_start_date,
2236 p_hierarchy_code => 'GL',
2237 p_end_date => l_asg_end_date,
2238 p_warning_code => 'GL',
2239 p_percent => ROUND(((l_earnings_amount*l_schedule_percent)/100), g_precision));
2240 END log_gl_hours_message;
2241
2242 BEGIN
2243 l_proc_step := 10;
2244 l_proc_name := 'CREATE_LINES';
2245
2246 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering ' || l_proc_name);
2247 hr_utility.trace('p_assignment_id: ' || fnd_number.number_to_canonical(p_assignment_id) ||
2248 ' p_payroll_id: ' || fnd_number.number_to_canonical(p_payroll_id) ||
2249 ' p_element_type_id: ' || fnd_number.number_to_canonical(p_element_type_id) ||
2250 ' p_last_paid_date: ' || fnd_date.date_to_canonical(p_last_paid_date));
2251
2252 p_return_status := fnd_api.g_ret_sts_success;
2253
2254 OPEN c_person_id;
2255 FETCH c_person_id INTO l_person_id;
2256 CLOSE c_person_id;
2257
2258 hr_utility.trace('l_person_id: ' || fnd_number.number_to_canonical(l_person_id));
2259 l_proc_step := 20;
2260 g_pateo_end_date := NULL;
2261
2262 OPEN enc_period_cur;
2263 FETCH enc_period_cur BULK COLLECT INTO r_enc_period.r_time_period_id,
2264 r_enc_period.r_period_start_date, r_enc_period.r_period_end_date,
2265 r_enc_period.r_asg_start_date, r_enc_period.r_asg_end_date,
2266 r_enc_period.r_effective_date, r_enc_period.r_process_flag,
2267 r_enc_period.r_schedule_percent, r_enc_period.r_reason_code;
2268 CLOSE enc_period_cur;
2269
2270 hr_utility.trace('r_enc_period.r_time_period_id.COUNT: ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id.COUNT));
2271 l_proc_step := 30;
2272
2273 IF (r_enc_period.r_time_period_id.COUNT > 0) THEN
2274 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);
2275 IF (p_return_status <> fnd_api.g_ret_sts_success) THEN
2276 RAISE fnd_api.g_exc_unexpected_error;
2277 END IF;
2278 END IF;
2279
2280 OPEN enc_period_cur;
2281 FETCH enc_period_cur BULK COLLECT INTO r_enc_period.r_time_period_id,
2282 r_enc_period.r_period_start_date, r_enc_period.r_period_end_date,
2283 r_enc_period.r_asg_start_date, r_enc_period.r_asg_end_date,
2284 r_enc_period.r_effective_date, r_enc_period.r_process_flag,
2285 r_enc_period.r_schedule_percent, r_enc_period.r_reason_code;
2286 CLOSE enc_period_cur;
2287
2288 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));
2289
2290 l_proc_step := 40;
2291
2292 IF (r_enc_period.r_time_period_id.COUNT > 0) THEN
2293 sub_slice_asg_chunk(p_assignment_id, p_element_type_id, g_business_group_id, g_set_of_books_id, p_return_status);
2294 IF (p_return_status <> fnd_api.g_ret_sts_success) THEN
2295 RAISE fnd_api.g_exc_unexpected_error;
2296 END IF;
2297 END IF;
2298
2299 hr_utility.trace('r_enc_period.r_time_period_id.COUNT: ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id.COUNT));
2300 l_proc_step := 50;
2301
2302 IF (r_enc_period.r_time_period_id.COUNT > 0) THEN
2303 determine_enc_amount(p_person_id => l_person_id,
2304 p_assignment_id => p_assignment_id,
2305 p_element_type_id => p_element_type_id,
2306 p_business_group_id => g_business_group_id,
2307 p_set_of_books_id => g_set_of_books_id,
2308 p_payroll_id => p_payroll_id,
2309 p_return_status => l_return_status);
2310 IF l_return_status <> fnd_api.g_ret_sts_success THEN
2311 RAISE fnd_api.g_exc_unexpected_error;
2312 END IF;
2313 END IF;
2314
2315 l_proc_step := 60;
2316 g_et_pointer := 1;
2317 g_ec_pointer := 1;
2318 g_asg_pointer := 1;
2319 g_ge_pointer := 1;
2320 g_odls_pointer := 1;
2321 g_da_pointer := 1;
2322 g_sa_pointer := 1;
2323 g_orig_pointer := 1;
2324 l_orig_pointer := 1;
2325 l_chunk_pointer := 1;
2326 l_prev_enc_lines_counter := t_enc_lines_array.r_time_period_id.COUNT + 1;
2327 l_min_start_date := fnd_date.canonical_to_date('1800/01/01');
2328 l_max_end_date := LEAST(NVL(g_actual_term_date, g_enc_org_end_date), g_enc_org_end_date);
2329 l_ignore_start := -1;
2330 l_ignore_end := -1;
2331
2332 IF (r_enc_period.r_asg_end_date.COUNT > 0) THEN
2333 l_min_start_date := r_enc_period.r_asg_start_date(1);
2334 l_max_end_date := LEAST(r_enc_period.r_asg_end_date(r_enc_period.r_asg_end_date.COUNT),
2335 l_max_end_date);
2336
2337 IF ( (l_min_start_date > r_enc_period.r_period_start_date(1)) AND
2338 (psp_general.business_days(r_enc_period.r_period_start_date(1),
2339 r_enc_period.r_period_end_date(1),p_assignment_id) <>
2340 psp_general.business_days(l_min_start_date,
2341 r_enc_period.r_period_end_date(1),p_assignment_id))) THEN
2342 l_ignore_start := r_enc_period.r_time_period_id(1);
2343 END IF;
2344
2345 IF ( (l_max_end_date < r_enc_period.r_period_end_date(r_enc_period.r_asg_end_date.COUNT)) AND
2346 (psp_general.business_days(r_enc_period.r_period_start_date(r_enc_period.r_asg_end_date.COUNT),
2347 r_enc_period.r_period_end_date(r_enc_period.r_asg_end_date.COUNT)) <>
2348 psp_general.business_days(r_enc_period.r_period_start_date(r_enc_period.r_asg_end_date.COUNT), l_max_end_date))) THEN
2349 l_ignore_end := r_enc_period.r_time_period_id(r_enc_period.r_asg_end_date.COUNT);
2350 END IF;
2351 hr_utility.trace('l_ignore_start: ' || l_ignore_start);
2352 hr_utility.trace('l_ignore_end: ' || l_ignore_end);
2353 END IF;
2354
2355 LOOP
2356 EXIT WHEN (l_chunk_pointer > r_enc_period.r_time_period_id.COUNT);
2357 l_asg_start_date := r_enc_period.r_asg_start_date(l_chunk_pointer);
2358 l_asg_end_date := r_enc_period.r_asg_end_date(l_chunk_pointer);
2359 l_period_start_date := r_enc_period.r_period_start_date(l_chunk_pointer);
2360 l_period_end_date := r_enc_period.r_period_end_date(l_chunk_pointer);
2361 l_time_period_id := r_enc_period.r_time_period_id(l_chunk_pointer);
2362 l_process_flag := r_enc_period.r_process_flag(l_chunk_pointer);
2363 l_earnings_amount := r_enc_period.r_encumbrance_amount(l_chunk_pointer);
2364 l_period_ind := r_enc_period.r_period_ind(l_chunk_pointer);
2365 l_effective_date := r_enc_period.r_effective_date(l_chunk_pointer);
2366 l_reason_code := r_enc_period.r_reason_code(l_chunk_pointer);
2367
2368 l_bus_days_in_chunk := psp_general.business_days(l_asg_start_date, l_asg_end_date,p_assignment_id);
2369 l_dist_amount := 0;
2370 l_schedule_line_id := NULL;
2371 l_org_schedule_id := NULL;
2372 l_element_account_id := NULL;
2373 l_default_account_id := NULL;
2374 l_suspense_account_id := NULL;
2375
2376 hr_utility.trace('Processing chunk: CP: ' || l_chunk_pointer || ' TP: ' || l_time_period_id ||
2377 ' PSD: ' || TO_CHAR(l_period_start_date, 'DD-MON-RRRR') || ' PED: ' || TO_CHAR(l_period_end_date, 'DD-MON-RRRR') ||
2378 ' ASD: ' || TO_CHAR(l_asg_start_date, 'DD-MON-RRRR') || ' AED: ' || TO_CHAR(l_asg_end_date, 'DD-MON-RRRR') ||
2379 ' PF: ' || l_process_flag || ' EA: ' || l_earnings_amount || ' ED: ' || TO_CHAR(l_effective_date, 'DD-MON-RRRR') ||
2380 ' BD: ' || l_bus_days_in_chunk);
2381
2382 hr_utility.trace('l_chunk_pointer: ' || fnd_number.number_to_canonical(l_chunk_pointer) ||
2383 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
2384 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
2385 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
2386 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
2387 ' l_effective_date: ' || fnd_date.date_to_canonical(l_effective_date) ||
2388 ' l_time_period_id: ' || fnd_number.number_to_canonical(l_time_period_id) ||
2389 ' l_prev_time_period_id: ' || fnd_number.number_to_canonical(l_prev_time_period_id) ||
2390 ' l_process_flag: ' || l_process_flag ||
2391 ' l_earnings_amount: ' || fnd_number.number_to_canonical(l_earnings_amount) ||
2392 ' r_enc_period.r_period_amount(l_chunk_pointer): ' || fnd_number.number_to_canonical(r_enc_period.r_period_amount(l_chunk_pointer)) ||
2393 ' l_period_ind: ' || fnd_number.number_to_canonical(l_period_ind) ||
2394 ' g_enc_lines_counter: ' || fnd_number.number_to_canonical(g_enc_lines_counter));
2395
2396 l_proc_step := 70 + (l_chunk_pointer / 100000);
2397
2398 IF (l_earnings_amount <> 0) AND (l_bus_days_in_chunk > 0) THEN
2399 IF (l_process_flag = 'ET') THEN
2400 FOR recno IN 1..r_et.line_account_id.COUNT
2401 LOOP
2402 IF ((l_asg_start_date <= r_et.end_date_active(recno))
2403 AND (l_asg_end_date >= r_et.start_date_active(recno))) THEN
2404 g_et_pointer := recno;
2405 l_schedule_line_id := r_et.line_account_id(recno);
2406 l_gl_code_combination_id := r_et.gl_code_combination_id(recno);
2407 l_project_id := r_et.project_id(recno);
2408 l_task_id := r_et.task_id(recno);
2409 l_award_id := r_et.award_id(recno);
2410 l_schedule_percent := r_et.percent(recno);
2411 l_expenditure_type := r_et.expenditure_type(recno);
2412 l_expenditure_org_id := r_et.expenditure_organization_id(recno);
2413 l_start_date_active := r_et.start_date_active(recno);
2414 l_end_date_active := r_et.end_date_active(recno);
2415 l_poeta_start_date := r_et.poeta_start_date(recno);
2416 l_poeta_end_date := r_et.poeta_end_date(recno);
2417 l_attribute_category := r_et.attribute_category(recno);
2418 l_attribute1 := r_et.attribute1(recno);
2419 l_attribute2 := r_et.attribute2(recno);
2420 l_attribute3 := r_et.attribute3(recno);
2421 l_attribute4 := r_et.attribute4(recno);
2422 l_attribute5 := r_et.attribute5(recno);
2423 l_attribute6 := r_et.attribute6(recno);
2424 l_attribute7 := r_et.attribute7(recno);
2425 l_attribute8 := r_et.attribute8(recno);
2426 l_attribute9 := r_et.attribute9(recno);
2427 l_attribute10 := r_et.attribute10(recno);
2428 l_acct_type := r_et.acct_type(recno);
2429
2430 IF (g_uom = 'H' AND l_gl_code_combination_id IS NOT NULL) THEN
2431 log_gl_hours_message;
2432 ELSE
2433
2434 IF (g_et_autopop = 'Y') THEN
2435 psp_autopop.main(p_acct_type => l_acct_type,
2436 p_person_id => l_person_id,
2437 p_assignment_id => p_assignment_id,
2438 p_element_type_id => p_element_type_id,
2439 p_project_id => l_project_id,
2440 p_expenditure_organization_id => l_expenditure_org_id,
2441 p_task_id => l_task_id,
2442 p_award_id => l_award_id,
2443 p_expenditure_type => l_expenditure_type,
2444 p_gl_code_combination_id => l_gl_code_combination_id,
2445 p_payroll_date => l_asg_end_date, --- replaced l_effective_date..5592784
2446 p_set_of_books_id => g_set_of_books_id,
2447 p_business_group_id => g_business_group_id,
2448 ret_expenditure_type => l_new_expenditure_type,
2449 ret_gl_code_combination_id => l_new_gl_code_combination_id,
2450 retcode => l_autopop_status);
2451
2452 IF (l_autopop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
2453 (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2454 l_autopop_error := 'AUTO_POP_EXP_ERROR';
2455 IF (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2456 l_autopop_error := 'AUTO_POP_NO_VALUE';
2457 END IF;
2458 IF (l_asg_start_date <= g_enc_org_end_date) THEN
2459 orig_ci.gl_code_combination_id(g_orig_pointer) := l_gl_code_combination_id;
2460 orig_ci.project_id(g_orig_pointer) := l_project_id;
2461 orig_ci.task_id(g_orig_pointer) := l_task_id;
2462 orig_ci.award_id(g_orig_pointer) := l_award_id;
2463 orig_ci.expenditure_organization_id(g_orig_pointer) := l_expenditure_org_id;
2464 orig_ci.expenditure_type(g_orig_pointer) := l_expenditure_type;
2465 g_orig_pointer := g_orig_pointer + 1;
2466 l_enc_period_count := r_enc_period.r_time_period_id.COUNT + 1;
2467 r_enc_period.r_period_ind(l_enc_period_count) := r_enc_period.r_period_ind(l_chunk_pointer);
2468 r_enc_period.r_period_start_date(l_enc_period_count) := r_enc_period.r_period_start_date(l_chunk_pointer);
2469 r_enc_period.r_period_end_date(l_enc_period_count) := r_enc_period.r_period_end_date(l_chunk_pointer);
2470 r_enc_period.r_asg_start_date(l_enc_period_count) := r_enc_period.r_asg_start_date(l_chunk_pointer);
2471 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);
2472 r_enc_period.r_effective_date(l_enc_period_count) := r_enc_period.r_effective_date(l_chunk_pointer);
2473 r_enc_period.r_time_period_id(l_enc_period_count) := r_enc_period.r_time_period_id(l_chunk_pointer);
2474 r_enc_period.r_process_flag(l_enc_period_count) := 'SA';
2475 r_enc_period.r_schedule_percent(l_enc_period_count) := 100;
2476 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND(r_enc_period.r_encumbrance_amount(l_chunk_pointer) *
2477 (psp_general.business_days(l_asg_start_date, r_enc_period.r_asg_end_date(l_enc_period_count)) / l_bus_days_in_chunk));
2478 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);
2479 r_enc_period.r_period_amount(l_enc_period_count) := r_enc_period.r_period_amount(l_chunk_pointer);
2480 r_enc_period.r_reason_code(l_enc_period_count) := l_autopop_error;
2481 END IF;
2482 add_cel_warnings(p_start_date => r_enc_period.r_asg_start_date(l_chunk_pointer),
2483 p_hierarchy_code => 'SA',
2484 p_end_date => r_enc_period.r_asg_end_date(l_chunk_pointer),
2485 p_warning_code => 'AUTOPOP',
2486 p_gl_ccid => l_gl_code_combination_id,
2487 p_project_id => l_project_id,
2488 p_task_id => l_task_id,
2489 p_award_id => l_award_id,
2490 p_exp_org_id => l_expenditure_org_id,
2491 p_exp_type => l_expenditure_type,
2492 p_effective_date => l_effective_date,
2493 p_error_status => l_autopop_error);
2494 hr_utility.trace('Posting to suspense account');
2495 ELSE
2496 IF (l_acct_type = 'E') THEN
2497 psp_enc_pre_process.validate_poeta (p_project_id => l_project_id,
2498 p_task_id => l_task_id,
2499 p_award_id => l_award_id,
2500 p_expenditure_type => l_new_expenditure_type,
2501 p_expenditure_organization_id => l_expenditure_org_id,
2502 p_payroll_id => p_payroll_id,
2503 p_start_date => l_poeta_start_date,
2504 p_end_date => l_poeta_end_date,
2505 p_return_status => p_return_status);
2506 IF p_return_status <> fnd_api.g_ret_sts_success THEN
2507 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2508 END IF;
2509 l_expenditure_type := l_new_expenditure_type;
2510 ELSE
2511 l_gl_code_combination_id := l_new_gl_code_combination_id;
2512 END IF;
2513 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2514 END IF;
2515 ELSE
2516 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2517 END IF;
2518 END IF;
2519 END IF;
2520 END LOOP;
2521 ELSIF (l_process_flag = 'EG') THEN
2522 FOR recno IN 1..r_ec.line_account_id.COUNT
2523 LOOP
2524 IF ((l_asg_start_date <= r_ec.end_date_active(recno))
2525 AND (l_asg_end_date >= r_ec.start_date_active(recno))) THEN
2526 g_ec_pointer := recno;
2527 l_schedule_line_id := r_ec.line_account_id(recno);
2528 l_gl_code_combination_id := r_ec.gl_code_combination_id(recno);
2529 l_project_id := r_ec.project_id(recno);
2530 l_task_id := r_ec.task_id(recno);
2531 l_award_id := r_ec.award_id(recno);
2532 l_schedule_percent := r_ec.percent(recno);
2533 l_expenditure_type := r_ec.expenditure_type(recno);
2534 l_expenditure_org_id := r_ec.expenditure_organization_id(recno);
2535 l_start_date_active := r_ec.start_date_active(recno);
2536 l_end_date_active := r_ec.end_date_active(recno);
2537 l_poeta_start_date := r_ec.poeta_start_date(recno);
2538 l_poeta_end_date := r_ec.poeta_end_date(recno);
2539 l_attribute_category := r_ec.attribute_category(recno);
2540 l_attribute1 := r_ec.attribute1(recno);
2541 l_attribute2 := r_ec.attribute2(recno);
2542 l_attribute3 := r_ec.attribute3(recno);
2543 l_attribute4 := r_ec.attribute4(recno);
2544 l_attribute5 := r_ec.attribute5(recno);
2545 l_attribute6 := r_ec.attribute6(recno);
2546 l_attribute7 := r_ec.attribute7(recno);
2547 l_attribute8 := r_ec.attribute8(recno);
2548 l_attribute9 := r_ec.attribute9(recno);
2549 l_attribute10 := r_ec.attribute10(recno);
2550 l_acct_type := r_ec.acct_type(recno);
2551
2552 IF (g_uom = 'H' AND l_gl_code_combination_id IS NOT NULL) THEN
2553 log_gl_hours_message;
2554 ELSE
2555 IF (g_eg_autopop = 'Y') THEN
2556 psp_autopop.main(p_acct_type => l_acct_type,
2557 p_person_id => l_person_id,
2558 p_assignment_id => p_assignment_id,
2559 p_element_type_id => p_element_type_id,
2560 p_project_id => l_project_id,
2561 p_expenditure_organization_id => l_expenditure_org_id,
2562 p_task_id => l_task_id,
2563 p_award_id => l_award_id,
2564 p_expenditure_type => l_expenditure_type,
2565 p_gl_code_combination_id => l_gl_code_combination_id,
2566 p_payroll_date => l_asg_end_date, --- replaced l_effective_date..5592784
2567 p_set_of_books_id => g_set_of_books_id,
2568 p_business_group_id => g_business_group_id,
2569 ret_expenditure_type => l_new_expenditure_type,
2570 ret_gl_code_combination_id => l_new_gl_code_combination_id,
2571 retcode => l_autopop_status);
2572
2573 IF (l_autopop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
2574 (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2575 l_autopop_error := 'AUTO_POP_EXP_ERROR';
2576 IF (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2577 l_autopop_error := 'AUTO_POP_NO_VALUE';
2578 END IF;
2579 IF (l_asg_start_date <= g_enc_org_end_date) THEN
2580 orig_ci.gl_code_combination_id(g_orig_pointer) := l_gl_code_combination_id;
2581 orig_ci.project_id(g_orig_pointer) := l_project_id;
2582 orig_ci.task_id(g_orig_pointer) := l_task_id;
2583 orig_ci.award_id(g_orig_pointer) := l_award_id;
2584 orig_ci.expenditure_organization_id(g_orig_pointer) := l_expenditure_org_id;
2585 orig_ci.expenditure_type(g_orig_pointer) := l_expenditure_type;
2586 g_orig_pointer := g_orig_pointer + 1;
2587 l_enc_period_count := r_enc_period.r_time_period_id.COUNT + 1;
2588 r_enc_period.r_period_ind(l_enc_period_count) := r_enc_period.r_period_ind(l_chunk_pointer);
2589 r_enc_period.r_period_start_date(l_enc_period_count) := r_enc_period.r_period_start_date(l_chunk_pointer);
2590 r_enc_period.r_period_end_date(l_enc_period_count) := r_enc_period.r_period_end_date(l_chunk_pointer);
2591 r_enc_period.r_asg_start_date(l_enc_period_count) := r_enc_period.r_asg_start_date(l_chunk_pointer);
2592 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);
2593 r_enc_period.r_effective_date(l_enc_period_count) := r_enc_period.r_effective_date(l_chunk_pointer);
2594 r_enc_period.r_time_period_id(l_enc_period_count) := r_enc_period.r_time_period_id(l_chunk_pointer);
2595 r_enc_period.r_process_flag(l_enc_period_count) := 'SA';
2596 r_enc_period.r_schedule_percent(l_enc_period_count) := 100;
2597 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND(r_enc_period.r_encumbrance_amount(l_chunk_pointer) *
2598 (psp_general.business_days(l_asg_start_date, r_enc_period.r_asg_end_date(l_enc_period_count)) / l_bus_days_in_chunk));
2599 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);
2600 r_enc_period.r_period_amount(l_enc_period_count) := r_enc_period.r_period_amount(l_chunk_pointer);
2601 r_enc_period.r_reason_code(l_enc_period_count) := l_autopop_error;
2602 END IF;
2603 add_cel_warnings(p_start_date => r_enc_period.r_asg_start_date(l_chunk_pointer),
2604 p_hierarchy_code => 'SA',
2605 p_end_date => r_enc_period.r_asg_end_date(l_chunk_pointer),
2606 p_warning_code => 'AUTOPOP',
2607 p_gl_ccid => l_gl_code_combination_id,
2608 p_project_id => l_project_id,
2609 p_task_id => l_task_id,
2610 p_award_id => l_award_id,
2611 p_exp_org_id => l_expenditure_org_id,
2612 p_exp_type => l_expenditure_type,
2613 p_effective_date => l_effective_date,
2614 p_error_status => l_autopop_error);
2615 hr_utility.trace('Posting to suspense account');
2616 ELSE
2617 IF (l_acct_type = 'E') THEN
2618 psp_enc_pre_process.validate_poeta (p_project_id => l_project_id,
2619 p_task_id => l_task_id,
2620 p_award_id => l_award_id,
2621 p_expenditure_type => l_new_expenditure_type,
2622 p_expenditure_organization_id => l_expenditure_org_id,
2623 p_payroll_id => p_payroll_id,
2624 p_start_date => l_poeta_start_date,
2625 p_end_date => l_poeta_end_date,
2626 p_return_status => p_return_status);
2627 IF p_return_status <> fnd_api.g_ret_sts_success THEN
2628 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2629 END IF;
2630 l_expenditure_type := l_new_expenditure_type;
2631 ELSE
2632 l_gl_code_combination_id := l_new_gl_code_combination_id;
2633 END IF;
2634 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2635 END IF;
2636 ELSE
2637 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2638 END IF;
2639 END IF;
2640 END IF;
2641 END LOOP;
2642 ELSIF (l_process_flag = 'A') THEN
2643 FOR recno IN 1..r_asg.line_account_id.COUNT
2644 LOOP
2645 IF ((l_asg_start_date <= r_asg.end_date_active(recno))
2646 AND (l_asg_end_date >= r_asg.start_date_active(recno))) THEN
2647 g_asg_pointer := recno;
2648 l_schedule_line_id := r_asg.line_account_id(recno);
2649 l_gl_code_combination_id := r_asg.gl_code_combination_id(recno);
2650 l_project_id := r_asg.project_id(recno);
2651 l_task_id := r_asg.task_id(recno);
2652 l_award_id := r_asg.award_id(recno);
2653 l_schedule_percent := r_asg.percent(recno);
2654 l_expenditure_type := r_asg.expenditure_type(recno);
2655 l_expenditure_org_id := r_asg.expenditure_organization_id(recno);
2656 l_start_date_active := r_asg.start_date_active(recno);
2657 l_end_date_active := r_asg.end_date_active(recno);
2658 l_poeta_start_date := r_asg.poeta_start_date(recno);
2659 l_poeta_end_date := r_asg.poeta_end_date(recno);
2660 l_attribute_category := r_asg.attribute_category(recno);
2661 l_attribute1 := r_asg.attribute1(recno);
2662 l_attribute2 := r_asg.attribute2(recno);
2663 l_attribute3 := r_asg.attribute3(recno);
2664 l_attribute4 := r_asg.attribute4(recno);
2665 l_attribute5 := r_asg.attribute5(recno);
2666 l_attribute6 := r_asg.attribute6(recno);
2667 l_attribute7 := r_asg.attribute7(recno);
2668 l_attribute8 := r_asg.attribute8(recno);
2669 l_attribute9 := r_asg.attribute9(recno);
2670 l_attribute10 := r_asg.attribute10(recno);
2671 l_acct_type := r_asg.acct_type(recno);
2672
2673 IF (g_uom = 'H' AND l_gl_code_combination_id IS NOT NULL) THEN
2674 log_gl_hours_message;
2675 ELSE
2676 IF (g_as_autopop = 'Y') THEN
2677 psp_autopop.main(p_acct_type => l_acct_type,
2678 p_person_id => l_person_id,
2679 p_assignment_id => p_assignment_id,
2680 p_element_type_id => p_element_type_id,
2681 p_project_id => l_project_id,
2682 p_expenditure_organization_id => l_expenditure_org_id,
2683 p_task_id => l_task_id,
2684 p_award_id => l_award_id,
2685 p_expenditure_type => l_expenditure_type,
2686 p_gl_code_combination_id => l_gl_code_combination_id,
2687 p_payroll_date => l_asg_end_date, --- replaced l_effective_date..5592784
2688 p_set_of_books_id => g_set_of_books_id,
2689 p_business_group_id => g_business_group_id,
2690 ret_expenditure_type => l_new_expenditure_type,
2691 ret_gl_code_combination_id => l_new_gl_code_combination_id,
2692 retcode => l_autopop_status);
2693
2694 IF (l_autopop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
2695 (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2696 l_autopop_error := 'AUTO_POP_EXP_ERROR';
2697 IF (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2698 l_autopop_error := 'AUTO_POP_NO_VALUE';
2699 END IF;
2700 IF (l_asg_start_date <= g_enc_org_end_date) THEN
2701 orig_ci.gl_code_combination_id(g_orig_pointer) := l_gl_code_combination_id;
2702 orig_ci.project_id(g_orig_pointer) := l_project_id;
2703 orig_ci.task_id(g_orig_pointer) := l_task_id;
2704 orig_ci.award_id(g_orig_pointer) := l_award_id;
2705 orig_ci.expenditure_organization_id(g_orig_pointer) := l_expenditure_org_id;
2706 orig_ci.expenditure_type(g_orig_pointer) := l_expenditure_type;
2707 g_orig_pointer := g_orig_pointer + 1;
2708 l_enc_period_count := r_enc_period.r_time_period_id.COUNT + 1;
2709 r_enc_period.r_period_ind(l_enc_period_count) := r_enc_period.r_period_ind(l_chunk_pointer);
2710 r_enc_period.r_period_start_date(l_enc_period_count) := r_enc_period.r_period_start_date(l_chunk_pointer);
2711 r_enc_period.r_period_end_date(l_enc_period_count) := r_enc_period.r_period_end_date(l_chunk_pointer);
2712 r_enc_period.r_asg_start_date(l_enc_period_count) := r_enc_period.r_asg_start_date(l_chunk_pointer);
2713 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);
2714 r_enc_period.r_effective_date(l_enc_period_count) := r_enc_period.r_effective_date(l_chunk_pointer);
2715 r_enc_period.r_time_period_id(l_enc_period_count) := r_enc_period.r_time_period_id(l_chunk_pointer);
2716 r_enc_period.r_process_flag(l_enc_period_count) := 'SA';
2717 r_enc_period.r_schedule_percent(l_enc_period_count) := 100;
2718 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND(r_enc_period.r_encumbrance_amount(l_chunk_pointer) *
2719 (psp_general.business_days(l_asg_start_date, r_enc_period.r_asg_end_date(l_enc_period_count)) / l_bus_days_in_chunk));
2720 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);
2721 r_enc_period.r_period_amount(l_enc_period_count) := r_enc_period.r_period_amount(l_chunk_pointer);
2722 r_enc_period.r_reason_code(l_enc_period_count) := l_autopop_error;
2723 END IF;
2724 add_cel_warnings(p_start_date => r_enc_period.r_asg_start_date(l_chunk_pointer),
2725 p_hierarchy_code => 'SA',
2726 p_end_date => r_enc_period.r_asg_end_date(l_chunk_pointer),
2727 p_warning_code => 'AUTOPOP',
2728 p_gl_ccid => l_gl_code_combination_id,
2729 p_project_id => l_project_id,
2730 p_task_id => l_task_id,
2731 p_award_id => l_award_id,
2732 p_exp_org_id => l_expenditure_org_id,
2733 p_exp_type => l_expenditure_type,
2734 p_effective_date => l_effective_date,
2735 p_error_status => l_autopop_error);
2736 hr_utility.trace('Posting to suspense account');
2737 ELSE
2738 IF (l_acct_type = 'E') THEN
2739 psp_enc_pre_process.validate_poeta (p_project_id => l_project_id,
2740 p_task_id => l_task_id,
2741 p_award_id => l_award_id,
2742 p_expenditure_type => l_new_expenditure_type,
2743 p_expenditure_organization_id => l_expenditure_org_id,
2744 p_payroll_id => p_payroll_id,
2745 p_start_date => l_poeta_start_date,
2746 p_end_date => l_poeta_end_date,
2747 p_return_status => p_return_status);
2748 IF p_return_status <> fnd_api.g_ret_sts_success THEN
2749 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2750 END IF;
2751 l_expenditure_type := l_new_expenditure_type;
2752 ELSE
2753 l_gl_code_combination_id := l_new_gl_code_combination_id;
2754 END IF;
2755 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2756 END IF;
2757 ELSE
2758 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2759 END IF;
2760 END IF;
2761 End IF;
2762 END LOOP;
2763 ELSIF (l_process_flag = 'GE') THEN
2764 FOR recno IN 1..r_gee.line_account_id.COUNT
2765 LOOP
2766 g_ge_pointer := recno;
2767 EXIT WHEN ((l_asg_start_date <= r_gee.end_date_active(recno))
2768 AND (l_asg_end_date >= r_gee.start_date_active(recno)));
2769 END LOOP;
2770 FOR recno IN g_ge_pointer..r_gee.line_account_id.COUNT
2771 LOOP
2772 EXIT WHEN (NOT ((l_asg_start_date <= r_gee.end_date_active(recno))
2773 AND (l_asg_end_date >= r_gee.start_date_active(recno))));
2774
2775 g_ge_pointer := recno;
2776 l_element_account_id := r_gee.line_account_id(recno);
2777 l_gl_code_combination_id := r_gee.gl_code_combination_id(recno);
2778 l_project_id := r_gee.project_id(recno);
2779 l_task_id := r_gee.task_id(recno);
2780 l_award_id := r_gee.award_id(recno);
2781 l_schedule_percent := r_gee.percent(recno);
2782 l_expenditure_type := r_gee.expenditure_type(recno);
2783 l_expenditure_org_id := r_gee.expenditure_organization_id(recno);
2784 l_start_date_active := r_gee.start_date_active(recno);
2785 l_end_date_active := r_gee.end_date_active(recno);
2786 l_poeta_start_date := r_gee.poeta_start_date(recno);
2787 l_poeta_end_date := r_gee.poeta_end_date(recno);
2788 l_attribute_category := r_gee.attribute_category(recno);
2789 l_attribute1 := r_gee.attribute1(recno);
2790 l_attribute2 := r_gee.attribute2(recno);
2791 l_attribute3 := r_gee.attribute3(recno);
2792 l_attribute4 := r_gee.attribute4(recno);
2793 l_attribute5 := r_gee.attribute5(recno);
2794 l_attribute6 := r_gee.attribute6(recno);
2795 l_attribute7 := r_gee.attribute7(recno);
2796 l_attribute8 := r_gee.attribute8(recno);
2797 l_attribute9 := r_gee.attribute9(recno);
2798 l_attribute10 := r_gee.attribute10(recno);
2799 l_acct_type := r_gee.acct_type(recno);
2800
2801 IF (g_uom = 'H' AND l_gl_code_combination_id IS NOT NULL) THEN
2802 log_gl_hours_message;
2803 ELSE
2804
2805 IF (g_ge_autopop = 'Y') THEN
2806 psp_autopop.main(p_acct_type => l_acct_type,
2807 p_person_id => l_person_id,
2808 p_assignment_id => p_assignment_id,
2809 p_element_type_id => p_element_type_id,
2810 p_project_id => l_project_id,
2811 p_expenditure_organization_id => l_expenditure_org_id,
2812 p_task_id => l_task_id,
2813 p_award_id => l_award_id,
2814 p_expenditure_type => l_expenditure_type,
2815 p_gl_code_combination_id => l_gl_code_combination_id,
2816 p_payroll_date => l_asg_end_date, --- replaced l_effective_date..5592784
2817 p_set_of_books_id => g_set_of_books_id,
2818 p_business_group_id => g_business_group_id,
2819 ret_expenditure_type => l_new_expenditure_type,
2820 ret_gl_code_combination_id => l_new_gl_code_combination_id,
2821 retcode => l_autopop_status);
2822
2823 IF (l_autopop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
2824 (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2825 l_autopop_error := 'AUTO_POP_EXP_ERROR';
2826 IF (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2827 l_autopop_error := 'AUTO_POP_NO_VALUE';
2828 END IF;
2829 IF (l_asg_start_date <= g_enc_org_end_date) THEN
2830 orig_ci.gl_code_combination_id(g_orig_pointer) := l_gl_code_combination_id;
2831 orig_ci.project_id(g_orig_pointer) := l_project_id;
2832 orig_ci.task_id(g_orig_pointer) := l_task_id;
2833 orig_ci.award_id(g_orig_pointer) := l_award_id;
2834 orig_ci.expenditure_organization_id(g_orig_pointer) := l_expenditure_org_id;
2835 orig_ci.expenditure_type(g_orig_pointer) := l_expenditure_type;
2836 g_orig_pointer := g_orig_pointer + 1;
2837 l_enc_period_count := r_enc_period.r_time_period_id.COUNT + 1;
2838 r_enc_period.r_period_ind(l_enc_period_count) := r_enc_period.r_period_ind(l_chunk_pointer);
2839 r_enc_period.r_period_start_date(l_enc_period_count) := r_enc_period.r_period_start_date(l_chunk_pointer);
2840 r_enc_period.r_period_end_date(l_enc_period_count) := r_enc_period.r_period_end_date(l_chunk_pointer);
2841 r_enc_period.r_asg_start_date(l_enc_period_count) := r_enc_period.r_asg_start_date(l_chunk_pointer);
2842 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);
2843 r_enc_period.r_effective_date(l_enc_period_count) := r_enc_period.r_effective_date(l_chunk_pointer);
2844 r_enc_period.r_time_period_id(l_enc_period_count) := r_enc_period.r_time_period_id(l_chunk_pointer);
2845 r_enc_period.r_process_flag(l_enc_period_count) := 'SA';
2846 r_enc_period.r_schedule_percent(l_enc_period_count) := 100;
2847 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND(r_enc_period.r_encumbrance_amount(l_chunk_pointer) *
2848 (psp_general.business_days(l_asg_start_date, r_enc_period.r_asg_end_date(l_enc_period_count)) / l_bus_days_in_chunk));
2849 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);
2850 r_enc_period.r_period_amount(l_enc_period_count) := r_enc_period.r_period_amount(l_chunk_pointer);
2851 r_enc_period.r_reason_code(l_enc_period_count) := l_autopop_error;
2852 END IF;
2853 add_cel_warnings(p_start_date => r_enc_period.r_asg_start_date(l_chunk_pointer),
2854 p_hierarchy_code => 'SA',
2855 p_end_date => r_enc_period.r_asg_end_date(l_chunk_pointer),
2856 p_warning_code => 'AUTOPOP',
2857 p_gl_ccid => l_gl_code_combination_id,
2858 p_project_id => l_project_id,
2859 p_task_id => l_task_id,
2860 p_award_id => l_award_id,
2861 p_exp_org_id => l_expenditure_org_id,
2862 p_exp_type => l_expenditure_type,
2863 p_effective_date => l_effective_date,
2864 p_error_status => l_autopop_error);
2865 hr_utility.trace('Posting to suspense account');
2866 ELSE
2867 IF (l_acct_type = 'E') THEN
2868 psp_enc_pre_process.validate_poeta (p_project_id => l_project_id,
2869 p_task_id => l_task_id,
2870 p_award_id => l_award_id,
2871 p_expenditure_type => l_new_expenditure_type,
2872 p_expenditure_organization_id => l_expenditure_org_id,
2873 p_payroll_id => p_payroll_id,
2874 p_start_date => l_poeta_start_date,
2875 p_end_date => l_poeta_end_date,
2876 p_return_status => p_return_status);
2877 IF p_return_status <> fnd_api.g_ret_sts_success THEN
2878 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2879 END IF;
2880 l_expenditure_type := l_new_expenditure_type;
2881 ELSE
2882 l_gl_code_combination_id := l_new_gl_code_combination_id;
2883 END IF;
2884 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2885 END IF;
2886 ELSE
2887 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
2888 END IF;
2889 END IF;
2890 END LOOP;
2891 ELSIF (l_process_flag = 'DS') THEN
2892 FOR recno IN 1..r_odls.line_account_id.COUNT
2893 LOOP
2894 g_odls_pointer := recno;
2895 EXIT WHEN ((l_asg_start_date <= r_odls.end_date_active(recno))
2896 AND (l_asg_end_date >= r_odls.start_date_active(recno)));
2897 END LOOP;
2898 FOR recno IN g_odls_pointer..r_odls.line_account_id.COUNT
2899 LOOP
2900 EXIT WHEN (NOT ((l_asg_start_date <= r_odls.end_date_active(recno))
2901 AND (l_asg_end_date >= r_odls.start_date_active(recno))));
2902
2903 g_odls_pointer := recno;
2904 l_org_schedule_id := r_odls.line_account_id(recno);
2905 l_gl_code_combination_id := r_odls.gl_code_combination_id(recno);
2906 l_project_id := r_odls.project_id(recno);
2907 l_task_id := r_odls.task_id(recno);
2908 l_award_id := r_odls.award_id(recno);
2909 l_schedule_percent := r_odls.percent(recno);
2910 l_expenditure_type := r_odls.expenditure_type(recno);
2911 l_expenditure_org_id := r_odls.expenditure_organization_id(recno);
2912 l_start_date_active := r_odls.start_date_active(recno);
2913 l_end_date_active := r_odls.end_date_active(recno);
2914 l_poeta_start_date := r_odls.poeta_start_date(recno);
2915 l_poeta_end_date := r_odls.poeta_end_date(recno);
2916 l_attribute_category := r_odls.attribute_category(recno);
2917 l_attribute1 := r_odls.attribute1(recno);
2918 l_attribute2 := r_odls.attribute2(recno);
2919 l_attribute3 := r_odls.attribute3(recno);
2920 l_attribute4 := r_odls.attribute4(recno);
2921 l_attribute5 := r_odls.attribute5(recno);
2922 l_attribute6 := r_odls.attribute6(recno);
2923 l_attribute7 := r_odls.attribute7(recno);
2924 l_attribute8 := r_odls.attribute8(recno);
2925 l_attribute9 := r_odls.attribute9(recno);
2926 l_attribute10 := r_odls.attribute10(recno);
2927 l_acct_type := r_odls.acct_type(recno);
2928
2929 IF (g_uom = 'H' AND l_gl_code_combination_id IS NOT NULL) THEN
2930 log_gl_hours_message;
2931 ELSE
2932 IF (g_ds_autopop = 'Y') THEN
2933 psp_autopop.main(p_acct_type => l_acct_type,
2934 p_person_id => l_person_id,
2935 p_assignment_id => p_assignment_id,
2936 p_element_type_id => p_element_type_id,
2937 p_project_id => l_project_id,
2938 p_expenditure_organization_id => l_expenditure_org_id,
2939 p_task_id => l_task_id,
2940 p_award_id => l_award_id,
2941 p_expenditure_type => l_expenditure_type,
2942 p_gl_code_combination_id => l_gl_code_combination_id,
2943 p_payroll_date => l_asg_end_date, --- replaced l_effective_date..5592784
2944 p_set_of_books_id => g_set_of_books_id,
2945 p_business_group_id => g_business_group_id,
2946 ret_expenditure_type => l_new_expenditure_type,
2947 ret_gl_code_combination_id => l_new_gl_code_combination_id,
2948 retcode => l_autopop_status);
2949
2950 IF (l_autopop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
2951 (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2952 l_autopop_error := 'AUTO_POP_EXP_ERROR';
2953 IF (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
2954 l_autopop_error := 'AUTO_POP_NO_VALUE';
2955 END IF;
2956 IF (l_asg_start_date <= g_enc_org_end_date) THEN
2957 orig_ci.gl_code_combination_id(g_orig_pointer) := l_gl_code_combination_id;
2958 orig_ci.project_id(g_orig_pointer) := l_project_id;
2959 orig_ci.task_id(g_orig_pointer) := l_task_id;
2960 orig_ci.award_id(g_orig_pointer) := l_award_id;
2961 orig_ci.expenditure_organization_id(g_orig_pointer) := l_expenditure_org_id;
2962 orig_ci.expenditure_type(g_orig_pointer) := l_expenditure_type;
2963 g_orig_pointer := g_orig_pointer + 1;
2964 l_enc_period_count := r_enc_period.r_time_period_id.COUNT + 1;
2965 r_enc_period.r_period_ind(l_enc_period_count) := r_enc_period.r_period_ind(l_chunk_pointer);
2966 r_enc_period.r_period_start_date(l_enc_period_count) := r_enc_period.r_period_start_date(l_chunk_pointer);
2967 r_enc_period.r_period_end_date(l_enc_period_count) := r_enc_period.r_period_end_date(l_chunk_pointer);
2968 r_enc_period.r_asg_start_date(l_enc_period_count) := r_enc_period.r_asg_start_date(l_chunk_pointer);
2969 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);
2970 r_enc_period.r_effective_date(l_enc_period_count) := r_enc_period.r_effective_date(l_chunk_pointer);
2971 r_enc_period.r_time_period_id(l_enc_period_count) := r_enc_period.r_time_period_id(l_chunk_pointer);
2972 r_enc_period.r_process_flag(l_enc_period_count) := 'SA';
2973 r_enc_period.r_schedule_percent(l_enc_period_count) := 100;
2974 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND(r_enc_period.r_encumbrance_amount(l_chunk_pointer) *
2975 (psp_general.business_days(l_asg_start_date, r_enc_period.r_asg_end_date(l_enc_period_count)) / l_bus_days_in_chunk));
2976 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);
2977 r_enc_period.r_period_amount(l_enc_period_count) := r_enc_period.r_period_amount(l_chunk_pointer);
2978 r_enc_period.r_reason_code(l_enc_period_count) := l_autopop_error;
2979 END IF;
2980 add_cel_warnings(p_start_date => r_enc_period.r_asg_start_date(l_chunk_pointer),
2981 p_hierarchy_code => 'SA',
2982 p_end_date => r_enc_period.r_asg_end_date(l_chunk_pointer),
2983 p_warning_code => 'AUTOPOP',
2984 p_gl_ccid => l_gl_code_combination_id,
2985 p_project_id => l_project_id,
2986 p_task_id => l_task_id,
2987 p_award_id => l_award_id,
2988 p_exp_org_id => l_expenditure_org_id,
2989 p_exp_type => l_expenditure_type,
2990 p_effective_date => l_effective_date,
2991 p_error_status => l_autopop_error);
2992 hr_utility.trace('Posting to suspense account');
2993 ELSE
2994 IF (l_acct_type = 'E') THEN
2995 psp_enc_pre_process.validate_poeta (p_project_id => l_project_id,
2996 p_task_id => l_task_id,
2997 p_award_id => l_award_id,
2998 p_expenditure_type => l_new_expenditure_type,
2999 p_expenditure_organization_id => l_expenditure_org_id,
3000 p_payroll_id => p_payroll_id,
3001 p_start_date => l_poeta_start_date,
3002 p_end_date => l_poeta_end_date,
3003 p_return_status => p_return_status);
3004 IF p_return_status <> fnd_api.g_ret_sts_success THEN
3005 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3006 END IF;
3007 l_expenditure_type := l_new_expenditure_type;
3008 ELSE
3009 l_gl_code_combination_id := l_new_gl_code_combination_id;
3010 END IF;
3011 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
3012 END IF;
3013 ELSE
3014 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
3015 END IF;
3016 END IF;
3017 END LOOP;
3018 ELSIF (l_process_flag = 'DA') THEN
3019 FOR recno IN 1..r_da.line_account_id.COUNT
3020 LOOP
3021 g_da_pointer := recno;
3022 EXIT WHEN ((l_asg_start_date <= r_da.end_date_active(recno))
3023 AND (l_asg_end_date >= r_da.start_date_active(recno)));
3024 END LOOP;
3025
3026 FOR recno IN g_da_pointer..r_da.line_account_id.COUNT
3027 LOOP
3028 EXIT WHEN (NOT ((l_asg_start_date <= r_da.end_date_active(recno))
3029 AND (l_asg_end_date >= r_da.start_date_active(recno))));
3030
3031 g_da_pointer := recno;
3032 l_default_account_id := r_da.line_account_id(recno);
3033 l_gl_code_combination_id := r_da.gl_code_combination_id(recno);
3034 l_project_id := r_da.project_id(recno);
3035 l_task_id := r_da.task_id(recno);
3036 l_award_id := r_da.award_id(recno);
3037 l_schedule_percent := r_da.percent(recno);
3038 l_expenditure_type := r_da.expenditure_type(recno);
3039 l_expenditure_org_id := r_da.expenditure_organization_id(recno);
3040 l_start_date_active := r_da.start_date_active(recno);
3041 l_end_date_active := r_da.end_date_active(recno);
3042 l_poeta_start_date := r_da.poeta_start_date(recno);
3043 l_poeta_end_date := r_da.poeta_end_date(recno);
3044 l_attribute_category := r_da.attribute_category(recno);
3045 l_attribute1 := r_da.attribute1(recno);
3046 l_attribute2 := r_da.attribute2(recno);
3047 l_attribute3 := r_da.attribute3(recno);
3048 l_attribute4 := r_da.attribute4(recno);
3049 l_attribute5 := r_da.attribute5(recno);
3050 l_attribute6 := r_da.attribute6(recno);
3051 l_attribute7 := r_da.attribute7(recno);
3052 l_attribute8 := r_da.attribute8(recno);
3053 l_attribute9 := r_da.attribute9(recno);
3054 l_attribute10 := r_da.attribute10(recno);
3055 l_acct_type := r_da.acct_type(recno);
3056
3057 IF (g_uom = 'H' AND l_gl_code_combination_id IS NOT NULL) THEN
3058 log_gl_hours_message;
3059 ELSE
3060
3061 IF (g_da_autopop = 'Y') THEN
3062 psp_autopop.main(p_acct_type => l_acct_type,
3063 p_person_id => l_person_id,
3064 p_assignment_id => p_assignment_id,
3065 p_element_type_id => p_element_type_id,
3066 p_project_id => l_project_id,
3067 p_expenditure_organization_id => l_expenditure_org_id,
3068 p_task_id => l_task_id,
3069 p_award_id => l_award_id,
3070 p_expenditure_type => l_expenditure_type,
3071 p_gl_code_combination_id => l_gl_code_combination_id,
3072 p_payroll_date => l_asg_end_date, --- replaced l_effective_date..5592784
3073 p_set_of_books_id => g_set_of_books_id,
3074 p_business_group_id => g_business_group_id,
3075 ret_expenditure_type => l_new_expenditure_type,
3076 ret_gl_code_combination_id => l_new_gl_code_combination_id,
3077 retcode => l_autopop_status);
3078
3079 IF (l_autopop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
3080 (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
3081 l_autopop_error := 'AUTO_POP_EXP_ERROR';
3082 IF (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
3083 l_autopop_error := 'AUTO_POP_NO_VALUE';
3084 END IF;
3085 IF (l_asg_start_date <= g_enc_org_end_date) THEN
3086 orig_ci.gl_code_combination_id(g_orig_pointer) := l_gl_code_combination_id;
3087 orig_ci.project_id(g_orig_pointer) := l_project_id;
3088 orig_ci.task_id(g_orig_pointer) := l_task_id;
3089 orig_ci.award_id(g_orig_pointer) := l_award_id;
3090 orig_ci.expenditure_organization_id(g_orig_pointer) := l_expenditure_org_id;
3091 orig_ci.expenditure_type(g_orig_pointer) := l_expenditure_type;
3092 g_orig_pointer := g_orig_pointer + 1;
3093 l_enc_period_count := r_enc_period.r_time_period_id.COUNT + 1;
3094 r_enc_period.r_period_ind(l_enc_period_count) := r_enc_period.r_period_ind(l_chunk_pointer);
3095 r_enc_period.r_period_start_date(l_enc_period_count) := r_enc_period.r_period_start_date(l_chunk_pointer);
3096 r_enc_period.r_period_end_date(l_enc_period_count) := r_enc_period.r_period_end_date(l_chunk_pointer);
3097 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);
3098 r_enc_period.r_asg_end_date(l_enc_period_count) := r_enc_period.r_asg_end_date(l_chunk_pointer);
3099 r_enc_period.r_effective_date(l_enc_period_count) := r_enc_period.r_effective_date(l_chunk_pointer);
3100 r_enc_period.r_time_period_id(l_enc_period_count) := r_enc_period.r_time_period_id(l_chunk_pointer);
3101 r_enc_period.r_process_flag(l_enc_period_count) := 'SA';
3102 r_enc_period.r_schedule_percent(l_enc_period_count) := 100;
3103 r_enc_period.r_encumbrance_amount(l_enc_period_count) := ROUND(r_enc_period.r_encumbrance_amount(l_chunk_pointer) *
3104 (psp_general.business_days(l_asg_start_date, r_enc_period.r_asg_end_date(l_enc_period_count)) / l_bus_days_in_chunk));
3105 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);
3106 r_enc_period.r_period_amount(l_enc_period_count) := r_enc_period.r_period_amount(l_chunk_pointer);
3107 r_enc_period.r_reason_code(l_enc_period_count) := l_autopop_error;
3108 END IF;
3109 add_cel_warnings(p_start_date => r_enc_period.r_asg_start_date(l_chunk_pointer),
3110 p_hierarchy_code => 'SA',
3111 p_end_date => r_enc_period.r_asg_end_date(l_chunk_pointer),
3112 p_warning_code => 'AUTOPOP',
3113 p_gl_ccid => l_gl_code_combination_id,
3114 p_project_id => l_project_id,
3115 p_task_id => l_task_id,
3116 p_award_id => l_award_id,
3117 p_exp_org_id => l_expenditure_org_id,
3118 p_exp_type => l_expenditure_type,
3119 p_effective_date => l_effective_date,
3120 p_error_status => l_autopop_error);
3121 hr_utility.trace('Posting to suspense account');
3122 ELSE
3123 IF (l_acct_type = 'E') THEN
3124 psp_enc_pre_process.validate_poeta (p_project_id => l_project_id,
3125 p_task_id => l_task_id,
3126 p_award_id => l_award_id,
3127 p_expenditure_type => l_new_expenditure_type,
3128 p_expenditure_organization_id => l_expenditure_org_id,
3129 p_payroll_id => p_payroll_id,
3130 p_start_date => l_poeta_start_date,
3131 p_end_date => l_poeta_end_date,
3132 p_return_status => p_return_status);
3133 IF p_return_status <> fnd_api.g_ret_sts_success THEN
3134 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3135 END IF;
3136 l_expenditure_type := l_new_expenditure_type;
3137 ELSE
3138 l_gl_code_combination_id := l_new_gl_code_combination_id;
3139 END IF;
3140 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
3141 END IF;
3142 ELSE
3143 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
3144 END IF;
3145 END IF;
3146 END LOOP;
3147 ELSIF (l_process_flag = 'SA') THEN
3148 IF (l_reason_code NOT IN ('LDM_BAL_NOT_100_PERCENT', 'LDM_NO_CI_FOUND')) THEN
3149 l_orig_gl_code_combination_id := orig_ci.gl_code_combination_id(l_orig_pointer);
3150 l_orig_project_id := orig_ci.project_id(l_orig_pointer);
3151 l_orig_task_id := orig_ci.task_id(l_orig_pointer);
3152 l_orig_award_id := orig_ci.award_id(l_orig_pointer);
3153 l_orig_expenditure_org_id := orig_ci.expenditure_organization_id(l_orig_pointer);
3154 l_orig_expenditure_type := orig_ci.expenditure_type(l_orig_pointer);
3155 l_orig_pointer := l_orig_pointer + 1;
3156 END IF;
3157
3158 FOR recno IN 1..r_sa.line_account_id.COUNT
3159 LOOP
3160 g_sa_pointer := recno;
3161 EXIT WHEN ((l_asg_start_date <= r_sa.end_date_active(recno))
3162 AND (l_asg_end_date >= r_sa.start_date_active(recno)));
3163 IF ((recno = r_sa.line_account_id.COUNT) AND
3164 (l_asg_start_date <= g_enc_org_end_date)) THEN
3165 OPEN asg_number_cur;
3166 FETCH asg_number_cur INTO l_organization_id;
3167 CLOSE asg_number_cur;
3168
3169 OPEN org_name_cur;
3170 FETCH org_name_cur INTO l_organization_name;
3171 CLOSE org_name_cur;
3172
3173 fnd_message.set_name('PSP', 'PSP_LD_SUSPENSE_AC_NOT_EXIST');
3174 fnd_message.set_token('ORG_NAME', l_organization_name);
3175 fnd_message.set_token('PAYROLL_DATE', l_asg_start_date);
3176 g_error_message := fnd_message.get;
3177 RAISE no_global_acct_exists;
3178 END IF;
3179 END LOOP;
3180
3181 FOR recno IN g_sa_pointer..r_sa.line_account_id.COUNT
3182 LOOP
3183 EXIT WHEN (NOT ((l_asg_start_date <= r_sa.end_date_active(recno))
3184 AND (l_asg_end_date >= r_sa.start_date_active(recno))));
3185
3186 g_sa_pointer := recno;
3187 l_suspense_account_id := r_sa.line_account_id(recno);
3188 l_gl_code_combination_id := r_sa.gl_code_combination_id(recno);
3189 l_project_id := r_sa.project_id(recno);
3190 l_task_id := r_sa.task_id(recno);
3191 l_award_id := r_sa.award_id(recno);
3192 l_schedule_percent := r_sa.percent(recno);
3193 l_expenditure_type := r_sa.expenditure_type(recno);
3194 l_expenditure_org_id := r_sa.expenditure_organization_id(recno);
3195 l_start_date_active := r_sa.start_date_active(recno);
3196 l_end_date_active := r_sa.end_date_active(recno);
3197 l_poeta_start_date := r_sa.poeta_start_date(recno);
3198 l_poeta_end_date := r_sa.poeta_end_date(recno);
3199 l_attribute_category := r_sa.attribute_category(recno);
3200 l_attribute1 := r_sa.attribute1(recno);
3201 l_attribute2 := r_sa.attribute2(recno);
3202 l_attribute3 := r_sa.attribute3(recno);
3203 l_attribute4 := r_sa.attribute4(recno);
3204 l_attribute5 := r_sa.attribute5(recno);
3205 l_attribute6 := r_sa.attribute6(recno);
3206 l_attribute7 := r_sa.attribute7(recno);
3207 l_attribute8 := r_sa.attribute8(recno);
3208 l_attribute9 := r_sa.attribute9(recno);
3209 l_attribute10 := r_sa.attribute10(recno);
3210 l_acct_type := r_sa.acct_type(recno);
3211
3212 IF (g_uom = 'H' AND l_gl_code_combination_id IS NOT NULL) THEN
3213 log_gl_hours_message;
3214 ELSE
3215
3216 IF (g_sa_autopop = 'Y') THEN
3217 psp_autopop.main(p_acct_type => l_acct_type,
3218 p_person_id => l_person_id,
3219 p_assignment_id => p_assignment_id,
3220 p_element_type_id => p_element_type_id,
3221 p_project_id => l_project_id,
3222 p_expenditure_organization_id => l_expenditure_org_id,
3223 p_task_id => l_task_id,
3224 p_award_id => l_award_id,
3225 p_expenditure_type => l_expenditure_type,
3226 p_gl_code_combination_id => l_gl_code_combination_id,
3227 p_payroll_date => l_asg_end_date, --- replaced l_effective_date..5592784
3228 p_set_of_books_id => g_set_of_books_id,
3229 p_business_group_id => g_business_group_id,
3230 ret_expenditure_type => l_new_expenditure_type,
3231 ret_gl_code_combination_id => l_new_gl_code_combination_id,
3232 retcode => l_autopop_status);
3233
3234 IF (l_autopop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
3235 (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
3236 l_autopop_error := 'AUTO_POP_EXP_ERROR';
3237 IF (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
3238 l_autopop_error := 'AUTO_POP_NO_VALUE';
3239 END IF;
3240 IF (l_acct_type = 'E') THEN
3241 OPEN project_number_cur;
3242 FETCH project_number_cur INTO l_project_number;
3243 CLOSE project_number_cur;
3244
3245 OPEN award_number_cur;
3246 FETCH award_number_cur INTO l_award_number;
3247 CLOSE award_number_cur;
3248
3249 OPEN task_number_cur;
3250 FETCH task_number_cur INTO l_task_number;
3251 CLOSE task_number_cur;
3252
3253 OPEN exp_org_name_cur;
3254 FETCH exp_org_name_cur INTO l_exp_org_name;
3255 CLOSE exp_org_name_cur;
3256
3257 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_INV_PATEO');
3258 fnd_message.set_token('PJ', l_project_number);
3259 fnd_message.set_token('TK', l_task_number);
3260 fnd_message.set_token('AW', l_award_number);
3261 fnd_message.set_token('EO', l_exp_org_name);
3262 fnd_message.set_token('ET', l_expenditure_type);
3263 ELSE
3264 l_gl_description := psp_general.get_gl_values(g_set_of_books_id, l_gl_code_combination_id);
3265 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_INV_GL');
3266 fnd_message.set_token('GL', l_gl_description);
3267 END IF;
3268 fnd_message.set_token('START_DATE', l_asg_start_date);
3269 fnd_message.set_token('END_DATE', l_asg_end_date);
3270 fnd_message.set_token('ERROR_STATUS', l_autopop_error);
3271 g_error_message := fnd_message.get;
3272 RAISE SUSPENSE_AUTOPOP_FAILED;
3273 ELSE
3274 IF (l_acct_type = 'E') THEN
3275 psp_enc_pre_process.validate_poeta (p_project_id => l_project_id,
3276 p_task_id => l_task_id,
3277 p_award_id => l_award_id,
3278 p_expenditure_type => l_new_expenditure_type,
3279 p_expenditure_organization_id => l_expenditure_org_id,
3280 p_payroll_id => p_payroll_id,
3281 p_start_date => l_poeta_start_date,
3282 p_end_date => l_poeta_end_date,
3283 p_return_status => p_return_status);
3284 IF p_return_status <> fnd_api.g_ret_sts_success THEN
3285 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3286 END IF;
3287 l_expenditure_type := l_new_expenditure_type;
3288 ELSE
3289 l_gl_code_combination_id := l_new_gl_code_combination_id;
3290 END IF;
3291 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
3292 END IF;
3293 ELSE
3294 process_all_hier(l_chunk_pointer, l_asg_start_date, l_asg_end_date, NULL, l_process_flag);
3295 END IF;
3296 END IF;
3297 END LOOP;
3298 ELSIF (l_process_flag = 'I') THEN
3299 hr_utility.trace('Ignoring chunk starting beyond org end date');
3300 END IF;
3301 END IF;
3302
3303 l_chunk_pointer := l_chunk_pointer + 1;
3304 END LOOP;
3305
3306 orig_ci.gl_code_combination_id.DELETE;
3307 orig_ci.project_id.DELETE;
3308 orig_ci.task_id.DELETE;
3309 orig_ci.award_id.DELETE;
3310 orig_ci.expenditure_organization_id.DELETE;
3311 orig_ci.expenditure_type.DELETE;
3312
3313 hr_utility.trace('Prev Enc Lines: ' || l_prev_enc_lines_counter);
3314 hr_utility.trace('G Enc Lines: ' || g_enc_lines_counter);
3315 hr_utility.trace('Enc Lines: ' || t_enc_lines_array.r_time_period_id.COUNT);
3316 l_time_period_id := -1;
3317 IF ((g_enc_lines_counter - l_prev_enc_lines_counter) > 0) THEN
3318 FOR recno IN 1..r_enc_period.r_time_period_id.COUNT
3319 LOOP
3320 IF (l_time_period_id <> r_enc_period.r_time_period_id(recno)) AND
3321 (r_enc_period.r_time_period_id(recno) NOT IN (l_ignore_start, l_ignore_end)) AND
3322 (g_enc_org_end_date > r_enc_period.r_period_start_date(recno)) THEN
3323 l_proc_step := 90 + (recno / 100000);
3324 l_running_total := 0;
3325 l_chunk_pointer := 1;
3326 l_time_period_id := r_enc_period.r_time_period_id(recno);
3327 FOR recno2 IN l_prev_enc_lines_counter..(g_enc_lines_counter-1)
3328 LOOP
3329 l_proc_step := 100 + (recno2 / 100000);
3330 IF (t_enc_lines_array.r_time_period_id(recno2) = l_time_period_id) THEN
3331 l_running_total := l_running_total + t_enc_lines_array.r_encumbrance_amount(recno2);
3332 l_chunk_pointer := recno2;
3333 hr_utility.trace('Encumbrance Amount: ' || t_enc_lines_array.r_encumbrance_amount(recno2));
3334 END IF;
3335 END LOOP;
3336
3337 IF (l_running_total > 0) AND (l_running_total <> r_enc_period.r_period_amount(recno)) THEN
3338 t_enc_lines_array.r_encumbrance_amount(l_chunk_pointer) :=
3339 t_enc_lines_array.r_encumbrance_amount(l_chunk_pointer) +
3340 (r_enc_period.r_period_amount(recno) - l_running_total);
3341 END IF;
3342
3343 hr_utility.trace('l_time_period_id: ' || l_time_period_id ||
3344 ' l_running_total: ' || fnd_number.number_to_canonical(l_running_total) ||
3345 ' r_enc_period.r_period_amount(recno): ' || fnd_number.number_to_canonical(r_enc_period.r_period_amount(recno)) ||
3346 ' 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)));
3347 END IF;
3348 END LOOP;
3349 END IF;
3350
3351 r_enc_period.r_time_period_id.DELETE;
3352 r_enc_period.r_period_start_date.DELETE;
3353 r_enc_period.r_period_end_date.DELETE;
3354 r_enc_period.r_asg_start_date.DELETE;
3355 r_enc_period.r_asg_end_date.DELETE;
3356 r_enc_period.r_process_flag.DELETE;
3357 r_enc_period.r_period_ind.DELETE;
3358 r_enc_period.r_schedule_percent.DELETE;
3359 r_enc_period.r_encumbrance_amount.DELETE;
3360 r_enc_period.r_period_amount.DELETE;
3361 r_enc_period.r_reason_code.DELETE;
3362
3363 l_proc_step := 210;
3364 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving ' || l_proc_name);
3365 EXCEPTION
3366 WHEN suspense_autopop_failed THEN
3367 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'CREATE_LINES ');
3368 p_return_status := fnd_api.g_ret_sts_unexp_error;
3369 fnd_file.put_line(fnd_file.log, 'l_reason_code: ' || l_reason_code);
3370 fnd_file.put_line(fnd_file.log, fnd_number.number_to_canonical(l_proc_step) || ': ' || l_proc_name);
3371 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving ' || l_proc_name);
3372 WHEN OTHERS THEN
3373 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
3374 IF (g_error_message IS NULL) THEN
3375 g_error_message := l_proc_name || ': ' || SQLERRM;
3376 END IF;
3377 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'CREATE_LINES');
3378 p_return_status := fnd_api.g_ret_sts_unexp_error;
3379 fnd_file.put_line(fnd_file.log, fnd_number.number_to_canonical(l_proc_step) || ': ' || l_proc_name);
3380 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving ' || l_proc_name);
3381 END create_lines;
3382
3383 ---------------------- I N S E R T S T A T E M E N T ------------------------------------
3384 PROCEDURE insert_into_enc_lines(
3385 L_ENC_ELEMENT_TYPE_ID IN NUMBER,
3386 L_ENCUMBRANCE_DATE IN DATE,
3387 L_DR_CR_FLAG IN VARCHAR2,
3388 L_ENCUMBRANCE_AMOUNT IN NUMBER,
3389 L_ENC_LINE_TYPE IN VARCHAR2,
3390 L_SCHEDULE_LINE_ID IN NUMBER,
3391 L_ORG_SCHEDULE_ID IN NUMBER,
3392 L_DEFAULT_ORG_ACCOUNT_ID IN NUMBER,
3393 L_SUSPENSE_ORG_ACCOUNT_ID IN NUMBER,
3394 L_ELEMENT_ACCOUNT_ID IN NUMBER,
3395 L_GL_PROJECT_FLAG IN VARCHAR2,
3396 L_PERSON_ID IN NUMBER,
3397 L_ASSIGNMENT_ID IN NUMBER,
3398 L_AWARD_ID IN NUMBER,
3399 L_TASK_ID IN NUMBER,
3400 L_EXPENDITURE_TYPE IN VARCHAR2,
3401 L_EXPENDITURE_ORGANIZATION_ID IN NUMBER,
3402 L_PROJECT_ID IN NUMBER,
3403 L_GL_CODE_COMBINATION_ID IN NUMBER,
3404 L_TIME_PERIOD_ID IN NUMBER,
3405 L_PAYROLL_ID IN NUMBER,
3406 L_BUSINESS_GROUP_ID IN NUMBER,
3407 L_SET_OF_BOOKS_ID IN NUMBER,
3408 L_SUSPENSE_REASON_CODE IN VARCHAR2,
3409 L_DEFAULT_REASON_CODE IN VARCHAR2,
3410 L_CHANGE_FLAG IN VARCHAR2,
3411 L_ENC_START_DATE IN DATE,
3412 L_ENC_END_DATE IN DATE,
3413 p_attribute_category IN VARCHAR2, -- Introduced DFF parameters for bug fix 2908859
3414 p_attribute1 IN VARCHAR2,
3415 p_attribute2 IN VARCHAR2,
3416 p_attribute3 IN VARCHAR2,
3417 p_attribute4 IN VARCHAR2,
3418 p_attribute5 IN VARCHAR2,
3419 p_attribute6 IN VARCHAR2,
3420 p_attribute7 IN VARCHAR2,
3421 p_attribute8 IN VARCHAR2,
3422 p_attribute9 IN VARCHAR2,
3423 p_attribute10 IN VARCHAR2,
3424 p_orig_gl_code_combination_id IN NUMBER,
3425 p_orig_project_id IN NUMBER,
3426 p_orig_task_id IN NUMBER,
3427 p_orig_award_id IN NUMBER,
3428 p_orig_expenditure_org_id IN NUMBER,
3429 p_orig_expenditure_type IN VARCHAR2,
3430 p_hierarchy_code IN VARCHAR2,
3431 p_return_status OUT NOCOPY VARCHAR2) IS
3432 l_enc_line_id NUMBER;
3433 l_row_id VARCHAR2(30);
3434 i NUMBER := 0;
3435 l_time_period_id_found VARCHAR2(10) := 'FALSE';
3436 l_rec_no NUMBER := 0;
3437 l_enc_control_id NUMBER;
3438 l_return_status VARCHAR2(1);
3439 BEGIN
3440 --For Enh. Bug 2259310 : Changed the enc_control_tab from array of records to records of array and hence the change
3441 --in the way each element of record to be accessed.
3442 --Instead of calling INSERT_ROW of PSP_ENC_LINES for each CI of an assignment, all the lines are collated into an
3443 --array for an assignment and inserted using Oracle 8i feature
3444
3445 /* added to skip creation of lines with zero dollars Bug 1671971:- Subha */
3446 IF l_encumbrance_amount <> 0 THEN
3447
3448 -- The following code is used to populate number_of_dr,number_of_cr,total_dr_amount,
3449 -- total_cr_amount,gl_dr_amount,gl_cr_amount,ogm_dr_amount,ogm_cr_amount of
3450 -- psp_enc_controls table.
3451
3452 -- Check for dr_cr_flag and increment the counter and amount accordingly.
3453 FOR I IN 1..enc_control_tab.r_enc_control_id.COUNT
3454 loop
3455 IF (enc_control_tab.r_time_period_id(i) = l_time_period_id
3456 AND enc_control_tab.r_uom(i) = g_uom) THEN
3457 l_time_period_id_found := 'TRUE';
3458 l_rec_no := i;
3459 l_enc_control_id := enc_control_tab.r_enc_control_id(l_rec_no);
3460 EXIT;
3461 end if;
3462 end loop;
3463
3464 IF l_time_period_id_found = 'FALSE' THEN
3465 create_controls(g_payroll_action_id, l_payroll_id,
3466 l_time_period_id, l_business_group_id, l_set_of_books_id,
3467 l_enc_control_id, l_return_status);
3468
3469 l_rec_no := enc_control_tab.r_enc_control_id.COUNT + 1;
3470 enc_control_tab.r_time_period_id(l_rec_no) := l_time_period_id;
3471 enc_control_tab.r_uom(l_rec_no) := g_uom;
3472 /***** Commented the following for Create and Update multi thread enh.
3473 -- Get a number for enc control id
3474 BEGIN
3475 SELECT psp_enc_controls_s.nextval
3476 INTO l_enc_control_id
3477 FROM DUAL;
3478 END;
3479 End of comment for Create and Update multi thread enh. *****/
3480 enc_control_tab.r_enc_control_id(l_rec_no) := l_enc_control_id;
3481 enc_control_tab.r_no_of_dr(l_rec_no) := 0;
3482 enc_control_tab.r_total_dr_amount(l_rec_no) := 0;
3483 enc_control_tab.r_gl_dr_amount(l_rec_no) := 0;
3484 enc_control_tab.r_ogm_dr_amount(l_rec_no) :=0;
3485 enc_control_tab.r_no_of_cr(l_rec_no) :=0;
3486 enc_control_tab.r_total_cr_amount(l_rec_no) := 0;
3487 enc_control_tab.r_gl_cr_amount(l_rec_no) := 0;
3488 enc_control_tab.r_ogm_cr_amount(l_rec_no) :=0;
3489 END IF;
3490
3491 IF l_dr_cr_flag = 'D' THEN
3492 g_dr_ctr := NVL(g_dr_ctr,0) + 1;
3493 enc_control_tab.r_no_of_dr(l_rec_no) := NVL(enc_control_tab.r_no_of_dr(l_rec_no),0) + 1;
3494 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);
3495
3496 IF l_gl_project_flag = 'G' THEN
3497 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);
3498 ELSIF l_gl_project_flag = 'P' THEN
3499 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);
3500 END IF;
3501
3502 ELSIF l_dr_cr_flag = 'C' THEN
3503 g_cr_ctr := NVL(g_cr_ctr,0) + 1;
3504 enc_control_tab.r_no_of_cr(l_rec_no) := NVL(enc_control_tab.r_no_of_cr(l_rec_no),0) + 1;
3505 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);
3506
3507 IF l_gl_project_flag = 'G' THEN
3508 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);
3509 ELSIF l_gl_project_flag = 'P' THEN
3510 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);
3511 END IF;
3512 END IF;
3513
3514 --Introduced For Enh. Bug 2259310
3515 -- Insert into enc lines record
3516 t_enc_lines_array.r_enc_element_type_id(g_enc_lines_counter) := l_enc_element_type_id;
3517 t_enc_lines_array.r_encumbrance_date(g_enc_lines_counter) := l_encumbrance_date;
3518 t_enc_lines_array.r_dr_cr_flag(g_enc_lines_counter) := l_dr_cr_flag;
3519 t_enc_lines_array.r_encumbrance_amount(g_enc_lines_counter) := l_encumbrance_amount;
3520 t_enc_lines_array.r_enc_line_type(g_enc_lines_counter) := l_enc_line_type;
3521 t_enc_lines_array.r_schedule_line_id(g_enc_lines_counter) := l_schedule_line_id;
3522 t_enc_lines_array.r_org_schedule_id(g_enc_lines_counter) := l_org_schedule_id;
3523 t_enc_lines_array.r_default_org_account_id(g_enc_lines_counter) := l_default_org_account_id;
3524 t_enc_lines_array.r_suspense_org_account_id(g_enc_lines_counter) := l_suspense_org_account_id;
3525 t_enc_lines_array.r_element_account_id(g_enc_lines_counter) := l_element_account_id;
3526 t_enc_lines_array.r_gl_project_flag(g_enc_lines_counter) := l_gl_project_flag;
3527 t_enc_lines_array.r_person_id(g_enc_lines_counter) := l_person_id;
3528 t_enc_lines_array.r_assignment_id(g_enc_lines_counter) := l_assignment_id;
3529 t_enc_lines_array.r_award_id(g_enc_lines_counter) := l_award_id;
3530 t_enc_lines_array.r_task_id(g_enc_lines_counter) := l_task_id;
3531 t_enc_lines_array.r_expenditure_type(g_enc_lines_counter) := l_expenditure_type;
3532 t_enc_lines_array.r_expenditure_organization_id(g_enc_lines_counter) := l_expenditure_organization_id;
3533 t_enc_lines_array.r_project_id(g_enc_lines_counter) := l_project_id;
3534 t_enc_lines_array.r_gl_code_combination_id(g_enc_lines_counter) := l_gl_code_combination_id;
3535 t_enc_lines_array.r_time_period_id(g_enc_lines_counter) := l_time_period_id;
3536 t_enc_lines_array.r_default_reason_code(g_enc_lines_counter) := l_default_reason_code;
3537 t_enc_lines_array.r_suspense_reason_code(g_enc_lines_counter) := l_suspense_reason_code;
3538 t_enc_lines_array.r_enc_control_id(g_enc_lines_counter) := l_enc_control_id;
3539 t_enc_lines_array.r_change_flag(g_enc_lines_counter) := l_change_flag;
3540 t_enc_lines_array.r_enc_start_date(g_enc_lines_counter) := l_enc_start_date;
3541 t_enc_lines_array.r_enc_end_date(g_enc_lines_counter) := l_enc_end_date;
3542 t_enc_lines_array.r_attribute_category(g_enc_lines_counter) := NVL(p_attribute_category, 'NULL_VALUE'); -- Introduced DFF columns for bug fix 2908859
3543 t_enc_lines_array.r_attribute1(g_enc_lines_counter) := NVL(p_attribute1, 'NULL_VALUE');
3544 t_enc_lines_array.r_attribute2(g_enc_lines_counter) := NVL(p_attribute2, 'NULL_VALUE');
3545 t_enc_lines_array.r_attribute3(g_enc_lines_counter) := NVL(p_attribute3, 'NULL_VALUE');
3546 t_enc_lines_array.r_attribute4(g_enc_lines_counter) := NVL(p_attribute4, 'NULL_VALUE');
3547 t_enc_lines_array.r_attribute5(g_enc_lines_counter) := NVL(p_attribute5, 'NULL_VALUE');
3548 t_enc_lines_array.r_attribute6(g_enc_lines_counter) := NVL(p_attribute6, 'NULL_VALUE');
3549 t_enc_lines_array.r_attribute7(g_enc_lines_counter) := NVL(p_attribute7, 'NULL_VALUE');
3550 t_enc_lines_array.r_attribute8(g_enc_lines_counter) := NVL(p_attribute8, 'NULL_VALUE');
3551 t_enc_lines_array.r_attribute9(g_enc_lines_counter) := NVL(p_attribute9, 'NULL_VALUE');
3552 t_enc_lines_array.r_attribute10(g_enc_lines_counter) := NVL(p_attribute10, 'NULL_VALUE');
3553 t_enc_lines_array.r_orig_gl_code_combination_id(g_enc_lines_counter) := p_orig_gl_code_combination_id;
3554 t_enc_lines_array.r_orig_project_id(g_enc_lines_counter) := p_orig_project_id;
3555 t_enc_lines_array.r_orig_award_id(g_enc_lines_counter) := p_orig_award_id;
3556 t_enc_lines_array.r_orig_task_id(g_enc_lines_counter) := p_orig_task_id;
3557 t_enc_lines_array.r_orig_expenditure_type(g_enc_lines_counter) := p_orig_expenditure_type;
3558 t_enc_lines_array.r_orig_expenditure_org_id(g_enc_lines_counter) := p_orig_expenditure_org_id;
3559 t_enc_lines_array.r_hierarchy_code(g_enc_lines_counter) := p_hierarchy_code;
3560
3561 g_enc_lines_counter := g_enc_lines_counter +1;
3562 END IF; /* skip inserting lines of zero dollars */
3563 p_return_status := fnd_api.g_ret_sts_success;
3564 EXCEPTION
3565 WHEN OTHERS THEN
3566 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
3567 IF (g_error_message IS NULL) THEN
3568 g_error_message := 'INSERT_INTO_ENC_LINES: ' || SQLERRM;
3569 END IF;
3570 fnd_msg_pub.add_exc_msg('PSP_ENC_LINES','INSERT_INTO_ENC_LINES');
3571 p_return_status := fnd_api.g_ret_sts_unexp_error;
3572 END insert_into_enc_lines;
3573
3574 --------------------------- INSERT INTO CONTROL TABLES --------------------------------------
3575 PROCEDURE Create_Controls(p_payroll_action_id IN NUMBER,
3576 p_payroll_id IN NUMBER,
3577 p_time_period_id IN NUMBER,
3578 p_business_group_id IN NUMBER,
3579 p_set_of_books_id IN NUMBER,
3580 p_enc_control_id OUT NOCOPY NUMBER,
3581 p_return_status OUT NOCOPY VARCHAR2) IS
3582
3583 l_action_code VARCHAR2(2);-- DEFAULT 'N';
3584 --Added the following variables for the Enhancement -Enc Redesign: Enh. Bug 2259310
3585 l_batch_name VARCHAR2(30) DEFAULT 'ENC'||TO_CHAR(TRUNC(SYSDATE));
3586 l_last_update_date DATE DEFAULT SYSDATE;
3587 l_last_updated_by NUMBER DEFAULT NVL(FND_GLOBAL.USER_ID, -1);
3588 l_last_updated_login NUMBER DEFAULT NVL(FND_GLOBAL.LOGIN_ID, -1);
3589 CURSOR get_enc_control_id_cur IS
3590 SELECT enc_control_id
3591 FROM psp_enc_controls
3592 WHERE payroll_action_id = p_payroll_action_id
3593 AND payroll_id = p_payroll_id
3594 AND time_period_id = p_time_period_id
3595 AND uom = g_uom;
3596 BEGIN
3597 /* Added IF conditon below for Restart update/Quick Update Encumbrance Lines Enh. */
3598 -- IF g_enc_line_type IN ('U','Q') THEN
3599 l_action_code := 'IC';
3600 -- END IF;
3601
3602 OPEN get_enc_control_id_cur;
3603 FETCH get_enc_control_id_cur INTO p_enc_control_id;
3604 CLOSE get_enc_control_id_cur;
3605
3606 -- FORALL i IN 1 ..enc_control_tab.r_time_period_id.COUNT
3607 IF (p_enc_control_id IS NULL) THEN
3608 SELECT psp_enc_controls_s.NEXTVAL INTO p_enc_control_id FROM DUAL;
3609
3610 INSERT INTO PSP_ENC_CONTROLS
3611 (time_period_id, enc_control_id,
3612 number_of_dr, number_of_cr,
3613 total_dr_amount, total_cr_amount,
3614 gl_dr_amount, gl_cr_amount,
3615 ogm_dr_amount, ogm_cr_amount,
3616 payroll_id, set_of_books_id,
3617 encumbrance_date, action_code,
3618 last_update_date, last_updated_by,
3619 creation_date, created_by,
3620 last_update_login, batch_name,
3621 business_group_id, action_type,
3622 payroll_action_id, uom)
3623 VALUES (p_time_period_id, p_enc_control_id,
3624 0, 0,
3625 0, 0,
3626 0, 0,
3627 0, 0,
3628 p_payroll_id, p_set_of_books_id,
3629 l_last_update_date, l_action_code,
3630 l_last_update_date, l_last_updated_by,
3631 l_last_update_date, l_last_updated_by,
3632 l_last_updated_login, l_batch_name,
3633 p_business_group_id, 'U',
3634 p_payroll_action_id, g_uom);
3635 /* Commented for Create and Update multi thread enh.
3636 VALUES (enc_control_tab.R_TIME_PERIOD_ID(i), enc_control_tab.R_ENC_CONTROL_ID(i),
3637 enc_control_tab.R_NO_OF_DR(i), enc_control_tab.R_NO_OF_CR(i),
3638 round(enc_control_tab.R_TOTAL_DR_AMOUNT(i),g_precision),-- intoduced Rounding for Bug 2916848 Ilo Ehnc.
3639 round(enc_control_tab.R_TOTAL_CR_AMOUNT(i),g_precision),-- intoduced Rounding for Bug 2916848 Ilo Ehnc.
3640 round(enc_control_tab.R_GL_DR_AMOUNT(i),g_precision),-- intoduced Rounding for Bug 2916848 Ilo Ehnc.
3641 round(enc_control_tab.R_GL_CR_AMOUNT(i),g_precision),-- intoduced Rounding for Bug 2916848 Ilo Ehnc.
3642 round(enc_control_tab.R_OGM_DR_AMOUNT(i),g_precision),-- intoduced Rounding for Bug 2916848 Ilo Ehnc.
3643 round(enc_control_tab.R_OGM_CR_AMOUNT(i),g_precision),-- intoduced Rounding for Bug 2916848 Ilo Ehnc.
3644 p_payroll_id, p_set_of_books_id,
3645 l_last_update_date, l_action_code,
3646 l_last_update_date, l_last_updated_by,
3647 l_last_update_date, l_last_updated_by,
3648 l_last_updated_login, l_batch_name,
3649 p_business_group_id, g_enc_line_type,
3650 p_payroll_action_id);
3651 End of comment for Create and Update Multi thread enh. *****/
3652 END IF;
3653
3654 enc_control_tab.r_time_period_id.delete;
3655 enc_control_tab.r_enc_control_id.delete;
3656 enc_control_tab.r_no_of_dr.delete;
3657 enc_control_tab.r_no_of_cr.delete;
3658 enc_control_tab.r_total_dr_amount.delete;
3659 enc_control_tab.r_total_cr_amount.delete;
3660 enc_control_tab.r_gl_dr_amount.delete;
3661 enc_control_tab.r_gl_cr_amount.delete;
3662 enc_control_tab.r_ogm_dr_amount.delete;
3663 enc_control_tab.r_ogm_cr_amount.delete;
3664 enc_control_tab.r_uom.delete;
3665
3666 COMMIT;
3667 p_return_status := fnd_api.g_ret_sts_success;
3668 EXCEPTION
3669 WHEN OTHERS THEN
3670 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
3671 IF (g_error_message IS NULL) THEN
3672 g_error_message := 'CREATE_CONTROLS: ' || SQLERRM;
3673 END IF;
3674 p_return_status := fnd_api.g_ret_sts_unexp_error;
3675 fnd_message.set_name('PSP','PSP_ENC_INSERT_CONTROLS');
3676 FND_MSG_PUB.ADD;
3677 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3678 END create_controls;
3679
3680 /**********************************************************
3681 Created By: lveerubh
3682
3683 Date Created By:08-MAR-2002
3684
3685 Purpose: To Determine the Prorata dates. This procedure is called from each of the hierachy.
3686 It determines the spilt of the active assignment chunk into Suspense posting and Schdedule posting
3687 And for each such dates arrived calculates the pro-rated amount. All the dates along with amount and
3688 flag to indicate suspense posting is populated in an array t_peot_gl_hier_array.
3689 Introduced as part of Enhnacement Enc Redesign : Bug 2259310.
3690
3691 Who When What
3692 lveerubh 08-MAR-2002 Created the procedure
3693 lveerubh 20-APR-2002 For Bug 2317856
3694 ***************************************************************/
3695 PROCEDURE determine_pro_rata_dates ( p_assignment_id IN NUMBER,
3696 p_ls_start_date IN DATE,
3697 p_ls_end_date IN DATE,
3698 p_poeta_start_date IN DATE,
3699 p_poeta_end_date IN DATE,
3700 p_asg_start_date IN DATE,
3701 p_asg_end_date IN DATE,
3702 p_asg_amount IN NUMBER,
3703 p_poeta_gl_hier_array IN OUT NOCOPY r_poeta_gl_hier_tab,
3704 p_return_status OUT NOCOPY VARCHAR2
3705 )
3706 IS
3707
3708 -- p_ls_start_date : GREATEST(Labor Schedule Start date , Assignment start date)
3709 -- p_ls_end_date : LEAST(Labor Schedule End date , Assignment end date)
3710
3711 l_start_date date := p_ls_start_date;
3712 l_end_date date := p_ls_end_date;
3713 i NUMBER := 1;
3714 l_bus_days_in_period NUMBER;
3715 l_bus_days_in_schedules NUMBER;
3716 l_susp_date DATE DEFAULT fnd_date.canonical_to_date('1800/01/01');
3717
3718
3719 DIVIDE_BY_ZERO EXCEPTION;
3720
3721 BEGIN
3722 /************
3723 The procedure has been functionally changed for bug 2317856
3724 --Step 1:
3725 --Obtain the start date = MAX (labor schedule start date, poeta start date) and
3726 --end date = min (labor schedule end date, poeta end date).
3727 --Note here that assignment start date and assignment end date checks are not being considered
3728 --for the following reason:
3729 --The posting to Enc lines has to be for the entire period of active assignment chunk.
3730 --Hence this procedure is calculating the date rage for which the POETA or GL needs to be posted
3731 --with the active assignment chunk.
3732 ******************/
3733
3734 --For Bug 2317856
3735 --Frame of reference would be asg start date and asg end date
3736 --No suspense postings for part which does not have LS or after which LS ends
3737 --IF poeta ends before l_start_date then period for which the LS is applicable within asg. chunk shall go to suspense
3738 --l_start_date and l_end_date are equivalent to greatest of ASD and LSD , least of AED and LED respectively.
3739
3740 --For Bug 2317856 :
3741 --1.Adding the extra check of poeta_end_date <l_start_date
3742 --2. Changed the p_asg_start_date and p_asg_end_date to l_start_date and l_end_date respectively
3743 --3. As the amount needs to be prorated hence cannot return in the IF or ELSIF
3744 --4. Moved the subslicing of l_start_Date and l_end_date periods into IF -ELSIF-ELSE condition. Thus moving the
3745 -- END IF down.
3746 --For Bug 2325710 : Introduced the p_poeta_start_date > l_end_date condition for suspense posting
3747 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
3748 p_poeta_gl_hier_array(i).r_amount := round(p_asg_amount,g_ext_precision);
3749 -- Introduced rounding for Bug 2916848 Ilo Mrc Ehnc
3750 p_poeta_gl_hier_array(i).r_enc_start_date := l_start_date;
3751 p_poeta_gl_hier_array(i).r_enc_end_date := l_end_date;
3752 p_poeta_gl_hier_array(i).r_susp_flag := 'Y';
3753 /*******************************************
3754 p_return_status := fnd_api.g_ret_sts_success;
3755 RETURN;
3756 END IF;
3757 IF l_start_date < NVL(p_poeta_start_date,l_start_date) THEN
3758 l_start_date := NVL(p_poeta_start_date,l_start_date);
3759 END IF;
3760
3761 --End Date
3762 IF l_end_date > NVL(p_poeta_end_date,l_end_date) THEN
3763 l_end_date := NVL(p_poeta_end_date,l_end_date);
3764 END IF;
3765 IF p_asg_start_date < l_start_date THEN --(ASD <PSD )
3766 t_poeta_gl_hier_array(i).r_enc_start_date := p_asg_start_date;
3767 t_poeta_gl_hier_array(i).r_enc_end_date := l_start_date-1;
3768 t_poeta_gl_hier_array(i).r_susp_flag := 'Y';
3769 i := i+1;
3770 IF l_end_date < p_asg_end_date THEN -- (PED<AED)
3771 t_poeta_gl_hier_array(i).r_enc_start_date := l_start_date;
3772 t_poeta_gl_hier_array(i).r_enc_end_date := l_end_date ;
3773 i := i +1;
3774 t_poeta_gl_hier_array(i).r_enc_start_date := l_end_date+1;
3775 t_poeta_gl_hier_array(i).r_enc_end_date := p_asg_end_date ;
3776 t_poeta_gl_hier_array(i).r_susp_flag := 'Y';
3777 ELSE-- (AED<=PED)
3778 t_poeta_gl_hier_array(i).r_enc_start_date := l_start_date;
3779 t_poeta_gl_hier_array(i).r_enc_end_date := p_asg_end_date ;
3780 END IF;
3781 ELSE --(ASD>= PSD)
3782 t_poeta_gl_hier_array(i).r_enc_start_date := p_asg_start_date;
3783 IF l_end_date < p_asg_end_date THEN --(PED<AED)
3784 t_poeta_gl_hier_array(i).r_enc_end_date := l_end_date ;
3785 i := i +1;
3786 t_poeta_gl_hier_array(i).r_enc_start_date := l_end_date+1;
3787 t_poeta_gl_hier_array(i).r_enc_end_date := p_asg_end_date ;
3788 t_poeta_gl_hier_array(i).r_susp_flag := 'Y';
3789 ELSE --(AED<= PED)
3790 t_poeta_gl_hier_array(i).r_enc_end_date := p_asg_end_date ;
3791 END IF;
3792 END IF;
3793 *****************************************/
3794 --Introduced for GL Validation -2317856
3795 ELSIF (p_poeta_start_date IS NULL) THEN
3796 p_poeta_gl_hier_array(i).r_amount := round(p_asg_amount,g_ext_precision);
3797 -- Introduced rounding for bug 2916848 Ilo Mrc Ehnc.
3798 p_poeta_gl_hier_array(i).r_enc_start_date := l_start_date;
3799 p_poeta_gl_hier_array(i).r_enc_end_date := l_end_date;
3800 p_poeta_gl_hier_array(i).r_susp_flag := 'N'; -- Introduced for bug fix 3085980
3801 ELSE
3802 /**Populating the t_poeta_gl_hier_array for using in the schedule hierarchy - FOR POETA processing **/
3803 --For Bug 2317856
3804 --1. Changed p_asg_start_date to l_start_date and p_asg_end_date to l_end_date
3805 --2. l_start_daet and l_end_Date are compared with POETA start and end date respectively
3806 -- Where SD : GREATEST(Labor Schedule Start date , Assignment start date)
3807 -- ED: LEAST(Labor Schedule End date , Assignment end date)
3808 -- PSD :POETA start date, PED:POETA End date
3809
3810 IF l_start_date < p_poeta_start_date THEN --(SD <PSD )
3811 p_poeta_gl_hier_array(i).r_enc_start_date := l_start_date;
3812 p_poeta_gl_hier_array(i).r_enc_end_date := p_poeta_start_date-1;
3813 p_poeta_gl_hier_array(i).r_susp_flag := 'Y';
3814 i := i+1;
3815 IF l_end_date > p_poeta_end_date THEN -- (PED<ED)
3816 p_poeta_gl_hier_array(i).r_enc_start_date := p_poeta_start_date;
3817 p_poeta_gl_hier_array(i).r_enc_end_date := p_poeta_end_date ;
3818 p_poeta_gl_hier_array(i).r_susp_flag := 'N'; -- Introduced for bug fix 3085980
3819 i := i +1;
3820 p_poeta_gl_hier_array(i).r_enc_start_date := p_poeta_end_date+1;
3821 p_poeta_gl_hier_array(i).r_enc_end_date := l_end_date ;
3822 p_poeta_gl_hier_array(i).r_susp_flag := 'Y';
3823 ELSE-- (ED<=PED)
3824 p_poeta_gl_hier_array(i).r_enc_start_date := p_poeta_start_date;
3825 p_poeta_gl_hier_array(i).r_enc_end_date := l_end_date ;
3826 p_poeta_gl_hier_array(i).r_susp_flag := 'N'; -- Introduced for bug fix 3085980
3827 END IF;
3828 ELSE --(SD>= PSD)
3829 p_poeta_gl_hier_array(i).r_enc_start_date := l_start_date;
3830 p_poeta_gl_hier_array(i).r_susp_flag := 'N'; -- Introduced for bug fix 3085980
3831 IF l_end_date > p_poeta_end_date THEN --(PED<ED)
3832 p_poeta_gl_hier_array(i).r_enc_end_date := p_poeta_end_date ;
3833 i := i +1;
3834 p_poeta_gl_hier_array(i).r_enc_start_date := p_poeta_end_date+1;
3835 p_poeta_gl_hier_array(i).r_enc_end_date := l_end_date ;
3836 p_poeta_gl_hier_array(i).r_susp_flag := 'Y';
3837 ELSE --(ED<= PED)
3838 p_poeta_gl_hier_array(i).r_enc_end_date := l_end_date ;
3839 END IF;
3840 END IF;
3841 END IF; --Main IF :2317856
3842
3843 l_bus_days_in_period := PSP_GENERAL.BUSINESS_DAYS(p_asg_start_date, p_asg_end_date,p_assignment_id);
3844 IF l_bus_days_in_period = 0 THEN
3845 fnd_message.set_name('PSP', 'PSP_ENC_ZERO_WORK_DAYS_PERIOD');
3846 fnd_message.set_token('START_DATE', p_asg_start_date);
3847 fnd_message.set_token('END_DATE', p_asg_end_date);
3848 g_error_message := fnd_message.get;
3849 RAISE DIVIDE_BY_ZERO;
3850 END IF;
3851
3852 For j in 1 .. p_poeta_gl_hier_array.COUNT
3853 LOOP
3854 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);
3855 p_poeta_gl_hier_array(j).r_amount :=
3856 round(((p_asg_amount * l_bus_days_in_schedules) / l_bus_days_in_period),g_ext_precision);
3857 -- Introduced rounding for Bug 2916848 Ilo Mrc Ehnc.
3858 END LOOP;
3859 p_return_status := fnd_api.g_ret_sts_success;
3860
3861 EXCEPTION
3862 WHEN DIVIDE_BY_ZERO THEN
3863 g_error_api_path := SUBSTR(' DETERMINE_PRO_RATA_DATES'||g_error_api_path,1,230);
3864 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', ' DETERMINE_PRO_RATA_DATES ');
3865 p_return_status := fnd_api.g_ret_sts_unexp_error;
3866
3867 WHEN OTHERS THEN
3868 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
3869 IF (g_error_message IS NULL) THEN
3870 g_error_message := 'DETERMINE_PRO_RATA_DATES: ' || SQLERRM;
3871 END IF;
3872 g_error_api_path := SUBSTR(' DETERMINE_PRO_RATA_DATES'||g_error_api_path,1,230);
3873 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', ' DETERMINE_PRO_RATA_DATES ');
3874 p_return_status := fnd_api.g_ret_sts_unexp_error;
3875
3876 END determine_pro_rata_dates;
3877
3878 /**************************************************************************************************************************
3879 Created By: lveerubh
3880
3881 Date Created By:08-MAR-2002
3882
3883 Purpose: To insert into psp_enc_lines from Array. This procedure has been introduced to bulk insert
3884 into psp_enc_lines from the record of collection t_enc_lines_array.
3885 Introduced as part of Enhnacement Enc Redesign : Bug 2259310.
3886 Who When What
3887 lveerubh 08-MAR-2002 Created the procedure
3888 ********************************************************************************************************************************/
3889 PROCEDURE insert_enc_lines_from_arrays( p_payroll_id IN NUMBER,
3890 p_business_group_id IN NUMBER,
3891 p_set_of_books_id IN NUMBER,
3892 p_enc_line_type IN VARCHAR2,
3893 p_return_status OUT NOCOPY VARCHAR2)
3894 IS
3895 l_last_update_date DATE DEFAULT SYSDATE;
3896 l_last_updated_by NUMBER DEFAULT NVL(FND_GLOBAL.USER_ID, -1);
3897 l_last_update_login NUMBER DEFAULT NVL(FND_GLOBAL.LOGIN_ID, -1);
3898 BEGIN
3899 FORALL i IN 1 .. t_enc_lines_array2.r_enc_element_type_id.COUNT
3900 insert into psp_enc_lines
3901 (
3902 enc_element_type_id,
3903 enc_line_id,
3904 business_group_id,
3905 encumbrance_date,
3906 dr_cr_flag,
3907 encumbrance_amount,
3908 enc_line_type,
3909 schedule_line_id,
3910 org_schedule_id,
3911 default_org_account_id,
3912 suspense_org_account_id,
3913 element_account_id,
3914 gl_project_flag,
3915 person_id,
3916 assignment_id,
3917 award_id,
3918 task_id,
3919 expenditure_type,
3920 expenditure_organization_id,
3921 project_id,
3922 gl_code_combination_id,
3923 time_period_id,
3924 payroll_id,
3925 set_of_books_id,
3926 default_reason_code,
3927 suspense_reason_code,
3928 status_code,
3929 enc_control_id,
3930 change_flag,
3931 enc_start_date,
3932 enc_end_date,
3933 last_update_date,
3934 last_updated_by,
3935 last_update_login,
3936 created_by,
3937 creation_date,
3938 attribute_category, -- Introduced DFF columns for bug fix 2908859
3939 attribute1,
3940 attribute2,
3941 attribute3,
3942 attribute4,
3943 attribute5,
3944 attribute6,
3945 attribute7,
3946 attribute8,
3947 attribute9,
3948 attribute10,
3949 payroll_action_id,
3950 orig_gl_code_combination_id,
3951 orig_project_id,
3952 orig_task_id,
3953 orig_award_id,
3954 orig_expenditure_org_id,
3955 orig_expenditure_type,
3956 hierarchy_code
3957 )
3958 values (
3959 t_enc_lines_array2.r_enc_element_type_id(i)
3960 ,PSP_ENC_LINES_S.NEXTVAL
3961 ,p_business_group_id
3962 , t_enc_lines_array2.r_encumbrance_date(i)
3963 , t_enc_lines_array2.r_dr_cr_flag(i)
3964 ,round( t_enc_lines_array2.r_encumbrance_amount(i),g_precision) -- introduced rounding for BUg 2916848 Ilo Ehnc.
3965 , t_enc_lines_array2.r_enc_line_type(i)
3966 , t_enc_lines_array2.r_schedule_line_id(i)
3967 , t_enc_lines_array2.r_org_schedule_id(i)
3968 , t_enc_lines_array2.r_default_org_account_id(i)
3969 , t_enc_lines_array2.r_suspense_org_account_id(i)
3970 , t_enc_lines_array2.r_element_account_id(i)
3971 , t_enc_lines_array2.r_gl_project_flag(i)
3972 , t_enc_lines_array2.r_person_id(i)
3973 , t_enc_lines_array2.r_assignment_id(i)
3974 , t_enc_lines_array2.r_award_id(i)
3975 , t_enc_lines_array2.r_task_id(i)
3976 , t_enc_lines_array2.r_expenditure_type(i)
3977 , t_enc_lines_array2.r_expenditure_organization_id(i)
3978 , t_enc_lines_array2.r_project_id(i)
3979 , t_enc_lines_array2.r_gl_code_combination_id(i)
3980 , t_enc_lines_array2.r_time_period_id(i)
3981 , p_payroll_id
3982 , p_set_of_books_id
3983 , t_enc_lines_array2.r_default_reason_code(i)
3984 , t_enc_lines_array2.r_suspense_reason_code(i)
3985 , p_enc_line_type --status_code
3986 , t_enc_lines_array2.r_enc_control_id(i)
3987 , t_enc_lines_array2.r_change_flag(i)
3988 , t_enc_lines_array2.r_enc_start_date(i)
3989 , t_enc_lines_array2.r_enc_end_date(i)
3990 , l_last_update_date
3991 , l_last_updated_by
3992 , l_last_update_login
3993 , l_last_updated_by
3994 , l_last_update_date
3995 , DECODE(t_enc_lines_array2.r_attribute_category(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute_category(i))
3996 , DECODE(t_enc_lines_array2.r_attribute1(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute1(i))
3997 , DECODE(t_enc_lines_array2.r_attribute2(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute2(i))
3998 , DECODE(t_enc_lines_array2.r_attribute3(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute3(i))
3999 , DECODE(t_enc_lines_array2.r_attribute4(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute4(i))
4000 , DECODE(t_enc_lines_array2.r_attribute5(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute5(i))
4001 , DECODE(t_enc_lines_array2.r_attribute6(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute6(i))
4002 , DECODE(t_enc_lines_array2.r_attribute7(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute7(i))
4003 , DECODE(t_enc_lines_array2.r_attribute8(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute8(i))
4004 , DECODE(t_enc_lines_array2.r_attribute9(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute9(i))
4005 , DECODE(t_enc_lines_array2.r_attribute10(i), 'NULL_VALUE', NULL, t_enc_lines_array2.r_attribute10(i))
4006 , g_payroll_action_id
4007 , t_enc_lines_array2.r_orig_gl_code_combination_id(i)
4008 , t_enc_lines_array2.r_orig_project_id(i)
4009 , t_enc_lines_array2.r_orig_task_id(i)
4010 , t_enc_lines_array2.r_orig_award_id(i)
4011 , t_enc_lines_array2.r_orig_expenditure_org_id(i)
4012 , t_enc_lines_array2.r_orig_expenditure_type(i)
4013 , t_enc_lines_array2.r_hierarchy_code(i)
4014 );
4015
4016 DELETE psp_enc_lines
4017 WHERE payroll_id = p_payroll_id
4018 AND business_group_id = p_business_group_id
4019 AND set_of_books_id = p_set_of_books_id
4020 AND encumbrance_amount = 0;
4021
4022 t_enc_lines_array2.r_enc_element_type_id.delete;
4023 t_enc_lines_array2.r_encumbrance_date.delete;
4024 t_enc_lines_array2.r_dr_cr_flag.delete;
4025 t_enc_lines_array2.r_encumbrance_amount.delete;
4026 t_enc_lines_array2.r_enc_line_type.delete;
4027 t_enc_lines_array2.r_schedule_line_id.delete;
4028 t_enc_lines_array2.r_org_schedule_id.delete;
4029 t_enc_lines_array2.r_default_org_account_id.delete;
4030 t_enc_lines_array2.r_suspense_org_account_id.delete;
4031 t_enc_lines_array2.r_element_account_id.delete;
4032 t_enc_lines_array2.r_gl_project_flag.delete;
4033 t_enc_lines_array2.r_person_id.delete;
4034 t_enc_lines_array2.r_assignment_id.delete;
4035 t_enc_lines_array2.r_award_id.delete;
4036 t_enc_lines_array2.r_task_id.delete;
4037 t_enc_lines_array2.r_expenditure_type.delete;
4038 t_enc_lines_array2.r_expenditure_organization_id.delete;
4039 t_enc_lines_array2.r_project_id.delete;
4040 t_enc_lines_array2.r_gl_code_combination_id.delete;
4041 t_enc_lines_array2.r_time_period_id.delete;
4042 t_enc_lines_array2.r_default_reason_code.delete;
4043 t_enc_lines_array2.r_suspense_reason_code.delete;
4044 t_enc_lines_array2.r_enc_control_id.delete;
4045 t_enc_lines_array2.r_change_flag.delete;
4046 t_enc_lines_array2.r_enc_start_date.delete;
4047 t_enc_lines_array2.r_enc_end_date.delete;
4048 t_enc_lines_array2.r_attribute_category.delete;
4049 t_enc_lines_array2.r_attribute1.delete;
4050 t_enc_lines_array2.r_attribute2.delete;
4051 t_enc_lines_array2.r_attribute3.delete;
4052 t_enc_lines_array2.r_attribute4.delete;
4053 t_enc_lines_array2.r_attribute5.delete;
4054 t_enc_lines_array2.r_attribute6.delete;
4055 t_enc_lines_array2.r_attribute7.delete;
4056 t_enc_lines_array2.r_attribute8.delete;
4057 t_enc_lines_array2.r_attribute9.delete;
4058 t_enc_lines_array2.r_attribute10.delete;
4059 t_enc_lines_array2.r_orig_gl_code_combination_id.delete;
4060 t_enc_lines_array2.r_orig_project_id.delete;
4061 t_enc_lines_array2.r_orig_award_id.delete;
4062 t_enc_lines_array2.r_orig_task_id.delete;
4063 t_enc_lines_array2.r_orig_expenditure_type.delete;
4064 t_enc_lines_array2.r_orig_expenditure_org_id.delete;
4065 t_enc_lines_array2.r_hierarchy_code.delete;
4066
4067 p_return_status := fnd_api.g_ret_sts_success;
4068
4069 EXCEPTION
4070 WHEN OTHERS THEN
4071 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
4072 IF (g_error_message IS NULL) THEN
4073 g_error_message := 'INSERT_ENC_LINES_FROM_ARRAYS: ' || SQLERRM;
4074 END IF;
4075 g_error_api_path := SUBSTR(' INSERT_ENC_LINES_FROM_ARRAYS:'||g_error_api_path,1,230);
4076 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', ' INSERT_ENC_LINES_FROM_ARRAYS');
4077 p_return_status := fnd_api.g_ret_sts_unexp_error;
4078 END insert_enc_lines_from_arrays;
4079
4080 -- Introduced the following procedure for bug fix 3462452
4081 PROCEDURE sub_slice_asg_chunk (p_assignment_id IN NUMBER,
4082 p_element_type_id IN NUMBER,
4083 p_business_group_id IN NUMBER,
4084 p_set_of_books_id IN NUMBER,
4085 p_return_status OUT NOCOPY VARCHAR2) IS
4086 TYPE r_sch_hier_type IS RECORD
4087 (start_date t_date_type,
4088 end_date t_date_type,
4089 schedule_percent t_num_15_type);
4090 r_sch_rec r_sch_hier_type;
4091
4092 l_return_status VARCHAR2(1);
4093 l_start_date DATE;
4094 l_end_date DATE;
4095 l_min_start_date DATE DEFAULT r_enc_period.r_asg_start_date(1);
4096 l_max_end_date DATE DEFAULT r_enc_period.r_asg_end_date(r_enc_period.r_asg_end_date.COUNT);
4097 l_schedule_percent NUMBER;
4098 l_new_start_date DATE;
4099 l_new_end_date DATE;
4100 l_process_flag VARCHAR2(10);
4101 l_period_start_date DATE;
4102 l_period_end_date DATE;
4103 l_asg_start_date DATE;
4104 l_asg_end_date DATE;
4105 l_rec_no NUMBER DEFAULT 1;
4106 l_sub_slice_counter NUMBER;
4107 l_run_id NUMBER;
4108 l_period_count NUMBER;
4109 l_schedule_hierarchy_id NUMBER;
4110 l_sch_pointer NUMBER;
4111 l_proc_name VARCHAR2(61) DEFAULT g_package_name || 'SUB_SLICE_ASG_CHUNK';
4112 l_reason_code VARCHAR2(50);
4113 l_proc_step NUMBER(20,10);
4114
4115 r_enc_period_tmp1 enc_period_rectype;
4116
4117 --CURSOR global_element_cur (p_period_start_date IN DATE,
4118 -- p_period_end_date IN DATE,
4119 -- p_asg_start_date IN DATE,
4120 -- p_asg_end_date IN DATE) IS
4121 CURSOR global_element_cur IS
4122 SELECT GREATEST(l_min_start_date, start_date_active) start_date_active,
4123 LEAST(l_max_end_date, end_date_active) end_date_active,
4124 SUM(percent) schedule_percent
4125 FROM psp_element_type_accounts
4126 WHERE business_group_id = p_business_group_id
4127 AND set_of_books_id = p_set_of_books_id
4128 AND element_type_id = p_element_type_id
4129 AND ( gl_code_combination_id IS NOT NULL
4130 OR award_id IS NOT NULL)
4131 AND start_date_active <= l_max_end_date
4132 AND end_date_active >= l_min_start_date
4133 GROUP BY GREATEST(l_min_start_date, start_date_active),
4134 LEAST(l_max_end_date, end_date_active)
4135 ORDER BY start_date_active;
4136
4137 --CURSOR odls_cur (p_asg_start_date IN DATE,
4138 -- p_asg_end_date IN DATE) IS
4139 CURSOR odls_cur IS
4140 SELECT GREATEST(l_min_start_date, paf.effective_start_date, schedule_begin_date) schedule_begin_date,
4141 LEAST(l_max_end_date, paf.effective_end_date, schedule_end_date) schedule_end_date,
4142 SUM(schedule_percent) schedule_percent
4143 FROM per_assignments_f paf,
4144 psp_default_labor_schedules pdls
4145 WHERE paf.assignment_id = p_assignment_id
4146 AND l_min_start_date <= paf.effective_end_date
4147 AND l_max_end_date >= paf.effective_start_date
4148 AND paf.organization_id = pdls.organization_id
4149 AND pdls.business_group_id = p_business_group_id
4150 AND pdls.set_of_books_id = p_set_of_books_id
4151 AND ( gl_code_combination_id IS NOT NULL
4152 OR award_id IS NOT NULL)
4153 AND schedule_begin_date <= l_max_end_date
4154 AND schedule_end_date >= l_min_start_date
4155 GROUP BY GREATEST(l_min_start_date, paf.effective_start_date, schedule_begin_date),
4156 LEAST(l_max_end_date, paf.effective_end_date, schedule_end_date)
4157 ORDER BY 1;
4158
4159 CURSOR ls_hier_cur (p_scheduling_types_code IN VARCHAR2) IS
4160 SELECT psh.schedule_hierarchy_id
4161 FROM psp_schedule_hierarchy psh
4162 WHERE psh.business_group_id = p_business_group_id
4163 AND psh.set_of_books_id = p_set_of_books_id
4164 AND psh.scheduling_types_code = p_scheduling_types_code
4165 AND ( (p_scheduling_types_code = 'ET' AND psh.element_type_id = p_element_type_id)
4166 OR (p_scheduling_types_code = 'A'))
4167 AND psh.assignment_id = p_assignment_id;
4168
4169 /***** Modified the following cursor for 11510_CU2 consolidated performance fixes.
4170 CURSOR eg_hier_cur IS
4171 SELECT DISTINCT schedule_hierarchy_id
4172 FROM psp_schedule_hierarchy psh,
4173 psp_element_groups peg,
4174 psp_group_element_list pgel
4175 WHERE psh.business_group_id = p_business_group_id
4176 AND psh.set_of_books_id = p_set_of_books_id
4177 AND peg.business_group_id = p_business_group_id
4178 AND peg.set_of_books_id = p_set_of_books_id
4179 AND psh.scheduling_types_code = 'EG'
4180 AND psh.element_group_id = peg.element_group_id
4181 AND peg.end_date_active >= r_enc_period.r_period_start_date(1)
4182 AND peg.start_date_active <= r_enc_period.r_period_end_date(l_period_count)
4183 AND pgel.element_type_id = p_element_type_id
4184 AND psh.assignment_id = p_assignment_id;
4185 End of comment for 11510_CU2 consloidated performance fixes. *****/
4186
4187 -- Modified cursor for 11510_CU2 consloidated performance fixes.
4188 CURSOR eg_hier_cur IS
4189 SELECT schedule_hierarchy_id
4190 FROM psp_schedule_hierarchy psh
4191 WHERE EXISTS (SELECT 1
4192 FROM psp_element_groups peg,
4193 psp_group_element_list pgel
4194 WHERE peg.business_group_id = p_business_group_id
4195 AND peg.set_of_books_id = p_set_of_books_id
4196 AND peg.end_date_active >= r_enc_period.r_period_start_date(1)
4197 AND peg.start_date_active <= r_enc_period.r_period_end_date(l_period_count)
4198 AND peg.element_group_id = psh.element_group_id
4199 AND peg.element_group_id = pgel.element_group_id -- Added for Bug 10113387
4200 AND pgel.element_type_id = p_element_type_id)
4201 AND psh.business_group_id = p_business_group_id
4202 AND psh.set_of_books_id = p_set_of_books_id
4203 AND psh.scheduling_types_code = 'EG'
4204 AND psh.assignment_id = p_assignment_id;
4205
4206
4207 CURSOR ls_matrix_cur IS
4208 SELECT GREATEST(l_min_start_date, period_start_date) period_start_date,
4209 LEAST(l_max_end_date, period_end_date) period_end_date,
4210 SUM(period_schedule_percent) schedule_percent
4211 FROM psp_matrix_driver pmd
4212 WHERE run_id = l_run_id
4213 AND period_start_date <= l_max_end_date
4214 AND period_end_date >= l_min_start_date
4215 GROUP BY GREATEST(l_min_start_date, period_start_date),
4216 LEAST(l_max_end_date, period_end_date)
4217 ORDER BY 1;
4218
4219 CURSOR eg_matrix_cur IS
4220 SELECT GREATEST(l_min_start_date, peg.start_date_active, period_start_date) period_start_date,
4221 LEAST(l_max_end_date, peg.end_date_active, period_end_date) period_end_date,
4222 SUM(period_schedule_percent) schedule_percent
4223 FROM psp_matrix_driver pmd,
4224 psp_schedule_lines psl,
4225 psp_schedule_hierarchy psh,
4226 psp_element_groups peg
4227 WHERE run_id = l_run_id
4228 AND psl.schedule_line_id = pmd.schedule_line_id
4229 AND psl.schedule_hierarchy_id = psh.schedule_hierarchy_id
4230 AND psh.element_group_id = peg.element_group_id
4231 AND peg.start_date_active <= l_max_end_date
4232 AND peg.end_date_active >= l_min_start_date
4233 AND period_start_date <= l_max_end_date
4234 AND period_end_date >= l_min_start_date
4235 AND ( gl_code_combination_id IS NOT NULL
4236 OR award_id IS NOT NULL)
4237 GROUP BY GREATEST(l_min_start_date, peg.start_date_active, period_start_date),
4238 LEAST(l_max_end_date, peg.end_date_active, period_end_date)
4239 ORDER BY 1;
4240
4241 -- Introduced the following for bug fix 3970852
4242 TYPE t_date IS TABLE OF DATE INDEX BY BINARY_INTEGER;
4243 TYPE t_char IS TABLE OF CHAR INDEX BY BINARY_INTEGER;
4244 initial_dates t_date;
4245 date_type t_char;
4246
4247 TYPE schedule_chunk_rec IS RECORD
4248 (schedule_begin_date t_date,
4249 schedule_end_date t_date);
4250 schedule_chunk schedule_chunk_rec;
4251
4252 CURSOR sched_lines(schedule_hierarchy_id NUMBER) IS
4253 SELECT schedule_line_id l_id,
4254 schedule_begin_date sbd,
4255 schedule_end_date sed,
4256 schedule_percent sp
4257 FROM psp_schedule_lines
4258 WHERE schedule_hierarchy_id = schedule_hierarchy_id
4259 AND ( gl_code_combination_id IS NOT NULL
4260 OR award_id IS NOT NULL)
4261 AND schedule_end_date >= l_min_start_date
4262 AND schedule_begin_date <= l_max_end_date;
4263
4264 CURSOR dates(p_schedule_hierarchy_id NUMBER) IS
4265 SELECT schedule_begin_date dat , 'B'
4266 FROM psp_schedule_lines
4267 WHERE schedule_hierarchy_id = p_schedule_hierarchy_id
4268 AND ( gl_code_combination_id IS NOT NULL
4269 OR award_id IS NOT NULL)
4270 AND schedule_end_date >= l_min_start_date
4271 AND schedule_begin_date <= l_max_end_date
4272 UNION
4273 SELECT schedule_end_date dat , 'E'
4274 FROM psp_schedule_lines
4275 WHERE schedule_hierarchy_id = p_schedule_hierarchy_id
4276 AND ( gl_code_combination_id IS NOT NULL
4277 OR award_id IS NOT NULL)
4278 AND schedule_end_date >= l_min_start_date
4279 AND schedule_begin_date <= l_max_end_date
4280 ORDER BY 1, 2 ;
4281
4282 recno INTEGER;
4283 -- End of bug fix 3970852
4284 BEGIN
4285 psp_matrix_driver_pkg.set_runid;
4286 l_run_id := psp_matrix_driver_pkg.get_run_id;
4287
4288 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering ' || l_proc_name);
4289 hr_utility.trace('p_assignment_id: ' || fnd_number.number_to_canonical(p_assignment_id) ||
4290 ' p_element_type_id: ' || fnd_number.number_to_canonical(p_element_type_id) ||
4291 ' p_business_group_id: ' || fnd_number.number_to_canonical(p_business_group_id) ||
4292 ' p_set_of_books_id: ' || fnd_number.number_to_canonical(p_set_of_books_id) ||
4293 ' r_enc_period.r_time_period_id.COUNT: ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id.COUNT));
4294 hr_utility.trace('Dumping Assignment Chunk Before Global Element Processing ...');
4295 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
4296 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
4297 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
4298 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
4299 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
4300 RPAD('Reason Code', 50, ' '));
4301
4302 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
4303 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
4304 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
4305 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
4306 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
4307 RPAD('-', 50, '-'));
4308
4309 FOR recno IN 1..r_enc_period.r_time_period_id.COUNT
4310 LOOP
4311 hr_utility.trace(LPAD(recno, 13, ' ') || ' ' ||
4312 LPAD(r_enc_period.r_time_period_id(recno), 14, ' ') || ' ' ||
4313 RPAD(TO_CHAR(r_enc_period.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
4314 RPAD(TO_CHAR(r_enc_period.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
4315 RPAD(TO_CHAR(r_enc_period.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
4316 RPAD(TO_CHAR(r_enc_period.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
4317 RPAD(TO_CHAR(r_enc_period.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
4318 RPAD(r_enc_period.r_process_flag(recno), 12, ' ') || ' ' ||
4319 LPAD(r_enc_period.r_schedule_percent(recno), 16, ' ') || ' ' ||
4320 RPAD(r_enc_period.r_reason_code(recno), 50, ' '));
4321 END LOOP;
4322 hr_utility.trace('Global Element Processing');
4323
4324 l_proc_step := 10;
4325 l_sch_pointer := 1;
4326
4327 OPEN global_element_cur;
4328 FETCH global_element_cur BULK COLLECT INTO r_sch_rec.start_date, r_sch_rec.end_date, r_sch_rec.schedule_percent;
4329 CLOSE global_element_cur;
4330
4331 hr_utility.trace('r_sch_rec.start_date.COUNT: ' || r_sch_rec.start_date.COUNT);
4332 hr_utility.trace('Schedule Chunk Details');
4333 hr_utility.trace(RPAD('Start Date', 15, ' ') || ' ' ||
4334 RPAD('End Date', 15, ' ') || ' ' || LPAD('Schedule Percent', 16, ' '));
4335
4336 hr_utility.trace(RPAD('-', 15, '-') || ' ' ||
4337 RPAD('-', 15, '-') || ' ' || RPAD('-', 16, '-'));
4338
4339 FOR recno IN 1..r_sch_rec.start_date.COUNT
4340 LOOP
4341 hr_utility.trace(RPAD(TO_CHAR(r_sch_rec.start_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
4342 RPAD(TO_CHAR(r_sch_rec.end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
4343 LPAD(r_sch_rec.schedule_percent(recno), 16, ' '));
4344 END LOOP;
4345
4346 FOR I IN 1..r_enc_period.r_time_period_id.COUNT
4347 LOOP
4348 l_period_start_date := r_enc_period.r_period_start_date(I);
4349 l_period_end_date := r_enc_period.r_period_end_date(I);
4350 l_asg_start_date := r_enc_period.r_asg_start_date(I);
4351 l_asg_end_date := r_enc_period.r_asg_end_date(I);
4352 l_sub_slice_counter := 1;
4353 l_proc_step := 20 + (I / 100000);
4354
4355 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
4356 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
4357 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
4358 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
4359 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
4360 ' r_enc_period.r_time_period_id(I): ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id(I)) ||
4361 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no));
4362
4363 IF (r_sch_rec.end_date.COUNT > 0) THEN
4364 FOR ge_recno IN l_sch_pointer..r_sch_rec.start_date.COUNT
4365 LOOP
4366 l_start_date:= r_sch_rec.start_date(ge_recno);
4367 l_end_date:= r_sch_rec.end_date(ge_recno);
4368 l_schedule_percent:= r_sch_rec.schedule_percent(ge_recno);
4369 l_proc_step := 30 + (ge_recno / 100000);
4370 -- OPEN global_element_cur(l_period_start_date, l_period_end_date, l_asg_start_date, l_asg_end_date);
4371 -- FETCH global_element_cur INTO l_start_date, l_end_date, l_schedule_percent;
4372
4373 hr_utility.trace('l_sub_slice_counter: ' || fnd_number.number_to_canonical(l_sub_slice_counter) ||
4374 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no) ||
4375 ' l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
4376 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
4377 ' l_schedule_percent: ' || fnd_number.number_to_canonical(l_schedule_percent));
4378 -- hr_utility.trace('global_element_cur%ROWCOUNT: ' || fnd_number.number_to_canonical(global_element_cur%ROWCOUNT));
4379
4380 -- IF (global_element_cur%NOTFOUND) THEN
4381 IF (l_start_date > l_asg_end_date) THEN
4382 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4383 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4384 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4385 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4386 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4387 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4388 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4389 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
4390 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4391 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4392 l_rec_no := l_rec_no + 1;
4393 EXIT;
4394 END IF;
4395 -- CLOSE global_element_cur;
4396 -- EXIT;
4397 -- END IF;
4398 -- CLOSE global_element_cur;
4399
4400 IF (l_end_date >= l_asg_start_date) AND (l_start_date <= l_asg_end_date) THEN
4401 IF (l_asg_start_date = l_start_date AND l_asg_end_date = l_end_date) THEN
4402 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4403 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4404 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4405 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4406 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4407 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4408 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4409 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'GE';
4410 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4411 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4412 l_rec_no := l_rec_no + 1;
4413 IF (l_schedule_percent < 100) THEN
4414 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4415 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4416 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4417 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4418 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4419 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4420 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4421 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
4422 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
4423 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4424 l_rec_no := l_rec_no + 1;
4425 END IF;
4426 EXIT;
4427 ELSE
4428 IF (l_start_date > GREATEST(l_period_start_date, l_asg_start_date)) THEN
4429 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date);
4430 l_new_end_date := l_start_date - 1;
4431 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4432 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4433 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4434 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
4435 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
4436 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4437 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4438 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
4439 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4440 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4441 l_rec_no := l_rec_no + 1;
4442 l_asg_start_date := l_start_date;
4443 END IF;
4444
4445 IF (l_end_date < LEAST(l_period_end_date, l_asg_end_date)) THEN
4446 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date, l_start_date);
4447 l_new_end_date := l_end_date;
4448 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4449 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4450 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4451 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
4452 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
4453 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4454 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4455 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'GE';
4456 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4457 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4458 l_rec_no := l_rec_no + 1;
4459 IF (l_schedule_percent < 100) THEN
4460 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4461 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4462 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4463 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
4464 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
4465 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4466 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4467 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
4468 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
4469 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4470 l_rec_no := l_rec_no + 1;
4471 END IF;
4472 l_asg_start_date := l_end_date + 1;
4473 IF (ge_recno = r_sch_rec.start_date.COUNT) AND
4474 (l_asg_start_date <= l_asg_end_date) THEN
4475 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4476 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4477 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4478 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4479 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4480 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4481 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4482 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
4483 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4484 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4485 l_rec_no := l_rec_no + 1;
4486 END IF;
4487 ELSE
4488 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4489 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4490 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4491 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4492 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4493 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4494 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4495 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'GE';
4496 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4497 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4498 l_rec_no := l_rec_no + 1;
4499 IF (l_schedule_percent < 100) THEN
4500 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4501 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4502 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4503 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4504 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4505 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4506 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4507 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
4508 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
4509 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4510 l_rec_no := l_rec_no + 1;
4511 END IF;
4512 l_asg_start_date := l_end_date + 1;
4513 END IF;
4514 END IF;
4515 l_sub_slice_counter := 2;
4516 ELSE
4517 IF (ge_recno = r_sch_rec.start_date.COUNT) THEN
4518 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4519 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
4520 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
4521 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
4522 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
4523 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4524 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4525 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
4526 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4527 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4528 l_rec_no := l_rec_no + 1;
4529 END IF;
4530 END IF;
4531 l_sch_pointer := ge_recno;
4532 EXIT WHEN l_asg_start_date > l_asg_end_date;
4533 END LOOP;
4534 ELSE
4535 r_enc_period_tmp1.r_period_ind(l_rec_no) := I;
4536 r_enc_period_tmp1.r_period_start_date(l_rec_no) := r_enc_period.r_period_start_date(I);
4537 r_enc_period_tmp1.r_period_end_date(l_rec_no) := r_enc_period.r_period_end_date(I);
4538 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := r_enc_period.r_asg_start_date(I);
4539 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := r_enc_period.r_asg_end_date(I);
4540 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
4541 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
4542 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
4543 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
4544 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
4545 l_rec_no := l_rec_no + 1;
4546 END IF;
4547 END LOOP;
4548
4549 r_sch_rec.start_date.delete;
4550 r_sch_rec.end_date.delete;
4551 r_sch_rec.schedule_percent.delete;
4552 r_enc_period.r_time_period_id.DELETE;
4553 r_enc_period.r_period_start_date.DELETE;
4554 r_enc_period.r_period_end_date.DELETE;
4555 r_enc_period.r_asg_start_date.DELETE;
4556 r_enc_period.r_asg_end_date.DELETE;
4557 r_enc_period.r_process_flag.DELETE;
4558 r_enc_period.r_period_ind.DELETE;
4559 r_enc_period.r_schedule_percent.DELETE;
4560 r_enc_period.r_encumbrance_amount.DELETE;
4561 r_enc_period.r_period_amount.DELETE;
4562 r_enc_period.r_reason_code.DELETE;
4563 r_enc_period.r_effective_date.DELETE;
4564 l_rec_no := 1;
4565 l_proc_step := 40;
4566
4567 hr_utility.trace('Dumping Assignment Chunk After Global Element Processing ...');
4568 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
4569 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
4570 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
4571 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
4572 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
4573 RPAD('Reason Code', 50, ' '));
4574
4575 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
4576 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
4577 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
4578 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
4579 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
4580 RPAD('-', 50, '-'));
4581
4582 FOR recno IN 1..r_enc_period_tmp1.r_time_period_id.COUNT
4583 LOOP
4584 hr_utility.trace(LPAD(recno, 13, ' ') || ' ' ||
4585 LPAD(r_enc_period_tmp1.r_time_period_id(recno), 14, ' ') || ' ' ||
4586 RPAD(TO_CHAR(r_enc_period_tmp1.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
4587 RPAD(TO_CHAR(r_enc_period_tmp1.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
4588 RPAD(TO_CHAR(r_enc_period_tmp1.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
4589 RPAD(TO_CHAR(r_enc_period_tmp1.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
4590 RPAD(TO_CHAR(r_enc_period_tmp1.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
4591 RPAD(r_enc_period_tmp1.r_process_flag(recno), 12, ' ') || ' ' ||
4592 LPAD(r_enc_period_tmp1.r_schedule_percent(recno), 16, ' ') || ' ' ||
4593 RPAD(r_enc_period_tmp1.r_reason_code(recno), 50, ' '));
4594 END LOOP;
4595 hr_utility.trace('Element Type Processing ...');
4596
4597 OPEN ls_hier_cur('ET');
4598 FETCH ls_hier_cur INTO l_schedule_hierarchy_id;
4599 CLOSE ls_hier_cur;
4600
4601 /***** Commented for bug fix 3970852 to resolve issues when schedule dates equal default end date
4602 psp_matrix_driver_pkg.clear_table('REFRESH');
4603 psp_matrix_driver_pkg.purge_table;
4604 psp_matrix_driver_pkg.load_table(l_schedule_hierarchy_id);
4605
4606 DELETE psp_matrix_driver
4607 WHERE run_id = l_run_id
4608 AND (period_start_date > l_max_end_date
4609 OR period_end_date < l_min_start_date
4610 OR period_schedule_percent = 0);
4611
4612 UPDATE psp_matrix_driver pmd
4613 SET period_end_date = period_end_date - 1
4614 WHERE run_id = l_run_id
4615 AND period_start_date < period_end_date
4616 AND period_start_date = (SELECT MIN(psl1.schedule_begin_date)
4617 FROM psp_schedule_lines psl1
4618 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
4619 AND EXISTS (SELECT 1
4620 FROM psp_schedule_lines psl1
4621 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
4622 AND psl1.schedule_begin_date = pmd.period_end_date
4623 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
4624
4625 UPDATE psp_matrix_driver pmd
4626 SET period_end_date = period_end_date - 1
4627 WHERE run_id = l_run_id
4628 AND period_start_date < period_end_date
4629 AND NOT (NOT EXISTS (SELECT 1
4630 FROM psp_schedule_lines psl1
4631 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
4632 AND psl1.schedule_begin_date = pmd.period_end_date
4633 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
4634 AND EXISTS (SELECT 1
4635 FROM psp_schedule_lines psl1
4636 WHERE psl1.schedule_end_date = pmd.period_end_date
4637 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id))
4638 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
4639 FROM psp_schedule_lines psl1
4640 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
4641
4642 UPDATE psp_matrix_driver pmd
4643 SET period_start_date = period_start_date + 1
4644 WHERE run_id = l_run_id
4645 AND period_start_date < period_end_date
4646 AND NOT EXISTS (SELECT 1
4647 FROM psp_schedule_lines psl1
4648 WHERE psl1.schedule_begin_date = pmd.period_start_date
4649 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
4650 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
4651 FROM psp_schedule_lines psl1
4652 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
4653
4654 UPDATE psp_matrix_driver pmd
4655 SET period_start_date = period_start_date + 1
4656 WHERE run_id = l_run_id
4657 AND period_start_date < period_end_date
4658 AND EXISTS (SELECT 1
4659 FROM psp_schedule_lines psl1
4660 WHERE psl1.schedule_begin_date = pmd.period_start_date
4661 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
4662 AND EXISTS (SELECT 1
4663 FROM psp_schedule_lines psl1
4664 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
4665 AND psl1.schedule_end_date = pmd.period_start_date
4666 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
4667 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
4668 FROM psp_schedule_lines psl1
4669 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
4670 End of comment for bug fix 3970852 *****/
4671
4672 -- Introduced the following to prepare schedule chunk dates instead of load_table for bug fix 3970852
4673 recno := 1;
4674
4675 OPEN dates(l_schedule_hierarchy_id);
4676 FETCH dates BULK COLLECT INTO initial_dates, date_type;
4677 CLOSE dates;
4678
4679 FOR rowno IN 1..(initial_dates.COUNT - 1)
4680 LOOP
4681 IF (date_type(rowno) = 'B' AND date_type(rowno+1) = 'B') THEN
4682 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno);
4683 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1) - 1;
4684 recno := recno+1;
4685 ELSIF (date_type(rowno) = 'B' AND date_type(rowno+1) = 'E') THEN
4686 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno);
4687 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1);
4688 recno := recno+1;
4689 ELSIF (date_type(rowno) = 'E' AND date_type(rowno+1) = 'E') THEN
4690 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno) + 1;
4691 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1);
4692 recno := recno+1;
4693 ELSIF (date_type(rowno) = 'E' AND date_type(rowno+1) = 'B') THEN
4694 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno) + 1;
4695 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1) -1;
4696 recno := recno+1;
4697 END IF;
4698 END LOOP;
4699
4700 FORALL rowno IN 1..schedule_chunk.schedule_begin_date.COUNT
4701 INSERT INTO psp_matrix_driver
4702 (RUN_ID, SCHEDULE_LINE_ID,
4703 PERIOD_START_DATE,
4704 PERIOD_END_DATE,
4705 PERIOD_SCHEDULE_PERCENT)
4706 SELECT l_run_id, schedule_line_id,
4707 GREATEST(l_min_start_date, schedule_chunk.schedule_begin_date(rowno)),
4708 LEAST(l_max_end_date, schedule_chunk.schedule_end_date(rowno)),
4709 schedule_percent
4710 FROM psp_schedule_lines psl
4711 WHERE schedule_hierarchy_id = l_schedule_hierarchy_id
4712 AND schedule_end_date >= l_min_start_date
4713 AND schedule_begin_date <= l_max_end_date
4714 AND ( gl_code_combination_id IS NOT NULL
4715 OR award_id IS NOT NULL)
4716 AND psl.schedule_begin_date <= schedule_chunk.schedule_end_date(rowno)
4717 AND psl.schedule_end_date >= schedule_chunk.schedule_begin_date(rowno);
4718
4719 initial_dates.delete;
4720 date_type.delete;
4721 schedule_chunk.schedule_end_date.delete;
4722 schedule_chunk.schedule_begin_date.delete;
4723 -- End of bug fix 3970852
4724
4725 l_sch_pointer := 1;
4726 OPEN ls_matrix_cur;
4727 FETCH ls_matrix_cur BULK COLLECT INTO r_sch_rec.start_date, r_sch_rec.end_date, r_sch_rec.schedule_percent;
4728 CLOSE ls_matrix_cur;
4729
4730 hr_utility.trace('r_sch_rec.start_date.COUNT: ' || r_sch_rec.start_date.COUNT);
4731 hr_utility.trace('Schedule Chunk Details');
4732 hr_utility.trace(RPAD('Start Date', 15, ' ') || ' ' ||
4733 RPAD('End Date', 15, ' ') || ' ' || LPAD('Schedule Percent', 16, ' '));
4734 hr_utility.trace(RPAD('-', 15, '-') || ' ' ||
4735 RPAD('-', 15, '-') || ' ' || RPAD('-', 16, '-'));
4736
4737 FOR recno IN 1..r_sch_rec.start_date.COUNT
4738 LOOP
4739 hr_utility.trace(RPAD(TO_CHAR(r_sch_rec.start_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
4740 RPAD(TO_CHAR(r_sch_rec.end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
4741 LPAD(r_sch_rec.schedule_percent(recno), 16, ' '));
4742 END LOOP;
4743
4744 FOR I IN 1..r_enc_period_tmp1.r_time_period_id.COUNT
4745 LOOP
4746 l_period_start_date := r_enc_period_tmp1.r_period_start_date(I);
4747 l_period_end_date := r_enc_period_tmp1.r_period_end_date(I);
4748 l_asg_start_date := r_enc_period_tmp1.r_asg_start_date(I);
4749 l_asg_end_date := r_enc_period_tmp1.r_asg_end_date(I);
4750 l_process_flag := r_enc_period_tmp1.r_process_flag(I);
4751 l_sub_slice_counter := 1;
4752 l_proc_step := 50 + (I / 100000);
4753
4754 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
4755 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
4756 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
4757 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
4758 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
4759 ' r_enc_period_tmp1.r_time_period_id(I): ' || fnd_number.number_to_canonical(r_enc_period_tmp1.r_time_period_id(I)) ||
4760 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no));
4761
4762 IF (l_process_flag = 'Y') AND (r_sch_rec.end_date.COUNT > 0) THEN
4763 FOR et_recno IN l_sch_pointer..r_sch_rec.start_date.COUNT
4764 LOOP
4765 l_start_date:= r_sch_rec.start_date(et_recno);
4766 l_end_date:= r_sch_rec.end_date(et_recno);
4767 l_schedule_percent:= r_sch_rec.schedule_percent(et_recno);
4768 l_proc_step := 60 + (et_recno / 100000);
4769
4770 hr_utility.trace(' l_sub_slice_counter: ' || fnd_number.number_to_canonical(l_sub_slice_counter) ||
4771 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no) ||
4772 ' l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
4773 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
4774 ' l_schedule_percent: ' || fnd_number.number_to_canonical(l_schedule_percent));
4775
4776 -- OPEN ls_matrix_cur;
4777 -- FETCH ls_matrix_cur INTO l_start_date, l_end_date, l_schedule_percent;
4778 -- IF (ls_matrix_cur%NOTFOUND) THEN
4779 IF (l_start_date > l_asg_end_date) THEN
4780 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4781 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4782 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4783 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
4784 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
4785 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4786 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4787 r_enc_period.r_process_flag(l_rec_no) := 'Y';
4788 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
4789 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4790 l_rec_no := l_rec_no + 1;
4791 EXIT;
4792 END IF;
4793 -- CLOSE ls_matrix_cur;
4794 -- EXIT;
4795 -- END IF;
4796 -- CLOSE ls_matrix_cur;
4797
4798 IF (l_end_date >= l_asg_start_date) AND (l_start_date <= l_asg_end_date) THEN
4799 IF (l_asg_start_date = l_start_date AND l_asg_end_date = l_end_date) THEN
4800 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4801 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4802 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4803 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
4804 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
4805 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4806 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4807 r_enc_period.r_process_flag(l_rec_no) := 'ET';
4808 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
4809 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4810 l_rec_no := l_rec_no + 1;
4811 IF (l_schedule_percent < 100) THEN
4812 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4813 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4814 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4815 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
4816 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
4817 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4818 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4819 r_enc_period.r_process_flag(l_rec_no) := 'BAL';
4820 r_enc_period.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
4821 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4822 l_rec_no := l_rec_no + 1;
4823 END IF;
4824 EXIT;
4825 ELSE
4826 IF (l_start_date > GREATEST(l_period_start_date, l_asg_start_date)) THEN
4827 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date);
4828 l_new_end_date := l_start_date - 1;
4829 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4830 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4831 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4832 r_enc_period.r_asg_start_date(l_rec_no) := l_new_start_date;
4833 r_enc_period.r_asg_end_date(l_rec_no) := l_new_end_date;
4834 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4835 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4836 r_enc_period.r_process_flag(l_rec_no) := 'Y';
4837 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
4838 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4839 l_rec_no := l_rec_no + 1;
4840 l_asg_start_date := l_start_date;
4841 END IF;
4842
4843 IF (l_end_date < LEAST(l_period_end_date, l_asg_end_date)) THEN
4844 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date, l_start_date);
4845 l_new_end_date := l_end_date;
4846 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4847 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4848 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4849 r_enc_period.r_asg_start_date(l_rec_no) := l_new_start_date;
4850 r_enc_period.r_asg_end_date(l_rec_no) := l_new_end_date;
4851 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4852 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4853 r_enc_period.r_process_flag(l_rec_no) := 'ET';
4854 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
4855 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4856 l_rec_no := l_rec_no + 1;
4857 IF (l_schedule_percent < 100) THEN
4858 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4859 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4860 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4861 r_enc_period.r_asg_start_date(l_rec_no) := l_new_start_date;
4862 r_enc_period.r_asg_end_date(l_rec_no) := l_new_end_date;
4863 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4864 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4865 r_enc_period.r_process_flag(l_rec_no) := 'BAL';
4866 r_enc_period.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
4867 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4868 l_rec_no := l_rec_no + 1;
4869 END IF;
4870 l_asg_start_date := l_end_date + 1;
4871 IF (et_recno = r_sch_rec.start_date.COUNT) AND
4872 (l_asg_start_date <= l_asg_end_date) THEN
4873 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4874 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4875 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4876 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
4877 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
4878 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4879 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4880 r_enc_period.r_process_flag(l_rec_no) := 'Y';
4881 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
4882 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4883 l_rec_no := l_rec_no + 1;
4884 END IF;
4885 ELSE
4886 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4887 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4888 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4889 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
4890 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
4891 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4892 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4893 r_enc_period.r_process_flag(l_rec_no) := 'ET';
4894 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
4895 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4896 l_rec_no := l_rec_no + 1;
4897 IF (l_schedule_percent < 100) THEN
4898 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4899 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
4900 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
4901 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
4902 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
4903 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4904 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4905 r_enc_period.r_process_flag(l_rec_no) := 'BAL';
4906 r_enc_period.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
4907 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4908 l_rec_no := l_rec_no + 1;
4909 END IF;
4910 l_asg_start_date := l_end_date + 1;
4911 END IF;
4912 END IF;
4913 l_sub_slice_counter := 2;
4914 ELSE
4915 IF (et_recno = r_sch_rec.start_date.COUNT) THEN
4916 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4917 r_enc_period.r_period_start_date(l_rec_no) := r_enc_period_tmp1.r_period_start_date(I);
4918 r_enc_period.r_period_end_date(l_rec_no) := r_enc_period_tmp1.r_period_end_date(I);
4919 r_enc_period.r_asg_start_date(l_rec_no) := r_enc_period_tmp1.r_asg_start_date(I);
4920 r_enc_period.r_asg_end_date(l_rec_no) := r_enc_period_tmp1.r_asg_end_date(I);
4921 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4922 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4923 r_enc_period.r_process_flag(l_rec_no) := r_enc_period_tmp1.r_process_flag(I);
4924 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
4925 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4926 l_rec_no := l_rec_no + 1;
4927 END IF;
4928 END IF;
4929 l_sch_pointer := et_recno;
4930 EXIT WHEN l_asg_start_date > l_asg_end_date;
4931 END LOOP;
4932 ELSE
4933 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
4934 r_enc_period.r_period_start_date(l_rec_no) := r_enc_period_tmp1.r_period_start_date(I);
4935 r_enc_period.r_period_end_date(l_rec_no) := r_enc_period_tmp1.r_period_end_date(I);
4936 r_enc_period.r_asg_start_date(l_rec_no) := r_enc_period_tmp1.r_asg_start_date(I);
4937 r_enc_period.r_asg_end_date(l_rec_no) := r_enc_period_tmp1.r_asg_end_date(I);
4938 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
4939 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
4940 r_enc_period.r_process_flag(l_rec_no) := r_enc_period_tmp1.r_process_flag(I);
4941 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
4942 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
4943 l_rec_no := l_rec_no + 1;
4944 END IF;
4945 END LOOP;
4946
4947 r_sch_rec.start_date.delete;
4948 r_sch_rec.end_date.delete;
4949 r_sch_rec.schedule_percent.delete;
4950 r_enc_period_tmp1.r_time_period_id.DELETE;
4951 r_enc_period_tmp1.r_period_start_date.DELETE;
4952 r_enc_period_tmp1.r_period_end_date.DELETE;
4953 r_enc_period_tmp1.r_asg_start_date.DELETE;
4954 r_enc_period_tmp1.r_asg_end_date.DELETE;
4955 r_enc_period_tmp1.r_process_flag.DELETE;
4956 r_enc_period_tmp1.r_period_ind.DELETE;
4957 r_enc_period_tmp1.r_schedule_percent.DELETE;
4958 r_enc_period_tmp1.r_encumbrance_amount.DELETE;
4959 r_enc_period_tmp1.r_period_amount.DELETE;
4960 r_enc_period_tmp1.r_reason_code.DELETE;
4961 r_enc_period_tmp1.r_effective_date.DELETE;
4962 l_rec_no := 1;
4963 l_proc_step := 70;
4964
4965 hr_utility.trace('Dumping Assignment Chunk After Element Type Processing ...');
4966 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
4967 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
4968 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
4969 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
4970 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
4971 RPAD('Reason Code', 50, ' '));
4972 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
4973 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
4974 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
4975 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
4976 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
4977 RPAD('-', 50, '-'));
4978
4979 FOR recno IN 1..r_enc_period.r_time_period_id.COUNT
4980 LOOP
4981 hr_utility.trace(LPAD(r_enc_period.r_period_ind(recno), 13, ' ') || ' ' ||
4982 LPAD(r_enc_period.r_time_period_id(recno), 14, ' ') || ' ' ||
4983 RPAD(TO_CHAR(r_enc_period.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
4984 RPAD(TO_CHAR(r_enc_period.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
4985 RPAD(TO_CHAR(r_enc_period.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
4986 RPAD(TO_CHAR(r_enc_period.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
4987 RPAD(TO_CHAR(r_enc_period.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
4988 RPAD(r_enc_period.r_process_flag(recno), 12, ' ') || ' ' ||
4989 LPAD(r_enc_period.r_schedule_percent(recno), 16, ' ') || ' ' ||
4990 RPAD(r_enc_period.r_reason_code(recno), 50, ' '));
4991 END LOOP;
4992 hr_utility.trace('Element Group Processing ...');
4993
4994 psp_matrix_driver_pkg.clear_table('REFRESH');
4995 psp_matrix_driver_pkg.purge_table;
4996 l_period_count := r_enc_period.r_time_period_id.COUNT;
4997 OPEN eg_hier_cur;
4998 LOOP
4999 FETCH eg_hier_cur INTO l_schedule_hierarchy_id;
5000 EXIT WHEN eg_hier_cur%NOTFOUND;
5001
5002 /***** Commented for bug fix 3970852 to resolve issues when schedule dates equal default end date
5003 psp_matrix_driver_pkg.load_table(l_schedule_hierarchy_id);
5004
5005 DELETE psp_matrix_driver
5006 WHERE run_id = l_run_id
5007 AND (period_start_date > l_max_end_date
5008 OR period_end_date < l_min_start_date
5009 OR period_schedule_percent = 0);
5010
5011 UPDATE psp_matrix_driver pmd
5012 SET period_end_date = period_end_date - 1
5013 WHERE run_id = l_run_id
5014 AND period_start_date < period_end_date
5015 AND period_start_date = (SELECT MIN(psl1.schedule_begin_date)
5016 FROM psp_schedule_lines psl1
5017 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
5018 AND EXISTS (SELECT 1
5019 FROM psp_schedule_lines psl1
5020 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
5021 AND psl1.schedule_begin_date = pmd.period_end_date
5022 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
5023
5024 UPDATE psp_matrix_driver pmd
5025 SET period_end_date = period_end_date - 1
5026 WHERE run_id = l_run_id
5027 AND period_start_date < period_end_date
5028 AND NOT (NOT EXISTS (SELECT 1
5029 FROM psp_schedule_lines psl1
5030 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
5031 AND psl1.schedule_begin_date = pmd.period_end_date
5032 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
5033 AND EXISTS (SELECT 1
5034 FROM psp_schedule_lines psl1
5035 WHERE psl1.schedule_end_date = pmd.period_end_date
5036 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id))
5037 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
5038 FROM psp_schedule_lines psl1
5039 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
5040
5041 UPDATE psp_matrix_driver pmd
5042 SET period_start_date = period_start_date + 1
5043 WHERE run_id = l_run_id
5044 AND period_start_date < period_end_date
5045 AND NOT EXISTS (SELECT 1
5046 FROM psp_schedule_lines psl1
5047 WHERE psl1.schedule_begin_date = pmd.period_start_date
5048 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
5049 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
5050 FROM psp_schedule_lines psl1
5051 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
5052
5053 UPDATE psp_matrix_driver pmd
5054 SET period_start_date = period_start_date + 1
5055 WHERE run_id = l_run_id
5056 AND period_start_date < period_end_date
5057 AND EXISTS (SELECT 1
5058 FROM psp_schedule_lines psl1
5059 WHERE psl1.schedule_begin_date = pmd.period_start_date
5060 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
5061 AND EXISTS (SELECT 1
5062 FROM psp_schedule_lines psl1
5063 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
5064 AND psl1.schedule_end_date = pmd.period_start_date
5065 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
5066 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
5067 FROM psp_schedule_lines psl1
5068 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
5069 End of comment for bug fix 3970852 *****/
5070
5071 -- Introduced the following to prepare schedule chunk dates instead of load_table for bug fix 3970852
5072 recno := 1;
5073
5074 OPEN dates(l_schedule_hierarchy_id);
5075 FETCH dates BULK COLLECT INTO initial_dates, date_type;
5076 CLOSE dates;
5077
5078 FOR rowno IN 1..(initial_dates.COUNT - 1)
5079 LOOP
5080 IF (date_type(rowno) = 'B' AND date_type(rowno+1) = 'B') THEN
5081 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno);
5082 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1) - 1;
5083 recno := recno+1;
5084 ELSIF (date_type(rowno) = 'B' AND date_type(rowno+1) = 'E') THEN
5085 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno);
5086 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1);
5087 recno := recno+1;
5088 ELSIF (date_type(rowno) = 'E' AND date_type(rowno+1) = 'E') THEN
5089 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno) + 1;
5090 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1);
5091 recno := recno+1;
5092 ELSIF (date_type(rowno) = 'E' AND date_type(rowno+1) = 'B') THEN
5093 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno) + 1;
5094 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1) -1;
5095 recno := recno+1;
5096 END IF;
5097 END LOOP;
5098
5099 FORALL rowno IN 1..schedule_chunk.schedule_begin_date.COUNT
5100 INSERT INTO psp_matrix_driver
5101 (RUN_ID, SCHEDULE_LINE_ID,
5102 PERIOD_START_DATE,
5103 PERIOD_END_DATE,
5104 PERIOD_SCHEDULE_PERCENT)
5105 SELECT l_run_id, schedule_line_id,
5106 GREATEST(l_min_start_date, schedule_chunk.schedule_begin_date(rowno)),
5107 LEAST(l_max_end_date, schedule_chunk.schedule_end_date(rowno)),
5108 schedule_percent
5109 FROM psp_schedule_lines psl
5110 WHERE schedule_hierarchy_id = l_schedule_hierarchy_id
5111 AND schedule_end_date >= l_min_start_date
5112 AND schedule_begin_date <= l_max_end_date
5113 AND ( gl_code_combination_id IS NOT NULL
5114 OR award_id IS NOT NULL)
5115 AND psl.schedule_begin_date <= schedule_chunk.schedule_end_date(rowno)
5116 AND psl.schedule_end_date >= schedule_chunk.schedule_begin_date(rowno);
5117
5118 initial_dates.delete;
5119 date_type.delete;
5120 schedule_chunk.schedule_end_date.delete;
5121 schedule_chunk.schedule_begin_date.delete;
5122 -- End of bug fix 3970852
5123 END LOOP;
5124 CLOSE eg_hier_cur;
5125
5126 l_sch_pointer := 1;
5127 OPEN eg_matrix_cur;
5128 FETCH eg_matrix_cur BULK COLLECT INTO r_sch_rec.start_date, r_sch_rec.end_date, r_sch_rec.schedule_percent;
5129 CLOSE eg_matrix_cur;
5130
5131 hr_utility.trace('r_sch_rec.start_date.COUNT: ' || r_sch_rec.start_date.COUNT);
5132 hr_utility.trace('Schedule Chunk Details');
5133 hr_utility.trace(RPAD('Start Date', 15, ' ') || ' ' ||
5134 RPAD('End Date', 15, ' ') || ' ' || LPAD('Schedule Percent', 16, ' '));
5135 hr_utility.trace(RPAD('-', 15, '-') || ' ' ||
5136 RPAD('-', 15, '-') || ' ' || RPAD('-', 16, '-'));
5137
5138 FOR recno IN 1..r_sch_rec.start_date.COUNT
5139 LOOP
5140 hr_utility.trace(RPAD(TO_CHAR(r_sch_rec.start_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
5141 RPAD(TO_CHAR(r_sch_rec.end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
5142 LPAD(r_sch_rec.schedule_percent(recno), 16, ' '));
5143 END LOOP;
5144
5145 FOR I IN 1..r_enc_period.r_time_period_id.COUNT
5146 LOOP
5147 l_period_start_date := r_enc_period.r_period_start_date(I);
5148 l_period_end_date := r_enc_period.r_period_end_date(I);
5149 l_asg_start_date := r_enc_period.r_asg_start_date(I);
5150 l_asg_end_date := r_enc_period.r_asg_end_date(I);
5151 l_process_flag := r_enc_period.r_process_flag(I);
5152 l_sub_slice_counter := 1;
5153 l_proc_step := 80 + (I / 100000);
5154
5155 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
5156 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
5157 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
5158 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
5159 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
5160 ' r_enc_period.r_time_period_id(I): ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id(I)) ||
5161 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no));
5162
5163 IF (l_process_flag = 'Y') AND (r_sch_rec.end_date.COUNT > 0) THEN
5164 FOR eg_recno IN l_sch_pointer..r_sch_rec.start_date.COUNT
5165 LOOP
5166 l_start_date:= r_sch_rec.start_date(eg_recno);
5167 l_end_date:= r_sch_rec.end_date(eg_recno);
5168 l_schedule_percent:= r_sch_rec.schedule_percent(eg_recno);
5169 l_proc_step := 90 + (eg_recno / 100000);
5170
5171 hr_utility.trace(' l_sub_slice_counter: ' || fnd_number.number_to_canonical(l_sub_slice_counter) ||
5172 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no) ||
5173 ' l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
5174 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
5175 ' l_schedule_percent: ' || fnd_number.number_to_canonical(l_schedule_percent));
5176
5177 -- OPEN eg_matrix_cur;
5178 -- FETCH eg_matrix_cur INTO l_start_date, l_end_date, l_schedule_percent;
5179 -- IF (eg_matrix_cur%NOTFOUND) THEN
5180 IF (l_start_date > l_asg_end_date) THEN
5181 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5182 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5183 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5184 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5185 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5186 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5187 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5188 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
5189 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5190 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5191 l_rec_no := l_rec_no + 1;
5192 EXIT;
5193 END IF;
5194 -- CLOSE eg_matrix_cur;
5195 -- EXIT;
5196 -- END IF;
5197 -- CLOSE eg_matrix_cur;
5198
5199 IF (l_end_date >= l_asg_start_date) AND (l_start_date <= l_asg_end_date) THEN
5200 IF (l_asg_start_date = l_start_date AND l_asg_end_date = l_end_date) THEN
5201 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5202 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5203 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5204 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5205 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5206 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5207 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5208 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'EG';
5209 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5210 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5211 l_rec_no := l_rec_no + 1;
5212 IF (l_schedule_percent < 100) THEN
5213 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5214 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5215 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5216 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5217 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5218 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5219 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5220 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
5221 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5222 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5223 l_rec_no := l_rec_no + 1;
5224 END IF;
5225 EXIT;
5226 ELSE
5227 IF (l_start_date > GREATEST(l_period_start_date, l_asg_start_date)) THEN
5228 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date);
5229 l_new_end_date := l_start_date - 1;
5230 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5231 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5232 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5233 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
5234 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
5235 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5236 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5237 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
5238 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5239 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5240 l_rec_no := l_rec_no + 1;
5241 l_asg_start_date := l_start_date;
5242 END IF;
5243
5244 IF (l_end_date < LEAST(l_period_end_date, l_asg_end_date)) THEN
5245 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date, l_start_date);
5246 l_new_end_date := l_end_date;
5247 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5248 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5249 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5250 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
5251 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
5252 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5253 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5254 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'EG';
5255 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5256 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5257 l_rec_no := l_rec_no + 1;
5258 IF (l_schedule_percent < 100) THEN
5259 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5260 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5261 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5262 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
5263 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
5264 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5265 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5266 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
5267 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5268 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5269 l_rec_no := l_rec_no + 1;
5270 END IF;
5271 l_asg_start_date := l_end_date + 1;
5272 IF (eg_recno = r_sch_rec.start_date.COUNT) AND
5273 (l_asg_start_date <= l_asg_end_date) THEN
5274 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5275 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5276 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5277 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5278 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5279 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5280 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5281 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
5282 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5283 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5284 l_rec_no := l_rec_no + 1;
5285 END IF;
5286 ELSE
5287 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5288 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5289 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5290 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5291 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5292 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5293 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5294 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'EG';
5295 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5296 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5297 l_rec_no := l_rec_no + 1;
5298 IF (l_schedule_percent < 100) THEN
5299 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5300 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5301 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5302 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5303 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5304 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5305 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5306 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
5307 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5308 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5309 l_rec_no := l_rec_no + 1;
5310 END IF;
5311 l_asg_start_date := l_end_date + 1;
5312 END IF;
5313 END IF;
5314 l_sub_slice_counter := 2;
5315 ELSE
5316 IF (eg_recno = r_sch_rec.start_date.COUNT) THEN
5317 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5318 r_enc_period_tmp1.r_period_start_date(l_rec_no) := r_enc_period.r_period_start_date(I);
5319 r_enc_period_tmp1.r_period_end_date(l_rec_no) := r_enc_period.r_period_end_date(I);
5320 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := r_enc_period.r_asg_start_date(I);
5321 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := r_enc_period.r_asg_end_date(I);
5322 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5323 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5324 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
5325 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5326 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5327 l_rec_no := l_rec_no + 1;
5328 END IF;
5329 END IF;
5330 l_sch_pointer := eg_recno;
5331 EXIT WHEN l_asg_start_date > l_asg_end_date;
5332 END LOOP;
5333 ELSE
5334 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5335 r_enc_period_tmp1.r_period_start_date(l_rec_no) := r_enc_period.r_period_start_date(I);
5336 r_enc_period_tmp1.r_period_end_date(l_rec_no) := r_enc_period.r_period_end_date(I);
5337 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := r_enc_period.r_asg_start_date(I);
5338 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := r_enc_period.r_asg_end_date(I);
5339 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5340 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5341 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
5342 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5343 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5344 l_rec_no := l_rec_no + 1;
5345 END IF;
5346 END LOOP;
5347
5348 r_enc_period.r_time_period_id.DELETE;
5349 r_enc_period.r_period_start_date.DELETE;
5350 r_enc_period.r_period_end_date.DELETE;
5351 r_enc_period.r_asg_start_date.DELETE;
5352 r_enc_period.r_asg_end_date.DELETE;
5353 r_enc_period.r_process_flag.DELETE;
5354 r_enc_period.r_period_ind.DELETE;
5355 r_enc_period.r_schedule_percent.DELETE;
5356 r_enc_period.r_encumbrance_amount.DELETE;
5357 r_enc_period.r_period_amount.DELETE;
5358 r_enc_period.r_reason_code.DELETE;
5359 r_enc_period.r_effective_date.DELETE;
5360 l_rec_no := 1;
5361 l_proc_step := 100;
5362
5363 hr_utility.trace('Dumping Assignment Chunk After Element Group Processing ...');
5364 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
5365 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
5366 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
5367 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
5368 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
5369 RPAD('Reason Code', 50, ' '));
5370 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
5371 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
5372 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
5373 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
5374 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
5375 RPAD('-', 50, '-'));
5376
5377 FOR recno IN 1..r_enc_period_tmp1.r_time_period_id.COUNT
5378 LOOP
5379 hr_utility.trace(LPAD(r_enc_period_tmp1.r_period_ind(recno), 13, ' ') || ' ' ||
5380 LPAD(r_enc_period_tmp1.r_time_period_id(recno), 14, ' ') || ' ' ||
5381 RPAD(TO_CHAR(r_enc_period_tmp1.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
5382 RPAD(TO_CHAR(r_enc_period_tmp1.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
5383 RPAD(TO_CHAR(r_enc_period_tmp1.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
5384 RPAD(TO_CHAR(r_enc_period_tmp1.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
5385 RPAD(TO_CHAR(r_enc_period_tmp1.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
5386 RPAD(r_enc_period_tmp1.r_process_flag(recno), 12, ' ') || ' ' ||
5387 LPAD(r_enc_period_tmp1.r_schedule_percent(recno), 16, ' ') || ' ' ||
5388 RPAD(r_enc_period_tmp1.r_reason_code(recno), 50, ' '));
5389 END LOOP;
5390 hr_utility.trace('Assignment Processing ...');
5391
5392 psp_matrix_driver_pkg.clear_table('REFRESH');
5393 psp_matrix_driver_pkg.purge_table;
5394 l_period_count := r_enc_period.r_time_period_id.COUNT;
5395 OPEN ls_hier_cur('A');
5396 FETCH ls_hier_cur INTO l_schedule_hierarchy_id;
5397 CLOSE ls_hier_cur;
5398
5399 /***** Commented for bug fix 3970852 to resolve issues when schedule dates equal default end date
5400 psp_matrix_driver_pkg.clear_table('REFRESH');
5401 psp_matrix_driver_pkg.purge_table;
5402 psp_matrix_driver_pkg.load_table(l_schedule_hierarchy_id);
5403
5404 DELETE psp_matrix_driver
5405 WHERE run_id = l_run_id
5406 AND (period_start_date > l_max_end_date
5407 OR period_end_date < l_min_start_date
5408 OR period_schedule_percent = 0);
5409
5410 UPDATE psp_matrix_driver pmd
5411 SET period_end_date = period_end_date - 1
5412 WHERE run_id = l_run_id
5413 AND period_start_date < period_end_date
5414 AND period_start_date = (SELECT MIN(psl1.schedule_begin_date)
5415 FROM psp_schedule_lines psl1
5416 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
5417 AND EXISTS (SELECT 1
5418 FROM psp_schedule_lines psl1
5419 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
5420 AND psl1.schedule_begin_date = pmd.period_end_date
5421 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
5422
5423 UPDATE psp_matrix_driver pmd
5424 SET period_end_date = period_end_date - 1
5425 WHERE run_id = l_run_id
5426 AND period_start_date < period_end_date
5427 AND NOT (NOT EXISTS (SELECT 1
5428 FROM psp_schedule_lines psl1
5429 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
5430 AND psl1.schedule_begin_date = pmd.period_end_date
5431 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
5432 AND EXISTS (SELECT 1
5433 FROM psp_schedule_lines psl1
5434 WHERE psl1.schedule_end_date = pmd.period_end_date
5435 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id))
5436 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
5437 FROM psp_schedule_lines psl1
5438 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
5439
5440 UPDATE psp_matrix_driver pmd
5441 SET period_start_date = period_start_date + 1
5442 WHERE run_id = l_run_id
5443 AND period_start_date < period_end_date
5444 AND NOT EXISTS (SELECT 1
5445 FROM psp_schedule_lines psl1
5446 WHERE psl1.schedule_begin_date = pmd.period_start_date
5447 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
5448 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
5449 FROM psp_schedule_lines psl1
5450 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
5451
5452 UPDATE psp_matrix_driver pmd
5453 SET period_start_date = period_start_date + 1
5454 WHERE run_id = l_run_id
5455 AND period_start_date < period_end_date
5456 AND EXISTS (SELECT 1
5457 FROM psp_schedule_lines psl1
5458 WHERE psl1.schedule_begin_date = pmd.period_start_date
5459 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
5460 AND EXISTS (SELECT 1
5461 FROM psp_schedule_lines psl1
5462 WHERE psl1.schedule_line_id <> pmd.schedule_line_id
5463 AND psl1.schedule_end_date = pmd.period_start_date
5464 AND psl1.schedule_hierarchy_id = l_schedule_hierarchy_id)
5465 AND period_start_date <> (SELECT MIN(psl1.schedule_begin_date)
5466 FROM psp_schedule_lines psl1
5467 WHERE psl1.schedule_hierarchy_id = l_schedule_hierarchy_id);
5468 End of comment for bug fix 3970852 *****/
5469
5470 -- Introduced the following to prepare schedule chunk dates instead of load_table for bug fix 3970852
5471 recno := 1;
5472
5473 OPEN dates(l_schedule_hierarchy_id);
5474 FETCH dates BULK COLLECT INTO initial_dates, date_type;
5475 CLOSE dates;
5476
5477 FOR rowno IN 1..(initial_dates.COUNT - 1)
5478 LOOP
5479 IF (date_type(rowno) = 'B' AND date_type(rowno+1) = 'B') THEN
5480 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno);
5481 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1) - 1;
5482 recno := recno+1;
5483 ELSIF (date_type(rowno) = 'B' AND date_type(rowno+1) = 'E') THEN
5484 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno);
5485 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1);
5486 recno := recno+1;
5487 ELSIF (date_type(rowno) = 'E' AND date_type(rowno+1) = 'E') THEN
5488 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno) + 1;
5489 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1);
5490 recno := recno+1;
5491 ELSIF (date_type(rowno) = 'E' AND date_type(rowno+1) = 'B') THEN
5492 schedule_chunk.schedule_begin_date(recno) := initial_dates(rowno) + 1;
5493 schedule_chunk.schedule_end_date(recno) := initial_dates(rowno+1) -1;
5494 recno := recno+1;
5495 END IF;
5496 END LOOP;
5497
5498 FORALL rowno IN 1..schedule_chunk.schedule_begin_date.COUNT
5499 INSERT INTO psp_matrix_driver
5500 (RUN_ID, SCHEDULE_LINE_ID,
5501 PERIOD_START_DATE, PERIOD_END_DATE,
5502 PERIOD_SCHEDULE_PERCENT)
5503 SELECT l_run_id, schedule_line_id,
5504 GREATEST(l_min_start_date, schedule_chunk.schedule_begin_date(rowno)),
5505 LEAST(l_max_end_date, schedule_chunk.schedule_end_date(rowno)),
5506 schedule_percent
5507 FROM psp_schedule_lines psl
5508 WHERE schedule_hierarchy_id = l_schedule_hierarchy_id
5509 AND schedule_end_date >= l_min_start_date
5510 AND schedule_begin_date <= l_max_end_date
5511 AND ( gl_code_combination_id IS NOT NULL
5512 OR award_id IS NOT NULL)
5513 AND psl.schedule_begin_date <= schedule_chunk.schedule_end_date(rowno)
5514 AND psl.schedule_end_date >= schedule_chunk.schedule_begin_date(rowno);
5515
5516 initial_dates.delete;
5517 date_type.delete;
5518 schedule_chunk.schedule_end_date.delete;
5519 schedule_chunk.schedule_begin_date.delete;
5520 -- End of bug fix 3970852
5521
5522 l_sch_pointer := 1;
5523 OPEN ls_matrix_cur;
5524 FETCH ls_matrix_cur BULK COLLECT INTO r_sch_rec.start_date, r_sch_rec.end_date, r_sch_rec.schedule_percent;
5525 CLOSE ls_matrix_cur;
5526
5527 hr_utility.trace('r_sch_rec.start_date.COUNT: ' || r_sch_rec.start_date.COUNT);
5528 hr_utility.trace('Schedule Chunk Details');
5529 hr_utility.trace(RPAD('Start Date', 15, ' ') || ' ' ||
5530 RPAD('End Date', 15, ' ') || ' ' || LPAD('Schedule Percent', 16, ' '));
5531
5532 hr_utility.trace(RPAD('-', 15, '-') || ' ' ||
5533 RPAD('-', 15, '-') || ' ' || RPAD('-', 16, '-'));
5534
5535 FOR recno IN 1..r_sch_rec.start_date.COUNT
5536 LOOP
5537 hr_utility.trace(RPAD(TO_CHAR(r_sch_rec.start_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
5538 RPAD(TO_CHAR(r_sch_rec.end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
5539 LPAD(r_sch_rec.schedule_percent(recno), 16, ' '));
5540 END LOOP;
5541
5542 FOR I IN 1..r_enc_period_tmp1.r_time_period_id.COUNT
5543 LOOP
5544 l_period_start_date := r_enc_period_tmp1.r_period_start_date(I);
5545 l_period_end_date := r_enc_period_tmp1.r_period_end_date(I);
5546 l_asg_start_date := r_enc_period_tmp1.r_asg_start_date(I);
5547 l_asg_end_date := r_enc_period_tmp1.r_asg_end_date(I);
5548 l_process_flag := r_enc_period_tmp1.r_process_flag(I);
5549 l_sub_slice_counter := 1;
5550 l_proc_step := 110 + (I / 100000);
5551
5552 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
5553 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
5554 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
5555 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
5556 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
5557 ' r_enc_period_tmp1.r_time_period_id(I): ' || fnd_number.number_to_canonical(r_enc_period_tmp1.r_time_period_id(I)) ||
5558 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no));
5559
5560 IF (l_process_flag = 'Y') AND (r_sch_rec.end_date.COUNT > 0) THEN
5561 FOR asg_recno IN l_sch_pointer..r_sch_rec.start_date.COUNT
5562 LOOP
5563 l_start_date:= r_sch_rec.start_date(asg_recno);
5564 l_end_date:= r_sch_rec.end_date(asg_recno);
5565 l_schedule_percent:= r_sch_rec.schedule_percent(asg_recno);
5566 l_proc_step := 120 + (l_rec_no / 100000);
5567
5568 hr_utility.trace(' l_sub_slice_counter: ' || fnd_number.number_to_canonical(l_sub_slice_counter) ||
5569 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no) ||
5570 ' l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
5571 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
5572 ' l_schedule_percent: ' || fnd_number.number_to_canonical(l_schedule_percent));
5573 -- OPEN ls_matrix_cur;
5574 -- FETCH ls_matrix_cur INTO l_start_date, l_end_date, l_schedule_percent;
5575 -- IF (ls_matrix_cur%NOTFOUND) THEN
5576 IF (l_start_date > l_asg_end_date) THEN
5577 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5578 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5579 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5580 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
5581 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
5582 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5583 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5584 r_enc_period.r_process_flag(l_rec_no) := 'Y';
5585 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
5586 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5587 l_rec_no := l_rec_no + 1;
5588 EXIT;
5589 END IF;
5590 -- CLOSE ls_matrix_cur;
5591 -- EXIT;
5592 -- END IF;
5593 -- CLOSE ls_matrix_cur;
5594
5595 IF (l_end_date >= l_asg_start_date) AND (l_start_date <= l_asg_end_date) THEN
5596 IF (l_asg_start_date = l_start_date AND l_asg_end_date = l_end_date) THEN
5597 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5598 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5599 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5600 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
5601 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
5602 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5603 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5604 r_enc_period.r_process_flag(l_rec_no) := 'A';
5605 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
5606 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5607 l_rec_no := l_rec_no + 1;
5608 IF (l_schedule_percent < 100) THEN
5609 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5610 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5611 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5612 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
5613 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
5614 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5615 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5616 r_enc_period.r_process_flag(l_rec_no) := 'BAL';
5617 r_enc_period.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5618 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5619 l_rec_no := l_rec_no + 1;
5620 END IF;
5621 EXIT;
5622 ELSE
5623 IF (l_start_date > GREATEST(l_period_start_date, l_asg_start_date)) THEN
5624 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date);
5625 l_new_end_date := l_start_date - 1;
5626 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5627 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5628 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5629 r_enc_period.r_asg_start_date(l_rec_no) := l_new_start_date;
5630 r_enc_period.r_asg_end_date(l_rec_no) := l_new_end_date;
5631 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5632 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5633 r_enc_period.r_process_flag(l_rec_no) := 'Y';
5634 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
5635 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5636 l_rec_no := l_rec_no + 1;
5637 l_asg_start_date := l_start_date;
5638 END IF;
5639
5640 IF (l_end_date < LEAST(l_period_end_date, l_asg_end_date)) THEN
5641 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date, l_start_date);
5642 l_new_end_date := l_end_date;
5643 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5644 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5645 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5646 r_enc_period.r_asg_start_date(l_rec_no) := l_new_start_date;
5647 r_enc_period.r_asg_end_date(l_rec_no) := l_new_end_date;
5648 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5649 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5650 r_enc_period.r_process_flag(l_rec_no) := 'A';
5651 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
5652 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5653 l_rec_no := l_rec_no + 1;
5654 IF (l_schedule_percent < 100) THEN
5655 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5656 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5657 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5658 r_enc_period.r_asg_start_date(l_rec_no) := l_new_start_date;
5659 r_enc_period.r_asg_end_date(l_rec_no) := l_new_end_date;
5660 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5661 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5662 r_enc_period.r_process_flag(l_rec_no) := 'BAL';
5663 r_enc_period.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5664 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5665 l_rec_no := l_rec_no + 1;
5666 END IF;
5667 l_asg_start_date := l_end_date + 1;
5668 IF (asg_recno = r_sch_rec.start_date.COUNT) AND
5669 (l_asg_start_date <= l_asg_end_date) THEN
5670 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5671 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5672 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5673 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
5674 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
5675 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5676 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5677 r_enc_period.r_process_flag(l_rec_no) := 'Y';
5678 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
5679 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5680 l_rec_no := l_rec_no + 1;
5681 END IF;
5682 ELSE
5683 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5684 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5685 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5686 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
5687 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
5688 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5689 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5690 r_enc_period.r_process_flag(l_rec_no) := 'A';
5691 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
5692 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5693 l_rec_no := l_rec_no + 1;
5694 IF (l_schedule_percent < 100) THEN
5695 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5696 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
5697 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
5698 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
5699 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
5700 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5701 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5702 r_enc_period.r_process_flag(l_rec_no) := 'BAL';
5703 r_enc_period.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5704 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5705 l_rec_no := l_rec_no + 1;
5706 END IF;
5707 l_asg_start_date := l_end_date + 1;
5708 END IF;
5709 END IF;
5710 l_sub_slice_counter := 2;
5711 ELSE
5712 IF (asg_recno = r_sch_rec.start_date.COUNT) THEN
5713 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5714 r_enc_period.r_period_start_date(l_rec_no) := r_enc_period_tmp1.r_period_start_date(I);
5715 r_enc_period.r_period_end_date(l_rec_no) := r_enc_period_tmp1.r_period_end_date(I);
5716 r_enc_period.r_asg_start_date(l_rec_no) := r_enc_period_tmp1.r_asg_start_date(I);
5717 r_enc_period.r_asg_end_date(l_rec_no) := r_enc_period_tmp1.r_asg_end_date(I);
5718 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5719 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5720 r_enc_period.r_process_flag(l_rec_no) := r_enc_period_tmp1.r_process_flag(I);
5721 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
5722 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5723 l_rec_no := l_rec_no + 1;
5724 END IF;
5725 END IF;
5726 l_sch_pointer := asg_recno;
5727 EXIT WHEN l_asg_start_date > l_asg_end_date;
5728 END LOOP;
5729 ELSE
5730 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
5731 r_enc_period.r_period_start_date(l_rec_no) := r_enc_period_tmp1.r_period_start_date(I);
5732 r_enc_period.r_period_end_date(l_rec_no) := r_enc_period_tmp1.r_period_end_date(I);
5733 r_enc_period.r_asg_start_date(l_rec_no) := r_enc_period_tmp1.r_asg_start_date(I);
5734 r_enc_period.r_asg_end_date(l_rec_no) := r_enc_period_tmp1.r_asg_end_date(I);
5735 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
5736 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
5737 r_enc_period.r_process_flag(l_rec_no) := r_enc_period_tmp1.r_process_flag(I);
5738 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
5739 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
5740 l_rec_no := l_rec_no + 1;
5741 END IF;
5742 END LOOP;
5743
5744 r_sch_rec.start_date.delete;
5745 r_sch_rec.end_date.delete;
5746 r_sch_rec.schedule_percent.delete;
5747 r_enc_period_tmp1.r_time_period_id.DELETE;
5748 r_enc_period_tmp1.r_period_start_date.DELETE;
5749 r_enc_period_tmp1.r_period_end_date.DELETE;
5750 r_enc_period_tmp1.r_asg_start_date.DELETE;
5751 r_enc_period_tmp1.r_asg_end_date.DELETE;
5752 r_enc_period_tmp1.r_process_flag.DELETE;
5753 r_enc_period_tmp1.r_period_ind.DELETE;
5754 r_enc_period_tmp1.r_schedule_percent.DELETE;
5755 r_enc_period_tmp1.r_encumbrance_amount.DELETE;
5756 r_enc_period_tmp1.r_period_amount.DELETE;
5757 r_enc_period_tmp1.r_reason_code.DELETE;
5758 r_enc_period_tmp1.r_effective_date.DELETE;
5759 l_rec_no := 1;
5760 l_proc_step := 130;
5761
5762 -- psp_matrix_driver_pkg.clear_table('REFRESH'); Commented for bug fix 3970852
5763 -- psp_matrix_driver_pkg.purge_table; Commented for bug fix 3970852
5764
5765 hr_utility.trace('Dumping Assignment Chunk After Assignment Processing ...');
5766 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
5767 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
5768 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
5769 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
5770 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
5771 RPAD('Reason Code', 50, ' '));
5772 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
5773 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
5774 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
5775 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
5776 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
5777 RPAD('-', 50, '-'));
5778
5779 FOR recno IN 1..r_enc_period.r_time_period_id.COUNT
5780 LOOP
5781 hr_utility.trace(LPAD(r_enc_period.r_period_ind(recno), 13, ' ') || ' ' ||
5782 LPAD(r_enc_period.r_time_period_id(recno), 14, ' ') || ' ' ||
5783 RPAD(TO_CHAR(r_enc_period.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
5784 RPAD(TO_CHAR(r_enc_period.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
5785 RPAD(TO_CHAR(r_enc_period.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
5786 RPAD(TO_CHAR(r_enc_period.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
5787 RPAD(TO_CHAR(r_enc_period.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
5788 RPAD(r_enc_period.r_process_flag(recno), 12, ' ') || ' ' ||
5789 LPAD(r_enc_period.r_schedule_percent(recno), 16, ' ') || ' ' ||
5790 RPAD(r_enc_period.r_reason_code(recno), 50, ' '));
5791 END LOOP;
5792
5793 IF (g_org_def_labor_schedule = 'Y') THEN
5794 hr_utility.trace('Organization Default LS Processing');
5795
5796 l_sch_pointer := 1;
5797 OPEN odls_cur;
5798 FETCH odls_cur BULK COLLECT INTO r_sch_rec.start_date, r_sch_rec.end_date, r_sch_rec.schedule_percent;
5799 CLOSE odls_cur;
5800
5801 hr_utility.trace('r_sch_rec.start_date.COUNT: ' || r_sch_rec.start_date.COUNT);
5802 hr_utility.trace('Schedule Chunk Details');
5803 hr_utility.trace(RPAD('Start Date', 15, ' ') || ' ' ||
5804 RPAD('End Date', 15, ' ') || ' ' || LPAD('Schedule Percent', 16, ' '));
5805 hr_utility.trace(RPAD('-', 15, '-') || ' ' ||
5806 RPAD('-', 15, '-') || ' ' || RPAD('-', 16, '-'));
5807
5808 FOR recno IN 1..r_sch_rec.start_date.COUNT
5809 LOOP
5810 hr_utility.trace(RPAD(TO_CHAR(r_sch_rec.start_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
5811 RPAD(TO_CHAR(r_sch_rec.end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
5812 LPAD(r_sch_rec.schedule_percent(recno), 16, ' '));
5813 END LOOP;
5814
5815 FOR I IN 1..r_enc_period.r_time_period_id.COUNT
5816 LOOP
5817 l_period_start_date := r_enc_period.r_period_start_date(I);
5818 l_period_end_date := r_enc_period.r_period_end_date(I);
5819 l_asg_start_date := r_enc_period.r_asg_start_date(I);
5820 l_asg_end_date := r_enc_period.r_asg_end_date(I);
5821 l_process_flag := r_enc_period.r_process_flag(I);
5822 l_sub_slice_counter := 1;
5823 l_proc_step := 150 + (I / 100000);
5824
5825 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
5826 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
5827 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
5828 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
5829 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
5830 ' r_enc_period.r_time_period_id(I): ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id(I)) ||
5831 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no));
5832
5833 IF (l_process_flag = 'Y') AND (r_sch_rec.end_date.COUNT > 0) THEN
5834 FOR odls_recno IN l_sch_pointer..r_sch_rec.start_date.COUNT
5835 LOOP
5836 l_start_date:= r_sch_rec.start_date(odls_recno);
5837 l_end_date:= r_sch_rec.end_date(odls_recno);
5838 l_schedule_percent:= r_sch_rec.schedule_percent(odls_recno);
5839 l_proc_step := 160 + (l_rec_no / 100000);
5840 -- OPEN odls_cur(l_asg_start_date, l_asg_end_date);
5841 -- FETCH odls_cur INTO l_start_date, l_end_date, l_schedule_percent;
5842
5843 hr_utility.trace('l_sub_slice_counter: ' || fnd_number.number_to_canonical(l_sub_slice_counter) ||
5844 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no) ||
5845 ' l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
5846 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
5847 ' l_schedule_percent: ' || fnd_number.number_to_canonical(l_schedule_percent));
5848 -- hr_utility.trace('odls_cur%ROWCOUNT: ' || fnd_number.number_to_canonical(odls_cur%ROWCOUNT));
5849
5850 -- IF (odls_cur%NOTFOUND) THEN
5851 IF (l_start_date > l_asg_end_date) THEN
5852 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5853 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5854 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5855 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5856 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5857 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5858 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5859 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
5860 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5861 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5862 l_rec_no := l_rec_no + 1;
5863 EXIT;
5864 END IF;
5865 -- CLOSE odls_cur;
5866 -- EXIT;
5867 -- END IF;
5868 -- CLOSE odls_cur;
5869
5870 IF (l_end_date >= l_asg_start_date) AND (l_start_date <= l_asg_end_date) THEN
5871 IF (l_asg_start_date = l_start_date AND l_asg_end_date = l_end_date) THEN
5872 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5873 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5874 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5875 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5876 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5877 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5878 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5879 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'DS';
5880 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5881 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5882 l_rec_no := l_rec_no + 1;
5883 IF (l_schedule_percent < 100) THEN
5884 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5885 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5886 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5887 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5888 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5889 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5890 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5891 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
5892 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5893 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5894 l_rec_no := l_rec_no + 1;
5895 END IF;
5896 EXIT;
5897 ELSE
5898 IF (l_start_date > GREATEST(l_period_start_date, l_asg_start_date)) THEN
5899 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date);
5900 l_new_end_date := l_start_date - 1;
5901 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5902 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5903 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5904 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
5905 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
5906 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5907 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5908 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
5909 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5910 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5911 l_rec_no := l_rec_no + 1;
5912 l_asg_start_date := l_start_date;
5913 END IF;
5914
5915 IF (l_end_date < LEAST(l_period_end_date, l_asg_end_date)) THEN
5916 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date, l_start_date);
5917 l_new_end_date := l_end_date;
5918 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5919 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5920 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5921 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
5922 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
5923 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5924 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5925 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'DS';
5926 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5927 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5928 l_rec_no := l_rec_no + 1;
5929 IF (l_schedule_percent < 100) THEN
5930 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5931 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5932 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5933 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
5934 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
5935 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5936 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5937 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
5938 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5939 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5940 l_rec_no := l_rec_no + 1;
5941 END IF;
5942 l_asg_start_date := l_end_date + 1;
5943 IF (odls_recno = r_sch_rec.start_date.COUNT) AND
5944 (l_asg_start_date <= l_asg_end_date) THEN
5945 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5946 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5947 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5948 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5949 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5950 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5951 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5952 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
5953 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5954 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5955 l_rec_no := l_rec_no + 1;
5956 END IF;
5957 /***** Commented the following code for bug fix 3672723 as it was causing duplicate posting for same assignment chunks
5958 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5959 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5960 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5961 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5962 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5963 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5964 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'Y';
5965 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5966 l_rec_no := l_rec_no + 1;
5967 End of Comment for bug fix 3673723 *****/
5968 ELSE
5969 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5970 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5971 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5972 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5973 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5974 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5975 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5976 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'DS';
5977 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
5978 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5979 l_rec_no := l_rec_no + 1;
5980 IF (l_schedule_percent < 100) THEN
5981 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
5982 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
5983 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
5984 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
5985 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
5986 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
5987 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
5988 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'BAL';
5989 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := 100 - l_schedule_percent;
5990 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
5991 l_rec_no := l_rec_no + 1;
5992 END IF;
5993 l_asg_start_date := l_end_date + 1;
5994 END IF;
5995 END IF;
5996 l_sub_slice_counter := 2;
5997 ELSE
5998 IF (odls_recno = r_sch_rec.start_date.COUNT) THEN
5999 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
6000 r_enc_period_tmp1.r_period_start_date(l_rec_no) := r_enc_period.r_period_start_date(I);
6001 r_enc_period_tmp1.r_period_end_date(l_rec_no) := r_enc_period.r_period_end_date(I);
6002 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := r_enc_period.r_asg_start_date(I);
6003 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := r_enc_period.r_asg_end_date(I);
6004 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
6005 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
6006 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
6007 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
6008 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
6009 l_rec_no := l_rec_no + 1;
6010 END IF;
6011 END IF;
6012 l_sch_pointer := odls_recno;
6013 EXIT WHEN l_asg_start_date > l_asg_end_date;
6014 END LOOP;
6015 ELSE
6016 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
6017 r_enc_period_tmp1.r_period_start_date(l_rec_no) := r_enc_period.r_period_start_date(I);
6018 r_enc_period_tmp1.r_period_end_date(l_rec_no) := r_enc_period.r_period_end_date(I);
6019 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := r_enc_period.r_asg_start_date(I);
6020 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := r_enc_period.r_asg_end_date(I);
6021 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
6022 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
6023 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
6024 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
6025 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
6026 l_rec_no := l_rec_no + 1;
6027 END IF;
6028 END LOOP;
6029
6030 r_sch_rec.start_date.delete;
6031 r_sch_rec.end_date.delete;
6032 r_sch_rec.schedule_percent.delete;
6033 r_enc_period.r_time_period_id.DELETE;
6034 r_enc_period.r_period_start_date.DELETE;
6035 r_enc_period.r_period_end_date.DELETE;
6036 r_enc_period.r_asg_start_date.DELETE;
6037 r_enc_period.r_asg_end_date.DELETE;
6038 r_enc_period.r_process_flag.DELETE;
6039 r_enc_period.r_period_ind.DELETE;
6040 r_enc_period.r_schedule_percent.DELETE;
6041 r_enc_period.r_encumbrance_amount.DELETE;
6042 r_enc_period.r_period_amount.DELETE;
6043 r_enc_period.r_reason_code.DELETE;
6044 r_enc_period.r_effective_date.DELETE;
6045 l_rec_no := 1;
6046 l_proc_step := 170;
6047
6048 hr_utility.trace('Dumping Assignment Chunk After Organization Default Schedules Processing ...');
6049 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
6050 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
6051 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
6052 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
6053 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
6054 RPAD('Reason Code', 50, ' '));
6055 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
6056 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
6057 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
6058 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
6059 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
6060 RPAD('-', 50, '-'));
6061
6062 FOR recno IN 1..r_enc_period_tmp1.r_time_period_id.COUNT
6063 LOOP
6064 hr_utility.trace(LPAD(r_enc_period_tmp1.r_period_ind(recno), 13, ' ') || ' ' ||
6065 LPAD(r_enc_period_tmp1.r_time_period_id(recno), 14, ' ') || ' ' ||
6066 RPAD(TO_CHAR(r_enc_period_tmp1.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
6067 RPAD(TO_CHAR(r_enc_period_tmp1.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
6068 RPAD(TO_CHAR(r_enc_period_tmp1.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
6069 RPAD(TO_CHAR(r_enc_period_tmp1.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
6070 RPAD(TO_CHAR(r_enc_period_tmp1.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
6071 RPAD(r_enc_period_tmp1.r_process_flag(recno), 12, ' ') || ' ' ||
6072 LPAD(r_enc_period_tmp1.r_schedule_percent(recno), 16, ' ') || ' ' ||
6073 RPAD(r_enc_period_tmp1.r_reason_code(recno), 50, ' '));
6074 END LOOP;
6075
6076 FOR I IN 1..r_enc_period_tmp1.r_time_period_id.COUNT
6077 LOOP
6078 r_enc_period.r_period_ind(I) := r_enc_period_tmp1.r_period_ind(I);
6079 r_enc_period.r_period_start_date(I) := r_enc_period_tmp1.r_period_start_date(I);
6080 r_enc_period.r_period_end_date(I) := r_enc_period_tmp1.r_period_end_date(I);
6081 r_enc_period.r_asg_start_date(I) := r_enc_period_tmp1.r_asg_start_date(I);
6082 r_enc_period.r_asg_end_date(I) := r_enc_period_tmp1.r_asg_end_date(I);
6083 r_enc_period.r_time_period_id(I) := r_enc_period_tmp1.r_time_period_id(I);
6084 r_enc_period.r_effective_date(I) := r_enc_period_tmp1.r_effective_date(I);
6085 r_enc_period.r_process_flag(I) := r_enc_period_tmp1.r_process_flag(I);
6086 r_enc_period.r_schedule_percent(I) := r_enc_period_tmp1.r_schedule_percent(I);
6087 r_enc_period.r_reason_code(I) := r_enc_period_tmp1.r_reason_code(I);
6088 END LOOP;
6089 END IF;
6090
6091 IF (g_org_def_account = 'Y') THEN
6092 hr_utility.trace('Organization Default Account Processing');
6093
6094 l_sch_pointer := 1;
6095 FOR I IN 1..r_enc_period.r_time_period_id.COUNT
6096 LOOP
6097 l_period_start_date := r_enc_period.r_period_start_date(I);
6098 l_period_end_date := r_enc_period.r_period_end_date(I);
6099 l_asg_start_date := r_enc_period.r_asg_start_date(I);
6100 l_asg_end_date := r_enc_period.r_asg_end_date(I);
6101 l_process_flag := r_enc_period.r_process_flag(I);
6102 l_sub_slice_counter := 1;
6103 l_proc_step := 180 + (I / 100000);
6104
6105 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
6106 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
6107 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
6108 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
6109 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
6110 ' r_enc_period.r_time_period_id(I): ' || fnd_number.number_to_canonical(r_enc_period.r_time_period_id(I)) ||
6111 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no));
6112
6113 IF (l_process_flag IN ('BAL', 'Y')) AND (r_da.end_date_active.COUNT > 0) THEN
6114 FOR da_recno IN l_sch_pointer..r_da.start_date_active.COUNT
6115 LOOP
6116 l_start_date:= r_da.start_date_active(da_recno);
6117 l_end_date:= r_da.end_date_active(da_recno);
6118 IF (l_process_flag = 'BAL') THEN
6119 l_schedule_percent := r_enc_period.r_schedule_percent(I);
6120 ELSE
6121 l_schedule_percent:= r_da.percent(da_recno);
6122 END IF;
6123 l_proc_step := 190 + (l_rec_no / 100000);
6124
6125 hr_utility.trace(' l_sub_slice_counter: ' || fnd_number.number_to_canonical(l_sub_slice_counter) ||
6126 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no) ||
6127 ' l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
6128 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
6129 ' l_schedule_percent: ' || fnd_number.number_to_canonical(l_schedule_percent));
6130
6131 IF (l_start_date > l_asg_end_date) THEN
6132 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
6133 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
6134 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
6135 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
6136 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
6137 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
6138 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
6139 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
6140 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
6141 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
6142 l_rec_no := l_rec_no + 1;
6143 EXIT;
6144 END IF;
6145
6146 IF (l_end_date >= l_asg_start_date) AND (l_start_date <= l_asg_end_date) THEN
6147 IF (l_process_flag = 'BAL') THEN
6148 l_reason_code := '1';
6149 l_schedule_percent := r_enc_period.r_schedule_percent(I);
6150 fnd_message.set_name('PSP', 'PSP_DEFAULT_REASON_1');
6151 fnd_message.set_token('START_DATE', l_asg_start_date);
6152 fnd_message.set_token('END_DATE', l_asg_end_date);
6153 fnd_message.set_token('PERCENT', r_enc_period.r_schedule_percent(I));
6154 g_warning_message := fnd_message.get;
6155 add_cel_warnings(p_start_date => l_asg_start_date,
6156 p_hierarchy_code => 'DA',
6157 p_end_date => l_asg_end_date,
6158 p_warning_code => 'BAL',
6159 p_percent => r_enc_period.r_schedule_percent(I));
6160 ELSE
6161 l_reason_code := '3';
6162 fnd_message.set_name('PSP', 'PSP_DEFAULT_REASON_3');
6163 fnd_message.set_token('START_DATE', l_asg_start_date);
6164 fnd_message.set_token('END_DATE', l_asg_end_date);
6165 g_warning_message := fnd_message.get;
6166 add_cel_warnings(p_start_date => l_asg_start_date,
6167 p_hierarchy_code => 'DA',
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_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
6173 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
6174 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
6175 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
6176 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
6177 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
6178 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
6179 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'DA';
6180 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := l_schedule_percent;
6181 r_enc_period_tmp1.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_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
6188 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
6189 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
6190 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
6191 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
6192 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
6193 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
6194 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
6195 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
6196 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
6197 l_rec_no := l_rec_no + 1;
6198 l_asg_start_date := l_start_date;
6199 END IF;
6200
6201 IF (l_end_date < LEAST(l_period_end_date, l_asg_end_date)) THEN
6202 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date, l_start_date);
6203 l_new_end_date := l_end_date;
6204 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
6205 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
6206 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
6207 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_new_start_date;
6208 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_new_end_date;
6209 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
6210 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
6211 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'DA';
6212 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := l_schedule_percent;
6213 r_enc_period_tmp1.r_reason_code(l_rec_no) := l_reason_code;
6214 l_rec_no := l_rec_no + 1;
6215 l_asg_start_date := l_end_date + 1;
6216 IF (da_recno = r_da.start_date_active.COUNT) AND
6217 (l_asg_start_date <= l_asg_end_date) THEN
6218 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
6219 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
6220 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
6221 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
6222 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
6223 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
6224 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
6225 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
6226 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
6227 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
6228 l_rec_no := l_rec_no + 1;
6229 END IF;
6230 ELSE
6231 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
6232 r_enc_period_tmp1.r_period_start_date(l_rec_no) := l_period_start_date;
6233 r_enc_period_tmp1.r_period_end_date(l_rec_no) := l_period_end_date;
6234 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := l_asg_start_date;
6235 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := l_asg_end_date;
6236 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
6237 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
6238 r_enc_period_tmp1.r_process_flag(l_rec_no) := 'DA';
6239 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := l_schedule_percent;
6240 r_enc_period_tmp1.r_reason_code(l_rec_no) := l_reason_code;
6241 l_rec_no := l_rec_no + 1;
6242 l_asg_start_date := l_end_date + 1;
6243 END IF;
6244 END IF;
6245 l_sub_slice_counter := 2;
6246 ELSE
6247 IF (da_recno = r_da.start_date_active.COUNT) THEN
6248 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
6249 r_enc_period_tmp1.r_period_start_date(l_rec_no) := r_enc_period.r_period_start_date(I);
6250 r_enc_period_tmp1.r_period_end_date(l_rec_no) := r_enc_period.r_period_end_date(I);
6251 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := r_enc_period.r_asg_start_date(I);
6252 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := r_enc_period.r_asg_end_date(I);
6253 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
6254 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
6255 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
6256 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
6257 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
6258 l_rec_no := l_rec_no + 1;
6259 END IF;
6260 END IF;
6261 l_sch_pointer := da_recno;
6262 EXIT WHEN l_asg_start_date > l_asg_end_date;
6263 END LOOP;
6264 ELSE
6265 r_enc_period_tmp1.r_period_ind(l_rec_no) := r_enc_period.r_period_ind(I);
6266 r_enc_period_tmp1.r_period_start_date(l_rec_no) := r_enc_period.r_period_start_date(I);
6267 r_enc_period_tmp1.r_period_end_date(l_rec_no) := r_enc_period.r_period_end_date(I);
6268 r_enc_period_tmp1.r_asg_start_date(l_rec_no) := r_enc_period.r_asg_start_date(I);
6269 r_enc_period_tmp1.r_asg_end_date(l_rec_no) := r_enc_period.r_asg_end_date(I);
6270 r_enc_period_tmp1.r_time_period_id(l_rec_no) := r_enc_period.r_time_period_id(I);
6271 r_enc_period_tmp1.r_effective_date(l_rec_no) := r_enc_period.r_effective_date(I);
6272 r_enc_period_tmp1.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
6273 r_enc_period_tmp1.r_schedule_percent(l_rec_no) := r_enc_period.r_schedule_percent(I);
6274 r_enc_period_tmp1.r_reason_code(l_rec_no) := r_enc_period.r_reason_code(I);
6275 l_rec_no := l_rec_no + 1;
6276 END IF;
6277 END LOOP;
6278 hr_utility.trace('Dumping Assignment Chunk After Organization Default Account Processing ...');
6279 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
6280 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
6281 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
6282 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
6283 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
6284 RPAD('Reason Code', 50, ' '));
6285 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
6286 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
6287 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
6288 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
6289 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
6290 RPAD('-', 50, '-'));
6291
6292 FOR recno IN 1..r_enc_period_tmp1.r_time_period_id.COUNT
6293 LOOP
6294 hr_utility.trace(LPAD(r_enc_period_tmp1.r_period_ind(recno), 13, ' ') || ' ' ||
6295 LPAD(r_enc_period_tmp1.r_time_period_id(recno), 14, ' ') || ' ' ||
6296 RPAD(TO_CHAR(r_enc_period_tmp1.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
6297 RPAD(TO_CHAR(r_enc_period_tmp1.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
6298 RPAD(TO_CHAR(r_enc_period_tmp1.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
6299 RPAD(TO_CHAR(r_enc_period_tmp1.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
6300 RPAD(TO_CHAR(r_enc_period_tmp1.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
6301 RPAD(r_enc_period_tmp1.r_process_flag(recno), 12, ' ') || ' ' ||
6302 LPAD(r_enc_period_tmp1.r_schedule_percent(recno), 16, ' ') || ' ' ||
6303 RPAD(r_enc_period_tmp1.r_reason_code(recno), 50, ' '));
6304 END LOOP;
6305 ELSE
6306 FOR I IN 1..r_enc_period.r_time_period_id.COUNT
6307 LOOP
6308 r_enc_period_tmp1.r_period_ind(I) := r_enc_period.r_period_ind(I);
6309 r_enc_period_tmp1.r_period_start_date(I) := r_enc_period.r_period_start_date(I);
6310 r_enc_period_tmp1.r_period_end_date(I) := r_enc_period.r_period_end_date(I);
6311 r_enc_period_tmp1.r_asg_start_date(I) := r_enc_period.r_asg_start_date(I);
6312 r_enc_period_tmp1.r_asg_end_date(I) := r_enc_period.r_asg_end_date(I);
6313 r_enc_period_tmp1.r_time_period_id(I) := r_enc_period.r_time_period_id(I);
6314 r_enc_period_tmp1.r_process_flag(I) := r_enc_period.r_process_flag(I);
6315 r_enc_period_tmp1.r_schedule_percent(I) := r_enc_period.r_schedule_percent(I);
6316 r_enc_period_tmp1.r_reason_code(I) := r_enc_period.r_reason_code(I);
6317 r_enc_period_tmp1.r_effective_date(I) := r_enc_period.r_effective_date(I);
6318 END LOOP;
6319 END IF;
6320
6321 r_enc_period.r_time_period_id.DELETE;
6322 r_enc_period.r_period_start_date.DELETE;
6323 r_enc_period.r_period_end_date.DELETE;
6324 r_enc_period.r_asg_start_date.DELETE;
6325 r_enc_period.r_asg_end_date.DELETE;
6326 r_enc_period.r_process_flag.DELETE;
6327 r_enc_period.r_period_ind.DELETE;
6328 r_enc_period.r_schedule_percent.DELETE;
6329 r_enc_period.r_encumbrance_amount.DELETE;
6330 r_enc_period.r_period_amount.DELETE;
6331 r_enc_period.r_reason_code.DELETE;
6332 r_enc_period.r_effective_date.DELETE;
6333
6334 l_rec_no := 1;
6335 l_proc_step := 200;
6336
6337 hr_utility.trace('Organization Suspense Account Processing');
6338
6339 l_sch_pointer := 1;
6340 FOR I IN 1..r_enc_period_tmp1.r_time_period_id.COUNT
6341 LOOP
6342 l_period_start_date := r_enc_period_tmp1.r_period_start_date(I);
6343 l_period_end_date := r_enc_period_tmp1.r_period_end_date(I);
6344 l_asg_start_date := r_enc_period_tmp1.r_asg_start_date(I);
6345 l_asg_end_date := r_enc_period_tmp1.r_asg_end_date(I);
6346 l_process_flag := r_enc_period_tmp1.r_process_flag(I);
6347 l_sub_slice_counter := 1;
6348 l_proc_step := 210 + (I / 100000);
6349
6350 hr_utility.trace('I: ' || fnd_number.number_to_canonical(I) ||
6351 ' l_period_start_date: ' || fnd_date.date_to_canonical(l_period_start_date) ||
6352 ' l_period_end_date: ' || fnd_date.date_to_canonical(l_period_end_date) ||
6353 ' l_asg_start_date: ' || fnd_date.date_to_canonical(l_asg_start_date) ||
6354 ' l_asg_end_date: ' || fnd_date.date_to_canonical(l_asg_end_date) ||
6355 ' r_enc_period_tmp1.r_time_period_id(I): ' || fnd_number.number_to_canonical(r_enc_period_tmp1.r_time_period_id(I)) ||
6356 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no));
6357
6358 IF (l_process_flag IN ('BAL', 'Y')) AND (l_sch_pointer <= r_sa.end_date_active.COUNT) THEN
6359 IF (l_asg_start_date <= g_enc_org_end_date) THEN
6360 FOR sa_recno IN l_sch_pointer..r_sa.start_date_active.COUNT
6361 LOOP
6362 l_start_date:= r_sa.start_date_active(sa_recno);
6363 l_end_date:= r_sa.end_date_active(sa_recno);
6364 IF (l_process_flag = 'BAL') THEN
6365 l_schedule_percent := r_enc_period_tmp1.r_schedule_percent(I);
6366 ELSE
6367 l_schedule_percent:= r_sa.percent(sa_recno);
6368 END IF;
6369 l_proc_step := 220 + (l_rec_no / 100000);
6370
6371 hr_utility.trace('l_sub_slice_counter: ' || fnd_number.number_to_canonical(l_sub_slice_counter) ||
6372 ' l_rec_no: ' || fnd_number.number_to_canonical(l_rec_no) ||
6373 ' l_start_date: ' || fnd_date.date_to_canonical(l_start_date) ||
6374 ' l_end_date: ' || fnd_date.date_to_canonical(l_end_date) ||
6375 ' l_schedule_percent: ' || fnd_number.number_to_canonical(l_schedule_percent));
6376
6377 IF (r_sa.start_date_active(sa_recno) > l_asg_end_date) THEN
6378 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6379 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
6380 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
6381 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
6382 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
6383 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6384 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6385 r_enc_period.r_process_flag(l_rec_no) := r_enc_period_tmp1.r_process_flag(I);
6386 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
6387 r_enc_period.r_reason_code(l_rec_no) := l_reason_code;
6388 l_rec_no := l_rec_no + 1;
6389 EXIT;
6390 END IF;
6391
6392 IF (l_end_date >= l_asg_start_date) AND (l_start_date <= l_asg_end_date) THEN
6393 IF (l_process_flag = 'BAL') THEN
6394 l_reason_code := 'LDM_BAL_NOT_100_PERCENT';
6395 add_cel_warnings(p_start_date => l_asg_start_date,
6396 p_hierarchy_code => 'SA',
6397 p_end_date => l_asg_end_date,
6398 p_warning_code => 'BAL',
6399 p_percent => r_enc_period_tmp1.r_schedule_percent(I));
6400 ELSE
6401 l_reason_code := 'LDM_NO_CI_FOUND';
6402 add_cel_warnings(p_start_date => l_asg_start_date,
6403 p_hierarchy_code => 'SA',
6404 p_end_date => l_asg_end_date,
6405 p_warning_code => 'NO_CI');
6406 END IF;
6407 IF (l_asg_start_date = l_start_date AND l_asg_end_date = l_end_date) THEN
6408 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6409 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
6410 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
6411 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
6412 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
6413 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6414 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6415 r_enc_period.r_process_flag(l_rec_no) := 'SA';
6416 r_enc_period.r_schedule_percent(l_rec_no) := l_schedule_percent;
6417 r_enc_period.r_reason_code(l_rec_no) := l_reason_code;
6418 l_rec_no := l_rec_no + 1;
6419 ELSE
6420 IF (l_start_date > GREATEST(l_period_start_date, l_asg_start_date)) THEN
6421 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date);
6422 l_new_end_date := l_start_date - 1;
6423 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6424 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
6425 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
6426 r_enc_period.r_asg_start_date(l_rec_no) := l_new_start_date;
6427 r_enc_period.r_asg_end_date(l_rec_no) := l_new_end_date;
6428 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6429 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6430 r_enc_period.r_process_flag(l_rec_no) := l_process_flag;
6431 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
6432 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
6433 l_rec_no := l_rec_no + 1;
6434 l_asg_start_date := l_start_date;
6435 END IF;
6436 IF (l_end_date < LEAST(l_period_end_date, l_asg_end_date)) THEN
6437 l_new_start_date := GREATEST(l_period_start_date, l_asg_start_date, l_start_date);
6438 l_new_end_date := l_end_date;
6439 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6440 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
6441 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
6442 r_enc_period.r_asg_start_date(l_rec_no) := l_new_start_date;
6443 r_enc_period.r_asg_end_date(l_rec_no) := l_new_end_date;
6444 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6445 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6446 r_enc_period.r_process_flag(l_rec_no) := 'SA';
6447 r_enc_period.r_schedule_percent(l_rec_no) := l_schedule_percent;
6448 r_enc_period.r_reason_code(l_rec_no) := l_reason_code;
6449 l_rec_no := l_rec_no + 1;
6450 l_asg_start_date := l_end_date + 1;
6451 IF (sa_recno = r_sa.start_date_active.COUNT) AND
6452 (l_asg_start_date <= l_asg_end_date) THEN
6453 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6454 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
6455 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
6456 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
6457 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
6458 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6459 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6460 r_enc_period.r_process_flag(l_rec_no) := r_enc_period.r_process_flag(I);
6461 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
6462 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
6463 l_rec_no := l_rec_no + 1;
6464 END IF;
6465 ELSE
6466 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6467 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
6468 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
6469 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
6470 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
6471 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6472 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6473 r_enc_period.r_process_flag(l_rec_no) := 'SA';
6474 r_enc_period.r_schedule_percent(l_rec_no) := l_schedule_percent;
6475 r_enc_period.r_reason_code(l_rec_no) := l_reason_code;
6476 l_rec_no := l_rec_no + 1;
6477 l_asg_start_date := l_end_date + 1;
6478 END IF;
6479 END IF;
6480 l_sub_slice_counter := 2;
6481 ELSE
6482 IF (sa_recno = r_sa.start_date_active.COUNT) THEN
6483 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6484 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
6485 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
6486 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
6487 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
6488 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6489 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6490 r_enc_period.r_process_flag(l_rec_no) := r_enc_period_tmp1.r_process_flag(I);
6491 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
6492 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
6493 l_rec_no := l_rec_no + 1;
6494 END IF;
6495 END IF;
6496 l_sch_pointer := sa_recno;
6497 EXIT WHEN l_asg_start_date > l_asg_end_date;
6498 END LOOP;
6499 ELSE
6500 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6501 r_enc_period.r_period_start_date(l_rec_no) := l_period_start_date;
6502 r_enc_period.r_period_end_date(l_rec_no) := l_period_end_date;
6503 r_enc_period.r_asg_start_date(l_rec_no) := l_asg_start_date;
6504 r_enc_period.r_asg_end_date(l_rec_no) := l_asg_end_date;
6505 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6506 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6507 r_enc_period.r_process_flag(l_rec_no) := 'I';
6508 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
6509 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
6510 l_rec_no := l_rec_no + 1;
6511 END IF;
6512 ELSE
6513 r_enc_period.r_period_ind(l_rec_no) := r_enc_period_tmp1.r_period_ind(I);
6514 r_enc_period.r_period_start_date(l_rec_no) := r_enc_period_tmp1.r_period_start_date(I);
6515 r_enc_period.r_period_end_date(l_rec_no) := r_enc_period_tmp1.r_period_end_date(I);
6516 r_enc_period.r_asg_start_date(l_rec_no) := r_enc_period_tmp1.r_asg_start_date(I);
6517 r_enc_period.r_asg_end_date(l_rec_no) := r_enc_period_tmp1.r_asg_end_date(I);
6518 r_enc_period.r_time_period_id(l_rec_no) := r_enc_period_tmp1.r_time_period_id(I);
6519 r_enc_period.r_effective_date(l_rec_no) := r_enc_period_tmp1.r_effective_date(I);
6520 r_enc_period.r_process_flag(l_rec_no) := r_enc_period_tmp1.r_process_flag(I);
6521 r_enc_period.r_schedule_percent(l_rec_no) := r_enc_period_tmp1.r_schedule_percent(I);
6522 r_enc_period.r_reason_code(l_rec_no) := r_enc_period_tmp1.r_reason_code(I);
6523 l_rec_no := l_rec_no + 1;
6524 END IF;
6525 END LOOP;
6526
6527 r_enc_period_tmp1.r_time_period_id.DELETE;
6528 r_enc_period_tmp1.r_period_start_date.DELETE;
6529 r_enc_period_tmp1.r_period_end_date.DELETE;
6530 r_enc_period_tmp1.r_asg_start_date.DELETE;
6531 r_enc_period_tmp1.r_asg_end_date.DELETE;
6532 r_enc_period_tmp1.r_process_flag.DELETE;
6533 r_enc_period_tmp1.r_period_ind.DELETE;
6534 r_enc_period_tmp1.r_schedule_percent.DELETE;
6535 r_enc_period_tmp1.r_encumbrance_amount.DELETE;
6536 r_enc_period_tmp1.r_period_amount.DELETE;
6537 r_enc_period_tmp1.r_reason_code.DELETE;
6538 r_enc_period_tmp1.r_effective_date.DELETE;
6539 l_proc_step := 230;
6540
6541 hr_utility.trace('Dumping Assignment Chunk After Suspense Account Processing ...');
6542 hr_utility.trace(LPAD('Chunk Pointer', 13, ' ') || ' ' ||
6543 LPAD('Time Period Id', 14, ' ') || ' ' || RPAD('Period Start Date', 17, ' ') || ' ' ||
6544 RPAD('Period End Date', 15, ' ') || ' ' || RPAD('Asg Start Date', 14, ' ') || ' ' ||
6545 RPAD('Asg End Date', 12, ' ') || ' ' || RPAD('Effective Date', 14, ' ') || ' ' ||
6546 RPAD('Process Flag', 12, ' ') || ' ' || LPAD('Schedule Percent', 16, ' ') || ' ' ||
6547 RPAD('Reason Code', 50, ' '));
6548 hr_utility.trace(LPAD('-', 13, '-') || ' ' ||
6549 LPAD('-', 14, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
6550 RPAD('-', 15, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
6551 RPAD('-', 12, '-') || ' ' || RPAD('-', 14, '-') || ' ' ||
6552 RPAD('-', 12, '-') || ' ' || LPAD('-', 16, '-') || ' ' ||
6553 RPAD('-', 50, '-'));
6554
6555 FOR recno IN 1..r_enc_period.r_time_period_id.COUNT
6556 LOOP
6557 hr_utility.trace(LPAD(r_enc_period.r_period_ind(recno), 13, ' ') || ' ' ||
6558 LPAD(r_enc_period.r_time_period_id(recno), 14, ' ') || ' ' ||
6559 RPAD(TO_CHAR(r_enc_period.r_period_start_date(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
6560 RPAD(TO_CHAR(r_enc_period.r_period_end_date(recno), 'DD-MON-RRRR'), 15, ' ') || ' ' ||
6561 RPAD(TO_CHAR(r_enc_period.r_asg_start_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
6562 RPAD(TO_CHAR(r_enc_period.r_asg_end_date(recno), 'DD-MON-RRRR'), 12, ' ') || ' ' ||
6563 RPAD(TO_CHAR(r_enc_period.r_effective_date(recno), 'DD-MON-RRRR'), 14, ' ') || ' ' ||
6564 RPAD(r_enc_period.r_process_flag(recno), 12, ' ') || ' ' ||
6565 LPAD(r_enc_period.r_schedule_percent(recno), 16, ' ') || ' ' ||
6566 RPAD(r_enc_period.r_reason_code(recno), 50, ' '));
6567 r_enc_period.r_encumbrance_amount(recno) := 0;
6568 END LOOP;
6569 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving ' || l_proc_name);
6570
6571 p_return_status := fnd_api.g_ret_sts_success;
6572 EXCEPTION
6573 WHEN OTHERS THEN
6574 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
6575 IF (g_error_message IS NULL) THEN
6576 g_error_message := l_proc_name || ': ' || SQLERRM;
6577 END IF;
6578 g_error_api_path := SUBSTR(' SUB_SLICE_ASG_CHUNK:'||g_error_api_path,1,230);
6579 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', ' SUB_SLICE_ASG_CHUNK');
6580 p_return_status := fnd_api.g_ret_sts_unexp_error;
6581 fnd_file.put_line(fnd_file.log, fnd_number.number_to_canonical(l_proc_step) || ': ' || l_proc_name);
6582 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving ' || l_proc_name);
6583 END sub_slice_asg_chunk;
6584 -- End of bug fix 3462452
6585
6586 /*
6587
6588 13566809 : Generally CUEL uses PYUGEN process ,where CEL_RANGE_CODE is called once and basing on the number of threads the
6589 CEL_INIT and CEL_ARCHIVE will be initiated. Therefore variable declared in CEL_RANGE_CODE cannot be used in CEL_INIT and CEL_ARCHIVE.
6590
6591 Added the profile option functionality in the CEL_INIT procedure to capture the payroll mode before processing CEL_ARCHIVE.
6592 CUEL works in thread mode and every thread initiates its own CEL_INIT and its corresponding CEL_ARCHIVE process. So before processing
6593 CEL_ARCHIVE the payroll mode is set in CEL_INIT.
6594
6595 This profile option is also used in ENC_PRE_PROCESS procedure which is called from CEL_RANGE_CODE procedure but this is initiated
6596 only once. The profile option used here cannot be used in the CEL_ARCHIVE . So therefore we are using the profile option
6597 functionality in the both CEL_INIT and ENC_PRE_PROCESS.
6598
6599 */
6600
6601 PROCEDURE cel_init(p_payroll_action_id IN NUMBER) IS
6602 BEGIN
6603 fnd_file.put_line(fnd_file.log,fnd_date.date_to_canonical(SYSDATE) || ' FND :: Initializing the profile option ');
6604 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' HR :: Initializing the profile option ');
6605 g_payroll_mode := NVL(FND_PROFILE.VALUE('PSP_USING_ORACLE_PAYROLL'),'Y'); -- 13566809
6606 -- spc_track_cel('Init', NULL, 'Start');
6607 NULL;
6608 -- spc_track_cel('Init', NULL, 'End');
6609 EXCEPTION
6610 WHEN OTHERS THEN
6611 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
6612 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'CEL_INIT: SQLCODE: ' || fnd_number.number_to_canonical(SQLCODE) || ' SQLERRM: ' || SQLERRM);
6613 psp_message_s.print_error(p_mode => FND_FILE.LOG,
6614 p_print_header => FND_API.G_TRUE);
6615 END cel_init;
6616
6617 PROCEDURE cel_range_code (pactid IN NUMBER,
6618 sqlstr OUT NOCOPY VARCHAR2) IS
6619 l_payroll_id NUMBER(15);
6620 l_process_mode VARCHAR2(15);
6621 l_process_code VARCHAR2(15);
6622 l_return_status VARCHAR2(1);
6623 l_last_update_date DATE;
6624 l_last_updated_by NUMBER;
6625 l_last_updated_login NUMBER;
6626 l_request_id NUMBER;
6627 l_business_group_id NUMBER(15);
6628 l_set_of_books_id NUMBER(15);
6629 NO_UPDATE_REC_FOUND EXCEPTION;
6630
6631 CURSOR action_parameters_cur IS
6632 SELECT fnd_number.canonical_to_number(NVL(argument11, -1)),
6633 argument12
6634 FROM fnd_concurrent_requests
6635 WHERE request_id = l_request_id;
6636
6637 CURSOR enc_payrolls_cur IS
6638 SELECT pep.payroll_id
6639 FROM psp_enc_payrolls pep
6640 WHERE pep.business_group_id = l_business_group_id
6641 AND pep.set_of_books_id = l_set_of_books_id;
6642 BEGIN
6643 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering CEL_RANGE_CODE pactid: ' || pactid);
6644
6645 l_last_update_date := SYSDATE;
6646 l_last_updated_by := NVL(FND_GLOBAL.USER_ID, -1);
6647 l_last_updated_login := NVL(FND_GLOBAL.LOGIN_ID, -1);
6648 l_request_id := fnd_global.conc_request_id;
6649 l_set_of_books_id := FND_PROFILE.VALUE('GL_SET_OF_BKS_ID');
6650 l_business_group_id := FND_PROFILE.VALUE('PER_BUSINESS_GROUP_ID');
6651
6652 OPEN action_parameters_cur;
6653 FETCH action_parameters_cur INTO l_payroll_id, l_process_mode;
6654 CLOSE action_parameters_cur;
6655
6656 IF (l_payroll_id = -1) THEN
6657 l_payroll_id := NULL;
6658 END IF;
6659 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_payroll_id: ' || l_payroll_id || '
6660 process_mode: ' || l_process_mode);
6661
6662 l_process_code := 'CEL';
6663 IF (l_process_mode = 'TERMINATE') THEN
6664 l_process_code := 'LET';
6665 END IF;
6666
6667 INSERT INTO psp_enc_processes
6668 (request_id, process_code, payroll_action_id,
6669 process_status, process_phase, business_group_id,
6670 set_of_books_id, creation_date, created_by,
6671 last_update_date, last_updated_by, last_update_login)
6672 VALUES
6673 (l_request_id, l_process_code, pactid,
6674 'I', NULL, l_business_group_id,
6675 l_set_of_books_id, l_last_update_date, l_last_updated_by,
6676 l_last_update_date, l_last_updated_by, l_last_updated_login);
6677
6678 IF ((l_payroll_id IS NOT NULL) OR (l_process_mode = 'TERMINATE')) THEN
6679 enc_pre_process(pactid, l_payroll_id, l_process_mode, l_return_status);
6680
6681 IF l_return_status <> fnd_api.g_ret_sts_success THEN
6682 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6683 END IF;
6684 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);
6685 ELSE
6686 OPEN enc_payrolls_cur;
6687 LOOP
6688 FETCH enc_payrolls_cur INTO l_payroll_id;
6689 EXIT WHEN enc_payrolls_cur%NOTFOUND;
6690
6691 enc_pre_process(pactid, l_payroll_id, l_process_mode, l_return_status);
6692 IF l_return_status <> fnd_api.g_ret_sts_success THEN
6693 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6694 END IF;
6695 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);
6696 END LOOP;
6697 CLOSE enc_payrolls_cur;
6698 l_payroll_id := NULL;
6699 END IF;
6700
6701 sqlstr := 'SELECT DISTINCT assignment_id FROM psp_enc_changed_assignments WHERE ';
6702 IF (l_payroll_id IS NOT NULL) THEN
6703 sqlstr := sqlstr || 'payroll_id = ' || fnd_number.number_to_canonical(l_payroll_id) || ' AND ';
6704 END IF;
6705
6706 sqlstr := sqlstr || 'payroll_action_id = :payroll_action_id ORDER BY assignment_id';
6707
6708 INSERT INTO psp_enc_process_assignments
6709 (payroll_action_id, assignment_id, payroll_id,
6710 assignment_status, creation_date, created_by,
6711 last_update_date, last_updated_by, last_update_login)
6712 SELECT DISTINCT pactid, assignment_id, payroll_id,
6713 'I', l_last_update_date, l_last_updated_by,
6714 l_last_update_date, l_last_updated_by, l_last_updated_login
6715 FROM psp_enc_changed_assignments
6716 WHERE payroll_action_id = pactid;
6717
6718 IF (SQL%ROWCOUNT = 0) THEN
6719 fnd_message.set_name('PSP', 'PSP_ENC_NO_LIN_UPD');
6720 g_warning_message := fnd_message.get;
6721 fnd_file.put_line(fnd_file.log, g_warning_message);
6722 psp_general.add_report_error
6723 (p_request_id => l_request_id,
6724 p_message_level => 'N',
6725 p_source_id => NULL,
6726 p_source_name => NULL,
6727 p_error_message => g_warning_message,
6728 p_payroll_action_id => pactid,
6729 p_return_status => l_return_status);
6730 RAISE NO_UPDATE_REC_FOUND;
6731 END IF;
6732
6733 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' sqlstr: ' || sqlstr);
6734 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving CEL_RANGE_CODE pactid: ' || pactid);
6735 EXCEPTION
6736 WHEN NO_UPDATE_REC_FOUND THEN
6737 psp_message_s.print_error (p_mode => FND_FILE.LOG, p_print_header => FND_API.G_FALSE);
6738 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving CEL_RANGE_CODE pactid: ' || pactid);
6739 WHEN OTHERS THEN
6740 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
6741 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'CEL_RANGE_CODE: SQLCODE: ' || fnd_number.number_to_canonical(SQLCODE) || ' SQLERRM: ' || SQLERRM);
6742 psp_message_s.print_error(p_mode => FND_FILE.LOG,
6743 p_print_header => FND_API.G_TRUE);
6744 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving CEL_RANGE_CODE pactid: ' || pactid);
6745 END cel_range_code;
6746
6747 PROCEDURE cel_asg_action_code (p_pactid IN NUMBER,
6748 start_asg IN NUMBER,
6749 end_asg IN NUMBER,
6750 p_chunk_num IN NUMBER) IS
6751 CURSOR get_assignments_cur IS
6752 SELECT DISTINCT assignment_id
6753 FROM psp_enc_changed_assignments
6754 WHERE assignment_id BETWEEN start_asg AND end_asg
6755 AND payroll_action_id = p_pactid;
6756
6757 TYPE t_number_15 IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
6758 t_asg_array t_number_15;
6759 l_asg_action_id NUMBER(15);
6760 BEGIN
6761 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering CEL_ASG_ACTION_CODE p_pactid: ' || p_pactid || '
6762 start_asg: ' || start_asg || '
6763 end_asg: ' || end_asg || '
6764 p_chunk_num: ' || p_chunk_num);
6765
6766 OPEN get_assignments_cur;
6767 FETCH get_assignments_cur BULK COLLECT INTO t_asg_array;
6768 CLOSE get_assignments_cur;
6769
6770 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' t_asg_array.COUNT: ' || t_asg_array.COUNT);
6771 FOR recno IN 1..t_asg_array.COUNT
6772 LOOP
6773 SELECT pay_assignment_actions_s.NEXTVAL INTO l_asg_action_id FROM DUAL;
6774 hr_nonrun_asact.insact(l_asg_action_id,
6775 pactid => p_pactid,
6776 chunk => p_chunk_num,
6777 object_id => t_asg_array(recno),
6778 object_type => 'ASG',
6779 p_transient_action => TRUE);
6780 END LOOP;
6781 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving CEL_ASG_ACTION_CODE payroll_action_id: ' || p_pactid || '
6782 start_asg: ' || start_asg || '
6783 end_asg: ' || end_asg || '
6784 p_chunk_num: ' || p_chunk_num);
6785 END cel_asg_action_code;
6786
6787 PROCEDURE cel_archive (p_payroll_action_id IN NUMBER,
6788 p_chunk_number IN NUMBER) IS
6789 l_business_group_id NUMBER(15);
6790 l_set_of_books_id NUMBER(15);
6791 l_assignment_id NUMBER(15);
6792 l_payroll_id NUMBER(15);
6793 l_person_id NUMBER(15);
6794 l_organization_id NUMBER(15);
6795 l_assignment_number per_all_assignments_f.assignment_number%TYPE;
6796 l_payroll_name pay_all_payrolls_f.payroll_name%TYPE;
6797 l_full_name per_all_people_f.full_name%TYPE;
6798 l_organization_name hr_organization_units.name%TYPE;
6799 l_process_mode VARCHAR2(15);
6800 l_enc_begin_date DATE;
6801 l_min_asg_id NUMBER(15);
6802 l_max_asg_id NUMBER(15);
6803 l_enc_period_end_date DATE;
6804 l_enc_period_date DATE;
6805 l_element_type_id NUMBER;
6806 l_element_name pay_element_types_f.element_name%TYPE;
6807 l_return_status VARCHAR2(1);
6808 l_enc_org_end_date DATE;
6809 l_max_enc_date DATE;
6810 l_enc_create NUMBER;
6811 l_new_cust NUMBER;
6812 l_pre_process_mode VARCHAR2(1);
6813 l_profile_value BOOLEAN;
6814 l_max_enc_lines_date DATE;
6815 l_enc_create_lines NUMBER;
6816 l_max_enc_hist_date DATE;
6817 l_enclines_check BOOLEAN;
6818 l_enclines_index NUMBER;
6819 l_liq_only_count NUMBER(15);
6820 l_liq_all_count NUMBER(15);
6821 l_money_value NUMBER(15);
6822 l_hours_value NUMBER(15);
6823
6824 CURSOR payroll_id_cur IS
6825 SELECT fnd_number.canonical_to_number(NVL(argument11, -1)),
6826 argument12
6827 FROM fnd_concurrent_requests fcr,
6828 psp_enc_processes pep
6829 WHERE pep.payroll_action_id = p_payroll_action_id
6830 AND fcr.request_id = pep.request_id;
6831
6832 CURSOR get_asg_id_cur IS
6833 SELECT MIN(object_id),
6834 MAX(object_id)
6835 FROM pay_temp_object_actions
6836 WHERE payroll_action_id = p_payroll_action_id
6837 AND chunk_number = p_chunk_number;
6838
6839 CURSOR get_payroll_asg_cur IS
6840 SELECT DISTINCT payroll_id,
6841 assignment_id,
6842 change_date
6843 FROM psp_enc_changed_assignments peca
6844 WHERE assignment_id BETWEEN l_min_asg_id AND l_max_asg_id
6845 AND ( (l_process_mode = 'TERMINATE' AND change_type = 'TR')
6846 OR (l_process_mode = 'REGULAR' AND change_type <> 'TR'))
6847 AND payroll_id = NVL(l_payroll_id, payroll_id)
6848 AND NOT EXISTS(
6849 SELECT 1
6850 FROM psp_enc_process_assignments pepa
6851 WHERE pepa.assignment_id = peca.assignment_id
6852 AND assignment_status IN ('S','L')
6853 AND payroll_id = l_payroll_id
6854 )
6855 -- Added the above condition for the bug 13036705
6856 /*AND NOT EXISTS (SELECT 1
6857 FROM psp_enc_process_assignments pepa
6858 WHERE pepa.assignment_id = peca.assignment_id
6859 AND pepa.payroll_action_id = p_payroll_action_id
6860 AND pepa.assignment_status <> 'B')*/;
6861
6862 l_asg_sl_count number := 0 ;
6863 CURSOR earnings_element_cur(p_Assignment_ID NUMBER) IS
6864 SELECT DISTINCT
6865 pet.element_type_id,
6866 pc.costing_debit_or_credit
6867 FROM PAY_ELEMENT_ENTRIES_F pee,
6868 PAY_ELEMENT_LINKS_F pel,
6869 PAY_ELEMENT_TYPES_F pet,
6870 PER_ASSIGNMENTS_F pa,
6871 PAY_ELEMENT_CLASSIFICATIONS pc
6872 WHERE pee.assignment_id = p_assignment_id
6873 AND pa.assignment_id = p_assignment_id
6874 AND pee.effective_end_date >= pa.effective_start_date
6875 AND pee.effective_start_date <= pa.effective_end_date
6876 AND pee.element_link_id = pel.element_link_id
6877 AND pel.effective_end_date >= pa.effective_start_date
6878 AND pel.effective_start_date <= pa.effective_end_date
6879 AND pee.entry_type = 'E'
6880 AND pel.element_type_id = pet.element_type_id
6881 AND pet.effective_end_date >= pa.effective_start_date
6882 AND pet.effective_start_date <=pa.effective_end_date
6883 AND pel.business_group_id = l_business_group_id
6884 AND pet.element_type_id IN ( SELECT element_type_id
6885 FROM psp_enc_elements
6886 WHERE business_group_id = l_business_group_id
6887 AND set_of_books_id = l_set_of_books_id)
6888 AND pet.classification_id = pc.classification_id
6889 ORDER BY pet.element_type_id;
6890
6891 CURSOR c_max_enc_date (p_assignment_id NUMBER,
6892 p_element_type_id NUMBER,
6893 p_enc_begin_date DATE) IS
6894 SELECT COUNT(1),
6895 NVL(MAX(pelh.encumbrance_date),p_enc_begin_date)
6896 FROM psp_enc_lines_history pelh
6897 WHERE pelh.assignment_id = l_assignment_id
6898 AND pelh.enc_element_type_id = p_element_type_id
6899 AND pelh.payroll_id = l_payroll_id;
6900
6901 /* Bug 5642002: Replaced earned date with period end date */
6902 -- Modified the following cursor for bug 9862281
6903
6904
6905
6906 CURSOR c_last_pay_run (p_assignment_id NUMBER)IS
6907 SELECT /*+ INDEX(ppa PAY_PAYROLL_ACTIONS_N51)
6908 INDEX(ptp PER_TIME_PERIODS_N50) */
6909 Max(ptp.end_date)
6910 FROM pay_payroll_actions ppa,
6911 pay_assignment_actions paa,
6912 per_time_periods ptp
6913 WHERE ppa.payroll_action_id = paa.payroll_action_id (+)
6914 AND ppa.business_group_id = l_business_group_id
6915 AND ppa.payroll_id = l_payroll_id
6916 AND NVL(paa.assignment_id, p_assignment_id) = p_assignment_id
6917 AND ppa.action_type IN ( 'R','Q')
6918 AND NVL(paa.action_status, ppa.action_status) = 'C'
6919 and ppa.date_earned between ptp.start_date and ptp.end_date
6920 and ptp.payroll_id = ppa.payroll_id
6921 -- AND ppa.time_period_id = ptp.time_period_id -- Commented for the Bug 12647364
6922 ;
6923
6924
6925
6926
6927 CURSOR c_tp_start_date IS
6928 SELECT MIN(ptp.start_date)
6929 FROM per_time_periods ptp
6930 WHERE ptp.payroll_id = l_payroll_id;
6931
6932 CURSOR c_obtain_eff_date_option IS
6933 SELECT NVL(parameter_value,1)
6934 FROM psp_enc_setup_options peso
6935 WHERE peso.setup_parameter ='EFFECTIVE_DATE'
6936 AND peso.business_group_id = l_business_group_id
6937 AND peso.set_of_books_id = l_set_of_books_id;
6938
6939 CURSOR c_max_enc_lines_date (p_assignment_id NUMBER,
6940 p_element_type_id NUMBER,
6941 p_enc_begin_date DATE) IS
6942 SELECT COUNT(1), NVL(MAX(pel.encumbrance_date),p_enc_begin_date)
6943 FROM psp_enc_lines pel
6944 WHERE pel.enc_element_type_id = p_element_type_id
6945 AND pel.assignment_id = p_assignment_id
6946 AND pel.payroll_id = l_payroll_id;
6947
6948 CURSOR cel_request_id_cur IS
6949 SELECT request_id
6950 FROM pay_payroll_actions
6951 WHERE payroll_action_id = p_payroll_action_id;
6952
6953 CURSOR asg_number_cur (p_effective_date IN DATE) IS
6954 SELECT assignment_number,
6955 person_id,
6956 organization_id
6957 FROM per_all_assignments_f
6958 WHERE assignment_id = l_assignment_id
6959 AND payroll_id = l_payroll_id
6960 AND effective_end_date >= p_effective_date
6961 AND ROWNUM = 1;
6962
6963 CURSOR payroll_name_cur IS
6964 SELECT payroll_name
6965 FROM pay_all_payrolls_f
6966 WHERE payroll_id = l_payroll_id
6967 AND business_group_id = g_business_group_id
6968 AND gl_set_of_books_id = g_set_of_books_id;
6969
6970 CURSOR person_name_cur (p_effective_date IN DATE) IS
6971 SELECT full_name
6972 FROM per_all_people_f
6973 WHERE person_id = l_person_id
6974 AND effective_end_date >= p_effective_date
6975 AND ROWNUM = 1;
6976
6977 CURSOR org_name_cur IS
6978 SELECT name
6979 FROM hr_organization_units
6980 WHERE organization_id = l_organization_id;
6981
6982 CURSOR element_name_cur IS
6983 SELECT element_name
6984 FROM pay_element_types_f
6985 WHERE element_type_id = l_element_type_id
6986 AND ROWNUM = 1;
6987
6988 CURSOR emphours_config_cur IS
6989 SELECT pcv_information2 employee_hours
6990 FROM pqp_configuration_values
6991 WHERE pcv_information_category = 'PSP_IMPORT_EMPLOYEE_HOURS'
6992 AND legislation_code IS NULL
6993 AND NVL(business_group_id, l_business_group_id) = l_business_group_id;
6994
6995 CURSOR autopop_config_cur IS
6996 SELECT pcv_information1 global_element_autopop,
6997 pcv_information2 element_type_autopop,
6998 pcv_information3 element_class_autopop,
6999 pcv_information4 assignment_autopop,
7000 pcv_information5 default_schedule_autopop,
7001 pcv_information6 default_account_autopop,
7002 pcv_information7 suspense_account
7003 FROM pqp_configuration_values
7004 WHERE pcv_information_category = 'PSP_ENABLE_AUTOPOPULATION'
7005 AND legislation_code IS NULL
7006 AND NVL(business_group_id, l_business_group_id) = l_business_group_id
7007 ORDER BY business_group_id;
7008
7009 CURSOR liq_only_asg_cur IS
7010 SELECT COUNT(1)
7011 FROM psp_enc_changed_assignments
7012 WHERE assignment_id = l_assignment_id
7013 AND payroll_id = l_payroll_id
7014 AND payroll_action_id = p_payroll_action_id
7015 AND change_type <> 'LQ';
7016
7017 CURSOR liq_all_cur IS
7018 SELECT COUNT(1)
7019 FROM psp_enc_changed_assignments
7020 WHERE assignment_id = l_assignment_id
7021 AND payroll_id = l_payroll_id
7022 AND payroll_action_id = p_payroll_action_id
7023 AND change_type = 'ZZ';
7024
7025 CURSOR money_value_cur (p_element_type_id IN NUMBER) IS
7026 SELECT COUNT(1)
7027 FROM psp_enc_elements pee
7028 WHERE element_type_id = p_element_type_id
7029 AND ( formula_id IS NOT NULL
7030 OR EXISTS (SELECT 1
7031 FROM pay_input_values_f piv
7032 WHERE piv.input_value_id = pee.input_value_id
7033 AND SUBSTR(piv.uom, 1, 1) <> 'H'));
7034
7035 CURSOR hours_value_cur (p_element_type_id IN NUMBER) IS
7036 SELECT COUNT(1)
7037 FROM psp_enc_elements pee
7038 WHERE element_type_id = p_element_type_id
7039 AND ( formula_id IS NOT NULL
7040 OR EXISTS (SELECT 1
7041 FROM pay_input_values_f piv
7042 WHERE piv.input_value_id = pee.input_value_id
7043 AND SUBSTR(piv.uom, 1, 1) = 'H'));
7044
7045
7046 TYPE payid_tab IS TABLE OF per_all_assignments_f.payroll_id%TYPE INDEX BY BINARY_INTEGER;
7047 TYPE asgid_tab IS TABLE OF per_all_assignments_f.assignment_id%TYPE INDEX BY BINARY_INTEGER;
7048 TYPE term_date_tab IS TABLE OF DATE INDEX BY BINARY_INTEGER;
7049 TYPE t_asg_id_rec IS RECORD
7050 (payroll_array payid_tab,
7051 asg_array asgid_tab,
7052 term_date_array term_date_tab);
7053 t_assignments t_asg_id_rec;
7054
7055 TYPE enclinesasg_tab IS TABLE OF psp_enc_lines.assignment_id%TYPE INDEX BY BINARY_INTEGER;
7056 TYPE enclinesele_tab IS TABLE OF psp_enc_lines.enc_element_type_id%TYPE INDEX BY BINARY_INTEGER;
7057 TYPE enclinesdat_tab IS TABLE OF psp_enc_lines.encumbrance_date%TYPE INDEX BY BINARY_INTEGER;
7058 TYPE t_enclines_rec IS RECORD
7059 (asg_array enclinesasg_tab,
7060 ele_array enclinesele_tab,
7061 dat_array enclinesdat_tab);
7062 t_enclines t_enclines_rec;
7063
7064 PROCEDURE log_cel_warnings IS
7065 CURSOR project_number_cur (p_project_id IN NUMBER) IS
7066 SELECT SEGMENT1
7067 FROM pa_projects_all
7068 WHERE project_id = p_project_id;
7069
7070 CURSOR award_number_cur (p_award_id IN NUMBER) IS
7071 SELECT award_number
7072 FROM gms_awards_all
7073 WHERE award_id = p_award_id;
7074
7075 CURSOR task_number_cur (p_task_id IN NUMBER) IS
7076 SELECT task_number
7077 FROM pa_tasks_expend_v -- Bug : 16391366 (20/03/2013)
7078 WHERE task_id = p_task_id;
7079
7080 CURSOR exp_org_name_cur (p_expenditure_org_id IN NUMBER) IS
7081 SELECT name
7082 FROM hr_organization_units
7083 WHERE organization_id = p_expenditure_org_id;
7084
7085 l_project_number pa_projects_all.segment1%TYPE;
7086 l_task_number VARCHAR2(300); -- pa_tasks.task_number%TYPE; Bug : 16391366 (27/03/2013)
7087 l_award_number gms_awards_all.award_number%TYPE;
7088 l_exp_org_name hr_organization_units.name%TYPE;
7089 l_gl_description VARCHAR2(1000);
7090 BEGIN
7091 FOR recno IN 1..cel_warnings.start_date.COUNT
7092 LOOP
7093 OPEN asg_number_cur(cel_warnings.start_date(recno));
7094 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
7095 CLOSE asg_number_cur;
7096
7097 OPEN payroll_name_cur;
7098 FETCH payroll_name_cur INTO l_payroll_name;
7099 CLOSE payroll_name_cur;
7100
7101 OPEN person_name_cur(cel_warnings.start_date(recno));
7102 FETCH person_name_cur INTO l_full_name;
7103 CLOSE person_name_cur;
7104
7105 OPEN org_name_cur;
7106 FETCH org_name_cur INTO l_organization_name;
7107 CLOSE org_name_cur;
7108
7109 OPEN element_name_cur;
7110 FETCH element_name_cur INTO l_element_name;
7111 CLOSE element_name_cur;
7112
7113 IF (cel_warnings.warning_code(recno) = 'BAL') THEN
7114 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_BALNOT100');
7115 fnd_message.set_token('START_DATE', cel_warnings.start_date(recno));
7116 fnd_message.set_token('END_DATE', cel_warnings.end_date(recno));
7117 fnd_message.set_token('PERCENT', cel_warnings.percent(recno));
7118 g_warning_message := fnd_message.get;
7119 ELSIF (cel_warnings.warning_code(recno) = 'GL') THEN
7120 fnd_message.set_name('PSP', 'PSP_CANNOT_ENC_HOURS_TO_GL');
7121 fnd_message.set_token('START_DATE', cel_warnings.start_date(recno));
7122 fnd_message.set_token('END_DATE', cel_warnings.end_date(recno));
7123 fnd_message.set_token('HOURS', cel_warnings.percent(recno));
7124 g_warning_message := fnd_message.get;
7125 ELSIF (cel_warnings.warning_code(recno) = 'AUTOPOP') AND
7126 (cel_warnings.gl_ccid(recno) IS NOT NULL) THEN
7127 l_gl_description := psp_general.get_gl_values(g_set_of_books_id, cel_warnings.gl_ccid(recno));
7128 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_AUTOPOP');
7129 fnd_message.set_token('START_DATE', cel_warnings.start_date(recno));
7130 fnd_message.set_token('END_DATE', cel_warnings.end_date(recno));
7131 fnd_message.set_token('GL', l_gl_description);
7132 fnd_message.set_token('AUTOPOP_STATUS', cel_warnings.error_status(recno));
7133 g_warning_message := fnd_message.get;
7134 ELSIF (cel_warnings.warning_code(recno) = 'AUTOPOP') AND (cel_warnings.gl_ccid(recno) IS NULL) THEN
7135 OPEN project_number_cur(cel_warnings.project_id(recno));
7136 FETCH project_number_cur INTO l_project_number;
7137 CLOSE project_number_cur;
7138
7139 OPEN award_number_cur(cel_warnings.award_id(recno));
7140 FETCH award_number_cur INTO l_award_number;
7141 CLOSE award_number_cur;
7142
7143 OPEN task_number_cur(cel_warnings.task_id(recno));
7144 FETCH task_number_cur INTO l_task_number;
7145 CLOSE task_number_cur;
7146
7147 OPEN exp_org_name_cur(cel_warnings.exp_org_id(recno));
7148 FETCH exp_org_name_cur INTO l_exp_org_name;
7149 CLOSE exp_org_name_cur;
7150
7151 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_AP_PATEO');
7152 fnd_message.set_token('START_DATE', cel_warnings.start_date(recno));
7153 fnd_message.set_token('END_DATE', cel_warnings.end_date(recno));
7154 fnd_message.set_token('PJ', l_project_number);
7155 fnd_message.set_token('TK', l_task_number);
7156 fnd_message.set_token('AW', l_award_number);
7157 fnd_message.set_token('EO', l_exp_org_name);
7158 fnd_message.set_token('ET', cel_warnings.exp_type(recno));
7159 fnd_message.set_token('AUTOPOP_STATUS', cel_warnings.error_status(recno));
7160 g_warning_message := fnd_message.get;
7161 ELSIF (cel_warnings.warning_code(recno) = 'NO_CI') THEN
7162 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_NOCI');
7163 fnd_message.set_token('START_DATE', cel_warnings.start_date(recno));
7164 fnd_message.set_token('END_DATE', cel_warnings.end_date(recno));
7165 g_warning_message := fnd_message.get;
7166 ELSIF (cel_warnings.warning_code(recno) = 'INVALID_CI') THEN
7167 OPEN project_number_cur(cel_warnings.project_id(recno));
7168 FETCH project_number_cur INTO l_project_number;
7169 CLOSE project_number_cur;
7170
7171 OPEN award_number_cur(cel_warnings.award_id(recno));
7172 FETCH award_number_cur INTO l_award_number;
7173 CLOSE award_number_cur;
7174
7175 OPEN task_number_cur(cel_warnings.task_id(recno));
7176 FETCH task_number_cur INTO l_task_number;
7177 CLOSE task_number_cur;
7178
7179 OPEN exp_org_name_cur(cel_warnings.exp_org_id(recno));
7180 FETCH exp_org_name_cur INTO l_exp_org_name;
7181 CLOSE exp_org_name_cur;
7182
7183 IF (cel_warnings.error_status(recno) IS NOT NULL) THEN
7184 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_INV_PATEO');
7185 fnd_message.set_token('PJ', l_project_number);
7186 fnd_message.set_token('TK', l_task_number);
7187 fnd_message.set_token('AW', l_award_number);
7188 fnd_message.set_token('EO', l_exp_org_name);
7189 fnd_message.set_token('ET', cel_warnings.exp_type(recno));
7190 fnd_message.set_token('START_DATE', cel_warnings.start_date(recno));
7191 fnd_message.set_token('END_DATE', cel_warnings.end_date(recno));
7192 fnd_message.set_token('ERROR_STATUS', cel_warnings.error_status(recno));
7193 ELSE
7194 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_END_PATEO');
7195 fnd_message.set_token('PJ', l_project_number);
7196 fnd_message.set_token('TK', l_task_number);
7197 fnd_message.set_token('AW', l_award_number);
7198 fnd_message.set_token('EO', l_exp_org_name);
7199 fnd_message.set_token('ET', cel_warnings.exp_type(recno));
7200 fnd_message.set_token('START_DATE', cel_warnings.start_date(recno));
7201 fnd_message.set_token('END_DATE', cel_warnings.end_date(recno));
7202 fnd_message.set_token('EFFECTIVE_DATE', cel_warnings.effective_date(recno));
7203 END IF;
7204 g_warning_message := fnd_message.get;
7205 END IF;
7206
7207 psp_general.add_report_error
7208 (p_request_id => g_request_id,
7209 p_message_level => 'W',
7210 p_source_id => l_assignment_id,
7211 p_source_name => l_assignment_number,
7212 p_parent_source_id => l_person_id,
7213 p_parent_source_name => l_full_name,
7214 p_error_message => g_warning_message,
7215 p_payroll_action_id => p_payroll_action_id,
7216 p_value1 => l_payroll_id,
7217 p_information1 => l_payroll_name,
7218 p_value2 => l_organization_id,
7219 p_value3 => l_element_type_id,
7220 p_information2 => l_organization_name,
7221 p_information3 => l_element_name,
7222 p_information4 => fnd_date.date_to_canonical(cel_warnings.start_date(recno)),
7223 p_information5 => fnd_date.date_to_canonical(cel_warnings.end_date(recno)),
7224 p_information6 => cel_warnings.hierarchy_code(recno),
7225 p_information7 => cel_warnings.error_status(recno),
7226 p_return_status => l_return_status);
7227 END LOOP;
7228 cel_warnings.start_date.DELETE;
7229 cel_warnings.end_date.DELETE;
7230 cel_warnings.warning_code.DELETE;
7231 cel_warnings.project_id.DELETE;
7232 cel_warnings.task_id.DELETE;
7233 cel_warnings.award_id.DELETE;
7234 cel_warnings.exp_org_id.DELETE;
7235 cel_warnings.exp_type.DELETE;
7236 cel_warnings.effective_date.DELETE;
7237 cel_warnings.error_status.DELETE;
7238 cel_warnings.percent.DELETE;
7239 END log_cel_warnings;
7240 BEGIN
7241 SAVEPOINT CEL_ARCHIVE;
7242 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 ||')');
7243
7244 l_set_of_books_id := FND_PROFILE.VALUE('GL_SET_OF_BKS_ID');
7245 l_business_group_id := FND_PROFILE.VALUE('PER_BUSINESS_GROUP_ID');
7246 g_set_of_books_id := l_set_of_books_id;
7247 g_business_group_id := l_business_group_id;
7248 g_enc_line_type := 'U';
7249 g_package_name := 'PSP_ENC_CREATE_LINES.';
7250 g_payroll_action_id := p_payroll_action_id;
7251 g_dff_grouping_option := psp_general.get_enc_dff_grouping_option(l_business_group_id);
7252
7253 OPEN cel_request_id_cur;
7254 FETCH cel_request_id_cur INTO g_request_id;
7255 CLOSE cel_request_id_cur;
7256
7257 OPEN emphours_config_cur;
7258 FETCH emphours_config_cur INTO g_employee_hours;
7259 IF (emphours_config_cur%ROWCOUNT = 0) THEN
7260 g_employee_hours := 'N';
7261 END IF;
7262 CLOSE emphours_config_cur;
7263
7264 OPEN autopop_config_cur;
7265 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;
7266 IF (autopop_config_cur%ROWCOUNT = 0) THEN
7267 g_ge_autopop := 'N';
7268 g_et_autopop := 'N';
7269 g_eg_autopop := 'N';
7270 g_as_autopop := 'N';
7271 g_ds_autopop := 'N';
7272 g_da_autopop := 'N';
7273 g_sa_autopop := 'N';
7274 END IF;
7275 CLOSE autopop_config_cur;
7276
7277 OPEN c_obtain_eff_date_option;
7278 FETCH c_obtain_eff_date_option INTO g_Eff_Date_Value;
7279 CLOSE c_obtain_eff_date_option;
7280
7281 OPEN payroll_id_cur;
7282 FETCH payroll_id_cur INTO l_payroll_id, l_process_mode;
7283 CLOSE payroll_id_cur;
7284 IF (l_payroll_id = -1) THEN
7285 l_payroll_id := NULL;
7286 END IF;
7287
7288 l_enc_create_lines := 1;
7289 l_enclines_index := 1;
7290 l_enc_create := 1;
7291 l_pre_process_mode:= 'R';
7292 g_currency_code := psp_general.get_currency_code(l_business_group_id);
7293 psp_general.get_currency_precision(g_currency_code,g_precision,g_ext_precision);
7294 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' g_enc_line_type: U
7295 g_request_id: ' || g_request_id || '
7296 g_payroll_action_id: ' || g_payroll_action_id || '
7297 g_currency_code: ' || g_currency_code || '
7298 g_ge_autopop: ' || g_ge_autopop || ' g_et_autopop: ' || g_et_autopop ||
7299 ' g_eg_autopop: ' || g_eg_autopop || ' g_as_autopop: ' || g_as_autopop ||
7300 ' g_ds_autopop: ' || g_ds_autopop || ' g_da_autopop: ' || g_da_autopop ||
7301 ' g_sa_autopop: ' || g_sa_autopop);
7302
7303 OPEN c_obtain_eff_date_option;
7304 FETCH c_obtain_eff_date_option INTO g_eff_date_value;
7305 CLOSE c_obtain_eff_date_option;
7306
7307 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' g_eff_date_value: ' || g_eff_date_value);
7308
7309 obtain_enc_org_end_date(p_enc_org_end_date => l_enc_org_end_date,
7310 p_business_group_id => l_business_group_id,
7311 p_set_of_books_id => l_set_of_books_id,
7312 p_return_status => l_return_status);
7313 IF l_return_status <> fnd_api.g_ret_sts_success THEN
7314 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7315 END IF;
7316 g_enc_org_end_date := l_enc_org_end_date ;
7317 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' g_enc_org_end_date: ' || fnd_date.date_to_canonical(g_enc_org_end_date));
7318
7319 OPEN get_asg_id_cur;
7320 FETCH get_asg_id_cur INTO l_min_asg_id, l_max_asg_id;
7321 CLOSE get_asg_id_cur;
7322 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);
7323
7324 OPEN get_payroll_asg_cur;
7325 FETCH get_payroll_asg_cur BULK COLLECT INTO t_assignments.payroll_array, t_assignments.asg_array, t_assignments.term_date_array;
7326 CLOSE get_payroll_asg_cur;
7327
7328 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' t_assignments.asg_array.COUNT: ' || t_assignments.asg_array.COUNT);
7329 --Bug 13036705
7330 for k in 1.. t_assignments.asg_array.COUNT
7331 loop
7332 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || k||')'||' asg: '||t_assignments.asg_array(k)
7333 ||' payroll: '||t_assignments.payroll_array(k)
7334 ||' term date: '||t_assignments.term_date_array(k));
7335
7336 select count(*)
7337 into l_asg_sl_count
7338 from psp_enc_process_assignments
7339 where assignment_id = t_assignments.asg_array(k)
7340 and assignment_status in ('S','L');
7341 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' count: '||l_asg_sl_count);
7342
7343 end loop;
7344 --Bug 13036705
7345 FOR recno IN 1 ..t_assignments.asg_array.COUNT
7346 LOOP
7347 l_assignment_id := t_assignments.asg_array(recno);
7348 l_payroll_id := t_assignments.payroll_array(recno);
7349 g_enc_lines_counter := 1;
7350 g_actual_term_date := t_assignments.term_date_array(recno);
7351 -- l_enc_begin_date := NULL;
7352
7353 OPEN liq_only_asg_cur;
7354 FETCH liq_only_asg_cur INTO l_liq_only_count;
7355 CLOSE liq_only_asg_cur;
7356
7357 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_liq_only_count: '||l_liq_only_count);
7358
7359 OPEN liq_all_cur;
7360 FETCH liq_all_cur INTO l_liq_all_count;
7361 CLOSE liq_all_cur;
7362
7363 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_liq_all_count: '||l_liq_all_count);
7364
7365 IF ((l_liq_all_count =0) AND (l_liq_only_count > 0)) THEN
7366 delete_previous_error_log(p_assignment_id => l_assignment_id,
7367 p_payroll_id => l_payroll_id,
7368 p_payroll_action_id => p_payroll_action_id);
7369
7370 /* commented for bug 5581265: Need to consider date earn at each assignment level instead of payroll */
7371 -- IF ((recno = 1) OR (l_payroll_id <> t_assignments.payroll_array(recno-1))) THEN
7372 l_enc_begin_date := NULL;
7373
7374 --13566809 : Separate mechanism is handled for ORACLE and OTHER payroll as both are accessing different queries
7375
7376 IF g_payroll_mode = 'N' THEN
7377
7378 -- 13566809 : For OTHER payroll we are using the same old cursor c_last_pay_run.
7379
7380 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' g_payroll_mode : N ');
7381
7382 OPEN c_last_pay_run(t_assignments.asg_array(recno));
7383 FETCH c_last_pay_run INTO l_enc_begin_date;
7384 CLOSE c_last_pay_run;
7385
7386
7387 ELSIF g_payroll_mode = 'Y' THEN
7388
7389 /* 13566809 : For Oracle payroll instead of using the C_LAST_PAY_RUN cursor we are using the caching mechanism to improve performance.
7390 So therefore in this process at this place earlier the query C_LAST_PAY_RUN cursor was used and this has outer join.
7391 But now when calling GET_ASG_PAY_END_DATE function, this uses cursor query ORACLE_PAYROLL_ASG_END_DATE which does not
7392 have outer join and this is a common query which is already used in CEL_RANGE_CODE */
7393
7394 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' g_payroll_mode : Y ');
7395
7396 l_enc_begin_date := get_asg_pay_end_date(NULL,p_payroll_action_id,l_assignment_id,l_business_group_id,l_payroll_id); --13566809
7397
7398 END IF;
7399
7400 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_enc_begin_date 1 '||l_enc_begin_date);
7401
7402
7403 IF l_enc_begin_date IS NULL THEN
7404 OPEN c_tp_start_date;
7405 FETCH c_tp_start_date INTO l_enc_begin_date;
7406 CLOSE c_tp_start_date;
7407 END IF;
7408
7409 -- END IF;
7410 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_enc_begin_date 2 '||l_enc_begin_date);
7411
7412
7413 OPEN earnings_element_cur(l_assignment_id);
7414 LOOP
7415 FETCH earnings_element_cur INTO l_element_type_id, g_dr_cr_flag;
7416 EXIT WHEN earnings_element_cur%NOTFOUND ;
7417
7418 OPEN money_value_cur(l_element_type_id);
7419 FETCH money_value_cur INTO l_money_value;
7420 CLOSE money_value_cur;
7421
7422 IF (l_money_value > 0) THEN
7423 g_uom := 'M';
7424
7425 OPEN c_max_enc_date(l_assignment_id, l_element_type_id, l_enc_begin_date);
7426 FETCH c_max_enc_date INTO l_enc_create, l_max_enc_hist_date;
7427 CLOSE c_max_enc_date;
7428
7429 OPEN c_max_enc_lines_date(l_assignment_id, l_element_type_id, l_enc_begin_date);
7430 FETCH c_max_enc_lines_date INTO l_enc_create_lines, l_max_enc_lines_date;
7431 CLOSE c_max_enc_lines_date;
7432
7433 l_max_enc_date := GREATEST(l_max_enc_lines_date, l_max_enc_hist_date);
7434
7435 IF l_enc_create = 0 AND l_enc_create_lines = 0 THEN
7436 l_enc_create :=1;
7437 END IF;
7438 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' g_actual_term_date: ' || fnd_date.date_to_canonical(g_actual_term_date) || '
7439 l_max_enc_date: ' || fnd_date.date_to_canonical(l_max_enc_date) || '
7440 l_enc_create: ' || l_enc_create);
7441
7442 IF l_enc_create > 0 THEN
7443 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' p_chunk_number: ' || p_chunk_number || '
7444 p_assignment_id => ' || l_assignment_id || '
7445 p_payroll_id => ' || l_payroll_id || '
7446 p_element_type_id => ' || l_element_type_id || '
7447 p_business_group_id => ' || l_business_group_id || '
7448 p_set_of_books_id => ' || l_set_of_books_id || '
7449 p_last_paid_date => ' || l_enc_begin_date || '
7450 p_max_enc_date => ' || l_max_enc_date);
7451 create_lines( p_assignment_id => l_assignment_id,
7452 p_payroll_id => l_payroll_id,
7453 p_element_type_id => l_element_type_id,
7454 -- p_business_group_id => l_business_group_id,
7455 -- p_set_of_books_id => l_set_of_books_id,
7456 p_last_paid_date => l_enc_begin_date,
7457 -- p_max_enc_date => l_max_enc_date,
7458 p_return_status => l_return_status);
7459 IF l_return_status <> fnd_api.g_ret_sts_success THEN
7460 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7461 END IF;
7462 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);
7463 log_cel_warnings;
7464 END IF;
7465 END IF;
7466 IF (g_employee_hours = 'Y') THEN
7467 OPEN hours_value_cur(l_element_type_id);
7468 FETCH hours_value_cur INTO l_hours_value;
7469 CLOSE hours_value_cur;
7470
7471 IF (l_hours_value > 0) THEN
7472 g_uom := 'H';
7473 psp_general.get_currency_precision('STAT',g_precision,g_ext_precision);
7474 OPEN c_max_enc_date(l_assignment_id, l_element_type_id, l_enc_begin_date);
7475 FETCH c_max_enc_date INTO l_enc_create, l_max_enc_hist_date;
7476 CLOSE c_max_enc_date;
7477
7478 OPEN c_max_enc_lines_date(l_assignment_id, l_element_type_id, l_enc_begin_date);
7479 FETCH c_max_enc_lines_date INTO l_enc_create_lines, l_max_enc_lines_date;
7480 CLOSE c_max_enc_lines_date;
7481
7482 l_max_enc_date := GREATEST(l_max_enc_lines_date, l_max_enc_hist_date);
7483
7484 IF l_enc_create = 0 AND l_enc_create_lines = 0 THEN
7485 l_enc_create :=1;
7486 END IF;
7487 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' g_actual_term_date: ' || fnd_date.date_to_canonical(g_actual_term_date) || '
7488 l_max_enc_date: ' || fnd_date.date_to_canonical(l_max_enc_date) || '
7489 l_enc_create: ' || l_enc_create);
7490
7491 IF l_enc_create > 0 THEN
7492 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' p_chunk_number: ' || p_chunk_number || '
7493 p_assignment_id => ' || l_assignment_id || '
7494 p_payroll_id => ' || l_payroll_id || '
7495 p_element_type_id => ' || l_element_type_id || '
7496 p_business_group_id => ' || l_business_group_id || '
7497 p_set_of_books_id => ' || l_set_of_books_id || '
7498 p_last_paid_date => ' || l_enc_begin_date || '
7499 p_max_enc_date => ' || l_max_enc_date);
7500 create_lines( p_assignment_id => l_assignment_id,
7501 p_payroll_id => l_payroll_id,
7502 p_element_type_id => l_element_type_id,
7503 -- p_business_group_id => l_business_group_id,
7504 -- p_set_of_books_id => l_set_of_books_id,
7505 p_last_paid_date => l_enc_begin_date,
7506 -- p_max_enc_date => l_max_enc_date,
7507 p_return_status => l_return_status);
7508 IF l_return_status <> fnd_api.g_ret_sts_success THEN
7509 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7510 END IF;
7511 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);
7512 log_cel_warnings;
7513 END IF;
7514 END IF;
7515 END IF;
7516
7517 END LOOP;
7518
7519 IF (earnings_element_cur%ROWCOUNT = 0) THEN
7520 fnd_file.put_line(fnd_file.log, 'No element found for encumbrance.');
7521 END IF;
7522 CLOSE earnings_element_cur;
7523
7524 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);
7525 verify_changes(p_payroll_id => l_payroll_id,
7526 p_assignment_id => l_assignment_id,
7527 p_business_group_id => l_business_group_id,
7528 p_set_of_books_id => l_set_of_books_id,
7529 p_enc_line_type => 'U',
7530 l_retcode => l_return_status);
7531
7532 IF l_return_status <> fnd_api.g_ret_sts_success THEN
7533 RAISE fnd_api.g_exc_unexpected_error;
7534 END IF;
7535 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Completed verify_changes for l_assignment_id: ' || l_assignment_id || ' payroll_id: ' || l_payroll_id);
7536 ELSE
7537 IF (l_liq_all_count > 0) THEN
7538 UPDATE psp_enc_lines_history pelh
7539 SET change_flag = 'N'
7540 WHERE assignment_id = l_assignment_id
7541 AND payroll_id = l_payroll_id
7542 AND change_flag = 'U'
7543 AND EXISTS (SELECT 1
7544 FROM psp_enc_summary_lines pesl
7545 WHERE pesl.assignment_id = l_assignment_id
7546 AND pesl.payroll_id = l_payroll_id
7547 AND status_code = 'A'
7548 AND pesl.enc_summary_line_id = pelh.enc_summary_line_id);
7549 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Updated lines to be liquidated');
7550 DELETE psp_enc_changed_assignments
7551 WHERE assignment_id = l_assignment_id
7552 AND payroll_id = l_payroll_id
7553 AND change_type = 'ZZ';
7554 ELSE
7555 UPDATE psp_enc_lines_history pelh
7556 SET change_flag = 'N'
7557 WHERE assignment_id = l_assignment_id
7558 AND payroll_id = l_payroll_id
7559 AND change_flag = 'U'
7560 AND EXISTS (SELECT 1
7561 FROM psp_enc_summary_lines pesl
7562 WHERE pesl.assignment_id = l_assignment_id
7563 AND pesl.payroll_id = l_payroll_id
7564 AND status_code = 'A'
7565 AND pesl.enc_summary_line_id = pelh.enc_summary_line_id
7566 AND pesl.effective_date <= (NVL((get_payroll_pay_end_date(l_payroll_id)
7567 -- and ptp.time_period_id = ppa.time_period_id -- Added for 11661463 -- Commented for the Bug 12647364
7568 ),l_enc_begin_date)) );
7569
7570 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Updated lines to be liquidated by regular liquidation');
7571 UPDATE psp_enc_lines_history pelh
7572 SET change_flag = 'U'
7573 WHERE assignment_id = l_assignment_id
7574 AND payroll_id = l_payroll_id
7575 AND change_flag = 'N'
7576 AND EXISTS (SELECT 1
7577 FROM psp_enc_summary_lines pesl
7578 WHERE pesl.assignment_id = l_assignment_id
7579 AND pesl.payroll_id = l_payroll_id
7580 AND status_code = 'A'
7581 AND pesl.enc_summary_line_id = pelh.enc_summary_line_id
7582 AND pesl.effective_date > (NVL((get_payroll_pay_end_date(l_payroll_id)
7583 -- and ptp.time_period_id = ppa.time_period_id -- Added for 11661463 -- Commented for the Bug 12647364
7584 ),l_enc_begin_date)) );
7585
7586 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Updated lines not to be liquidated by regular liquidation');
7587 END IF;
7588 END IF;
7589
7590 create_liq_lines (p_payroll_action_id => p_payroll_action_id,
7591 p_payroll_id => l_payroll_id,
7592 p_assignment_id => l_assignment_id,
7593 p_enc_begin_date => l_enc_begin_date,
7594 p_business_group_id => l_business_group_id,
7595 p_set_of_books_id => l_set_of_books_id,
7596 p_return_status => l_return_status);
7597
7598 IF l_return_status <> fnd_api.g_ret_sts_success THEN
7599 RAISE fnd_api.g_exc_unexpected_error;
7600 END IF;
7601 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);
7602
7603 create_sum_lines (p_payroll_action_id => p_payroll_action_id,
7604 p_payroll_id => l_payroll_id,
7605 p_assignment_id => l_assignment_id,
7606 p_business_group_id => l_business_group_id,
7607 p_set_of_books_id => l_set_of_books_id,
7608 p_return_status => l_return_status);
7609
7610 IF l_return_status <> fnd_api.g_ret_sts_success THEN
7611 RAISE fnd_api.g_exc_unexpected_error;
7612 END IF;
7613 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);
7614
7615 update_hierarchy_dates (p_payroll_action_id => p_payroll_action_id,
7616 p_payroll_id => l_payroll_id,
7617 p_assignment_id => l_assignment_id,
7618 p_return_status => l_return_status);
7619
7620 IF l_return_status <> fnd_api.g_ret_sts_success THEN
7621 RAISE fnd_api.g_exc_unexpected_error;
7622 END IF;
7623 END LOOP;
7624
7625 FORALL recno IN 1..t_assignments.asg_array.COUNT
7626 UPDATE psp_enc_process_assignments pepa
7627 SET assignment_status = 'B'
7628 WHERE pepa.payroll_action_id = p_payroll_action_id
7629 AND pepa.assignment_id = t_assignments.asg_array(recno)
7630 AND pepa.payroll_id = t_assignments.payroll_array(recno)
7631 AND NOT EXISTS (SELECT 1
7632 FROM psp_enc_summary_lines pesl
7633 WHERE pesl.payroll_action_id = p_payroll_action_id
7634 AND pesl.assignment_id = t_assignments.asg_array(recno)
7635 AND pesl.payroll_id = t_assignments.payroll_array(recno));
7636
7637 FORALL recno IN 1..t_assignments.asg_array.COUNT
7638 UPDATE psp_enc_process_assignments pepa
7639 SET assignment_status = 'S'
7640 WHERE pepa.payroll_action_id = p_payroll_action_id
7641 AND pepa.assignment_id = t_assignments.asg_array(recno)
7642 AND pepa.payroll_id = t_assignments.payroll_array(recno)
7643 AND EXISTS (SELECT 1
7644 FROM psp_enc_summary_lines pesl
7645 WHERE pesl.payroll_action_id = p_payroll_action_id
7646 AND pesl.assignment_id = t_assignments.asg_array(recno)
7647 AND pesl.payroll_id = t_assignments.payroll_array(recno));
7648
7649 FORALL recno IN 1..t_assignments.asg_array.COUNT
7650 UPDATE psp_enc_process_assignments pepa
7651 SET assignment_status = 'L'
7652 WHERE pepa.payroll_action_id = p_payroll_action_id
7653 AND pepa.assignment_id = t_assignments.asg_array(recno)
7654 AND pepa.payroll_id = t_assignments.payroll_array(recno)
7655 AND EXISTS (SELECT 1
7656 FROM psp_enc_summary_lines pesl
7657 WHERE pesl.payroll_action_id = p_payroll_action_id
7658 AND pesl.superceded_line_id IS NOT NULL
7659 AND pesl.assignment_id = t_assignments.asg_array(recno)
7660 AND pesl.payroll_id = t_assignments.payroll_array(recno));
7661
7662 t_assignments.payroll_array.delete;
7663 t_assignments.asg_array.delete;
7664
7665 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 ||')');
7666 EXCEPTION
7667 WHEN OTHERS THEN
7668 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
7669 log_cel_warnings;
7670 IF (g_error_message IS NOT NULL) THEN
7671 IF (l_assignment_id IS NOT NULL) THEN
7672 OPEN asg_number_cur(l_enc_begin_date);
7673 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
7674 CLOSE asg_number_cur;
7675
7676 OPEN payroll_name_cur;
7677 FETCH payroll_name_cur INTO l_payroll_name;
7678 CLOSE payroll_name_cur;
7679
7680 OPEN person_name_cur(l_enc_begin_date);
7681 FETCH person_name_cur INTO l_full_name;
7682 CLOSE person_name_cur;
7683
7684 OPEN org_name_cur;
7685 FETCH org_name_cur INTO l_organization_name;
7686 CLOSE org_name_cur;
7687
7688 OPEN element_name_cur;
7689 FETCH element_name_cur INTO l_element_name;
7690 CLOSE element_name_cur;
7691
7692 psp_general.add_report_error
7693 (p_request_id => g_request_id,
7694 p_message_level => 'E',
7695 p_source_id => l_assignment_id,
7696 p_source_name => l_assignment_number,
7697 p_parent_source_id => l_person_id,
7698 p_parent_source_name => l_full_name,
7699 p_error_message => g_error_message,
7700 p_payroll_action_id => p_payroll_action_id,
7701 p_value1 => l_payroll_id,
7702 p_information1 => l_payroll_name,
7703 p_value2 => l_organization_id,
7704 p_information2 => l_organization_name,
7705 p_value3 => l_element_type_id,
7706 p_information3 => l_element_name,
7707 p_return_status => l_return_status);
7708 ELSE
7709 psp_general.add_report_error
7710 (p_request_id => g_request_id,
7711 p_message_level => 'E',
7712 p_source_id => NULL,
7713 p_source_name => NULL,
7714 p_parent_source_id => NULL,
7715 p_parent_source_name => NULL,
7716 p_error_message => g_error_message,
7717 p_payroll_action_id => p_payroll_action_id,
7718 p_value1 => NULL,
7719 p_information1 => NULL,
7720 p_return_status => l_return_status);
7721 END IF;
7722 END IF;
7723 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'CEL_ARCHIVE: SQLCODE: ' || fnd_number.number_to_canonical(SQLCODE) || ' SQLERRM: ' || SQLERRM);
7724 psp_message_s.print_error(p_mode => FND_FILE.LOG, p_print_header => FND_API.G_TRUE);
7725 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 ||')');
7726 ROLLBACK TO CEL_ARCHIVE;
7727 RAISE;
7728 END cel_archive;
7729
7730 procedure cel_deinit(p_payroll_action_id in number) IS
7731 PRAGMA AUTONOMOUS_TRANSACTION;
7732 l_last_update_date DATE;
7733 l_last_updated_by NUMBER;
7734 l_request_id NUMBER(15);
7735 l_business_group_id NUMBER(15);
7736 l_set_of_books_id NUMBER(15);
7737 l_error_count NUMBER;
7738 l_process_mode VARCHAR2(30);
7739 l_process_phase VARCHAR2(30);
7740 call_status BOOLEAN;
7741 rphase VARCHAR2(30);
7742 rstatus VARCHAR2(30);
7743 dphase VARCHAR2(30);
7744 dstatus VARCHAR2(30);
7745 message VARCHAR2(240);
7746 l_xml_layout BOOLEAN;
7747 l_st_count NUMBER(15);
7748
7749 CURSOR payroll_id_cur IS
7750 SELECT argument12
7751 FROM fnd_concurrent_requests fcr,
7752 psp_enc_processes pep
7753 WHERE pep.payroll_action_id = p_payroll_action_id
7754 AND fcr.request_id = pep.request_id;
7755
7756 CURSOR process_phase_cur IS
7757 SELECT process_phase
7758 FROM psp_enc_processes
7759 WHERE payroll_action_id = p_payroll_action_id
7760 AND process_code = 'ST';
7761
7762 CURSOR error_check_cur IS
7763 SELECT COUNT(1)
7764 FROM psp_report_errors
7765 WHERE payroll_action_id = p_payroll_action_id
7766 AND request_id >= l_request_id
7767 AND message_level = 'E';
7768
7769 CURSOR st_count_cur Is
7770 SELECT COUNT(1)
7771 FROM psp_enc_summary_lines
7772 WHERE payroll_action_id = p_payroll_action_id
7773 AND status_code = 'N';
7774 BEGIN
7775 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Entering CEL_DEINIT payroll_action_id: ' || p_payroll_action_id);
7776 l_last_update_date := SYSDATE;
7777 l_last_updated_by:= NVL(FND_GLOBAL.USER_ID, -1);
7778 l_request_id := fnd_global.conc_request_id;
7779
7780 OPEN payroll_id_cur;
7781 FETCH payroll_id_cur INTO l_process_mode;
7782 CLOSE payroll_id_cur;
7783
7784 OPEN process_phase_cur;
7785 FETCH process_phase_cur INTO l_process_phase;
7786 CLOSE process_phase_cur;
7787 l_process_phase := NVL(l_process_phase, 'deinit');
7788
7789 IF NOT (l_process_mode = 'TERMINATE' AND l_process_phase = 'deinit_st') THEN
7790 OPEN error_check_cur;
7791 FETCH error_check_cur INTO l_error_count;
7792 CLOSE error_check_cur;
7793
7794 IF (l_error_count > 0) THEN
7795 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.');
7796 l_business_group_id := fnd_profile.value('PER_BUSINESS_GROUP_ID');
7797 l_set_of_books_id := fnd_profile.value('GL_SET_OF_BKS_ID');
7798 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Before submitting Encumbrance Run Results Report');
7799 l_xml_layout := fnd_request.add_layout('PSP','PSPENRSRTF','en','US','PDF');
7800 l_request_id := fnd_request.submit_request('PSP',
7801 'PSPENRSLT',
7802 '',
7803 '',
7804 FALSE,
7805 TO_CHAR(p_payroll_action_id),
7806 TO_CHAR(fnd_global.conc_request_id),
7807 TO_CHAR(l_business_group_id),
7808 TO_CHAR(l_set_of_books_id));
7809
7810 IF l_request_id = 0 THEN
7811 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Encumbrance Run Results Report submission failed');
7812 fnd_message.set_name('PSP','PSP_TR_GL_IMP_FAILED');
7813 fnd_msg_pub.add;
7814 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7815 END IF;
7816 COMMIT;
7817 RAISE fnd_api.g_exc_unexpected_error;
7818 END IF;
7819
7820 UPDATE psp_enc_process_assignments pepa
7821 SET assignment_status = 'B'
7822 WHERE payroll_action_id = p_payroll_action_id
7823 AND NOT EXISTS (SELECT 1
7824 FROM psp_enc_summary_lines pesl
7825 WHERE pesl.payroll_action_id = p_payroll_action_id
7826 AND pesl.assignment_id = pepa.assignment_id
7827 AND pesl.payroll_id = pepa.payroll_id
7828 AND pesl.status_code = 'N');
7829
7830 UPDATE psp_enc_process_assignments pepa
7831 SET assignment_status = 'S'
7832 WHERE payroll_action_id = p_payroll_action_id
7833 AND EXISTS (SELECT 1
7834 FROM psp_enc_summary_lines pesl
7835 WHERE pesl.payroll_action_id = p_payroll_action_id
7836 AND pesl.assignment_id = pepa.assignment_id
7837 AND pesl.payroll_id = pepa.payroll_id
7838 AND pesl.status_code = 'N'
7839 AND pesl.superceded_line_id IS NULL);
7840
7841 UPDATE psp_enc_process_assignments pepa
7842 SET assignment_status = 'L'
7843 WHERE payroll_action_id = p_payroll_action_id
7844 AND EXISTS (SELECT 1
7845 FROM psp_enc_summary_lines pesl
7846 WHERE pesl.payroll_action_id = p_payroll_action_id
7847 AND pesl.assignment_id = pepa.assignment_id
7848 AND pesl.payroll_id = pepa.payroll_id
7849 AND pesl.status_code = 'N'
7850 AND pesl.superceded_line_id IS NOT NULL);
7851
7852 fnd_stats.gather_table_stats('PSP', 'PSP_ENC_CONTROLS');
7853 fnd_stats.gather_table_stats('PSP', 'PSP_ENC_LINES');
7854 fnd_stats.gather_table_stats('PSP', 'PSP_ENC_SUMMARY_LINES');
7855 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Completed Gather Statistics');
7856
7857 DELETE FROM psp_enc_controls pec
7858 WHERE pec.payroll_action_id = p_payroll_action_id
7859 AND NOT EXISTS (SELECT 1
7860 FROM psp_enc_lines pel
7861 WHERE pel.enc_control_id = pec.enc_control_id);
7862 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');
7863
7864 UPDATE psp_enc_controls pec
7865 SET (action_code,
7866 number_of_dr, number_of_cr,
7867 total_dr_amount, total_cr_amount,
7868 gl_dr_amount, gl_cr_amount,
7869 ogm_dr_amount, ogm_cr_amount) =
7870 (SELECT 'N',
7871 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))),
7872 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))),
7873 SUM(fnd_number.canonical_to_number(DECODE(pel.gl_project_flag, 'G', DECODE(pel.dr_cr_flag, 'D', pel.encumbrance_amount, 0), 0))),
7874 SUM(fnd_number.canonical_to_number(DECODE(pel.gl_project_flag, 'G', DECODE(pel.dr_cr_flag, 'C', pel.encumbrance_amount, 0), 0))),
7875 SUM(fnd_number.canonical_to_number(DECODE(pel.gl_project_flag, 'P', DECODE(pel.dr_cr_flag, 'D', pel.encumbrance_amount, 0), 0))),
7876 SUM(fnd_number.canonical_to_number(DECODE(pel.gl_project_flag, 'P', DECODE(pel.dr_cr_flag, 'C', pel.encumbrance_amount, 0), 0)))
7877 FROM psp_enc_lines pel
7878 WHERE pel.enc_control_id = pec.enc_control_id)
7879 WHERE payroll_action_id = p_payroll_action_id;
7880 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated summary columns in psp_enc_controls');
7881
7882 IF (l_process_mode = 'TERMINATE') THEN
7883 UPDATE psp_enc_changed_assignments peca
7884 SET payroll_action_id = p_payroll_action_id
7885 WHERE EXISTS (SELECT 1
7886 FROM psp_enc_changed_assignments peca2
7887 WHERE peca2.assignment_id = peca.assignment_id
7888 AND peca2.change_type = 'TR');
7889 END IF;
7890
7891 INSERT INTO psp_enc_changed_asg_history
7892 (request_id, assignment_id, payroll_id, change_type, processing_module, created_by,
7893 creation_date, processed_flag, reference_id, action_type, payroll_action_id, change_date)
7894 SELECT l_request_id, peca.assignment_id, peca.payroll_id, peca.change_type,
7895 'U', l_last_updated_by, l_last_update_date, NULL, NVL(peca.reference_id, 0),
7896 NVL(peca.action_type, 'U'), p_payroll_action_id, change_date
7897 FROM psp_enc_changed_assignments peca
7898 WHERE payroll_action_id = p_payroll_action_id;
7899 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Copied change assignment records to psp_enc_changed_asg_history');
7900
7901 DELETE psp_enc_changed_assignments peca
7902 WHERE peca.payroll_action_id = p_payroll_action_id;
7903 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted processed change assignment records in psp_enc_change_assignments');
7904
7905 UPDATE psp_enc_processes
7906 SET process_status = 'P'
7907 WHERE payroll_action_id = p_payroll_action_id;
7908 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process_status in psp_enc_processes');
7909
7910 UPDATE psp_enc_processes
7911 SET process_status = 'B',
7912 process_phase = 'no_summarize_transfer'
7913 WHERE payroll_action_id = p_payroll_action_id
7914 AND NOT EXISTS (SELECT 1
7915 FROM psp_enc_summary_lines pesl
7916 WHERE pesl.payroll_action_id = p_payroll_action_id
7917 AND pesl.status_code = 'N');
7918
7919 UPDATE psp_enc_processes
7920 SET process_phase = 'summarize_transfer'
7921 WHERE payroll_action_id = p_payroll_action_id
7922 AND EXISTS (SELECT 1
7923 FROM psp_enc_summary_lines pesl
7924 WHERE pesl.payroll_action_id = p_payroll_action_id
7925 AND pesl.status_code = 'N'
7926 AND pesl.superceded_line_id IS NULL);
7927
7928 UPDATE psp_enc_processes
7929 SET process_phase = 'liquidate'
7930 WHERE payroll_action_id = p_payroll_action_id
7931 AND EXISTS (SELECT 1
7932 FROM psp_enc_summary_lines pesl
7933 WHERE pesl.payroll_action_id = p_payroll_action_id
7934 AND pesl.status_code = 'N'
7935 AND pesl.superceded_line_id is NOT NULL);
7936 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process_phase in psp_enc_processes');
7937 END IF;
7938
7939 l_business_group_id := fnd_profile.value('PER_BUSINESS_GROUP_ID');
7940 l_set_of_books_id := fnd_profile.value('GL_SET_OF_BKS_ID');
7941 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Before submitting Encumbrance Run Results Report');
7942 l_xml_layout := fnd_request.add_layout('PSP','PSPENRSRTF','en','US','PDF');
7943 l_request_id := fnd_request.submit_request('PSP',
7944 'PSPENRSLT',
7945 '',
7946 '',
7947 FALSE,
7948 TO_CHAR(p_payroll_action_id),
7949 TO_CHAR(fnd_global.conc_request_id),
7950 TO_CHAR(l_business_group_id),
7951 TO_CHAR(l_set_of_books_id));
7952
7953 IF l_request_id = 0 THEN
7954 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Encumbrance Run Results Report submission failed');
7955 fnd_message.set_name('PSP','PSP_TR_GL_IMP_FAILED');
7956 fnd_msg_pub.add;
7957 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7958 END IF;
7959 COMMIT;
7960
7961 -- 13566809 The delete statement deletes all the assignment information
7962 -- from temp table before the CUEL process completes.
7963
7964 DELETE FROM psp_asg_end_dates
7965 WHERE payroll_action_id = p_payroll_action_id;
7966
7967 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleting data from the temporary dummy table'||sql%rowcount);
7968 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE)|| ' Deleting data from the temporary dummy table'||sql%rowcount);
7969 IF (l_process_mode = 'TERMINATE') THEN
7970 OPEN st_count_cur;
7971 FETCH st_count_cur INTO l_st_count;
7972 CLOSE st_count_cur;
7973
7974 IF (l_st_count > 0) THEN
7975 l_business_group_id := fnd_profile.value('PER_BUSINESS_GROUP_ID');
7976 l_set_of_books_id := fnd_profile.value('GL_SET_OF_BKS_ID');
7977
7978 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Before submitting Encumbrance Summarize and Transfer');
7979 l_request_id := fnd_request.submit_request('PSP',
7980 'PSPENSTR',
7981 '',
7982 '',
7983 FALSE,
7984 TO_CHAR(p_payroll_action_id),
7985 TO_CHAR(l_business_group_id),
7986 TO_CHAR(l_set_of_books_id));
7987
7988 IF l_request_id = 0 THEN
7989 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Encumbrance Summarize and Transfer submission failed');
7990 fnd_message.set_name('PSP','PSP_TR_GL_IMP_FAILED');
7991 fnd_msg_pub.add;
7992 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7993 END IF;
7994
7995 UPDATE psp_enc_processes
7996 SET process_phase = 'deinit_st'
7997 WHERE payroll_action_id = p_payroll_action_id
7998 AND process_code = 'ST';
7999 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process_phase in psp_enc_processes');
8000
8001 COMMIT;
8002
8003 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Waiting for Encumbrance Summarize and Transfer request to complete');
8004 call_status := fnd_concurrent.wait_for_request(l_request_id, 10, 0, rphase, rstatus, dphase, dstatus, message);
8005
8006 IF call_status = FALSE THEN
8007 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Encumbrance Summarize and Transfer failed');
8008 fnd_message.set_name('PSP','PSP_ENC_STR_FAILED');
8009 fnd_msg_pub.add;
8010 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8011 END IF;
8012 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Encumbrance Summarize and Transfer completed');
8013 ELSE
8014 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');
8015 END IF;
8016 END IF;
8017
8018 COMMIT;
8019 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving CEL_DEINIT payroll_action_id: ' || p_payroll_action_id);
8020 END cel_deinit;
8021
8022 PROCEDURE verify_changes(p_payroll_id IN NUMBER,
8023 p_assignment_id IN NUMBER,
8024 p_business_group_id IN NUMBER,
8025 p_set_of_books_id IN NUMBER,
8026 p_enc_line_type IN VARCHAR2,
8027 l_retcode OUT NOCOPY VARCHAR2) IS
8028 TYPE time_period_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
8029 TYPE encumbrance_date_tl IS TABLE OF DATE INDEX BY BINARY_INTEGER;
8030 TYPE dr_cr_flag_tl IS TABLE OF VARCHAR2(1) INDEX BY BINARY_INTEGER;
8031 TYPE encumbrance_amount_tl IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
8032 TYPE gl_project_flag_tl IS TABLE OF VARCHAR2(15) INDEX BY BINARY_INTEGER;
8033 TYPE schedule_line_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
8034 TYPE org_schedule_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
8035 TYPE default_org_account_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
8036 TYPE suspense_org_account_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
8037 TYPE element_account_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
8038 TYPE project_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
8039 TYPE task_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
8040 TYPE award_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
8041 TYPE expenditure_type_tl IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;
8042 TYPE exp_organization_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
8043 TYPE gl_code_combination_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
8044 TYPE attribute_category_tl IS TABLE OF VARCHAR2(150) INDEX BY BINARY_INTEGER;
8045 TYPE attribute_tl IS TABLE OF VARCHAR2(150) INDEX BY BINARY_INTEGER;
8046 TYPE hierarchy_code_tl IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;
8047 TYPE enc_summary_line_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
8048 TYPE enc_element_type_id_tl IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
8049
8050 l_time_period_id_tl time_period_id_tl;
8051 l_encumbrance_date_tl encumbrance_date_tl;
8052 l_dr_cr_flag_tl dr_cr_flag_tl;
8053 l_encumbrance_amount_tl encumbrance_amount_tl;
8054 l_gl_project_flag_tl gl_project_flag_tl;
8055 l_schedule_line_id_tl schedule_line_id_tl;
8056 l_org_schedule_id_tl org_schedule_id_tl;
8057 l_default_org_account_id_tl default_org_account_id_tl;
8058 l_suspense_org_account_id_tl suspense_org_account_id_tl;
8059 l_element_account_id_tl element_account_id_tl;
8060 l_project_id_tl project_id_tl;
8061 l_task_id_tl task_id_tl;
8062 l_award_id_tl award_id_tl;
8063 l_expenditure_type_tl expenditure_type_tl;
8064 l_exp_organization_id_tl exp_organization_id_tl;
8065 l_gl_code_combination_id_tl gl_code_combination_id_tl;
8066 l_attribute_category_tl attribute_category_tl;
8067 l_attribute1_tl attribute_tl;
8068 l_attribute2_tl attribute_tl;
8069 l_attribute3_tl attribute_tl;
8070 l_attribute4_tl attribute_tl;
8071 l_attribute5_tl attribute_tl;
8072 l_attribute6_tl attribute_tl;
8073 l_attribute7_tl attribute_tl;
8074 l_attribute8_tl attribute_tl;
8075 l_attribute9_tl attribute_tl;
8076 l_attribute10_tl attribute_tl;
8077 l_default_reason_tl attribute_tl;
8078 l_suspense_reason_tl attribute_tl;
8079 l_hierarchy_code_tl hierarchy_code_tl;
8080 l_enc_summary_line_id_tl enc_summary_line_id_tl;
8081 l_enc_element_type_id_tl enc_element_type_id_tl;
8082
8083 CURSOR enc_lines_history_cur IS
8084 SELECT DISTINCT pelh.time_period_id ,
8085 pelh.encumbrance_date ,
8086 pelh.dr_cr_flag,
8087 pelh.encumbrance_amount ,
8088 pelh.gl_project_flag,
8089 pelh.enc_element_type_id,
8090 NVL(pelh.schedule_line_id,-99) ,
8091 NVL(pelh.org_schedule_id, -99) ,
8092 NVL(pelh.default_org_account_id, -99),
8093 NVL(pelh.suspense_org_account_id, -99),
8094 NVL(pelh.element_account_id, -99) ,
8095 NVL(pelh.project_id, -99),
8096 NVL(pelh.task_id, -99) ,
8097 NVL(pelh.award_id, -99),
8098 NVL(pelh.expenditure_type, '-99') ,
8099 NVL(pelh.expenditure_organization_id, -99) ,
8100 NVL(pelh.gl_code_combination_id, -99),
8101 NVL(pelh.attribute_category,'NULL_VALUE'),
8102 NVL(pelh.attribute1, 'NULL_VALUE'),
8103 NVL(pelh.attribute2, 'NULL_VALUE'),
8104 NVL(pelh.attribute3, 'NULL_VALUE'),
8105 NVL(pelh.attribute4, 'NULL_VALUE'),
8106 NVL(pelh.attribute5, 'NULL_VALUE'),
8107 NVL(pelh.attribute6, 'NULL_VALUE'),
8108 NVL(pelh.attribute7, 'NULL_VALUE'),
8109 NVL(pelh.attribute8, 'NULL_VALUE'),
8110 NVL(pelh.attribute9, 'NULL_VALUE'),
8111 NVL(pelh.attribute10, 'NULL_VALUE'),
8112 NVL(pelh.default_reason_code, 'NULL'),
8113 NVL(pelh.suspense_reason_code, 'NULL'),
8114 hierarchy_code
8115 FROM psp_enc_lines_history pelh
8116 WHERE pelh.change_flag = 'U'
8117 AND payroll_id = p_payroll_id
8118 AND assignment_id = p_assignment_id;
8119
8120 CURSOR modified_summary_lines_cur IS
8121 SELECT DISTINCT enc_summary_line_id
8122 FROM psp_enc_lines_history
8123 WHERE change_flag = 'N'
8124 AND payroll_id = p_payroll_id
8125 AND assignment_id = p_assignment_id;
8126
8127 l_enc_lines_no NUMBER(15);
8128 l_delete_flag CHAR(1);
8129 l_return_status VARCHAR2(1);
8130 BEGIN
8131 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering verify_changes
8132 p_payroll_id: ' || p_payroll_id || ' p_assignment_id: ' || p_assignment_id || '
8133 p_business_group_id: ' || p_business_group_id || ' p_set_of_books_id: ' || p_set_of_books_id || '
8134 p_enc_line_type: ' || p_enc_line_type);
8135
8136 UPDATE psp_enc_lines_history
8137 SET change_flag = 'N'
8138 WHERE assignment_id = p_assignment_id
8139 AND payroll_id = p_payroll_id
8140 AND change_flag = 'U'
8141 AND status_code = 'A';
8142
8143 IF (g_dff_grouping_option = 'N') THEN
8144 FORALL recno IN 1 .. t_enc_lines_array.r_time_period_id.COUNT
8145 UPDATE psp_enc_lines_history pelh
8146 SET change_flag='U'
8147 WHERE time_period_id = t_enc_lines_array.r_time_period_id(recno)
8148 AND change_flag = 'N'
8149 AND pelh.encumbrance_date = t_enc_lines_array.r_encumbrance_date(recno)
8150 AND pelh.enc_element_type_id = t_enc_lines_array.r_enc_element_type_id(recno)
8151 AND pelh.dr_cr_flag = t_enc_lines_array.r_dr_cr_flag(recno)
8152 AND pelh.encumbrance_amount = ROUND( t_enc_lines_array.r_encumbrance_amount(recno),g_precision)
8153 AND pelh.gl_project_flag = t_enc_lines_array.r_gl_project_flag(recno)
8154 AND pelh.hierarchy_code = t_enc_lines_array.r_hierarchy_code(recno)
8155 AND NVL(pelh.project_id, -99) = NVL(t_enc_lines_array.r_project_id(recno), -99)
8156 AND NVL(pelh.task_id, -99) = NVL(t_enc_lines_array.r_task_id(recno), -99)
8157 AND NVL(pelh.award_id, -99) = NVL(t_enc_lines_array.r_award_id(recno), -99)
8158 AND NVL(pelh.expenditure_type, '-99') = NVL(t_enc_lines_array.r_expenditure_type(recno), '-99')
8159 AND NVL(pelh.expenditure_organization_id, -99) = NVL(t_enc_lines_array.r_expenditure_organization_id(recno), -99)
8160 AND NVL(pelh.gl_code_combination_id, -99) = NVL(t_enc_lines_array.r_gl_code_combination_id(recno), -99)
8161 AND NVL(suspense_reason_code, 'NULL') = NVL(t_enc_lines_array.r_suspense_reason_code(recno), 'NULL')
8162 AND NVL(default_reason_code, 'NULL') = NVL(t_enc_lines_array.r_default_reason_code(recno), 'NULL')
8163 AND pelh.assignment_id = p_assignment_id
8164 AND pelh.payroll_id = p_payroll_id;
8165 ELSE
8166 FORALL recno IN 1 .. t_enc_lines_array.r_time_period_id.COUNT
8167 UPDATE psp_enc_lines_history pelh
8168 SET change_flag='U'
8169 WHERE time_period_id = t_enc_lines_array.r_time_period_id(recno)
8170 AND change_flag = 'N'
8171 AND pelh.encumbrance_date = t_enc_lines_array.r_encumbrance_date(recno)
8172 AND pelh.enc_element_type_id = t_enc_lines_array.r_enc_element_type_id(recno)
8173 AND pelh.dr_cr_flag = t_enc_lines_array.r_dr_cr_flag(recno)
8174 AND pelh.encumbrance_amount = ROUND( t_enc_lines_array.r_encumbrance_amount(recno),g_precision)
8175 AND pelh.gl_project_flag = t_enc_lines_array.r_gl_project_flag(recno)
8176 AND pelh.hierarchy_code = t_enc_lines_array.r_hierarchy_code(recno)
8177 AND NVL(pelh.project_id, -99) = NVL(t_enc_lines_array.r_project_id(recno), -99)
8178 AND NVL(pelh.task_id, -99) = NVL(t_enc_lines_array.r_task_id(recno), -99)
8179 AND NVL(pelh.award_id, -99) = NVL(t_enc_lines_array.r_award_id(recno), -99)
8180 AND NVL(pelh.expenditure_type, '-99') = NVL(t_enc_lines_array.r_expenditure_type(recno), '-99')
8181 AND NVL(pelh.expenditure_organization_id, -99) = NVL(t_enc_lines_array.r_expenditure_organization_id(recno), -99)
8182 AND NVL(pelh.gl_code_combination_id, -99) = NVL(t_enc_lines_array.r_gl_code_combination_id(recno), -99)
8183 AND NVL(suspense_reason_code, 'NULL') = NVL(t_enc_lines_array.r_suspense_reason_code(recno), 'NULL')
8184 AND NVL(default_reason_code, 'NULL') = NVL(t_enc_lines_array.r_default_reason_code(recno), 'NULL')
8185 AND pelh.assignment_id = p_assignment_id
8186 AND pelh.payroll_id = p_payroll_id
8187 AND NVL(pelh.attribute_category, 'NULL_VALUE') = t_enc_lines_array.r_attribute_category(recno)
8188 AND NVL(pelh.attribute1, 'NULL_VALUE') = t_enc_lines_array.r_attribute1(recno)
8189 AND NVL(pelh.attribute2, 'NULL_VALUE') = t_enc_lines_array.r_attribute2(recno)
8190 AND NVL(pelh.attribute3, 'NULL_VALUE') = t_enc_lines_array.r_attribute3(recno)
8191 AND NVL(pelh.attribute4, 'NULL_VALUE') = t_enc_lines_array.r_attribute4(recno)
8192 AND NVL(pelh.attribute5, 'NULL_VALUE') = t_enc_lines_array.r_attribute5(recno)
8193 AND NVL(pelh.attribute6, 'NULL_VALUE') = t_enc_lines_array.r_attribute6(recno)
8194 AND NVL(pelh.attribute7, 'NULL_VALUE') = t_enc_lines_array.r_attribute7(recno)
8195 AND NVL(pelh.attribute8, 'NULL_VALUE') = t_enc_lines_array.r_attribute8(recno)
8196 AND NVL(pelh.attribute9, 'NULL_VALUE') = t_enc_lines_array.r_attribute9(recno)
8197 AND NVL(pelh.attribute10, 'NULL_VALUE') = t_enc_lines_array.r_attribute10(recno);
8198 END IF;
8199
8200 OPEN modified_summary_lines_cur;
8201 FETCH modified_summary_lines_cur BULK COLLECT INTO l_enc_summary_line_id_tl;
8202 CLOSE modified_summary_lines_cur;
8203
8204 hr_utility.trace('l_enc_summary_line_id_tl.COUNT: ' || l_enc_summary_line_id_tl.COUNT);
8205
8206 FORALL recno IN 1..l_enc_summary_line_id_tl.COUNT
8207 UPDATE psp_enc_lines_history pelh
8208 SET change_flag='N'
8209 WHERE enc_summary_line_id = l_enc_summary_line_id_tl(recno)
8210 AND change_flag='U';
8211
8212 l_enc_summary_line_id_tl.DELETE;
8213
8214 OPEN enc_lines_history_cur;
8215 FETCH enc_lines_history_cur BULK COLLECT INTO
8216 l_time_period_id_tl,l_encumbrance_date_tl,l_dr_cr_flag_tl,l_encumbrance_amount_tl,
8217 l_gl_project_flag_tl,l_enc_element_type_id_tl,l_schedule_line_id_tl,l_org_schedule_id_tl,
8218 l_default_org_account_id_tl,l_suspense_org_account_id_tl,l_element_account_id_tl,
8219 l_project_id_tl,l_task_id_tl,l_award_id_tl,l_expenditure_type_tl,l_exp_organization_id_tl,
8220 l_gl_code_combination_id_tl, l_attribute_category_tl,
8221 l_attribute1_tl,l_attribute2_tl,l_attribute3_tl,l_attribute4_tl,l_attribute5_tl,
8222 l_attribute6_tl,l_attribute7_tl,l_attribute8_tl,l_attribute9_tl,l_attribute10_tl,
8223 l_default_reason_tl, l_suspense_reason_tl, l_hierarchy_code_tl;
8224 CLOSE enc_lines_history_cur;
8225
8226 l_enc_lines_no := 1;
8227 IF (g_dff_grouping_option = 'N') THEN
8228 FOR recno1 IN 1..t_enc_lines_array.r_time_period_id.COUNT
8229 LOOP
8230 l_delete_flag := 'N';
8231 FOR recno2 IN 1 .. l_time_period_id_tl.COUNT
8232 LOOP
8233 IF (t_enc_lines_array.r_time_period_id(recno1) = l_time_period_id_tl(recno2)
8234 AND t_enc_lines_array.r_encumbrance_date(recno1) = l_encumbrance_date_tl(recno2)
8235 AND t_enc_lines_array.r_dr_cr_flag(recno1) = l_dr_cr_flag_tl(recno2)
8236 AND ROUND(t_enc_lines_array.r_encumbrance_amount(recno1), g_precision) = l_encumbrance_amount_tl(recno2)
8237 AND t_enc_lines_array.r_gl_project_flag(recno1) = l_gl_project_flag_tl(recno2)
8238 AND t_enc_lines_array.r_enc_element_type_id(recno1) = l_enc_element_type_id_tl(recno2)
8239 AND t_enc_lines_array.r_hierarchy_code(recno1) = l_hierarchy_code_tl(recno2)
8240 AND NVL(t_enc_lines_array.r_default_reason_code(recno1), 'NULL') = NVL(l_default_reason_tl(recno2), 'NULL')
8241 AND NVL(t_enc_lines_array.r_suspense_reason_code(recno1), 'NULL') = NVL(l_suspense_reason_tl(recno2), 'NULL')
8242 AND NVL(t_enc_lines_array.r_project_id(recno1), -99) = l_project_id_tl(recno2)
8243 AND NVL(t_enc_lines_array.r_task_id(recno1), -99) = l_task_id_tl(recno2)
8244 AND NVL(t_enc_lines_array.r_award_id(recno1), -99) = l_award_id_tl(recno2)
8245 AND NVL(t_enc_lines_array.r_expenditure_type(recno1), '-99') = l_expenditure_type_tl(recno2)
8246 AND NVL(t_enc_lines_array.r_expenditure_organization_id(recno1), -99) = l_exp_organization_id_tl(recno2)
8247 AND NVL(t_enc_lines_array.r_gl_code_combination_id(recno1), -99) = l_gl_code_combination_id_tl(recno2)) THEN
8248 l_delete_flag := 'Y';
8249 EXIT;
8250 END IF;
8251 END LOOP;
8252
8253 IF (l_delete_flag = 'N') THEN
8254 t_enc_lines_array2.r_enc_element_type_id(l_enc_lines_no) := t_enc_lines_array.r_enc_element_type_id(recno1);
8255 t_enc_lines_array2.r_encumbrance_date(l_enc_lines_no) := t_enc_lines_array.r_encumbrance_date(recno1);
8256 t_enc_lines_array2.r_dr_cr_flag(l_enc_lines_no) := t_enc_lines_array.r_dr_cr_flag(recno1);
8257 t_enc_lines_array2.r_encumbrance_amount(l_enc_lines_no) := t_enc_lines_array.r_encumbrance_amount(recno1);
8258 t_enc_lines_array2.r_enc_line_type(l_enc_lines_no) := t_enc_lines_array.r_enc_line_type(recno1);
8259 t_enc_lines_array2.r_schedule_line_id(l_enc_lines_no) := t_enc_lines_array.r_schedule_line_id(recno1);
8260 t_enc_lines_array2.r_org_schedule_id(l_enc_lines_no) := t_enc_lines_array.r_org_schedule_id(recno1);
8261 t_enc_lines_array2.r_default_org_account_id(l_enc_lines_no) := t_enc_lines_array.r_default_org_account_id(recno1);
8262 t_enc_lines_array2.r_suspense_org_account_id(l_enc_lines_no) := t_enc_lines_array.r_suspense_org_account_id(recno1);
8263 t_enc_lines_array2.r_element_account_id(l_enc_lines_no) := t_enc_lines_array.r_element_account_id(recno1);
8264 t_enc_lines_array2.r_gl_project_flag(l_enc_lines_no) := t_enc_lines_array.r_gl_project_flag(recno1);
8265 t_enc_lines_array2.r_person_id(l_enc_lines_no) := t_enc_lines_array.r_person_id(recno1);
8266 t_enc_lines_array2.r_assignment_id(l_enc_lines_no) := t_enc_lines_array.r_assignment_id(recno1);
8267 t_enc_lines_array2.r_award_id(l_enc_lines_no) := t_enc_lines_array.r_award_id(recno1);
8268 t_enc_lines_array2.r_task_id(l_enc_lines_no) := t_enc_lines_array.r_task_id(recno1);
8269 t_enc_lines_array2.r_expenditure_type(l_enc_lines_no) := t_enc_lines_array.r_expenditure_type(recno1);
8270 t_enc_lines_array2.r_expenditure_organization_id(l_enc_lines_no) := t_enc_lines_array.r_expenditure_organization_id(recno1);
8271 t_enc_lines_array2.r_project_id(l_enc_lines_no) := t_enc_lines_array.r_project_id(recno1);
8272 t_enc_lines_array2.r_gl_code_combination_id(l_enc_lines_no) := t_enc_lines_array.r_gl_code_combination_id(recno1);
8273 t_enc_lines_array2.r_time_period_id(l_enc_lines_no) := t_enc_lines_array.r_time_period_id(recno1);
8274 t_enc_lines_array2.r_default_reason_code(l_enc_lines_no) := t_enc_lines_array.r_default_reason_code(recno1);
8275 t_enc_lines_array2.r_suspense_reason_code(l_enc_lines_no) := t_enc_lines_array.r_suspense_reason_code(recno1);
8276 t_enc_lines_array2.r_enc_control_id(l_enc_lines_no) := t_enc_lines_array.r_enc_control_id(recno1);
8277 t_enc_lines_array2.r_change_flag(l_enc_lines_no) := t_enc_lines_array.r_change_flag(recno1);
8278 t_enc_lines_array2.r_enc_start_date(l_enc_lines_no) := t_enc_lines_array.r_enc_start_date(recno1);
8279 t_enc_lines_array2.r_enc_end_date(l_enc_lines_no) := t_enc_lines_array.r_enc_end_date(recno1);
8280 t_enc_lines_array2.r_attribute_category(l_enc_lines_no) := t_enc_lines_array.r_attribute_category(recno1);
8281 t_enc_lines_array2.r_attribute1(l_enc_lines_no) := t_enc_lines_array.r_attribute1(recno1);
8282 t_enc_lines_array2.r_attribute2(l_enc_lines_no) := t_enc_lines_array.r_attribute2(recno1);
8283 t_enc_lines_array2.r_attribute3(l_enc_lines_no) := t_enc_lines_array.r_attribute3(recno1);
8284 t_enc_lines_array2.r_attribute4(l_enc_lines_no) := t_enc_lines_array.r_attribute4(recno1);
8285 t_enc_lines_array2.r_attribute5(l_enc_lines_no) := t_enc_lines_array.r_attribute5(recno1);
8286 t_enc_lines_array2.r_attribute6(l_enc_lines_no) := t_enc_lines_array.r_attribute6(recno1);
8287 t_enc_lines_array2.r_attribute7(l_enc_lines_no) := t_enc_lines_array.r_attribute7(recno1);
8288 t_enc_lines_array2.r_attribute8(l_enc_lines_no) := t_enc_lines_array.r_attribute8(recno1);
8289 t_enc_lines_array2.r_attribute9(l_enc_lines_no) := t_enc_lines_array.r_attribute9(recno1);
8290 t_enc_lines_array2.r_attribute10(l_enc_lines_no) := t_enc_lines_array.r_attribute10(recno1);
8291 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);
8292 t_enc_lines_array2.r_orig_project_id(l_enc_lines_no) := t_enc_lines_array.r_orig_project_id(recno1);
8293 t_enc_lines_array2.r_orig_award_id(l_enc_lines_no) := t_enc_lines_array.r_orig_award_id(recno1);
8294 t_enc_lines_array2.r_orig_task_id(l_enc_lines_no) := t_enc_lines_array.r_orig_task_id(recno1);
8295 t_enc_lines_array2.r_orig_expenditure_type(l_enc_lines_no) := t_enc_lines_array.r_orig_expenditure_type(recno1);
8296 t_enc_lines_array2.r_orig_expenditure_org_id(l_enc_lines_no) := t_enc_lines_array.r_orig_expenditure_org_id(recno1);
8297 t_enc_lines_array2.r_hierarchy_code(l_enc_lines_no) := t_enc_lines_array.r_hierarchy_code(recno1);
8298 l_enc_lines_no := l_enc_lines_no + 1;
8299 END IF;
8300 END LOOP;
8301 ELSE
8302 FOR recno1 IN 1..t_enc_lines_array.r_time_period_id.COUNT
8303 LOOP
8304 l_delete_flag := 'N';
8305 FOR recno2 IN 1 .. l_time_period_id_tl.COUNT
8306 LOOP
8307 IF (t_enc_lines_array.r_time_period_id(recno1) = l_time_period_id_tl(recno2)
8308 AND t_enc_lines_array.r_encumbrance_date(recno1) = l_encumbrance_date_tl(recno2)
8309 AND t_enc_lines_array.r_dr_cr_flag(recno1) = l_dr_cr_flag_tl(recno2)
8310 AND t_enc_lines_array.r_enc_element_type_id(recno1) = l_enc_element_type_id_tl(recno2)
8311 AND ROUND(t_enc_lines_array.r_encumbrance_amount(recno1), g_precision) = l_encumbrance_amount_tl(recno2)
8312 AND t_enc_lines_array.r_gl_project_flag(recno1) = l_gl_project_flag_tl(recno2)
8313 AND t_enc_lines_array.r_hierarchy_code(recno1) = l_hierarchy_code_tl(recno2)
8314 AND NVL(t_enc_lines_array.r_default_reason_code(recno1), 'NULL') = NVL(l_default_reason_tl(recno2), 'NULL')
8315 AND NVL(t_enc_lines_array.r_suspense_reason_code(recno1), 'NULL') = NVL(l_suspense_reason_tl(recno2), 'NULL')
8316 AND NVL(t_enc_lines_array.r_project_id(recno1), -99) = l_project_id_tl(recno2)
8317 AND NVL(t_enc_lines_array.r_task_id(recno1), -99) = l_task_id_tl(recno2)
8318 AND NVL(t_enc_lines_array.r_award_id(recno1), -99) = l_award_id_tl(recno2)
8319 AND NVL(t_enc_lines_array.r_expenditure_type(recno1), '-99') = l_expenditure_type_tl(recno2)
8320 AND NVL(t_enc_lines_array.r_expenditure_organization_id(recno1), -99) = l_exp_organization_id_tl(recno2)
8321 AND NVL(t_enc_lines_array.r_gl_code_combination_id(recno1), -99) = l_gl_code_combination_id_tl(recno2)
8322 AND t_enc_lines_array.r_attribute_category(recno1) = l_attribute_category_tl(recno2)
8323 AND t_enc_lines_array.r_attribute1(recno1) = l_attribute1_tl(recno2)
8324 AND t_enc_lines_array.r_attribute2(recno1) = l_attribute2_tl(recno2)
8325 AND t_enc_lines_array.r_attribute3(recno1) = l_attribute3_tl(recno2)
8326 AND t_enc_lines_array.r_attribute4(recno1) = l_attribute4_tl(recno2)
8327 AND t_enc_lines_array.r_attribute5(recno1) = l_attribute5_tl(recno2)
8328 AND t_enc_lines_array.r_attribute6(recno1) = l_attribute6_tl(recno2)
8329 AND t_enc_lines_array.r_attribute7(recno1) = l_attribute7_tl(recno2)
8330 AND t_enc_lines_array.r_attribute8(recno1) = l_attribute8_tl(recno2)
8331 AND t_enc_lines_array.r_attribute9(recno1) = l_attribute9_tl(recno2)
8332 AND t_enc_lines_array.r_attribute10(recno1) = l_attribute10_tl(recno2)) THEN
8333 l_delete_flag := 'Y';
8334 EXIT;
8335 END IF;
8336 END LOOP;
8337
8338 IF (l_delete_flag = 'N') THEN
8339 t_enc_lines_array2.r_enc_element_type_id(l_enc_lines_no) := t_enc_lines_array.r_enc_element_type_id(recno1);
8340 t_enc_lines_array2.r_encumbrance_date(l_enc_lines_no) := t_enc_lines_array.r_encumbrance_date(recno1);
8341 t_enc_lines_array2.r_dr_cr_flag(l_enc_lines_no) := t_enc_lines_array.r_dr_cr_flag(recno1);
8342 t_enc_lines_array2.r_encumbrance_amount(l_enc_lines_no) := t_enc_lines_array.r_encumbrance_amount(recno1);
8343 t_enc_lines_array2.r_enc_line_type(l_enc_lines_no) := t_enc_lines_array.r_enc_line_type(recno1);
8344 t_enc_lines_array2.r_schedule_line_id(l_enc_lines_no) := t_enc_lines_array.r_schedule_line_id(recno1);
8345 t_enc_lines_array2.r_org_schedule_id(l_enc_lines_no) := t_enc_lines_array.r_org_schedule_id(recno1);
8346 t_enc_lines_array2.r_default_org_account_id(l_enc_lines_no) := t_enc_lines_array.r_default_org_account_id(recno1);
8347 t_enc_lines_array2.r_suspense_org_account_id(l_enc_lines_no) := t_enc_lines_array.r_suspense_org_account_id(recno1);
8348 t_enc_lines_array2.r_element_account_id(l_enc_lines_no) := t_enc_lines_array.r_element_account_id(recno1);
8349 t_enc_lines_array2.r_gl_project_flag(l_enc_lines_no) := t_enc_lines_array.r_gl_project_flag(recno1);
8350 t_enc_lines_array2.r_person_id(l_enc_lines_no) := t_enc_lines_array.r_person_id(recno1);
8351 t_enc_lines_array2.r_assignment_id(l_enc_lines_no) := t_enc_lines_array.r_assignment_id(recno1);
8352 t_enc_lines_array2.r_award_id(l_enc_lines_no) := t_enc_lines_array.r_award_id(recno1);
8353 t_enc_lines_array2.r_task_id(l_enc_lines_no) := t_enc_lines_array.r_task_id(recno1);
8354 t_enc_lines_array2.r_expenditure_type(l_enc_lines_no) := t_enc_lines_array.r_expenditure_type(recno1);
8355 t_enc_lines_array2.r_expenditure_organization_id(l_enc_lines_no) := t_enc_lines_array.r_expenditure_organization_id(recno1);
8356 t_enc_lines_array2.r_project_id(l_enc_lines_no) := t_enc_lines_array.r_project_id(recno1);
8357 t_enc_lines_array2.r_gl_code_combination_id(l_enc_lines_no) := t_enc_lines_array.r_gl_code_combination_id(recno1);
8358 t_enc_lines_array2.r_time_period_id(l_enc_lines_no) := t_enc_lines_array.r_time_period_id(recno1);
8359 t_enc_lines_array2.r_default_reason_code(l_enc_lines_no) := t_enc_lines_array.r_default_reason_code(recno1);
8360 t_enc_lines_array2.r_suspense_reason_code(l_enc_lines_no) := t_enc_lines_array.r_suspense_reason_code(recno1);
8361 t_enc_lines_array2.r_enc_control_id(l_enc_lines_no) := t_enc_lines_array.r_enc_control_id(recno1);
8362 t_enc_lines_array2.r_change_flag(l_enc_lines_no) := t_enc_lines_array.r_change_flag(recno1);
8363 t_enc_lines_array2.r_enc_start_date(l_enc_lines_no) := t_enc_lines_array.r_enc_start_date(recno1);
8364 t_enc_lines_array2.r_enc_end_date(l_enc_lines_no) := t_enc_lines_array.r_enc_end_date(recno1);
8365 t_enc_lines_array2.r_attribute_category(l_enc_lines_no) := t_enc_lines_array.r_attribute_category(recno1);
8366 t_enc_lines_array2.r_attribute1(l_enc_lines_no) := t_enc_lines_array.r_attribute1(recno1);
8367 t_enc_lines_array2.r_attribute2(l_enc_lines_no) := t_enc_lines_array.r_attribute2(recno1);
8368 t_enc_lines_array2.r_attribute3(l_enc_lines_no) := t_enc_lines_array.r_attribute3(recno1);
8369 t_enc_lines_array2.r_attribute4(l_enc_lines_no) := t_enc_lines_array.r_attribute4(recno1);
8370 t_enc_lines_array2.r_attribute5(l_enc_lines_no) := t_enc_lines_array.r_attribute5(recno1);
8371 t_enc_lines_array2.r_attribute6(l_enc_lines_no) := t_enc_lines_array.r_attribute6(recno1);
8372 t_enc_lines_array2.r_attribute7(l_enc_lines_no) := t_enc_lines_array.r_attribute7(recno1);
8373 t_enc_lines_array2.r_attribute8(l_enc_lines_no) := t_enc_lines_array.r_attribute8(recno1);
8374 t_enc_lines_array2.r_attribute9(l_enc_lines_no) := t_enc_lines_array.r_attribute9(recno1);
8375 t_enc_lines_array2.r_attribute10(l_enc_lines_no) := t_enc_lines_array.r_attribute10(recno1);
8376 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);
8377 t_enc_lines_array2.r_orig_project_id(l_enc_lines_no) := t_enc_lines_array.r_orig_project_id(recno1);
8378 t_enc_lines_array2.r_orig_award_id(l_enc_lines_no) := t_enc_lines_array.r_orig_award_id(recno1);
8379 t_enc_lines_array2.r_orig_task_id(l_enc_lines_no) := t_enc_lines_array.r_orig_task_id(recno1);
8380 t_enc_lines_array2.r_orig_expenditure_type(l_enc_lines_no) := t_enc_lines_array.r_orig_expenditure_type(recno1);
8381 t_enc_lines_array2.r_orig_expenditure_org_id(l_enc_lines_no) := t_enc_lines_array.r_orig_expenditure_org_id(recno1);
8382 t_enc_lines_array2.r_hierarchy_code(l_enc_lines_no) := t_enc_lines_array.r_hierarchy_code(recno1);
8383 l_enc_lines_no := l_enc_lines_no + 1;
8384 END IF;
8385 END LOOP;
8386 END IF;
8387
8388 t_enc_lines_array.r_enc_element_type_id.DELETE;
8389 t_enc_lines_array.r_encumbrance_date.DELETE;
8390 t_enc_lines_array.r_dr_cr_flag.DELETE;
8391 t_enc_lines_array.r_encumbrance_amount.DELETE;
8392 t_enc_lines_array.r_enc_line_type.DELETE;
8393 t_enc_lines_array.r_schedule_line_id.DELETE;
8394 t_enc_lines_array.r_org_schedule_id.DELETE;
8395 t_enc_lines_array.r_default_org_account_id.DELETE;
8396 t_enc_lines_array.r_suspense_org_account_id.DELETE;
8397 t_enc_lines_array.r_element_account_id.DELETE;
8398 t_enc_lines_array.r_gl_project_flag.DELETE;
8399 t_enc_lines_array.r_person_id.DELETE;
8400 t_enc_lines_array.r_assignment_id.DELETE;
8401 t_enc_lines_array.r_award_id.DELETE;
8402 t_enc_lines_array.r_task_id.DELETE;
8403 t_enc_lines_array.r_expenditure_type.DELETE;
8404 t_enc_lines_array.r_expenditure_organization_id.DELETE;
8405 t_enc_lines_array.r_project_id.DELETE;
8406 t_enc_lines_array.r_gl_code_combination_id.DELETE;
8407 t_enc_lines_array.r_time_period_id.DELETE;
8408 t_enc_lines_array.r_default_reason_code.DELETE;
8409 t_enc_lines_array.r_suspense_reason_code.DELETE;
8410 t_enc_lines_array.r_enc_control_id.DELETE;
8411 t_enc_lines_array.r_change_flag.DELETE;
8412 t_enc_lines_array.r_enc_start_date.DELETE;
8413 t_enc_lines_array.r_enc_end_date.DELETE;
8414 t_enc_lines_array.r_attribute_category.DELETE;
8415 t_enc_lines_array.r_attribute1.DELETE;
8416 t_enc_lines_array.r_attribute2.DELETE;
8417 t_enc_lines_array.r_attribute3.DELETE;
8418 t_enc_lines_array.r_attribute4.DELETE;
8419 t_enc_lines_array.r_attribute5.DELETE;
8420 t_enc_lines_array.r_attribute6.DELETE;
8421 t_enc_lines_array.r_attribute7.DELETE;
8422 t_enc_lines_array.r_attribute8.DELETE;
8423 t_enc_lines_array.r_attribute9.DELETE;
8424 t_enc_lines_array.r_attribute10.DELETE;
8425 t_enc_lines_array.r_orig_gl_code_combination_id.DELETE;
8426 t_enc_lines_array.r_orig_project_id.DELETE;
8427 t_enc_lines_array.r_orig_award_id.DELETE;
8428 t_enc_lines_array.r_orig_task_id.DELETE;
8429 t_enc_lines_array.r_orig_expenditure_type.DELETE;
8430 t_enc_lines_array.r_orig_expenditure_org_id.DELETE;
8431 t_enc_lines_array.r_hierarchy_code.DELETE;
8432 t_enc_lines_array.r_hierarchy_start_date.DELETE;
8433 t_enc_lines_array.r_hierarchy_end_date.DELETE;
8434
8435 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);
8436
8437 --IF (t_enc_lines_array2.r_enc_element_type_id.COUNT = 0) THEN
8438 --delete_previous_error_log(p_assignment_id => p_assignment_id,
8439 --p_payroll_id => p_payroll_id,
8440 --p_payroll_action_id => g_payroll_action_id);
8441 --END IF;
8442
8443 insert_enc_lines_from_arrays (p_payroll_id => p_payroll_id,
8444 p_business_group_id => p_business_group_id,
8445 p_set_of_books_id => p_set_of_books_id,
8446 p_enc_line_type => 'U',
8447 p_return_status => l_return_status);
8448
8449 IF l_return_status <> fnd_api.g_ret_sts_success THEN
8450 RAISE fnd_api.g_exc_unexpected_error;
8451 END IF;
8452
8453 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving verify_changes
8454 p_payroll_id: ' || p_payroll_id || ' p_assignment_id: ' || p_assignment_id || '
8455 p_business_group_id: ' || p_business_group_id || ' p_set_of_books_id: ' || p_set_of_books_id || '
8456 p_enc_line_type: ' || p_enc_line_type);
8457 l_retcode := FND_API.G_RET_STS_SUCCESS;
8458 EXCEPTION
8459 WHEN OTHERS THEN
8460 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
8461 IF (g_error_message IS NULL) THEN
8462 g_error_message := 'VERIFY_CHANGES: ' || SQLERRM;
8463 END IF;
8464 g_error_api_path := SUBSTR('VERIFY_CHANGES:' || g_error_api_path,1,230);
8465 fnd_msg_pub.add_exc_msg('PSP_ENC_UPDATE_LINES', 'VERIFY_CHANGES');
8466 l_retcode := fnd_api.g_ret_sts_unexp_error;
8467 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving verify_changes
8468 p_payroll_id: ' || p_payroll_id || '
8469 p_assignment_id: ' || p_assignment_id || '
8470 p_business_group_id: ' || p_business_group_id || '
8471 p_set_of_books_id: ' || p_set_of_books_id || '
8472 p_enc_line_type: ' || p_enc_line_type);
8473 END verify_changes;
8474
8475 PROCEDURE create_liq_lines (p_payroll_action_id IN NUMBER,
8476 p_payroll_id IN NUMBER,
8477 p_assignment_id IN NUMBER,
8478 p_enc_begin_date IN DATE,
8479 p_business_group_id IN NUMBER,
8480 p_set_of_books_id IN NUMBER,
8481 p_return_status OUT NOCOPY VARCHAR2) IS
8482 l_last_updated_by NUMBER(15);
8483 l_last_update_login NUMBER(15);
8484 BEGIN
8485 l_last_updated_by := fnd_global.user_id;
8486 l_last_update_login := fnd_global.login_id;
8487
8488 INSERT INTO psp_enc_summary_lines
8489 (enc_summary_line_id, business_group_id, set_of_books_id,
8490 enc_control_id, time_period_id, person_id,
8491 assignment_id, effective_date, gl_code_combination_id,
8492 project_id, task_id, award_id,
8493 expenditure_organization_id, expenditure_type,
8494 summary_amount, dr_cr_flag, status_code,
8495 payroll_id, gl_project_flag, superceded_line_id,
8496 attribute_category, attribute1, attribute2,
8497 attribute3, attribute4, attribute5,
8498 attribute6, attribute7, attribute8,
8499 attribute9, attribute10, payroll_action_id,
8500 proposed_termination_date, last_update_date, last_updated_by,
8501 last_update_login, created_by, creation_date,
8502 update_flag, org_id)
8503 SELECT psp_enc_summary_lines_s.NEXTVAL,
8504 p_business_group_id,
8505 p_set_of_books_id,
8506 pesl.enc_control_id,
8507 pesl.time_period_id,
8508 pesl.person_id,
8509 pesl.assignment_id,
8510 pesl.effective_date,
8511 pesl.gl_code_combination_id,
8512 pesl.project_id,
8513 pesl.task_id,
8514 pesl.award_id,
8515 pesl.expenditure_organization_id,
8516 pesl.expenditure_type,
8517 DECODE(pesl.gl_project_flag, 'G', pesl.summary_amount, -pesl.summary_amount),
8518 DECODE(pesl.dr_cr_flag, 'C', 'D', 'D', 'C') dr_cr_flag,
8519 'N',
8520 pesl.payroll_id,
8521 pesl.gl_project_flag,
8522 pesl.enc_summary_line_id,
8523 DECODE(g_dff_grouping_option, 'Y', pesl.attribute_category, NULL) attribute_category,
8524 DECODE(g_dff_grouping_option, 'Y', pesl.attribute1, NULL) attribute1,
8525 DECODE(g_dff_grouping_option, 'Y', pesl.attribute2, NULL) attribute2,
8526 DECODE(g_dff_grouping_option, 'Y', pesl.attribute3, NULL) attribute3,
8527 DECODE(g_dff_grouping_option, 'Y', pesl.attribute4, NULL) attribute4,
8528 DECODE(g_dff_grouping_option, 'Y', pesl.attribute5, NULL) attribute5,
8529 DECODE(g_dff_grouping_option, 'Y', pesl.attribute6, NULL) attribute6,
8530 DECODE(g_dff_grouping_option, 'Y', pesl.attribute7, NULL) attribute7,
8531 DECODE(g_dff_grouping_option, 'Y', pesl.attribute8, NULL) attribute8,
8532 DECODE(g_dff_grouping_option, 'Y', pesl.attribute9, NULL) attribute9,
8533 DECODE(g_dff_grouping_option, 'Y', pesl.attribute10, NULL) attribute10,
8534 p_payroll_action_id,
8535 g_actual_term_date,
8536 SYSDATE,
8537 l_last_updated_by,
8538 l_last_update_login,
8539 l_last_updated_by,
8540 SYSDATE,
8541 DECODE(SIGN(TRUNC(effective_date)-TRUNC(p_enc_begin_date)), 1, 'U', 'L'),
8542 pesl.org_id
8543 FROM psp_enc_summary_lines pesl
8544 WHERE pesl.assignment_id = p_assignment_id
8545 AND pesl.payroll_id = p_payroll_id
8546 AND pesl.status_code = 'A'
8547 AND pesl.enc_summary_line_id IN (SELECT pelh.enc_summary_line_id
8548 FROM psp_enc_lines_history pelh
8549 WHERE pelh.change_flag = 'N'
8550 AND pelh.assignment_id = p_assignment_id
8551 AND pelh.payroll_id = p_payroll_id);
8552 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' No of liquidation lines created: ' || SQL%ROWCOUNT);
8553
8554 p_return_status := fnd_api.g_ret_sts_success;
8555 EXCEPTION
8556 WHEN OTHERS THEN
8557 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
8558 IF (g_error_message IS NULL) THEN
8559 g_error_message := 'CREATE_LIQ_LINES: ' || SQLERRM;
8560 END IF;
8561 g_error_api_path := SUBSTR('CREATE_LIQ_LINES:' || g_error_api_path,1,230);
8562 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'CREATE_LIQ_LINES');
8563 p_return_status := fnd_api.g_ret_sts_unexp_error;
8564 END create_liq_lines;
8565
8566 PROCEDURE create_sum_lines (p_payroll_action_id IN NUMBER,
8567 p_payroll_id IN NUMBER,
8568 p_assignment_id IN NUMBER,
8569 p_business_group_id IN NUMBER,
8570 p_set_of_books_id IN NUMBER,
8571 p_return_status OUT NOCOPY VARCHAR2) IS
8572 l_last_updated_by NUMBER(15);
8573 l_last_update_login NUMBER(15);
8574
8575 CURSOR sum_lines_cur IS
8576 SELECT pel.enc_control_id,
8577 pel.time_period_id,
8578 pel.person_id,
8579 pel.encumbrance_date,
8580 pel.gl_code_combination_id,
8581 pel.project_id,
8582 pel.task_id,
8583 pel.award_id,
8584 pel.expenditure_type,
8585 pel.expenditure_organization_id,
8586 SUM(pel.encumbrance_amount),
8587 pel.dr_cr_flag,
8588 pel.gl_project_flag,
8589 DECODE(g_dff_grouping_option, 'Y', pel.attribute_category, NULL) attribute_category,
8590 DECODE(g_dff_grouping_option, 'Y', pel.attribute1, NULL) attribute1,
8591 DECODE(g_dff_grouping_option, 'Y', pel.attribute2, NULL) attribute2,
8592 DECODE(g_dff_grouping_option, 'Y', pel.attribute3, NULL) attribute3,
8593 DECODE(g_dff_grouping_option, 'Y', pel.attribute4, NULL) attribute4,
8594 DECODE(g_dff_grouping_option, 'Y', pel.attribute5, NULL) attribute5,
8595 DECODE(g_dff_grouping_option, 'Y', pel.attribute6, NULL) attribute6,
8596 DECODE(g_dff_grouping_option, 'Y', pel.attribute7, NULL) attribute7,
8597 DECODE(g_dff_grouping_option, 'Y', pel.attribute8, NULL) attribute8,
8598 DECODE(g_dff_grouping_option, 'Y', pel.attribute9, NULL) attribute9,
8599 DECODE(g_dff_grouping_option, 'Y', pel.attribute10, NULL) attribute10,
8600 pa.org_id
8601 FROM PSP_ENC_LINES pel,
8602 PSP_ORGANIZATION_ACCOUNTS pos,
8603 pa_projects_all pa
8604 WHERE pel.ENCUMBRANCE_AMOUNT <> 0
8605 AND pel.assignment_id = p_assignment_id
8606 AND pel.payroll_id = p_payroll_id
8607 AND pel.suspense_org_account_id = pos.organization_account_id(+)
8608 AND pa.project_id (+) = pel.project_id
8609 AND pel.payroll_action_id = p_payroll_action_id
8610 GROUP BY pel.enc_control_id,
8611 pel.time_period_id,
8612 pel.person_id,
8613 pel.encumbrance_date,
8614 pel.gl_code_combination_id,
8615 pel.project_id,
8616 pel.task_id,
8617 pel.award_id,
8618 pel.expenditure_type,
8619 pel.expenditure_organization_id,
8620 pel.dr_cr_flag,
8621 pel.gl_project_flag,
8622 DECODE(g_dff_grouping_option, 'Y', pel.attribute_category, NULL),
8623 DECODE(g_dff_grouping_option, 'Y', pel.attribute1, NULL),
8624 DECODE(g_dff_grouping_option, 'Y', pel.attribute2, NULL),
8625 DECODE(g_dff_grouping_option, 'Y', pel.attribute3, NULL),
8626 DECODE(g_dff_grouping_option, 'Y', pel.attribute4, NULL),
8627 DECODE(g_dff_grouping_option, 'Y', pel.attribute5, NULL),
8628 DECODE(g_dff_grouping_option, 'Y', pel.attribute6, NULL),
8629 DECODE(g_dff_grouping_option, 'Y', pel.attribute7, NULL),
8630 DECODE(g_dff_grouping_option, 'Y', pel.attribute8, NULL),
8631 DECODE(g_dff_grouping_option, 'Y', pel.attribute9, NULL),
8632 DECODE(g_dff_grouping_option, 'Y', pel.attribute10, NULL),
8633 pa.org_id;
8634
8635 TYPE sum_lines_rec is RECORD
8636 (enc_summary_line_id t_num_15_type,
8637 enc_control_id t_num_15_type,
8638 time_period_id t_num_15_type,
8639 person_id t_num_15_type,
8640 effective_date t_date_type,
8641 gl_code_combination_id t_num_15_type,
8642 project_id t_num_15_type,
8643 task_id t_num_15_type,
8644 award_id t_num_15_type,
8645 expenditure_organization_id t_num_15_type,
8646 expenditure_type t_varchar_50_type,
8647 summary_amount t_num_10d2_type,
8648 dr_cr_flag t_varchar_50_type,
8649 gl_project_flag t_varchar_50_type,
8650 attribute_category t_varchar_50_type,
8651 attribute1 t_varchar_150_type,
8652 attribute2 t_varchar_150_type,
8653 attribute3 t_varchar_150_type,
8654 attribute4 t_varchar_150_type,
8655 attribute5 t_varchar_150_type,
8656 attribute6 t_varchar_150_type,
8657 attribute7 t_varchar_150_type,
8658 attribute8 t_varchar_150_type,
8659 attribute9 t_varchar_150_type,
8660 attribute10 t_varchar_150_type,
8661 org_id t_num_15_type);
8662 t_sum_lines sum_lines_rec;
8663 BEGIN
8664 l_last_updated_by := fnd_global.user_id;
8665 l_last_update_login := fnd_global.login_id;
8666
8667 OPEN sum_lines_cur;
8668 FETCH sum_lines_cur BULK COLLECT INTO t_sum_lines.enc_control_id,
8669 t_sum_lines.time_period_id, t_sum_lines.person_id,
8670 t_sum_lines.effective_date, t_sum_lines.gl_code_combination_id,
8671 t_sum_lines.project_id, t_sum_lines.task_id,
8672 t_sum_lines.award_id, t_sum_lines.expenditure_type,
8673 t_sum_lines.expenditure_organization_id,t_sum_lines.summary_amount,
8674 t_sum_lines.dr_cr_flag, t_sum_lines.gl_project_flag,
8675 t_sum_lines.attribute_category, t_sum_lines.attribute1,
8676 t_sum_lines.attribute2, t_sum_lines.attribute3,
8677 t_sum_lines.attribute4, t_sum_lines.attribute5,
8678 t_sum_lines.attribute6, t_sum_lines.attribute7,
8679 t_sum_lines.attribute8, t_sum_lines.attribute9,
8680 t_sum_lines.attribute10, t_sum_lines.org_id;
8681 CLOSE sum_lines_cur;
8682
8683 FOR recno IN 1..t_sum_lines.enc_control_id.COUNT
8684 LOOP
8685 SELECT psp_enc_summary_lines_s.NEXTVAL INTO t_sum_lines.enc_summary_line_id(recno) FROM DUAL;
8686 END LOOP;
8687
8688 FORALL recno IN 1..t_sum_lines.enc_control_id.COUNT
8689 INSERT INTO psp_enc_summary_lines
8690 (enc_summary_line_id, business_group_id, enc_control_id,
8691 time_period_id, person_id, assignment_id,
8692 effective_date, set_of_books_id, gl_code_combination_id,
8693 project_id, task_id, award_id,
8694 expenditure_organization_id, expenditure_type, summary_amount,
8695 dr_cr_flag, status_code, payroll_id,
8696 gl_project_flag,
8697 attribute_category, attribute1, attribute2,
8698 attribute3, attribute4, attribute5,
8699 attribute6, attribute7, attribute8,
8700 attribute9, attribute10, payroll_action_id,
8701 proposed_termination_date, last_update_date, last_updated_by,
8702 last_update_login, created_by, creation_date,
8703 org_id)
8704 VALUES (t_sum_lines.enc_summary_line_id(recno), p_business_group_id,
8705 t_sum_lines.enc_control_id(recno), t_sum_lines.time_period_id(recno),
8706 t_sum_lines.person_id(recno), p_assignment_id,
8707 t_sum_lines.effective_date(recno), p_set_of_books_id,
8708 t_sum_lines.gl_code_combination_id(recno), t_sum_lines.project_id(recno),
8709 t_sum_lines.task_id(recno), t_sum_lines.award_id(recno),
8710 t_sum_lines.expenditure_organization_id(recno), t_sum_lines.expenditure_type(recno),
8711 t_sum_lines.summary_amount(recno), t_sum_lines.dr_cr_flag(recno),
8712 'N', p_payroll_id, t_sum_lines.gl_project_flag(recno),
8713 t_sum_lines.attribute_category(recno), t_sum_lines.attribute1(recno),
8714 t_sum_lines.attribute2(recno), t_sum_lines.attribute3(recno),
8715 t_sum_lines.attribute4(recno), t_sum_lines.attribute5(recno),
8716 t_sum_lines.attribute6(recno), t_sum_lines.attribute7(recno),
8717 t_sum_lines.attribute8(recno), t_sum_lines.attribute9(recno),
8718 t_sum_lines.attribute10(recno), p_payroll_action_id,
8719 g_actual_term_date, SYSDATE,
8720 l_last_updated_by, l_last_update_login,
8721 l_last_updated_by, SYSDATE,
8722 t_sum_lines.org_id(recno));
8723 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);
8724
8725 IF (g_dff_grouping_option = 'Y') THEN
8726 FORALL recno IN 1..t_sum_lines.enc_summary_line_id.COUNT
8727 UPDATE psp_enc_lines pel
8728 SET enc_summary_line_id = t_sum_lines.enc_summary_line_id(recno)
8729 WHERE payroll_action_id = p_payroll_action_id
8730 AND pel.assignment_id = p_assignment_id
8731 AND pel.payroll_id = p_payroll_id
8732 AND pel.enc_control_id = t_sum_lines.enc_control_id(recno)
8733 AND pel.time_period_id = t_sum_lines.time_period_id(recno)
8734 AND pel.person_id = t_sum_lines.person_id(recno)
8735 AND pel.encumbrance_date = t_sum_lines.effective_date(recno)
8736 AND NVL(pel.gl_code_combination_id, -99) = NVL(t_sum_lines.gl_code_combination_id(recno), -99)
8737 AND NVL(pel.project_id, -99) = NVL(t_sum_lines.project_id(recno), -99)
8738 AND NVL(pel.task_id, -99) = NVL(t_sum_lines.task_id(recno), -99)
8739 AND NVL(pel.award_id, -99) = NVL(t_sum_lines.award_id(recno), -99)
8740 AND NVL(pel.expenditure_type, 'NULL') = NVL(t_sum_lines.expenditure_type(recno), 'NULL')
8741 AND NVL(pel.expenditure_organization_id, -99) = NVL(t_sum_lines.expenditure_organization_id(recno), -99)
8742 AND pel.dr_cr_flag = t_sum_lines.dr_cr_flag(recno)
8743 AND pel.gl_project_flag = t_sum_lines.gl_project_flag(recno)
8744 AND NVL(pel.attribute_category, 'NULL') = NVL(t_sum_lines.attribute_category(recno), 'NULL')
8745 AND NVL(pel.attribute1, 'NULL') = NVL(t_sum_lines.attribute1(recno), 'NULL')
8746 AND NVL(pel.attribute2, 'NULL') = NVL(t_sum_lines.attribute2(recno), 'NULL')
8747 AND NVL(pel.attribute3, 'NULL') = NVL(t_sum_lines.attribute3(recno), 'NULL')
8748 AND NVL(pel.attribute4, 'NULL') = NVL(t_sum_lines.attribute4(recno), 'NULL')
8749 AND NVL(pel.attribute5, 'NULL') = NVL(t_sum_lines.attribute5(recno), 'NULL')
8750 AND NVL(pel.attribute6, 'NULL') = NVL(t_sum_lines.attribute6(recno), 'NULL')
8751 AND NVL(pel.attribute7, 'NULL') = NVL(t_sum_lines.attribute7(recno), 'NULL')
8752 AND NVL(pel.attribute8, 'NULL') = NVL(t_sum_lines.attribute8(recno), 'NULL')
8753 AND NVL(pel.attribute9, 'NULL') = NVL(t_sum_lines.attribute9(recno), 'NULL')
8754 AND NVL(pel.attribute10, 'NULL') = NVL(t_sum_lines.attribute10(recno), 'NULL');
8755 ELSE
8756 FORALL recno IN 1..t_sum_lines.enc_summary_line_id.COUNT
8757 UPDATE psp_enc_lines pel
8758 SET enc_summary_line_id = t_sum_lines.enc_summary_line_id(recno)
8759 WHERE payroll_action_id = p_payroll_action_id
8760 AND pel.assignment_id = p_assignment_id
8761 AND pel.payroll_id = p_payroll_id
8762 AND pel.enc_control_id = t_sum_lines.enc_control_id(recno)
8763 AND pel.time_period_id = t_sum_lines.time_period_id(recno)
8764 AND pel.person_id = t_sum_lines.person_id(recno)
8765 AND pel.encumbrance_date = t_sum_lines.effective_date(recno)
8766 AND NVL(pel.gl_code_combination_id, -99) = NVL(t_sum_lines.gl_code_combination_id(recno), -99)
8767 AND NVL(pel.project_id, -99) = NVL(t_sum_lines.project_id(recno), -99)
8768 AND NVL(pel.task_id, -99) = NVL(t_sum_lines.task_id(recno), -99)
8769 AND NVL(pel.award_id, -99) = NVL(t_sum_lines.award_id(recno), -99)
8770 AND NVL(pel.expenditure_type, 'NULL') = NVL(t_sum_lines.expenditure_type(recno), 'NULL')
8771 AND NVL(pel.expenditure_organization_id, -99) = NVL(t_sum_lines.expenditure_organization_id(recno), -99)
8772 AND pel.dr_cr_flag = t_sum_lines.dr_cr_flag(recno)
8773 AND pel.gl_project_flag = t_sum_lines.gl_project_flag(recno);
8774 END IF;
8775 p_return_status := fnd_api.g_ret_sts_success;
8776 EXCEPTION
8777 WHEN OTHERS THEN
8778 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
8779 IF (g_error_message IS NULL) THEN
8780 g_error_message := 'CREATE_SUM_LINES: ' || SQLERRM;
8781 END IF;
8782 g_error_api_path := SUBSTR('CREATE_SUM_LINES:' || g_error_api_path,1,230);
8783 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'CREATE_SUM_LINES');
8784 p_return_status := fnd_api.g_ret_sts_unexp_error;
8785 END create_sum_lines;
8786
8787 PROCEDURE enc_pre_process (p_payroll_action_id IN NUMBER,
8788 p_payroll_id IN NUMBER,
8789 p_process_mode IN VARCHAR2,
8790 p_return_status OUT NOCOPY VARCHAR2) IS
8791 l_new_cust NUMBER;
8792 l_pre_process_mode CHAR(1);
8793 l_inc_exc_flag CHAR(1);
8794 l_business_group_id NUMBER(15);
8795 l_set_of_books_id NUMBER(15);
8796 l_request_id NUMBER(15);
8797 l_count NUMBER(15);
8798 l_enc_begin_date DATE;
8799 l_return_status VARCHAR2(1);
8800 l_assignment_id NUMBER(15);
8801 l_payroll_action_id NUMBER(15);
8802 l_payroll_id NUMBER(15);
8803 l_person_id NUMBER(15);
8804 l_organization_id NUMBER(15);
8805 l_assignment_number per_all_assignments_f.assignment_number%TYPE;
8806 l_payroll_name pay_all_payrolls_f.payroll_name%TYPE;
8807 l_full_name per_all_people_f.full_name%TYPE;
8808 l_organization_name hr_organization_units.name%TYPE;
8809 l_process_description fnd_concurrent_programs_tl.user_concurrent_program_name%TYPE;
8810 l_process_mode VARCHAR2(15);
8811 l_person_id1 NUMBER(15);
8812 l_termination_date1 DATE;
8813 l_person_id2 NUMBER(15);
8814 l_termination_date2 DATE;
8815 l_person_id3 NUMBER(15);
8816 l_termination_date3 DATE;
8817 l_person_id4 NUMBER(15);
8818 l_termination_date4 DATE;
8819 l_person_id5 NUMBER(15);
8820 l_termination_date5 DATE;
8821
8822
8823 CURSOR new_cust_cur IS
8824 SELECT COUNT(1)
8825 FROM psp_enc_controls
8826 WHERE ROWNUM = 1;
8827
8828 CURSOR action_parameters_cur IS
8829 SELECT fnd_number.canonical_to_number(NVL(argument13, '-1')),
8830 fnd_date.canonical_to_date(NVL(argument14, fnd_date.date_to_canonical(TRUNC(SYSDATE)))),
8831 fnd_number.canonical_to_number(NVL(argument15, '-1')),
8832 fnd_date.canonical_to_date(NVL(argument16, fnd_date.date_to_canonical(TRUNC(SYSDATE)))),
8833 fnd_number.canonical_to_number(NVL(argument17, '-1')),
8834 fnd_date.canonical_to_date(NVL(argument18, fnd_date.date_to_canonical(TRUNC(SYSDATE)))),
8835 fnd_number.canonical_to_number(NVL(argument19, '-1')),
8836 fnd_date.canonical_to_date(NVL(argument20, fnd_date.date_to_canonical(TRUNC(SYSDATE)))),
8837 fnd_number.canonical_to_number(NVL(argument21, '-1')),
8838 fnd_date.canonical_to_date(NVL(argument22, fnd_date.date_to_canonical(TRUNC(SYSDATE))))
8839 FROM psp_enc_processes pep,
8840 fnd_concurrent_requests fcr
8841 WHERE pep.payroll_action_id = p_payroll_action_id
8842 AND fcr.request_id = pep.request_id;
8843
8844 CURSOR enc_payroll_cur IS
8845 SELECT pep.inc_exc_flag
8846 FROM psp_enc_payrolls pep
8847 WHERE pep.payroll_id = p_payroll_id
8848 AND pep.business_group_id = l_business_group_id
8849 AND pep.set_of_books_id = l_set_of_books_id;
8850
8851 /* Bug 5642002: Replaced earned date with period end date */
8852 CURSOR c_last_pay_run IS
8853 SELECT /*+ use_nl(PTP) */ Max(ptp.end_date)
8854 FROM pay_payroll_actions ppa,
8855 pay_assignment_actions paa,
8856 per_time_periods ptp
8857 WHERE ppa.payroll_action_id = paa.payroll_action_id (+)
8858 AND ppa.business_group_id = l_business_group_id
8859 AND ppa.payroll_id = p_payroll_id
8860 AND ppa.action_type IN ( 'R','Q')
8861 AND NVL(paa.action_status, ppa.action_status) = 'C'
8862 and ppa.date_earned between ptp.start_date and ptp.end_date
8863 and ptp.payroll_id = ppa.payroll_id;
8864
8865 CURSOR c_tp_start_date IS
8866 SELECT MIN(ptp.start_date)
8867 FROM per_time_periods ptp
8868 WHERE ptp.payroll_id= p_payroll_id;
8869
8870 CURSOR asg_number_cur (p_start_date IN DATE) IS
8871 SELECT assignment_number,
8872 person_id,
8873 organization_id
8874 FROM per_all_assignments_f
8875 WHERE assignment_id = l_assignment_id
8876 AND payroll_id = NVL(l_payroll_id, p_payroll_id)
8877 AND effective_end_date >= p_start_date
8878 AND ROWNUM = 1;
8879
8880 CURSOR payroll_name_cur IS
8881 SELECT payroll_name
8882 FROM pay_all_payrolls_f
8883 WHERE payroll_id = p_payroll_id
8884 AND business_group_id = g_business_group_id
8885 AND gl_set_of_books_id = g_set_of_books_id
8886 AND ROWNUM = 1;
8887
8888 CURSOR person_name_cur (p_start_date IN DATE) IS
8889 SELECT full_name
8890 FROM per_all_people_f
8891 WHERE person_id = l_person_id
8892 AND effective_end_date >= p_start_date
8893 AND ROWNUM = 1;
8894
8895 CURSOR org_name_cur IS
8896 SELECT name
8897 FROM hr_organization_units
8898 WHERE organization_id = l_organization_id;
8899
8900 CURSOR process_descr_cur IS
8901 SELECT pep.request_id || ': ' || fcpt.user_concurrent_program_name
8902 FROM psp_enc_processes pep,
8903 fnd_concurrent_requests fcr,
8904 fnd_concurrent_programs_tl fcpt
8905 WHERE EXISTS (SELECT 1
8906 FROM psp_enc_summary_lines pesl
8907 WHERE pesl.payroll_action_id = pep.payroll_action_id
8908 AND pesl.payroll_action_id = l_payroll_action_id)
8909 AND fcr.request_id = pep.request_id
8910 AND fcpt.concurrent_program_id = fcr.concurrent_program_id
8911 AND fcpt.language = USERENV('LANG')
8912 ORDER BY DECODE(pep.process_code, 'LET', 1, 'ST', 2, 3);
8913
8914 CURSOR in_process_term_cur (p_person_id IN NUMBER) IS
8915 SELECT DISTINCT assignment_id,
8916 payroll_id,
8917 payroll_action_id
8918 FROM psp_enc_summary_lines pesl
8919 WHERE pesl.person_id = p_person_id
8920 AND pesl.status_code = 'N';
8921
8922 CURSOR in_process_asg_cur IS
8923 SELECT pepa.assignment_id,
8924 pepa.payroll_action_id
8925 FROM psp_enc_process_assignments pepa
8926 WHERE pepa.payroll_id = p_payroll_id
8927 AND pepa.assignment_status NOT IN ('B', 'P');
8928
8929 l_prev_enc_end_date PSP_ENC_END_DATES_V.prev_enc_end_date%TYPE; -- Bug 7188209
8930
8931 -- Modifications for the delete statement for bug 9862281
8932 CURSOR exc_asg_cur(
8933 p_payroll_id NUMBER,
8934 p_business_group_id NUMBER,
8935 p_payroll_action_id NUMBER,
8936 l_request_id NUMBER) IS
8937 SELECT /*+INDEX(peca PSP_ENC_CHANGED_ASSIGNMENTS_N3)
8938
8939 */
8940 peca.assignment_id
8941 FROM psp_enc_changed_assignments peca
8942 WHERE payroll_action_id = p_payroll_action_id
8943 AND payroll_id = p_payroll_id
8944 AND request_id = l_request_id
8945 AND assignment_id IN
8946 (
8947 SELECT /*+ ORDERED
8948 INDEX(pep PSP_ENC_PAYROLLS_N1)
8949 INDEX(pepa PSP_ENC_PAYROLL_ASSIGNMENTS_N1)
8950 */
8951 pepa.assignment_id
8952 FROM psp_enc_payrolls pep
8953 ,psp_enc_payroll_assignments pepa
8954 WHERE pep.payroll_id = p_payroll_id
8955 AND pep.inc_exc_flag = 'Y'
8956 AND pep.enc_payroll_id = pepa.enc_payroll_id
8957 AND pep.business_group_id = p_business_group_id
8958 UNION
8959 SELECT /*+ORDERED
8960 NO_USE_MERGE(paaf) */
8961 DISTINCT
8962 paaf.assignment_id
8963 FROM psp_enc_payrolls pep
8964 ,per_all_assignments_f paaf
8965 WHERE pep.inc_exc_flag = 'N'
8966 AND pep.payroll_id = paaf.payroll_id
8967 AND pep.payroll_id = p_payroll_id
8968 AND pep.business_group_id = p_business_group_id
8969 AND paaf.assignment_type = 'E'
8970 AND NOT EXISTS
8971 (
8972 SELECT pepa.assignment_id
8973 FROM psp_enc_payroll_assignments pepa
8974 WHERE pepa.business_group_id = p_business_group_id
8975 AND pepa.assignment_id = paaf.assignment_id
8976 )
8977 );
8978 l_asg_exists NUMBER;
8979
8980 TYPE t_asg_id_type IS TABLE OF NUMBER(15) ;
8981
8982 asg_id_tab t_asg_id_type;
8983 -- Modifications for bug 9862281 end
8984 BEGIN
8985 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Entering ENC_PRE_PROCESS
8986 p_payroll_action_id: ' || p_payroll_action_id || '
8987 p_payroll_id: ' || p_payroll_id || '
8988 p_process_mode: ' || p_process_mode);
8989
8990 l_request_id := FND_GLOBAL. CONC_REQUEST_ID;
8991 l_set_of_books_id := FND_PROFILE.VALUE('GL_SET_OF_BKS_ID');
8992 l_business_group_id := FND_PROFILE.VALUE('PER_BUSINESS_GROUP_ID');
8993 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_request_id: ' || l_request_id ||'
8994 l_set_of_books_id: ' || l_set_of_books_id || '
8995 l_business_group_id: ' || l_business_group_id);
8996
8997 IF (p_process_mode = 'REGULAR') THEN
8998 OPEN new_cust_cur;
8999 FETCH new_cust_cur INTO l_new_cust;
9000 CLOSE new_cust_cur;
9001
9002 OPEN c_last_pay_run;
9003 FETCH c_last_pay_run INTO l_enc_begin_date;
9004 CLOSE c_last_pay_run;
9005
9006 IF (l_enc_begin_date IS NULL) THEN
9007 OPEN c_tp_start_date;
9008 FETCH c_tp_start_date INTO l_enc_begin_date;
9009 CLOSE c_tp_start_date;
9010 END IF;
9011 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_enc_begin_date: ' || fnd_date.date_to_canonical(l_enc_begin_date));
9012
9013 l_pre_process_mode := 'R';
9014 IF (l_new_cust = 0 AND psp_general.start_capturing_updates(l_business_group_id) = 'N') THEN
9015 l_pre_process_mode := 'F';
9016 END IF;
9017
9018 psp_enc_pre_process.poeta_pre_process
9019 (p_pre_process_mode => l_pre_process_mode,
9020 p_payroll_id => p_payroll_id,
9021 p_business_group_id => l_business_group_id,
9022 p_set_of_books_id => l_set_of_books_id,
9023 p_return_status => l_return_status);
9024 IF l_return_status <> fnd_api.g_ret_sts_success THEN
9025 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9026 END IF;
9027 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Completed psp_enc_pre_process.poeta_pre_process');
9028
9029 IF (l_pre_process_mode <>'F') THEN
9030 psp_enc_pre_process.labor_schedule_pre_process
9031 (p_enc_line_type => 'U',
9032 p_payroll_id => p_payroll_id,
9033 p_return_status => l_return_status);
9034
9035 IF l_return_status <> fnd_api.g_ret_sts_success THEN
9036 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
9037 END IF;
9038 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Completed psp_enc_pre_process.labor_schedule_pre_process');
9039 END IF;
9040
9041 OPEN enc_payroll_cur;
9042 FETCH enc_payroll_cur INTO l_inc_exc_flag;
9043 CLOSE enc_payroll_cur;
9044 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_inc_exc_flag: ' || l_inc_exc_flag);
9045
9046 -- Bug 7188209
9047 -- Bug 10058104
9048 select prev_enc_end_date into l_prev_enc_end_date
9049 from PSP_ENC_END_DATES_V
9050 where business_group_id = l_business_group_id
9051 and set_of_books_id = l_set_of_books_id
9052 and default_org_flag='Y';
9053 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_prev_enc_end_date = ' || l_prev_enc_end_date);
9054
9055 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Using Oracle Payroll Profile Value: '||FND_PROFILE.VALUE('PSP_USING_ORACLE_PAYROLL'));
9056
9057 -- The following profile check is introduced and the insert statements are duplicated
9058 -- to take care of the performance issues caused by outer joins added for the custoemrs
9059 -- who are using Non-Oracle Payroll as in the bug 12769510
9060
9061 IF NVL(FND_PROFILE.VALUE('PSP_USING_ORACLE_PAYROLL'),'Y') = 'Y' -- Oracle Payroll Profile
9062 THEN
9063 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Using Oracle Payroll');
9064
9065 g_payroll_mode := 'Y'; --This helps to choose the query for oracle payroll in get_asg_pay_end_date function ----13566809
9066
9067 IF l_inc_exc_flag = 'Y' THEN
9068
9069 INSERT INTO psp_enc_changed_assignments
9070 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
9071 SELECT DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'CR', p_payroll_action_id
9072 FROM per_assignments_f pa
9073 WHERE pa.payroll_id = p_payroll_id
9074 AND pa.assignment_type = 'E'
9075 AND pa.business_group_id = l_business_group_id
9076 -- AND pa.effective_end_date >= l_enc_begin_date
9077 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
9078 AND pa.effective_end_date >= (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pa.assignment_id,pa.business_group_id,pa.payroll_id) --13566809
9079 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9080 ),l_enc_begin_date))
9081 AND NOT EXISTS (SELECT pepa.assignment_id
9082 FROM psp_enc_payroll_assignments pepa,
9083 psp_enc_payrolls pep
9084 WHERE pepa.enc_payroll_id = pep.enc_payroll_id
9085 AND pepa.business_group_id = l_business_group_id
9086 AND pepa.set_of_books_id = l_set_of_books_id
9087 AND pepa.business_group_id = pep.business_group_id
9088 AND pepa.set_of_books_id = pep.set_of_books_id
9089 AND pep.payroll_id = p_payroll_id
9090 AND pepa.assignment_id = pa.assignment_id)
9091 AND NOT EXISTS (SELECT 1
9092 FROM psp_enc_changed_assignments peca
9093 WHERE peca.assignment_id = pa.assignment_id
9094 AND peca.payroll_id = p_payroll_id)
9095 AND NOT EXISTS (SELECT 1
9096 FROM psp_enc_summary_lines pesl
9097 WHERE pesl.assignment_id = pa.assignment_id
9098 AND pesl.status_code IN ('A', 'N')
9099 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
9100 AND pesl.effective_date > (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pesl.assignment_id,pesl.business_group_id,pesl.payroll_id) --13566809
9101 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9102 ),l_enc_begin_date))
9103 AND pesl.payroll_id = p_payroll_id);
9104
9105 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '10-A Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
9106
9107
9108 -- Added this INSERT for bug 7188209
9109
9110 INSERT INTO psp_enc_changed_assignments
9111 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
9112 SELECT DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'CR', p_payroll_action_id
9113 FROM per_assignments_f pa
9114 WHERE pa.payroll_id = p_payroll_id
9115 AND pa.assignment_type = 'E'
9116 AND pa.business_group_id = l_business_group_id
9117 AND pa.effective_end_date >= (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pa.assignment_id,pa.business_group_id,pa.payroll_id) --13566809
9118 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9119 ),l_enc_begin_date))
9120 AND NOT EXISTS (SELECT pepa.assignment_id
9121 FROM psp_enc_payroll_assignments pepa,
9122 psp_enc_payrolls pep
9123 WHERE pepa.enc_payroll_id = pep.enc_payroll_id
9124 AND pepa.business_group_id = l_business_group_id
9125 AND pepa.set_of_books_id = l_set_of_books_id
9126 AND pepa.business_group_id = pep.business_group_id
9127 AND pepa.set_of_books_id = pep.set_of_books_id
9128 AND pep.payroll_id = p_payroll_id
9129 AND pepa.assignment_id = pa.assignment_id)
9130 AND NOT EXISTS (SELECT 1
9131 FROM psp_enc_changed_assignments peca
9132 WHERE peca.assignment_id = pa.assignment_id
9133 AND peca.payroll_id = p_payroll_id)
9134 AND NOT EXISTS (SELECT 1
9135 FROM psp_enc_summary_lines pesl
9136 WHERE pesl.assignment_id = pa.assignment_id
9137 AND pesl.status_code IN ('A', 'N')
9138 AND pesl.effective_date > l_prev_enc_end_date
9139 AND pesl.payroll_id = p_payroll_id);
9140
9141 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '10-B Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
9142
9143 INSERT INTO psp_enc_changed_assignments
9144 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
9145 SELECT DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'ZZ', p_payroll_action_id
9146 FROM per_assignments_f pa
9147 WHERE pa.payroll_id = p_payroll_id
9148 AND pa.assignment_type = 'E'
9149 AND pa.business_group_id = l_business_group_id
9150 -- AND pa.effective_end_date >= l_enc_begin_date -- Commenting this in the fix 12769510 as it is found to be commented in 11i code
9151 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
9152 AND pa.effective_end_date >= (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pa.assignment_id,pa.business_group_id,pa.payroll_id) --13566809
9153 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9154 ),l_enc_begin_date))
9155 AND EXISTS (SELECT pepa.assignment_id
9156 FROM psp_enc_payroll_assignments pepa,
9157 psp_enc_payrolls pep
9158 WHERE pepa.enc_payroll_id = pep.enc_payroll_id
9159 AND pepa.business_group_id = l_business_group_id
9160 AND pepa.set_of_books_id = l_set_of_books_id
9161 AND pepa.business_group_id = pep.business_group_id
9162 AND pepa.set_of_books_id = pep.set_of_books_id
9163 AND pep.payroll_id = p_payroll_id
9164 AND pepa.assignment_id = pa.assignment_id)
9165 AND EXISTS (SELECT 1
9166 FROM psp_enc_summary_lines pesl
9167 WHERE pesl.assignment_id = pa.assignment_id
9168 AND pesl.status_code = 'A'
9169 AND pesl.payroll_id = p_payroll_id)
9170 AND NOT EXISTS (SELECT 1
9171 FROM psp_enc_summary_lines pesl
9172 WHERE pesl.assignment_id = pa.assignment_id
9173 AND pesl.status_code = 'N'
9174 AND pesl.payroll_id = p_payroll_id);
9175
9176 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '20 Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
9177
9178 ELSE
9179 -- Modified the following statement for bug 9862281
9180 INSERT INTO psp_enc_changed_assignments
9181 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
9182 SELECT /*+
9183 index(Pepa PSP_ENC_PAYROLL_ASSIGNMENTS_N1)
9184 index(PA PER_ASSIGNMENTS_F_PK)
9185 INDEX(pep PSP_ENC_PAYROLLS_N1) */
9186 DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'CR', p_payroll_action_id
9187 FROM psp_enc_payrolls pep,
9188 psp_enc_payroll_assignments pepa,
9189 per_assignments_f pa
9190 WHERE pa.payroll_id = p_payroll_id
9191 AND pepa.business_group_id = l_business_group_id
9192 AND pepa.set_of_books_id = l_set_of_books_id
9193 AND pepa.assignment_id = pa.assignment_id
9194 -- AND pa.effective_end_date >= l_enc_begin_date -- Commenting this in the fix 12769510 as it is found to be commented in 11i code
9195 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
9196 AND pa.effective_end_date >= (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pa.assignment_id,pa.business_group_id,pa.payroll_id) --13566809
9197 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9198 ),l_enc_begin_date))
9199 AND pep.payroll_id = p_payroll_id
9200 AND pep.enc_payroll_id = pepa.enc_payroll_id
9201 AND NOT EXISTS (SELECT 1
9202 FROM psp_enc_changed_assignments peca
9203 WHERE peca.assignment_id = pepa.assignment_id
9204 AND peca.payroll_id = p_payroll_id)
9205 AND NOT EXISTS (SELECT 1
9206 FROM psp_enc_summary_lines pesl
9207 WHERE pesl.assignment_id = pa.assignment_id
9208 AND pesl.payroll_id = pa.payroll_id -- Added for bug 9862281
9209 AND pesl.status_code IN ('A', 'N')
9210 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
9211 AND pesl.effective_date > (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pesl.assignment_id,pesl.business_group_id,pesl.payroll_id) --13566809
9212 ),l_enc_begin_date)) );
9213
9214
9215
9216 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '30-A Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
9217
9218 -- Added for bug 7188209
9219 INSERT INTO psp_enc_changed_assignments
9220 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
9221 SELECT DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'CR', p_payroll_action_id
9222 FROM psp_enc_payroll_assignments pepa,
9223 psp_enc_payrolls pep,
9224 per_assignments_f pa
9225 WHERE pa.payroll_id = p_payroll_id
9226 AND pepa.business_group_id = l_business_group_id
9227 AND pepa.set_of_books_id = l_set_of_books_id
9228 AND pepa.assignment_id = pa.assignment_id
9229 AND pa.effective_end_date >= (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pa.assignment_id,pa.business_group_id,pa.payroll_id) --13566809
9230 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9231 ),l_enc_begin_date))
9232 AND pep.payroll_id = p_payroll_id
9233 AND pep.enc_payroll_id = pepa.enc_payroll_id
9234 AND NOT EXISTS (SELECT 1
9235 FROM psp_enc_changed_assignments peca
9236 WHERE peca.assignment_id = pepa.assignment_id
9237 AND peca.payroll_id = p_payroll_id)
9238 AND NOT EXISTS (SELECT 1
9239 FROM psp_enc_summary_lines pesl
9240 WHERE pesl.assignment_id = pa.assignment_id
9241 AND pesl.status_code IN ('A', 'N')
9242 AND pesl.effective_date > l_prev_enc_end_date);
9243
9244 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '30-B Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
9245
9246 INSERT INTO psp_enc_changed_assignments
9247 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
9248 SELECT DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'ZZ', p_payroll_action_id
9249 FROM per_assignments_f pa
9250 WHERE pa.payroll_id = p_payroll_id
9251 AND pa.assignment_type = 'E'
9252 AND pa.business_group_id = l_business_group_id
9253 -- AND pa.effective_end_date >= l_enc_begin_date -- Commenting this in the fix 12769510 as it is found to be commented in 11i code
9254 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
9255 AND pa.effective_end_date >= (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pa.assignment_id,pa.business_group_id,pa.payroll_id) --13566809
9256 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9257 ),l_enc_begin_date))
9258 AND NOT EXISTS (SELECT pepa.assignment_id
9259 FROM psp_enc_payroll_assignments pepa,
9260 psp_enc_payrolls pep
9261 WHERE pepa.enc_payroll_id = pep.enc_payroll_id
9262 AND pepa.business_group_id = l_business_group_id
9263 AND pepa.set_of_books_id = l_set_of_books_id
9264 AND pepa.business_group_id = pep.business_group_id
9265 AND pepa.set_of_books_id = pep.set_of_books_id
9266 AND pep.payroll_id = p_payroll_id
9267 AND pepa.assignment_id = pa.assignment_id)
9268 AND EXISTS (SELECT 1
9269 FROM psp_enc_summary_lines pesl
9270 WHERE pesl.assignment_id = pa.assignment_id
9271 AND pesl.status_code = 'A'
9272 AND pesl.payroll_id = p_payroll_id)
9273 AND NOT EXISTS (SELECT 1
9274 FROM psp_enc_summary_lines pesl
9275 WHERE pesl.assignment_id = pa.assignment_id
9276 AND pesl.status_code = 'N'
9277 AND pesl.payroll_id = p_payroll_id);
9278 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '40 Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
9279 END IF;
9280
9281 INSERT INTO psp_enc_changed_assignments
9282 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
9283 SELECT DISTINCT l_request_id, p_payroll_id, assignment_id, 'LQ', p_payroll_action_id
9284 FROM psp_enc_summary_lines pesl
9285 WHERE payroll_id = p_payroll_id
9286 AND business_group_id = l_business_group_id
9287 AND status_code = 'A'
9288 -- AND effective_date <= l_enc_begin_date -- Commenting this in the fix 12769510 as it is found to be commented in 11i code
9289 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
9290 AND pesl.effective_date <= (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pesl.assignment_id,pesl.business_group_id,pesl.payroll_id) --13566809
9291 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9292 ),l_enc_begin_date))
9293 AND NOT EXISTS (SELECT 1
9294 FROM psp_enc_changed_assignments peca
9295 WHERE peca.assignment_id = pesl.assignment_id
9296 AND peca.payroll_id = p_payroll_id)
9297 AND NOT EXISTS (SELECT /*+INDEX(pesl2 PSP_ENC_SUMMARY_LINES_N6)*/ 1
9298 FROM psp_enc_summary_lines pesl2
9299 WHERE pesl2.assignment_id = pesl.assignment_id
9300 AND pesl2.status_code = 'N'
9301 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
9302 AND pesl2.effective_date <= (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pesl2.assignment_id,pesl2.business_group_id,pesl2.payroll_id) --13566809
9303 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9304 ),l_enc_begin_date))
9305 AND pesl2.payroll_id = p_payroll_id);
9306 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '50 Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
9307
9308 ELSE -- NOn-Oracle Payroll profile is set to YES (For Stanford type of customers)
9309 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Using Non-Oracle Payroll');
9310
9311 g_payroll_mode := 'N'; --this helps to choose the query for non oracle payroll in get_asg_pay_end_date function --13566809
9312
9313 IF l_inc_exc_flag = 'Y' THEN
9314
9315 INSERT INTO psp_enc_changed_assignments
9316 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
9317 SELECT DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'CR', p_payroll_action_id
9318 FROM per_assignments_f pa
9319 WHERE pa.payroll_id = p_payroll_id
9320 AND pa.assignment_type = 'E'
9321 AND pa.business_group_id = l_business_group_id
9322 -- AND pa.effective_end_date >= l_enc_begin_date
9323 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
9324 AND pa.effective_end_date >= (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pa.assignment_id,pa.business_group_id,pa.payroll_id) --13566809
9325 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9326 ),l_enc_begin_date))
9327 AND NOT EXISTS (SELECT pepa.assignment_id
9328 FROM psp_enc_payroll_assignments pepa,
9329 psp_enc_payrolls pep
9330 WHERE pepa.enc_payroll_id = pep.enc_payroll_id
9331 AND pepa.business_group_id = l_business_group_id
9332 AND pepa.set_of_books_id = l_set_of_books_id
9333 AND pepa.business_group_id = pep.business_group_id
9334 AND pepa.set_of_books_id = pep.set_of_books_id
9335 AND pep.payroll_id = p_payroll_id
9336 AND pepa.assignment_id = pa.assignment_id)
9337 AND NOT EXISTS (SELECT 1
9338 FROM psp_enc_changed_assignments peca
9339 WHERE peca.assignment_id = pa.assignment_id
9340 AND peca.payroll_id = p_payroll_id)
9341 AND NOT EXISTS (SELECT 1
9342 FROM psp_enc_summary_lines pesl
9343 WHERE pesl.assignment_id = pa.assignment_id
9344 AND pesl.status_code IN ('A', 'N')
9345 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
9346 AND pesl.effective_date > (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pesl.assignment_id,pesl.business_group_id,pesl.payroll_id) --13566809
9347 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9348 ),l_enc_begin_date)) --13566809
9349 AND pesl.payroll_id = p_payroll_id);
9350
9351 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '10-A Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
9352
9353 -- Added this INSERT for bug 7188209
9354
9355 INSERT INTO psp_enc_changed_assignments
9356 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
9357 SELECT DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'CR', p_payroll_action_id
9358 FROM per_assignments_f pa
9359 WHERE pa.payroll_id = p_payroll_id
9360 AND pa.assignment_type = 'E'
9361 AND pa.business_group_id = l_business_group_id
9362 AND pa.effective_end_date >= (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pa.assignment_id,pa.business_group_id,pa.payroll_id) --13566809
9363 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9364 ),l_enc_begin_date))
9365 AND NOT EXISTS (SELECT pepa.assignment_id
9366 FROM psp_enc_payroll_assignments pepa,
9367 psp_enc_payrolls pep
9368 WHERE pepa.enc_payroll_id = pep.enc_payroll_id
9369 AND pepa.business_group_id = l_business_group_id
9370 AND pepa.set_of_books_id = l_set_of_books_id
9371 AND pepa.business_group_id = pep.business_group_id
9372 AND pepa.set_of_books_id = pep.set_of_books_id
9373 AND pep.payroll_id = p_payroll_id
9374 AND pepa.assignment_id = pa.assignment_id)
9375 AND NOT EXISTS (SELECT 1
9376 FROM psp_enc_changed_assignments peca
9377 WHERE peca.assignment_id = pa.assignment_id
9378 AND peca.payroll_id = p_payroll_id)
9379 AND NOT EXISTS (SELECT 1
9380 FROM psp_enc_summary_lines pesl
9381 WHERE pesl.assignment_id = pa.assignment_id
9382 AND pesl.status_code IN ('A', 'N')
9383 AND pesl.effective_date > l_prev_enc_end_date
9384 AND pesl.payroll_id = p_payroll_id);
9385
9386 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '10-B Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
9387
9388 INSERT INTO psp_enc_changed_assignments
9389 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
9390 SELECT DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'ZZ', p_payroll_action_id
9391 FROM per_assignments_f pa
9392 WHERE pa.payroll_id = p_payroll_id
9393 AND pa.assignment_type = 'E'
9394 AND pa.business_group_id = l_business_group_id
9395 -- AND pa.effective_end_date >= l_enc_begin_date -- Commenting this in the fix 12769510 as it is found to be commented in 11i code
9396 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
9397 AND pa.effective_end_date >= (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pa.assignment_id,pa.business_group_id,pa.payroll_id) --13566809
9398 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9399 ),l_enc_begin_date))
9400 AND EXISTS (SELECT pepa.assignment_id
9401 FROM psp_enc_payroll_assignments pepa,
9402 psp_enc_payrolls pep
9403 WHERE pepa.enc_payroll_id = pep.enc_payroll_id
9404 AND pepa.business_group_id = l_business_group_id
9405 AND pepa.set_of_books_id = l_set_of_books_id
9406 AND pepa.business_group_id = pep.business_group_id
9407 AND pepa.set_of_books_id = pep.set_of_books_id
9408 AND pep.payroll_id = p_payroll_id
9409 AND pepa.assignment_id = pa.assignment_id)
9410 AND EXISTS (SELECT 1
9411 FROM psp_enc_summary_lines pesl
9412 WHERE pesl.assignment_id = pa.assignment_id
9413 AND pesl.status_code = 'A'
9414 AND pesl.payroll_id = p_payroll_id)
9415 AND NOT EXISTS (SELECT 1
9416 FROM psp_enc_summary_lines pesl
9417 WHERE pesl.assignment_id = pa.assignment_id
9418 AND pesl.status_code = 'N'
9419 AND pesl.payroll_id = p_payroll_id);
9420
9421 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '20 Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
9422
9423 ELSE
9424 -- Modified the following statement for bug 9862281
9425 INSERT INTO psp_enc_changed_assignments
9426 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
9427 SELECT /*+
9428 index(Pepa PSP_ENC_PAYROLL_ASSIGNMENTS_N1)
9429 index(PA PER_ASSIGNMENTS_F_PK)
9430 INDEX(pep PSP_ENC_PAYROLLS_N1) */
9431 DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'CR', p_payroll_action_id
9432 FROM psp_enc_payrolls pep,
9433 psp_enc_payroll_assignments pepa,
9434 per_assignments_f pa
9435 WHERE pa.payroll_id = p_payroll_id
9436 AND pepa.business_group_id = l_business_group_id
9437 AND pepa.set_of_books_id = l_set_of_books_id
9438 AND pepa.assignment_id = pa.assignment_id
9439 -- AND pa.effective_end_date >= l_enc_begin_date -- Commenting this in the fix 12769510 as it is found to be commented in 11i code
9440 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
9441 AND pa.effective_end_date >= (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pa.assignment_id,pa.business_group_id,pa.payroll_id) --13566809
9442 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9443 ),l_enc_begin_date))
9444 AND pep.payroll_id = p_payroll_id
9445 AND pep.enc_payroll_id = pepa.enc_payroll_id
9446 AND NOT EXISTS (SELECT 1
9447 FROM psp_enc_changed_assignments peca
9448 WHERE peca.assignment_id = pepa.assignment_id
9449 AND peca.payroll_id = p_payroll_id)
9450 AND NOT EXISTS (SELECT 1
9451 FROM psp_enc_summary_lines pesl
9452 WHERE pesl.assignment_id = pa.assignment_id
9453 AND pesl.payroll_id = pa.payroll_id -- Added for bug 9862281
9454 AND pesl.status_code IN ('A', 'N')
9455 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
9456 AND pesl.effective_date > (NVL((SELECT /*+
9457 INDEX(ppa PAY_PAYROLL_ACTIONS_N51)
9458 INDEX(ptp PER_TIME_PERIODS_N50)
9459 INDEX(paa PAY_ASSIGNMENT_ACTIONS_N4) */
9460 Max(ptp.end_date)
9461 FROM pay_payroll_actions ppa,
9462 per_time_periods ptp,
9463 pay_assignment_actions paa
9464 WHERE paa.assignment_id(+) = pesl.assignment_id
9465 AND ppa.payroll_action_id = paa.payroll_action_id (+)
9466 -- AND ppa.time_period_id = ptp.time_period_id -- Commented for the Bug 12647364
9467 AND ppa.business_group_id = pesl.business_group_id
9468 AND ppa.payroll_id = pesl.payroll_id
9469 AND ppa.action_type IN ( 'R','Q')
9470 AND paa.action_status = 'C' -- Bug: 12769510 -- added the following two conditions as
9471 -- they are existing in 11i code and are related to the fix 6122540
9472 and ppa.date_earned between ptp.start_date and ptp.end_date
9473 and ptp.payroll_id = ppa.payroll_id),l_enc_begin_date)) );
9474
9475
9476
9477 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '30-A Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
9478
9479 -- Added for bug 7188209
9480 INSERT INTO psp_enc_changed_assignments
9481 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
9482 SELECT DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'CR', p_payroll_action_id
9483 FROM psp_enc_payroll_assignments pepa,
9484 psp_enc_payrolls pep,
9485 per_assignments_f pa
9486 WHERE pa.payroll_id = p_payroll_id
9487 AND pepa.business_group_id = l_business_group_id
9488 AND pepa.set_of_books_id = l_set_of_books_id
9489 AND pepa.assignment_id = pa.assignment_id
9490 AND pa.effective_end_date >= (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pa.assignment_id,pa.business_group_id,pa.payroll_id) --13566809
9491 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9492 ),l_enc_begin_date))
9493 AND pep.payroll_id = p_payroll_id
9494 AND pep.enc_payroll_id = pepa.enc_payroll_id
9495 AND NOT EXISTS (SELECT 1
9496 FROM psp_enc_changed_assignments peca
9497 WHERE peca.assignment_id = pepa.assignment_id
9498 AND peca.payroll_id = p_payroll_id)
9499 AND NOT EXISTS (SELECT 1
9500 FROM psp_enc_summary_lines pesl
9501 WHERE pesl.assignment_id = pa.assignment_id
9502 AND pesl.status_code IN ('A', 'N')
9503 AND pesl.effective_date > l_prev_enc_end_date);
9504
9505 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '30-B Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
9506
9507 INSERT INTO psp_enc_changed_assignments
9508 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
9509 SELECT DISTINCT l_request_id, p_payroll_id, pa.assignment_id, 'ZZ', p_payroll_action_id
9510 FROM per_assignments_f pa
9511 WHERE pa.payroll_id = p_payroll_id
9512 AND pa.assignment_type = 'E'
9513 AND pa.business_group_id = l_business_group_id
9514 -- AND pa.effective_end_date >= l_enc_begin_date -- Commenting this in the fix 12769510 as it is found to be commented in 11i code
9515 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
9516 AND pa.effective_end_date >= (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pa.assignment_id,pa.business_group_id,pa.payroll_id) --13566809
9517 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9518 ),l_enc_begin_date))
9519 AND NOT EXISTS (SELECT pepa.assignment_id
9520 FROM psp_enc_payroll_assignments pepa,
9521 psp_enc_payrolls pep
9522 WHERE pepa.enc_payroll_id = pep.enc_payroll_id
9523 AND pepa.business_group_id = l_business_group_id
9524 AND pepa.set_of_books_id = l_set_of_books_id
9525 AND pepa.business_group_id = pep.business_group_id
9526 AND pepa.set_of_books_id = pep.set_of_books_id
9527 AND pep.payroll_id = p_payroll_id
9528 AND pepa.assignment_id = pa.assignment_id)
9529 AND EXISTS (SELECT 1
9530 FROM psp_enc_summary_lines pesl
9531 WHERE pesl.assignment_id = pa.assignment_id
9532 AND pesl.status_code = 'A'
9533 AND pesl.payroll_id = p_payroll_id)
9534 AND NOT EXISTS (SELECT 1
9535 FROM psp_enc_summary_lines pesl
9536 WHERE pesl.assignment_id = pa.assignment_id
9537 AND pesl.status_code = 'N'
9538 AND pesl.payroll_id = p_payroll_id);
9539 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '40 Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
9540 END IF;
9541
9542 INSERT INTO psp_enc_changed_assignments
9543 (request_id, payroll_id, assignment_id, change_type, payroll_action_id)
9544 SELECT DISTINCT l_request_id, p_payroll_id, assignment_id, 'LQ', p_payroll_action_id
9545 FROM psp_enc_summary_lines pesl
9546 WHERE payroll_id = p_payroll_id
9547 AND business_group_id = l_business_group_id
9548 AND status_code = 'A'
9549 -- AND effective_date <= l_enc_begin_date -- Commenting this in the fix 12769510 as it is found to be commented in 11i code
9550 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
9551 AND pesl.effective_date <= (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pesl.assignment_id,pesl.business_group_id,pesl.payroll_id) --13566809
9552 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9553 ),l_enc_begin_date))
9554 AND NOT EXISTS (SELECT 1
9555 FROM psp_enc_changed_assignments peca
9556 WHERE peca.assignment_id = pesl.assignment_id
9557 AND peca.payroll_id = p_payroll_id)
9558 AND NOT EXISTS (SELECT /*+INDEX(pesl2 PSP_ENC_SUMMARY_LINES_N6)*/ 1
9559 FROM psp_enc_summary_lines pesl2
9560 WHERE pesl2.assignment_id = pesl.assignment_id
9561 AND pesl2.status_code = 'N'
9562 -- Bug 5642002: Replaced last Payroll Process date with last assignment Process date
9563 AND pesl2.effective_date <= (NVL((get_asg_pay_end_date(g_payroll_mode,p_payroll_action_id,pesl2.assignment_id,pesl2.business_group_id,pesl2.payroll_id)--13566809
9564 -- AND ptp.time_period_id = ppa.time_period_id -- Added for bug 9862281 -- Commented for the Bug 12647364
9565 ),l_enc_begin_date))
9566 AND pesl2.payroll_id = p_payroll_id);
9567 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || '50 Inserted ' || SQL%ROWCOUNT || ' assignments into psp_enc_changed_assignments');
9568
9569 END IF; -- End of Oracle Payroll Profile
9570
9571 UPDATE psp_enc_changed_assignments peca
9572 SET payroll_action_id = p_payroll_action_id
9573 WHERE payroll_action_id IS NULL
9574 AND payroll_id = NVL(p_payroll_id, payroll_id)
9575 AND NOT EXISTS (SELECT 1
9576 FROM psp_enc_process_assignments pepa
9577 WHERE pepa.assignment_id = peca.assignment_id
9578 AND pepa.assignment_status NOT IN ('B', 'P')
9579 AND pepa.payroll_id = peca.payroll_id);
9580 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');
9581
9582 /*
9583 DELETE FROM psp_enc_changed_assignments
9584 WHERE payroll_action_id = p_payroll_action_id
9585 AND payroll_id = p_payroll_id
9586 AND request_id = l_request_id
9587 and assignment_id IN(SELECT assignment_id from PSP_ENC_PAYROLL_ASSIGNMENT_V
9588 WHERE payroll_id = p_payroll_id
9589 AND exclude = 'Y'
9590 MINUS
9591 SELECT ASSIGNMENT_ID FROM psp_enc_changed_asg_history
9592 WHERE payroll_id = p_payroll_id);
9593 */
9594 -- Modified the delete statement for bug 9862281
9595 BEGIN
9596 OPEN exc_asg_cur(p_payroll_id, l_business_group_id, p_payroll_action_id, l_request_id);
9597
9598 FETCH exc_asg_cur BULK COLLECT INTO asg_id_tab;
9599 asg_id_tab := SET(asg_id_tab);
9600
9601 FOR rec_i IN 1..asg_id_tab.COUNT LOOP
9602 fnd_file.put_line(fnd_file.log,fnd_date.date_to_canonical(SYSDATE) || ' Excluded asg ' ||asg_id_tab(rec_i));
9603
9604 l_asg_exists := 0;
9605
9606 BEGIN
9607 SELECT /*+ FIRST_ROWS(1) */ 1
9608 INTO l_asg_exists
9609 FROM psp_enc_changed_asg_history
9610 WHERE assignment_id = asg_id_tab(rec_i)
9611 AND payroll_id = p_payroll_id
9612 AND ROWNUM < 2;
9613 EXCEPTION
9614 WHEN no_data_found THEN
9615
9616 DELETE FROM psp_enc_changed_assignments
9617 WHERE payroll_action_id = p_payroll_action_id
9618 AND payroll_id = p_payroll_id
9619 AND request_id = l_request_id
9620 and assignment_id = asg_id_tab(rec_i);
9621 fnd_file.put_line(fnd_file.log,fnd_date.date_to_canonical(SYSDATE) || ' Deleted asg ' ||asg_id_tab(rec_i));
9622 END;
9623 END LOOP;
9624
9625 CLOSE exc_asg_cur;
9626 END;
9627 -- Modified the delete statement for bug 9862281 end
9628 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Deleted new excluded assignments in psp_enc_changed_assignments not to be processed by this Create and Update process');
9629
9630 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' opening in_process_asg_cur fpr payroll_id: '||p_payroll_id);
9631
9632
9633 OPEN in_process_asg_cur;
9634 LOOP
9635 FETCH in_process_asg_cur INTO l_assignment_id, l_payroll_action_id;
9636 EXIT WHEN in_process_asg_cur%NOTFOUND;
9637
9638 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_assignment_id: '||l_assignment_id ||' l_payroll_action_id: '|| l_payroll_action_id);
9639
9640 OPEN process_descr_cur;
9641 FETCH process_descr_cur INTO l_process_description;
9642 CLOSE process_descr_cur;
9643
9644 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_process_description: '||l_process_description);
9645
9646 fnd_message.set_name('PSP', 'PSP_ENC_ASG_IN_PROCESS');
9647 fnd_message.set_token('PROCESS_DESCRIPTION', l_process_description);
9648 g_warning_message := fnd_message.get;
9649
9650 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' g_warning_message: '||g_warning_message);
9651
9652 OPEN asg_number_cur (l_enc_begin_date);
9653 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
9654 CLOSE asg_number_cur;
9655
9656 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_assignment_number: '|| l_assignment_number|| ' l_person_id: '||l_person_id|| ' l_organization_id: '||l_organization_id);
9657
9658 OPEN payroll_name_cur;
9659 FETCH payroll_name_cur INTO l_payroll_name;
9660 CLOSE payroll_name_cur;
9661
9662 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_payroll_name: '||l_payroll_name);
9663
9664 OPEN person_name_cur (l_enc_begin_date);
9665 FETCH person_name_cur INTO l_full_name;
9666 CLOSE person_name_cur;
9667
9668 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_full_name: '||l_full_name);
9669
9670 OPEN org_name_cur;
9671 FETCH org_name_cur INTO l_organization_name;
9672 CLOSE org_name_cur;
9673 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_organization_name: '||l_organization_name);
9674
9675
9676 psp_general.add_report_error
9677 (p_request_id => l_request_id,
9678 p_message_level => 'N',
9679 p_source_id => l_assignment_id,
9680 p_source_name => l_assignment_number,
9681 p_parent_source_id => l_person_id,
9682 p_parent_source_name => l_full_name,
9683 p_error_message => g_warning_message,
9684 p_payroll_action_id => p_payroll_action_id,
9685 p_value1 => p_payroll_id,
9686 p_information1 => l_payroll_name,
9687 p_value2 => l_organization_id,
9688 p_information2 => l_organization_name,
9689 p_return_status => l_return_status);
9690 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' l_return_status: '||l_return_status);
9691
9692 END LOOP;
9693 CLOSE in_process_asg_cur;
9694 ELSE
9695 OPEN action_parameters_cur;
9696 FETCH action_parameters_cur INTO l_person_id1, l_termination_date1,
9697 l_person_id2, l_termination_date2, l_person_id3, l_termination_date3,
9698 l_person_id4, l_termination_date4, l_person_id5, l_termination_date5;
9699 CLOSE action_parameters_cur;
9700 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) || '
9701 l_person_id2: ' || l_person_id2 || ' l_termination_date2: ' || fnd_date.date_to_canonical(l_termination_date2) || '
9702 l_person_id3: ' || l_person_id3 || ' l_termination_date3: ' || fnd_date.date_to_canonical(l_termination_date3) || '
9703 l_person_id4: ' || l_person_id4 || ' l_termination_date4: ' || fnd_date.date_to_canonical(l_termination_date4) || '
9704 l_person_id5: ' || l_person_id5 || ' l_termination_date5: ' || fnd_date.date_to_canonical(l_termination_date5));
9705
9706 INSERT INTO PSP_ENC_CHANGED_ASSIGNMENTS
9707 (request_id, assignment_id, payroll_id, change_type, payroll_action_id, change_date)
9708 SELECT DISTINCT l_request_id,
9709 pesl.assignment_id,
9710 pesl.payroll_id,
9711 'TR',
9712 p_payroll_action_id,
9713 l_termination_date1
9714 FROM psp_enc_summary_lines pesl
9715 WHERE pesl.person_id = l_person_id1
9716 AND pesl.effective_date >= l_termination_date1
9717 AND ( gl_code_combination_id IS NOT NULL
9718 OR award_id IS NOT NULL)
9719 AND pesl.status_code = 'A'
9720 AND NOT EXISTS (SELECT 1
9721 FROM psp_enc_summary_lines pesl2
9722 WHERE pesl2.person_id = l_person_id1
9723 AND pesl2.status_code = 'N');
9724 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Inserted termination assignments into psp_enc_changed_assignments ' || SQL%ROWCOUNT);
9725 IF (SQL%ROWCOUNT = 0) THEN
9726 OPEN in_process_term_cur(l_person_id1);
9727 LOOP
9728 FETCH in_process_term_cur INTO l_assignment_id, l_payroll_id, l_payroll_action_id;
9729 EXIT WHEN in_process_term_cur%NOTFOUND;
9730
9731 OPEN process_descr_cur;
9732 FETCH process_descr_cur INTO l_process_description;
9733 CLOSE process_descr_cur;
9734
9735 fnd_message.set_name('PSP', 'PSP_ENC_ASG_IN_PROCESS');
9736 fnd_message.set_token('PROCESS_DESCRIPTION', l_process_description);
9737 g_warning_message := fnd_message.get;
9738
9739 OPEN asg_number_cur (l_termination_date1);
9740 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
9741 CLOSE asg_number_cur;
9742
9743 OPEN payroll_name_cur;
9744 FETCH payroll_name_cur INTO l_payroll_name;
9745 CLOSE payroll_name_cur;
9746
9747 OPEN person_name_cur (l_termination_date1);
9748 FETCH person_name_cur INTO l_full_name;
9749 CLOSE person_name_cur;
9750
9751 OPEN org_name_cur;
9752 FETCH org_name_cur INTO l_organization_name;
9753 CLOSE org_name_cur;
9754
9755 psp_general.add_report_error
9756 (p_request_id => l_request_id,
9757 p_message_level => 'N',
9758 p_source_id => l_assignment_id,
9759 p_source_name => l_assignment_number,
9760 p_parent_source_id => l_person_id,
9761 p_parent_source_name => l_full_name,
9762 p_error_message => g_warning_message,
9763 p_payroll_action_id => p_payroll_action_id,
9764 p_value1 => l_payroll_id,
9765 p_information1 => l_payroll_name,
9766 p_value2 => l_organization_id,
9767 p_information2 => l_organization_name,
9768 p_return_status => l_return_status);
9769 END LOOP;
9770 CLOSE in_process_term_cur;
9771 END IF;
9772
9773 IF (l_person_id2 > 0) THEN
9774 INSERT INTO PSP_ENC_CHANGED_ASSIGNMENTS
9775 (request_id, assignment_id, payroll_id, change_type, payroll_action_id, change_date)
9776 SELECT DISTINCT l_request_id,
9777 pesl.assignment_id,
9778 pesl.payroll_id,
9779 'TR',
9780 p_payroll_action_id,
9781 l_termination_date2
9782 FROM psp_enc_summary_lines pesl
9783 WHERE pesl.person_id = l_person_id2
9784 AND pesl.effective_date >= l_termination_date2
9785 AND ( gl_code_combination_id IS NOT NULL
9786 OR award_id IS NOT NULL)
9787 AND pesl.status_code = 'A'
9788 AND NOT EXISTS (SELECT 1
9789 FROM psp_enc_summary_lines pesl2
9790 WHERE pesl2.person_id = l_person_id2
9791 AND pesl2.status_code = 'N');
9792 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Inserted termination assignments into psp_enc_changed_assignments ' || SQL%ROWCOUNT);
9793 IF (SQL%ROWCOUNT = 0) THEN
9794 OPEN in_process_term_cur(l_person_id2);
9795 LOOP
9796 FETCH in_process_term_cur INTO l_assignment_id, l_payroll_id, l_payroll_action_id;
9797 EXIT WHEN in_process_term_cur%NOTFOUND;
9798
9799 OPEN process_descr_cur;
9800 FETCH process_descr_cur INTO l_process_description;
9801 CLOSE process_descr_cur;
9802
9803 fnd_message.set_name('PSP', 'PSP_ENC_ASG_IN_PROCESS');
9804 fnd_message.set_token('PROCESS_DESCRIPTION', l_process_description);
9805 g_warning_message := fnd_message.get;
9806
9807 OPEN asg_number_cur (l_termination_date2);
9808 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
9809 CLOSE asg_number_cur;
9810
9811 OPEN payroll_name_cur;
9812 FETCH payroll_name_cur INTO l_payroll_name;
9813 CLOSE payroll_name_cur;
9814
9815 OPEN person_name_cur (l_termination_date2);
9816 FETCH person_name_cur INTO l_full_name;
9817 CLOSE person_name_cur;
9818
9819 OPEN org_name_cur;
9820 FETCH org_name_cur INTO l_organization_name;
9821 CLOSE org_name_cur;
9822
9823 psp_general.add_report_error
9824 (p_request_id => l_request_id,
9825 p_message_level => 'N',
9826 p_source_id => l_assignment_id,
9827 p_source_name => l_assignment_number,
9828 p_parent_source_id => l_person_id,
9829 p_parent_source_name => l_full_name,
9830 p_error_message => g_warning_message,
9831 p_payroll_action_id => p_payroll_action_id,
9832 p_value1 => l_payroll_id,
9833 p_information1 => l_payroll_name,
9834 p_value2 => l_organization_id,
9835 p_information2 => l_organization_name,
9836 p_return_status => l_return_status);
9837 END LOOP;
9838 CLOSE in_process_term_cur;
9839 END IF;
9840 END IF;
9841
9842 IF (l_person_id3 > 0) THEN
9843 INSERT INTO PSP_ENC_CHANGED_ASSIGNMENTS
9844 (request_id, assignment_id, payroll_id, change_type, payroll_action_id, change_date)
9845 SELECT DISTINCT l_request_id,
9846 pesl.assignment_id,
9847 pesl.payroll_id,
9848 'TR',
9849 p_payroll_action_id,
9850 l_termination_date3
9851 FROM psp_enc_summary_lines pesl
9852 WHERE pesl.person_id = l_person_id3
9853 AND pesl.effective_date >= l_termination_date3
9854 AND ( gl_code_combination_id IS NOT NULL
9855 OR award_id IS NOT NULL)
9856 AND pesl.status_code = 'A'
9857 AND NOT EXISTS (SELECT 1
9858 FROM psp_enc_summary_lines pesl2
9859 WHERE pesl2.person_id = l_person_id3
9860 AND pesl2.status_code = 'N');
9861 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Inserted termination assignments into psp_enc_changed_assignments ' || SQL%ROWCOUNT);
9862 IF (SQL%ROWCOUNT = 0) THEN
9863 OPEN in_process_term_cur(l_person_id3);
9864 LOOP
9865 FETCH in_process_term_cur INTO l_assignment_id, l_payroll_id, l_payroll_action_id;
9866 EXIT WHEN in_process_term_cur%NOTFOUND;
9867
9868 OPEN process_descr_cur;
9869 FETCH process_descr_cur INTO l_process_description;
9870 CLOSE process_descr_cur;
9871
9872 fnd_message.set_name('PSP', 'PSP_ENC_ASG_IN_PROCESS');
9873 fnd_message.set_token('PROCESS_DESCRIPTION', l_process_description);
9874 g_warning_message := fnd_message.get;
9875
9876 OPEN asg_number_cur (l_termination_date3);
9877 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
9878 CLOSE asg_number_cur;
9879
9880 OPEN payroll_name_cur;
9881 FETCH payroll_name_cur INTO l_payroll_name;
9882 CLOSE payroll_name_cur;
9883
9884 OPEN person_name_cur (l_termination_date3);
9885 FETCH person_name_cur INTO l_full_name;
9886 CLOSE person_name_cur;
9887
9888 OPEN org_name_cur;
9889 FETCH org_name_cur INTO l_organization_name;
9890 CLOSE org_name_cur;
9891
9892 psp_general.add_report_error
9893 (p_request_id => l_request_id,
9894 p_message_level => 'N',
9895 p_source_id => l_assignment_id,
9896 p_source_name => l_assignment_number,
9897 p_parent_source_id => l_person_id,
9898 p_parent_source_name => l_full_name,
9899 p_error_message => g_warning_message,
9900 p_payroll_action_id => p_payroll_action_id,
9901 p_value1 => l_payroll_id,
9902 p_information1 => l_payroll_name,
9903 p_value2 => l_organization_id,
9904 p_information2 => l_organization_name,
9905 p_return_status => l_return_status);
9906 END LOOP;
9907 CLOSE in_process_term_cur;
9908 END IF;
9909 END IF;
9910
9911 IF (l_person_id4 > 0) THEN
9912 INSERT INTO PSP_ENC_CHANGED_ASSIGNMENTS
9913 (request_id, assignment_id, payroll_id, change_type, payroll_action_id, change_date)
9914 SELECT DISTINCT l_request_id,
9915 pesl.assignment_id,
9916 pesl.payroll_id,
9917 'TR',
9918 p_payroll_action_id,
9919 l_termination_date4
9920 FROM psp_enc_summary_lines pesl
9921 WHERE pesl.person_id = l_person_id4
9922 AND pesl.effective_date >= l_termination_date4
9923 AND ( gl_code_combination_id IS NOT NULL
9924 OR award_id IS NOT NULL)
9925 AND pesl.status_code = 'A'
9926 AND NOT EXISTS (SELECT 1
9927 FROM psp_enc_summary_lines pesl2
9928 WHERE pesl2.person_id = l_person_id4
9929 AND pesl2.status_code = 'N');
9930 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Inserted termination assignments into psp_enc_changed_assignments ' || SQL%ROWCOUNT);
9931 IF (SQL%ROWCOUNT = 0) THEN
9932 OPEN in_process_term_cur(l_person_id4);
9933 LOOP
9934 FETCH in_process_term_cur INTO l_assignment_id, l_payroll_id, l_payroll_action_id;
9935 EXIT WHEN in_process_term_cur%NOTFOUND;
9936
9937 OPEN process_descr_cur;
9938 FETCH process_descr_cur INTO l_process_description;
9939 CLOSE process_descr_cur;
9940
9941 fnd_message.set_name('PSP', 'PSP_ENC_ASG_IN_PROCESS');
9942 fnd_message.set_token('PROCESS_DESCRIPTION', l_process_description);
9943 g_warning_message := fnd_message.get;
9944
9945 OPEN asg_number_cur (l_termination_date4);
9946 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
9947 CLOSE asg_number_cur;
9948
9949 OPEN payroll_name_cur;
9950 FETCH payroll_name_cur INTO l_payroll_name;
9951 CLOSE payroll_name_cur;
9952
9953 OPEN person_name_cur (l_termination_date4);
9954 FETCH person_name_cur INTO l_full_name;
9955 CLOSE person_name_cur;
9956
9957 OPEN org_name_cur;
9958 FETCH org_name_cur INTO l_organization_name;
9959 CLOSE org_name_cur;
9960
9961 psp_general.add_report_error
9962 (p_request_id => l_request_id,
9963 p_message_level => 'N',
9964 p_source_id => l_assignment_id,
9965 p_source_name => l_assignment_number,
9966 p_parent_source_id => l_person_id,
9967 p_parent_source_name => l_full_name,
9968 p_error_message => g_warning_message,
9969 p_payroll_action_id => p_payroll_action_id,
9970 p_value1 => l_payroll_id,
9971 p_information1 => l_payroll_name,
9972 p_value2 => l_organization_id,
9973 p_information2 => l_organization_name,
9974 p_return_status => l_return_status);
9975 END LOOP;
9976 CLOSE in_process_term_cur;
9977 END IF;
9978 END IF;
9979
9980 IF (l_person_id5 > 0) THEN
9981 INSERT INTO PSP_ENC_CHANGED_ASSIGNMENTS
9982 (request_id, assignment_id, payroll_id, change_type, payroll_action_id, change_date)
9983 SELECT DISTINCT l_request_id,
9984 pesl.assignment_id,
9985 pesl.payroll_id,
9986 'TR',
9987 p_payroll_action_id,
9988 l_termination_date5
9989 FROM psp_enc_summary_lines pesl
9990 WHERE pesl.person_id = l_person_id5
9991 AND pesl.effective_date >= l_termination_date5
9992 AND ( gl_code_combination_id IS NOT NULL
9993 OR award_id IS NOT NULL)
9994 AND pesl.status_code = 'A'
9995 AND NOT EXISTS (SELECT 1
9996 FROM psp_enc_summary_lines pesl2
9997 WHERE pesl2.person_id = l_person_id5
9998 AND pesl2.status_code = 'N');
9999 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Inserted termination assignments into psp_enc_changed_assignments ' || SQL%ROWCOUNT);
10000 IF (SQL%ROWCOUNT = 0) THEN
10001 OPEN in_process_term_cur(l_person_id5);
10002 LOOP
10003 FETCH in_process_term_cur INTO l_assignment_id, l_payroll_id, l_payroll_action_id;
10004 EXIT WHEN in_process_term_cur%NOTFOUND;
10005
10006 OPEN process_descr_cur;
10007 FETCH process_descr_cur INTO l_process_description;
10008 CLOSE process_descr_cur;
10009
10010 fnd_message.set_name('PSP', 'PSP_ENC_ASG_IN_PROCESS');
10011 fnd_message.set_token('PROCESS_DESCRIPTION', l_process_description);
10012 g_warning_message := fnd_message.get;
10013
10014 OPEN asg_number_cur (l_termination_date5);
10015 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
10016 CLOSE asg_number_cur;
10017
10018 OPEN payroll_name_cur;
10019 FETCH payroll_name_cur INTO l_payroll_name;
10020 CLOSE payroll_name_cur;
10021
10022 OPEN person_name_cur (l_termination_date5);
10023 FETCH person_name_cur INTO l_full_name;
10024 CLOSE person_name_cur;
10025
10026 OPEN org_name_cur;
10027 FETCH org_name_cur INTO l_organization_name;
10028 CLOSE org_name_cur;
10029
10030 psp_general.add_report_error
10031 (p_request_id => l_request_id,
10032 p_message_level => 'N',
10033 p_source_id => l_assignment_id,
10034 p_source_name => l_assignment_number,
10035 p_parent_source_id => l_person_id,
10036 p_parent_source_name => l_full_name,
10037 p_error_message => g_warning_message,
10038 p_payroll_action_id => p_payroll_action_id,
10039 p_value1 => l_payroll_id,
10040 p_information1 => l_payroll_name,
10041 p_value2 => l_organization_id,
10042 p_information2 => l_organization_name,
10043 p_return_status => l_return_status);
10044 END LOOP;
10045 CLOSE in_process_term_cur;
10046 END IF;
10047 END IF;
10048 END IF;
10049
10050 COMMIT;
10051 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving ENC_PRE_PROCESS
10052 p_payroll_action_id: ' || p_payroll_action_id || '
10053 p_payroll_id: ' || p_payroll_id || '
10054 p_process_mode: ' || p_process_mode);
10055 p_return_status := fnd_api.g_ret_sts_success;
10056 EXCEPTION
10057 WHEN OTHERS THEN
10058 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
10059 IF (g_error_message IS NULL) THEN
10060 g_error_message := 'PSP_ENC_PROCESS: ' || SQLERRM;
10061 END IF;
10062 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'ENC_PRE_PROCESS: SQLCODE: ' || fnd_number.number_to_canonical(SQLCODE) || ' SQLERRM: ' || SQLERRM);
10063 psp_message_s.print_error(p_mode => FND_FILE.LOG, p_print_header => FND_API.G_TRUE);
10064 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving ENC_PRE_PROCESS
10065 p_payroll_action_id: ' || p_payroll_action_id || '
10066 p_payroll_id: ' || p_payroll_id || '
10067 p_process_mode: ' || p_process_mode);
10068 p_return_status := fnd_api.g_ret_sts_unexp_error;
10069 END enc_pre_process;
10070
10071 PROCEDURE rollback_cel (errbuf OUT NOCOPY VARCHAR2,
10072 retcode OUT NOCOPY VARCHAR2,
10073 p_payroll_action_id IN NUMBER,
10074 p_person_id1 IN NUMBER,
10075 p_assignment_id1 IN NUMBER,
10076 p_person_id2 IN NUMBER,
10077 p_assignment_id2 IN NUMBER,
10078 p_person_id3 IN NUMBER,
10079 p_assignment_id3 IN NUMBER,
10080 p_person_id4 IN NUMBER,
10081 p_assignment_id4 IN NUMBER,
10082 p_person_id5 IN NUMBER,
10083 p_assignment_id5 IN NUMBER) IS
10084 TYPE t_number_15 IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
10085 TYPE r_superceded_lines_rec IS RECORD
10086 (enc_summary_line_id t_number_15);
10087 t_superceded_lines r_superceded_lines_rec;
10088
10089 l_assignments t_number_15;
10090 l_assignments_tmp t_number_15;
10091
10092 l_assignment_id NUMBER(15);
10093 l_payroll_id NUMBER(15);
10094 l_asg_counter NUMBER(15);
10095
10096 CURSOR asg_cur (p_person_id IN NUMBER,
10097 p_assignment_id IN NUMBER) IS
10098 SELECT DISTINCT pepa.assignment_id
10099 FROM psp_enc_process_assignments pepa,
10100 per_all_assignments_f paf
10101 WHERE pepa.payroll_action_id = p_payroll_action_id
10102 AND paf.person_id = p_person_id
10103 AND paf.assignment_id = pepa.assignment_id
10104 AND ( p_assignment_id IS NULL
10105 OR pepa.assignment_id = p_assignment_id);
10106
10107 CURSOR superceded_line_cur (p_assignment_id IN NUMBER) IS
10108 SELECT superceded_line_id
10109 FROM psp_enc_summary_lines pesl
10110 WHERE pesl.payroll_action_id = p_payroll_action_id
10111 AND pesl.superceded_line_id IS NOT NULL
10112 AND assignment_id = p_assignment_id;
10113
10114 l_request_id NUMBER(15);
10115 BEGIN
10116 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Entering ROLLBACK_CEL p_payroll_action_id: ' || p_payroll_action_id);
10117 l_request_id := fnd_global.conc_request_id;
10118
10119 IF (p_person_id1 IS NULL) THEN
10120 OPEN superceded_line_cur(NULL);
10121 FETCH superceded_line_cur BULK COLLECT INTO t_superceded_lines.enc_summary_line_id;
10122 CLOSE superceded_line_cur;
10123
10124 FORALL recno IN 1..t_superceded_lines.enc_summary_line_id.COUNT
10125 UPDATE psp_enc_lines_history
10126 SET change_flag = 'N'
10127 WHERE enc_summary_line_id = t_superceded_lines.enc_summary_line_id(recno);
10128 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Reverted respective superceded lines in psp_enc_lines_history');
10129
10130 DELETE psp_enc_summary_lines
10131 WHERE payroll_action_id = p_payroll_action_id;
10132 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_summary_lines');
10133
10134 DELETE psp_enc_lines
10135 WHERE payroll_action_id = p_payroll_action_id;
10136 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_lines');
10137
10138 DELETE psp_enc_controls
10139 WHERE payroll_action_id = p_payroll_action_id;
10140 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_controls');
10141
10142 DELETE psp_report_errors
10143 WHERE payroll_action_id = p_payroll_action_id;
10144 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_report_errors');
10145
10146 UPDATE psp_enc_processes
10147 SET process_status = 'B',
10148 process_phase = 'rollback'
10149 WHERE payroll_action_id = p_payroll_action_id;
10150 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process status to ''Rollback'' in psp_enc_processes');
10151
10152 UPDATE psp_enc_process_assignments
10153 SET assignment_status = 'B'
10154 WHERE payroll_action_id = p_payroll_action_id;
10155 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process status to ''Rollback'' in psp_enc_process_assignments');
10156
10157 UPDATE psp_enc_changed_assignments
10158 SET payroll_action_id = NULL
10159 WHERE payroll_action_id = p_payroll_action_id;
10160 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated payroll_action_id in psp_enc_changed_assignments');
10161
10162 INSERT INTO psp_enc_changed_assignments
10163 (request_id, assignment_id, payroll_id, change_type,
10164 processed_flag, reference_id, action_type, change_date)
10165 SELECT l_request_id, pecah.assignment_id, pecah.payroll_id, pecah.change_type,
10166 NULL, NVL(pecah.reference_id, 0), pecah.action_type, change_date
10167 FROM psp_enc_changed_asg_history pecah
10168 WHERE payroll_action_id = p_payroll_action_id
10169 AND action_type NOT IN ('CR', 'LQ', 'TR');
10170 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Copied change assignment records to psp_enc_changed_assignments');
10171
10172 DELETE psp_enc_changed_asg_history
10173 WHERE payroll_action_id = p_payroll_action_id;
10174 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Copied change assignment records to psp_enc_changed_assignments');
10175 ELSE
10176 OPEN asg_cur(p_person_id1, p_assignment_id1);
10177 FETCH asg_cur BULK COLLECT INTO l_assignments;
10178 CLOSE asg_cur;
10179
10180 IF (p_person_id2 IS NOT NULL) THEN
10181 OPEN asg_cur(p_person_id2, p_assignment_id2);
10182 FETCH asg_cur BULK COLLECT INTO l_assignments_tmp;
10183 CLOSE asg_cur;
10184
10185 l_asg_counter := l_assignments.COUNT + 1;
10186 FOR recno IN 1..l_assignments_tmp.COUNT
10187 LOOP
10188 l_assignments(l_asg_counter) := l_assignments_tmp(recno);
10189 l_asg_counter := l_asg_counter + 1;
10190 END LOOP;
10191 l_assignments_tmp.DELETE;
10192 END IF;
10193
10194 IF (p_person_id3 IS NOT NULL) THEN
10195 OPEN asg_cur(p_person_id3, p_assignment_id3);
10196 FETCH asg_cur BULK COLLECT INTO l_assignments_tmp;
10197 CLOSE asg_cur;
10198
10199 l_asg_counter := l_assignments.COUNT + 1;
10200 FOR recno IN 1..l_assignments_tmp.COUNT
10201 LOOP
10202 l_assignments(l_asg_counter) := l_assignments_tmp(recno);
10203 l_asg_counter := l_asg_counter + 1;
10204 END LOOP;
10205 l_assignments_tmp.DELETE;
10206 END IF;
10207
10208 IF (p_person_id4 IS NOT NULL) THEN
10209 OPEN asg_cur(p_person_id4, p_assignment_id4);
10210 FETCH asg_cur BULK COLLECT INTO l_assignments_tmp;
10211 CLOSE asg_cur;
10212
10213 l_asg_counter := l_assignments.COUNT + 1;
10214 FOR recno IN 1..l_assignments_tmp.COUNT
10215 LOOP
10216 l_assignments(l_asg_counter) := l_assignments_tmp(recno);
10217 l_asg_counter := l_asg_counter + 1;
10218 END LOOP;
10219 l_assignments_tmp.DELETE;
10220 END IF;
10221
10222 IF (p_person_id5 IS NOT NULL) THEN
10223 OPEN asg_cur(p_person_id5, p_assignment_id5);
10224 FETCH asg_cur BULK COLLECT INTO l_assignments_tmp;
10225 CLOSE asg_cur;
10226
10227 l_asg_counter := l_assignments.COUNT + 1;
10228 FOR recno IN 1..l_assignments_tmp.COUNT
10229 LOOP
10230 l_assignments(l_asg_counter) := l_assignments_tmp(recno);
10231 l_asg_counter := l_asg_counter + 1;
10232 END LOOP;
10233 l_assignments_tmp.DELETE;
10234 END IF;
10235
10236 FOR recno IN 1..l_assignments.COUNT
10237 LOOP
10238 OPEN superceded_line_cur(l_assignments(recno));
10239 FETCH superceded_line_cur BULK COLLECT INTO t_superceded_lines.enc_summary_line_id;
10240 CLOSE superceded_line_cur;
10241
10242 FORALL recno IN 1..t_superceded_lines.enc_summary_line_id.COUNT
10243 UPDATE psp_enc_lines_history
10244 SET change_flag = 'N'
10245 WHERE enc_summary_line_id = t_superceded_lines.enc_summary_line_id(recno);
10246 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Reverted respective superceded lines in psp_enc_lines_history');
10247
10248 DELETE psp_enc_summary_lines
10249 WHERE payroll_action_id = p_payroll_action_id
10250 AND assignment_id = l_assignments(recno);
10251 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_summary_lines');
10252
10253 DELETE psp_enc_lines
10254 WHERE payroll_action_id = p_payroll_action_id
10255 AND assignment_id = l_assignments(recno);
10256 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_lines');
10257
10258 DELETE psp_enc_controls pec
10259 WHERE payroll_action_id = p_payroll_action_id
10260 AND NOT EXISTS (SELECT 1
10261 FROM psp_enc_lines pel
10262 WHERE payroll_action_id = p_payroll_action_id
10263 AND pel.enc_control_id = pec.enc_control_id);
10264 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_controls');
10265
10266 DELETE psp_report_errors
10267 WHERE payroll_action_id = p_payroll_action_id
10268 AND source_id = l_assignments(recno);
10269 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_report_errors');
10270
10271 UPDATE psp_enc_process_assignments
10272 SET assignment_status = 'B'
10273 WHERE payroll_action_id = p_payroll_action_id
10274 AND assignment_id = l_assignments(recno);
10275 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated assignment status to ''Rollback'' in psp_enc_process_assignments');
10276
10277 UPDATE psp_enc_changed_assignments
10278 SET payroll_action_id = NULL
10279 WHERE payroll_action_id = p_payroll_action_id
10280 AND assignment_id = l_assignments(recno);
10281 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated payroll_action_id in psp_enc_changed_assignments');
10282
10283 INSERT INTO psp_enc_changed_assignments
10284 (request_id, assignment_id, payroll_id, change_type,
10285 processed_flag, reference_id, action_type, change_date)
10286 SELECT l_request_id, pecah.assignment_id, pecah.payroll_id, pecah.change_type,
10287 NULL, NVL(pecah.reference_id, 0), pecah.action_type, change_date
10288 FROM psp_enc_changed_asg_history pecah
10289 WHERE payroll_action_id = p_payroll_action_id
10290 AND assignment_id = l_assignments(recno)
10291 AND action_type NOT IN ('CR', 'LQ', 'TR');
10292 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Copied change assignment records to psp_enc_changed_assignments');
10293
10294 DELETE psp_enc_changed_asg_history
10295 WHERE payroll_action_id = p_payroll_action_id
10296 AND assignment_id = l_assignments(recno);
10297 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Copied change assignment records to psp_enc_changed_assignments');
10298 END LOOP;
10299
10300 UPDATE psp_enc_processes
10301 SET process_status = 'B',
10302 process_phase = 'rollback'
10303 WHERE payroll_action_id = p_payroll_action_id
10304 AND NOT EXISTS (SELECT 1
10305 FROM psp_enc_summary_lines
10306 WHERE payroll_action_id = p_payroll_action_id);
10307 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process status to ''Rollback'' in psp_enc_processes');
10308 END IF;
10309
10310 COMMIT;
10311 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving ROLLBACK_CEL p_payroll_action_id: ' || p_payroll_action_id);
10312 retcode := fnd_api.g_ret_sts_success;
10313 EXCEPTION
10314 WHEN OTHERS THEN
10315 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
10316 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', 'ROLLBACK_CEL: SQLCODE: ' || fnd_number.number_to_canonical(SQLCODE) || ' SQLERRM: ' || SQLERRM);
10317 psp_message_s.print_error(p_mode => FND_FILE.LOG, p_print_header => FND_API.G_TRUE);
10318 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving ROLLBACK_CEL p_payroll_action_id: ' || p_payroll_action_id);
10319 retcode := fnd_api.g_ret_sts_unexp_error;
10320 END rollback_cel;
10321
10322 PROCEDURE load_sch_hierarchy (p_assignment_id IN NUMBER,
10323 p_payroll_id IN NUMBER,
10324 p_element_type_id IN NUMBER,
10325 p_business_group_id IN NUMBER,
10326 p_set_of_books_id IN NUMBER,
10327 p_return_status OUT NOCOPY VARCHAR2) IS
10328 l_proc_name VARCHAR2(61) DEFAULT g_package_name || 'LOAD_SCH_HIERARCHY';
10329 l_proc_step NUMBER(20,10);
10330 r_sa_tmp r_schedule_line_type;
10331 r_gsa r_schedule_line_type;
10332 l_min_start_date DATE;
10333 l_max_end_date DATE;
10334
10335 CURSOR global_element_cur IS
10336 SELECT peta.element_account_id,
10337 peta.gl_code_combination_id,
10338 peta.project_id,
10339 peta.task_id,
10340 peta.award_id,
10341 peta.expenditure_type,
10342 peta.expenditure_organization_id,
10343 peta.start_date_active,
10344 peta.end_date_active,
10345 peta.poeta_start_date,
10346 peta.poeta_end_date,
10347 peta.percent,
10348 DECODE(g_dff_grouping_option, 'Y', peta.attribute_category, NULL),
10349 DECODE(g_dff_grouping_option, 'Y', peta.attribute1, NULL),
10350 DECODE(g_dff_grouping_option, 'Y', peta.attribute2, NULL),
10351 DECODE(g_dff_grouping_option, 'Y', peta.attribute3, NULL),
10352 DECODE(g_dff_grouping_option, 'Y', peta.attribute4, NULL),
10353 DECODE(g_dff_grouping_option, 'Y', peta.attribute5, NULL),
10354 DECODE(g_dff_grouping_option, 'Y', peta.attribute6, NULL),
10355 DECODE(g_dff_grouping_option, 'Y', peta.attribute7, NULL),
10356 DECODE(g_dff_grouping_option, 'Y', peta.attribute8, NULL),
10357 DECODE(g_dff_grouping_option, 'Y', peta.attribute9, NULL),
10358 DECODE(g_dff_grouping_option, 'Y', peta.attribute10, NULL),
10359 DECODE(peta.expenditure_type, NULL, 'N', 'E') acct_type
10360 FROM psp_element_type_accounts peta
10361 WHERE peta.element_type_id = p_element_type_id
10362 AND peta.business_group_id = p_business_group_id
10363 AND peta.set_of_books_id = p_set_of_books_id
10364 AND ( peta.gl_code_combination_id IS NOT NULL
10365 OR peta.award_id IS NOT NULL)
10366 AND peta.end_date_active >= l_min_start_date
10367 AND peta.start_date_active <= g_enc_org_end_date
10368 ORDER BY peta.start_date_active, peta.end_date_active;
10369
10370 CURSOR sch_lines_element_type_cur IS
10371 SELECT psl.schedule_line_id,
10372 psl.gl_code_combination_id,
10373 psl.project_id,
10374 psl.task_id,
10375 psl.award_id,
10376 psl.expenditure_type,
10377 psl.expenditure_organization_id,
10378 psl.schedule_begin_date,
10379 psl.schedule_end_date,
10380 psl.poeta_start_date,
10381 psl.poeta_end_date,
10382 psl.schedule_percent,
10383 DECODE(g_dff_grouping_option, 'Y', psl.attribute_category, NULL),
10384 DECODE(g_dff_grouping_option, 'Y', psl.attribute1, NULL),
10385 DECODE(g_dff_grouping_option, 'Y', psl.attribute2, NULL),
10386 DECODE(g_dff_grouping_option, 'Y', psl.attribute3, NULL),
10387 DECODE(g_dff_grouping_option, 'Y', psl.attribute4, NULL),
10388 DECODE(g_dff_grouping_option, 'Y', psl.attribute5, NULL),
10389 DECODE(g_dff_grouping_option, 'Y', psl.attribute6, NULL),
10390 DECODE(g_dff_grouping_option, 'Y', psl.attribute7, NULL),
10391 DECODE(g_dff_grouping_option, 'Y', psl.attribute8, NULL),
10392 DECODE(g_dff_grouping_option, 'Y', psl.attribute9, NULL),
10393 DECODE(g_dff_grouping_option, 'Y', psl.attribute10, NULL),
10394 DECODE(psl.expenditure_type, NULL, 'N', 'E') acct_type
10395 FROM psp_schedule_hierarchy psh,
10396 psp_schedule_lines psl
10397 WHERE psh.assignment_id = p_assignment_id
10398 AND psh.element_type_id = p_element_type_id
10399 AND psh.business_group_id = p_business_group_id
10400 AND psh.set_of_books_id = p_set_of_books_id
10401 AND psh.schedule_hierarchy_id = psl.schedule_hierarchy_id
10402 AND ( psl.gl_code_combination_id IS NOT NULL
10403 OR psl.award_id IS NOT NULL )
10404 AND psl.schedule_begin_date <= g_enc_org_end_date
10405 AND psl.schedule_end_date >= l_min_start_date
10406 AND psl.default_flag IS NULL
10407 ORDER BY psl.schedule_begin_date, psl.schedule_end_date;
10408
10409 CURSOR sch_lines_element_class_cur IS
10410 SELECT psl.schedule_line_id,
10411 psl.gl_code_combination_id,
10412 psl.project_id,
10413 psl.task_id,
10414 psl.award_id,
10415 psl.expenditure_type,
10416 psl.expenditure_organization_id,
10417 psl.schedule_begin_date,
10418 psl.schedule_end_date,
10419 psl.poeta_start_date,
10420 psl.poeta_end_date,
10421 psl.schedule_percent,
10422 DECODE(g_dff_grouping_option, 'Y', psl.attribute_category, NULL),
10423 DECODE(g_dff_grouping_option, 'Y', psl.attribute1, NULL),
10424 DECODE(g_dff_grouping_option, 'Y', psl.attribute2, NULL),
10425 DECODE(g_dff_grouping_option, 'Y', psl.attribute3, NULL),
10426 DECODE(g_dff_grouping_option, 'Y', psl.attribute4, NULL),
10427 DECODE(g_dff_grouping_option, 'Y', psl.attribute5, NULL),
10428 DECODE(g_dff_grouping_option, 'Y', psl.attribute6, NULL),
10429 DECODE(g_dff_grouping_option, 'Y', psl.attribute7, NULL),
10430 DECODE(g_dff_grouping_option, 'Y', psl.attribute8, NULL),
10431 DECODE(g_dff_grouping_option, 'Y', psl.attribute9, NULL),
10432 DECODE(g_dff_grouping_option, 'Y', psl.attribute10, NULL),
10433 DECODE(psl.expenditure_type, NULL, 'N', 'E') acct_type
10434 FROM psp_element_types pet,
10435 psp_group_element_list pgel,
10436 psp_schedule_hierarchy psh,
10437 psp_schedule_lines psl
10438 WHERE pet.element_type_id = p_element_type_id
10439 AND pet.business_group_id = p_business_group_id
10440 AND pet.set_of_books_id = p_set_of_books_id
10441 AND pet.start_date_active <= g_enc_org_end_date
10442 AND pet.end_date_active >= l_min_start_date
10443 AND pet.element_type_id = pgel.element_type_id
10444 AND psh.business_group_id = p_business_group_id
10445 AND psh.set_of_books_id = p_set_of_books_id
10446 AND pgel.element_group_id = psh.element_group_id
10447 AND psh.assignment_id = p_assignment_id
10448 AND psh.schedule_hierarchy_id = psl.schedule_hierarchy_id
10449 AND ( psl.gl_code_combination_id IS NOT NULL
10450 OR psl.award_id IS NOT NULL)
10451 AND psl.schedule_begin_date <= pet.end_date_active
10452 AND psl.schedule_end_date >= pet.start_date_active
10453 AND psl.default_flag IS NULL
10454 ORDER BY psl.schedule_begin_date, psl.schedule_end_date;
10455
10456 CURSOR sch_lines_assignment_cur IS
10457 SELECT psl.schedule_line_id,
10458 psl.gl_code_combination_id,
10459 psl.project_id,
10460 psl.task_id,
10461 psl.award_id,
10462 psl.expenditure_type,
10463 psl.expenditure_organization_id,
10464 psl.schedule_begin_date,
10465 psl.schedule_end_date,
10466 psl.poeta_start_date,
10467 psl.poeta_end_date,
10468 psl.schedule_percent,
10469 DECODE(g_dff_grouping_option, 'Y', psl.attribute_category, NULL),
10470 DECODE(g_dff_grouping_option, 'Y', psl.attribute1, NULL),
10471 DECODE(g_dff_grouping_option, 'Y', psl.attribute2, NULL),
10472 DECODE(g_dff_grouping_option, 'Y', psl.attribute3, NULL),
10473 DECODE(g_dff_grouping_option, 'Y', psl.attribute4, NULL),
10474 DECODE(g_dff_grouping_option, 'Y', psl.attribute5, NULL),
10475 DECODE(g_dff_grouping_option, 'Y', psl.attribute6, NULL),
10476 DECODE(g_dff_grouping_option, 'Y', psl.attribute7, NULL),
10477 DECODE(g_dff_grouping_option, 'Y', psl.attribute8, NULL),
10478 DECODE(g_dff_grouping_option, 'Y', psl.attribute9, NULL),
10479 DECODE(g_dff_grouping_option, 'Y', psl.attribute10, NULL),
10480 DECODE(psl.expenditure_type, NULL, 'N', 'E') acct_type
10481 FROM psp_schedule_hierarchy psh,
10482 psp_schedule_lines psl
10483 WHERE psh.scheduling_types_code = 'A'
10484 AND psh.element_group_id IS NULL
10485 AND psh.element_type_id IS NULL
10486 AND psh.assignment_id = p_assignment_id
10487 AND psh.business_group_id = p_business_group_id
10488 AND psh.set_of_books_id = p_set_of_books_id
10489 AND psh.schedule_hierarchy_id = psl.schedule_hierarchy_id
10490 AND ( psl.gl_code_combination_id IS NOT NULL
10491 OR psl.award_id IS NOT NULL)
10492 AND psl.schedule_begin_date <= g_enc_org_end_date
10493 AND psl.schedule_end_date >= l_min_start_date
10494 AND psl.default_flag IS NULL
10495 ORDER BY psl.schedule_begin_date, psl.schedule_end_date;
10496
10497 CURSOR asg_org_cur IS
10498 SELECT organization_id,
10499 effective_start_date,
10500 NVL(LEAD(effective_start_date - 1) OVER (ORDER BY effective_end_date), LEAST(l_max_end_date, effective_end_date))
10501 FROM per_assignments_f paf
10502 WHERE assignment_id = p_assignment_id
10503 AND payroll_id = p_payroll_id
10504 AND effective_start_date <= LEAST(l_max_end_date, g_enc_org_end_date)
10505 ANd effective_end_date >= l_min_start_date
10506 AND effective_start_date = (SELECT MIN(paf2.effective_start_date)
10507 FROM per_assignments_f paf2
10508 WHERE paf2.assignment_id = p_assignment_id
10509 AND paf2.payroll_id = paf.payroll_id
10510 AND paf2.organization_id = paf.organization_id
10511 AND paf2.effective_start_date >= paf.effective_start_date);
10512
10513 TYPE r_asg_org_type IS RECORD
10514 (organization_id t_num_15_type,
10515 start_date t_date_type,
10516 end_date t_date_type);
10517 r_asg_org r_asg_org_type;
10518
10519 CURSOR org_labor_schedule_cur (p_organization_id IN NUMBER,
10520 p_org_start_date IN DATE,
10521 p_org_end_date IN DATE) IS
10522 SELECT pdls.org_schedule_id,
10523 pdls.gl_code_combination_id,
10524 pdls.project_id,
10525 pdls.task_id,
10526 pdls.award_id,
10527 pdls.expenditure_type,
10528 pdls.expenditure_organization_id,
10529 GREATEST(pdls.schedule_begin_date, p_org_start_date),
10530 LEAST(pdls.schedule_end_date, p_org_end_date),
10531 pdls.poeta_start_date,
10532 pdls.poeta_end_date,
10533 pdls.schedule_percent,
10534 DECODE(g_dff_grouping_option, 'Y', pdls.attribute_category, NULL),
10535 DECODE(g_dff_grouping_option, 'Y', pdls.attribute1, NULL),
10536 DECODE(g_dff_grouping_option, 'Y', pdls.attribute2, NULL),
10537 DECODE(g_dff_grouping_option, 'Y', pdls.attribute3, NULL),
10538 DECODE(g_dff_grouping_option, 'Y', pdls.attribute4, NULL),
10539 DECODE(g_dff_grouping_option, 'Y', pdls.attribute5, NULL),
10540 DECODE(g_dff_grouping_option, 'Y', pdls.attribute6, NULL),
10541 DECODE(g_dff_grouping_option, 'Y', pdls.attribute7, NULL),
10542 DECODE(g_dff_grouping_option, 'Y', pdls.attribute8, NULL),
10543 DECODE(g_dff_grouping_option, 'Y', pdls.attribute9, NULL),
10544 DECODE(g_dff_grouping_option, 'Y', pdls.attribute10, NULL),
10545 DECODE(pdls.expenditure_type, NULL, 'N', 'E') acct_type
10546 FROM psp_default_labor_schedules pdls
10547 WHERE pdls.business_group_id = p_business_group_id
10548 AND pdls.set_of_books_id = p_set_of_books_id
10549 AND pdls.organization_id = p_organization_id
10550 AND ( pdls.gl_code_combination_id IS NOT NULL
10551 OR pdls.award_id IS NOT NULL)
10552 AND pdls.schedule_begin_date <= p_org_end_date
10553 AND pdls.schedule_end_date >= p_org_start_date
10554 ORDER BY GREATEST(pdls.schedule_begin_date, p_org_start_date), LEAST(pdls.schedule_end_date, p_org_end_date);
10555
10556 CURSOR default_account_cur (p_organization_id IN NUMBER,
10557 p_org_start_date IN DATE,
10558 p_org_end_date IN DATE) IS
10559 SELECT poa.organization_account_id,
10560 poa.gl_code_combination_id,
10561 poa.project_id,
10562 poa.task_id,
10563 poa.award_id,
10564 poa.expenditure_type,
10565 poa.expenditure_organization_id,
10566 GREATEST(poa.start_date_active, p_org_start_date),
10567 LEAST(poa.end_date_active, p_org_end_date),
10568 poa.poeta_start_date,
10569 poa.poeta_end_date,
10570 100 percent,
10571 DECODE(g_dff_grouping_option, 'Y', poa.attribute_category, NULL),
10572 DECODE(g_dff_grouping_option, 'Y', poa.attribute1, NULL),
10573 DECODE(g_dff_grouping_option, 'Y', poa.attribute2, NULL),
10574 DECODE(g_dff_grouping_option, 'Y', poa.attribute3, NULL),
10575 DECODE(g_dff_grouping_option, 'Y', poa.attribute4, NULL),
10576 DECODE(g_dff_grouping_option, 'Y', poa.attribute5, NULL),
10577 DECODE(g_dff_grouping_option, 'Y', poa.attribute6, NULL),
10578 DECODE(g_dff_grouping_option, 'Y', poa.attribute7, NULL),
10579 DECODE(g_dff_grouping_option, 'Y', poa.attribute8, NULL),
10580 DECODE(g_dff_grouping_option, 'Y', poa.attribute9, NULL),
10581 DECODE(g_dff_grouping_option, 'Y', poa.attribute10, NULL),
10582 DECODE(poa.expenditure_type, NULL, 'N', 'E') acct_type
10583 FROM psp_organization_accounts poa
10584 WHERE poa.organization_id = p_organization_id
10585 AND poa.business_group_id = p_business_group_id
10586 AND poa.set_of_books_id = p_set_of_books_id
10587 AND poa.account_type_code = 'D'
10588 AND poa.start_date_active <= p_org_end_date
10589 AND poa.end_date_active >= p_org_start_date
10590 AND ( poa.gl_code_combination_id IS NOT NULL
10591 OR poa.award_id IS NOT NULL)
10592 ORDER BY GREATEST(poa.start_date_active, p_org_start_date), LEAST(poa.end_date_active, p_org_end_date);
10593
10594
10595 CURSOR suspense_account_cur (p_organization_id IN NUMBER,
10596 p_org_start_date IN DATE,
10597 p_org_end_date IN DATE) IS
10598 SELECT poa.organization_account_id,
10599 poa.gl_code_combination_id,
10600 poa.project_id,
10601 poa.task_id,
10602 poa.award_id,
10603 poa.expenditure_type,
10604 poa.expenditure_organization_id,
10605 GREATEST(poa.start_date_active, p_org_start_date),
10606 LEAST(poa.end_date_active, p_org_end_date),
10607 poa.poeta_start_date,
10608 poa.poeta_end_date,
10609 100 percent,
10610 DECODE(g_dff_grouping_option, 'Y', poa.attribute_category, NULL),
10611 DECODE(g_dff_grouping_option, 'Y', poa.attribute1, NULL),
10612 DECODE(g_dff_grouping_option, 'Y', poa.attribute2, NULL),
10613 DECODE(g_dff_grouping_option, 'Y', poa.attribute3, NULL),
10614 DECODE(g_dff_grouping_option, 'Y', poa.attribute4, NULL),
10615 DECODE(g_dff_grouping_option, 'Y', poa.attribute5, NULL),
10616 DECODE(g_dff_grouping_option, 'Y', poa.attribute6, NULL),
10617 DECODE(g_dff_grouping_option, 'Y', poa.attribute7, NULL),
10618 DECODE(g_dff_grouping_option, 'Y', poa.attribute8, NULL),
10619 DECODE(g_dff_grouping_option, 'Y', poa.attribute9, NULL),
10620 DECODE(g_dff_grouping_option, 'Y', poa.attribute10, NULL),
10621 DECODE(poa.expenditure_type, NULL, 'N', 'E') acct_type
10622 FROM psp_organization_accounts poa
10623 WHERE poa.organization_id = p_organization_id
10624 AND poa.business_group_id = p_business_group_id
10625 AND poa.set_of_books_id = p_set_of_books_id
10626 AND poa.account_type_code = 'S'
10627 AND poa.start_date_active <= p_org_end_date
10628 AND poa.end_date_active >= p_org_start_date
10629 AND ( poa.gl_code_combination_id IS NOT NULL
10630 OR poa.award_id IS NOT NULL)
10631 ORDER BY GREATEST(poa.start_date_active, p_org_start_date), LEAST(poa.end_date_active, p_org_end_date);
10632
10633
10634 CURSOR generic_suspense_cur IS
10635 SELECT poa.organization_account_id,
10636 poa.gl_code_combination_id,
10637 poa.project_id,
10638 poa.task_id,
10639 poa.award_id,
10640 poa.expenditure_type,
10641 poa.expenditure_organization_id,
10642 poa.start_date_active,
10643 poa.end_date_active,
10644 poa.poeta_start_date,
10645 poa.poeta_end_date,
10646 100 percent,
10647 DECODE(g_dff_grouping_option, 'Y', poa.attribute_category, NULL),
10648 DECODE(g_dff_grouping_option, 'Y', poa.attribute1, NULL),
10649 DECODE(g_dff_grouping_option, 'Y', poa.attribute2, NULL),
10650 DECODE(g_dff_grouping_option, 'Y', poa.attribute3, NULL),
10651 DECODE(g_dff_grouping_option, 'Y', poa.attribute4, NULL),
10652 DECODE(g_dff_grouping_option, 'Y', poa.attribute5, NULL),
10653 DECODE(g_dff_grouping_option, 'Y', poa.attribute6, NULL),
10654 DECODE(g_dff_grouping_option, 'Y', poa.attribute7, NULL),
10655 DECODE(g_dff_grouping_option, 'Y', poa.attribute8, NULL),
10656 DECODE(g_dff_grouping_option, 'Y', poa.attribute9, NULL),
10657 DECODE(g_dff_grouping_option, 'Y', poa.attribute10, NULL),
10658 DECODE(poa.expenditure_type, NULL, 'N', 'E') acct_type
10659 FROM psp_organization_accounts poa
10660 WHERE poa.business_group_id = p_business_group_id
10661 AND poa.set_of_books_id = p_set_of_books_id
10662 AND poa.account_type_code = 'G'
10663 AND poa.start_date_active <= g_enc_org_end_date
10664 AND poa.end_date_active >= l_min_start_date
10665 AND ( poa.gl_code_combination_id IS NOT NULL
10666 OR poa.award_id IS NOT NULL)
10667 ORDER BY poa.start_date_active, poa.end_date_active;
10668 BEGIN
10669 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering LOAD_SCH_HIERARCHY p_assignment_id: ' || fnd_number.number_to_canonical(p_assignment_id) || '
10670 p_element_type_id: ' || fnd_number.number_to_canonical(p_element_type_id) || '
10671 p_business_group_id: ' || fnd_number.number_to_canonical(p_business_group_id) || '
10672 p_set_of_books_id: ' || fnd_number.number_to_canonical(p_set_of_books_id));
10673
10674 clear_sch_hierarchy;
10675
10676 l_min_start_date := r_enc_period.r_asg_start_date(1);
10677 l_max_end_date := r_enc_period.r_asg_end_date(r_enc_period.r_period_end_date.COUNT);
10678
10679 OPEN global_element_cur;
10680 FETCH global_element_cur BULK COLLECT INTO r_gee.line_account_id,
10681 r_gee.gl_code_combination_id, r_gee.project_id,
10682 r_gee.task_id, r_gee.award_id,
10683 r_gee.expenditure_type, r_gee.expenditure_organization_id,
10684 r_gee.start_date_active, r_gee.end_date_active,
10685 r_gee.poeta_start_date, r_gee.poeta_end_date,
10686 r_gee.percent, r_gee.attribute_category,
10687 r_gee.attribute1, r_gee.attribute2,
10688 r_gee.attribute3, r_gee.attribute4,
10689 r_gee.attribute5, r_gee.attribute6,
10690 r_gee.attribute7, r_gee.attribute8,
10691 r_gee.attribute9, r_gee.attribute10, r_gee.acct_type;
10692 CLOSE global_element_cur;
10693 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_gee.line_account_id.COUNT: ' || r_gee.line_account_id.COUNT);
10694
10695 OPEN sch_lines_element_type_cur;
10696 FETCH sch_lines_element_type_cur BULK COLLECT INTO r_et.line_account_id,
10697 r_et.gl_code_combination_id, r_et.project_id,
10698 r_et.task_id, r_et.award_id,
10699 r_et.expenditure_type, r_et.expenditure_organization_id,
10700 r_et.start_date_active, r_et.end_date_active,
10701 r_et.poeta_start_date, r_et.poeta_end_date,
10702 r_et.percent, r_et.attribute_category,
10703 r_et.attribute1, r_et.attribute2,
10704 r_et.attribute3, r_et.attribute4,
10705 r_et.attribute5, r_et.attribute6,
10706 r_et.attribute7, r_et.attribute8,
10707 r_et.attribute9, r_et.attribute10, r_et.acct_type;
10708 CLOSE sch_lines_element_type_cur;
10709 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_et.line_account_id.COUNT: ' || r_et.line_account_id.COUNT);
10710
10711 OPEN sch_lines_element_class_cur;
10712 FETCH sch_lines_element_class_cur BULK COLLECT INTO r_ec.line_account_id,
10713 r_ec.gl_code_combination_id, r_ec.project_id,
10714 r_ec.task_id, r_ec.award_id,
10715 r_ec.expenditure_type, r_ec.expenditure_organization_id,
10716 r_ec.start_date_active, r_ec.end_date_active,
10717 r_ec.poeta_start_date, r_ec.poeta_end_date,
10718 r_ec.percent, r_ec.attribute_category,
10719 r_ec.attribute1, r_ec.attribute2,
10720 r_ec.attribute3, r_ec.attribute4,
10721 r_ec.attribute5, r_ec.attribute6,
10722 r_ec.attribute7, r_ec.attribute8,
10723 r_ec.attribute9, r_ec.attribute10, r_ec.acct_type;
10724 CLOSE sch_lines_element_class_cur;
10725 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_ec.line_account_id.COUNT: ' || r_ec.line_account_id.COUNT);
10726
10727 OPEN sch_lines_assignment_cur;
10728 FETCH sch_lines_assignment_cur BULK COLLECT INTO r_asg.line_account_id,
10729 r_asg.gl_code_combination_id, r_asg.project_id,
10730 r_asg.task_id, r_asg.award_id,
10731 r_asg.expenditure_type, r_asg.expenditure_organization_id,
10732 r_asg.start_date_active, r_asg.end_date_active,
10733 r_asg.poeta_start_date, r_asg.poeta_end_date,
10734 r_asg.percent, r_asg.attribute_category,
10735 r_asg.attribute1, r_asg.attribute2,
10736 r_asg.attribute3, r_asg.attribute4,
10737 r_asg.attribute5, r_asg.attribute6,
10738 r_asg.attribute7, r_asg.attribute8,
10739 r_asg.attribute9, r_asg.attribute10, r_asg.acct_type;
10740 CLOSE sch_lines_assignment_cur;
10741 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_asg.line_account_id.COUNT: ' || r_asg.line_account_id.COUNT);
10742
10743 OPEN asg_org_cur;
10744 FETCH asg_org_cur BULK COLLECT INTO r_asg_org.organization_id, r_asg_org.start_date, r_asg_org.end_date;
10745 CLOSE asg_org_cur;
10746
10747 g_odls_pointer := 0;
10748 g_da_pointer := 0;
10749 g_sa_pointer := 0;
10750
10751 FOR recno IN 1..r_asg_org.organization_id.COUNT
10752 LOOP
10753 OPEN org_labor_schedule_cur (r_asg_org.organization_id(recno),
10754 r_asg_org.start_date(recno), r_asg_org.end_date(recno));
10755 FETCH org_labor_schedule_cur BULK COLLECT INTO r_gsa.line_account_id,
10756 r_gsa.gl_code_combination_id, r_gsa.project_id,
10757 r_gsa.task_id, r_gsa.award_id,
10758 r_gsa.expenditure_type, r_gsa.expenditure_organization_id,
10759 r_gsa.start_date_active, r_gsa.end_date_active,
10760 r_gsa.poeta_start_date, r_gsa.poeta_end_date,
10761 r_gsa.percent, r_gsa.attribute_category,
10762 r_gsa.attribute1, r_gsa.attribute2,
10763 r_gsa.attribute3, r_gsa.attribute4,
10764 r_gsa.attribute5, r_gsa.attribute6,
10765 r_gsa.attribute7, r_gsa.attribute8,
10766 r_gsa.attribute9, r_gsa.attribute10, r_gsa.acct_type;
10767 CLOSE org_labor_schedule_cur;
10768
10769 FOR recno2 IN 1..r_gsa.line_account_id.COUNT
10770 LOOP
10771 g_odls_pointer := g_odls_pointer + 1;
10772 r_odls.line_account_id(g_odls_pointer) := r_gsa.line_account_id(recno2);
10773 r_odls.gl_code_combination_id(g_odls_pointer) := r_gsa.gl_code_combination_id(recno2);
10774 r_odls.project_id(g_odls_pointer) := r_gsa.project_id(recno2);
10775 r_odls.task_id(g_odls_pointer) := r_gsa.task_id(recno2);
10776 r_odls.award_id(g_odls_pointer) := r_gsa.award_id(recno2);
10777 r_odls.expenditure_type(g_odls_pointer) := r_gsa.expenditure_type(recno2);
10778 r_odls.expenditure_organization_id(g_odls_pointer) := r_gsa.expenditure_organization_id(recno2);
10779 r_odls.start_date_active(g_odls_pointer) := r_gsa.start_date_active(recno2);
10780 r_odls.end_date_active(g_odls_pointer) := r_gsa.end_date_active(recno2);
10781 r_odls.poeta_start_date(g_odls_pointer) := r_gsa.poeta_start_date(recno2);
10782 r_odls.poeta_end_date(g_odls_pointer) := r_gsa.poeta_end_date(recno2);
10783 r_odls.percent(g_odls_pointer) := r_gsa.percent(recno2);
10784 r_odls.attribute_category(g_odls_pointer) := r_gsa.attribute_category(recno2);
10785 r_odls.attribute1(g_odls_pointer) := r_gsa.attribute1(recno2);
10786 r_odls.attribute2(g_odls_pointer) := r_gsa.attribute2(recno2);
10787 r_odls.attribute3(g_odls_pointer) := r_gsa.attribute3(recno2);
10788 r_odls.attribute4(g_odls_pointer) := r_gsa.attribute4(recno2);
10789 r_odls.attribute5(g_odls_pointer) := r_gsa.attribute5(recno2);
10790 r_odls.attribute6(g_odls_pointer) := r_gsa.attribute6(recno2);
10791 r_odls.attribute7(g_odls_pointer) := r_gsa.attribute7(recno2);
10792 r_odls.attribute8(g_odls_pointer) := r_gsa.attribute8(recno2);
10793 r_odls.attribute9(g_odls_pointer) := r_gsa.attribute9(recno2);
10794 r_odls.attribute10(g_odls_pointer) := r_gsa.attribute10(recno2);
10795 r_odls.acct_type(g_odls_pointer) := r_gsa.acct_type(recno2);
10796 END LOOP;
10797
10798 r_gsa.line_account_id.DELETE;
10799 r_gsa.gl_code_combination_id.DELETE;
10800 r_gsa.project_id.DELETE;
10801 r_gsa.task_id.DELETE;
10802 r_gsa.award_id.DELETE;
10803 r_gsa.expenditure_type.DELETE;
10804 r_gsa.expenditure_organization_id.DELETE;
10805 r_gsa.start_date_active.DELETE;
10806 r_gsa.end_date_active.DELETE;
10807 r_gsa.poeta_start_date.DELETE;
10808 r_gsa.poeta_end_date.DELETE;
10809 r_gsa.percent.DELETE;
10810 r_gsa.attribute_category.DELETE;
10811 r_gsa.attribute1.DELETE;
10812 r_gsa.attribute2.DELETE;
10813 r_gsa.attribute3.DELETE;
10814 r_gsa.attribute4.DELETE;
10815 r_gsa.attribute5.DELETE;
10816 r_gsa.attribute6.DELETE;
10817 r_gsa.attribute7.DELETE;
10818 r_gsa.attribute8.DELETE;
10819 r_gsa.attribute9.DELETE;
10820 r_gsa.attribute10.DELETE;
10821 r_gsa.acct_type.DELETE;
10822
10823 OPEN default_account_cur (r_asg_org.organization_id(recno),
10824 r_asg_org.start_date(recno), r_asg_org.end_date(recno));
10825 FETCH default_account_cur BULK COLLECT INTO r_gsa.line_account_id,
10826 r_gsa.gl_code_combination_id, r_gsa.project_id,
10827 r_gsa.task_id, r_gsa.award_id,
10828 r_gsa.expenditure_type, r_gsa.expenditure_organization_id,
10829 r_gsa.start_date_active, r_gsa.end_date_active,
10830 r_gsa.poeta_start_date, r_gsa.poeta_end_date,
10831 r_gsa.percent, r_gsa.attribute_category,
10832 r_gsa.attribute1, r_gsa.attribute2,
10833 r_gsa.attribute3, r_gsa.attribute4,
10834 r_gsa.attribute5, r_gsa.attribute6,
10835 r_gsa.attribute7, r_gsa.attribute8,
10836 r_gsa.attribute9, r_gsa.attribute10, r_gsa.acct_type;
10837 CLOSE default_account_cur;
10838
10839 FOR recno2 IN 1..r_gsa.line_account_id.COUNT
10840 LOOP
10841 g_da_pointer := g_da_pointer + 1;
10842 r_da.line_account_id(g_da_pointer) := r_gsa.line_account_id(recno2);
10843 r_da.gl_code_combination_id(g_da_pointer) := r_gsa.gl_code_combination_id(recno2);
10844 r_da.project_id(g_da_pointer) := r_gsa.project_id(recno2);
10845 r_da.task_id(g_da_pointer) := r_gsa.task_id(recno2);
10846 r_da.award_id(g_da_pointer) := r_gsa.award_id(recno2);
10847 r_da.expenditure_type(g_da_pointer) := r_gsa.expenditure_type(recno2);
10848 r_da.expenditure_organization_id(g_da_pointer) := r_gsa.expenditure_organization_id(recno2);
10849 r_da.start_date_active(g_da_pointer) := r_gsa.start_date_active(recno2);
10850 r_da.end_date_active(g_da_pointer) := r_gsa.end_date_active(recno2);
10851 r_da.poeta_start_date(g_da_pointer) := r_gsa.poeta_start_date(recno2);
10852 r_da.poeta_end_date(g_da_pointer) := r_gsa.poeta_end_date(recno2);
10853 r_da.percent(g_da_pointer) := r_gsa.percent(recno2);
10854 r_da.attribute_category(g_da_pointer) := r_gsa.attribute_category(recno2);
10855 r_da.attribute1(g_da_pointer) := r_gsa.attribute1(recno2);
10856 r_da.attribute2(g_da_pointer) := r_gsa.attribute2(recno2);
10857 r_da.attribute3(g_da_pointer) := r_gsa.attribute3(recno2);
10858 r_da.attribute4(g_da_pointer) := r_gsa.attribute4(recno2);
10859 r_da.attribute5(g_da_pointer) := r_gsa.attribute5(recno2);
10860 r_da.attribute6(g_da_pointer) := r_gsa.attribute6(recno2);
10861 r_da.attribute7(g_da_pointer) := r_gsa.attribute7(recno2);
10862 r_da.attribute8(g_da_pointer) := r_gsa.attribute8(recno2);
10863 r_da.attribute9(g_da_pointer) := r_gsa.attribute9(recno2);
10864 r_da.attribute10(g_da_pointer) := r_gsa.attribute10(recno2);
10865 r_da.acct_type(g_da_pointer) := r_gsa.acct_type(recno2);
10866 END LOOP;
10867
10868 r_gsa.line_account_id.DELETE;
10869 r_gsa.gl_code_combination_id.DELETE;
10870 r_gsa.project_id.DELETE;
10871 r_gsa.task_id.DELETE;
10872 r_gsa.award_id.DELETE;
10873 r_gsa.expenditure_type.DELETE;
10874 r_gsa.expenditure_organization_id.DELETE;
10875 r_gsa.start_date_active.DELETE;
10876 r_gsa.end_date_active.DELETE;
10877 r_gsa.poeta_start_date.DELETE;
10878 r_gsa.poeta_end_date.DELETE;
10879 r_gsa.percent.DELETE;
10880 r_gsa.attribute_category.DELETE;
10881 r_gsa.attribute1.DELETE;
10882 r_gsa.attribute2.DELETE;
10883 r_gsa.attribute3.DELETE;
10884 r_gsa.attribute4.DELETE;
10885 r_gsa.attribute5.DELETE;
10886 r_gsa.attribute6.DELETE;
10887 r_gsa.attribute7.DELETE;
10888 r_gsa.attribute8.DELETE;
10889 r_gsa.attribute9.DELETE;
10890 r_gsa.attribute10.DELETE;
10891 r_gsa.acct_type.DELETE;
10892
10893 OPEN suspense_account_cur (r_asg_org.organization_id(recno),
10894 r_asg_org.start_date(recno), r_asg_org.end_date(recno));
10895 FETCH suspense_account_cur BULK COLLECT INTO r_gsa.line_account_id,
10896 r_gsa.gl_code_combination_id, r_gsa.project_id,
10897 r_gsa.task_id, r_gsa.award_id,
10898 r_gsa.expenditure_type, r_gsa.expenditure_organization_id,
10899 r_gsa.start_date_active, r_gsa.end_date_active,
10900 r_gsa.poeta_start_date, r_gsa.poeta_end_date,
10901 r_gsa.percent, r_gsa.attribute_category,
10902 r_gsa.attribute1, r_gsa.attribute2,
10903 r_gsa.attribute3, r_gsa.attribute4,
10904 r_gsa.attribute5, r_gsa.attribute6,
10905 r_gsa.attribute7, r_gsa.attribute8,
10906 r_gsa.attribute9, r_gsa.attribute10, r_gsa.acct_type;
10907 CLOSE suspense_account_cur;
10908
10909 FOR recno2 IN 1..r_gsa.line_account_id.COUNT
10910 LOOP
10911 g_sa_pointer := g_sa_pointer + 1;
10912 r_sa_tmp.line_account_id(g_sa_pointer) := r_gsa.line_account_id(recno2);
10913 r_sa_tmp.gl_code_combination_id(g_sa_pointer) := r_gsa.gl_code_combination_id(recno2);
10914 r_sa_tmp.project_id(g_sa_pointer) := r_gsa.project_id(recno2);
10915 r_sa_tmp.task_id(g_sa_pointer) := r_gsa.task_id(recno2);
10916 r_sa_tmp.award_id(g_sa_pointer) := r_gsa.award_id(recno2);
10917 r_sa_tmp.expenditure_type(g_sa_pointer) := r_gsa.expenditure_type(recno2);
10918 r_sa_tmp.expenditure_organization_id(g_sa_pointer) := r_gsa.expenditure_organization_id(recno2);
10919 r_sa_tmp.start_date_active(g_sa_pointer) := r_gsa.start_date_active(recno2);
10920 r_sa_tmp.end_date_active(g_sa_pointer) := r_gsa.end_date_active(recno2);
10921 r_sa_tmp.poeta_start_date(g_sa_pointer) := r_gsa.poeta_start_date(recno2);
10922 r_sa_tmp.poeta_end_date(g_sa_pointer) := r_gsa.poeta_end_date(recno2);
10923 r_sa_tmp.percent(g_sa_pointer) := r_gsa.percent(recno2);
10924 r_sa_tmp.attribute_category(g_sa_pointer) := r_gsa.attribute_category(recno2);
10925 r_sa_tmp.attribute1(g_sa_pointer) := r_gsa.attribute1(recno2);
10926 r_sa_tmp.attribute2(g_sa_pointer) := r_gsa.attribute2(recno2);
10927 r_sa_tmp.attribute3(g_sa_pointer) := r_gsa.attribute3(recno2);
10928 r_sa_tmp.attribute4(g_sa_pointer) := r_gsa.attribute4(recno2);
10929 r_sa_tmp.attribute5(g_sa_pointer) := r_gsa.attribute5(recno2);
10930 r_sa_tmp.attribute6(g_sa_pointer) := r_gsa.attribute6(recno2);
10931 r_sa_tmp.attribute7(g_sa_pointer) := r_gsa.attribute7(recno2);
10932 r_sa_tmp.attribute8(g_sa_pointer) := r_gsa.attribute8(recno2);
10933 r_sa_tmp.attribute9(g_sa_pointer) := r_gsa.attribute9(recno2);
10934 r_sa_tmp.attribute10(g_sa_pointer) := r_gsa.attribute10(recno2);
10935 r_sa_tmp.acct_type(g_sa_pointer) := r_gsa.acct_type(recno2);
10936 END LOOP;
10937
10938 r_gsa.line_account_id.DELETE;
10939 r_gsa.gl_code_combination_id.DELETE;
10940 r_gsa.project_id.DELETE;
10941 r_gsa.task_id.DELETE;
10942 r_gsa.award_id.DELETE;
10943 r_gsa.expenditure_type.DELETE;
10944 r_gsa.expenditure_organization_id.DELETE;
10945 r_gsa.start_date_active.DELETE;
10946 r_gsa.end_date_active.DELETE;
10947 r_gsa.poeta_start_date.DELETE;
10948 r_gsa.poeta_end_date.DELETE;
10949 r_gsa.percent.DELETE;
10950 r_gsa.attribute_category.DELETE;
10951 r_gsa.attribute1.DELETE;
10952 r_gsa.attribute2.DELETE;
10953 r_gsa.attribute3.DELETE;
10954 r_gsa.attribute4.DELETE;
10955 r_gsa.attribute5.DELETE;
10956 r_gsa.attribute6.DELETE;
10957 r_gsa.attribute7.DELETE;
10958 r_gsa.attribute8.DELETE;
10959 r_gsa.attribute9.DELETE;
10960 r_gsa.attribute10.DELETE;
10961 r_gsa.acct_type.DELETE;
10962 END LOOP;
10963 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_odls.line_account_id.COUNT: ' || r_odls.line_account_id.COUNT);
10964 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_da.line_account_id.COUNT: ' || r_da.line_account_id.COUNT);
10965 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_sa_tmp.line_account_id.COUNT: ' || r_sa_tmp.line_account_id.COUNT);
10966
10967 IF (r_sa_tmp.line_account_id.COUNT = 0) THEN
10968 OPEN generic_suspense_cur;
10969 FETCH generic_suspense_cur BULK COLLECT INTO r_sa.line_account_id,
10970 r_sa.gl_code_combination_id, r_sa.project_id,
10971 r_sa.task_id, r_sa.award_id,
10972 r_sa.expenditure_type, r_sa.expenditure_organization_id,
10973 r_sa.start_date_active, r_sa.end_date_active,
10974 r_sa.poeta_start_date, r_sa.poeta_end_date,
10975 r_sa.percent, r_sa.attribute_category,
10976 r_sa.attribute1, r_sa.attribute2,
10977 r_sa.attribute3, r_sa.attribute4,
10978 r_sa.attribute5, r_sa.attribute6,
10979 r_sa.attribute7, r_sa.attribute8,
10980 r_sa.attribute9, r_sa.attribute10, r_sa.acct_type;
10981 CLOSE generic_suspense_cur;
10982 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_sa.line_account_id.COUNT: ' || r_sa.line_account_id.COUNT);
10983 ELSE
10984 OPEN generic_suspense_cur;
10985 FETCH generic_suspense_cur BULK COLLECT INTO r_gsa.line_account_id,
10986 r_gsa.gl_code_combination_id, r_gsa.project_id,
10987 r_gsa.task_id, r_gsa.award_id,
10988 r_gsa.expenditure_type, r_gsa.expenditure_organization_id,
10989 r_gsa.start_date_active, r_gsa.end_date_active,
10990 r_gsa.poeta_start_date, r_gsa.poeta_end_date,
10991 r_gsa.percent, r_gsa.attribute_category,
10992 r_gsa.attribute1, r_gsa.attribute2,
10993 r_gsa.attribute3, r_gsa.attribute4,
10994 r_gsa.attribute5, r_gsa.attribute6,
10995 r_gsa.attribute7, r_gsa.attribute8,
10996 r_gsa.attribute9, r_gsa.attribute10, r_gsa.acct_type;
10997 CLOSE generic_suspense_cur;
10998 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_gsa.line_account_id.COUNT: ' || r_gsa.line_account_id.COUNT);
10999
11000 g_sa_pointer := 0;
11001 IF (r_sa_tmp.start_date_active(1) >= r_enc_period.r_asg_start_date(1)) THEN
11002 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) ||
11003 ' r_sa_tmp.start_date_active(1): ' || r_sa_tmp.start_date_active(1) ||
11004 ' r_enc_period.r_asg_start_date(1): ' || r_enc_period.r_asg_start_date(1));
11005 FOR gsa_rec_no IN 1..r_gsa.line_account_id.COUNT
11006 LOOP
11007 EXIT WHEN r_gsa.start_date_active(gsa_rec_no) >= r_sa_tmp.start_date_active(1);
11008
11009 g_sa_pointer := g_sa_pointer + 1;
11010 r_sa.line_account_id(g_sa_pointer) := r_gsa.line_account_id(gsa_rec_no);
11011 r_sa.gl_code_combination_id(g_sa_pointer) := r_gsa.gl_code_combination_id(gsa_rec_no);
11012 r_sa.project_id(g_sa_pointer) := r_gsa.project_id(gsa_rec_no);
11013 r_sa.task_id(g_sa_pointer) := r_gsa.task_id(gsa_rec_no);
11014 r_sa.award_id(g_sa_pointer) := r_gsa.award_id(gsa_rec_no);
11015 r_sa.expenditure_type(g_sa_pointer) := r_gsa.expenditure_type(gsa_rec_no);
11016 r_sa.expenditure_organization_id(g_sa_pointer) := r_gsa.expenditure_organization_id(gsa_rec_no);
11017 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));
11018 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);
11019 r_sa.poeta_start_date(g_sa_pointer) := r_gsa.poeta_start_date(gsa_rec_no);
11020 r_sa.poeta_end_date(g_sa_pointer) := r_gsa.poeta_end_date(gsa_rec_no);
11021 r_sa.percent(g_sa_pointer) := r_gsa.percent(gsa_rec_no);
11022 r_sa.attribute_category(g_sa_pointer) := r_gsa.attribute_category(gsa_rec_no);
11023 r_sa.attribute1(g_sa_pointer) := r_gsa.attribute1(gsa_rec_no);
11024 r_sa.attribute2(g_sa_pointer) := r_gsa.attribute2(gsa_rec_no);
11025 r_sa.attribute3(g_sa_pointer) := r_gsa.attribute3(gsa_rec_no);
11026 r_sa.attribute4(g_sa_pointer) := r_gsa.attribute4(gsa_rec_no);
11027 r_sa.attribute5(g_sa_pointer) := r_gsa.attribute5(gsa_rec_no);
11028 r_sa.attribute6(g_sa_pointer) := r_gsa.attribute6(gsa_rec_no);
11029 r_sa.attribute7(g_sa_pointer) := r_gsa.attribute7(gsa_rec_no);
11030 r_sa.attribute8(g_sa_pointer) := r_gsa.attribute8(gsa_rec_no);
11031 r_sa.attribute9(g_sa_pointer) := r_gsa.attribute9(gsa_rec_no);
11032 r_sa.attribute10(g_sa_pointer) := r_gsa.attribute10(gsa_rec_no);
11033 r_sa.acct_type(g_sa_pointer) := r_gsa.acct_type(gsa_rec_no);
11034 END LOOP;
11035 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Identified Generic Suspense Lines for suspense gap before the first suspense line');
11036 END IF;
11037 g_sa_pointer := g_sa_pointer + 1;
11038 r_sa.line_account_id(g_sa_pointer) := r_sa_tmp.line_account_id(1);
11039 r_sa.gl_code_combination_id(g_sa_pointer) := r_sa_tmp.gl_code_combination_id(1);
11040 r_sa.project_id(g_sa_pointer) := r_sa_tmp.project_id(1);
11041 r_sa.task_id(g_sa_pointer) := r_sa_tmp.task_id(1);
11042 r_sa.award_id(g_sa_pointer) := r_sa_tmp.award_id(1);
11043 r_sa.expenditure_type(g_sa_pointer) := r_sa_tmp.expenditure_type(1);
11044 r_sa.expenditure_organization_id(g_sa_pointer) := r_sa_tmp.expenditure_organization_id(1);
11045 r_sa.start_date_active(g_sa_pointer) := r_sa_tmp.start_date_active(1);
11046 r_sa.end_date_active(g_sa_pointer) := r_sa_tmp.end_date_active(1);
11047 r_sa.poeta_start_date(g_sa_pointer) := r_sa_tmp.poeta_start_date(1);
11048 r_sa.poeta_end_date(g_sa_pointer) := r_sa_tmp.poeta_end_date(1);
11049 r_sa.percent(g_sa_pointer) := r_sa_tmp.percent(1);
11050 r_sa.attribute_category(g_sa_pointer) := r_sa_tmp.attribute_category(1);
11051 r_sa.attribute1(g_sa_pointer) := r_sa_tmp.attribute1(1);
11052 r_sa.attribute2(g_sa_pointer) := r_sa_tmp.attribute2(1);
11053 r_sa.attribute3(g_sa_pointer) := r_sa_tmp.attribute3(1);
11054 r_sa.attribute4(g_sa_pointer) := r_sa_tmp.attribute4(1);
11055 r_sa.attribute5(g_sa_pointer) := r_sa_tmp.attribute5(1);
11056 r_sa.attribute6(g_sa_pointer) := r_sa_tmp.attribute6(1);
11057 r_sa.attribute7(g_sa_pointer) := r_sa_tmp.attribute7(1);
11058 r_sa.attribute8(g_sa_pointer) := r_sa_tmp.attribute8(1);
11059 r_sa.attribute9(g_sa_pointer) := r_sa_tmp.attribute9(1);
11060 r_sa.attribute10(g_sa_pointer) := r_sa_tmp.attribute10(1);
11061 r_sa.acct_type(g_sa_pointer) := r_sa_tmp.acct_type(1);
11062 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Stamped first suspense line');
11063
11064 IF (r_sa_tmp.line_account_id.COUNT > 1) THEN
11065 FOR sa_recno IN 2..r_sa_tmp.line_account_id.COUNT
11066 LOOP
11067 IF (r_sa_tmp.start_date_active(sa_recno) > r_sa.end_date_active(g_sa_pointer)+1) THEN
11068 FOR gsa_rec_no IN 1..r_gsa.line_account_id.COUNT
11069 LOOP
11070 EXIT WHEN r_sa.end_date_active(g_sa_pointer)+1 >= r_sa_tmp.start_date_active(sa_recno);
11071 IF (r_gsa.end_date_active(gsa_rec_no) >= r_sa.end_date_active(g_sa_pointer)+1) THEN
11072 g_sa_pointer := g_sa_pointer + 1;
11073 r_sa.line_account_id(g_sa_pointer) := r_gsa.line_account_id(gsa_rec_no);
11074 r_sa.gl_code_combination_id(g_sa_pointer) := r_gsa.gl_code_combination_id(gsa_rec_no);
11075 r_sa.project_id(g_sa_pointer) := r_gsa.project_id(gsa_rec_no);
11076 r_sa.task_id(g_sa_pointer) := r_gsa.task_id(gsa_rec_no);
11077 r_sa.award_id(g_sa_pointer) := r_gsa.award_id(gsa_rec_no);
11078 r_sa.expenditure_type(g_sa_pointer) := r_gsa.expenditure_type(gsa_rec_no);
11079 r_sa.expenditure_organization_id(g_sa_pointer) := r_gsa.expenditure_organization_id(gsa_rec_no);
11080 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);
11081 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);
11082 r_sa.poeta_start_date(g_sa_pointer) := r_gsa.poeta_start_date(gsa_rec_no);
11083 r_sa.poeta_end_date(g_sa_pointer) := r_gsa.poeta_end_date(gsa_rec_no);
11084 r_sa.percent(g_sa_pointer) := r_gsa.percent(gsa_rec_no);
11085 r_sa.attribute_category(g_sa_pointer) := r_gsa.attribute_category(gsa_rec_no);
11086 r_sa.attribute1(g_sa_pointer) := r_gsa.attribute1(gsa_rec_no);
11087 r_sa.attribute2(g_sa_pointer) := r_gsa.attribute2(gsa_rec_no);
11088 r_sa.attribute3(g_sa_pointer) := r_gsa.attribute3(gsa_rec_no);
11089 r_sa.attribute4(g_sa_pointer) := r_gsa.attribute4(gsa_rec_no);
11090 r_sa.attribute5(g_sa_pointer) := r_gsa.attribute5(gsa_rec_no);
11091 r_sa.attribute6(g_sa_pointer) := r_gsa.attribute6(gsa_rec_no);
11092 r_sa.attribute7(g_sa_pointer) := r_gsa.attribute7(gsa_rec_no);
11093 r_sa.attribute8(g_sa_pointer) := r_gsa.attribute8(gsa_rec_no);
11094 r_sa.attribute9(g_sa_pointer) := r_gsa.attribute9(gsa_rec_no);
11095 r_sa.attribute10(g_sa_pointer) := r_gsa.attribute10(gsa_rec_no);
11096 r_sa.acct_type(g_sa_pointer) := r_gsa.acct_type(gsa_rec_no);
11097 hr_utility.trace(' Stamped generic suspense line between ' ||
11098 r_sa.start_date_active(g_sa_pointer) || ' AND ' ||
11099 r_sa.end_date_active(g_sa_pointer));
11100 END IF;
11101 END LOOP;
11102 END IF;
11103 hr_utility.trace(' Attempting to stamp org suspense');
11104 g_sa_pointer := g_sa_pointer + 1;
11105 r_sa.line_account_id(g_sa_pointer) := r_sa_tmp.line_account_id(sa_recno);
11106 r_sa.gl_code_combination_id(g_sa_pointer) := r_sa_tmp.gl_code_combination_id(sa_recno);
11107 r_sa.project_id(g_sa_pointer) := r_sa_tmp.project_id(sa_recno);
11108 r_sa.task_id(g_sa_pointer) := r_sa_tmp.task_id(sa_recno);
11109 r_sa.award_id(g_sa_pointer) := r_sa_tmp.award_id(sa_recno);
11110 r_sa.expenditure_type(g_sa_pointer) := r_sa_tmp.expenditure_type(sa_recno);
11111 r_sa.expenditure_organization_id(g_sa_pointer) := r_sa_tmp.expenditure_organization_id(sa_recno);
11112 r_sa.start_date_active(g_sa_pointer) := r_sa_tmp.start_date_active(sa_recno);
11113 r_sa.end_date_active(g_sa_pointer) := r_sa_tmp.end_date_active(sa_recno);
11114 r_sa.poeta_start_date(g_sa_pointer) := r_sa_tmp.poeta_start_date(sa_recno);
11115 r_sa.poeta_end_date(g_sa_pointer) := r_sa_tmp.poeta_end_date(sa_recno);
11116 r_sa.percent(g_sa_pointer) := r_sa_tmp.percent(sa_recno);
11117 r_sa.attribute_category(g_sa_pointer) := r_sa_tmp.attribute_category(sa_recno);
11118 r_sa.attribute1(g_sa_pointer) := r_sa_tmp.attribute1(sa_recno);
11119 r_sa.attribute2(g_sa_pointer) := r_sa_tmp.attribute2(sa_recno);
11120 r_sa.attribute3(g_sa_pointer) := r_sa_tmp.attribute3(sa_recno);
11121 r_sa.attribute4(g_sa_pointer) := r_sa_tmp.attribute4(sa_recno);
11122 r_sa.attribute5(g_sa_pointer) := r_sa_tmp.attribute5(sa_recno);
11123 r_sa.attribute6(g_sa_pointer) := r_sa_tmp.attribute6(sa_recno);
11124 r_sa.attribute7(g_sa_pointer) := r_sa_tmp.attribute7(sa_recno);
11125 r_sa.attribute8(g_sa_pointer) := r_sa_tmp.attribute8(sa_recno);
11126 r_sa.attribute9(g_sa_pointer) := r_sa_tmp.attribute9(sa_recno);
11127 r_sa.attribute10(g_sa_pointer) := r_sa_tmp.attribute10(sa_recno);
11128 r_sa.acct_type(g_sa_pointer) := r_sa_tmp.acct_type(sa_recno);
11129 hr_utility.trace(' Stamped org suspense line between ' ||
11130 r_sa.start_date_active(g_sa_pointer) || ' AND ' || r_sa.end_date_active(g_sa_pointer));
11131 END LOOP;
11132 END IF;
11133
11134 IF (r_sa.end_date_active(g_sa_pointer) < g_enc_org_end_date) THEN
11135 FOR gsa_rec_no IN 1..r_gsa.line_account_id.COUNT
11136 LOOP
11137 IF r_gsa.end_date_active(gsa_rec_no) > r_sa_tmp.end_date_active(r_sa_tmp.end_date_active.COUNT) THEN
11138 g_sa_pointer := g_sa_pointer + 1;
11139 r_sa.line_account_id(g_sa_pointer) := r_gsa.line_account_id(gsa_rec_no);
11140 r_sa.gl_code_combination_id(g_sa_pointer) := r_gsa.gl_code_combination_id(gsa_rec_no);
11141 r_sa.project_id(g_sa_pointer) := r_gsa.project_id(gsa_rec_no);
11142 r_sa.task_id(g_sa_pointer) := r_gsa.task_id(gsa_rec_no);
11143 r_sa.award_id(g_sa_pointer) := r_gsa.award_id(gsa_rec_no);
11144 r_sa.expenditure_type(g_sa_pointer) := r_gsa.expenditure_type(gsa_rec_no);
11145 r_sa.expenditure_organization_id(g_sa_pointer) := r_gsa.expenditure_organization_id(gsa_rec_no);
11146 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);
11147 r_sa.end_date_active(g_sa_pointer) := LEAST(r_gsa.end_date_active(gsa_rec_no), g_enc_org_end_date);
11148 r_sa.poeta_start_date(g_sa_pointer) := r_gsa.poeta_start_date(gsa_rec_no);
11149 r_sa.poeta_end_date(g_sa_pointer) := r_gsa.poeta_end_date(gsa_rec_no);
11150 r_sa.percent(g_sa_pointer) := r_gsa.percent(gsa_rec_no);
11151 r_sa.attribute_category(g_sa_pointer) := r_gsa.attribute_category(gsa_rec_no);
11152 r_sa.attribute1(g_sa_pointer) := r_gsa.attribute1(gsa_rec_no);
11153 r_sa.attribute2(g_sa_pointer) := r_gsa.attribute2(gsa_rec_no);
11154 r_sa.attribute3(g_sa_pointer) := r_gsa.attribute3(gsa_rec_no);
11155 r_sa.attribute4(g_sa_pointer) := r_gsa.attribute4(gsa_rec_no);
11156 r_sa.attribute5(g_sa_pointer) := r_gsa.attribute5(gsa_rec_no);
11157 r_sa.attribute6(g_sa_pointer) := r_gsa.attribute6(gsa_rec_no);
11158 r_sa.attribute7(g_sa_pointer) := r_gsa.attribute7(gsa_rec_no);
11159 r_sa.attribute8(g_sa_pointer) := r_gsa.attribute8(gsa_rec_no);
11160 r_sa.attribute9(g_sa_pointer) := r_gsa.attribute9(gsa_rec_no);
11161 r_sa.attribute10(g_sa_pointer) := r_gsa.attribute10(gsa_rec_no);
11162 r_sa.acct_type(g_sa_pointer) := r_gsa.acct_type(gsa_rec_no);
11163 END IF;
11164 END LOOP;
11165 r_sa_tmp.line_account_id.DELETE;
11166 r_sa_tmp.gl_code_combination_id.DELETE;
11167 r_sa_tmp.project_id.DELETE;
11168 r_sa_tmp.task_id.DELETE;
11169 r_sa_tmp.award_id.DELETE;
11170 r_sa_tmp.expenditure_type.DELETE;
11171 r_sa_tmp.expenditure_organization_id.DELETE;
11172 r_sa_tmp.start_date_active.DELETE;
11173 r_sa_tmp.end_date_active.DELETE;
11174 r_sa_tmp.poeta_start_date.DELETE;
11175 r_sa_tmp.poeta_end_date.DELETE;
11176 r_sa_tmp.percent.DELETE;
11177 r_sa_tmp.attribute_category.DELETE;
11178 r_sa_tmp.attribute1.DELETE;
11179 r_sa_tmp.attribute2.DELETE;
11180 r_sa_tmp.attribute3.DELETE;
11181 r_sa_tmp.attribute4.DELETE;
11182 r_sa_tmp.attribute5.DELETE;
11183 r_sa_tmp.attribute6.DELETE;
11184 r_sa_tmp.attribute7.DELETE;
11185 r_sa_tmp.attribute8.DELETE;
11186 r_sa_tmp.attribute9.DELETE;
11187 r_sa_tmp.attribute10.DELETE;
11188 r_sa_tmp.acct_type.DELETE;
11189 END IF;
11190 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' r_sa.line_account_id.COUNT: ' || r_sa.line_account_id.COUNT);
11191 END IF;
11192
11193 r_gsa.line_account_id.DELETE;
11194 r_gsa.gl_code_combination_id.DELETE;
11195 r_gsa.project_id.DELETE;
11196 r_gsa.task_id.DELETE;
11197 r_gsa.award_id.DELETE;
11198 r_gsa.expenditure_type.DELETE;
11199 r_gsa.expenditure_organization_id.DELETE;
11200 r_gsa.start_date_active.DELETE;
11201 r_gsa.end_date_active.DELETE;
11202 r_gsa.poeta_start_date.DELETE;
11203 r_gsa.poeta_end_date.DELETE;
11204 r_gsa.percent.DELETE;
11205 r_gsa.attribute_category.DELETE;
11206 r_gsa.attribute1.DELETE;
11207 r_gsa.attribute2.DELETE;
11208 r_gsa.attribute3.DELETE;
11209 r_gsa.attribute4.DELETE;
11210 r_gsa.attribute5.DELETE;
11211 r_gsa.attribute6.DELETE;
11212 r_gsa.attribute7.DELETE;
11213 r_gsa.attribute8.DELETE;
11214 r_gsa.attribute9.DELETE;
11215 r_gsa.attribute10.DELETE;
11216 r_gsa.acct_type.DELETE;
11217
11218 g_pateo_end_date := fnd_date.canonical_to_date('1800/01/01 00:00:00');
11219
11220 hr_utility.trace('
11221 Global Element Hierarchy');
11222 hr_utility.trace(LPAD('Element Account Id', 18, ' ') || ' ' ||
11223 RPAD('Start Date Active', 17, ' ') || ' ' || RPAD('End Date Active', 17, ' ') || ' ' ||
11224 RPAD('PATEO Start Date', 17, ' ') || ' ' || RPAD('PATEO End Date', 17, ' ') || ' ' ||
11225 LPAD('GL CC Id', 15, ' ') || ' ' || LPAD('Project Id', 15, ' ') || ' ' ||
11226 LPAD('Task Id', 15, ' ') || ' ' || LPAD('Award Id', 15, ' ') || ' ' ||
11227 LPAD('Expenditure Org Id', 18, ' ') || ' ' || RPAD('Expenditure Type', 30, ' ') || ' ' ||
11228 LPAD('Percent', 10, ' '));
11229
11230 hr_utility.trace(LPAD('-', 18, '-') || ' ' ||
11231 RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
11232 RPAD('-', 17, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' ||
11233 LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 18, '-') || ' ' ||
11234 RPAD('-', 30, '-') || ' ' || LPAD('-', 10, '-'));
11235
11236 FOR recno IN 1..r_gee.line_account_id.COUNT
11237 LOOP
11238 hr_utility.trace(LPAD(r_gee.line_account_id(recno), 17, ' ') || ' ' ||
11239 RPAD(TO_CHAR(r_gee.start_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
11240 RPAD(TO_CHAR(r_gee.end_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
11241 RPAD(NVL(TO_CHAR(r_gee.poeta_start_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
11242 RPAD(NVL(TO_CHAR(r_gee.poeta_end_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
11243 LPAD(NVL(r_gee.gl_code_combination_id(recno), '-1'), 15, ' ') || ' ' ||
11244 LPAD(NVL(r_gee.project_id(recno), '-1'), 15, ' ') || ' ' ||
11245 LPAD(NVL(r_gee.task_id(recno), '-1'), 15, ' ') || ' ' ||
11246 LPAD(NVL(r_gee.award_id(recno), '-1'), 15, ' ') || ' ' ||
11247 LPAD(NVL(r_gee.expenditure_organization_id(recno), '-1'), 18, ' ') || ' ' ||
11248 RPAD(NVL(r_gee.expenditure_type(recno), ' '), 30, ' ') || ' ' ||
11249 LPAD(r_gee.percent(recno), 10, ' '));
11250
11251 IF (r_gee.expenditure_type(recno) IS NOT NULL) THEN
11252 psp_enc_pre_process.validate_poeta (p_project_id => r_gee.project_id(recno),
11253 p_task_id => r_gee.task_id(recno),
11254 p_award_id => r_gee.award_id(recno),
11255 p_expenditure_type => r_gee.expenditure_type(recno),
11256 p_expenditure_organization_id => r_gee.expenditure_organization_id(recno),
11257 p_payroll_id => p_payroll_id,
11258 p_start_date => r_gee.poeta_start_date(recno),
11259 p_end_date => r_gee.poeta_end_date(recno),
11260 p_return_status => p_return_status);
11261
11262 IF p_return_status <> fnd_api.g_ret_sts_success THEN
11263 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11264 END IF;
11265 END IF;
11266 g_pateo_end_date := GREATEST(g_pateo_end_date, NVL(r_gee.poeta_end_date(recno), g_pateo_end_date));
11267 END LOOP;
11268
11269 hr_utility.trace('
11270 Element Type Hierarchy');
11271 hr_utility.trace(LPAD('Schedule Line Id', 17, ' ') || ' ' ||
11272 RPAD('Start Date Active', 17, ' ') || ' ' || RPAD('End Date Active', 17, ' ') || ' ' ||
11273 RPAD('PATEO Start Date', 17, ' ') || ' ' || RPAD('PATEO End Date', 17, ' ') || ' ' ||
11274 LPAD('GL CC Id', 15, ' ') || ' ' || LPAD('Project Id', 15, ' ') || ' ' ||
11275 LPAD('Task Id', 15, ' ') || ' ' || LPAD('Award Id', 15, ' ') || ' ' ||
11276 LPAD('Expenditure Org Id', 18, ' ') || ' ' || RPAD('Expenditure Type', 30, ' ') || ' ' ||
11277 LPAD('Percent', 10, ' '));
11278
11279 hr_utility.trace(LPAD('-', 17, '-') || ' ' ||
11280 RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
11281 RPAD('-', 17, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' ||
11282 LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 18, '-') || ' ' ||
11283 RPAD('-', 30, '-') || ' ' || LPAD('-', 10, '-'));
11284
11285 FOR recno IN 1..r_et.line_account_id.COUNT
11286 LOOP
11287 hr_utility.trace(LPAD(r_et.line_account_id(recno), 17, ' ') || ' ' ||
11288 RPAD(TO_CHAR(r_et.start_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
11289 RPAD(TO_CHAR(r_et.end_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
11290 RPAD(NVL(TO_CHAR(r_et.poeta_start_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
11291 RPAD(NVL(TO_CHAR(r_et.poeta_end_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
11292 LPAD(NVL(r_et.gl_code_combination_id(recno), '-1'), 15, ' ') || ' ' ||
11293 LPAD(NVL(r_et.project_id(recno), '-1'), 15, ' ') || ' ' ||
11294 LPAD(NVL(r_et.task_id(recno), '-1'), 15, ' ') || ' ' ||
11295 LPAD(NVL(r_et.award_id(recno), '-1'), 15, ' ') || ' ' ||
11296 LPAD(NVL(r_et.expenditure_organization_id(recno), '-1'), 18, ' ') || ' ' ||
11297 RPAD(NVL(r_et.expenditure_type(recno), ' '), 30, ' ') || ' ' ||
11298 LPAD(r_et.percent(recno), 10, ' '));
11299 IF (r_et.expenditure_type(recno) IS NOT NULL) THEN
11300 psp_enc_pre_process.validate_poeta (p_project_id => r_et.project_id(recno),
11301 p_task_id => r_et.task_id(recno),
11302 p_award_id => r_et.award_id(recno),
11303 p_expenditure_type => r_et.expenditure_type(recno),
11304 p_expenditure_organization_id => r_et.expenditure_organization_id(recno),
11305 p_payroll_id => p_payroll_id,
11306 p_start_date => r_et.poeta_start_date(recno),
11307 p_end_date => r_et.poeta_end_date(recno),
11308 p_return_status => p_return_status);
11309
11310 IF p_return_status <> fnd_api.g_ret_sts_success THEN
11311 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11312 END IF;
11313 END IF;
11314 g_pateo_end_date := GREATEST(g_pateo_end_date, NVL(r_et.poeta_end_date(recno), g_pateo_end_date));
11315 END LOOP;
11316
11317 hr_utility.trace('
11318 Element Class Hierarchy');
11319 hr_utility.trace(LPAD('Schedule Line Id', 17, ' ') || ' ' ||
11320 RPAD('Start Date Active', 17, ' ') || ' ' || RPAD('End Date Active', 17, ' ') || ' ' ||
11321 RPAD('PATEO Start Date', 17, ' ') || ' ' || RPAD('PATEO End Date', 17, ' ') || ' ' ||
11322 LPAD('GL CC Id', 15, ' ') || ' ' || LPAD('Project Id', 15, ' ') || ' ' ||
11323 LPAD('Task Id', 15, ' ') || ' ' || LPAD('Award Id', 15, ' ') || ' ' ||
11324 LPAD('Expenditure Org Id', 18, ' ') || ' ' || RPAD('Expenditure Type', 30, ' ') || ' ' ||
11325 LPAD('Percent', 10, ' '));
11326
11327 hr_utility.trace(LPAD('-', 17, '-') || ' ' ||
11328 RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
11329 RPAD('-', 17, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' ||
11330 LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 18, '-') || ' ' ||
11331 RPAD('-', 30, '-') || ' ' || LPAD('-', 10, '-'));
11332
11333 FOR recno IN 1..r_ec.line_account_id.COUNT
11334 LOOP
11335 hr_utility.trace(LPAD(r_ec.line_account_id(recno), 17, ' ') || ' ' ||
11336 RPAD(TO_CHAR(r_ec.start_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
11337 RPAD(TO_CHAR(r_ec.end_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
11338 RPAD(NVL(TO_CHAR(r_ec.poeta_start_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
11339 RPAD(NVL(TO_CHAR(r_ec.poeta_end_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
11340 LPAD(NVL(r_ec.gl_code_combination_id(recno), '-1'), 15, ' ') || ' ' ||
11341 LPAD(NVL(r_ec.project_id(recno), '-1'), 15, ' ') || ' ' ||
11342 LPAD(NVL(r_ec.task_id(recno), '-1'), 15, ' ') || ' ' ||
11343 LPAD(NVL(r_ec.award_id(recno), '-1'), 15, ' ') || ' ' ||
11344 LPAD(NVL(r_ec.expenditure_organization_id(recno), '-1'), 18, ' ') || ' ' ||
11345 RPAD(NVL(r_ec.expenditure_type(recno), ' '), 30, ' ') || ' ' ||
11346 LPAD(r_ec.percent(recno), 10, ' '));
11347 IF (r_ec.expenditure_type(recno) IS NOT NULL) THEN
11348 psp_enc_pre_process.validate_poeta (p_project_id => r_ec.project_id(recno),
11349 p_task_id => r_ec.task_id(recno),
11350 p_award_id => r_ec.award_id(recno),
11351 p_expenditure_type => r_ec.expenditure_type(recno),
11352 p_expenditure_organization_id => r_ec.expenditure_organization_id(recno),
11353 p_payroll_id => p_payroll_id,
11354 p_start_date => r_ec.poeta_start_date(recno),
11355 p_end_date => r_ec.poeta_end_date(recno),
11356 p_return_status => p_return_status);
11357
11358 IF p_return_status <> fnd_api.g_ret_sts_success THEN
11359 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11360 END IF;
11361 END IF;
11362 g_pateo_end_date := GREATEST(g_pateo_end_date, NVL(r_ec.poeta_end_date(recno), g_pateo_end_date));
11363 END LOOP;
11364
11365 hr_utility.trace('
11366 Assignment Hierarchy');
11367 hr_utility.trace(LPAD('Schedule Line Id', 17, ' ') || ' ' ||
11368 RPAD('Start Date Active', 17, ' ') || ' ' || RPAD('End Date Active', 17, ' ') || ' ' ||
11369 RPAD('PATEO Start Date', 17, ' ') || ' ' || RPAD('PATEO End Date', 17, ' ') || ' ' ||
11370 LPAD('GL CC Id', 15, ' ') || ' ' || LPAD('Project Id', 15, ' ') || ' ' ||
11371 LPAD('Task Id', 15, ' ') || ' ' || LPAD('Award Id', 15, ' ') || ' ' ||
11372 LPAD('Expenditure Org Id', 18, ' ') || ' ' || RPAD('Expenditure Type', 30, ' ') || ' ' ||
11373 LPAD('Percent', 10, ' '));
11374
11375 hr_utility.trace(LPAD('-', 17, '-') || ' ' ||
11376 RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
11377 RPAD('-', 17, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' ||
11378 LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 18, '-') || ' ' ||
11379 RPAD('-', 30, '-') || ' ' || LPAD('-', 10, '-'));
11380
11381 FOR recno IN 1..r_asg.line_account_id.COUNT
11382 LOOP
11383 hr_utility.trace(LPAD(r_asg.line_account_id(recno), 17, ' ') || ' ' ||
11384 RPAD(TO_CHAR(r_asg.start_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
11385 RPAD(TO_CHAR(r_asg.end_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
11386 RPAD(NVL(TO_CHAR(r_asg.poeta_start_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
11387 RPAD(NVL(TO_CHAR(r_asg.poeta_end_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
11388 LPAD(NVL(r_asg.gl_code_combination_id(recno), '-1'), 15, ' ') || ' ' ||
11389 LPAD(NVL(r_asg.project_id(recno), '-1'), 15, ' ') || ' ' ||
11390 LPAD(NVL(r_asg.task_id(recno), '-1'), 15, ' ') || ' ' ||
11391 LPAD(NVL(r_asg.award_id(recno), '-1'), 15, ' ') || ' ' ||
11392 LPAD(NVL(r_asg.expenditure_organization_id(recno), '-1'), 18, ' ') || ' ' ||
11393 RPAD(NVL(r_asg.expenditure_type(recno), ' '), 30, ' ') || ' ' ||
11394 LPAD(r_asg.percent(recno), 10, ' '));
11395 IF (r_asg.expenditure_type(recno) IS NOT NULL) THEN
11396 psp_enc_pre_process.validate_poeta (p_project_id => r_asg.project_id(recno),
11397 p_task_id => r_asg.task_id(recno),
11398 p_award_id => r_asg.award_id(recno),
11399 p_expenditure_type => r_asg.expenditure_type(recno),
11400 p_expenditure_organization_id => r_asg.expenditure_organization_id(recno),
11401 p_payroll_id => p_payroll_id,
11402 p_start_date => r_asg.poeta_start_date(recno),
11403 p_end_date => r_asg.poeta_end_date(recno),
11404 p_return_status => p_return_status);
11405
11406 IF p_return_status <> fnd_api.g_ret_sts_success THEN
11407 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11408 END IF;
11409 END IF;
11410 g_pateo_end_date := GREATEST(g_pateo_end_date, NVL(r_asg.poeta_end_date(recno), g_pateo_end_date));
11411 END LOOP;
11412
11413 hr_utility.trace('
11414 Organization Default Schedules Hierarchy');
11415 hr_utility.trace(LPAD('Schedule Line Id', 17, ' ') || ' ' ||
11416 RPAD('Start Date Active', 17, ' ') || ' ' || RPAD('End Date Active', 17, ' ') || ' ' ||
11417 RPAD('PATEO Start Date', 17, ' ') || ' ' || RPAD('PATEO End Date', 17, ' ') || ' ' ||
11418 LPAD('GL CC Id', 15, ' ') || ' ' || LPAD('Project Id', 15, ' ') || ' ' ||
11419 LPAD('Task Id', 15, ' ') || ' ' || LPAD('Award Id', 15, ' ') || ' ' ||
11420 LPAD('Expenditure Org Id', 18, ' ') || ' ' || RPAD('Expenditure Type', 30, ' ') || ' ' ||
11421 LPAD('Percent', 10, ' '));
11422
11423 hr_utility.trace(LPAD('-', 17, '-') || ' ' ||
11424 RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
11425 RPAD('-', 17, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' ||
11426 LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 18, '-') || ' ' ||
11427 RPAD('-', 30, '-') || ' ' || LPAD('-', 10, '-'));
11428
11429 FOR recno IN 1..r_odls.line_account_id.COUNT
11430 LOOP
11431 hr_utility.trace(LPAD(r_odls.line_account_id(recno), 17, ' ') || ' ' ||
11432 RPAD(TO_CHAR(r_odls.start_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
11433 RPAD(TO_CHAR(r_odls.end_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
11434 RPAD(NVL(TO_CHAR(r_odls.poeta_start_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
11435 RPAD(NVL(TO_CHAR(r_odls.poeta_end_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
11436 LPAD(NVL(r_odls.gl_code_combination_id(recno), '-1'), 15, ' ') || ' ' ||
11437 LPAD(NVL(r_odls.project_id(recno), '-1'), 15, ' ') || ' ' ||
11438 LPAD(NVL(r_odls.task_id(recno), '-1'), 15, ' ') || ' ' ||
11439 LPAD(NVL(r_odls.award_id(recno), '-1'), 15, ' ') || ' ' ||
11440 LPAD(NVL(r_odls.expenditure_organization_id(recno), '-1'), 18, ' ') || ' ' ||
11441 RPAD(NVL(r_odls.expenditure_type(recno), ' '), 30, ' ') || ' ' ||
11442 LPAD(r_odls.percent(recno), 10, ' '));
11443 IF (r_odls.expenditure_type(recno) IS NOT NULL) THEN
11444 psp_enc_pre_process.validate_poeta (p_project_id => r_odls.project_id(recno),
11445 p_task_id => r_odls.task_id(recno),
11446 p_award_id => r_odls.award_id(recno),
11447 p_expenditure_type => r_odls.expenditure_type(recno),
11448 p_expenditure_organization_id => r_odls.expenditure_organization_id(recno),
11449 p_payroll_id => p_payroll_id,
11450 p_start_date => r_odls.poeta_start_date(recno),
11451 p_end_date => r_odls.poeta_end_date(recno),
11452 p_return_status => p_return_status);
11453
11454 IF p_return_status <> fnd_api.g_ret_sts_success THEN
11455 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11456 END IF;
11457 END IF;
11458 g_pateo_end_date := GREATEST(g_pateo_end_date, NVL(r_odls.poeta_end_date(recno), g_pateo_end_date));
11459 END LOOP;
11460
11461 hr_utility.trace('
11462 Organization Default Account Hierarchy');
11463 hr_utility.trace(LPAD('Line Account Id', 17, ' ') || ' ' ||
11464 RPAD('Start Date Active', 17, ' ') || ' ' || RPAD('End Date Active', 17, ' ') || ' ' ||
11465 RPAD('PATEO Start Date', 17, ' ') || ' ' || RPAD('PATEO End Date', 17, ' ') || ' ' ||
11466 LPAD('GL CC Id', 15, ' ') || ' ' || LPAD('Project Id', 15, ' ') || ' ' ||
11467 LPAD('Task Id', 15, ' ') || ' ' || LPAD('Award Id', 15, ' ') || ' ' ||
11468 LPAD('Expenditure Org Id', 18, ' ') || ' ' || RPAD('Expenditure Type', 30, ' ') || ' ' ||
11469 LPAD('Percent', 10, ' '));
11470
11471 hr_utility.trace(LPAD('-', 17, '-') || ' ' ||
11472 RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
11473 RPAD('-', 17, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' ||
11474 LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 18, '-') || ' ' ||
11475 RPAD('-', 30, '-') || ' ' || LPAD('-', 10, '-'));
11476
11477 FOR recno IN 1..r_da.line_account_id.COUNT
11478 LOOP
11479 hr_utility.trace(LPAD(r_da.line_account_id(recno), 17, ' ') || ' ' ||
11480 RPAD(TO_CHAR(r_da.start_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
11481 RPAD(TO_CHAR(r_da.end_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
11482 RPAD(NVL(TO_CHAR(r_da.poeta_start_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
11483 RPAD(NVL(TO_CHAR(r_da.poeta_end_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
11484 LPAD(NVL(r_da.gl_code_combination_id(recno), '-1'), 15, ' ') || ' ' ||
11485 LPAD(NVL(r_da.project_id(recno), '-1'), 15, ' ') || ' ' ||
11486 LPAD(NVL(r_da.task_id(recno), '-1'), 15, ' ') || ' ' ||
11487 LPAD(NVL(r_da.award_id(recno), '-1'), 15, ' ') || ' ' ||
11488 LPAD(NVL(r_da.expenditure_organization_id(recno), '-1'), 18, ' ') || ' ' ||
11489 RPAD(NVL(r_da.expenditure_type(recno), ' '), 30, ' ') || ' ' ||
11490 LPAD(r_da.percent(recno), 10, ' '));
11491 IF (r_da.expenditure_type(recno) IS NOT NULL) THEN
11492 psp_enc_pre_process.validate_poeta (p_project_id => r_da.project_id(recno),
11493 p_task_id => r_da.task_id(recno),
11494 p_award_id => r_da.award_id(recno),
11495 p_expenditure_type => r_da.expenditure_type(recno),
11496 p_expenditure_organization_id => r_da.expenditure_organization_id(recno),
11497 p_payroll_id => p_payroll_id,
11498 p_start_date => r_da.poeta_start_date(recno),
11499 p_end_date => r_da.poeta_end_date(recno),
11500 p_return_status => p_return_status);
11501
11502 IF p_return_status <> fnd_api.g_ret_sts_success THEN
11503 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11504 END IF;
11505 END IF;
11506 g_pateo_end_date := GREATEST(g_pateo_end_date, NVL(r_da.poeta_end_date(recno), g_pateo_end_date));
11507 END LOOP;
11508
11509 hr_utility.trace('
11510 Suspense Account Hierarchy');
11511 hr_utility.trace(LPAD('Line Account Id', 17, ' ') || ' ' ||
11512 RPAD('Start Date Active', 17, ' ') || ' ' || RPAD('End Date Active', 17, ' ') || ' ' ||
11513 RPAD('PATEO Start Date', 17, ' ') || ' ' || RPAD('PATEO End Date', 17, ' ') || ' ' ||
11514 LPAD('GL CC Id', 15, ' ') || ' ' || LPAD('Project Id', 15, ' ') || ' ' ||
11515 LPAD('Task Id', 15, ' ') || ' ' || LPAD('Award Id', 15, ' ') || ' ' ||
11516 LPAD('Expenditure Org Id', 18, ' ') || ' ' || RPAD('Expenditure Type', 30, ' ') || ' ' ||
11517 LPAD('Percent', 10, ' '));
11518
11519 hr_utility.trace(LPAD('-', 17, '-') || ' ' ||
11520 RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' || RPAD('-', 17, '-') || ' ' ||
11521 RPAD('-', 17, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' ||
11522 LPAD('-', 15, '-') || ' ' || LPAD('-', 15, '-') || ' ' || LPAD('-', 18, '-') || ' ' ||
11523 RPAD('-', 30, '-') || ' ' || LPAD('-', 10, '-'));
11524
11525 FOR recno IN 1..r_sa.line_account_id.COUNT
11526 LOOP
11527 hr_utility.trace(LPAD(r_sa.line_account_id(recno), 17, ' ') || ' ' ||
11528 RPAD(TO_CHAR(r_sa.start_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
11529 RPAD(TO_CHAR(r_sa.end_date_active(recno), 'DD-MON-RRRR'), 17, ' ') || ' ' ||
11530 RPAD(NVL(TO_CHAR(r_sa.poeta_start_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
11531 RPAD(NVL(TO_CHAR(r_sa.poeta_end_date(recno), 'DD-MON-RRRR'), ' '), 17, ' ') || ' ' ||
11532 LPAD(NVL(r_sa.gl_code_combination_id(recno), '-1'), 15, ' ') || ' ' ||
11533 LPAD(NVL(r_sa.project_id(recno), '-1'), 15, ' ') || ' ' ||
11534 LPAD(NVL(r_sa.task_id(recno), '-1'), 15, ' ') || ' ' ||
11535 LPAD(NVL(r_sa.award_id(recno), '-1'), 15, ' ') || ' ' ||
11536 LPAD(NVL(r_sa.expenditure_organization_id(recno), '-1'), 18, ' ') || ' ' ||
11537 RPAD(NVL(r_sa.expenditure_type(recno), ' '), 30, ' ') || ' ' ||
11538 LPAD(r_sa.percent(recno), 10, ' '));
11539 IF (r_sa.expenditure_type(recno) IS NOT NULL) THEN
11540 psp_enc_pre_process.validate_poeta (p_project_id => r_sa.project_id(recno),
11541 p_task_id => r_sa.task_id(recno),
11542 p_award_id => r_sa.award_id(recno),
11543 p_expenditure_type => r_sa.expenditure_type(recno),
11544 p_expenditure_organization_id => r_sa.expenditure_organization_id(recno),
11545 p_payroll_id => p_payroll_id,
11546 p_start_date => r_sa.poeta_start_date(recno),
11547 p_end_date => r_sa.poeta_end_date(recno),
11548 p_return_status => p_return_status);
11549
11550 IF p_return_status <> fnd_api.g_ret_sts_success THEN
11551 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
11552 END IF;
11553 END IF;
11554 g_pateo_end_date := GREATEST(g_pateo_end_date, NVL(r_sa.poeta_end_date(recno), g_pateo_end_date));
11555 END LOOP;
11556
11557 IF ((g_pateo_end_date = fnd_date.canonical_to_date('1800/01/01 00:00:00')) OR
11558 (g_pateo_end_date < g_enc_org_end_date)) THEN
11559 g_pateo_end_date := g_enc_org_end_date;
11560 END IF;
11561 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' g_pateo_end_date: ' || TO_CHAR(g_pateo_end_date, 'DD-MON-RRRR'));
11562
11563 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving LOAD_SCH_HIERARCHY');
11564 p_return_status := fnd_api.g_ret_sts_success;
11565 EXCEPTION
11566 WHEN OTHERS THEN
11567 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
11568 IF (g_error_message IS NULL) THEN
11569 g_error_message := 'LOAD_SCH_HIERARCHY: ' || SQLERRM;
11570 END IF;
11571 g_error_api_path := SUBSTR(' LOAD_SCH_HIERARCHY:'||g_error_api_path,1,230);
11572 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', ' LOAD_SCH_HIERARCHY');
11573 p_return_status := fnd_api.g_ret_sts_unexp_error;
11574 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' ' || fnd_number.number_to_canonical(l_proc_step) || ': LOAD_SCH_HIERARCHY');
11575 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving LOAD_SCH_HIERARCHY');
11576 END load_sch_hierarchy;
11577
11578 PROCEDURE add_cel_warnings(p_start_date IN DATE DEFAULT NULL,
11579 p_end_date IN DATE DEFAULT NULL,
11580 p_hierarchy_code IN VARCHAR2 DEFAULT NULL,
11581 p_warning_code IN VARCHAR2 DEFAULT NULL,
11582 p_gl_ccid IN NUMBER DEFAULT NULL,
11583 p_project_id IN NUMBER DEFAULT NULL,
11584 p_task_id IN NUMBER DEFAULT NULL,
11585 p_award_id IN NUMBER DEFAULT NULL,
11586 p_exp_org_id IN NUMBER DEFAULT NULL,
11587 p_exp_type IN VARCHAR2 DEFAULT NULL,
11588 p_effective_date IN DATE DEFAULT NULL,
11589 p_error_status IN VARCHAR2 DEFAULT NULL,
11590 p_percent IN NUMBER DEFAULT NULL) IS
11591 l_warning_ind NUMBER(15);
11592 l_duplicate_ind NUMBER(15);
11593 BEGIN
11594 hr_utility.trace('Entering add_cel_warnings');
11595 l_warning_ind := cel_warnings.start_date.COUNT;
11596 hr_utility.trace('p_start_date: ' || p_start_date || ' p_end_date: ' || p_end_date ||
11597 ' p_hierarchy_code: ' || p_hierarchy_code || ' p_warning_code: ' || p_warning_code ||
11598 ' p_gl_ccid: ' || p_gl_ccid || ' p_project_id: ' || p_project_id || ' p_task_id: ' || p_task_id ||
11599 ' p_award_id:' || p_award_id || ' p_exp_org_id: ' || p_exp_org_id ||
11600 ' p_exp_type: ' || p_exp_type || ' p_effective_date: ' || p_effective_date ||
11601 ' p_error_status: ' || p_error_status || ' p_percent: ' || p_percent);
11602
11603 IF (p_warning_code = 'BAL') THEN
11604 LOOP
11605 EXIT WHEN l_warning_ind = 0;
11606 EXIT WHEN (( (cel_warnings.end_date(l_warning_ind) = (p_start_date -1) OR
11607 ( (cel_warnings.end_date(l_warning_ind) >= p_start_date) AND
11608 (cel_warnings.start_date(l_warning_ind) <= p_end_date)))) AND
11609 (cel_warnings.hierarchy_code(l_warning_ind) = p_hierarchy_code) AND
11610 (cel_warnings.warning_code(l_warning_ind) = 'BAL') AND
11611 (cel_warnings.percent(l_warning_ind) = p_percent));
11612 l_warning_ind := l_warning_ind - 1;
11613 END LOOP;
11614 hr_utility.trace('processing bal l_warning_ind: ' || l_warning_ind);
11615
11616 l_duplicate_ind := cel_warnings.start_date.COUNT;
11617 LOOP
11618 EXIT WHEN l_duplicate_ind = 0;
11619 EXIT WHEN (( (cel_warnings.end_date(l_duplicate_ind) = (p_start_date -1) OR
11620 ( (cel_warnings.end_date(l_duplicate_ind) >= p_start_date) AND
11621 (cel_warnings.start_date(l_duplicate_ind) <= p_end_date)))) AND
11622 (cel_warnings.hierarchy_code(l_duplicate_ind) <> p_hierarchy_code) AND
11623 (cel_warnings.warning_code(l_duplicate_ind) = 'BAL') AND
11624 (cel_warnings.percent(l_duplicate_ind) = p_percent));
11625 l_duplicate_ind := l_duplicate_ind - 1;
11626 END LOOP;
11627 hr_utility.trace('processing bal l_duplicate_ind: ' || l_duplicate_ind);
11628
11629 IF (l_warning_ind = 0) THEN
11630 l_warning_ind := cel_warnings.start_date.COUNT + 1;
11631 cel_warnings.start_date(l_warning_ind) := p_start_date;
11632 cel_warnings.end_date(l_warning_ind) := p_end_date;
11633 cel_warnings.hierarchy_code(l_warning_ind) := p_hierarchy_code;
11634 cel_warnings.warning_code(l_warning_ind) := p_warning_code;
11635 cel_warnings.gl_ccid(l_warning_ind) := NULL;
11636 cel_warnings.project_id(l_warning_ind) := NULL;
11637 cel_warnings.task_id(l_warning_ind) := NULL;
11638 cel_warnings.award_id(l_warning_ind) := NULL;
11639 cel_warnings.exp_org_id(l_warning_ind) := NULL;
11640 cel_warnings.exp_type(l_warning_ind) := NULL;
11641 cel_warnings.effective_date(l_warning_ind) := NULL;
11642 cel_warnings.error_status(l_warning_ind) := NULL;
11643 cel_warnings.percent(l_warning_ind) := p_percent;
11644 ELSE
11645 cel_warnings.end_date(l_warning_ind) := p_end_date;
11646 END IF;
11647
11648 IF (l_duplicate_ind > 0) THEN
11649 cel_warnings.end_date(l_duplicate_ind) := p_end_date;
11650 cel_warnings.start_date(l_warning_ind) := cel_warnings.start_date(l_duplicate_ind);
11651 END IF;
11652 ELSIF (p_warning_code = 'NO_CI') THEN
11653 LOOP
11654 EXIT WHEN l_warning_ind = 0;
11655 EXIT WHEN (( (cel_warnings.end_date(l_warning_ind) = (p_start_date -1) OR
11656 ( (cel_warnings.end_date(l_warning_ind) >= p_start_date) AND
11657 (cel_warnings.start_date(l_warning_ind) <= p_end_date)))) AND
11658 (cel_warnings.hierarchy_code(l_warning_ind) = p_hierarchy_code) AND
11659 (cel_warnings.warning_code(l_warning_ind) = 'NO_CI'));
11660 l_warning_ind := l_warning_ind - 1;
11661 END LOOP;
11662 hr_utility.trace('processing no_ci l_warning_ind: ' || l_warning_ind);
11663
11664 l_duplicate_ind := cel_warnings.start_date.COUNT;
11665 LOOP
11666 EXIT WHEN l_duplicate_ind = 0;
11667 EXIT WHEN (( (cel_warnings.end_date(l_duplicate_ind) = (p_start_date -1) OR
11668 ( (cel_warnings.end_date(l_duplicate_ind) >= p_start_date) AND
11669 (cel_warnings.start_date(l_duplicate_ind) <= p_end_date)))) AND
11670 (cel_warnings.hierarchy_code(l_duplicate_ind) <> p_hierarchy_code) AND
11671 (cel_warnings.warning_code(l_duplicate_ind) = 'NO_CI'));
11672 l_duplicate_ind := l_duplicate_ind - 1;
11673 END LOOP;
11674 hr_utility.trace('processing no_ci l_duplicate_ind: ' || l_duplicate_ind);
11675
11676 IF (l_warning_ind = 0) THEN
11677 l_warning_ind := cel_warnings.start_date.COUNT + 1;
11678 cel_warnings.start_date(l_warning_ind) := p_start_date;
11679 cel_warnings.end_date(l_warning_ind) := p_end_date;
11680 cel_warnings.hierarchy_code(l_warning_ind) := p_hierarchy_code;
11681 cel_warnings.warning_code(l_warning_ind) := p_warning_code;
11682 cel_warnings.gl_ccid(l_warning_ind) := NULL;
11683 cel_warnings.project_id(l_warning_ind) := NULL;
11684 cel_warnings.task_id(l_warning_ind) := NULL;
11685 cel_warnings.award_id(l_warning_ind) := NULL;
11686 cel_warnings.exp_org_id(l_warning_ind) := NULL;
11687 cel_warnings.exp_type(l_warning_ind) := NULL;
11688 cel_warnings.effective_date(l_warning_ind) := NULL;
11689 cel_warnings.error_status(l_warning_ind) := NULL;
11690 cel_warnings.percent(l_warning_ind) := NULL;
11691 ELSE
11692 cel_warnings.end_date(l_warning_ind) := p_end_date;
11693 END IF;
11694
11695 IF (l_duplicate_ind > 0) THEN
11696 cel_warnings.end_date(l_duplicate_ind) := p_end_date;
11697 cel_warnings.start_date(l_warning_ind) := cel_warnings.start_date(l_duplicate_ind);
11698 END IF;
11699 ELSIF (p_warning_code = 'INVALID_CI') THEN
11700 LOOP
11701 EXIT WHEN l_warning_ind = 0;
11702 EXIT WHEN (( (cel_warnings.end_date(l_warning_ind) = (p_start_date -1) OR
11703 ( (cel_warnings.end_date(l_warning_ind) >= p_start_date) AND
11704 (cel_warnings.start_date(l_warning_ind) <= p_end_date)))) AND
11705 (cel_warnings.hierarchy_code(l_warning_ind) = p_hierarchy_code) AND
11706 (cel_warnings.warning_code(l_warning_ind) = 'INVALID_CI') AND
11707 (cel_warnings.project_id(l_warning_ind) = p_project_id) AND
11708 (cel_warnings.task_id(l_warning_ind) = p_task_id) AND
11709 (cel_warnings.award_id(l_warning_ind) = p_award_id) AND
11710 (cel_warnings.exp_org_id(l_warning_ind) = p_exp_org_id) AND
11711 (cel_warnings.exp_type(l_warning_ind) = p_exp_type) AND
11712 (NVL(cel_warnings.error_status(l_warning_ind), 'NULL') = NVL(p_error_status, 'NULL')));
11713 l_warning_ind := l_warning_ind - 1;
11714 END LOOP;
11715 hr_utility.trace('processing invalid_ci l_warning_ind: ' || l_warning_ind);
11716
11717 IF (l_warning_ind = 0) THEN
11718 l_warning_ind := cel_warnings.start_date.COUNT + 1;
11719 cel_warnings.start_date(l_warning_ind) := p_start_date;
11720 cel_warnings.end_date(l_warning_ind) := p_end_date;
11721 cel_warnings.hierarchy_code(l_warning_ind) := p_hierarchy_code;
11722 cel_warnings.warning_code(l_warning_ind) := p_warning_code;
11723 cel_warnings.gl_ccid(l_warning_ind) := NULL;
11724 cel_warnings.project_id(l_warning_ind) := p_project_id;
11725 cel_warnings.task_id(l_warning_ind) := p_task_id;
11726 cel_warnings.award_id(l_warning_ind) := p_award_id;
11727 cel_warnings.exp_org_id(l_warning_ind) := p_exp_org_id;
11728 cel_warnings.exp_type(l_warning_ind) := p_exp_type;
11729 cel_warnings.effective_date(l_warning_ind) := p_effective_date;
11730 cel_warnings.error_status(l_warning_ind) := p_error_status;
11731 cel_warnings.percent(l_warning_ind) := NULL;
11732 ELSE
11733 cel_warnings.end_date(l_warning_ind) := p_end_date;
11734 END IF;
11735 ELSIF (p_warning_code = 'AUTOPOP') AND (p_gl_ccid IS NOT NULL) THEN
11736 LOOP
11737 EXIT WHEN l_warning_ind = 0;
11738 EXIT WHEN (( (cel_warnings.end_date(l_warning_ind) = (p_start_date -1) OR
11739 ( (cel_warnings.end_date(l_warning_ind) >= p_start_date) AND
11740 (cel_warnings.start_date(l_warning_ind) <= p_end_date)))) AND
11741 (cel_warnings.hierarchy_code(l_warning_ind) = p_hierarchy_code) AND
11742 (cel_warnings.warning_code(l_warning_ind) = 'AUTOPOP') AND
11743 (cel_warnings.gl_ccid(l_warning_ind) = p_gl_ccid) AND
11744 (NVL(cel_warnings.error_status(l_warning_ind), 'NULL') = NVL(p_error_status, 'NULL')));
11745 l_warning_ind := l_warning_ind - 1;
11746 END LOOP;
11747 hr_utility.trace('processing autopop l_warning_ind: ' || l_warning_ind);
11748
11749 IF (l_warning_ind = 0) THEN
11750 l_warning_ind := cel_warnings.start_date.COUNT + 1;
11751 cel_warnings.start_date(l_warning_ind) := p_start_date;
11752 cel_warnings.end_date(l_warning_ind) := p_end_date;
11753 cel_warnings.hierarchy_code(l_warning_ind) := p_hierarchy_code;
11754 cel_warnings.warning_code(l_warning_ind) := p_warning_code;
11755 cel_warnings.gl_ccid(l_warning_ind) := p_gl_ccid;
11756 cel_warnings.project_id(l_warning_ind) := NULL;
11757 cel_warnings.task_id(l_warning_ind) := NULL;
11758 cel_warnings.award_id(l_warning_ind) := NULL;
11759 cel_warnings.exp_org_id(l_warning_ind) := NULL;
11760 cel_warnings.exp_type(l_warning_ind) := NULL;
11761 cel_warnings.effective_date(l_warning_ind) := NULL;
11762 cel_warnings.error_status(l_warning_ind) := p_error_status;
11763 cel_warnings.percent(l_warning_ind) := NULL;
11764 ELSE
11765 cel_warnings.end_date(l_warning_ind) := p_end_date;
11766 END IF;
11767 ELSIF (p_warning_code = 'AUTOPOP') AND (p_gl_ccid IS NULL) THEN
11768 LOOP
11769 EXIT WHEN l_warning_ind = 0;
11770 EXIT WHEN (( (cel_warnings.end_date(l_warning_ind) = (p_start_date -1) OR
11771 ( (cel_warnings.end_date(l_warning_ind) >= p_start_date) AND
11772 (cel_warnings.start_date(l_warning_ind) <= p_end_date)))) AND
11773 (cel_warnings.hierarchy_code(l_warning_ind) = p_hierarchy_code) AND
11774 (cel_warnings.warning_code(l_warning_ind) = 'AUTOPOP') AND
11775 (cel_warnings.project_id(l_warning_ind) = p_project_id) AND
11776 (cel_warnings.task_id(l_warning_ind) = p_task_id) AND
11777 (cel_warnings.award_id(l_warning_ind) = p_award_id) AND
11778 (cel_warnings.exp_org_id(l_warning_ind) = p_exp_org_id) AND
11779 (cel_warnings.exp_type(l_warning_ind) = p_exp_type) AND
11780 (NVL(cel_warnings.error_status(l_warning_ind), 'NULL') = NVL(p_error_status, 'NULL')));
11781 l_warning_ind := l_warning_ind - 1;
11782 END LOOP;
11783 hr_utility.trace('processing autopop l_warning_ind: ' || l_warning_ind);
11784
11785 IF (l_warning_ind = 0) THEN
11786 l_warning_ind := cel_warnings.start_date.COUNT + 1;
11787 cel_warnings.start_date(l_warning_ind) := p_start_date;
11788 cel_warnings.end_date(l_warning_ind) := p_end_date;
11789 cel_warnings.hierarchy_code(l_warning_ind) := p_hierarchy_code;
11790 cel_warnings.warning_code(l_warning_ind) := p_warning_code;
11791 cel_warnings.gl_ccid(l_warning_ind) := NULL;
11792 cel_warnings.project_id(l_warning_ind) := p_project_id;
11793 cel_warnings.task_id(l_warning_ind) := p_task_id;
11794 cel_warnings.award_id(l_warning_ind) := p_award_id;
11795 cel_warnings.exp_org_id(l_warning_ind) := p_exp_org_id;
11796 cel_warnings.exp_type(l_warning_ind) := p_exp_type;
11797 cel_warnings.effective_date(l_warning_ind) := NULL;
11798 cel_warnings.error_status(l_warning_ind) := p_error_status;
11799 cel_warnings.percent(l_warning_ind) := NULL;
11800 ELSE
11801 cel_warnings.end_date(l_warning_ind) := p_end_date;
11802 END IF;
11803 ELSIF (p_warning_code = 'GL') THEN
11804 LOOP
11805 EXIT WHEN l_warning_ind = 0;
11806 EXIT WHEN (( (cel_warnings.end_date(l_warning_ind) = (p_start_date -1) OR
11807 ( (cel_warnings.end_date(l_warning_ind) >= p_start_date) AND
11808 (cel_warnings.start_date(l_warning_ind) <= p_end_date)))) AND
11809 (cel_warnings.hierarchy_code(l_warning_ind) = p_hierarchy_code) AND
11810 (cel_warnings.warning_code(l_warning_ind) = 'GL'));
11811 l_warning_ind := l_warning_ind - 1;
11812 END LOOP;
11813 hr_utility.trace('processing bal l_warning_ind: ' || l_warning_ind);
11814
11815 l_duplicate_ind := cel_warnings.start_date.COUNT;
11816 LOOP
11817 EXIT WHEN l_duplicate_ind = 0;
11818 EXIT WHEN (( (cel_warnings.end_date(l_duplicate_ind) = (p_start_date -1) OR
11819 ( (cel_warnings.end_date(l_duplicate_ind) >= p_start_date) AND
11820 (cel_warnings.start_date(l_duplicate_ind) <= p_end_date)))) AND
11821 (cel_warnings.hierarchy_code(l_duplicate_ind) <> p_hierarchy_code) AND
11822 (cel_warnings.warning_code(l_duplicate_ind) = 'GL'));
11823 l_duplicate_ind := l_duplicate_ind - 1;
11824 END LOOP;
11825 hr_utility.trace('processing bal l_duplicate_ind: ' || l_duplicate_ind);
11826
11827 IF (l_warning_ind = 0) THEN
11828 l_warning_ind := cel_warnings.start_date.COUNT + 1;
11829 cel_warnings.start_date(l_warning_ind) := p_start_date;
11830 cel_warnings.end_date(l_warning_ind) := p_end_date;
11831 cel_warnings.hierarchy_code(l_warning_ind) := p_hierarchy_code;
11832 cel_warnings.warning_code(l_warning_ind) := p_warning_code;
11833 cel_warnings.gl_ccid(l_warning_ind) := NULL;
11834 cel_warnings.project_id(l_warning_ind) := NULL;
11835 cel_warnings.task_id(l_warning_ind) := NULL;
11836 cel_warnings.award_id(l_warning_ind) := NULL;
11837 cel_warnings.exp_org_id(l_warning_ind) := NULL;
11838 cel_warnings.exp_type(l_warning_ind) := NULL;
11839 cel_warnings.effective_date(l_warning_ind) := NULL;
11840 cel_warnings.error_status(l_warning_ind) := NULL;
11841 cel_warnings.percent(l_warning_ind) := p_percent;
11842 ELSE
11843 cel_warnings.end_date(l_warning_ind) := p_end_date;
11844 cel_warnings.percent(l_warning_ind) := cel_warnings.percent(l_warning_ind) + p_percent;
11845 END IF;
11846
11847 IF (l_duplicate_ind > 0) THEN
11848 cel_warnings.end_date(l_duplicate_ind) := p_end_date;
11849 cel_warnings.start_date(l_warning_ind) := cel_warnings.start_date(l_duplicate_ind);
11850 cel_warnings.percent(l_warning_ind) := cel_warnings.percent(l_duplicate_ind) + p_percent;
11851 END IF;
11852 END IF;
11853 hr_utility.trace('cel_warnings.start_date.COUNT: ' || cel_warnings.start_date.COUNT);
11854 hr_utility.trace('Leaving add_cel_warnings');
11855 END add_cel_warnings;
11856
11857 PROCEDURE delete_previous_error_log(p_assignment_id IN NUMBER,
11858 p_payroll_id IN NUMBER,
11859 p_payroll_action_id IN NUMBER) IS
11860 PRAGMA AUTONOMOUS_TRANSACTION;
11861 BEGIN
11862 DELETE psp_report_errors
11863 WHERE source_id = p_assignment_id
11864 AND value1 = p_payroll_id
11865 AND payroll_action_id = p_payroll_action_id;
11866
11867 COMMIT;
11868 END delete_previous_error_log;
11869
11870 PROCEDURE update_hierarchy_dates (p_assignment_id IN NUMBER,
11871 p_payroll_id IN NUMBER,
11872 p_payroll_action_id IN NUMBER,
11873 p_return_status OUT NOCOPY VARCHAR2) IS
11874 CURSOR hierarchy_dates_cur IS
11875 SELECT DISTINCT enc_element_type_id,
11876 hierarchy_code,
11877 NVL(gl_code_combination_id, -99),
11878 NVL(project_id, -99),
11879 NVL(task_id, -99),
11880 NVL(award_id, -99),
11881 NVL(expenditure_organization_id, -99),
11882 NVL(expenditure_type, '-99'),
11883 enc_start_date,
11884 enc_end_date
11885 FROM psp_enc_lines
11886 WHERE payroll_action_id = p_payroll_action_id
11887 AND assignment_id = p_assignment_id
11888 AND payroll_id = p_payroll_id
11889 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
11890
11891 CURSOR history_dates_cur IS
11892 SELECT DISTINCT enc_element_type_id,
11893 hierarchy_code,
11894 NVL(gl_code_combination_id, -99),
11895 NVL(project_id, -99),
11896 NVL(task_id, -99),
11897 NVL(award_id, -99),
11898 NVL(expenditure_organization_id, -99),
11899 NVL(expenditure_type, '-99'),
11900 enc_start_date,
11901 enc_end_date
11902 FROM psp_enc_lines_history
11903 WHERE assignment_id = p_assignment_id
11904 AND payroll_id = p_payroll_id
11905 AND change_flag = 'N'
11906 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
11907
11908 TYPE r_enc_rec IS RECORD
11909 (element_type_id t_num_15_type,
11910 hierarchy_code t_varchar_50_type,
11911 gl_ccid t_num_15_type,
11912 project_id t_num_15_type,
11913 task_id t_num_15_type,
11914 award_id t_num_15_type,
11915 exp_org_id t_num_15_type,
11916 exp_type t_varchar_50_type,
11917 enc_start_date t_date_type,
11918 enc_end_date t_date_type);
11919
11920 t_enc_lines r_enc_rec;
11921 t_enc_nlines r_enc_rec;
11922 l_nlines_counter NUMBER(15);
11923 BEGIN
11924 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Entering UPDATE_HIERARCHY_DATES');
11925 OPEN hierarchy_dates_cur;
11926 FETCH hierarchy_dates_cur BULK COLLECT INTO t_enc_lines.element_type_id, t_enc_lines.hierarchy_code,
11927 t_enc_lines.gl_ccid, t_enc_lines.project_id, t_enc_lines.task_id,
11928 t_enc_lines.award_id, t_enc_lines.exp_org_id, t_enc_lines.exp_type,
11929 t_enc_lines.enc_start_date, t_enc_lines.enc_end_date;
11930 CLOSE hierarchy_dates_cur;
11931
11932 IF (t_enc_lines.element_type_id.COUNT > 0) THEN
11933 t_enc_nlines.element_type_id(1) := t_enc_lines.element_type_id(1);
11934 t_enc_nlines.hierarchy_code(1) := t_enc_lines.hierarchy_code(1);
11935 t_enc_nlines.gl_ccid(1) := t_enc_lines.gl_ccid(1);
11936 t_enc_nlines.project_id(1) := t_enc_lines.project_id(1);
11937 t_enc_nlines.task_id(1) := t_enc_lines.task_id(1);
11938 t_enc_nlines.award_id(1) := t_enc_lines.award_id(1);
11939 t_enc_nlines.exp_org_id(1) := t_enc_lines.exp_org_id(1);
11940 t_enc_nlines.exp_type(1) := t_enc_lines.exp_type(1);
11941 t_enc_nlines.enc_start_date(1) := t_enc_lines.enc_start_date(1);
11942 t_enc_nlines.enc_end_date(1) := t_enc_lines.enc_end_date(1);
11943 l_nlines_counter := 1;
11944 FOR recno IN 2..t_enc_lines.element_type_id.COUNT
11945 LOOP
11946 IF (t_enc_lines.element_type_id(recno) = t_enc_lines.element_type_id(recno-1) AND
11947 t_enc_lines.hierarchy_code(recno) = t_enc_lines.hierarchy_code(recno-1) AND
11948 t_enc_lines.gl_ccid(recno) = t_enc_lines.gl_ccid(recno-1) AND
11949 t_enc_lines.project_id(recno) = t_enc_lines.project_id(recno-1) AND
11950 t_enc_lines.task_id(recno) = t_enc_lines.task_id(recno-1) AND
11951 t_enc_lines.award_id(recno) = t_enc_lines.award_id(recno-1) AND
11952 t_enc_lines.exp_org_id(recno) = t_enc_lines.exp_org_id(recno-1) AND
11953 t_enc_lines.exp_type(recno) = t_enc_lines.exp_type(recno-1) AND
11954 t_enc_lines.enc_start_date(recno) -1 = t_enc_lines.enc_end_date(recno-1)) THEN
11955 t_enc_nlines.enc_end_date(l_nlines_counter) := t_enc_lines.enc_end_date(recno);
11956 ELSE
11957 l_nlines_counter := l_nlines_counter + 1;
11958 t_enc_nlines.element_type_id(l_nlines_counter) := t_enc_lines.element_type_id(recno);
11959 t_enc_nlines.hierarchy_code(l_nlines_counter) := t_enc_lines.hierarchy_code(recno);
11960 t_enc_nlines.gl_ccid(l_nlines_counter) := t_enc_lines.gl_ccid(recno);
11961 t_enc_nlines.project_id(l_nlines_counter) := t_enc_lines.project_id(recno);
11962 t_enc_nlines.task_id(l_nlines_counter) := t_enc_lines.task_id(recno);
11963 t_enc_nlines.award_id(l_nlines_counter) := t_enc_lines.award_id(recno);
11964 t_enc_nlines.exp_org_id(l_nlines_counter) := t_enc_lines.exp_org_id(recno);
11965 t_enc_nlines.exp_type(l_nlines_counter) := t_enc_lines.exp_type(recno);
11966 t_enc_nlines.enc_start_date(l_nlines_counter) := t_enc_lines.enc_start_date(recno);
11967 t_enc_nlines.enc_end_date(l_nlines_counter) := t_enc_lines.enc_end_date(recno);
11968 END IF;
11969 END LOOP;
11970
11971 FOR recno IN 1..t_enc_nlines.element_type_id.COUNT
11972 LOOP
11973 IF (t_enc_nlines.gl_ccid(recno) = -99) THEN
11974 t_enc_nlines.gl_ccid(recno) := NULL;
11975 ELSE
11976 t_enc_nlines.project_id(recno) := NULL;
11977 t_enc_nlines.task_id(recno) := NULL;
11978 t_enc_nlines.award_id(recno) := NULL;
11979 t_enc_nlines.exp_org_id(recno) := NULL;
11980 t_enc_nlines.exp_type(recno) := NULL;
11981 END IF;
11982 END LOOP;
11983
11984 FORALL recno IN 1..t_enc_nlines.element_type_id.COUNT
11985 UPDATE psp_enc_lines
11986 SET hierarchy_start_date = t_enc_nlines.enc_start_date(recno),
11987 hierarchy_end_date = t_enc_nlines.enc_end_date(recno)
11988 WHERE payroll_action_id = p_payroll_action_id
11989 AND assignment_id = p_assignment_id
11990 AND payroll_id = p_payroll_id
11991 AND enc_element_type_id = t_enc_nlines.element_type_id(recno)
11992 AND hierarchy_code = t_enc_nlines.hierarchy_code(recno)
11993 AND gl_code_combination_id IS NOT NULL
11994 AND t_enc_nlines.gl_ccid(recno) IS NOT NULL
11995 AND gl_code_combination_id = t_enc_nlines.gl_ccid(recno)
11996 AND enc_start_date <= t_enc_nlines.enc_end_date(recno)
11997 AND enc_end_date >= t_enc_nlines.enc_start_date(recno);
11998
11999 FORALL recno IN 1..t_enc_nlines.element_type_id.COUNT
12000 UPDATE psp_enc_lines
12001 SET hierarchy_start_date = t_enc_nlines.enc_start_date(recno),
12002 hierarchy_end_date = t_enc_nlines.enc_end_date(recno)
12003 WHERE payroll_action_id = p_payroll_action_id
12004 AND assignment_id = p_assignment_id
12005 AND payroll_id = p_payroll_id
12006 AND enc_element_type_id = t_enc_nlines.element_type_id(recno)
12007 AND hierarchy_code = t_enc_nlines.hierarchy_code(recno)
12008 AND award_id IS NOT NULL
12009 AND t_enc_nlines.award_id(recno) IS NOT NULL
12010 AND project_id = t_enc_nlines.project_id(recno)
12011 AND task_id = t_enc_nlines.task_id(recno)
12012 AND award_id = t_enc_nlines.award_id(recno)
12013 AND expenditure_organization_id = t_enc_nlines.exp_org_id(recno)
12014 AND expenditure_type = t_enc_nlines.exp_type(recno)
12015 AND enc_start_date <= t_enc_nlines.enc_end_date(recno)
12016 AND enc_end_date >= t_enc_nlines.enc_start_date(recno);
12017 END IF;
12018
12019 t_enc_lines.element_type_id.DELETE;
12020 t_enc_lines.hierarchy_code.DELETE;
12021 t_enc_lines.gl_ccid.DELETE;
12022 t_enc_lines.project_id.DELETE;
12023 t_enc_lines.task_id.DELETE;
12024 t_enc_lines.award_id.DELETE;
12025 t_enc_lines.exp_org_id.DELETE;
12026 t_enc_lines.exp_type.DELETE;
12027 t_enc_lines.enc_start_date.DELETE;
12028 t_enc_lines.enc_end_date.DELETE;
12029
12030 t_enc_nlines.element_type_id.DELETE;
12031 t_enc_nlines.hierarchy_code.DELETE;
12032 t_enc_nlines.gl_ccid.DELETE;
12033 t_enc_nlines.project_id.DELETE;
12034 t_enc_nlines.task_id.DELETE;
12035 t_enc_nlines.award_id.DELETE;
12036 t_enc_nlines.exp_org_id.DELETE;
12037 t_enc_nlines.exp_type.DELETE;
12038 t_enc_nlines.enc_start_date.DELETE;
12039 t_enc_nlines.enc_end_date.DELETE;
12040
12041 OPEN history_dates_cur;
12042 FETCH history_dates_cur BULK COLLECT INTO t_enc_lines.element_type_id, t_enc_lines.hierarchy_code,
12043 t_enc_lines.gl_ccid, t_enc_lines.project_id, t_enc_lines.task_id,
12044 t_enc_lines.award_id, t_enc_lines.exp_org_id, t_enc_lines.exp_type,
12045 t_enc_lines.enc_start_date, t_enc_lines.enc_end_date;
12046 CLOSE history_dates_cur;
12047
12048 IF (t_enc_lines.element_type_id.COUNT > 0) THEN
12049 t_enc_nlines.element_type_id(1) := t_enc_lines.element_type_id(1);
12050 t_enc_nlines.hierarchy_code(1) := t_enc_lines.hierarchy_code(1);
12051 t_enc_nlines.gl_ccid(1) := t_enc_lines.gl_ccid(1);
12052 t_enc_nlines.project_id(1) := t_enc_lines.project_id(1);
12053 t_enc_nlines.task_id(1) := t_enc_lines.task_id(1);
12054 t_enc_nlines.award_id(1) := t_enc_lines.award_id(1);
12055 t_enc_nlines.exp_org_id(1) := t_enc_lines.exp_org_id(1);
12056 t_enc_nlines.exp_type(1) := t_enc_lines.exp_type(1);
12057 t_enc_nlines.enc_start_date(1) := t_enc_lines.enc_start_date(1);
12058 t_enc_nlines.enc_end_date(1) := t_enc_lines.enc_end_date(1);
12059 l_nlines_counter := 1;
12060 FOR recno IN 2..t_enc_lines.element_type_id.COUNT
12061 LOOP
12062 IF (t_enc_lines.element_type_id(recno) = t_enc_lines.element_type_id(recno-1) AND
12063 t_enc_lines.hierarchy_code(recno) = t_enc_lines.hierarchy_code(recno-1) AND
12064 t_enc_lines.gl_ccid(recno) = t_enc_lines.gl_ccid(recno-1) AND
12065 t_enc_lines.project_id(recno) = t_enc_lines.project_id(recno-1) AND
12066 t_enc_lines.task_id(recno) = t_enc_lines.task_id(recno-1) AND
12067 t_enc_lines.award_id(recno) = t_enc_lines.award_id(recno-1) AND
12068 t_enc_lines.exp_org_id(recno) = t_enc_lines.exp_org_id(recno-1) AND
12069 t_enc_lines.exp_type(recno) = t_enc_lines.exp_type(recno-1) AND
12070 t_enc_lines.enc_start_date(recno) -1 = t_enc_lines.enc_end_date(recno-1)) THEN
12071 t_enc_nlines.enc_end_date(l_nlines_counter) := t_enc_lines.enc_end_date(recno);
12072 ELSE
12073 l_nlines_counter := l_nlines_counter + 1;
12074 t_enc_nlines.element_type_id(l_nlines_counter) := t_enc_lines.element_type_id(recno);
12075 t_enc_nlines.hierarchy_code(l_nlines_counter) := t_enc_lines.hierarchy_code(recno);
12076 t_enc_nlines.gl_ccid(l_nlines_counter) := t_enc_lines.gl_ccid(recno);
12077 t_enc_nlines.project_id(l_nlines_counter) := t_enc_lines.project_id(recno);
12078 t_enc_nlines.task_id(l_nlines_counter) := t_enc_lines.task_id(recno);
12079 t_enc_nlines.award_id(l_nlines_counter) := t_enc_lines.award_id(recno);
12080 t_enc_nlines.exp_org_id(l_nlines_counter) := t_enc_lines.exp_org_id(recno);
12081 t_enc_nlines.exp_type(l_nlines_counter) := t_enc_lines.exp_type(recno);
12082 t_enc_nlines.enc_start_date(l_nlines_counter) := t_enc_lines.enc_start_date(recno);
12083 t_enc_nlines.enc_end_date(l_nlines_counter) := t_enc_lines.enc_end_date(recno);
12084 END IF;
12085 END LOOP;
12086
12087 FOR recno IN 1..t_enc_nlines.element_type_id.COUNT
12088 LOOP
12089 IF (t_enc_nlines.gl_ccid(recno) = -99) THEN
12090 t_enc_nlines.gl_ccid(recno) := NULL;
12091 ELSE
12092 t_enc_nlines.project_id(recno) := NULL;
12093 t_enc_nlines.task_id(recno) := NULL;
12094 t_enc_nlines.award_id(recno) := NULL;
12095 t_enc_nlines.exp_org_id(recno) := NULL;
12096 t_enc_nlines.exp_type(recno) := NULL;
12097 END IF;
12098 END LOOP;
12099
12100 FORALL recno IN 1..t_enc_nlines.element_type_id.COUNT
12101 UPDATE psp_enc_lines_history
12102 SET hierarchy_start_date = t_enc_nlines.enc_start_date(recno),
12103 hierarchy_end_date = t_enc_nlines.enc_end_date(recno)
12104 WHERE assignment_id = p_assignment_id
12105 AND payroll_id = p_payroll_id
12106 AND change_flag = 'N'
12107 AND enc_element_type_id = t_enc_nlines.element_type_id(recno)
12108 AND hierarchy_code = t_enc_nlines.hierarchy_code(recno)
12109 AND gl_code_combination_id IS NOT NULL
12110 AND t_enc_nlines.gl_ccid(recno) IS NOT NULL
12111 AND gl_code_combination_id = t_enc_nlines.gl_ccid(recno)
12112 AND enc_start_date <= t_enc_nlines.enc_end_date(recno)
12113 AND enc_end_date >= t_enc_nlines.enc_start_date(recno);
12114
12115 FORALL recno IN 1..t_enc_nlines.element_type_id.COUNT
12116 UPDATE psp_enc_lines_history
12117 SET hierarchy_start_date = t_enc_nlines.enc_start_date(recno),
12118 hierarchy_end_date = t_enc_nlines.enc_end_date(recno)
12119 WHERE assignment_id = p_assignment_id
12120 AND payroll_id = p_payroll_id
12121 AND change_flag = 'N'
12122 AND enc_element_type_id = t_enc_nlines.element_type_id(recno)
12123 AND hierarchy_code = t_enc_nlines.hierarchy_code(recno)
12124 AND award_id IS NOT NULL
12125 AND t_enc_nlines.award_id(recno) IS NOT NULL
12126 AND project_id = t_enc_nlines.project_id(recno)
12127 AND task_id = t_enc_nlines.task_id(recno)
12128 AND award_id = t_enc_nlines.award_id(recno)
12129 AND expenditure_organization_id = t_enc_nlines.exp_org_id(recno)
12130 AND expenditure_type = t_enc_nlines.exp_type(recno)
12131 AND enc_start_date <= t_enc_nlines.enc_end_date(recno)
12132 AND enc_end_date >= t_enc_nlines.enc_start_date(recno);
12133 END IF;
12134 p_return_status := fnd_api.g_ret_sts_success;
12135 hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Leaving UPDATE_HIERARCHY_DATES');
12136 EXCEPTION
12137 WHEN OTHERS THEN
12138 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
12139 IF (g_error_message IS NULL) THEN
12140 g_error_message := 'UPDATE_HIERARCHY_DATES: ' || SQLERRM;
12141 END IF;
12142 g_error_api_path := SUBSTR(' UPDATE_HIERARCHY_DATES:'||g_error_api_path,1,230);
12143 fnd_msg_pub.add_exc_msg('PSP_ENC_CREATE_LINES', ' UPDATE_HIERARCHY_DATES');
12144 p_return_status := fnd_api.g_ret_sts_unexp_error;
12145 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving UPDATE_HIERARCHY_DATES');
12146 END update_hierarchy_dates;
12147
12148 PROCEDURE clear_sch_hierarchy IS
12149 BEGIN
12150 r_sa.line_account_id.DELETE;
12151 r_sa.gl_code_combination_id.DELETE;
12152 r_sa.project_id.DELETE;
12153 r_sa.task_id.DELETE;
12154 r_sa.award_id.DELETE;
12155 r_sa.expenditure_type.DELETE;
12156 r_sa.expenditure_organization_id.DELETE;
12157 r_sa.start_date_active.DELETE;
12158 r_sa.end_date_active.DELETE;
12159 r_sa.poeta_start_date.DELETE;
12160 r_sa.poeta_end_date.DELETE;
12161 r_sa.percent.DELETE;
12162 r_sa.attribute_category.DELETE;
12163 r_sa.attribute1.DELETE;
12164 r_sa.attribute2.DELETE;
12165 r_sa.attribute3.DELETE;
12166 r_sa.attribute4.DELETE;
12167 r_sa.attribute5.DELETE;
12168 r_sa.attribute6.DELETE;
12169 r_sa.attribute7.DELETE;
12170 r_sa.attribute8.DELETE;
12171 r_sa.attribute9.DELETE;
12172 r_sa.attribute10.DELETE;
12173 r_sa.acct_type.DELETE;
12174
12175 r_da.line_account_id.DELETE;
12176 r_da.gl_code_combination_id.DELETE;
12177 r_da.project_id.DELETE;
12178 r_da.task_id.DELETE;
12179 r_da.award_id.DELETE;
12180 r_da.expenditure_type.DELETE;
12181 r_da.expenditure_organization_id.DELETE;
12182 r_da.start_date_active.DELETE;
12183 r_da.end_date_active.DELETE;
12184 r_da.poeta_start_date.DELETE;
12185 r_da.poeta_end_date.DELETE;
12186 r_da.percent.DELETE;
12187 r_da.attribute_category.DELETE;
12188 r_da.attribute1.DELETE;
12189 r_da.attribute2.DELETE;
12190 r_da.attribute3.DELETE;
12191 r_da.attribute4.DELETE;
12192 r_da.attribute5.DELETE;
12193 r_da.attribute6.DELETE;
12194 r_da.attribute7.DELETE;
12195 r_da.attribute8.DELETE;
12196 r_da.attribute9.DELETE;
12197 r_da.attribute10.DELETE;
12198 r_da.acct_type.DELETE;
12199
12200 r_odls.line_account_id.DELETE;
12201 r_odls.gl_code_combination_id.DELETE;
12202 r_odls.project_id.DELETE;
12203 r_odls.task_id.DELETE;
12204 r_odls.award_id.DELETE;
12205 r_odls.expenditure_type.DELETE;
12206 r_odls.expenditure_organization_id.DELETE;
12207 r_odls.start_date_active.DELETE;
12208 r_odls.end_date_active.DELETE;
12209 r_odls.poeta_start_date.DELETE;
12210 r_odls.poeta_end_date.DELETE;
12211 r_odls.percent.DELETE;
12212 r_odls.attribute_category.DELETE;
12213 r_odls.attribute1.DELETE;
12214 r_odls.attribute2.DELETE;
12215 r_odls.attribute3.DELETE;
12216 r_odls.attribute4.DELETE;
12217 r_odls.attribute5.DELETE;
12218 r_odls.attribute6.DELETE;
12219 r_odls.attribute7.DELETE;
12220 r_odls.attribute8.DELETE;
12221 r_odls.attribute9.DELETE;
12222 r_odls.attribute10.DELETE;
12223 r_odls.acct_type.DELETE;
12224
12225 r_asg.line_account_id.DELETE;
12226 r_asg.gl_code_combination_id.DELETE;
12227 r_asg.project_id.DELETE;
12228 r_asg.task_id.DELETE;
12229 r_asg.award_id.DELETE;
12230 r_asg.expenditure_type.DELETE;
12231 r_asg.expenditure_organization_id.DELETE;
12232 r_asg.start_date_active.DELETE;
12233 r_asg.end_date_active.DELETE;
12234 r_asg.poeta_start_date.DELETE;
12235 r_asg.poeta_end_date.DELETE;
12236 r_asg.percent.DELETE;
12237 r_asg.attribute_category.DELETE;
12238 r_asg.attribute1.DELETE;
12239 r_asg.attribute2.DELETE;
12240 r_asg.attribute3.DELETE;
12241 r_asg.attribute4.DELETE;
12242 r_asg.attribute5.DELETE;
12243 r_asg.attribute6.DELETE;
12244 r_asg.attribute7.DELETE;
12245 r_asg.attribute8.DELETE;
12246 r_asg.attribute9.DELETE;
12247 r_asg.attribute10.DELETE;
12248 r_asg.acct_type.DELETE;
12249
12250 r_ec.line_account_id.DELETE;
12251 r_ec.gl_code_combination_id.DELETE;
12252 r_ec.project_id.DELETE;
12253 r_ec.task_id.DELETE;
12254 r_ec.award_id.DELETE;
12255 r_ec.expenditure_type.DELETE;
12256 r_ec.expenditure_organization_id.DELETE;
12257 r_ec.start_date_active.DELETE;
12258 r_ec.end_date_active.DELETE;
12259 r_ec.poeta_start_date.DELETE;
12260 r_ec.poeta_end_date.DELETE;
12261 r_ec.percent.DELETE;
12262 r_ec.attribute_category.DELETE;
12263 r_ec.attribute1.DELETE;
12264 r_ec.attribute2.DELETE;
12265 r_ec.attribute3.DELETE;
12266 r_ec.attribute4.DELETE;
12267 r_ec.attribute5.DELETE;
12268 r_ec.attribute6.DELETE;
12269 r_ec.attribute7.DELETE;
12270 r_ec.attribute8.DELETE;
12271 r_ec.attribute9.DELETE;
12272 r_ec.attribute10.DELETE;
12273 r_ec.acct_type.DELETE;
12274
12275 r_et.line_account_id.DELETE;
12276 r_et.gl_code_combination_id.DELETE;
12277 r_et.project_id.DELETE;
12278 r_et.task_id.DELETE;
12279 r_et.award_id.DELETE;
12280 r_et.expenditure_type.DELETE;
12281 r_et.expenditure_organization_id.DELETE;
12282 r_et.start_date_active.DELETE;
12283 r_et.end_date_active.DELETE;
12284 r_et.poeta_start_date.DELETE;
12285 r_et.poeta_end_date.DELETE;
12286 r_et.percent.DELETE;
12287 r_et.attribute_category.DELETE;
12288 r_et.attribute1.DELETE;
12289 r_et.attribute2.DELETE;
12290 r_et.attribute3.DELETE;
12291 r_et.attribute4.DELETE;
12292 r_et.attribute5.DELETE;
12293 r_et.attribute6.DELETE;
12294 r_et.attribute7.DELETE;
12295 r_et.attribute8.DELETE;
12296 r_et.attribute9.DELETE;
12297 r_et.attribute10.DELETE;
12298 r_et.acct_type.DELETE;
12299
12300 r_gee.line_account_id.DELETE;
12301 r_gee.gl_code_combination_id.DELETE;
12302 r_gee.project_id.DELETE;
12303 r_gee.task_id.DELETE;
12304 r_gee.award_id.DELETE;
12305 r_gee.expenditure_type.DELETE;
12306 r_gee.expenditure_organization_id.DELETE;
12307 r_gee.start_date_active.DELETE;
12308 r_gee.end_date_active.DELETE;
12309 r_gee.poeta_start_date.DELETE;
12310 r_gee.poeta_end_date.DELETE;
12311 r_gee.percent.DELETE;
12312 r_gee.attribute_category.DELETE;
12313 r_gee.attribute1.DELETE;
12314 r_gee.attribute2.DELETE;
12315 r_gee.attribute3.DELETE;
12316 r_gee.attribute4.DELETE;
12317 r_gee.attribute5.DELETE;
12318 r_gee.attribute6.DELETE;
12319 r_gee.attribute7.DELETE;
12320 r_gee.attribute8.DELETE;
12321 r_gee.attribute9.DELETE;
12322 r_gee.attribute10.DELETE;
12323 r_gee.acct_type.DELETE;
12324
12325 END clear_sch_hierarchy;
12326
12327 END PSP_ENC_CREATE_LINES;