[Home] [Help]
PACKAGE BODY: APPS.PSP_SUM_TRANS
Source
1 PACKAGE BODY PSP_SUM_TRANS as
2 /* $Header: PSPTRSTB.pls 120.17.12010000.2 2008/09/25 10:18:52 amakrish ship $ */
3 --- g_gms_avail VARCHAR2(1) := 'N'; removed the usage of this variable, because
4 --- transfer_to_gms has checks on GMS phase. bug 2444657
5 /* Following three global variables introduced to faciliate calling mark_batch_end procedure
6 from GL_TIE_BACK procedure: Bug 1929317 */
7 g_source_code Varchar2(30);
8 g_batch_name Varchar2(30);
9 g_time_period_id number;
10 g_payroll_id integer; --- added for ER enhancment.
11 -- g_currency_code Varchar2(15); -- added for bug no 2478000 Commented for Bug 2916848
12
13 -- Introduced the following for bug 2259310
14 g_enable_enc_summ_gl VARCHAR2(1) DEFAULT NVL(fnd_profile.value('PSP_ENABLE_ENC_SUMM_GL'), 'N');
15
16 g_insert_str VARCHAR2(5000); -- Introduced for Bug fix 2935850
17
18 g_dff_grouping_option CHAR(1); -- Introduced for bug fix 2908859
19 g_suspense_autopop varchar2(1); -- 5080403
20
21 PROCEDURE sum_and_transfer(errbuf OUT NOCOPY VARCHAR2,
22 retcode OUT NOCOPY VARCHAR2,
23 p_source_type IN VARCHAR2,
24 p_source_code IN VARCHAR2,
25 p_payroll_id IN NUMBER,
26 p_time_period_id IN NUMBER,
27 p_batch_name IN VARCHAR2,
28 p_business_group_id IN NUMBER,
29 p_set_of_books_id IN NUMBER) IS
30
31 l_return_status VARCHAR2(10);
32 l_msg_count NUMBER;
33 l_msg_data VARCHAR2(2000);
34 --- introduced for 5080403
35 cursor autopop_config_cur is
36 select pcv_information7 suspense_account
37 from pqp_configuration_values
38 where pcv_information_category = 'PSP_ENABLE_AUTOPOPULATION'
39 and legislation_code is null
40 and nvl(business_group_id, p_business_group_id) = p_business_group_id;
41
42 BEGIN
43 ---hr_utility.trace_on('Y','SandT');
44 g_error_api_path := '';
45 fnd_msg_pub.initialize;
46 psp_general.TRANSACTION_CHANGE_PURGEBLE;
47
48 /* Following three variables initialized to faciliate calling mark_batch_end procedure
49 from GL_TIE_BACK procedure: Bug 1929317 */
50
51 g_source_code := p_source_code;
52 g_batch_name := p_batch_name;
53 g_time_period_id := p_time_period_id;
54 g_payroll_id := p_payroll_id;
55 -- g_currency_code := psp_general.get_currency_code(p_business_group_id); -- Commented the following code for Bug 2916848
56
57 open autopop_config_cur; -- 5080403
58 fetch autopop_config_cur into g_suspense_autopop;
59 close autopop_config_cur;
60
61
62 g_dff_grouping_option := psp_general.get_act_dff_grouping_option(p_business_group_id); -- Introduced for bug fix 2908859
63
64 mark_batch_begin(p_source_type,
65 p_source_code,
66 p_payroll_id,
67 p_time_period_id,
68 p_batch_name,
69 p_business_group_id,
70 p_set_of_books_id,
71 l_return_status);
72
73 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
74 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
75 END IF;
76
77
78 -- FIRST NORMAL RUN
79 -- initiate the gl summarization and transfer
80 create_gl_sum_lines(p_source_type,
81 p_source_code,
82 p_time_period_id,
83 p_batch_name,
84 p_business_group_id,
85 p_set_of_books_id,
86 l_return_status);
87 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
88 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
89 END IF;
90
91 -- call the user extension to populate attribute1 through attribute30
92 IF FND_PROFILE.VALUE('PSP_ST_EXTENSION_ENABLE') = 'Y' THEN
93 --- 2968684 added params and exception handlers to the following proc.
94 psp_st_ext.summary_ext_actual(p_source_type,
95 p_source_code ,
96 p_payroll_id ,
97 p_time_period_id ,
98 p_batch_name ,
99 p_business_group_id,
100 p_set_of_books_id );
101 END IF;
102
103 transfer_to_gl_interface(p_source_type,
104 p_source_code,
105 p_time_period_id,
106 p_batch_name,
107 p_business_group_id,
108 p_set_of_books_id,
109 l_return_status);
110
111 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
112 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
113 END IF;
114
115 create_gms_sum_lines(p_source_type,
116 p_source_code,
117 p_time_period_id,
118 p_batch_name,
119 p_business_group_id,
120 p_set_of_books_id,
121 l_return_status);
122 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
123 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
124 END IF;
125
126 -- Call the user extension to populate attribute1 thru attribute 30.
127 IF FND_PROFILE.VALUE('PSP_ST_EXTENSION_ENABLE') = 'Y' THEN
128 --- 2968684 added params and exception handlers to the following proc.
129 psp_st_ext.summary_ext_actual(p_source_type,
130 p_source_code ,
131 p_payroll_id ,
132 p_time_period_id ,
133 p_batch_name ,
134 p_business_group_id,
135 p_set_of_books_id );
136 END IF;
137
138 transfer_to_gms_interface(p_source_type,
139 p_source_code,
140 p_time_period_id,
141 p_batch_name,
142 p_business_group_id,
143 p_set_of_books_id,
144 l_return_status);
145
146 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
147 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
148 END IF;
149
150 -- SECOND RUN TO TAKE CARE OF TIE-BACK
151 -- initiate the gl summarization
152 create_gl_sum_lines(p_source_type,
153 p_source_code,
154 p_time_period_id,
155 p_batch_name,
156 p_business_group_id,
157 p_set_of_books_id,
158 l_return_status);
159
160 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
161 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
162 END IF;
163
164 -- Call the user extension to populate attribute1 thru attribute 30.
165 IF FND_PROFILE.VALUE('PSP_ST_EXTENSION_ENABLE') = 'Y' THEN
166 --- 2968684 added params and exception handlers to the following proc.
167 psp_st_ext.summary_ext_actual(p_source_type,
168 p_source_code ,
169 p_payroll_id ,
170 p_time_period_id ,
171 p_batch_name ,
172 p_business_group_id,
173 p_set_of_books_id );
174 END IF;
175
176 transfer_to_gl_interface(p_source_type,
177 p_source_code,
178 p_time_period_id,
179 p_batch_name,
180 p_business_group_id,
181 p_set_of_books_id,
182 l_return_status);
183
184 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
185 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
186 END IF;
187
188
189
190 create_gms_sum_lines(p_source_type,
191 p_source_code,
192 p_time_period_id,
193 p_batch_name,
194 p_business_group_id,
195 p_set_of_books_id,
196 l_return_status);
197
198 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
199 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
200 END IF;
201
202 -- call the user extension to populate attribute1 through attribute30
203 IF FND_PROFILE.VALUE('PSP_ST_EXTENSION_ENABLE') = 'Y' THEN
204 --- 2968684 added params and exception handlers to the following proc.
205 psp_st_ext.summary_ext_actual(p_source_type,
206 p_source_code ,
207 p_payroll_id ,
208 p_time_period_id ,
209 p_batch_name ,
210 p_business_group_id,
211 p_set_of_books_id );
212 END IF;
213
214
215 transfer_to_gms_interface(p_source_type,
216 p_source_code,
217 p_time_period_id,
218 p_batch_name,
219 p_business_group_id,
220 p_set_of_books_id,
221 l_return_status);
222
223 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
224 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
225 END IF;
226
227 mark_batch_end(p_source_type,
228 p_source_code,
229 p_time_period_id,
230 p_batch_name,
231 p_business_group_id,
232 p_set_of_books_id,
233 l_return_status);
234
235 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
236 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
237 END IF;
238
239 PSP_MESSAGE_S.Print_success;
240
241 EXCEPTION
242 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
243
244 /* Introduced as part of bug fix #1776606 */
245 ROLLBACK;
246 /* Commented as part of Bug fix #1776606
247 mark_batch_end(p_source_type,
248 p_source_code,
249 p_time_period_id,
250 p_batch_name,
251 p_business_group_id,
252 p_set_of_books_id,
253 l_return_status);
254
255 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
256 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
257 END IF;
258
259 fnd_msg_pub.get(p_msg_index => FND_MSG_PUB.G_FIRST,
260 p_encoded => FND_API.G_FALSE,
261 p_data => l_msg_data,
262 p_msg_index_out => l_msg_count); */
263
264 g_error_api_path := 'SUM_AND_TRANSFER:'||g_error_api_path;
265 errbuf := SUBSTR(l_msg_data || fnd_global.local_chr(10) ||fnd_global.local_chr(10)||g_error_api_path,1,230);
266 psp_message_s.print_error(p_mode => FND_FILE.LOG,
267 p_print_header => FND_API.G_TRUE);
268 retcode := 2;
269 WHEN OTHERS THEN
270
271 /* Introduced as part of Bug fix #1776606 */
272 ROLLBACK;
273 /* Commented as part of Bug fix #1776606
274
275 mark_batch_end(p_source_type,
276 p_source_code,
277 p_time_period_id,
278 p_batch_name,
279 p_business_group_id,
280 p_set_of_books_id,
281 l_return_status);
282
283 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
284 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
285 END IF;
286
287 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','SUM_AND_TRANSFER');
288 fnd_msg_pub.get(p_msg_index => FND_MSG_PUB.G_FIRST,
289 p_encoded => FND_API.G_FALSE,
290 p_data => l_msg_data,
291 p_msg_index_out => l_msg_count); */
292
293 g_error_api_path := 'SUM_AND_TRANSFER:'||g_error_api_path;
294 errbuf := SUBSTR(l_msg_data || fnd_global.local_chr(10) ||fnd_global.local_chr(10)||g_error_api_path,1,230);
295 psp_message_s.print_error(p_mode => FND_FILE.LOG,
296 p_print_header => FND_API.G_TRUE);
297 retcode := 2;
298 END;
299
300 -------------------- MARK BATCH BEGIN --------------------------------------------
301
302 PROCEDURE mark_batch_begin(p_source_type IN VARCHAR2,
303 p_source_code IN VARCHAR2,
304 p_payroll_id IN NUMBER,
305 p_time_period_id IN NUMBER,
306 p_batch_name IN VARCHAR2,
307 p_business_group_id IN NUMBER,
308 p_set_of_books_id IN NUMBER,
309 p_return_status OUT NOCOPY VARCHAR2) IS
310
311 CURSOR payroll_control_cur2 IS
312 SELECT payroll_control_id
313 FROM psp_payroll_controls
314 WHERE source_type = nvl(p_source_type,source_type)
315 AND payroll_source_code = nvl(p_source_code,payroll_source_code)
316 AND payroll_id = NVL (p_payroll_id, payroll_id) -- Bug 7137063
317 AND time_period_id = nvl(p_time_period_id,time_period_id)
318 AND nvl(batch_name,'N') = nvl(nvl(p_batch_name,batch_name),'N')
319 AND (dist_dr_amount IS NOT NULL OR dist_cr_amount IS NOT NULL)
320 AND status_code in ('N','I') --- added 'I' for 2444657
321 AND business_group_id = p_business_group_id
322 AND set_of_books_id = p_set_of_books_id
323 AND source_type <> 'A' -- Adjustments are delinked.
324 AND parent_payroll_control_id is null;
325
326 l_payroll_control_id integer;
327
328 CURSOR payroll_control_cur IS
329 SELECT payroll_control_id,
330 source_type,
331 payroll_source_code,
332 time_period_id,
333 batch_name,
334 phase
335 FROM psp_payroll_controls
336 where status_code in ('N','I')
337 and source_type <> 'A'
338 and payroll_control_id = l_payroll_control_id
339 or parent_payroll_control_id = l_payroll_control_id;
340
341 payroll_control_rec payroll_control_cur%ROWTYPE;
342 l_gms_batch_name NUMBER(15);
343 l_ti_not_complete NUMBER(15);
344
345 BEGIN
346 SELECT psp_st_run_id_s.nextval
347 INTO g_run_id
348 FROM dual;
349 open payroll_control_cur2;
350 loop
351 fetch payroll_control_cur2 into l_payroll_control_id;
352 if payroll_control_cur2%notfound then
353 close payroll_control_cur2;
354 exit;
355 end if;
356 OPEN payroll_control_cur;
357 LOOP
358 FETCH payroll_control_cur INTO payroll_control_rec;
359 IF payroll_control_cur%NOTFOUND THEN
360 CLOSE payroll_control_cur;
361 EXIT;
362 END IF;
363 UPDATE psp_payroll_controls
364 SET status_code = 'I',
365 run_id = g_run_id
366 WHERE payroll_control_id = payroll_control_rec.payroll_control_id;
367
368 if (payroll_control_rec.phase = 'Submitted_TI_Request') then
369 select max(gms_batch_name)
370 into l_gms_batch_name
371 from psp_summary_lines
372 where payroll_control_id = payroll_control_rec.payroll_control_id;
373
374 select count(*)
375 into l_ti_not_complete
376 from pa_transaction_interface_all
377 where transaction_status_code = 'I'
378 and batch_name = to_char(l_gms_batch_name)
379 and transaction_source in ('GOLD', 'OLD');
380
381 if (l_ti_not_complete > 0) then
382 fnd_message.set_name('PSP','PSP_TI_DID_NOT_COMPLETE');
383 fnd_message.set_token('PAYROLL_CONTROL_ID', payroll_control_rec.payroll_control_id);
384 fnd_message.set_token('GMS_BATCH_NAME', l_gms_batch_name);
385 fnd_msg_pub.add;
386 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
387 end if;
388
389 end if;
390
391 END LOOP;
392 end loop;
393 /* Introduced as part of Bug fix #1776606 */
394 EXCEPTION
395 WHEN OTHERS THEN
396 g_error_api_path := 'MARK_BATCH_BEGIN: ' || g_error_api_path;
397 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','MARK_BATCH_BEGIN');
398 p_return_status := fnd_api.g_ret_sts_unexp_error;
399 RAISE;
400 END;
401 -------------------- MARK BATCH END ---------------------------------------------
402
403 PROCEDURE mark_batch_end(p_source_type IN VARCHAR2,
404 p_source_code IN VARCHAR2,
405 p_time_period_id IN NUMBER,
406 p_batch_name IN VARCHAR2,
407 p_business_group_id IN NUMBER,
408 p_set_of_books_id IN NUMBER,
409 p_return_status OUT NOCOPY VARCHAR2) IS
410
411 CURSOR payroll_control_cur IS
412 SELECT payroll_control_id,
413 source_type,
414 payroll_source_code,
415 time_period_id,
416 batch_name,
417 phase
418 FROM psp_payroll_controls
419 WHERE status_code = 'I'
420 AND run_id = g_run_id
421 AND source_type <> 'A';
422
423 payroll_control_rec payroll_control_cur%ROWTYPE;
424 l_summary_line_id NUMBER(10);
425 l_phase_counter NUMBER (10) DEFAULT 0 ;
426
427 --**************************************************************
428 l_line_counter NUMBER DEFAULT 0;
429 --**************************************************************
430 l_return_status varchar2(10);
431 errbuf varchar2(1000);
432 retcode varchar2(1000);
433
434 /* Start of Changes to check for migration before Supercedence */
435
436 l_migration_status BOOLEAN:= psp_general.is_effort_report_migrated;
437
438
439 /* End of Changes to check for migration before Supercedence */
440
441 BEGIN
442 --- call to supercede Effort reports
443
444
445 IF l_migration_status THEN
446
447
448 -- Introduced the above for checking on migration status
449
450 SUPERCEDE_ER(g_run_id,
451 errbuf,
452 retcode,
453 p_source_type ,
454 p_source_code ,
455 p_time_period_id,
456 p_batch_name,
457 l_return_status);
458 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
459 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
460 END IF;
461
462
463 End IF;
464
465
466
467
468 -- raise no_data_found; Commented for bug fix 408937
469 OPEN payroll_control_cur;
470 LOOP
471 FETCH payroll_control_cur INTO payroll_control_rec;
472 IF payroll_control_cur%NOTFOUND THEN
473 CLOSE payroll_control_cur;
474 EXIT;
475 END IF;
476
477
478 ---- Bug 2444657: removed the code that was trying to reset the
479 --- distribution lines status code to N for summary lines with status=N
480 --- becos this is redundant, anyway the dist lines will be with 'N'
481 --- Also removed update statment that makes summary lines status = R
482 -- whenever status = 'N', becos there is a new phase Summarize
483
484 -- This part is used to delete the rejected summary lines, mark the status_code
485 -- in psp_payroll_controls to 'P' or 'N',delete the zero line reversal entry records
486 /* Bug 1929317.. Did some changes here...deleted the original code.....Look into previous version
487 to compare .. Basically to check the number of lines in dist lines ...instead of summing on dist amount
488 for deciding wether to change control rec status to either 'P' or 'N' */
489 IF payroll_control_rec.source_type = 'O' OR payroll_control_rec.source_type = 'N' THEN
490
491 DELETE FROM psp_distribution_lines
492 WHERE distribution_amount = 0
493 AND payroll_sub_line_id IN (
494 select payroll_sub_line_id from psp_payroll_sub_lines where payroll_line_id IN (
495 select payroll_line_id from psp_payroll_lines where payroll_control_id IN (
496 select payroll_control_id from psp_payroll_controls where payroll_control_id=
497 payroll_control_rec.payroll_control_id)));
498
499 SELECT count(*)
500 INTO l_line_counter
501 FROM psp_distribution_lines pdl,
502 psp_payroll_sub_lines ppsl,
503 psp_payroll_lines ppl
504 WHERE ppl.payroll_control_id = payroll_control_rec.payroll_control_id
505 AND ppl.payroll_line_id = ppsl.payroll_line_id
506 AND ppsl.payroll_sub_line_id = pdl.payroll_sub_line_id;
507
508 If l_line_counter = 0 then
509
510 /* commented for 2445196
511 -- delete any rejected summary lines
512 DELETE FROM psp_summary_lines
513 WHERE payroll_control_id = payroll_control_rec.payroll_control_id
514 AND status_code = 'R';
515 */
516
517 -- update status_code to 'P' in psp_payroll_controls
518 UPDATE psp_payroll_controls
519 SET status_code = 'P',
520 run_id = NULL,
521 phase = NULL
522 WHERE payroll_control_id = payroll_control_rec.payroll_control_id;
523 ELSE
524 UPDATE psp_payroll_controls
525 SET status_code = 'N',
526 run_id = NULL
527 WHERE payroll_control_id = payroll_control_rec.payroll_control_id;
528 END IF;
529 ELSIF payroll_control_rec.source_type = 'P' THEN
530
531 -- delete the zero amount reversal lines
532 DELETE FROM psp_pre_gen_dist_lines
533 WHERE distribution_amount = 0
534 AND reversal_entry_flag = 'Y'
535 AND payroll_control_id = payroll_control_rec.payroll_control_id;
536
537 SELECT count(*)
538 INTO l_line_counter
539 FROM psp_pre_gen_dist_lines ppgd
540 WHERE ppgd.payroll_control_id = payroll_control_rec.payroll_control_id;
541
542 IF l_line_counter = 0 THEN
543 /* commented for 2445196
544 DELETE FROM psp_summary_lines
545 WHERE payroll_control_id = payroll_control_rec.payroll_control_id
546 AND status_code = 'R';
547 */
548
549 UPDATE psp_payroll_controls
550 SET status_code = 'P',
551 run_id = NULL,
552 phase = NULL
553 WHERE payroll_control_id = payroll_control_rec.payroll_control_id;
554 ELSE
555 UPDATE psp_payroll_controls
556 SET status_code = 'N',
557 run_id = NULL
558 WHERE payroll_control_id = payroll_control_rec.payroll_control_id;
559 END IF;
560 END IF;
561 END LOOP;
562 COMMIT;
563
564 /* Introduced as part of Bug fix #1776606 */
565 EXCEPTION
566 WHEN OTHERS THEN
567 g_error_api_path := 'MARK_BATCH_END: ' || g_error_api_path;
568 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','MARK_BATCH_END');
569 p_return_status := fnd_api.g_ret_sts_unexp_error;
570 RAISE;
571 END;
572 -------------------- CREATE GL SUM LINES -----------------------------------------------
573
574 PROCEDURE create_gl_sum_lines(p_source_type IN VARCHAR2,
575 p_source_code IN VARCHAR2,
576 p_time_period_id IN NUMBER,
577 p_batch_name IN VARCHAR2,
578 p_business_group_id IN NUMBER,
579 p_set_of_books_id IN NUMBER,
580 p_return_status OUT NOCOPY VARCHAR2) IS
581
582 CURSOR payroll_control_cur IS
583 SELECT payroll_control_id,
584 source_type,
585 payroll_source_code,
586 time_period_id,
587 batch_name,
588 gl_posting_override_date,
589 business_group_id,
590 set_of_books_id,
591 currency_code -- Introduced for Bug 2916848 Ilo Mrc
592 FROM psp_payroll_controls
593 WHERE source_type <> 'A'
594 AND run_id = g_run_id
595 AND (phase is null or
596 phase in ('GMS_Tie_Back', 'GL_Tie_Back')); ---- added for 2444657
597
598 CURSOR gl_sum_lines_cursor(P_PAYROLL_CONTROL_ID IN NUMBER) IS
599 SELECT ppl.person_id,
600 ppl.assignment_id,
601 decode(pdl.reversal_entry_flag,'Y',ppl.gl_code_combination_id,NULL,
602 nvl(pdl.suspense_auto_glccid, --- 5080403
603 nvl(pos.gl_code_combination_id,
604 nvl(pdl.auto_gl_code_combination_id, --- added for 2663344
605 nvl(psl.gl_code_combination_id,
606 nvl(pod.gl_code_combination_id,
607 nvl(pea.gl_code_combination_id,
608 pdls.gl_code_combination_id))))))) gl_ccid,
609 decode(pdl.reversal_entry_flag,'Y',decode(ppl.dr_cr_flag,'D','C','C','D'),NULL,ppl.dr_cr_flag) dr_cr_flag,
610 pdl.effective_date,
611 nvl(ppc.gl_posting_override_date, ppl.accounting_date) accounting_date,
612 nvl(ppl.exchange_rate_type,ppc.exchange_rate_type) exchange_rate_type, --- added for 3108109
613 pdl.distribution_amount,
614 pdl.distribution_line_id,
615 pdl.auto_gl_code_combination_id,
616 'D' tab_flag,
617 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute_category, pos.attribute_category), NULL) attribute_category, -- Introduced DFF columns for bug fix 2908859
618 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute1, pos.attribute8), NULL) attribute1,
619 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute2, pos.attribute8), NULL) attribute2,
620 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute3, pos.attribute8), NULL) attribute3,
621 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute4, pos.attribute8), NULL) attribute4,
622 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute5, pos.attribute8), NULL) attribute5,
623 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute6, pos.attribute8), NULL) attribute6,
624 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute7, pos.attribute8), NULL) attribute7,
625 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute8, pos.attribute8), NULL) attribute8,
626 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute9, pos.attribute9), NULL) attribute9,
627 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute10, pos.attribute10), NULL) attribute10
628 ---decode(pdl.suspense_org_account_id, NULL, 'N', 'Y') Suspense_Flag commented for 2663344
629 FROM psp_schedule_lines psl,
630 psp_organization_accounts pod,
631 psp_organization_accounts pos,
632 psp_element_type_accounts pea,
633 psp_default_labor_schedules pdls,
634 psp_payroll_controls ppc,
635 psp_payroll_lines ppl,
636 psp_payroll_sub_lines ppsl,
637 psp_distribution_lines pdl
638 WHERE pdl.status_code = 'N'
639 AND pdl.payroll_sub_line_id = ppsl.payroll_sub_line_id
640 AND ppsl.payroll_line_id = ppl.payroll_line_id
641 AND ppl.payroll_control_id = ppc.payroll_control_id
642 AND pdl.gl_project_flag = 'G'
643 AND pdl.distribution_amount <> 0
644 AND ppc.payroll_control_id = p_payroll_control_id
645 AND ppc.business_group_id = p_business_group_id
646 AND ppc.set_of_books_id = p_set_of_books_id
647 AND pdl.schedule_line_id = psl.schedule_line_id(+)
648 AND pdl.default_org_account_id = pod.organization_account_id(+)
649 AND pdl.element_account_id = pea.element_account_id(+)
650 AND pdl.org_schedule_id = pdls.org_schedule_id(+)
651 AND pdl.suspense_org_account_id = pos.organization_account_id(+)
652 AND pdl.cap_excess_glccid is null
653 UNION
654 SELECT ppg.person_id,
655 ppg.assignment_id,
656 nvl(ppg.suspense_auto_glccid,
657 nvl(pos.gl_code_combination_id,
658 ppg.gl_code_combination_id)) gl_ccid,
659 decode(ppg.reversal_entry_flag, 'Y', decode(ppg.dr_cr_flag, 'C', 'D', 'D', 'C'), ppg.dr_cr_flag) dr_cr_flag,
660 ppg.effective_date,
661 ppc.gl_posting_override_date accounting_date, --- 3108109
662 ppc.exchange_rate_type, --- added for 3108109
663 ppg.distribution_amount,
664 ppg.pre_gen_dist_line_id distribution_line_id,
665 to_number(NULL) auto_gl_code_combination_id, -- Place holder for auto pop details
666 'P' tab_flag,
667 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute_category, pos.attribute_category), NULL) attribute_category, -- Introduced DFF columns for bug fix 2908859
668 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute1, pos.attribute1), NULL) attribute1,
669 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute2, pos.attribute2), NULL) attribute2,
670 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute3, pos.attribute3), NULL) attribute3,
671 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute4, pos.attribute4), NULL) attribute4,
672 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute5, pos.attribute5), NULL) attribute5,
673 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute6, pos.attribute6), NULL) attribute6,
674 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute7, pos.attribute7), NULL) attribute7,
675 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute8, pos.attribute8), NULL) attribute8,
676 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute9, pos.attribute9), NULL) attribute9,
677 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute10, pos.attribute10), NULL) attribute10
678 ---decode(ppg.suspense_org_Account_id, NULL, 'N', 'Y') Suspense_Flag commented for 2663344
679 FROM psp_pre_gen_dist_lines ppg,
680 psp_organization_accounts pos,
681 psp_payroll_controls ppc
682 WHERE ppg.status_code = 'N'
683 /* changed following condition for bug 2007521 */
684 AND ((ppg.gl_code_combination_id IS NOT NULL and pos.project_id is null)
685 OR pos.gl_code_combination_id IS NOT NULL)
686 AND ppg.suspense_org_account_id = pos.organization_account_id(+)
687 AND ppg.payroll_control_id = p_payroll_control_id
688 AND ppg.business_group_id = p_business_group_id
689 AND ppg.set_of_books_id = p_set_of_books_id
690 AND ppc.payroll_control_id = p_payroll_control_id
691 UNION
692 SELECT ppl.person_id,
693 ppl.assignment_id,
694 decode(pdl.reversal_entry_flag,'Y',ppl.gl_code_combination_id,NULL,
695 nvl(pos.gl_code_combination_id,
696 nvl(pdl.auto_gl_code_combination_id, pdl.cap_excess_glccid))) gl_ccid,
697 decode(pdl.reversal_entry_flag,'Y',decode(ppl.dr_cr_flag,'D','C','C','D'),NULL,ppl.dr_cr_flag) dr_cr_flag,
698 pdl.effective_date,
699 nvl(ppc.gl_posting_override_date, ppl.accounting_date) accounting_date,
700 nvl(ppl.exchange_rate_type,ppc.exchange_rate_type) exchange_rate_type, --- added for 3108109
701 pdl.distribution_amount,
702 pdl.distribution_line_id,
703 pdl.auto_gl_code_combination_id,
704 'D' tab_flag,
705 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute_category, pos.attribute_category), NULL) attribute_category,
706 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute1, pos.attribute8), NULL) attribute1,
707 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute2, pos.attribute8), NULL) attribute2,
708 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute3, pos.attribute8), NULL) attribute3,
709 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute4, pos.attribute8), NULL) attribute4,
710 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute5, pos.attribute8), NULL) attribute5,
711 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute6, pos.attribute8), NULL) attribute6,
712 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute7, pos.attribute8), NULL) attribute7,
713 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute8, pos.attribute8), NULL) attribute8,
714 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute9, pos.attribute9), NULL) attribute9,
715 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute10, pos.attribute10), NULL) attribute10
716 FROM psp_payroll_controls ppc,
717 psp_payroll_lines ppl,
718 psp_payroll_sub_lines ppsl,
719 psp_organization_accounts pos,
720 psp_distribution_lines pdl
721 WHERE pdl.status_code = 'N'
722 AND pdl.payroll_sub_line_id = ppsl.payroll_sub_line_id
723 AND ppsl.payroll_line_id = ppl.payroll_line_id
724 AND ppl.payroll_control_id = ppc.payroll_control_id
725 AND pdl.gl_project_flag = 'G'
726 AND pdl.distribution_amount <> 0
727 AND ppc.payroll_control_id = p_payroll_control_id
728 AND ppc.business_group_id = p_business_group_id
729 AND ppc.set_of_books_id = p_set_of_books_id
730 AND pdl.suspense_org_account_id = pos.organization_account_id(+)
731 AND pdl.cap_excess_glccid is not null
732 AND pdl.reversal_entry_flag is null
733 ORDER BY 1,2,3,4,6,7,12,13,14,15,16,17,18,19,20,21,22,5;
734 --- order by accounting_date, exchange_rate_type for 3108109
735 --- order by attribute_category, attribute1 through attribute 10 for BUG 6007017
736
737
738 -- l_sob_id NUMBER(15) := FND_PROFILE.VALUE('PSP_SET_OF_BOOKS'); -- This comes as a param
739 l_person_id NUMBER(9);
740 l_assignment_id NUMBER(9);
741 l_gl_ccid NUMBER(15);
742 l_dr_cr_flag VARCHAR2(1);
743 l_effective_date DATE;
744 l_distribution_amount NUMBER;
745 l_rec_count NUMBER := 0;
746 l_summary_amount NUMBER := 0;
747
748 l_summary_line_id NUMBER(10);
749 gl_sum_lines_rec gl_sum_lines_cursor%ROWTYPE;
750
751 l_attribute_category VARCHAR2(30); -- Introduced variables for storing DFF values for bug fix 2908859
752 l_attribute1 VARCHAR2(150);
753 l_attribute2 VARCHAR2(150);
754 l_attribute3 VARCHAR2(150);
755 l_attribute4 VARCHAR2(150);
756 l_attribute5 VARCHAR2(150);
757 l_attribute6 VARCHAR2(150);
758 l_attribute7 VARCHAR2(150);
759 l_attribute8 VARCHAR2(150);
760 l_attribute9 VARCHAR2(150);
761 l_attribute10 VARCHAR2(150);
762
763 TYPE dist_id IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
764 dist_line_id dist_id;
765 l_dist_line_id NUMBER;
766 i BINARY_INTEGER := 0;
767 j NUMBER;
768 l_return_status VARCHAR2(10);
769 payroll_control_rec payroll_control_cur%ROWTYPE;
770 l_precision NUMBER;
771 l_ext_precision NUMBER;
772 l_accounting_date DATE; --- added 6 variables for 3108109
773 l_exchange_rate_type VARCHAR2(30);
774 l_value VARCHAR2(200);
775 l_table VARCHAR2(100);
776 l_period_end_date DATE;
777 l_begin_of_time DATE := to_date('01/01/1900','dd/mm/yyyy');
778
779 BEGIN
780 OPEN payroll_control_cur;
781 LOOP
782 FETCH payroll_control_cur INTO payroll_control_rec;
783 IF payroll_control_cur%NOTFOUND THEN
784 CLOSE payroll_control_cur;
785 EXIT;
786 END IF;
787
788 -- added for 3108109
789 BEGIN
790 SELECT end_date
791 INTO l_period_end_date
792 FROM per_time_periods
793 WHERE time_period_id = payroll_control_rec.time_period_id;
794 EXCEPTION
795 WHEN NO_DATA_FOUND THEN
796 l_value := 'Time Period Id = '||to_char(payroll_control_rec.time_period_id);
797 l_table := 'PER_TIME_PERIODS';
798 fnd_message.set_name('PSP','PSP_TR_VALUE_NOT_FOUND');
799 fnd_message.set_token('VALUE',l_value);
800 fnd_message.set_token('TABLE',l_table);
801 fnd_msg_pub.add;
802 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
803 END;
804
805
806 -- Made the following call for Bug 2916848 to populate l_precision , l_ext_precision
807 psp_general.get_currency_precision(payroll_control_rec.currency_code,l_precision,l_ext_precision);
808
809 -- create balancing transactions for GL
810 gl_balance_transaction(payroll_control_rec.source_type,
811 payroll_control_rec.payroll_control_id,
812 p_business_group_id,
813 p_set_of_books_id,
814 l_precision,-- Introduced for Bug 2916848
815 l_return_status);
816
817 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
818 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
819 END IF;
820
821 OPEN gl_sum_lines_cursor(payroll_control_rec.payroll_control_id);
822 l_rec_count := 0;
823 l_summary_amount := 0;
824 i := 0;
825 LOOP
826 FETCH gl_sum_lines_cursor INTO gl_sum_lines_rec;
827 l_rec_count := l_rec_count + 1;
828
829 IF gl_sum_lines_cursor%ROWCOUNT = 0 THEN
830 CLOSE gl_sum_lines_cursor;
831 EXIT;
832 ELSIF gl_sum_lines_cursor%NOTFOUND THEN
833 update psp_payroll_controls set phase = 'Summarize_GL_Lines' ---2444657:changed from NULL
834 where payroll_control_id = payroll_control_rec.payroll_control_id;
835 CLOSE gl_sum_lines_cursor;
836 EXIT;
837 END IF;
838 --
839
840 IF l_rec_count = 1 THEN
841 l_person_id := gl_sum_lines_rec.person_id;
842 l_assignment_id := gl_sum_lines_rec.assignment_id;
843 l_gl_ccid := gl_sum_lines_rec.gl_ccid;
844 l_dr_cr_flag := gl_sum_lines_rec.dr_cr_flag;
845 l_effective_date := nvl(payroll_control_rec.gl_posting_override_date,gl_sum_lines_rec.effective_date);
846 l_accounting_date := gl_sum_lines_rec.accounting_date; -- added for 3108109
847 l_exchange_rate_type := gl_sum_lines_rec.exchange_rate_type; --- added for 3108109
848 l_attribute_category := gl_sum_lines_rec.attribute_category; -- Introduced DFF columns for bug fix 2908859
849 l_attribute1 := gl_sum_lines_rec.attribute1;
850 l_attribute2 := gl_sum_lines_rec.attribute2;
851 l_attribute3 := gl_sum_lines_rec.attribute3;
852 l_attribute4 := gl_sum_lines_rec.attribute4;
853 l_attribute5 := gl_sum_lines_rec.attribute5;
854 l_attribute6 := gl_sum_lines_rec.attribute6;
855 l_attribute7 := gl_sum_lines_rec.attribute7;
856 l_attribute8 := gl_sum_lines_rec.attribute8;
857 l_attribute9 := gl_sum_lines_rec.attribute9;
858 l_attribute10 := gl_sum_lines_rec.attribute10;
859 END IF;
860
861 IF l_person_id <> gl_sum_lines_rec.person_id OR
862 l_assignment_id <> gl_sum_lines_rec.assignment_id OR
863 l_gl_ccid <> gl_sum_lines_rec.gl_ccid OR
864 l_dr_cr_flag <> gl_sum_lines_rec.dr_cr_flag OR
865 (NVL(l_attribute_category, 'NULL') <> NVL(gl_sum_lines_rec.attribute_category, 'NULL')) OR -- Introduced DFF columns checks for bug fix 2908859
866 (NVL(l_attribute1, 'NULL') <> NVL(gl_sum_lines_rec.attribute1, 'NULL')) OR
867 (NVL(l_attribute2, 'NULL') <> NVL(gl_sum_lines_rec.attribute2, 'NULL')) OR
868 (NVL(l_attribute3, 'NULL') <> NVL(gl_sum_lines_rec.attribute3, 'NULL')) OR
869 (NVL(l_attribute4, 'NULL') <> NVL(gl_sum_lines_rec.attribute4, 'NULL')) OR
870 (NVL(l_attribute5, 'NULL') <> NVL(gl_sum_lines_rec.attribute5, 'NULL')) OR
871 (NVL(l_attribute6, 'NULL') <> NVL(gl_sum_lines_rec.attribute6, 'NULL')) OR
872 (NVL(l_attribute7, 'NULL') <> NVL(gl_sum_lines_rec.attribute7, 'NULL')) OR
873 (NVL(l_attribute8, 'NULL') <> NVL(gl_sum_lines_rec.attribute8, 'NULL')) OR
874 (NVL(l_attribute9, 'NULL') <> NVL(gl_sum_lines_rec.attribute9, 'NULL')) OR
875 (NVL(l_attribute10, 'NULL') <> NVL(gl_sum_lines_rec.attribute10, 'NULL')) OR
876 nvl(l_accounting_date,l_begin_of_time) <>
877 nvl(gl_sum_lines_rec.accounting_date,l_begin_of_time) OR --------- added two condns for 3108109
878 nvl(l_exchange_rate_type,'-999') <>
879 nvl(gl_sum_lines_rec.exchange_rate_type,'-999') THEN
880
881 -- insert into summary lines
882 insert_into_summary_lines(
883 l_summary_line_id,
884 l_person_id,
885 l_assignment_id,
886 payroll_control_rec.time_period_id,
887 l_effective_date,
888 nvl(l_accounting_date,l_period_end_date),
889 l_exchange_rate_type, --- added 2 vars for 3108109
890 payroll_control_rec.source_type,
891 payroll_control_rec.payroll_source_code,
892 payroll_control_rec.set_of_books_id,
893 l_gl_ccid,
894 NULL,
895 NULL,
896 NULL,
897 NULL,
898 NULL,
899 round(l_summary_amount,l_precision), -- For Bug 2916848 Ilo Mrc Ehn
900 l_dr_cr_flag,
901 'N',
902 payroll_control_rec.batch_name,
903 payroll_control_rec.payroll_control_id,
904 payroll_control_rec.business_group_id,
905 l_attribute_category, -- Introduced DFF columns for bug fix 2908859
906 l_attribute1,
907 l_attribute2,
908 l_attribute3,
909 l_attribute4,
910 l_attribute5,
911 l_attribute6,
912 l_attribute7,
913 l_attribute8,
914 l_attribute9,
915 l_attribute10,
916 l_return_status);
917
918 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
919 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
920 END IF;
921
922
923 FOR j IN 1 .. dist_line_id.COUNT LOOP
924 l_dist_line_id := dist_line_id(j);
925
926 IF gl_sum_lines_rec.tab_flag = 'D' THEN
927 UPDATE psp_distribution_lines
928 SET summary_line_id = l_summary_line_id WHERE distribution_line_id = l_dist_line_id;
929 ELSIF gl_sum_lines_rec.tab_flag = 'P' THEN
930 UPDATE psp_pre_gen_dist_lines
931 SET summary_line_id = l_summary_line_id WHERE pre_gen_dist_line_id = l_dist_line_id;
932 END IF;
933 END LOOP;
934
935 -- initialise the summary amount and dist_line_id
936 l_summary_amount := 0;
937 dist_line_id.delete;
938 i := 0;
939 END IF;
940
941 l_person_id := gl_sum_lines_rec.person_id;
942 l_assignment_id := gl_sum_lines_rec.assignment_id;
943 l_gl_ccid := gl_sum_lines_rec.gl_ccid;
944 l_dr_cr_flag := gl_sum_lines_rec.dr_cr_flag;
945 l_exchange_rate_type := gl_sum_lines_rec.exchange_rate_type; --- added for 3108109
946 l_accounting_date := gl_sum_lines_rec.accounting_date;
947 l_attribute_category := gl_sum_lines_rec.attribute_category; -- Introduced DFF columns for bug fix 2908859
948 l_attribute1 := gl_sum_lines_rec.attribute1;
949 l_attribute2 := gl_sum_lines_rec.attribute2;
950 l_attribute3 := gl_sum_lines_rec.attribute3;
951 l_attribute4 := gl_sum_lines_rec.attribute4;
952 l_attribute5 := gl_sum_lines_rec.attribute5;
953 l_attribute6 := gl_sum_lines_rec.attribute6;
954 l_attribute7 := gl_sum_lines_rec.attribute7;
955 l_attribute8 := gl_sum_lines_rec.attribute8;
956 l_attribute9 := gl_sum_lines_rec.attribute9;
957 l_attribute10 := gl_sum_lines_rec.attribute10;
958 -- If gl_posting_override_date is given, use it first
959 l_effective_date := nvl(payroll_control_rec.gl_posting_override_date,gl_sum_lines_rec.effective_date);
960 -- If gl_posting_override_date is given, use it first
961
962 l_summary_amount := l_summary_amount + gl_sum_lines_rec.distribution_amount;
963 i := i + 1;
964 dist_line_id(i) := gl_sum_lines_rec.distribution_line_id;
965
966 END LOOP;
967
968 IF l_rec_count > 1 THEN
969 -- insert into summary lines
970 insert_into_summary_lines(
971 l_summary_line_id,
972 l_person_id,
973 l_assignment_id,
974 payroll_control_rec.time_period_id,
975 l_effective_date,
976 nvl(l_accounting_date,l_period_end_date), --- added for 3108109
977 l_exchange_rate_type,
978 payroll_control_rec.source_type,
979 payroll_control_rec.payroll_source_code,
980 payroll_control_rec.set_of_books_id,
981 l_gl_ccid,
982 NULL,
983 NULL,
984 NULL,
985 NULL,
986 NULL,
987 round(l_summary_amount, l_precision),
988 l_dr_cr_flag,
989 'N',
990 payroll_control_rec.batch_name,
991 payroll_control_rec.payroll_control_id,
992 payroll_control_rec.business_group_id,
993 l_attribute_category, -- Introduced DFF columns for bug fix 2908859
994 l_attribute1,
995 l_attribute2,
996 l_attribute3,
997 l_attribute4,
998 l_attribute5,
999 l_attribute6,
1000 l_attribute7,
1001 l_attribute8,
1002 l_attribute9,
1003 l_attribute10,
1004 l_return_status);
1005
1006
1007 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1008 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1009 END IF;
1010
1011
1012
1013 FOR j IN 1 .. dist_line_id.COUNT LOOP
1014 l_dist_line_id := dist_line_id(j);
1015
1016 IF gl_sum_lines_rec.tab_flag = 'D' THEN
1017 UPDATE psp_distribution_lines
1018 SET summary_line_id = l_summary_line_id,
1019 status_code = 'N'
1020 WHERE distribution_line_id = l_dist_line_id;
1021 ELSIF gl_sum_lines_rec.tab_flag = 'P' THEN
1022 UPDATE psp_pre_gen_dist_lines
1023 SET summary_line_id = l_summary_line_id,
1024 status_code = 'N'
1025 WHERE pre_gen_dist_line_id = l_dist_line_id;
1026 END IF;
1027 END LOOP;
1028
1029 dist_line_id.delete;
1030 END IF;
1031
1032 END LOOP;
1033 --
1034 p_return_status := fnd_api.g_ret_sts_success;
1035
1036 EXCEPTION
1037
1038 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1039 g_error_api_path := 'CREATE_GL_SUM_LINES:'||g_error_api_path;
1040 p_return_status := fnd_api.g_ret_sts_unexp_error;
1041 WHEN OTHERS THEN
1042 g_error_api_path := 'CREATE_GL_SUM_LINES:'||g_error_api_path;
1043 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','CREATE_GL_SUM_LINES');
1044 p_return_status := fnd_api.g_ret_sts_unexp_error;
1045
1046 END;
1047
1048
1049 ---------------------- I N S E R T S T A T E M E N T ------------------------------------
1050 PROCEDURE insert_into_summary_lines(
1051 P_SUMMARY_LINE_ID OUT NOCOPY NUMBER,
1052 P_PERSON_ID IN NUMBER,
1053 P_ASSIGNMENT_ID IN NUMBER,
1054 P_TIME_PERIOD_ID IN NUMBER,
1055 P_EFFECTIVE_DATE IN DATE,
1056 P_ACCOUNTING_DATE IN DATE, --- added 2 vars for 3108109
1057 P_EXCHANGE_RATE_TYPE IN VARCHAR2,
1058 P_SOURCE_TYPE IN VARCHAR2,
1059 P_SOURCE_CODE IN VARCHAR2,
1060 P_SET_OF_BOOKS_ID IN NUMBER,
1061 P_GL_CODE_COMBINATION_ID IN NUMBER,
1062 P_PROJECT_ID IN NUMBER,
1063 P_EXPENDITURE_ORGANIZATION_ID IN NUMBER,
1064 P_EXPENDITURE_TYPE IN VARCHAR2,
1065 P_TASK_ID IN NUMBER,
1066 P_AWARD_ID IN NUMBER,
1067 P_SUMMARY_AMOUNT IN NUMBER,
1068 P_DR_CR_FLAG IN VARCHAR2,
1069 P_STATUS_CODE IN VARCHAR2,
1070 P_INTERFACE_BATCH_NAME IN VARCHAR2,
1071 P_PAYROLL_CONTROL_ID IN NUMBER,
1072 P_BUSINESS_GROUP_ID IN NUMBER,
1073 p_attribute_category IN VARCHAR2, -- Introduced DFF parameters for bug fix 2908859
1074 p_attribute1 IN VARCHAR2,
1075 p_attribute2 IN VARCHAR2,
1076 p_attribute3 IN VARCHAR2,
1077 p_attribute4 IN VARCHAR2,
1078 p_attribute5 IN VARCHAR2,
1079 p_attribute6 IN VARCHAR2,
1080 p_attribute7 IN VARCHAR2,
1081 p_attribute8 IN VARCHAR2,
1082 p_attribute9 IN VARCHAR2,
1083 p_attribute10 IN VARCHAR2,
1084 P_RETURN_STATUS OUT NOCOPY VARCHAR2,
1085 P_ORG_ID IN NUMBER DEFAULT NULL -- R12 MOAc uptake
1086 ) IS
1087 l_gms_posting_effective_date DATE;
1088 BEGIN
1089
1090 -- Code added for Enhancement Employee Assignment with Zero Work Days
1091 IF P_PROJECT_ID IS NOT NULL THEN
1092 l_gms_posting_effective_date:= p_effective_date;
1093 psp_general.get_gms_effective_date(p_person_id,l_gms_posting_effective_date);
1094 END IF;
1095 -- Code ended for Enhancement Employee Assignment with Zero Work Days
1096
1097 SELECT PSP_SUMMARY_LINES_S.NEXTVAL
1098 INTO P_SUMMARY_LINE_ID
1099 FROM DUAL;
1100 INSERT INTO PSP_SUMMARY_LINES(
1101 SUMMARY_LINE_ID,
1102 PERSON_ID,
1103 ASSIGNMENT_ID,
1104 TIME_PERIOD_ID,
1105 EFFECTIVE_DATE,
1106 ACCOUNTING_DATE, --- added 2 vars for 3108109
1107 EXCHANGE_RATE_TYPE,
1108 GMS_POSTING_EFFECTIVE_DATE, /* New column added for Enhancement Employee Assignment with Zero Work Days */
1109 SOURCE_TYPE,
1110 SOURCE_CODE,
1111 SET_OF_BOOKS_ID,
1112 GL_CODE_COMBINATION_ID,
1113 PROJECT_ID,
1114 EXPENDITURE_ORGANIZATION_ID,
1115 EXPENDITURE_TYPE,
1116 TASK_ID,
1117 AWARD_ID,
1118 SUMMARY_AMOUNT,
1119 DR_CR_FLAG,
1120 STATUS_CODE,
1121 INTERFACE_BATCH_NAME,
1122 PAYROLL_CONTROL_ID,
1123 BUSINESS_GROUP_ID,
1124 LAST_UPDATE_DATE,
1125 LAST_UPDATED_BY,
1126 LAST_UPDATE_LOGIN,
1127 CREATED_BY,
1128 CREATION_DATE,
1129 ACTUAL_SUMMARY_AMOUNT, --For Bug 2496661
1130 attribute_category, -- Introduced for bug fix 2908859
1131 attribute1,
1132 attribute2,
1133 attribute3,
1134 attribute4,
1135 attribute5,
1136 attribute6,
1137 attribute7,
1138 attribute8,
1139 attribute9,
1140 attribute10,
1141 org_id -- R12 MOAc uptake
1142 )
1143 VALUES(
1144 P_SUMMARY_LINE_ID,
1145 P_PERSON_ID,
1146 P_ASSIGNMENT_ID,
1147 P_TIME_PERIOD_ID,
1148 P_EFFECTIVE_DATE,
1149 P_ACCOUNTING_DATE, -- added 2 vars for 3108109
1150 P_EXCHANGE_RATE_TYPE,
1151 L_GMS_POSTING_EFFECTIVE_DATE, /* New column added for Enhancement Employee Assignment with Zero Work Days */
1152 P_SOURCE_TYPE,
1153 P_SOURCE_CODE,
1154 P_SET_OF_BOOKS_ID,
1155 P_GL_CODE_COMBINATION_ID,
1156 P_PROJECT_ID,
1157 P_EXPENDITURE_ORGANIZATION_ID,
1158 P_EXPENDITURE_TYPE,
1159 P_TASK_ID,
1160 P_AWARD_ID,
1161 P_SUMMARY_AMOUNT,
1162 P_DR_CR_FLAG,
1163 P_STATUS_CODE,
1164 P_INTERFACE_BATCH_NAME,
1165 P_PAYROLL_CONTROL_ID,
1166 P_BUSINESS_GROUP_ID,
1167 SYSDATE,
1168 FND_GLOBAL.USER_ID,
1169 FND_GLOBAL.LOGIN_ID,
1170 FND_GLOBAL.USER_ID,
1171 SYSDATE,
1172 DECODE(P_PROJECT_ID, NULL,P_SUMMARY_AMOUNT, DECODE(P_DR_CR_FLAG,'C',0 - P_SUMMARY_AMOUNT,P_SUMMARY_AMOUNT)), --For Bug 2496661
1173 p_attribute_category, -- Introduced for bug fix 2908859
1174 p_attribute1,
1175 p_attribute2,
1176 p_attribute3,
1177 p_attribute4,
1178 p_attribute5,
1179 p_attribute6,
1180 p_attribute7,
1181 p_attribute8,
1182 p_attribute9,
1183 p_attribute10,
1184 p_org_id -- R12 MOAC uptake
1185 );
1186 --
1187 p_return_status := fnd_api.g_ret_sts_success;
1188 EXCEPTION
1189 WHEN OTHERS THEN
1190 --dbms_output.put_line('Errrrrrrrrrrrrrrrrrrrrrrrrrrorrrrrrrrrrr.........');
1191 g_error_api_path := 'INSERT_INTO_SUMMARY_LINES:'||g_error_api_path;
1192 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','INSERT_INTO_SUMMARY_LINES');
1193 p_return_status := fnd_api.g_ret_sts_unexp_error;
1194 END;
1195
1196 ------------------------ GL INTERFACE --------------------------------------------------
1197
1198 PROCEDURE transfer_to_gl_interface(p_source_type IN VARCHAR2,
1199 p_source_code IN VARCHAR2,
1200 p_time_period_id IN NUMBER,
1201 p_batch_name IN VARCHAR2,
1202 p_business_group_id IN NUMBER,
1203 p_set_of_books_id IN NUMBER,
1204 p_return_status OUT NOCOPY VARCHAR2) IS
1205
1206 /* Broke the gl_batch_cursor into gl_batch_cursor,gl_payroll_control_cursor for Bug 3112053 */
1207 CURSOR gl_batch_cursor IS
1208 SELECT DISTINCT source_type,
1209 payroll_source_code,
1210 time_period_id,
1211 batch_name,
1212 phase --- 2444657, to separate the old and new gl imports
1213 --- S and T can pull control recs with statuses 'I' and 'N' now
1214 FROM psp_payroll_controls
1215 WHERE status_code = 'I'
1216 AND source_type <> 'A'
1217 AND run_id = g_run_id
1218 AND phase in ('Summarize_GL_Lines', 'Submitted_JI_Request'); --- 2444657: added the condition
1219
1220
1221 CURSOR gl_payroll_control_cursor(p_source_type in varchar2, p_source_code in varchar2,
1222 p_time_period_id in number, p_batch_name in varchar2,
1223 p_phase varchar2) IS
1224
1225 SELECT payroll_control_id,
1226 currency_code,
1227 exchange_rate_type,
1228 phase --- 2444657: added
1229 FROM psp_payroll_controls
1230 WHERE source_type = p_source_type
1231 AND payroll_source_code = p_source_code
1232 AND time_period_id = p_time_period_id
1233 AND nvl(batch_name,'N') = nvl(nvl(p_batch_name,batch_name),'N')
1234 AND (dist_dr_amount IS NOT NULL OR dist_cr_amount IS NOT NULL)
1235 AND status_code = 'I'
1236 AND source_type <> 'A'
1237 AND business_group_id = p_business_group_id
1238 AND set_of_books_id = p_set_of_books_id
1239 AND run_id = g_run_id
1240 AND phase = p_phase; --- 2444657: added the condition;
1241
1242 /* End of code changes for bug 3112053 */
1243
1244 CURSOR gl_interface_cursor(l_payroll_control_id IN NUMBER) IS
1245 SELECT psl.summary_line_id,
1246 psl.source_code,
1247 psl.effective_date,
1248 psl.accounting_date, -- added 2 cols for 3108109
1249 psl.exchange_Rate_type,
1250 psl.set_of_books_id,
1251 psl.gl_code_combination_id,
1252 psl.summary_amount,
1253 psl.dr_cr_flag,
1254 psl.attribute1,
1255 psl.attribute2,
1256 psl.attribute3,
1257 psl.attribute4,
1258 psl.attribute5,
1259 psl.attribute6,
1260 psl.attribute7,
1261 psl.attribute8,
1262 psl.attribute9,
1263 psl.attribute10,
1264 psl.attribute11,
1265 psl.attribute12,
1266 psl.attribute13,
1267 psl.attribute14,
1268 psl.attribute15,
1269 psl.attribute16,
1270 psl.attribute17,
1271 psl.attribute18,
1272 psl.attribute19,
1273 psl.attribute20,
1274 psl.attribute21,
1275 psl.attribute22,
1276 psl.attribute23,
1277 psl.attribute24,
1278 psl.attribute25,
1279 psl.attribute26,
1280 psl.attribute27,
1281 psl.attribute28,
1282 psl.attribute29,
1283 psl.attribute30
1284 FROM psp_summary_lines psl
1285 WHERE psl.status_code = 'N'
1286 AND psl.gl_code_combination_id IS NOT NULL
1287 AND psl.payroll_control_id = l_payroll_control_id;
1288
1289 gl_batch_rec gl_batch_cursor%ROWTYPE;
1290 gl_payroll_control_rec gl_payroll_control_cursor%ROWTYPE; -- Introduced for Bug 3112053
1291 gl_interface_rec gl_interface_cursor%ROWTYPE;
1292
1293 l_user_je_source_name VARCHAR2(25);
1294 l_user_je_category_name VARCHAR2(25);
1295 l_period_name VARCHAR2(35);
1296 l_period_end_date DATE; ------ Bug 2663344: reverted commenting
1297 l_encumbrance_type_id NUMBER(15);
1298 l_entered_dr NUMBER;
1299 l_entered_cr NUMBER;
1300 l_group_id NUMBER;
1301 l_int_run_id NUMBER;
1302 l_reference1 VARCHAR2(100);
1303 l_reference4 VARCHAR2(100);
1304 l_return_status VARCHAR2(10);
1305 req_id NUMBER(15);
1306 call_status BOOLEAN;
1307 rphase VARCHAR2(30);
1308 rstatus VARCHAR2(30);
1309 dphase VARCHAR2(30);
1310 dstatus VARCHAR2(30);
1311 message VARCHAR2(240);
1312 p_errbuf VARCHAR2(32767);
1313 p_retcode VARCHAR2(32767);
1314 return_back EXCEPTION;
1315 l_rec_count NUMBER := 0;
1316 l_error VARCHAR2(100);
1317 l_product VARCHAR2(3);
1318 l_value VARCHAR2(200);
1319 l_table VARCHAR2(100);
1320 BEGIN
1321
1322 -- get the source name
1323 get_gl_je_sources(l_user_je_source_name,
1324 l_return_status);
1325 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1326 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1327 END IF;
1328
1329 -- get the category name
1330 get_gl_je_categories(l_user_je_category_name,
1331 l_return_status);
1332 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1333 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1334 END IF;
1335
1336 /* Changed the following code for Bug 3112053 , so as to submit one journal import for a batch having same
1337 source_code,source_type,time_period_id,batch_name combination */
1338
1339 OPEN gl_batch_cursor;
1340 LOOP
1341
1342 FETCH gl_batch_cursor INTO gl_batch_rec;
1343
1344 IF gl_batch_cursor%NOTFOUND THEN
1345 CLOSE gl_batch_cursor;
1346 EXIT;
1347 END IF;
1348
1349 -- get the group_id
1350
1351 SELECT gl_interface_control_s.nextval
1352 INTO l_group_id
1353 FROM dual;
1354
1355 BEGIN
1356 --- uncommented the end date for 2663344
1357 SELECT substr(period_name,1,35),end_date
1358 INTO l_period_name, l_period_end_date
1359 FROM per_time_periods
1360 WHERE time_period_id = gl_batch_rec.time_period_id;
1361 EXCEPTION
1362 WHEN NO_DATA_FOUND THEN
1363 l_value := 'Time Period Id = '||to_char(gl_batch_rec.time_period_id);
1364 l_table := 'PER_TIME_PERIODS';
1365 fnd_message.set_name('PSP','PSP_TR_VALUE_NOT_FOUND');
1366 fnd_message.set_token('VALUE',l_value);
1367 fnd_message.set_token('TABLE',l_table);
1368 fnd_msg_pub.add;
1369 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1370 END;
1371
1372 If gl_batch_rec.phase = 'Summarize_GL_Lines' then --- added for 2444657
1373 l_reference1 := gl_batch_rec.source_type||':'||gl_batch_rec.payroll_source_code||':'||l_period_name||':'||gl_batch_rec.batch_name;
1374
1375 l_reference4 := 'LD ACTUALS DISTRIBUTION';
1376
1377 OPEN gl_payroll_control_cursor(gl_batch_rec.source_type, gl_batch_rec.payroll_source_code,
1378 gl_batch_rec.time_period_id, gl_batch_rec.batch_name, gl_batch_rec.phase);
1379
1380 l_rec_count := 0;
1381
1382 LOOP
1383 FETCH gl_payroll_control_cursor INTO gl_payroll_control_rec;
1384 EXIT WHEN gl_payroll_control_cursor%NOTFOUND;
1385 -- update psp_summary_lines with group_id
1386
1387 UPDATE psp_summary_lines
1388 SET group_id = l_group_id
1389 WHERE status_code = 'N'
1390 AND gl_code_combination_id IS NOT NULL
1391 AND payroll_control_id = gl_payroll_control_rec.payroll_control_id;
1392
1393 OPEN gl_interface_cursor(gl_payroll_control_rec.payroll_control_id);
1394 LOOP
1395 FETCH gl_interface_cursor INTO gl_interface_rec;
1396 IF gl_interface_cursor%NOTFOUND THEN
1397 CLOSE gl_interface_cursor;
1398 EXIT;
1399 END IF;
1400
1401 l_rec_count := l_rec_count + 1;
1402
1403 IF gl_interface_rec.dr_cr_flag = 'D' THEN
1404 l_entered_dr := gl_interface_rec.summary_amount;
1405 l_entered_cr := NULL;
1406 ELSIF gl_interface_rec.dr_cr_flag = 'C' THEN
1407 l_entered_dr := NULL;
1408 l_entered_cr := gl_interface_rec.summary_amount;
1409 END IF;
1410
1411 -- dbms_output.put_line('Inserting into gl interface .............');
1412
1413 -- Changed The parameter g_currency_code to gl_batch_rec.currency_code, Introduced exchange_rate_type
1414 -- and conversion_date for Bug fix 2916848
1415 insert_into_gl_interface(
1416 P_SET_OF_BOOKS_ID, GL_INTERFACE_REC.EFFECTIVE_DATE,
1417 gl_payroll_control_rec.CURRENCY_CODE,
1418 L_USER_JE_CATEGORY_NAME,L_USER_JE_SOURCE_NAME,L_ENCUMBRANCE_TYPE_ID,
1419 GL_INTERFACE_REC.GL_CODE_COMBINATION_ID,L_ENTERED_DR,L_ENTERED_CR,
1420 L_GROUP_ID,L_REFERENCE1,L_REFERENCE1,L_REFERENCE4,
1421 GL_INTERFACE_REC.SUMMARY_LINE_ID,L_REFERENCE4,
1422 GL_INTERFACE_REC.ATTRIBUTE1,GL_INTERFACE_REC.ATTRIBUTE2,
1423 GL_INTERFACE_REC.ATTRIBUTE3,GL_INTERFACE_REC.ATTRIBUTE4,
1424 GL_INTERFACE_REC.ATTRIBUTE5,GL_INTERFACE_REC.ATTRIBUTE6,
1425 GL_INTERFACE_REC.ATTRIBUTE7,GL_INTERFACE_REC.ATTRIBUTE8,
1426 GL_INTERFACE_REC.ATTRIBUTE9,GL_INTERFACE_REC.ATTRIBUTE10,
1427 GL_INTERFACE_REC.ATTRIBUTE11,GL_INTERFACE_REC.ATTRIBUTE12,
1428 GL_INTERFACE_REC.ATTRIBUTE13,GL_INTERFACE_REC.ATTRIBUTE14,
1429 GL_INTERFACE_REC.ATTRIBUTE15,GL_INTERFACE_REC.ATTRIBUTE16,
1430 GL_INTERFACE_REC.ATTRIBUTE17,GL_INTERFACE_REC.ATTRIBUTE18,
1431 GL_INTERFACE_REC.ATTRIBUTE19,GL_INTERFACE_REC.ATTRIBUTE20,
1432 GL_INTERFACE_REC.ATTRIBUTE21,GL_INTERFACE_REC.ATTRIBUTE22,
1433 GL_INTERFACE_REC.ATTRIBUTE23,GL_INTERFACE_REC.ATTRIBUTE24,
1434 GL_INTERFACE_REC.ATTRIBUTE25,GL_INTERFACE_REC.ATTRIBUTE26,
1435 GL_INTERFACE_REC.ATTRIBUTE27,GL_INTERFACE_REC.ATTRIBUTE28,
1436 GL_INTERFACE_REC.ATTRIBUTE29,GL_INTERFACE_REC.ATTRIBUTE30,
1437 GL_INTERFACE_REC.EXCHANGE_RATE_TYPE, -- modified for 3108109
1438 GL_INTERFACE_REC.ACCOUNTING_DATE,
1439 -- Introduced for Bug 2916848
1440 L_RETURN_STATUS);
1441
1442 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1443 --dbms_output.put_line('Faaaaaaiiiiiiilllllllleeeeeeeeeddddddd......');
1444 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1445 END IF;
1446
1447 END LOOP; -- End of gl_interface_cursor
1448
1449 END LOOP; -- End of gl_payroll_control_cursor
1450 CLOSE gl_payroll_control_cursor;
1451
1452 else --- 2444657 ...phase = Submitted_JI_Request
1453 select group_id
1454 into l_group_id
1455 from psp_summary_lines
1456 where payroll_control_id in
1457 (SELECT payroll_control_id
1458 FROM psp_payroll_controls
1459 WHERE source_type = gl_batch_rec.source_type
1460 AND payroll_source_code = gl_batch_rec.payroll_source_code
1461 AND time_period_id = gl_batch_rec.time_period_id
1462 AND nvl(batch_name,'N') = nvl(nvl(gl_batch_rec.batch_name,batch_name),'N')
1463 AND (dist_dr_amount IS NOT NULL OR dist_cr_amount IS NOT NULL)
1464 AND status_code = 'I'
1465 AND business_group_id = p_business_group_id
1466 AND set_of_books_id = p_set_of_books_id
1467 AND run_id = g_run_id
1468 AND phase = 'Submitted_JI_Request')
1469 and gl_code_combination_id is not null
1470 and rownum = 1;
1471 end if; --- 2444657
1472
1473 IF l_rec_count > 0 and gl_batch_rec.phase = 'Summarize_GL_Lines' THEN ---added phase for 2444657
1474
1475 -- Call the gather table statistics here....
1476 BEGIN
1477
1478 FND_STATS.Gather_Table_Stats(ownname => 'GL',
1479 tabname => 'GL_INTERFACE');
1480 /* commented for , 2476829
1481 percent => 10,
1482 tmode => 'TEMPORARY'); */
1483
1484 EXCEPTION
1485
1486 WHEN others THEN
1487 NULL;
1488 END;
1489
1490 -- insert into gl_interface_control
1491
1492 SELECT GL_JOURNAL_IMPORT_S.NEXTVAL
1493 INTO l_int_run_id
1494 FROM dual;
1495
1496 INSERT into gl_interface_control(je_source_name,status,interface_run_id,
1497 group_id,set_of_books_id)
1498 VALUES (l_user_je_source_name, 'S',l_int_run_id,
1499 l_group_id,p_set_of_books_id);
1500
1501 --dbms_output.put_line('Calling GL .............');
1502
1503 req_id := fnd_request.submit_request(
1504 'SQLGL',
1505 'GLLEZL',
1506 '',
1507 '',
1508 FALSE,
1509 to_char(l_int_run_id),
1510 -- to_char(l_sob_id), -- Changed for MO
1511 to_char(p_set_of_books_id),
1512 'N',
1513 '',
1514 '', -- added for bug fix 2365769
1515 g_enable_enc_summ_gl, -- changed from '' for bug 2259310
1516 'W' -- removed extra 'N' for bug 2365769 Changed 'N' tp 'W' for bug fix 2908859
1517 );
1518
1519 IF req_id = 0 THEN
1520
1521 fnd_message.set_name('PSP','PSP_TR_GL_IMP_FAILED');
1522 fnd_msg_pub.add;
1523 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1524
1525 ELSE
1526
1527 -- Added the update for Rollback purposes.
1528 UPDATE psp_payroll_controls
1529 SET phase = 'Submitted_JI_Request'
1530 -- Introduced selective payroll control filter for bug fix 3157895
1531 WHERE source_type = NVL(gl_batch_rec.source_type, source_type)
1532 AND payroll_source_code = NVL(gl_batch_rec.payroll_source_code, payroll_source_code)
1533 AND time_period_id = NVL(gl_batch_rec.time_period_id, time_period_id)
1534 AND NVL(batch_name,'N') = NVL(NVL(gl_batch_rec.batch_name, batch_name), 'N')
1535 AND status_code = 'I'
1536 AND business_group_id = p_business_group_id
1537 AND set_of_books_id = p_set_of_books_id
1538 AND run_id = g_run_id;
1539 commit;
1540
1541 gl_batch_rec.phase := 'Submitted_JI_Request'; ---2444657
1542 call_status := fnd_concurrent.wait_for_request(req_id, 20, 0,
1543 rphase, rstatus, dphase, dstatus, message);
1544
1545 IF call_status = FALSE THEN
1546
1547 fnd_message.set_name('PSP','PSP_TR_GL_IMP_FAILED');
1548 fnd_msg_pub.add;
1549 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1550
1551 END IF;
1552
1553 END IF; -- End for check req_id = 0
1554 END IF; --- 2444657
1555
1556 /* Performing Gl tie Back for a set of control_ids having the same source_type,
1557 payroll_source_code, time_period_id, batch_name combination */
1558
1559
1560 OPEN gl_payroll_control_cursor(gl_batch_rec.source_type,
1561 gl_batch_rec.payroll_source_code, gl_batch_rec.time_period_id,
1562 gl_batch_rec.batch_name, gl_batch_rec.phase);
1563 LOOP
1564 FETCH gl_payroll_control_cursor INTO gl_payroll_control_rec;
1565 EXIT WHEN gl_payroll_control_cursor%NOTFOUND;
1566
1567
1568 -- mark the successfully transferred records as 'A' in psp_summary_lines and psp_distribution_lines
1569 -- and transfer the successful records to the history table
1570 -- 1874696:changed l_period_end_date to NULL in tie back call
1571 -- Bug 22663344 reverted null value to l_period_end_date
1572 gl_tie_back(gl_payroll_control_rec.payroll_control_id,
1573 gl_batch_rec.source_type,
1574 l_period_end_date,
1575 l_group_id,
1576 p_business_group_id,
1577 p_set_of_books_id,
1578 'N',
1579 l_return_status);
1580
1581 /* Bug 1617846 LD Recovery LOV not showing up fialed S and T */
1582 /* introduced ELSE clause */
1583
1584 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1585 CLOSE gl_payroll_control_cursor;
1586 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1587 END IF;
1588
1589 END LOOP;
1590 CLOSE gl_payroll_control_cursor;
1591
1592 COMMIT;
1593
1594 END LOOP; -- End of gl_batch_csr
1595
1596 /* End of code changes for Bug 3112053 */
1597
1598 p_return_status := fnd_api.g_ret_sts_success;
1599
1600 EXCEPTION
1601 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1602 --dbms_output.put_line('Gone to one level top ..................');
1603 g_error_api_path := 'TRANSFER_TO_GL_INTERFACE:'||g_error_api_path;
1604 p_return_status := fnd_api.g_ret_sts_unexp_error;
1605
1606 WHEN RETURN_BACK THEN
1607 p_return_status := fnd_api.g_ret_sts_success;
1608
1609 WHEN OTHERS THEN
1610 g_error_api_path := 'TRANSFER_TO_GL_INTERFACE:'||g_error_api_path;
1611 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','TRANSFER_TO_GL_INTERFACE');
1612 p_return_status := fnd_api.g_ret_sts_unexp_error;
1613 END;
1614
1615 ---------------------- GET_GL_JE_SOURCES --------------------------------------------------
1616 PROCEDURE get_gl_je_sources(P_USER_JE_SOURCE_NAME OUT NOCOPY VARCHAR2,
1617 P_RETURN_STATUS OUT NOCOPY VARCHAR2) IS
1618 l_error VARCHAR2(100);
1619 l_product VARCHAR2(3);
1620 BEGIN
1621 SELECT user_je_source_name
1622 INTO p_user_je_source_name
1623 FROM gl_je_sources
1624 WHERE je_source_name = 'OLD';
1625 EXCEPTION
1626 WHEN NO_DATA_FOUND THEN
1627 l_error := 'JE SOURCES = OLD';
1628 l_product := 'GL';
1629 fnd_message.set_name('PSP','PSP_TR_NOT_SET_UP');
1630 fnd_message.set_token('ERROR',l_error);
1631 fnd_message.set_token('PRODUCT',l_product);
1632 fnd_msg_pub.add;
1633 p_return_status := fnd_api.g_ret_sts_unexp_error;
1634 WHEN OTHERS THEN
1635 g_error_api_path := 'GL_JE_SOURCES:'||g_error_api_path;
1636 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','GL_JE_SOURCES');
1637 p_return_status := fnd_api.g_ret_sts_unexp_error;
1638 END;
1639
1640 ---------------------- GET_GL_CATEGORIES --------------------------------------------------
1641 PROCEDURE get_gl_je_categories(P_USER_JE_CATEGORY_NAME OUT NOCOPY VARCHAR2,
1642 P_RETURN_STATUS OUT NOCOPY VARCHAR2) IS
1643 l_error VARCHAR2(100);
1644 l_product VARCHAR2(3);
1645 BEGIN
1646 SELECT user_je_category_name
1647 INTO p_user_je_category_name
1648 FROM gl_je_categories
1649 WHERE je_category_name = 'OLD';
1650 EXCEPTION
1651 WHEN NO_DATA_FOUND THEN
1652 l_error := 'JE CATEGORY = OLD';
1653 l_product := 'GL';
1654 fnd_message.set_name('PSP','PSP_TR_NOT_SET_UP');
1655 fnd_message.set_token('ERROR',l_error);
1656 fnd_message.set_token('PRODUCT',l_product);
1657 fnd_msg_pub.add;
1658 p_return_status := fnd_api.g_ret_sts_unexp_error;
1659 WHEN OTHERS THEN
1660 g_error_api_path := 'GL_JE_CATEGORY_NAME:'||g_error_api_path;
1661 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','GL_JE_CATEGORY_NAME');
1662 p_return_status := fnd_api.g_ret_sts_unexp_error;
1663 END;
1664
1665 ---------------------- GET_ENCUM_TYPE_ID -----------------------------------------------
1666 PROCEDURE get_encum_type_id(P_ENCUMBRANCE_TYPE_ID OUT NOCOPY VARCHAR2,
1667 P_RETURN_STATUS OUT NOCOPY VARCHAR2) IS
1668 l_error VARCHAR2(100);
1669 l_product VARCHAR2(3);
1670 BEGIN
1671 SELECT encumbrance_type_id
1672 INTO p_encumbrance_type_id
1673 FROM gl_encumbrance_types
1674 WHERE encumbrance_type = 'OLD'
1675 AND enabled_flag = 'Y';
1676
1677 EXCEPTION
1678 WHEN NO_DATA_FOUND THEN
1679 l_error := 'ENCUMBRANCE TYPE = OLD';
1680 l_product := 'GL';
1681 fnd_message.set_name('PSP','PSP_TR_NOT_SET_UP');
1682 fnd_message.set_token('ERROR',l_error);
1683 fnd_message.set_token('PRODUCT',l_product);
1684 fnd_msg_pub.add;
1685 p_return_status := fnd_api.g_ret_sts_unexp_error;
1686 WHEN OTHERS THEN
1687 g_error_api_path := 'ENCUMBRANCE_TYPE_ID:'||g_error_api_path;
1688 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','ENCUMBRANCE_TYPE_ID');
1689 p_return_status := fnd_api.g_ret_sts_unexp_error;
1690 END;
1691
1692
1693 -------------------- GL TIE BACK -----------------------------------------------------
1694 PROCEDURE gl_tie_back(p_payroll_control_id IN NUMBER,
1695 p_source_type IN VARCHAR2,
1696 p_period_end_date IN DATE,
1697 p_group_id IN NUMBER,
1698 p_business_group_id IN NUMBER,
1699 p_set_of_books_id IN NUMBER,
1700 p_mode IN VARCHAR2, --Introduced as part of Bug fix #1776606
1701 p_return_status OUT NOCOPY VARCHAR2) IS
1702 CURSOR gl_tie_back_success_cur IS
1703 SELECT summary_line_id,
1704 dr_cr_flag,summary_amount
1705 FROM psp_summary_lines
1706 WHERE group_id = p_group_id
1707 AND payroll_control_id = p_payroll_control_id;
1708
1709 CURSOR gl_tie_back_reject_cur IS
1710 SELECT status,
1711 reference6
1712 FROM gl_interface
1713 WHERE group_id = p_group_id
1714 AND set_of_books_id = p_set_of_books_id
1715 AND user_je_source_name = 'OLD'
1716 AND reference6 in(select summary_line_id FROM psp_summary_lines -- Bug 7376898
1717 WHERE GROUP_ID = p_group_id
1718 AND payroll_control_id = p_payroll_control_id);
1719
1720
1721 CURSOR assign_susp_ac_cur(P_SUMMARY_LINE_ID IN NUMBER) IS
1722 SELECT pdl.rowid,
1723 pdl.distribution_line_id line_id,
1724 pdl.distribution_date,
1725 pdl.suspense_org_account_id,
1726 pdl.reversal_entry_flag,
1727 pdl.effective_date -- Bug 7040943 Added
1728 FROM psp_distribution_lines pdl
1729 WHERE pdl.summary_line_id = p_summary_line_id
1730 UNION
1731 SELECT ppgd.rowid,
1732 ppgd.pre_gen_dist_line_id line_id,
1733 ppgd.distribution_date,
1734 ppgd.suspense_org_account_id,
1735 ppgd.reversal_entry_flag,
1736 ppgd.effective_date -- Bug 7040943 Added
1737 FROM psp_pre_gen_dist_lines ppgd
1738 WHERE ppgd.summary_line_id = p_summary_line_id;
1739
1740 -- Get the Organization details ...
1741
1742 CURSOR get_susp_org_cur(P_ORG_ID IN VARCHAR2) IS
1743 SELECT hou.organization_id, hou.name, poa.gl_code_combination_id
1744 FROM hr_all_organization_units hou, psp_organization_accounts poa
1745 WHERE hou.organization_id = poa.organization_id
1746 AND poa.business_group_id = p_business_group_id
1747 AND poa.set_of_books_id = p_set_of_books_id
1748 AND poa.organization_account_id = p_org_id;
1749
1750 CURSOR get_org_id_cur(P_LINE_ID IN NUMBER) IS
1751 SELECT hou.organization_id, hou.name
1752 FROM hr_all_organization_units hou,
1753 per_assignments_f paf,
1754 psp_payroll_lines ppl,
1755 psp_payroll_sub_lines ppsl,
1756 psp_distribution_lines pdl
1757 WHERE pdl.payroll_sub_line_id = ppsl.payroll_sub_line_id
1758 AND ppsl.payroll_line_id = ppl.payroll_line_id
1759 AND pdl.distribution_line_id = p_line_id
1760 AND ppl.assignment_id = paf.assignment_id
1761 AND pdl.distribution_date BETWEEN paf.effective_start_date AND paf.effective_end_date
1762 AND paf.organization_id = hou.organization_id
1763 AND pdl.distribution_date between
1764 hou.date_from and nvl(hou.date_to,pdl.distribution_date)
1765 UNION
1766 SELECT hou.organization_id, hou.name
1767 FROM hr_all_organization_units hou,
1768 per_assignments_f paf,
1769 psp_pre_gen_dist_lines ppgd
1770 WHERE ppgd.pre_gen_dist_line_id = p_line_id
1771 AND ppgd.assignment_id = paf.assignment_id
1772 AND ppgd.distribution_date BETWEEN paf.effective_start_date AND paf.effective_end_date
1773 AND paf.organization_id = hou.organization_id;
1774
1775 l_orig_org_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
1776 l_orig_org_id number;
1777
1778 -- End of Get org id cursor Ravindra
1779
1780 CURSOR org_susp_ac_cur(P_ORGANIZATION_ID IN NUMBER,
1781 P_DISTRIBUTION_DATE IN DATE) IS
1782 SELECT poa.organization_account_id,
1783 poa.gl_code_combination_id,
1784 poa.project_id,
1785 poa.award_id,
1786 poa.task_id,
1787 poa.expenditure_organization_id,
1788 poa.expenditure_type
1789 FROM psp_organization_accounts poa
1790 WHERE poa.organization_id = p_organization_id
1791 AND poa.account_type_code = 'S'
1792 AND poa.business_group_id = p_business_group_id
1793 AND poa.set_of_books_id = p_set_of_books_id
1794 AND p_distribution_date BETWEEN poa.start_date_active AND
1795 nvl(poa.end_date_active,p_distribution_date);
1796
1797
1798 -- CURSOR global_susp_ac_cur(P_DISTRIBUTION_DATE IN DATE) IS
1799 CURSOR global_susp_ac_cur(P_ORGANIZATION_ACCOUNT_ID IN NUMBER) IS --BUG 2056877
1800 SELECT poa.organization_account_id,
1801 poa.gl_code_combination_id,
1802 poa.project_id,
1803 poa.award_id,
1804 poa.task_id,
1805 poa.expenditure_organization_id,
1806 poa.expenditure_type
1807 FROM psp_organization_accounts poa
1808 WHERE
1809 /* poa.account_type_code = 'G'
1810 AND poa.business_group_id = p_business_group_id
1811 AND poa.set_of_books_id = p_set_of_books_id
1812 AND p_distribution_date BETWEEN poa.start_date_active AND
1813 nvl(poa.end_date_active,p_distribution_date); Bug 2056877.*/
1814 organization_account_id = p_organization_account_id; --Added for bug 2056877.
1815
1816 l_organization_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
1817 l_organization_id NUMBER(15);
1818 l_rowid ROWID;
1819 l_assignment_id NUMBER(15);
1820 l_distribution_date DATE;
1821 l_suspense_org_account_id NUMBER(9);
1822 l_reversal_entry_flag VARCHAR2(1);
1823 l_lines_glccid NUMBER(15);
1824 --
1825 l_organization_account_id NUMBER(9);
1826 l_susp_glccid NUMBER(15);
1827 l_project_id NUMBER(15);
1828 l_award_id NUMBER(15);
1829 l_task_id NUMBER(15);
1830 --
1831 l_status VARCHAR2(50);
1832 l_reference6 VARCHAR2(100);
1833 --
1834 l_cnt_gl_interface NUMBER;
1835 l_summary_line_id NUMBER(10);
1836 l_gl_project_flag VARCHAR2(1);
1837 l_suspense_ac_failed VARCHAR2(1) := 'N';
1838 l_reversal_ac_failed VARCHAR2(1) := 'N';
1839 l_suspense_ac_not_found VARCHAR2(1) := 'N';
1840 l_susp_ac_found VARCHAR2(10) := 'TRUE';
1841 l_summary_amount NUMBER;
1842 l_dr_summary_amount NUMBER := 0;
1843 l_cr_summary_amount NUMBER := 0;
1844 l_dr_cr_flag VARCHAR2(1);
1845 l_effective_date DATE;
1846 x_susp_failed_org_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
1847 x_susp_failed_status VARCHAR2(50);
1848 x_susp_failed_date DATE;
1849 x_lines_glccid NUMBER(15);
1850 x_susp_nf_org_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
1851 x_susp_nf_date DATE;
1852 l_return_status VARCHAR2(10);
1853 x_line_id NUMBER;
1854 l_no_run number;
1855 l_return_value VARCHAR2(30); --Added for bug 2056877.
1856 no_profile_exists EXCEPTION; --Added for bug 2056877.
1857 no_val_date_matches EXCEPTION; --Added for bug 2056877.
1858 no_global_acct_exists EXCEPTION; --Added for bug 2056877.
1859 l_user_je_source_name varchar2(25); ---added for 2445196
1860 l_susp_exception varchar2(50); -- 2479579
1861 l_expenditure_type varchar2(100); -- introduced vars for 5080403
1862 l_exp_org_id number;
1863 l_new_expenditure_type varchar2(100);
1864 l_new_glccid number;
1865 l_acct_type varchar2(1);
1866 l_auto_pop_status varchar2(100);
1867 l_auto_status varchar2(100);
1868 l_person_id number;
1869 l_element_type_id number;
1870 l_assignment_number varchar2(100);
1871 l_element_type varchar2(200);
1872 l_person_name varchar2(300);
1873 l_account varchar2(1000);
1874 l_auto_org_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
1875
1876 l_pay_action_type psp_payroll_lines.payroll_action_type%TYPE; -- Bug 7040943
1877
1878 cursor get_element_type is
1879 select ppl.element_type_id,
1880 ppl.assignment_id,
1881 ppl.person_id
1882 from psp_payroll_lines ppl,
1883 psp_payroll_sub_lines ppsl,
1884 psp_distribution_lines pdl
1885 where pdl.distribution_line_id = x_line_id
1886 and pdl.payroll_sub_line_id = ppsl.payroll_sub_line_id
1887 and ppsl.payroll_line_id = ppl.payroll_line_id
1888 union all
1889 select ppg.element_type_id,
1890 ppg.assignment_id,
1891 ppg.person_id
1892 from psp_pre_gen_dist_lines ppg
1893 where pre_gen_dist_line_id = x_line_id;
1894
1895 cursor get_asg_details is
1896 select ppf.full_name,
1897 paf.assignment_number,
1898 pet.element_name,
1899 hou.name
1900 from per_all_people_f ppf,
1901 per_all_assignments_f paf,
1902 pay_element_types_f pet,
1903 hr_all_organization_units hou
1904 where ppf.person_id = l_person_id
1905 and l_distribution_date between ppf.effective_start_date and ppf.effective_end_date
1906 and paf.assignment_id = l_assignment_id
1907 and l_distribution_date between paf.effective_start_date and paf.effective_end_date
1908 and pet.element_type_id = l_element_type_id
1909 and l_distribution_date between pet.effective_start_date and pet.effective_end_date
1910 and hou.organization_id = paf.organization_id;
1911
1912 BEGIN
1913
1914 select count(*)
1915 into l_no_run
1916 from gl_interface
1917 where status = 'NEW'
1918 and group_id = p_group_id
1919 and user_je_source_name = 'OLD'
1920 AND reference6 in(select summary_line_id FROM psp_summary_lines -- Bug 7376898
1921 WHERE GROUP_ID = p_group_id
1922 AND payroll_control_id = p_payroll_control_id);
1923
1924 if l_no_run > 0 then
1925
1926 delete from gl_interface
1927 where group_id = p_group_id
1928 and user_je_source_name = 'OLD'
1929 AND reference6 in(select summary_line_id FROM psp_summary_lines -- Bug 7376898
1930 WHERE GROUP_ID = p_group_id
1931 AND payroll_control_id = p_payroll_control_id);
1932
1933
1934 delete from psp_summary_lines
1935 where payroll_control_id = p_payroll_control_id
1936 and group_id = p_group_id;
1937
1938 --- bug 4328598 -- fix begin
1939
1940 -- get the source name
1941 get_gl_je_sources(l_user_je_source_name,
1942 l_return_status);
1943 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1944 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1945 END IF;
1946
1947 delete gl_interface_Control
1948 where group_id = p_group_id
1949 and je_source_name = l_user_je_source_name;
1950
1951 update psp_payroll_controls
1952 set phase = null
1953 where payroll_control_id = p_payroll_control_id;
1954
1955 commit;
1956 --- bug 4328598--- fix end
1957
1958
1959 fnd_message.set_name('PSP','PSP_JI_DID_NOT_RUN');
1960 fnd_message.set_token('PAYROLL_CONTROL_ID',p_payroll_control_id);
1961 fnd_message.set_token('GROUP_ID',p_group_id);
1962 fnd_msg_pub.add;
1963 -- uncommented following statement for 2444657
1964 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1965
1966 end if;
1967
1968 SELECT count(*)
1969 INTO l_cnt_gl_interface
1970 FROM gl_interface
1971 WHERE group_id = p_group_id
1972 AND user_je_source_name = 'OLD'
1973 AND set_of_books_id = p_set_of_books_id
1974 AND reference6 in(select summary_line_id FROM psp_summary_lines -- Bug 7376898
1975 WHERE GROUP_ID = p_group_id
1976 AND payroll_control_id = p_payroll_control_id);
1977
1978
1979 --- moved this statement from transfer_to_gl procedure to the beginning of this
1980 -- procedure, becuase it not being set when user defined exceptions are occuring
1981 --- like invalid suspense FATAL error. Since there is a single commit for TIE-BACK
1982 -- this will work fine... for Bug fix 2444657
1983 UPDATE psp_payroll_controls
1984 SET phase = 'GL_Tie_Back'
1985 WHERE payroll_control_id = p_payroll_control_id;
1986
1987 IF l_cnt_gl_interface > 0 THEN
1988 --
1989 OPEN gl_tie_back_reject_cur;
1990 LOOP
1991 FETCH gl_tie_back_reject_cur INTO l_status,l_reference6;
1992 IF gl_tie_back_reject_cur%NOTFOUND THEN
1993 CLOSE gl_tie_back_reject_cur;
1994 EXIT;
1995 END IF;
1996 -- update summary_lines with the reject status code
1997 UPDATE psp_summary_lines
1998 SET interface_status = l_status, status_code = 'R'
1999 WHERE summary_line_id = to_number(l_reference6);
2000
2001 OPEN assign_susp_ac_cur(to_number(l_reference6));
2002 LOOP
2003
2004 FETCH assign_susp_ac_cur INTO l_rowid, x_line_id, l_distribution_date,
2005 l_suspense_org_account_id, l_reversal_entry_flag,
2006 l_effective_date; --Bug 7040943;
2007
2008 -- Bug 7376898
2009 SELECT payroll_action_type
2010 INTO l_pay_action_type
2011 FROM psp_payroll_lines
2012 WHERE payroll_control_id = p_payroll_control_id
2013 and payroll_line_id = (select payroll_line_id from psp_payroll_sub_lines
2014 where payroll_sub_line_id = (select payroll_sub_line_id
2015 from psp_distribution_lines
2016 where distribution_line_id = x_line_id));
2017
2018 IF assign_susp_ac_cur%NOTFOUND THEN
2019 CLOSE assign_susp_ac_cur;
2020 EXIT;
2021 END IF;
2022
2023 -- Get the name and gl_ccid of the suspense account used
2024 if l_suspense_org_account_id is not null then
2025 OPEN get_susp_org_cur(l_suspense_org_account_id);
2026 FETCH get_susp_org_cur into l_organization_id, l_organization_name,
2027 l_lines_glccid;
2028 CLOSE get_susp_org_cur;
2029 end if;
2030
2031
2032 IF (l_status <> 'P' AND substr(l_status,1,1) <> 'W') THEN -- moved this condition from elseif:Bug2205224
2033
2034 IF l_suspense_org_account_id IS NOT NULL THEN
2035
2036 x_susp_failed_org_name := l_organization_name;
2037 x_susp_failed_status := l_status;
2038 x_susp_failed_date := l_distribution_date;
2039 l_suspense_ac_failed := 'Y';
2040
2041 -- if the reversing a/c failed,update the status of the whole batch and display the error
2042 ELSIF l_reversal_entry_flag = 'Y' THEN
2043
2044 ---x_lines_glccid := l_lines_glccid; commented this line and introduced
2045 --- if-endif statment below for 2663344
2046 l_reversal_ac_failed := 'Y';
2047
2048 if x_lines_glccid is null then
2049 select gl_code_combination_id into x_lines_glccid
2050 from psp_summary_lines where summary_line_id = to_number(l_reference6);
2051 end if;
2052
2053 ELSE
2054
2055 l_susp_ac_found := 'TRUE';
2056 OPEN get_org_id_cur(x_line_id);
2057 FETCH get_org_id_cur into l_orig_org_id, l_orig_org_name;
2058 CLOSE get_org_id_cur;
2059
2060 --Bug 7040943 Starts
2061 IF l_pay_action_type = 'L' THEN
2062 l_distribution_date := l_effective_date;
2063 END IF;
2064 --Bug 7040943 End
2065
2066 OPEN org_susp_ac_cur(l_orig_org_id,l_distribution_date);
2067 FETCH org_susp_ac_cur INTO l_organization_account_id,l_susp_glccid,l_project_id,l_award_id,l_task_id,
2068 l_exp_org_id, l_expenditure_type;
2069 IF org_susp_ac_cur%NOTFOUND THEN
2070 /* Following code is added for bug 2056877 ,Added validation for generic suspense account */
2071 l_return_value := psp_general.find_global_suspense(l_distribution_date,
2072 p_business_group_id,
2073 p_set_of_books_id,
2074 l_organization_account_id );
2075 /* --------------------------------------------------------------------
2076 Valid return values are
2077 PROFILE_VAL_DATE_MATCHES Profile and Value and Date matching 'G'
2078 NO_PROFILE_EXISTS No Profile
2079 NO_VAL_DATE_MATCHES Profile and Either Value/date do not
2080 match with 'G'
2081 NO_GLOBAL_ACCT_EXISTS No 'G' exists
2082 ---------------------------------------------------------------------- */
2083 IF l_return_value = 'PROFILE_VAL_DATE_MATCHES' THEN
2084 -- OPEN global_susp_ac_cur(l_distribution_date);
2085 OPEN global_susp_ac_cur(l_organization_account_id); --Bug 2056877
2086 FETCH global_susp_ac_cur INTO l_organization_account_id,l_susp_glccid,l_project_id,l_award_id,l_task_id,
2087 l_exp_org_id, l_expenditure_type;
2088 IF global_susp_ac_cur%NOTFOUND THEN
2089 /* l_susp_ac_found := 'FALSE';
2090 l_suspense_ac_not_found := 'Y';
2091 x_susp_nf_org_name := l_orig_org_name;
2092 x_susp_nf_date := l_distribution_date; Commented for bug 2056877 */
2093 --- commented for 2479579 RAISE no_global_acct_exists; --Added for bug 2056877
2094 -- added following lines for 2479579
2095 l_susp_ac_found := 'NO_G_AC';
2096 l_suspense_ac_not_found := 'Y';
2097 END IF;
2098 CLOSE global_susp_ac_cur;
2099 ELSIF l_return_value = 'NO_GLOBAL_ACCT_EXISTS' THEN
2100 --- RAISE no_global_acct_exists; commented this line added following 2 lines for 2479579
2101 l_suspense_ac_not_found := 'Y';
2102 l_susp_ac_found := 'NO_G_AC';
2103 ELSIF l_return_value = 'NO_VAL_DATE_MATCHES' THEN
2104 --- RAISE no_val_date_matches; commented this line added following 2 lines for 2479579
2105 l_suspense_ac_not_found := 'Y';
2106 l_susp_ac_found := 'NO_DT_MCH';
2107 ELSIF l_return_value = 'NO_PROFILE_EXISTS' THEN
2108 --- RAISE no_profile_exists; commented this line added following 2 lines for 2479579
2109 l_suspense_ac_not_found := 'Y';
2110 l_susp_ac_found := 'NO_PROFL';
2111 END IF; -- Bug 2056877.
2112 END IF;
2113 CLOSE org_susp_ac_cur;
2114 -- introduced for 5080403
2115 if g_suspense_autopop = 'Y' and l_organization_account_id is not null then
2116 if l_susp_glccid is null then
2117 l_acct_type:='E';
2118 else
2119 l_acct_type:='N';
2120 end if;
2121 open get_element_type;
2122 fetch get_element_type into l_element_type_id, l_assignment_id, l_person_id;
2123 close get_element_type;
2124 psp_autopop.main( p_acct_type => l_acct_type,
2125 p_person_id => l_person_id,
2126 p_assignment_id => l_assignment_id,
2127 p_element_type_id => l_element_type_id,
2128 p_project_id => l_project_id,
2129 p_expenditure_organization_id => l_exp_org_id,
2130 p_task_id => l_task_id,
2131 p_award_id => l_award_id,
2132 p_expenditure_type => l_expenditure_type,
2133 p_gl_code_combination_id => l_susp_glccid,
2134 p_payroll_date => l_distribution_date,
2135 p_set_of_books_id => p_set_of_books_id,
2136 p_business_group_id => p_business_group_id,
2137 ret_expenditure_type => l_new_expenditure_type,
2138 ret_gl_code_combination_id => l_new_glccid,
2139 retcode => l_auto_pop_status);
2140 IF (l_auto_pop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
2141 (l_auto_pop_status = FND_API.G_RET_STS_ERROR) THEN
2142 IF l_auto_pop_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2143 if l_acct_type ='N' then
2144 l_auto_status := 'AUTO_POP_NA_ERROR';
2145 else
2146 l_auto_status :='AUTO_POP_EXP_ERROR';
2147 end if;
2148 elsif l_auto_pop_status = FND_API.G_RET_STS_ERROR THEN
2149 l_auto_status := 'AUTO_POP_NO_VALUE';
2150 end if;
2151 open get_asg_details;
2152 fetch get_asg_details into l_person_name, l_assignment_number, l_element_type, l_auto_org_name;
2153 close get_asg_details;
2154 psp_enc_crt_xml.p_set_of_books_id := p_set_of_books_id;
2155 psp_enc_crt_xml.p_business_group_id := p_business_group_id;
2156 if l_acct_type = 'N' then
2157 l_account :=
2158 psp_enc_crt_xml.cf_charging_instformula(l_susp_glccid,
2159 null,
2160 null,
2161 null,
2162 null,
2163 null);
2164 else
2165 l_account :=
2166 psp_enc_crt_xml.cf_charging_instformula(null,
2167 l_project_id,
2168 l_task_id,
2169 l_award_id,
2170 l_expenditure_type,
2171 l_exp_org_id);
2172 end if;
2173 fnd_message.set_name('PSP','PSP_SUSPENSE_AUTOPOP_FAIL');
2174 fnd_message.set_token('ORG_NAME',l_auto_org_name);
2175 fnd_message.set_token('EMPLOYEE_NAME',l_person_name);
2176 fnd_message.set_token('ASG_NUM',l_assignment_number);
2177 fnd_message.set_token('CHARGING_ACCOUNT',l_account);
2178 fnd_message.set_token('AUTOPOP_ERROR',l_auto_status);
2179 fnd_message.set_token('EFF_DATE',l_distribution_date);
2180 fnd_msg_pub.add;
2181 else
2182 if l_acct_type = 'E' then
2183 l_expenditure_type := l_new_expenditure_type;
2184 else
2185 l_susp_glccid := l_new_glccid;
2186 end if;
2187 end if;
2188 end if;
2189
2190 IF l_susp_ac_found = 'TRUE' THEN
2191
2192 IF l_susp_glccid IS NOT NULL THEN
2193 l_gl_project_flag := 'G';
2194 -- l_effective_date := p_period_end_date; --- uncommented for 22663344 --Bug 7040943
2195
2196 ELSE
2197 l_gl_project_flag := 'P';
2198
2199 /* Bug 1874696: deleted the procedure call for psp_general.poeta_effective_date
2200 */
2201 l_effective_date := l_distribution_date; --- added for Bug 2663344
2202
2203 END IF;
2204
2205 -- assign the organization suspense account and gl status
2206 --dbms_output.put_line('Updating distribution_lines ....NULL..');
2207
2208 IF p_source_type = 'O' OR p_source_type = 'N' THEN
2209
2210 /* Added the following for Bug 3065866 */
2211
2212 UPDATE PSP_DISTRIBUTION_LINES
2213 SET pre_distribution_run_flag = gl_project_flag
2214 WHERE rowid = l_rowid;
2215
2216 /* End of code changes for Bug 3065866 */
2217
2218 UPDATE psp_distribution_lines
2219 SET suspense_org_account_id = l_organization_account_id,
2220 suspense_reason_code = 'ST:' || l_status,
2221 gl_project_flag = l_gl_project_flag,
2222 status_code = 'N',
2223 effective_date = l_effective_date, --- for Bug 2663344
2224 suspense_auto_glccid = l_new_glccid, --- added suspense_auto for 5080403
2225 suspense_auto_exp_type = l_new_expenditure_type
2226 WHERE rowid = l_rowid;
2227 ELSIF p_source_type = 'P' THEN
2228 UPDATE psp_pre_gen_dist_lines
2229 SET suspense_org_account_id = l_organization_account_id,
2230 suspense_reason_code = 'ST:' || l_status,
2231 status_code = 'N',
2232 effective_date = l_effective_date, --- for Bug 2663344
2233 suspense_auto_glccid = l_new_glccid, --- added suspense_auto for 5080403
2234 suspense_auto_exp_type = l_new_expenditure_type
2235 WHERE rowid = l_rowid;
2236 END IF;
2237 ELSE -- introduced for 2479579
2238 l_susp_exception := l_susp_ac_found;
2239 END IF;
2240 END IF;
2241 END IF; -- Bug 2205224, status not in (P,W)
2242
2243
2244 END LOOP;
2245 END LOOP;
2246 ---2445196: cleanup gl interface b'cos rejection is available in rejected summary lines
2247 get_gl_je_sources(l_user_je_source_name,
2248 l_return_status);
2249 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2250 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2251 END IF;
2252
2253 delete gl_interface
2254 where group_id = p_group_id
2255 and set_of_books_id = p_set_of_books_id
2256 AND user_je_source_name = l_user_je_source_name
2257 and reference6 in(select summary_line_id FROM psp_summary_lines -- Bug 7376898
2258 WHERE GROUP_ID = p_group_id
2259 AND payroll_control_id = p_payroll_control_id);
2260
2261 IF l_reversal_ac_failed = 'Y' THEN
2262 fnd_message.set_name('PSP','PSP_GL_REVERSE_AC_REJECT');
2263 fnd_message.set_token('GLCCID',x_lines_glccid);
2264 fnd_msg_pub.add;
2265
2266 /* Added the following for the Bug 3065866 */
2267
2268 IF p_source_type = 'O' OR p_source_type = 'N' THEN
2269 UPDATE psp_distribution_lines
2270 SET suspense_org_account_id = NULL,
2271 suspense_reason_code = NULL,
2272 gl_project_flag = pre_distribution_run_flag,
2273 effective_date = decode(pre_distribution_run_flag,'G',
2274 p_period_end_date,distribution_date)
2275 WHERE suspense_reason_code like 'ST:%'
2276 AND summary_line_id
2277 IN (SELECT summary_line_id
2278 FROM psp_summary_lines
2279 WHERE payroll_control_id = p_payroll_control_id);
2280 ELSIF p_source_type = 'P' THEN
2281
2282 UPDATE psp_pre_gen_dist_lines
2283 SET suspense_org_account_id = NULL,
2284 suspense_reason_code = NULL,
2285 effective_date = decode(NVL(gl_code_combination_id,-999),gl_code_combination_id,
2286 p_period_end_date,distribution_date)
2287 WHERE suspense_reason_code like 'ST:%'
2288 AND summary_line_id
2289 IN (SELECT summary_line_id
2290 FROM psp_summary_lines
2291 WHERE payroll_control_id = p_payroll_control_id);
2292 END IF;
2293
2294 /* End of code for Bug 3065856 */
2295
2296
2297 /* Introduced the following check as part of Bug fix #1776606 */
2298 if p_mode = 'N' then
2299 /* introduced mark batch end Bug: 1929317 */
2300 mark_batch_end(p_source_type,
2301 g_source_code,
2302 g_time_period_id,
2303 g_batch_name,
2304 p_business_group_id,
2305 p_set_of_books_id,
2306 l_return_status);
2307 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2308 end if;
2309 END IF;
2310
2311 IF l_suspense_ac_failed = 'Y' or
2312 nvl(l_auto_status,'X') in ('AUTO_POP_NA_ERROR', 'AUTO_POP_EXP_ERROR', 'AUTO_POP_NO_VALUE') then
2313 --- above check for autopop error 5080403
2314 if nvl(l_suspense_ac_failed,'N') = 'Y' then
2315 fnd_message.set_name('PSP','PSP_TR_GL_SUSP_AC_REJECT');
2316 fnd_message.set_token('ORG_NAME',x_susp_failed_org_name);
2317 fnd_message.set_token('PAYROLL_DATE',x_susp_failed_date);
2318 fnd_message.set_token('ERROR_MSG',x_susp_failed_status);
2319 fnd_msg_pub.add;
2320 end if;
2321
2322 /* Added the following for Bug 3065866 */
2323
2324 IF p_source_type = 'O' OR p_source_type = 'N' THEN
2325
2326
2327 UPDATE psp_distribution_lines
2328 SET suspense_org_account_id = NULL,
2329 suspense_reason_code = NULL,
2330 gl_project_flag = pre_distribution_run_flag,
2331 effective_date = decode(pre_distribution_run_flag,'G',
2332 p_period_end_date,distribution_date)
2333 WHERE suspense_reason_code like 'ST:%'
2334 AND summary_line_id
2335 IN (SELECT summary_line_id
2336 FROM psp_summary_lines
2337 WHERE payroll_control_id = p_payroll_control_id );
2338 ELSIF p_source_type = 'P' THEN
2339 UPDATE psp_pre_gen_dist_lines
2340 SET suspense_org_account_id = NULL,
2341 suspense_reason_code = NULL,
2342 effective_date = decode(NVL(gl_code_combination_id,-999),gl_code_combination_id,
2343 p_period_end_date,distribution_date)
2344 WHERE suspense_reason_code like 'ST:%'
2345 AND summary_line_id
2346 IN ( SELECT summary_line_id
2347 FROM psp_summary_lines
2348 WHERE payroll_control_id = p_payroll_control_id );
2349 END IF;
2350
2351 /* End of code for Bug 3065866 */
2352
2353 /* Introduced the following check as part of Bug fix #1776606 */
2354 if p_mode = 'N' then
2355 /* introduced mark batch end Bug: 1929317 */
2356 mark_batch_end(p_source_type,
2357 g_source_code,
2358 g_time_period_id,
2359 g_batch_name,
2360 p_business_group_id,
2361 p_set_of_books_id,
2362 l_return_status);
2363 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2364 end if;
2365 END IF;
2366
2367 IF l_suspense_ac_not_found = 'Y' THEN
2368 /* commented following code for 2479579
2369 fnd_message.set_name('PSP','PSP_LD_SUSPENSE_AC_NOT_EXIST');
2370 fnd_message.set_token('ORG_NAME',x_susp_nf_org_name);
2371 fnd_message.set_token('PAYROLL_DATE',x_susp_nf_date);
2372 fnd_msg_pub.add; */
2373
2374 /* Introduced the following check as part of Bug fix #1776606 */
2375 if p_mode = 'N' then
2376 /* introduced mark batch end Bug: 1929317 */
2377 mark_batch_end(p_source_type,
2378 g_source_code,
2379 g_time_period_id,
2380 g_batch_name,
2381 p_business_group_id,
2382 p_set_of_books_id,
2383 l_return_status);
2384 --- RAISE FND_API.G_EXC_UNEXPECTED_ERROR; commented for 2479579
2385 -- introduced following if stmnt for 2479579
2386 if l_susp_exception = 'NO_G_AC' then
2387 RAISE no_global_acct_exists;
2388 elsif l_susp_exception = 'NO_DT_MCH' then
2389 RAISE no_val_date_matches;
2390 elsif l_susp_exception = 'NO_PROFL' then
2391 RAISE no_profile_exists;
2392 end if;
2393
2394 end if;
2395 END IF;
2396
2397
2398 ELSIF l_cnt_gl_interface = 0 and l_no_run = 0 THEN
2399 --
2400 OPEN gl_tie_back_success_cur;
2401 LOOP
2402 FETCH gl_tie_back_success_cur INTO l_summary_line_id,
2403 l_dr_cr_flag,l_summary_amount;
2404 IF gl_tie_back_success_cur%NOTFOUND THEN
2405 CLOSE gl_tie_back_success_cur;
2406 EXIT;
2407 END IF;
2408 -- update records in psp_summary_lines as 'A'
2409 UPDATE psp_summary_lines
2410 SET status_code = 'A'
2411 WHERE summary_line_id = l_summary_line_id;
2412
2413 IF l_dr_cr_flag = 'D' THEN
2414 l_dr_summary_amount := l_dr_summary_amount + l_summary_amount;
2415 ELSIF l_dr_cr_flag = 'C' THEN
2416 l_cr_summary_amount := l_cr_summary_amount + l_summary_amount;
2417 END IF;
2418
2419 IF p_source_type = 'O' OR p_source_type = 'N' THEN
2420
2421 UPDATE psp_distribution_lines
2422 SET status_code = 'A' WHERE summary_line_id = l_summary_line_id;
2423
2424 -- move the transferred records to psp_distribution_lines_history
2425 INSERT INTO psp_distribution_lines_history
2426 (distribution_line_id,payroll_sub_line_id,distribution_date,
2427 effective_date,distribution_amount,status_code,suspense_reason_code,
2428 effort_report_id,version_num,schedule_line_id,
2429 summary_line_id,default_org_account_id,suspense_org_account_id,
2430 element_account_id,org_schedule_id,
2431 user_defined_field,default_reason_code,reversal_entry_flag,gl_project_flag,
2432 auto_gl_code_combination_id, business_group_id, set_of_books_id,
2433 attribute_category, attribute1, attribute2, attribute3,
2434 attribute4, attribute5, attribute6, attribute7,
2435 attribute8, attribute9, attribute10,
2436 cap_excess_glccid, cap_excess_award_id, cap_excess_task_id,
2437 cap_excess_project_id, cap_excess_exp_type, cap_excess_exp_org_id,
2438 funding_source_code, annual_salary_cap, cap_excess_dist_line_id,
2439 suspense_auto_exp_type, suspense_auto_glccid, adj_account_flag) --- added 2 cols for 508040
2440 SELECT distribution_line_id,payroll_sub_line_id,distribution_date,
2441 effective_date,distribution_amount,status_code,suspense_reason_code,
2442 effort_report_id,version_num,schedule_line_id,
2443 summary_line_id,default_org_account_id,suspense_org_account_id,
2444 element_account_id,org_schedule_id,
2445 user_defined_field,default_reason_code,reversal_entry_flag,gl_project_flag,
2446 auto_gl_code_combination_id, business_group_id, set_of_books_id,
2447 attribute_category, attribute1, attribute2, attribute3,
2448 attribute4, attribute5, attribute6, attribute7,
2449 attribute8, attribute9, attribute10,
2450 cap_excess_glccid, cap_excess_award_id, cap_excess_task_id,
2451 cap_excess_project_id, cap_excess_exp_type, cap_excess_exp_org_id,
2452 funding_source_code, annual_salary_cap, cap_excess_dist_line_id,
2453 suspense_auto_exp_type, suspense_auto_glccid, adj_account_flag
2454 FROM psp_distribution_lines
2455 WHERE status_code = 'A'
2456 AND summary_line_id = l_summary_line_id;
2457
2458 DELETE FROM psp_distribution_lines
2459 WHERE status_code = 'A'
2460 AND summary_line_id = l_summary_line_id;
2461
2462 ELSIF p_source_type = 'P' THEN
2463
2464 UPDATE psp_pre_gen_dist_lines
2465 SET status_code = 'A' WHERE summary_line_id = l_summary_line_id;
2466
2467 -- move the transferred records to psp_pre_gen_dist_lines_history
2468 -- Introduced DFF columns for bug fix 2908859
2469 INSERT INTO psp_pre_gen_dist_lines_history
2470 (pre_gen_dist_line_id,distribution_interface_id,person_id,assignment_id,
2471 element_type_id,distribution_date,effective_date,distribution_amount,
2472 dr_cr_flag,payroll_control_id,source_type,source_code,time_period_id,
2473 batch_name,status_code,set_of_books_id,
2474 gl_code_combination_id,project_id,expenditure_organization_id,
2475 expenditure_type,task_id,award_id,suspense_reason_code,
2476 effort_report_id,version_num,summary_line_id,suspense_org_account_id,
2477 user_defined_field,reversal_entry_flag, business_group_id,
2478 attribute_category, attribute1, attribute2, attribute3,
2479 attribute4, attribute5, attribute6, attribute7,
2480 attribute8, attribute9, attribute10,
2481 suspense_auto_exp_type, suspense_auto_glccid) -- added 2 cols for 5080403
2482 SELECT pre_gen_dist_line_id,distribution_interface_id,person_id,assignment_id,
2483 element_type_id,distribution_date,effective_date,distribution_amount,
2484 dr_cr_flag,payroll_control_id,source_type,source_code,time_period_id,
2485 batch_name,status_code,set_of_books_id,
2486 gl_code_combination_id,project_id,expenditure_organization_id,
2487 expenditure_type,task_id,award_id,suspense_reason_code,
2488 effort_report_id,version_num,summary_line_id,suspense_org_account_id,
2489 user_defined_field,reversal_entry_flag, business_group_id,
2490 attribute_category, attribute1, attribute2, attribute3,
2491 attribute4, attribute5, attribute6, attribute7,
2492 attribute8, attribute9, attribute10,
2493 suspense_auto_exp_type, suspense_auto_glccid
2494 FROM psp_pre_gen_dist_lines
2495 WHERE status_code = 'A'
2496 AND summary_line_id = l_summary_line_id;
2497
2498 DELETE FROM psp_pre_gen_dist_lines
2499 WHERE status_code = 'A'
2500 AND summary_line_id = l_summary_line_id;
2501
2502 END IF;
2503
2504 END LOOP;
2505
2506 UPDATE psp_payroll_controls
2507 SET gl_dr_amount = nvl(gl_dr_amount,0) + l_dr_summary_amount,
2508 gl_cr_amount = nvl(gl_cr_amount,0) + l_cr_summary_amount
2509 WHERE payroll_control_id = p_payroll_control_id;
2510
2511 END IF;
2512 --
2513 p_return_status := fnd_api.g_ret_sts_success;
2514 EXCEPTION
2515
2516 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2517 --dbms_output.put_line('Gone to one level top ..................');
2518 g_error_api_path := 'GL_TIE_BACK:'||g_error_api_path;
2519 p_return_status := fnd_api.g_ret_sts_unexp_error;
2520
2521 /* Added Exceptions for bug 2056877 */
2522 WHEN NO_PROFILE_EXISTS THEN
2523 g_error_api_path := SUBSTR('GL_TIE_BACK:'||g_error_api_path,1,230);
2524 fnd_message.set_name('PSP','PSP_NO_PROFILE_EXISTS');
2525 fnd_msg_pub.add;
2526 p_return_status := fnd_api.g_ret_sts_unexp_error;
2527
2528 WHEN NO_VAL_DATE_MATCHES THEN
2529 g_error_api_path := SUBSTR('GL_TIE_BACK:'||g_error_api_path,1,230);
2530 fnd_message.set_name('PSP','PSP_NO_VAL_DATE_MATCHES');
2531 fnd_message.set_token('ORG_NAME',l_orig_org_name);
2532 fnd_message.set_token('PAYROLL_DATE',l_distribution_date);
2533 fnd_msg_pub.add;
2534 p_return_status := fnd_api.g_ret_sts_unexp_error;
2535
2536 WHEN NO_GLOBAL_ACCT_EXISTS THEN
2537 g_error_api_path := SUBSTR('GL_TIE_BACK:'||g_error_api_path,1,230);
2538 fnd_message.set_name('PSP','PSP_NO_GLOBAL_ACCT_EXISTS');
2539 fnd_message.set_token('ORG_NAME',l_orig_org_name);
2540 fnd_message.set_token('PAYROLL_DATE',l_distribution_date);
2541 fnd_msg_pub.add;
2542 p_return_status := fnd_api.g_ret_sts_unexp_error; --End of Changes for Bug 2056877.
2543
2544 WHEN OTHERS THEN
2545 g_error_api_path := 'GL_TIE_BACK:'||g_error_api_path;
2546 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','GL_TIE_BACK');
2547 p_return_status := fnd_api.g_ret_sts_unexp_error;
2548 END;
2549
2550
2551 ------------------ CREATE BALANCING TRANSACTIONS FOR GL ------------------------------
2552
2553 PROCEDURE gl_balance_transaction(
2554 P_SOURCE_TYPE IN VARCHAR2,
2555 P_PAYROLL_CONTROL_ID IN NUMBER,
2556 P_BUSINESS_GROUP_ID IN NUMBER,
2557 P_SET_OF_BOOKS_ID IN NUMBER,
2558 P_PRECISION IN NUMBER,-- Introduced this parameter For Bug 2916848
2559 P_RETURN_STATUS OUT NOCOPY VARCHAR2) IS
2560
2561 CURSOR dist_reversal_entry_cur(P_PAYROLL_CONTROL_ID IN NUMBER) IS
2562 SELECT pdl.payroll_sub_line_id,pdl.effective_date,
2563 round(sum(pdl.distribution_amount), p_precision) reversal_dist_amount,-- Changed rounding from 2 to p_precision
2564 -- For Bug 2916848
2565 pdl.business_group_id,
2566 pdl.set_of_books_id
2567 FROM psp_distribution_lines pdl,
2568 psp_payroll_sub_lines ppsl,
2569 psp_payroll_lines ppl,
2570 psp_payroll_controls ppc
2571 WHERE ppc.payroll_control_id = p_payroll_control_id
2572 AND ppc.payroll_control_id = ppl.payroll_control_id
2573 AND ppl.payroll_line_id = ppsl.payroll_line_id
2574 AND ppsl.payroll_sub_line_id = pdl.payroll_sub_line_id
2575 AND nvl(pdl.reversal_entry_flag,'N') = 'N'
2576 AND pdl.gl_project_flag = 'G'
2577 AND pdl.status_code = 'N'
2578 GROUP BY pdl.payroll_sub_line_id, pdl.effective_date, pdl.business_group_id, pdl.set_of_books_id;
2579
2580 CURSOR pg_reversal_entry_cur(P_PAYROLL_CONTROL_ID IN NUMBER) IS
2581 SELECT ppgd.distribution_interface_id,
2582 ppgd.person_id,
2583 ppgd.assignment_id,
2584 ppgd.element_type_id,
2585 ppgd.dr_cr_flag,
2586 ppgd.distribution_date,
2587 ppgd.effective_date,
2588 ppgd.source_type,
2589 ppgd.source_code,
2590 ppgd.time_period_id,
2591 ppgd.batch_name,
2592 ppgd.set_of_books_id,
2593 ppgd.business_group_id,
2594 round(sum(ppgd.distribution_amount), p_precision) reversal_dist_amount -- For Bug 2916848 changed to p_precision
2595 FROM psp_pre_gen_dist_lines ppgd,
2596 psp_organization_accounts pos
2597 WHERE ppgd.payroll_control_id = p_payroll_control_id
2598 AND nvl(ppgd.reversal_entry_flag,'N') = 'N'
2599 AND ((ppgd.gl_code_combination_id IS NOT NULL and pos.project_id is null ) OR -- Bug 2007521 Changed condn
2600 pos.gl_code_combination_id IS NOT NULL)
2601 AND ppgd.suspense_org_account_id = pos.organization_account_id(+)
2602 AND ppgd.status_code = 'N'
2603 -- AND ppgd.business_group_id = p_business_group_id
2604 -- AND ppgd.set_of_books_id = p_set_of_books_id
2605 GROUP BY ppgd.distribution_interface_id, ppgd.person_id,
2606 ppgd.assignment_id, ppgd.element_type_id,
2607 ppgd.dr_cr_flag, ppgd.distribution_date, ppgd.effective_date,
2608 ppgd.source_type, ppgd.source_code,
2609 ppgd.time_period_id, ppgd.batch_name, ppgd.set_of_books_id, ppgd.business_group_id;
2610
2611 dist_reversal_entry_rec dist_reversal_entry_cur%ROWTYPE;
2612 pg_reversal_entry_rec pg_reversal_entry_cur%ROWTYPE;
2613 l_reversal_dist_amount NUMBER;
2614 l_clrg_account_glccid NUMBER(15);
2615 l_cr_amount NUMBER;
2616 l_dr_amount NUMBER;
2617
2618 l_payroll_id NUMBER(9); -- Added for bug 5592964
2619
2620 BEGIN
2621
2622 IF p_source_type = 'O' OR p_source_type = 'N' THEN
2623
2624 DELETE FROM psp_distribution_lines
2625 WHERE reversal_entry_flag = 'Y'
2626 AND status_code = 'N'
2627 AND payroll_sub_line_id IN (
2628 select payroll_sub_line_id from psp_payroll_sub_lines where payroll_line_id IN (
2629 select payroll_line_id from psp_payroll_lines where payroll_control_id IN (
2630 select payroll_control_id from psp_payroll_controls where payroll_control_id=
2631 p_payroll_control_id)));
2632
2633
2634 -- recalculate and update the reversal sub-line amounts
2635 OPEN dist_reversal_entry_cur(p_payroll_control_id);
2636 LOOP
2637 FETCH dist_reversal_entry_cur INTO dist_reversal_entry_rec;
2638 IF dist_reversal_entry_cur%NOTFOUND THEN
2639 CLOSE dist_reversal_entry_cur;
2640 EXIT;
2641 END IF;
2642
2643 -- insert the reversal entry record into distribution lines
2644 insert into psp_distribution_lines
2645 (distribution_line_id,payroll_sub_line_id,distribution_date,effective_date,
2646 distribution_amount,status_code,gl_project_flag,reversal_entry_flag,
2647 business_group_id, set_of_books_id)
2648 values
2649 (PSP_DISTRIBUTION_LINES_S.NEXTVAL,dist_reversal_entry_rec.payroll_sub_line_id,
2650 dist_reversal_entry_rec.effective_date,dist_reversal_entry_rec.effective_date,
2651 dist_reversal_entry_rec.reversal_dist_amount,'N','G','Y',
2652 dist_reversal_entry_rec.business_group_id, dist_reversal_entry_rec.set_of_books_id);
2653
2654 END LOOP;
2655
2656 select sum(decode(reversal_entry_flag, 'Y', distribution_amount, 0)) cr_amount,
2657 sum(decode(reversal_entry_flag, 'Y', 0, distribution_amount)) dr_amount
2658 INTO l_cr_amount, l_dr_amount
2659 FROM psp_distribution_lines pdl,
2660 psp_payroll_sub_lines ppsl,
2661 psp_payroll_lines ppl,
2662 psp_payroll_controls ppc
2663 WHERE ppc.payroll_control_id = p_payroll_control_id
2664 AND ppc.payroll_control_id = ppl.payroll_control_id
2665 AND ppl.payroll_line_id = ppsl.payroll_line_id
2666 AND ppsl.payroll_sub_line_id = pdl.payroll_sub_line_id
2667 AND pdl.gl_project_flag = 'G'
2668 AND pdl.status_code = 'N';
2669
2670 IF l_cr_amount <> l_dr_amount then
2671 fnd_message.set_name('PSP','PSP_GL_REV_AMT_NOT_EQUAL');
2672 fnd_msg_pub.add;
2673 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2674 END IF;
2675
2676 ELSIF p_source_type = 'P' THEN
2677 SELECT payroll_id INTO l_payroll_id
2678 FROM psp_payroll_controls
2679 WHERE payroll_control_id = p_payroll_control_id;
2680
2681 BEGIN
2682 SELECT reversing_gl_ccid
2683 INTO l_clrg_account_glccid
2684 FROM PSP_CLEARING_ACCOUNT
2685 WHERE set_of_books_id = p_set_of_books_id
2686 AND business_group_id = p_business_group_id -- Changed for MO.
2687 AND payroll_id = l_payroll_id; -- Added for bug 5592964
2688 EXCEPTION
2689 WHEN NO_DATA_FOUND THEN
2690 fnd_message.set_name('PSP','PSP_TR_CLRG_AC_NOT_SET_UP');
2691 fnd_msg_pub.add;
2692 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2693 END;
2694
2695 delete from psp_pre_gen_dist_lines
2696 where reversal_entry_flag = 'Y'
2697 and status_code = 'N'
2698 and source_type = 'P'
2699 and payroll_control_id = p_payroll_control_id;
2700
2701 -- recalculate and update the reversal amounts
2702 OPEN pg_reversal_entry_cur(p_payroll_control_id);
2703 LOOP
2704 FETCH pg_reversal_entry_cur INTO pg_reversal_entry_rec;
2705 IF pg_reversal_entry_cur%NOTFOUND THEN
2706 CLOSE pg_reversal_entry_cur;
2707 EXIT;
2708 END IF;
2709
2710 -- Bug# 1140217
2711 -- UPDATE psp_pre_gen_dist_lines
2712 -- SET distribution_amount = pg_reversal_entry_rec.reversal_dist_amount
2713 -- WHERE distribution_interface_id = pg_reversal_entry_rec.distribution_interface_id
2714 -- AND reversal_entry_flag = 'Y';
2715
2716
2717 insert into psp_pre_gen_dist_lines
2718 (pre_gen_dist_line_id, distribution_interface_id, person_id, assignment_id,
2719 element_type_id, distribution_date, effective_date, distribution_amount,
2720 dr_cr_flag, payroll_control_id, source_type, source_code, time_period_id,
2721 batch_name, status_code, set_of_books_id, business_group_id, gl_code_combination_id,
2722 reversal_entry_flag)
2723 values (psp_distribution_lines_s.nextval, pg_reversal_entry_rec.distribution_interface_id,
2724 pg_reversal_entry_rec.person_id, pg_reversal_entry_rec.assignment_id,
2725 pg_reversal_entry_rec.element_type_id, pg_reversal_entry_rec.distribution_date,
2726 pg_reversal_entry_rec.effective_date, pg_reversal_entry_rec.reversal_dist_amount,
2727 pg_reversal_entry_rec.dr_cr_flag, p_payroll_control_id, pg_reversal_entry_rec.source_type,
2728 pg_reversal_entry_rec.source_code, pg_reversal_entry_rec.time_period_id,
2729 pg_reversal_entry_rec.batch_name, 'N', pg_reversal_entry_rec.set_of_books_id,
2730 pg_reversal_entry_rec.business_group_id, l_clrg_account_glccid, 'Y');
2731
2732 END LOOP;
2733
2734 select sum(decode(reversal_entry_flag, 'Y', distribution_amount, 0)),
2735 sum(decode(reversal_entry_flag, 'Y', 0, distribution_amount))
2736 into l_cr_amount, l_dr_amount
2737 from psp_pre_gen_dist_lines ppgd, psp_organization_accounts pos
2738 where payroll_control_id = p_payroll_control_id
2739 and ppgd.status_code = 'N'
2740 and ppgd.suspense_org_account_id = pos.organization_account_id(+)
2741 AND ((ppgd.gl_code_combination_id IS NOT NULL and ppgd.suspense_org_account_id is null ) OR
2742 pos.gl_code_combination_id IS NOT NULL);
2743 /* Bug 2007521: replaced following condn with above condn
2744 and (ppgd.gl_code_combination_id is not null or (ppgd.suspense_org_account_id is not null
2745 and pos.gl_code_combination_id is not null)); */
2746
2747 IF l_cr_amount <> l_dr_amount then
2748 fnd_message.set_name('PSP','PSP_GL_UNBALANCED_BATCH');
2749 fnd_msg_pub.add;
2750 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2751 END IF;
2752
2753 END IF;
2754 --
2755 p_return_status := fnd_api.g_ret_sts_success;
2756 EXCEPTION
2757 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2758 g_error_api_path := 'GL_BALANCE_TRANSACTION:'||g_error_api_path;
2759 p_return_status := fnd_api.g_ret_sts_unexp_error;
2760
2761 WHEN OTHERS THEN
2762 g_error_api_path := 'GL_BALANCE_TRANSACTION:'||g_error_api_path;
2763 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','GL_BALANCE_TRANSACTION');
2764 p_return_status := fnd_api.g_ret_sts_unexp_error;
2765 END;
2766
2767 ------------------ INSERT INTO GL INTERFACE -----------------------------------------------
2768
2769 PROCEDURE insert_into_gl_interface(
2770 P_SET_OF_BOOKS_ID IN NUMBER,
2771 P_ACCOUNTING_DATE IN DATE,
2772 P_CURRENCY_CODE IN VARCHAR2,
2773 P_USER_JE_CATEGORY_NAME IN VARCHAR2,
2774 P_USER_JE_SOURCE_NAME IN VARCHAR2,
2775 P_ENCUMBRANCE_TYPE_ID IN NUMBER,
2776 P_CODE_COMBINATION_ID IN NUMBER,
2777 P_ENTERED_DR IN NUMBER,
2778 P_ENTERED_CR IN NUMBER,
2779 P_GROUP_ID IN NUMBER,
2780 P_REFERENCE1 IN VARCHAR2,
2781 P_REFERENCE2 IN VARCHAR2,
2782 P_REFERENCE4 IN VARCHAR2,
2783 P_REFERENCE6 IN VARCHAR2,
2784 P_REFERENCE10 IN VARCHAR2,
2785 P_ATTRIBUTE1 IN VARCHAR2,
2786 P_ATTRIBUTE2 IN VARCHAR2,
2787 P_ATTRIBUTE3 IN VARCHAR2,
2788 P_ATTRIBUTE4 IN VARCHAR2,
2789 P_ATTRIBUTE5 IN VARCHAR2,
2790 P_ATTRIBUTE6 IN VARCHAR2,
2791 P_ATTRIBUTE7 IN VARCHAR2,
2792 P_ATTRIBUTE8 IN VARCHAR2,
2793 P_ATTRIBUTE9 IN VARCHAR2,
2794 P_ATTRIBUTE10 IN VARCHAR2,
2795 P_ATTRIBUTE11 IN VARCHAR2,
2796 P_ATTRIBUTE12 IN VARCHAR2,
2797 P_ATTRIBUTE13 IN VARCHAR2,
2798 P_ATTRIBUTE14 IN VARCHAR2,
2799 P_ATTRIBUTE15 IN VARCHAR2,
2800 P_ATTRIBUTE16 IN VARCHAR2,
2801 P_ATTRIBUTE17 IN VARCHAR2,
2802 P_ATTRIBUTE18 IN VARCHAR2,
2803 P_ATTRIBUTE19 IN VARCHAR2,
2804 P_ATTRIBUTE20 IN VARCHAR2,
2805 P_ATTRIBUTE21 IN VARCHAR2,
2806 P_ATTRIBUTE22 IN VARCHAR2,
2807 P_ATTRIBUTE23 IN VARCHAR2,
2808 P_ATTRIBUTE24 IN VARCHAR2,
2809 P_ATTRIBUTE25 IN VARCHAR2,
2810 P_ATTRIBUTE26 IN VARCHAR2,
2811 P_ATTRIBUTE27 IN VARCHAR2,
2812 P_ATTRIBUTE28 IN VARCHAR2,
2813 P_ATTRIBUTE29 IN VARCHAR2,
2814 P_ATTRIBUTE30 IN VARCHAR2,
2815 P_CURRENCY_CONVERSION_TYPE IN VARCHAR2, -- Introduced for bug fix 2916848
2816 P_CURRENCY_CONVERSION_DATE IN DATE, -- Introduced for bug fix 2916848
2817 P_RETURN_STATUS OUT NOCOPY VARCHAR2) IS
2818 BEGIN
2819
2820 --dbms_output.put_line('sob id='||to_char(p_set_of_books_id));
2821 -- dbms_output.put_line('a date='||to_char(p_accounting_date));
2822 -- dbms_output.put_line('curren='||p_currency_code);
2823 --dbms_output.put_line('category='||p_user_je_category_name);
2824 --dbms_output.put_line('source='||p_user_je_source_name);
2825
2826 INSERT INTO GL_INTERFACE(
2827 STATUS,
2828 SET_OF_BOOKS_ID,
2829 ACCOUNTING_DATE,
2830 CURRENCY_CODE,
2831 DATE_CREATED,
2832 CREATED_BY,
2833 ACTUAL_FLAG,
2834 USER_JE_CATEGORY_NAME,
2835 USER_JE_SOURCE_NAME,
2836 ENCUMBRANCE_TYPE_ID,
2837 CODE_COMBINATION_ID,
2838 ENTERED_DR,
2839 ENTERED_CR,
2840 GROUP_ID,
2841 REFERENCE1,
2842 REFERENCE2,
2843 REFERENCE4,
2844 REFERENCE6,
2845 REFERENCE10,
2846 ATTRIBUTE1,
2847 ATTRIBUTE2,
2848 ATTRIBUTE3,
2849 ATTRIBUTE4,
2850 ATTRIBUTE5,
2851 ATTRIBUTE6,
2852 ATTRIBUTE7,
2853 ATTRIBUTE8,
2854 ATTRIBUTE9,
2855 ATTRIBUTE10,
2856 ATTRIBUTE11,
2857 ATTRIBUTE12,
2858 ATTRIBUTE13,
2859 ATTRIBUTE14,
2860 ATTRIBUTE15,
2861 ATTRIBUTE16,
2862 ATTRIBUTE17,
2863 ATTRIBUTE18,
2864 ATTRIBUTE19,
2865 ATTRIBUTE20,
2866 REFERENCE21,
2867 REFERENCE22,
2868 REFERENCE23,
2869 REFERENCE24,
2870 REFERENCE25,
2871 REFERENCE26,
2872 REFERENCE27,
2873 REFERENCE28,
2874 REFERENCE29,
2875 REFERENCE30,
2876 -- Introduced the following columns for bug fix 2916848
2877 USER_CURRENCY_CONVERSION_TYPE,
2878 CURRENCY_CONVERSION_DATE)
2879 VALUES(
2880 'NEW',
2881 P_SET_OF_BOOKS_ID,
2882 P_ACCOUNTING_DATE,
2883 P_CURRENCY_CODE,
2884 SYSDATE,
2885 FND_GLOBAL.USER_ID,
2886 'A',
2887 P_USER_JE_CATEGORY_NAME,
2888 P_USER_JE_SOURCE_NAME,
2889 P_ENCUMBRANCE_TYPE_ID,
2890 P_CODE_COMBINATION_ID,
2891 P_ENTERED_DR,
2892 P_ENTERED_CR,
2893 P_GROUP_ID,
2894 P_REFERENCE1,
2895 P_REFERENCE2,
2896 P_REFERENCE4,
2897 P_REFERENCE6,
2898 P_REFERENCE10,
2899 P_ATTRIBUTE1,
2900 P_ATTRIBUTE2,
2901 P_ATTRIBUTE3,
2902 P_ATTRIBUTE4,
2903 P_ATTRIBUTE5,
2904 P_ATTRIBUTE6,
2905 P_ATTRIBUTE7,
2906 P_ATTRIBUTE8,
2907 P_ATTRIBUTE9,
2908 P_ATTRIBUTE10,
2909 P_ATTRIBUTE11,
2910 P_ATTRIBUTE12,
2911 P_ATTRIBUTE13,
2912 P_ATTRIBUTE14,
2913 P_ATTRIBUTE15,
2914 P_ATTRIBUTE16,
2915 P_ATTRIBUTE17,
2916 P_ATTRIBUTE18,
2917 P_ATTRIBUTE19,
2918 P_ATTRIBUTE20,
2919 P_ATTRIBUTE21,
2920 P_ATTRIBUTE22,
2921 P_ATTRIBUTE23,
2922 P_ATTRIBUTE24,
2923 P_ATTRIBUTE25,
2924 P_ATTRIBUTE26,
2925 P_ATTRIBUTE27,
2926 P_ATTRIBUTE28,
2927 P_ATTRIBUTE29,
2928 P_ATTRIBUTE30,
2929 P_CURRENCY_CONVERSION_TYPE,-- Introduced the following code for Bug fix 2916848
2930 DECODE(p_currency_conversion_type, NULL, NULL, P_CURRENCY_CONVERSION_DATE));-- Introduced the following code for Bug fix 2916848
2931 --dbms_output.put_line('DDDDDDDDDDDDDDDDDGL Interface Inserted ....................');
2932 p_return_status := fnd_api.g_ret_sts_success;
2933 EXCEPTION
2934 WHEN OTHERS THEN
2935 --dbms_output.put_line('Error while inserting .........................');
2936 g_error_api_path := 'INSERT_INTO_GL_INTERFACE:'||g_error_api_path;
2937 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','INSERT_INTO_GL_INTERFACE');
2938 p_return_status := fnd_api.g_ret_sts_unexp_error;
2939 END;
2940
2941 -------------------- CREATE GMS SUM LINES -----------------------------------------------
2942 PROCEDURE create_gms_sum_lines(p_source_type IN VARCHAR2,
2943 p_source_code IN VARCHAR2,
2944 p_time_period_id IN NUMBER,
2945 p_batch_name IN VARCHAR2,
2946 p_business_group_id IN NUMBER,
2947 p_set_of_books_id IN NUMBER,
2948 p_return_status OUT NOCOPY VARCHAR2) IS
2949
2950 CURSOR payroll_control_cur IS
2951 SELECT payroll_control_id,
2952 source_type,
2953 payroll_source_code,
2954 time_period_id,
2955 batch_name,
2956 business_group_id,
2957 set_of_books_id
2958 FROM psp_payroll_controls
2959 WHERE status_code = 'I'
2960 AND source_type <> 'A'
2961 AND run_id = g_run_id
2962 AND (phase is null or
2963 phase in ('GMS_Tie_Back', 'GL_Tie_Back')); --- added for 2444657
2964
2965 CURSOR gms_sum_lines_cursor(P_PAYROLL_CONTROL_ID IN NUMBER) IS
2966 SELECT ppl.person_id,
2967 ppl.assignment_id,
2968 nvl(pos.project_id,
2969 nvl(psl.project_id,
2970 nvl(pod.project_id,
2971 nvl(pea.project_id,
2972 pdls.project_id)))) project_id,
2973 nvl(pos.expenditure_organization_id,
2974 nvl(psl.expenditure_organization_id,
2975 nvl(pod.expenditure_organization_id,
2976 nvl(pea.expenditure_organization_id,
2977 pdls.expenditure_organization_id)))) expenditure_organization_id,
2978 nvl(pdl.suspense_auto_exp_type, --- added for 5080403
2979 nvl(pos.expenditure_type,
2980 nvl(pdl.auto_expenditure_type, --- added for 2663344
2981 nvl(psl.expenditure_type,
2982 nvl(pod.expenditure_type,
2983 nvl(pea.expenditure_type,
2984 pdls.expenditure_type)))))) expenditure_type,
2985 nvl(pos.task_id,
2986 nvl(psl.task_id,
2987 nvl(pod.task_id,
2988 nvl(pea.task_id,
2989 pdls.task_id)))) task_id,
2990 nvl(pos.award_id,
2991 nvl(psl.award_id,
2992 nvl(pod.award_id,
2993 nvl(pea.award_id,
2994 pdls.award_id)))) award_id,
2995 ppl.dr_cr_flag,
2996 pdl.effective_date,
2997 nvl(ppc.gl_posting_override_date,ppl.accounting_date) accounting_date, --- added for 3108109
2998 nvl(ppc.exchange_rate_type,ppl.exchange_rate_type) exchange_rate_type, --- added for 3108109
2999 pdl.distribution_amount,
3000 pdl.distribution_line_id distribution_line_id,
3001 pdl.auto_expenditure_type,
3002 'D' tab_flag,
3003 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute_category, pos.attribute_category), NULL) attribute_category, -- Introduced DFF columns for bug fix 2908859
3004 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute1, pos.attribute8), NULL) attribute1,
3005 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute2, pos.attribute8), NULL) attribute2,
3006 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute3, pos.attribute8), NULL) attribute3,
3007 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute4, pos.attribute8), NULL) attribute4,
3008 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute5, pos.attribute8), NULL) attribute5,
3009 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute6, pos.attribute8), NULL) attribute6,
3010 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute7, pos.attribute8), NULL) attribute7,
3011 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute8, pos.attribute8), NULL) attribute8,
3012 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute9, pos.attribute9), NULL) attribute9,
3013 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute10, pos.attribute10), NULL) attribute10
3014 ---decode(pdl.suspense_org_account_id, NULL, 'N', 'Y') Suspense_Flag uncommented for 2663344
3015 FROM psp_schedule_lines psl,
3016 psp_organization_accounts pod,
3017 psp_organization_accounts pos,
3018 psp_element_type_accounts pea,
3019 psp_default_labor_schedules pdls,
3020 psp_payroll_controls ppc,
3021 psp_payroll_lines ppl,
3022 psp_payroll_sub_lines ppsl,
3023 psp_distribution_lines pdl
3024 WHERE pdl.status_code = 'N'
3025 AND pdl.payroll_sub_line_id = ppsl.payroll_sub_line_id
3026 AND ppsl.payroll_line_id = ppl.payroll_line_id
3027 AND ppl.payroll_control_id = ppc.payroll_control_id
3028 AND pdl.schedule_line_id = psl.schedule_line_id(+)
3029 AND pdl.default_org_account_id = pod.organization_account_id(+)
3030 AND pdl.element_account_id = pea.element_account_id(+)
3031 AND pdl.org_schedule_id = pdls.org_schedule_id(+)
3032 AND pdl.suspense_org_account_id = pos.organization_account_id(+)
3033 AND pdl.gl_project_flag = 'P'
3034 AND ppc.business_group_id = p_business_group_id
3035 AND ppc.set_of_books_id = p_set_of_books_id
3036 AND ppc.payroll_control_id = p_payroll_control_id
3037 ANd pdl.cap_excess_project_id is null
3038 UNION
3039 SELECT ppg.person_id,
3040 ppg.assignment_id,
3041 nvl(pos.project_id,
3042 ppg.project_id) project_id,
3043 nvl(pos.expenditure_organization_id,
3044 ppg.expenditure_organization_id) expenditure_organization_id,
3045 nvl(ppg.suspense_auto_exp_type, --- 5080403
3046 nvl(pos.expenditure_type,
3047 ppg.expenditure_type)) expenditure_type,
3048 nvl(pos.task_id,
3049 ppg.task_id) task_id,
3050 nvl(pos.award_id,
3051 ppg.award_id) award_id,
3052 ppg.dr_cr_flag,
3053 ppg.effective_date,
3054 ppc.gl_posting_override_date accounting_date, -- for 3108109
3055 ppc.exchange_rate_type, -- added for 3108109
3056 ppg.distribution_amount,
3057 ppg.pre_gen_dist_line_id distribution_line_id,
3058 NULL, -- Place holder for autopop details
3059 'P' tab_flag,
3060 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute_category, pos.attribute_category), NULL) attribute_category, -- Introduced DFF columns for bug fix 2908859
3061 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute1, pos.attribute8), NULL) attribute1,
3062 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute2, pos.attribute8), NULL) attribute2,
3063 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute3, pos.attribute8), NULL) attribute3,
3064 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute4, pos.attribute8), NULL) attribute4,
3065 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute5, pos.attribute8), NULL) attribute5,
3066 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute6, pos.attribute8), NULL) attribute6,
3067 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute7, pos.attribute8), NULL) attribute7,
3068 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute8, pos.attribute8), NULL) attribute8,
3069 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute9, pos.attribute9), NULL) attribute9,
3070 DECODE(g_dff_grouping_option, 'Y', DECODE(ppg.suspense_org_account_id, NULL, ppg.attribute10, pos.attribute10), NULL) attribute10
3071 ---decode(ppg.suspense_org_Account_id, NULL, 'N', 'Y') Suspense_Flag commented for 2663344
3072 FROM psp_pre_gen_dist_lines ppg,
3073 psp_organization_accounts pos,
3074 psp_payroll_controls ppc
3075 WHERE ppg.status_code = 'N'
3076 /* changed following condn. First Pass can have suspense: Bug 2007521 */
3077 AND ((ppg.gl_code_combination_id IS NULL and pos.gl_code_combination_id is null) OR
3078 pos.project_id is not null)
3079 AND ppc.payroll_control_id = p_payroll_control_id --- 3108109
3080 AND ppg.suspense_org_account_id = pos.organization_account_id(+)
3081 AND ppg.payroll_control_id = p_payroll_control_id
3082 AND ppg.set_of_books_id = p_set_of_books_id
3083 AND ppg.payroll_control_id = p_payroll_control_id
3084 union
3085 SELECT ppl.person_id,
3086 ppl.assignment_id,
3087 nvl(pos.project_id, pdl.cap_excess_project_id) project_id,
3088 nvl(pos.expenditure_organization_id, pdl.cap_excess_exp_org_id) expenditure_organization_id,
3089 nvl(pos.expenditure_type, nvl(pdl.auto_expenditure_type, pdl.cap_excess_exp_type)) expenditure_type,
3090 nvl(pos.task_id, pdl.cap_excess_task_id) task_id,
3091 nvl(pos.award_id, pdl.cap_excess_award_id) award_id,
3092 ppl.dr_cr_flag,
3093 pdl.effective_date,
3094 nvl(ppc.gl_posting_override_date,ppl.accounting_date) accounting_date, --- added for 3108109
3095 nvl(ppc.exchange_rate_type,ppl.exchange_rate_type) exchange_rate_type, --- added for 3108109
3096 pdl.distribution_amount,
3097 pdl.distribution_line_id distribution_line_id,
3098 pdl.auto_expenditure_type,
3099 'D' tab_flag,
3100 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute_category, pos.attribute_category), NULL) attribute_category, -- Introduced DFF columns for bug fix 2908859
3101 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute1, pos.attribute8), NULL) attribute1,
3102 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute2, pos.attribute8), NULL) attribute2,
3103 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute3, pos.attribute8), NULL) attribute3,
3104 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute4, pos.attribute8), NULL) attribute4,
3105 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute5, pos.attribute8), NULL) attribute5,
3106 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute6, pos.attribute8), NULL) attribute6,
3107 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute7, pos.attribute8), NULL) attribute7,
3108 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute8, pos.attribute8), NULL) attribute8,
3109 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute9, pos.attribute9), NULL) attribute9,
3110 DECODE(g_dff_grouping_option, 'Y', DECODE(pdl.suspense_org_account_id, NULL, pdl.attribute10, pos.attribute10), NULL) attribute10
3111 ---decode(pdl.suspense_org_account_id, NULL, 'N', 'Y') Suspense_Flag uncommented for 2663344
3112 FROM psp_organization_accounts pos,
3113 psp_payroll_controls ppc,
3114 psp_payroll_lines ppl,
3115 psp_payroll_sub_lines ppsl,
3116 psp_distribution_lines pdl
3117 WHERE pdl.status_code = 'N'
3118 AND pdl.payroll_sub_line_id = ppsl.payroll_sub_line_id
3119 AND ppsl.payroll_line_id = ppl.payroll_line_id
3120 AND ppl.payroll_control_id = ppc.payroll_control_id
3121 AND pdl.suspense_org_account_id = pos.organization_account_id(+)
3122 AND pdl.gl_project_flag = 'P'
3123 AND ppc.business_group_id = p_business_group_id
3124 AND ppc.set_of_books_id = p_set_of_books_id
3125 AND ppc.payroll_control_id = p_payroll_control_id
3126 AND pdl.cap_excess_project_id is not null
3127 ORDER BY 1,2,3,4,5,6,7,8,10,11,16,17,18,19,20,21,22,23,24,25,26,9;
3128
3129 --- added the order by attribute_category, attribute1 through attribute10 columns for BUG 6007017
3130
3131
3132 gms_sum_lines_rec gms_sum_lines_cursor%ROWTYPE;
3133 payroll_control_rec payroll_control_cur%ROWTYPE;
3134
3135 l_person_id NUMBER(9);
3136 l_assignment_id NUMBER(9);
3137 l_project_id NUMBER(15);
3138 l_expenditure_organization_id NUMBER(15);
3139 l_expenditure_type VARCHAR2(30);
3140 l_task_id NUMBER(15);
3141 l_award_id NUMBER(15);
3142 l_dr_cr_flag VARCHAR2(1);
3143 l_effective_date DATE;
3144 l_distribution_amount NUMBER;
3145 l_rec_count NUMBER := 0;
3146 l_summary_amount NUMBER := 0;
3147 l_summary_line_id NUMBER(10);
3148
3149 l_attribute_category VARCHAR2(30); -- Introduced variables for storing DFF values for bug fix 2908859
3150 l_attribute1 VARCHAR2(150);
3151 l_attribute2 VARCHAR2(150);
3152 l_attribute3 VARCHAR2(150);
3153 l_attribute4 VARCHAR2(150);
3154 l_attribute5 VARCHAR2(150);
3155 l_attribute6 VARCHAR2(150);
3156 l_attribute7 VARCHAR2(150);
3157 l_attribute8 VARCHAR2(150);
3158 l_attribute9 VARCHAR2(150);
3159 l_attribute10 VARCHAR2(150);
3160
3161 TYPE dist_id IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
3162 dist_line_id dist_id;
3163 l_dist_line_id NUMBER;
3164 i BINARY_INTEGER := 0;
3165 j NUMBER;
3166 l_return_status VARCHAR2(10);
3167 --- added following variables for 3108109
3168 l_exchange_rate_type VARCHAR2(30);
3169 l_accounting_date DATE;
3170 l_value VARCHAR2(200);
3171 l_table VARCHAR2(100);
3172 l_period_end_date DATE;
3173 l_begin_of_time DATE := to_date('01/01/1900','dd/mm/yyyy');
3174
3175 -- R12 MOAC Uptake
3176 l_org_id Number(15);
3177
3178 BEGIN
3179 OPEN payroll_control_cur;
3180 LOOP
3181 FETCH payroll_control_cur INTO payroll_control_rec;
3182 IF payroll_control_cur%NOTFOUND THEN
3183 CLOSE payroll_control_cur;
3184 EXIT;
3185 END IF;
3186 -- added for 3108109
3187 BEGIN
3188 SELECT end_date
3189 INTO l_period_end_date
3190 FROM per_time_periods
3191 WHERE time_period_id = payroll_control_rec.time_period_id;
3192 EXCEPTION
3193 WHEN NO_DATA_FOUND THEN
3194 l_value := 'Time Period Id = '||to_char(payroll_control_rec.time_period_id);
3195 l_table := 'PER_TIME_PERIODS';
3196 fnd_message.set_name('PSP','PSP_TR_VALUE_NOT_FOUND');
3197 fnd_message.set_token('VALUE',l_value);
3198 fnd_message.set_token('TABLE',l_table);
3199 fnd_msg_pub.add;
3200 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3201 END;
3202
3203
3204 OPEN gms_sum_lines_cursor(payroll_control_rec.payroll_control_id);
3205 l_rec_count := 0;
3206 l_summary_amount := 0;
3207 i := 0;
3208 LOOP
3209 FETCH gms_sum_lines_cursor INTO gms_sum_lines_rec;
3210 l_rec_count := l_rec_count + 1;
3211 IF gms_sum_lines_cursor%ROWCOUNT = 0 THEN
3212 CLOSE gms_sum_lines_cursor;
3213 EXIT;
3214 ELSIF gms_sum_lines_cursor%NOTFOUND THEN
3215 if (l_rec_count > 1) then
3216 update psp_payroll_controls
3217 set phase = 'Summarize_GMS_Lines' ----2444657: Replaced NULL
3218 where payroll_control_id = payroll_control_rec.payroll_control_id;
3219 end if;
3220 CLOSE gms_sum_lines_cursor;
3221 EXIT;
3222 END IF;
3223 --
3224
3225 IF l_rec_count = 1 THEN
3226 l_person_id := gms_sum_lines_rec.person_id;
3227 l_assignment_id := gms_sum_lines_rec.assignment_id;
3228 l_project_id := gms_sum_lines_rec.project_id;
3229 l_expenditure_organization_id := gms_sum_lines_rec.expenditure_organization_id;
3230 l_expenditure_type := gms_sum_lines_rec.expenditure_type;
3231 l_task_id := gms_sum_lines_rec.task_id;
3232 l_award_id := gms_sum_lines_rec.award_id;
3233 l_dr_cr_flag := gms_sum_lines_rec.dr_cr_flag;
3234 l_effective_date := gms_sum_lines_rec.effective_date;
3235 l_accounting_date := gms_sum_lines_rec.accounting_date; -- added 2 vars for 3108109
3236 l_exchange_rate_type := gms_sum_lines_rec.exchange_rate_type;
3237 l_attribute_category := gms_sum_lines_rec.attribute_category; -- Introduced DFF variable mapping for bug fix 2908859
3238 l_attribute1 := gms_sum_lines_rec.attribute1;
3239 l_attribute2 := gms_sum_lines_rec.attribute2;
3240 l_attribute3 := gms_sum_lines_rec.attribute3;
3241 l_attribute4 := gms_sum_lines_rec.attribute4;
3242 l_attribute5 := gms_sum_lines_rec.attribute5;
3243 l_attribute6 := gms_sum_lines_rec.attribute6;
3244 l_attribute7 := gms_sum_lines_rec.attribute7;
3245 l_attribute8 := gms_sum_lines_rec.attribute8;
3246 l_attribute9 := gms_sum_lines_rec.attribute9;
3247 l_attribute10 := gms_sum_lines_rec.attribute10;
3248 END IF;
3249
3250 IF l_person_id <> gms_sum_lines_rec.person_id OR
3251 l_assignment_id <> gms_sum_lines_rec.assignment_id OR
3252 l_project_id <> gms_sum_lines_rec.project_id OR
3253 l_expenditure_organization_id <> gms_sum_lines_rec.expenditure_organization_id OR
3254 l_expenditure_type <> gms_sum_lines_rec.expenditure_type OR
3255 l_task_id <> gms_sum_lines_rec.task_id OR
3256 l_award_id <> gms_sum_lines_rec.award_id OR
3257 l_dr_cr_flag <> gms_sum_lines_rec.dr_cr_flag OR
3258 (NVL(l_attribute_category, 'NULL') <> NVL(gms_sum_lines_rec.attribute_category, 'NULL')) OR -- Introduced DFF columns checks for bug fix 2908859
3259 (NVL(l_attribute1, 'NULL') <> NVL(gms_sum_lines_rec.attribute1, 'NULL')) OR
3260 (NVL(l_attribute2, 'NULL') <> NVL(gms_sum_lines_rec.attribute2, 'NULL')) OR
3261 (NVL(l_attribute3, 'NULL') <> NVL(gms_sum_lines_rec.attribute3, 'NULL')) OR
3262 (NVL(l_attribute4, 'NULL') <> NVL(gms_sum_lines_rec.attribute4, 'NULL')) OR
3263 (NVL(l_attribute5, 'NULL') <> NVL(gms_sum_lines_rec.attribute5, 'NULL')) OR
3264 (NVL(l_attribute6, 'NULL') <> NVL(gms_sum_lines_rec.attribute6, 'NULL')) OR
3265 (NVL(l_attribute7, 'NULL') <> NVL(gms_sum_lines_rec.attribute7, 'NULL')) OR
3266 (NVL(l_attribute8, 'NULL') <> NVL(gms_sum_lines_rec.attribute8, 'NULL')) OR
3267 (NVL(l_attribute9, 'NULL') <> NVL(gms_sum_lines_rec.attribute9, 'NULL')) OR
3268 (NVL(l_attribute10, 'NULL') <> NVL(gms_sum_lines_rec.attribute10, 'NULL')) OR
3269 nvl(l_accounting_date,l_begin_of_time) <>
3270 nvl(gms_sum_lines_rec.accounting_date,l_begin_of_time) OR
3271 nvl(l_exchange_rate_type,'-999') <>
3272 nvl(gms_sum_lines_rec.exchange_rate_type,'-999')
3273 THEN
3274
3275 -- If it is a Debit entry, it is passed as a +ve entry to Oracle Projects
3276 -- If it is a Credit entry, it is passed as a -ve entry to Oracle Projects
3277 IF l_dr_cr_flag = 'C' THEN
3278 l_summary_amount := 0 - l_summary_amount;
3279 END IF;
3280
3281 -- R12 MOAC Uptake
3282 l_org_id := psp_general.Get_transaction_org_id (l_project_id,l_expenditure_organization_id);
3283
3284 -- insert into summary lines
3285 insert_into_summary_lines(
3286 l_summary_line_id,
3287 l_person_id,
3288 l_assignment_id,
3289 payroll_control_rec.time_period_id,
3290 l_effective_date,
3291 nvl(l_accounting_date,l_period_end_date), --- added for 3108109
3292 l_exchange_rate_type,
3293 payroll_control_rec.source_type,
3294 payroll_control_rec.payroll_source_code,
3295 payroll_control_rec.set_of_books_id,
3296 NULL,
3297 l_project_id,
3298 l_expenditure_organization_id,
3299 l_expenditure_type,
3300 l_task_id,
3301 l_award_id,
3302 l_summary_amount,
3303 l_dr_cr_flag,
3304 'N',
3305 payroll_control_rec.batch_name,
3306 payroll_control_rec.payroll_control_id,
3307 payroll_control_rec.business_group_id,
3308 l_attribute_category, -- Introduced DFF columns for bug fix 2908859
3309 l_attribute1,
3310 l_attribute2,
3311 l_attribute3,
3312 l_attribute4,
3313 l_attribute5,
3314 l_attribute6,
3315 l_attribute7,
3316 l_attribute8,
3317 l_attribute9,
3318 l_attribute10,
3319 l_return_status,
3320 l_org_id -- R12 MOAC Uptake
3321 );
3322
3323 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3324 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3325 END IF;
3326
3327 FOR j IN 1 .. dist_line_id.COUNT LOOP
3328 l_dist_line_id := dist_line_id(j);
3329 --dbms_output.put_line('Dist_line_id to be updated = '||to_char(l_dist_line_id));
3330
3331 IF gms_sum_lines_rec.tab_flag = 'D' THEN
3332 UPDATE psp_distribution_lines
3333 SET summary_line_id = l_summary_line_id WHERE distribution_line_id = l_dist_line_id;
3334 ELSIF gms_sum_lines_rec.tab_flag = 'P' THEN
3335 UPDATE psp_pre_gen_dist_lines
3336 SET summary_line_id = l_summary_line_id WHERE pre_gen_dist_line_id = l_dist_line_id;
3337 END IF;
3338 END LOOP;
3339
3340 -- initialise the summary amount and dist_line_id
3341 l_summary_amount := 0;
3342 dist_line_id.delete;
3343 i := 0;
3344 END IF;
3345
3346 l_person_id := gms_sum_lines_rec.person_id;
3347 l_assignment_id := gms_sum_lines_rec.assignment_id;
3348 l_project_id := gms_sum_lines_rec.project_id;
3349 l_expenditure_organization_id := gms_sum_lines_rec.expenditure_organization_id;
3350 l_expenditure_type := gms_sum_lines_rec.expenditure_type;
3351 l_task_id := gms_sum_lines_rec.task_id;
3352 l_award_id := gms_sum_lines_rec.award_id;
3353 l_dr_cr_flag := gms_sum_lines_rec.dr_cr_flag;
3354 l_effective_date := gms_sum_lines_rec.effective_date;
3355 l_accounting_date := gms_sum_lines_rec.accounting_date; --- 3108109
3356 l_exchange_rate_type := gms_sum_lines_rec.exchange_rate_type;
3357 l_attribute_category := gms_sum_lines_rec.attribute_category; -- Introduced DFF variable mapping for bug fix 2908859
3358 l_attribute1 := gms_sum_lines_rec.attribute1;
3359 l_attribute2 := gms_sum_lines_rec.attribute2;
3360 l_attribute3 := gms_sum_lines_rec.attribute3;
3361 l_attribute4 := gms_sum_lines_rec.attribute4;
3362 l_attribute5 := gms_sum_lines_rec.attribute5;
3363 l_attribute6 := gms_sum_lines_rec.attribute6;
3364 l_attribute7 := gms_sum_lines_rec.attribute7;
3365 l_attribute8 := gms_sum_lines_rec.attribute8;
3366 l_attribute9 := gms_sum_lines_rec.attribute9;
3367 l_attribute10 := gms_sum_lines_rec.attribute10;
3368
3369 l_summary_amount := l_summary_amount + gms_sum_lines_rec.distribution_amount;
3370 i := i + 1;
3371 dist_line_id(i) := gms_sum_lines_rec.distribution_line_id;
3372
3373
3374 END LOOP;
3375
3376 IF l_dr_cr_flag = 'C' Then
3377 l_summary_amount := 0 - l_summary_amount;
3378 END IF;
3379
3380 IF l_rec_count > 1 THEN
3381 -- insert into summary lines
3382
3383 -- R12 MOAC Uptake
3384 l_org_id := psp_general.Get_transaction_org_id (l_project_id,l_expenditure_organization_id);
3385
3386 insert_into_summary_lines(
3387 l_summary_line_id,
3388 l_person_id,
3389 l_assignment_id,
3390 payroll_control_rec.time_period_id,
3391 l_effective_date,
3392 nvl(l_accounting_date,l_period_end_date), --- 3108109
3393 l_exchange_rate_type,
3394 payroll_control_rec.source_type,
3395 payroll_control_rec.payroll_source_code,
3396 payroll_control_rec.set_of_books_id,
3397 NULL,
3398 l_project_id,
3399 l_expenditure_organization_id,
3400 l_expenditure_type,
3401 l_task_id,
3402 l_award_id,
3403 l_summary_amount,
3404 l_dr_cr_flag,
3405 'N',
3406 payroll_control_rec.batch_name,
3407 payroll_control_rec.payroll_control_id,
3408 payroll_control_rec.business_group_id,
3409 l_attribute_category, -- Introduced DFF columns for bug fix 2908859
3410 l_attribute1,
3411 l_attribute2,
3412 l_attribute3,
3413 l_attribute4,
3414 l_attribute5,
3415 l_attribute6,
3416 l_attribute7,
3417 l_attribute8,
3418 l_attribute9,
3419 l_attribute10,
3420 l_return_status,
3421 l_org_id -- R12 MOAC uptake
3422 );
3423
3424 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3425 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3426 END IF;
3427
3428 FOR j IN 1 .. dist_line_id.COUNT LOOP
3429 l_dist_line_id := dist_line_id(j);
3430 --dbms_output.put_line('Dist_line_id to be updated = '||to_char(l_dist_line_id));
3431
3432 IF gms_sum_lines_rec.tab_flag = 'D' THEN
3433 UPDATE psp_distribution_lines
3434 SET summary_line_id = l_summary_line_id,
3435 status_code = 'N'
3436 WHERE distribution_line_id = l_dist_line_id;
3437 ELSIF gms_sum_lines_rec.tab_flag = 'P' THEN
3438 UPDATE psp_pre_gen_dist_lines
3439 SET summary_line_id = l_summary_line_id,
3440 status_code = 'N'
3441 WHERE pre_gen_dist_line_id = l_dist_line_id;
3442 END IF;
3443 END LOOP;
3444 dist_line_id.delete;
3445 END IF;
3446 END LOOP;
3447 --
3448 p_return_status := fnd_api.g_ret_sts_success;
3449
3450
3451 EXCEPTION
3452
3453 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3454 g_error_api_path := 'CREATE_GMS_SUM_LINES:'||g_error_api_path;
3455 p_return_status := fnd_api.g_ret_sts_unexp_error;
3456 WHEN OTHERS THEN
3457 g_error_api_path := 'CREATE_GMS_SUM_LINES:'||g_error_api_path;
3458 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','CREATE_GMS_SUM_LINES');
3459 p_return_status := fnd_api.g_ret_sts_unexp_error;
3460
3461 END;
3462
3463 ----------------------------- GMS INTERFACE ---------------------------------------------
3464 PROCEDURE transfer_to_gms_interface(p_source_type IN VARCHAR2,
3465 p_source_code IN VARCHAR2,
3466 p_time_period_id IN NUMBER,
3467 p_batch_name IN VARCHAR2,
3468 p_business_group_id IN NUMBER,
3469 p_set_of_books_id IN NUMBER,
3470 p_return_status OUT NOCOPY VARCHAR2) IS
3471
3472 CURSOR gms_batch_cursor IS
3473 SELECT payroll_control_id,
3474 source_type,
3475 payroll_source_code,
3476 time_period_id,
3477 batch_name,
3478 -- Introduced the following currency_code,exchange_rate_type for bug 2916848
3479 Currency_code,
3480 exchange_rate_type,
3481 phase --- added for 2444657
3482 FROM psp_payroll_controls
3483 WHERE status_code = 'I'
3484 AND source_type <> 'A'
3485 AND run_id = g_run_id
3486 AND phase in ('Summarize_GMS_Lines','Submitted_TI_Request');
3487
3488 CURSOR gms_interface_cursor(P_PAYROLL_CONTROL_ID IN NUMBER) IS
3489 SELECT psl.summary_line_id,
3490 psl.source_code,
3491 psl.person_id,
3492 psl.assignment_id,
3493 NVL(psl.gms_posting_effective_date,psl.effective_date) effective_date, /* Column modified for Enhancement Employee Assignment with Zero Work Days */
3494 psl.accounting_date, --- added 2 cols for 3108109
3495 psl.exchange_Rate_type,
3496 psl.project_id,
3497 psl.expenditure_organization_id,
3498 psl.expenditure_type,
3499 psl.task_id,
3500 psl.award_id,
3501 psl.summary_amount,
3502 psl.dr_cr_flag,
3503 psl.attribute1, -- Introduced attributes 1, 4 and 5 for bug fix 2908859
3504 psl.attribute2,
3505 psl.attribute3,
3506 psl.attribute4,
3507 psl.attribute5,
3508 psl.attribute6,
3509 psl.attribute7,
3510 psl.attribute8,
3511 psl.attribute9,
3512 psl.attribute10,
3513 org_id
3514 FROM psp_summary_lines psl
3515 WHERE psl.status_code = 'N'
3516 AND psl.gl_code_combination_id IS NULL
3517 AND psl.payroll_control_id = p_payroll_control_id;
3518
3519 gms_batch_rec gms_batch_cursor%ROWTYPE;
3520 gms_interface_rec gms_interface_cursor%ROWTYPE;
3521 l_transaction_source VARCHAR2(30);
3522 l_expenditure_comment VARCHAR2(240);
3523 l_employee_number VARCHAR2(30);
3524 l_org_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
3525 l_segment1 VARCHAR2(25);
3526 l_task_number VARCHAR2(25);
3527 l_gms_batch_name VARCHAR2(10);
3528 l_expenditure_ending_date DATE;
3529 l_period_name VARCHAR2(35);
3530 l_period_end_date DATE; ----uncommented for 2663344
3531 l_return_status VARCHAR2(50); --- increased the size from 10 for 2671594
3532 req_id NUMBER(15);
3533 call_status BOOLEAN;
3534 rphase VARCHAR2(30);
3535 rstatus VARCHAR2(30);
3536 dphase VARCHAR2(30);
3537 dstatus VARCHAR2(30);
3538 message VARCHAR2(240);
3539 p_errbuf VARCHAR2(32767);
3540 p_retcode VARCHAR2(32767);
3541 return_back EXCEPTION;
3542 l_rec_count NUMBER := 0;
3543 l_error VARCHAR2(100);
3544 l_product VARCHAR2(3);
3545 l_value VARCHAR2(200);
3546 l_table VARCHAR2(100);
3547 -- Populate the GMS_TRANSACTION_INTERFACE table also.
3548 gms_rec gms_transaction_interface_all%ROWTYPE;
3549 l_gms_transaction_source VARCHAR2(20);
3550 l_txn_source VARCHAR2(30);
3551 -- l_org_id NUMBER(15); -- Commented for R12 MOAC uptake
3552 l_txn_interface_id NUMBER(15);
3553 l_gms_install BOOLEAN DEFAULT gms_install.enabled;
3554
3555 -- R12 MOAC Uptake
3556 TYPE ORG_ID_TYPE IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
3557 ORG_ID_TAB ORG_ID_TYPE;
3558
3559 TYPE gms_batch_name_TYPE IS TABLE OF varchar2(10) INDEX BY BINARY_INTEGER;
3560 gms_batch_name_TAB gms_batch_name_TYPE;
3561
3562 TYPE req_id_TYPE is TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
3563 req_id_TAB req_id_TYPE;
3564
3565 TYPE call_status_TYPE IS TABLE OF BOOLEAN INDEX BY BINARY_INTEGER;
3566 call_status_TAB call_status_TYPE;
3567
3568
3569 Cursor operating_unit_csr(p_payroll_control_id IN NUMBER) IS
3570 SELECT Distinct org_id
3571 FROM psp_summary_lines psl
3572 WHERE psl.status_code = 'N'
3573 AND psl.gl_code_combination_id IS NULL
3574 AND psl.payroll_control_id = p_payroll_control_id;
3575
3576 temp_org_id Number(15);
3577
3578 BEGIN
3579
3580 -- get the source name
3581 BEGIN
3582 SELECT transaction_source
3583 INTO l_transaction_source
3584 FROM pa_transaction_sources
3585 WHERE transaction_source = 'OLD';
3586 EXCEPTION
3587 WHEN NO_DATA_FOUND THEN
3588 l_error := 'TRANSACTION SOURCE = OLD';
3589 l_product := 'PA';
3590 fnd_message.set_name('PSP','PSP_TR_NOT_SET_UP');
3591 fnd_message.set_token('ERROR',l_error);
3592 fnd_message.set_token('PRODUCT',l_product);
3593 fnd_msg_pub.add;
3594 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3595 END;
3596
3597 if (l_gms_install) then -- Changed site_enabled check to l_gms_install check for bug fix 2908859
3598 BEGIN
3599 SELECT transaction_source
3600 INTO l_gms_transaction_source
3601 FROM pa_transaction_sources
3602 WHERE transaction_source = 'GOLD';
3603 EXCEPTION
3604 WHEN NO_DATA_FOUND THEN
3605 l_error := 'TRANSACTION SOURCE = GOLD';
3606 l_product := 'GMS';
3607 fnd_message.set_name('PSP','PSP_TR_NOT_SET_UP');
3608 fnd_message.set_token('ERROR',l_error);
3609 fnd_message.set_token('PRODUCT',l_product);
3610 fnd_msg_pub.add;
3611 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3612 END;
3613 end if;
3614
3615 OPEN gms_batch_cursor;
3616 LOOP
3617 FETCH gms_batch_cursor INTO gms_batch_rec;
3618 IF gms_batch_cursor%NOTFOUND THEN
3619 CLOSE gms_batch_cursor;
3620 EXIT;
3621 END IF ;
3622
3623
3624 -- get the period_name (moved this statement from below for 2444657)
3625 BEGIN
3626 -- uncommented period end date for 2663344
3627 SELECT substr(period_name ,1,35),end_date
3628 INTO l_period_name ,l_period_end_date
3629 FROM per_time_periods
3630 WHERE time_period_id = gms_batch_rec.time_period_id;
3631 EXCEPTION
3632 WHEN NO_DATA_FOUND THEN
3633 l_value := 'Time Period Id = '||to_char(gms_batch_rec.time_period_id);
3634 l_table := 'PER_TIME_PERIODS';
3635 fnd_message.set_name('PSP','PSP_TR_VALUE_NOT_FOUND');
3636 fnd_message.set_token('VALUE',l_value);
3637 fnd_message.set_token('TABLE',l_table);
3638 fnd_msg_pub.add;
3639 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3640 END;
3641
3642 -- R12 MOAC Uptake .. org_id array to always populate 5090047
3643 -- moved If condin below
3644 ORG_ID_TAB.delete;
3645 gms_batch_name_TAB.delete;
3646 req_id_TAB.delete;
3647 call_status_TAB.delete;
3648
3649 OPEN operating_unit_csr(gms_batch_rec.payroll_control_id);
3650 FETCH operating_unit_csr BULK COLLECT INTO org_id_tab;
3651 CLOSE operating_unit_csr ;
3652
3653 IF gms_batch_rec.phase = 'Summarize_GMS_Lines' then --2444657
3654
3655 FOR I in 1..org_id_tab.count
3656 LOOP
3657 SELECT to_char(psp_gms_batch_name_s.nextval)
3658 INTO gms_batch_name_tab(i)
3659 FROM dual;
3660 END LOOP;
3661 /*
3662 -- get the group_id
3663 SELECT to_char(psp_gms_batch_name_s.nextval)
3664 INTO l_gms_batch_name
3665 FROM dual;
3666 */
3667 -- R12 MOAC Uptake. Moved this code to loop
3668 -- update psp_summary_lines with gms batch name
3669 FOR I in 1..org_id_tab.count
3670 LOOP
3671 UPDATE psp_summary_lines
3672 SET gms_batch_name = gms_batch_name_tab(i) -- R12 MOAC uptake. changed from l_gms_batch_name
3673 WHERE payroll_control_id = gms_batch_rec.payroll_control_id
3674 AND status_code = 'N'
3675 AND gl_code_combination_id IS NULL
3676 AND org_id = org_id_tab(i); -- R12 MOAC uptake
3677 END LOOP;
3678
3679
3680 l_expenditure_comment := gms_batch_rec.source_type||':'||gms_batch_rec.payroll_source_code||':'||l_period_name||':'||gms_batch_rec.batch_name;
3681
3682 -- l_interface_id := pa_txn_interface_s.nextval;
3683
3684 OPEN gms_interface_cursor(gms_batch_rec.payroll_control_id);
3685 l_rec_count := 0;
3686 LOOP
3687 FETCH gms_interface_cursor INTO gms_interface_rec;
3688 IF gms_interface_cursor%NOTFOUND THEN
3689 CLOSE gms_interface_cursor;
3690 EXIT;
3691 END IF;
3692 l_rec_count := l_rec_count + 1;
3693
3694 -- get the employee number
3695 BEGIN
3696 SELECT employee_number
3697 INTO l_employee_number
3698 FROM per_people_f
3699 WHERE person_id = gms_interface_rec.person_id
3700 AND gms_interface_rec.effective_date BETWEEN effective_start_date AND effective_end_date;
3701 EXCEPTION
3702 WHEN NO_DATA_FOUND THEN
3703 l_value := 'Person Id = '||to_char(gms_interface_rec.person_id);
3704 l_table := 'PER_PEOPLE_F';
3705 fnd_message.set_name('PSP','PSP_TR_VALUE_NOT_FOUND');
3706 fnd_message.set_token('VALUE',l_value);
3707 fnd_message.set_token('TABLE',l_table);
3708 fnd_msg_pub.add;
3709 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3710 END;
3711
3712 -- get the employee's organization name
3713 BEGIN
3714 -- SELECT substr(name,1,60) Commented for bug fix 2447912
3715 SELECT name -- Removed SUBSTR for bug fix 2447912
3716 INTO l_org_name
3717 FROM hr_all_organization_units hou
3718 WHERE organization_id = gms_interface_rec.expenditure_organization_id;
3719 EXCEPTION
3720 WHEN NO_DATA_FOUND THEN
3721 l_value := 'Organization Id = '||to_char(gms_interface_rec.expenditure_organization_id);
3722 l_table := 'HR_ORGANIZATION_UNITS';
3723 fnd_message.set_name('PSP','PSP_TR_VALUE_NOT_FOUND');
3724 fnd_message.set_token('VALUE',l_value);
3725 fnd_message.set_token('TABLE',l_table);
3726 fnd_msg_pub.add;
3727 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3728 --l_org_name := NULL;
3729 --l_org_name := 'LDM_ORG_NAME_INVALID';
3730 END;
3731
3732 -- get the project number
3733 BEGIN
3734 SELECT segment1
3735 INTO l_segment1
3736 FROM pa_projects_all
3737 WHERE project_id = gms_interface_rec.project_Id;
3738 EXCEPTION
3739 WHEN NO_DATA_FOUND THEN
3740 l_value := 'Project Id = '||to_char(gms_interface_rec.project_Id);
3741 l_table := 'PA_PROJECTS_ALL';
3742 fnd_message.set_name('PSP','PSP_TR_VALUE_NOT_FOUND');
3743 fnd_message.set_token('VALUE',l_value);
3744 fnd_message.set_token('TABLE',l_table);
3745 fnd_msg_pub.add;
3746 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3747 END;
3748
3749 -- R12 MOAC Uptake. Org_id is stored in psp_summary_line Table
3750 /*
3751 -- get the org_id for the project..
3752 BEGIN
3753 SELECT org_id
3754 INTO l_org_id
3755 FROM pa_projects_all
3756 WHERE project_id = gms_interface_rec.project_Id;
3757 EXCEPTION
3758 WHEN NO_DATA_FOUND THEN
3759 l_value := 'Project Id = '||to_char(gms_interface_rec.project_Id);
3760 l_table := 'PA_PROJECTS_ALL';
3761 fnd_message.set_name('PSP','PSP_ORG_VALUE_NOT_FOUND');
3762 fnd_message.set_token('VALUE',l_value);
3763 fnd_message.set_token('TABLE',l_table);
3764 fnd_msg_pub.add;
3765 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3766 END;
3767 */
3768
3769 -- get the task number
3770 BEGIN
3771 SELECT task_number
3772 INTO l_task_number
3773 FROM pa_tasks
3774 WHERE task_id = gms_interface_rec.task_id;
3775 EXCEPTION
3776 WHEN NO_DATA_FOUND THEN
3777 l_value := 'Task Id = '||to_char(gms_interface_rec.task_id);
3778 l_table := 'PA_TASKS';
3779 fnd_message.set_name('PSP','PSP_TR_VALUE_NOT_FOUND');
3780 fnd_message.set_token('VALUE',l_value);
3781 fnd_message.set_token('TABLE',l_table);
3782 fnd_msg_pub.add;
3783 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3784 END;
3785
3786 -- Get the transaction_interface_id. We need this to populate the gms_interface table.
3787
3788 select pa_txn_interface_s.nextval
3789 into l_txn_interface_id
3790 from dual;
3791
3792 -- get the expenditure week ending date
3793
3794 -- set the context to single to call pa_utils function
3795 mo_global.set_policy_context('S', gms_interface_rec.org_id );
3796
3797 l_expenditure_ending_date := pa_utils.GetWeekending(gms_interface_rec.effective_date);
3798
3799 -- set the context again to multiple
3800 mo_global.set_policy_context('M', null);
3801
3802
3803 --
3804
3805 -- dbms_output.put_line('Inserting into pa interface.............');
3806
3807 -- if gms_interface_rec.award_id is not null then Commented for bug fix 2908859
3808 if (l_gms_install) then -- Introduced for bug fix 2908859
3809 l_txn_source := l_gms_transaction_source;
3810 else
3811 l_txn_source := l_transaction_source;
3812 end if;
3813
3814 --R12 MOAC Uptake
3815 FOR I in 1..org_id_tab.count
3816 LOOP
3817 IF org_id_tab(I) = gms_interface_rec.org_id THEN
3818 l_gms_batch_name := gms_batch_name_tab(I);
3819 EXIT;
3820 END IF;
3821 END LOOP;
3822
3823
3824
3825 -- Modified g_currency_code to gms_batch_rec.currency_code,Introduced Actual_exchange_rate_type
3826 -- actual rate_date for Bug 2916848
3827
3828 IF (gms_batch_rec.currency_code <> 'STAT') THEN
3829 insert_into_pa_interface(l_txn_interface_id,
3830 l_txn_source, L_GMS_BATCH_NAME,L_EXPENDITURE_ENDING_DATE,
3831 L_EMPLOYEE_NUMBER,L_ORG_NAME,GMS_INTERFACE_REC.EFFECTIVE_DATE,
3832 L_SEGMENT1,L_TASK_NUMBER,GMS_INTERFACE_REC.EXPENDITURE_TYPE,
3833 1,GMS_INTERFACE_REC.SUMMARY_AMOUNT,L_EXPENDITURE_COMMENT,
3834 -- 'P',GMS_INTERFACE_REC.SUMMARY_LINE_ID,GMS_INTERFACE_REC.AWARD_ID,
3835 -- Award details are populated into GMS_INT
3836 'P', GMS_INTERFACE_REC.SUMMARY_LINE_ID, GMS_INTERFACE_REC.ORG_ID,gms_batch_rec.CURRENCY_CODE ,
3837 GMS_INTERFACE_REC.SUMMARY_AMOUNT, gms_interface_rec.attribute1, --Changed NULL vale for Attribute1 to interface value for bug fix 2908859
3838 GMS_INTERFACE_REC.ATTRIBUTE2,GMS_INTERFACE_REC.ATTRIBUTE3,
3839 GMS_INTERFACE_REC.ATTRIBUTE4,GMS_INTERFACE_REC.ATTRIBUTE5, -- Introduced attributes 4 and 5 for bug fix 2908859
3840 GMS_INTERFACE_REC.ATTRIBUTE6,GMS_INTERFACE_REC.ATTRIBUTE7,
3841 GMS_INTERFACE_REC.ATTRIBUTE8,GMS_INTERFACE_REC.ATTRIBUTE9,
3842 GMS_INTERFACE_REC.ATTRIBUTE10,
3843 GMS_INTERFACE_REC.EXCHANGE_RATE_TYPE,
3844 gms_interface_rec.accounting_date,-- Introduced for bug 2916848 Ilo Ehn Mrc
3845 p_business_group_id,--Introduced for bug 2935850
3846 L_RETURN_STATUS);
3847
3848 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3849 --dbms_output.put_line('Faaaaaaiiiiiiilllllllleeeeeeeeeddddddd......');
3850 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3851 END IF;
3852
3853 ELSE
3854 insert_into_pa_interface(l_txn_interface_id,
3855 l_txn_source, L_GMS_BATCH_NAME,L_EXPENDITURE_ENDING_DATE,
3856 L_EMPLOYEE_NUMBER,L_ORG_NAME,GMS_INTERFACE_REC.EFFECTIVE_DATE,
3857 L_SEGMENT1,L_TASK_NUMBER,GMS_INTERFACE_REC.EXPENDITURE_TYPE,
3858 GMS_INTERFACE_REC.SUMMARY_AMOUNT, 0,L_EXPENDITURE_COMMENT,
3859 'P', GMS_INTERFACE_REC.SUMMARY_LINE_ID, GMS_INTERFACE_REC.ORG_ID,gms_batch_rec.CURRENCY_CODE ,
3860 GMS_INTERFACE_REC.SUMMARY_AMOUNT, gms_interface_rec.attribute1, --Changed NULL vale for Attribute1 to interface value for bug fix 2908859
3861 GMS_INTERFACE_REC.ATTRIBUTE2,GMS_INTERFACE_REC.ATTRIBUTE3,
3862 GMS_INTERFACE_REC.ATTRIBUTE4,GMS_INTERFACE_REC.ATTRIBUTE5, -- Introduced attributes 4 and 5 for bug fix 2908859
3863 GMS_INTERFACE_REC.ATTRIBUTE6,GMS_INTERFACE_REC.ATTRIBUTE7,
3864 GMS_INTERFACE_REC.ATTRIBUTE8,GMS_INTERFACE_REC.ATTRIBUTE9,
3865 GMS_INTERFACE_REC.ATTRIBUTE10,
3866 GMS_INTERFACE_REC.EXCHANGE_RATE_TYPE,
3867 gms_interface_rec.accounting_date,-- Introduced for bug 2916848 Ilo Ehn Mrc
3868 p_business_group_id,--Introduced for bug 2935850
3869 L_RETURN_STATUS);
3870
3871 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3872 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3873 END IF;
3874
3875 END IF;
3876
3877
3878 if (gms_interface_rec.award_id is not null) then
3879
3880 GMS_REC.TXN_INTERFACE_ID := l_txn_interface_id;
3881 GMS_REC.BATCH_NAME := l_gms_batch_name;
3882 GMS_REC.TRANSACTION_SOURCE := l_gms_transaction_source;
3883 GMS_REC.EXPENDITURE_ENDING_DATE := l_expenditure_ending_date;
3884 GMS_REC.EXPENDITURE_ITEM_DATE := gms_interface_rec.effective_date;
3885 GMS_REC.PROJECT_NUMBER := l_segment1;
3886 GMS_REC.TASK_NUMBER := l_task_number;
3887 GMS_REC.AWARD_ID := gms_interface_rec.award_id;
3888 GMS_REC.EXPENDITURE_TYPE := gms_interface_rec.expenditure_type;
3889 GMS_REC.TRANSACTION_STATUS_CODE := 'P';
3890 GMS_REC.ORIG_TRANSACTION_REFERENCE := gms_interface_rec.summary_line_id;
3891 GMS_REC.ORG_ID := GMS_INTERFACE_REC.org_id;
3892 GMS_REC.SYSTEM_LINKAGE := NULL;
3893 GMS_REC.USER_TRANSACTION_SOURCE := NULL;
3894 GMS_REC.TRANSACTION_TYPE := NULL;
3895 GMS_REC.BURDENABLE_RAW_COST := gms_interface_rec.summary_amount;
3896 GMS_REC.FUNDING_PATTERN_ID := NULL;
3897
3898 gms_transactions_pub.LOAD_GMS_XFACE_API(gms_rec, l_return_status);
3899
3900 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3901 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3902 END IF;
3903
3904 end if;
3905
3906 END LOOP;
3907 else --- 2444657 --- phase = 'Submitted_TI_Request'
3908 for i in 1..org_id_tab.count
3909 loop
3910 select gms_batch_name
3911 into gms_batch_name_tab(i)
3912 from psp_summary_lines
3913 where payroll_control_id = gms_batch_rec.payroll_control_id
3914 and org_id = org_id_tab(i)
3915 and project_id is not null
3916 and rownum = 1;
3917 end loop;
3918 if (l_gms_install) then --- fix for 5090047
3919 l_txn_source := l_gms_transaction_source;
3920 else
3921 l_txn_source := l_transaction_source;
3922 end if;
3923 hr_utility.trace(' deriving l_txn_source = '|| l_txn_source);
3924 end if; --- phase = 'Summarize_GL_Lines' ..2444657
3925 IF l_rec_count > 0 and gms_batch_rec.phase = 'Summarize_GMS_Lines' THEN ---2444657
3926
3927 FOR I in 1..org_id_tab.count
3928 LOOP
3929 l_gms_batch_name := gms_batch_name_tab(I);
3930
3931 -- set the context to single to submit_request
3932 mo_global.set_policy_context('S', org_id_tab(I) );
3933 fnd_request.set_org_id (org_id_tab(I) );
3934
3935 req_id_tab(i) := fnd_request.submit_request(
3936 'PA',
3937 'PAXTRTRX',
3938 NULL,
3939 NULL,
3940 FALSE,
3941 l_txn_source, -- should be l_txn_source rather than l_transaction_source,
3942 l_gms_batch_name);
3943
3944 IF req_id = 0 THEN
3945 fnd_message.set_name('PSP','PSP_TR_GMS_IMP_FAILED');
3946 fnd_msg_pub.add;
3947 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3948 END IF;
3949 END LOOP;
3950 update psp_payroll_controls
3951 set phase = 'Submitted_TI_Request'
3952 WHERE payroll_control_id = gms_batch_rec.payroll_control_id;
3953
3954 commit;
3955
3956 FOR I in 1..org_id_tab.count
3957 LOOP
3958 call_status_tab(I) := fnd_concurrent.wait_for_request(req_id_tab(I), 20, 0,
3959 rphase, rstatus, dphase, dstatus, message);
3960 IF call_status_tab(I) = FALSE then
3961 fnd_message.set_name('PSP','PSP_TR_GMS_IMP_FAILED');
3962 fnd_msg_pub.add;
3963 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3964 END IF;
3965 END LOOP;
3966 gms_batch_rec.phase := 'Submitted_TI_Request'; ---2444657
3967 END IF; --- 2444657 end rec_count > 0
3968
3969 -- set the context again to multiple
3970 mo_global.set_policy_context('M', null);
3971
3972 IF gms_batch_rec.phase = 'Submitted_TI_Request' then --2444657
3973 ---- added below for 5742525
3974 IF FND_PROFILE.VALUE('PSP_ST_EXTENSION_ENABLE') = 'Y' THEN
3975 psp_st_ext.tieback_actual(gms_batch_rec.payroll_control_id ,
3976 gms_batch_rec.source_type ,
3977 l_period_end_date ,
3978 l_gms_batch_name ,
3979 l_txn_source,
3980 p_business_group_id ,
3981 p_set_of_books_id );
3982 ENd if;
3983
3984 -- mark the successfully transferred records as 'A' in psp_summary_lines and psp_distribution_lines
3985 -- and transfer the successful records to the history table
3986 --- Bug 2663344 reverted NULL to l_period_end_date in tie back call
3987 hr_utility.trace(' before loop for gms_tie_back');
3988 FOR I in 1..org_id_tab.count
3989 LOOP
3990 hr_utility.trace(' tab_count ='||i);
3991 l_gms_batch_name := gms_batch_name_tab(I);
3992 hr_utility.trace(' tab_count 2nd time='||i);
3993
3994 gms_tie_back(gms_batch_rec.payroll_control_id,
3995 gms_batch_rec.source_type,
3996 l_period_end_date,
3997 l_gms_batch_name,
3998 p_business_group_id,
3999 p_set_of_books_id,
4000 l_txn_source,
4001 'N', --Introduced as part of Bug fix #1776606
4002 l_return_status);
4003 hr_utility.trace(' after tie back call to gms_tie_back');
4004
4005 /* Bug 1617846 LD Recovery LOV not showing up fialed S and T */
4006 /* introduced ELSE clause */
4007
4008 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4009 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4010 -- ELSE --Commented for R12 MOAc uptake;
4011 --- moved update psp_payroll_control phase = Tie back inside gms_tie_back
4012 --- for 2444657
4013 -- commit; --Commented for R12 MOAc uptake
4014 END IF;
4015 END LOOP;
4016 commit; -- R12 MOAc uptake; moved commit from above
4017 END IF;
4018 END LOOP;
4019
4020 --
4021 p_return_status := fnd_api.g_ret_sts_success;
4022 EXCEPTION
4023 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4024 g_error_api_path := 'TRANSFER_TO_GMS_INTERFACE:'||g_error_api_path;
4025 p_return_status := fnd_api.g_ret_sts_unexp_error;
4026
4027 WHEN RETURN_BACK THEN
4028 p_return_status := fnd_api.g_ret_sts_success;
4029
4030 WHEN OTHERS THEN
4031 g_error_api_path := 'TRANSFER_TO_GMS_INTERFACE:'||g_error_api_path;
4032 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','TRANSFER_TO_GMS_INTERFACE');
4033 p_return_status := fnd_api.g_ret_sts_unexp_error;
4034 END;
4035
4036
4037 ------------------------- GMS TIE BACK ---------------------------------------------------
4038 PROCEDURE gms_tie_back(p_payroll_control_id IN NUMBER,
4039 p_source_type IN VARCHAR2,
4040 p_period_end_date IN DATE,
4041 p_gms_batch_name IN VARCHAR2,
4042 p_business_group_id IN NUMBER,
4043 p_set_of_books_id IN NUMBER,
4044 p_txn_source IN VARCHAR2,
4045 p_mode IN VARCHAR2, --Introduced as part of Bug fix #1776606
4046 p_return_status OUT NOCOPY VARCHAR2) IS
4047 CURSOR gms_tie_back_success_cur IS
4048 SELECT summary_line_id,
4049 dr_cr_flag,summary_amount
4050 FROM psp_summary_lines
4051 WHERE gms_batch_name = p_gms_batch_name;
4052
4053
4054 CURSOR gms_tie_back_reject_cur IS
4055 --- SELECT nvl(transaction_rejection_code,'P'), *****Bug 1866362***
4056 select transaction_rejection_code,
4057 orig_transaction_reference,
4058 transaction_status_code,
4059 expenditure_ending_date, -- added following five columns for 2445196
4060 expenditure_id,
4061 interface_id,
4062 expenditure_item_id,
4063 txn_interface_id
4064 FROM pa_transaction_interface_all
4065 WHERE batch_name = p_gms_batch_name
4066 AND transaction_source = p_txn_source;
4067
4068 CURSOR assign_susp_ac_cur(P_SUMMARY_LINE_ID IN NUMBER) IS
4069 SELECT pdl.rowid,
4070 pdl.distribution_line_id line_id,
4071 pdl.distribution_date,
4072 pdl.suspense_org_account_id
4073 FROM psp_distribution_lines pdl
4074 WHERE pdl.summary_line_id = p_summary_line_id
4075 UNION
4076 SELECT ppgd.rowid,
4077 ppgd.pre_gen_dist_line_id line_id,
4078 ppgd.distribution_date,
4079 ppgd.suspense_org_account_id
4080 FROM psp_pre_gen_dist_lines ppgd
4081 WHERE ppgd.summary_line_id = p_summary_line_id;
4082
4083 CURSOR get_susp_org_cur1 (P_ORG_ID IN VARCHAR2) IS
4084 SELECT hou.organization_id, hou.name
4085 FROM hr_all_organization_units hou, psp_organization_accounts poa
4086 WHERE hou.organization_id = poa.organization_id
4087 AND poa.business_group_id = p_business_group_id
4088 AND poa.set_of_books_id = p_set_of_books_id
4089 AND poa.organization_account_id = p_org_id;
4090
4091 CURSOR get_org_id_cur1 (P_LINE_ID IN NUMBER) IS
4092 SELECT hou.organization_id, hou.name
4093 FROM hr_all_organization_units hou,
4094 per_assignments_f paf,
4095 psp_payroll_lines ppl,
4096 psp_payroll_sub_lines ppsl,
4097 psp_distribution_lines pdl
4098 WHERE paf.assignment_id = ppl.assignment_id
4099 AND hou.organization_id = paf.organization_id
4100 AND pdl.distribution_line_id = p_line_id
4101 AND ppsl.payroll_sub_line_id = pdl.payroll_sub_line_id
4102 AND ppl.payroll_line_id = ppsl.payroll_line_id
4103 AND pdl.distribution_date between paf.effective_start_date and paf.effective_end_date
4104 UNION
4105 SELECT hou.organization_id, hou.name
4106 FROM hr_all_organization_units hou,
4107 per_assignments_f paf,
4108 psp_pre_gen_dist_lines ppgdl
4109 WHERE paf.assignment_id = ppgdl.assignment_id
4110 AND hou.organization_id = paf.organization_id
4111 AND ppgdl.pre_gen_dist_line_id = p_line_id
4112 AND ppgdl.distribution_date between paf.effective_start_date and paf.effective_end_date;
4113
4114 l_orig_org_name1 hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
4115 l_orig_org_id1 number;
4116
4117 CURSOR org_susp_ac_cur(P_ORGANIZATION_ID IN NUMBER,
4118 P_DISTRIBUTION_DATE IN DATE) IS
4119 SELECT poa.organization_account_id,
4120 poa.gl_code_combination_id,
4121 poa.project_id,
4122 poa.award_id,
4123 poa.task_id, -- Line added by pvelamur for bug fix 897553
4124 poa.expenditure_organization_id,
4125 poa.expenditure_type
4126 FROM psp_organization_accounts poa
4127 WHERE poa.organization_id = p_organization_id
4128 AND poa.account_type_code = 'S'
4129 AND poa.business_group_id = p_business_group_id
4130 AND poa.set_of_books_id = p_set_of_books_id
4131 AND p_distribution_date BETWEEN poa.start_date_active AND
4132 nvl(poa.end_date_active,p_distribution_date);
4133
4134
4135 -- CURSOR global_susp_ac_cur(P_DISTRIBUTION_DATE IN DATE) IS
4136 CURSOR global_susp_ac_cur(P_ORGANIZATION_ACCOUNT_ID IN NUMBER) IS --BUG 2056877.
4137 SELECT poa.organization_account_id,
4138 poa.gl_code_combination_id,
4139 poa.project_id,
4140 poa.award_id,
4141 poa.task_id, -- Line added by pvelamur for bugfix 897553
4142 poa.expenditure_organization_id,
4143 poa.expenditure_type
4144 FROM psp_organization_accounts poa
4145 WHERE
4146 /* poa.account_type_code = 'G'
4147 AND poa.business_group_id = p_business_group_id
4148 AND poa.set_of_books_id = p_set_of_books_id
4149 AND p_distribution_date BETWEEN poa.start_date_active AND
4150 nvl(poa.end_date_active,p_distribution_date);Bug 2056877 */
4151 organization_account_id = p_organization_account_id; --Added for bug 2056877.
4152
4153 l_organization_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
4154 l_organization_id NUMBER(15);
4155 l_rowid ROWID;
4156 l_assignment_id NUMBER(15);
4157 l_distribution_date DATE;
4158 l_suspense_org_account_id NUMBER(9);
4159 --
4160 l_organization_account_id NUMBER(9);
4161 l_gl_code_combination_id NUMBER(15);
4162 l_project_id NUMBER(15);
4163 l_award_id NUMBER(15);
4164 l_task_id NUMBER(15);
4165 --
4166 l_cnt_gms_interface NUMBER;
4167 l_summary_line_id NUMBER(10);
4168 l_gl_project_flag VARCHAR2(1);
4169 l_suspense_ac_failed VARCHAR2(1) := 'N';
4170 l_suspense_ac_not_found VARCHAR2(1) := 'N';
4171 l_susp_ac_found VARCHAR2(10) := 'TRUE';
4172 l_summary_amount NUMBER;
4173 l_dr_summary_amount NUMBER := 0;
4174 l_cr_summary_amount NUMBER := 0;
4175 l_dr_cr_flag VARCHAR2(1);
4176 --
4177 l_trx_status_code VARCHAR2(2); /* Bug 1938458: Increased size from 1 to 2*/
4178 l_trx_reject_code VARCHAR2(30);
4179 l_orig_trx_reference VARCHAR2(30);
4180 l_effective_date DATE;
4181
4182 x_susp_failed_org_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
4183 x_susp_failed_reject_code VARCHAR2(30);
4184 x_susp_failed_date DATE;
4185 x_susp_nf_org_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
4186 x_susp_nf_date DATE;
4187 l_return_status VARCHAR2(10);
4188 x_line_id NUMBER;
4189 l_no_run NUMBER;
4190 l_trx_source VARCHAR2(40);
4191 l_no_run_status VARCHAR2(2);
4192 l_return_value VARCHAR2(30); --Added for bug 2056877.
4193 no_profile_exists EXCEPTION; --Added for bug 2056877.
4194 no_val_date_matches EXCEPTION; --Added for bug 2056877.
4195 no_global_acct_exists EXCEPTION; --Added for bug 2056877.
4196 l_expenditure_ending_date date; -- added five variables for 2445196
4197 l_expenditure_id number;
4198 l_interface_id number;
4199 l_expenditure_item_id number;
4200 l_txn_interface_id number;
4201 l_susp_exception varchar2(50); -- 2479579
4202
4203 l_expenditure_type varchar2(100); -- introduced vars for 5080403
4204 l_exp_org_id number;
4205 l_new_expenditure_type varchar2(100);
4206 l_new_glccid number;
4207 l_acct_type varchar2(1);
4208 l_auto_pop_status varchar2(100);
4209 l_auto_status varchar2(100);
4210 l_person_id number;
4211 l_element_type_id number;
4212 l_assignment_number varchar2(100);
4213 l_element_type varchar2(200);
4214 l_person_name varchar2(300);
4215 l_account varchar2(1000);
4216 l_auto_org_name hr_all_organization_units_tl.name%TYPE;
4217 l_pay_action_type psp_payroll_lines.payroll_action_type%TYPE; -- Bug 7040943
4218
4219 cursor get_element_type is
4220 select ppl.element_type_id,
4221 ppl.assignment_id,
4222 ppl.person_id
4223 from psp_payroll_lines ppl,
4224 psp_payroll_sub_lines ppsl,
4225 psp_distribution_lines pdl
4226 where pdl.distribution_line_id = x_line_id
4227 and pdl.payroll_sub_line_id = ppsl.payroll_sub_line_id
4228 and ppsl.payroll_line_id = ppl.payroll_line_id
4229 union all
4230 select ppg.element_type_id,
4231 ppg.assignment_id,
4232 ppg.person_id
4233 from psp_pre_gen_dist_lines ppg
4234 where pre_gen_dist_line_id = x_line_id;
4235
4236 cursor get_asg_details is
4237 select ppf.full_name,
4238 paf.assignment_number,
4239 pet.element_name,
4240 hou.name
4241 from per_all_people_f ppf,
4242 per_all_assignments_f paf,
4243 pay_element_types_f pet,
4244 hr_all_organization_units hou
4245 where ppf.person_id = l_person_id
4246 and l_distribution_date between ppf.effective_start_date and ppf.effective_end_date
4247 and paf.assignment_id = l_assignment_id
4248 and l_distribution_date between paf.effective_start_date and paf.effective_end_date
4249 and pet.element_type_id = l_element_type_id
4250 and l_distribution_date between pet.effective_start_date and pet.effective_end_date
4251 and hou.organization_id = paf.organization_id;
4252
4253
4254 -- Bug 4369939: Performance fix START
4255 TYPE t_varchar2_10_type IS TABLE OF varchar2(10) INDEX BY BINARY_INTEGER;
4256 TYPE t_varchar2_30_type IS TABLE OF varchar2(30) INDEX BY BINARY_INTEGER;
4257 TYPE t_number_type IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
4258 type SUMMARY_LINES_TYPE is record
4259 (
4260 L_SUMMARY_LINE_ID t_number_type,
4261 L_SUMMARY_LINE_ID_CHAR t_varchar2_30_type,
4262 L_GMS_BATCH_NAME t_varchar2_10_type
4263 );
4264
4265 summary_lines_rec SUMMARY_LINES_TYPE;
4266
4267 Cursor SUMMARY_LINES_csr IS
4268 Select SUMMARY_LINE_ID, to_CHAR(SUMMARY_LINE_ID) , GMS_BATCH_NAME
4269 From PSP_SUMMARY_LINES PSL
4270 where PSL.GMS_BATCH_NAME = p_gms_batch_name;
4271 -- Bug 4369939: Performance fix END
4272
4273
4274 FUNCTION PROCESS_COMPLETE RETURN BOOLEAN IS
4275
4276 cursor get_completion is
4277 select count(*), transaction_status_code
4278 from pa_transaction_interface_all
4279 where batch_name = p_gms_batch_name
4280 and transaction_source = p_txn_source
4281 and transaction_status_code in ('P', 'I')
4282 group by transaction_status_code ;
4283
4284 get_completion_rec get_completion%ROWTYPE;
4285
4286 begin
4287
4288 open get_completion;
4289 loop
4290 fetch get_completion into get_completion_rec;
4291
4292 if get_completion%ROWCOUNT = 0 then
4293 close get_completion;
4294 return TRUE;
4295 elsif get_completion%NOTFOUND then
4296 close get_completion;
4297 return FALSE;
4298 end if;
4299
4300 if get_completion_rec.transaction_status_code = 'P' then
4301
4302 -- -------------------------------------------------------------------------------------------
4303 -- If transaction_status_code = 'P' then the transaction import process did not kick off
4304 -- for some reason. Return 'NOT_RUN' in this case. So cleanup the tables and try to transfer
4305 -- again after summarization in the second pass.
4306 -- -------------------------------------------------------------------------------------------
4307
4308 delete from pa_transaction_interface_all
4309 where batch_name = p_gms_batch_name
4310 and transaction_source = p_txn_source;
4311
4312 if p_txn_source = 'GOLD' then
4313 delete from gms_transaction_interface_all
4314 where batch_name = p_gms_batch_name
4315 and transaction_source = 'GOLD';
4316 end if;
4317
4318 delete from psp_summary_lines
4319 where gms_batch_name = to_number(p_gms_batch_name)
4320 and payroll_control_id = p_payroll_control_id;
4321
4322
4323 elsif get_completion_rec.transaction_status_code = 'I' then
4324
4325 -- -------------------------------------------------------------------------------------------
4326 -- If transaction_status_code = 'I' then the transaction import process did not complete
4327 -- the Post Processing extension. So return 'NOT_COMPLETE' in this case. User needs to complete
4328 -- this process by running the transaction import manually and re-start the LD process.
4329 -- -------------------------------------------------------------------------------------------
4330
4331 l_no_run_status := 'I';
4332
4333 NULL; --- Return False here.
4334
4335 end if;
4336
4337 end loop;
4338
4339 exception
4340 when others then
4341 return FALSE;
4342 end PROCESS_COMPLETE;
4343
4344 BEGIN
4345
4346 hr_utility.trace('entered gms_tie_back');
4347
4348
4349 if NOT PROCESS_COMPLETE then
4350 if (l_no_run_status = 'I') then
4351 fnd_message.set_name('PSP','PSP_PRC_DID_NOT_RUN');
4352 fnd_message.set_token('PAYROLL_CONTROL_ID',p_payroll_control_id);
4353 fnd_message.set_token('GMS_BATCH_NAME',p_gms_batch_name);
4354 fnd_msg_pub.add;
4355 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4356 end if;
4357 end if;
4358 hr_utility.trace('entered gms_tie_back2');
4359
4360 -- Status codes have been added to transaction import process,
4361 -- to accomodate pre and post import extensions in 11i
4362 -- to following select statement
4363
4364 SELECT count(*)
4365 INTO l_cnt_gms_interface
4366 FROM pa_transaction_interface_all
4367 WHERE batch_name = p_gms_batch_name
4368 AND transaction_source = p_txn_source
4369 AND transaction_status_code in ('R', 'PO', 'PI', 'PR');
4370
4371 /* moved this statement to beginning for 2444657 */
4372 UPDATE psp_payroll_controls
4373 SET phase = 'GL_Tie_Back'
4374 WHERE payroll_control_id = p_payroll_control_id;
4375 hr_utility.trace('entered gms_tie_back3');
4376
4377 IF l_cnt_gms_interface > 0 THEN
4378 --
4379 OPEN gms_tie_back_reject_cur;
4380 LOOP
4381 FETCH gms_tie_back_reject_cur INTO l_trx_reject_code,l_orig_trx_reference,l_trx_status_code,
4382 l_expenditure_ending_date,l_expenditure_id, -- added 5 vars for 2445196
4383 l_interface_id,l_expenditure_item_id, l_txn_interface_id;
4384
4385
4386
4387 IF gms_tie_back_reject_cur%NOTFOUND THEN
4388 CLOSE gms_tie_back_reject_cur;
4389 EXIT;
4390 END IF;
4391
4392 -- update summary_lines with the reject status code
4393 IF l_trx_status_code in ('R', 'PO', 'PI', 'PR') THEN
4394 UPDATE psp_summary_lines
4395 SET interface_status = l_trx_reject_code, status_code = 'R',
4396 expenditure_ending_date = l_expenditure_ending_date, -- added 5 fields for 2445196
4397 expenditure_id = l_expenditure_id, interface_id=l_interface_id,
4398 expenditure_item_id=l_expenditure_item_id, txn_interface_id=l_txn_interface_id
4399 WHERE summary_line_id = to_number(l_orig_trx_reference);
4400 ELSIF l_trx_status_code = 'A' THEN
4401 UPDATE psp_summary_lines
4402 SET interface_status = l_trx_reject_code, status_code = 'A',
4403 expenditure_ending_date = l_expenditure_ending_date, -- added 5 fields for 2445196
4404 expenditure_id = l_expenditure_id, interface_id=l_interface_id,
4405 expenditure_item_id=l_expenditure_item_id, txn_interface_id=l_txn_interface_id
4406 WHERE summary_line_id = to_number(l_orig_trx_reference);
4407
4408 SELECT summary_amount,dr_cr_flag
4409 INTO l_summary_amount,l_dr_cr_flag
4410 FROM psp_summary_lines
4411 WHERE summary_line_id = to_number(l_orig_trx_reference) ;
4412 hr_utility.trace('entered gms_tie_back4');
4413 IF l_dr_cr_flag = 'D' THEN
4414 l_dr_summary_amount := l_dr_summary_amount + l_summary_amount;
4415 ELSIF l_dr_cr_flag = 'C' THEN
4416 -- credit is marked as -ve for posting to Oracle Projects
4417 l_cr_summary_amount := l_cr_summary_amount - l_summary_amount;
4418 END IF;
4419 END IF;
4420 hr_utility.trace('before open assign_susp_ac_cur');
4421 OPEN assign_susp_ac_cur(l_orig_trx_reference);
4422 LOOP
4423
4424 FETCH assign_susp_ac_cur INTO l_rowid, x_line_id, l_distribution_date, l_suspense_org_account_id;
4425
4426 /*Bug 7376898*/
4427 SELECT distinct payroll_action_type
4428 INTO l_pay_action_type
4429 FROM psp_payroll_lines
4430 WHERE payroll_control_id = p_payroll_control_id
4431 and payroll_line_id = (select payroll_line_id from psp_payroll_sub_lines
4432 where payroll_sub_line_id = (select payroll_sub_line_id
4433 from psp_distribution_lines
4434 where distribution_line_id = x_line_id));
4435 SELECT distinct effective_date
4436 INTO l_effective_date
4437 FROM psp_payroll_lines
4438 WHERE payroll_control_id = p_payroll_control_id
4439 and payroll_line_id = (select payroll_line_id from psp_payroll_sub_lines
4440 where payroll_sub_line_id = (select payroll_sub_line_id
4441 from psp_distribution_lines
4442 where distribution_line_id = x_line_id));
4443
4444 /*Bug 7376898 End*/
4445
4446 IF assign_susp_ac_cur%NOTFOUND THEN
4447 CLOSE assign_susp_ac_cur;
4448 EXIT;
4449 END IF;
4450 hr_utility.trace('entered gms_tie_back5');
4451
4452 IF l_trx_status_code = 'A' THEN
4453 IF p_source_type = 'O' OR p_source_type = 'N' THEN
4454 UPDATE psp_distribution_lines
4455 SET status_code = 'A'
4456 WHERE rowid = l_rowid;
4457
4458 INSERT INTO psp_distribution_lines_history
4459 (distribution_line_id,payroll_sub_line_id,distribution_date,
4460 effective_date,distribution_amount,status_code,suspense_reason_code,
4461 effort_report_id,version_num,schedule_line_id,summary_line_id,
4462 default_org_account_id,suspense_org_account_id,
4463 element_account_id,org_schedule_id,user_defined_field,
4464 default_reason_code,reversal_entry_flag,gl_project_flag,
4465 auto_expenditure_type, business_group_id, set_of_books_id,
4466 attribute_category, attribute1, attribute2, attribute3,
4467 attribute4, attribute5, attribute6, attribute7,
4468 attribute8, attribute9, attribute10,
4469 cap_excess_glccid, cap_excess_award_id, cap_excess_task_id,
4470 cap_excess_project_id, cap_excess_exp_type, cap_excess_exp_org_id,
4471 funding_source_code, annual_salary_cap, cap_excess_dist_line_id,
4472 suspense_auto_exp_type, suspense_auto_glccid, adj_account_flag)
4473 SELECT distribution_line_id,payroll_sub_line_id,distribution_date,
4474 effective_date,distribution_amount,status_code,suspense_reason_code,
4475 effort_report_id,version_num,schedule_line_id,summary_line_id,
4476 default_org_account_id,suspense_org_account_id,
4477 element_account_id,org_schedule_id,user_defined_field,
4478 default_reason_code,reversal_entry_flag,gl_project_flag,
4479 auto_expenditure_type, business_group_id, set_of_books_id,
4480 attribute_category, attribute1, attribute2, attribute3,
4481 attribute4, attribute5, attribute6, attribute7,
4482 attribute8, attribute9, attribute10,
4483 cap_excess_glccid, cap_excess_award_id, cap_excess_task_id,
4484 cap_excess_project_id, cap_excess_exp_type, cap_excess_exp_org_id,
4485 funding_source_code, annual_salary_cap, cap_excess_dist_line_id,
4486 suspense_auto_exp_type, suspense_auto_glccid, adj_account_flag
4487 FROM psp_distribution_lines
4488 WHERE status_code = 'A'
4489 AND summary_line_id = to_number(l_orig_trx_reference);
4490
4491 hr_utility.trace('after insert into dist lines');
4492 DELETE FROM psp_distribution_lines
4493 WHERE status_code = 'A'
4494 AND summary_line_id = to_number(l_orig_trx_reference);
4495
4496 --moved the two del stmnts above for 2445196
4497
4498 ELSIF p_source_type = 'P' THEN
4499 UPDATE psp_pre_gen_dist_lines
4500 SET status_code = 'A'
4501 WHERE rowid = l_rowid;
4502
4503 -- move the transferred records to psp_pre_gen_dist_lines_history
4504 INSERT INTO psp_pre_gen_dist_lines_history
4505 (pre_gen_dist_line_id,distribution_interface_id,person_id,assignment_id,
4506 element_type_id,distribution_date,effective_date,distribution_amount,
4507 dr_cr_flag,payroll_control_id,source_type,source_code,time_period_id,
4508 batch_name,status_code,set_of_books_id,
4509 gl_code_combination_id,project_id,expenditure_organization_id,
4510 expenditure_type,task_id,award_id,suspense_reason_code,
4511 effort_report_id,version_num,summary_line_id,suspense_org_account_id,
4512 user_defined_field,reversal_entry_flag, business_group_id,
4513 attribute_category, attribute1, attribute2, attribute3,
4514 attribute4, attribute5, attribute6, attribute7,
4515 attribute8, attribute9, attribute10,
4516 suspense_auto_exp_type, suspense_auto_glccid)
4517 SELECT pre_gen_dist_line_id,distribution_interface_id,person_id,assignment_id,
4518 element_type_id,distribution_date,effective_date,distribution_amount,
4519 dr_cr_flag,payroll_control_id,source_type,source_code,time_period_id,
4520 batch_name,status_code,set_of_books_id,
4521 gl_code_combination_id,project_id,expenditure_organization_id,
4522 expenditure_type,task_id,award_id,suspense_reason_code,
4523 effort_report_id,version_num,summary_line_id,suspense_org_account_id,
4524 user_defined_field,reversal_entry_flag, business_group_id,
4525 attribute_category, attribute1, attribute2, attribute3,
4526 attribute4, attribute5, attribute6, attribute7,
4527 attribute8, attribute9, attribute10,
4528 suspense_auto_exp_type, suspense_auto_glccid
4529 FROM psp_pre_gen_dist_lines
4530 WHERE status_code = 'A'
4531 AND summary_line_id = to_number(l_orig_trx_reference);
4532
4533 hr_utility.trace('after insert into pregen lines');
4534 DELETE FROM psp_pre_gen_dist_lines
4535 WHERE status_code = 'A'
4536 AND summary_line_id = to_number(l_orig_trx_reference);
4537 END IF;
4538 --- moved the two del stmnts below for 2445196, earlier commented for 2290051
4539
4540 /* Bug 1866362, S and T Failing with Fatal error Suspense A/C invalid, eventhough Suspense A/C is valid.
4541 Introduced reject_code not null condition, stick suspense only if this condition satisified */
4542 -- if a suspense a/c failed,update the status of the whole batch and display the error
4543 ELSIF l_trx_status_code <> 'A' and l_trx_reject_code is not NULL then
4544 -- introduced following IF by splitting from above ELSIF stmt: 2428953.
4545 If l_suspense_org_account_id is NOT NULL then
4546
4547 OPEN get_susp_org_cur1(l_suspense_org_account_id);
4548 FETCH get_susp_org_cur1 into l_organization_id, l_organization_name;
4549 CLOSE get_susp_org_cur1;
4550
4551 x_susp_failed_org_name := l_organization_name;
4552 x_susp_failed_reject_code := l_trx_reject_code;
4553 x_susp_failed_date := l_distribution_date;
4554 l_suspense_ac_failed := 'Y';
4555
4556 /* Commented For Bug 3065866
4557
4558 IF p_source_type = 'O' OR p_source_type = 'N' THEN
4559 UPDATE psp_distribution_lines
4560 SET suspense_reason_code = l_trx_reject_code,
4561 status_code = 'N'
4562 WHERE rowid = l_rowid;
4563 ELSIF p_source_type = 'P' THEN
4564 UPDATE psp_pre_gen_dist_lines
4565 SET suspense_reason_code = l_trx_reject_code,
4566 status_code = 'N'
4567 WHERE rowid = l_rowid;
4568 END IF; Enf of commenting for BUg 3065866 */
4569
4570 ELSE -- suspense org is null and rejected xface rec
4571 l_susp_ac_found := 'TRUE';
4572
4573 OPEN get_org_id_cur1(x_line_id);
4574 FETCH get_org_id_cur1 into l_orig_org_id1, l_orig_org_name1;
4575 --dbms_output.put_line('orig ord id is ' || l_orig_org_id1);
4576 IF get_org_id_cur1%NOTFOUND then
4577 -- dbms_output.put_line('Didnot get any data');
4578 null;
4579 END IF;
4580 CLOSE get_org_id_cur1;
4581
4582 --Bug 7040943 Starts
4583 IF l_pay_action_type = 'L' THEN
4584 l_distribution_date := l_effective_date;
4585 END IF;
4586 --Bug 7040943 End
4587
4588 OPEN org_susp_ac_cur(l_orig_org_id1, l_distribution_date);
4589 FETCH org_susp_ac_cur INTO l_organization_account_id,l_gl_code_combination_id,l_project_id,l_award_id,l_task_id,
4590 l_exp_org_id, l_expenditure_type;
4591
4592 IF org_susp_ac_cur%NOTFOUND THEN
4593 /* Following code is added for bug 2056877 ,Added validation for generic suspense account */
4594 l_return_value := psp_general.find_global_suspense(l_distribution_date,
4595 p_business_group_id,
4596 p_set_of_books_id,
4597 l_organization_account_id);
4598 /* --------------------------------------------------------------------
4599 Valid return values are
4600 PROFILE_VAL_DATE_MATCHES Profile and Value and Date matching 'G'
4601 NO_PROFILE_EXISTS No Profile
4602 NO_VAL_DATE_MATCHES Profile and Either Value/date do not
4603 match with 'G'
4604 NO_GLOBAL_ACCT_EXISTS No 'G' exists
4605 ---------------------------------------------------------------------- */
4606 IF l_return_value = 'PROFILE_VAL_DATE_MATCHES' THEN
4607 -- OPEN global_susp_ac_cur(l_distribution_date);
4608 OPEN global_susp_ac_cur(l_organization_account_id); -- Bug 2056877.
4609 FETCH global_susp_ac_cur INTO l_organization_account_id,l_gl_code_combination_id,l_project_id,l_award_id,
4610 l_task_id, l_exp_org_id, l_expenditure_type;
4611
4612 IF global_susp_ac_cur%NOTFOUND THEN
4613 /* l_susp_ac_found := 'FALSE';
4614 l_suspense_ac_not_found := 'Y';
4615 x_susp_nf_org_name := l_organization_name;
4616 x_susp_nf_org_name := l_orig_org_name1;
4617 x_susp_nf_date := l_distribution_date; */ --Commented for bug 2056877.
4618 --- commented for 2479579 RAISE no_global_acct_exists; --Added for bug 2056877
4619 -- added following lines for 2479579
4620 l_susp_ac_found := 'NO_G_AC';
4621 l_suspense_ac_not_found := 'Y';
4622 END IF;
4623 CLOSE global_susp_ac_cur;
4624 ELSIF l_return_value = 'NO_GLOBAL_ACCT_EXISTS' THEN
4625 --- RAISE no_global_acct_exists; commented this line added following 2 lines for 2479579
4626 l_suspense_ac_not_found := 'Y';
4627 l_susp_ac_found := 'NO_G_AC';
4628 ELSIF l_return_value = 'NO_VAL_DATE_MATCHES' THEN
4629 --- RAISE no_val_date_matches; commented this line added following 2 lines for 2479579
4630 l_suspense_ac_not_found := 'Y';
4631 l_susp_ac_found := 'NO_DT_MCH';
4632 ELSIF l_return_value = 'NO_PROFILE_EXISTS' THEN
4633 --- RAISE no_profile_exists; commented this line added following 2 lines for 2479579
4634 l_suspense_ac_not_found := 'Y';
4635 l_susp_ac_found := 'NO_PROFL';
4636 END IF; -- Bug 2056877.
4637 END IF;
4638 CLOSE org_susp_ac_cur;
4639 -- introduced for 5080403
4640 if g_suspense_autopop = 'Y' and l_organization_account_id is not null then
4641 if l_gl_code_combination_id is null then
4642 l_acct_type:='E';
4643 else
4644 l_acct_type:='N';
4645 end if;
4646 open get_element_type;
4647 fetch get_element_type into l_element_type_id, l_assignment_id, l_person_id;
4648 close get_element_type;
4649 psp_autopop.main( p_acct_type => l_acct_type,
4650 p_person_id => l_person_id,
4651 p_assignment_id => l_assignment_id,
4652 p_element_type_id => l_element_type_id,
4653 p_project_id => l_project_id,
4654 p_expenditure_organization_id => l_exp_org_id,
4655 p_task_id => l_task_id,
4656 p_award_id => l_award_id,
4657 p_expenditure_type => l_expenditure_type,
4658 p_gl_code_combination_id => l_gl_code_combination_id,
4659 p_payroll_date => l_distribution_date,
4660 p_set_of_books_id => p_set_of_books_id,
4661 p_business_group_id => p_business_group_id,
4662 ret_expenditure_type => l_new_expenditure_type,
4663 ret_gl_code_combination_id => l_new_glccid,
4664 retcode => l_auto_pop_status);
4665 IF (l_auto_pop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
4666 (l_auto_pop_status = FND_API.G_RET_STS_ERROR) THEN
4667 IF l_auto_pop_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
4668 if l_acct_type ='N' then
4669 l_auto_status := 'AUTO_POP_NA_ERROR';
4670 else
4671 l_auto_status :='AUTO_POP_EXP_ERROR';
4672 end if;
4673 elsif l_auto_pop_status = FND_API.G_RET_STS_ERROR THEN
4674 l_auto_status := 'AUTO_POP_NO_VALUE';
4675 end if;
4676 open get_asg_details;
4677 fetch get_asg_details into l_person_name, l_assignment_number, l_element_type, l_auto_org_name;
4678 close get_asg_details;
4679 psp_enc_crt_xml.p_set_of_books_id := p_set_of_books_id;
4680 psp_enc_crt_xml.p_business_group_id := p_business_group_id;
4681 if l_acct_type = 'N' then
4682 l_account :=
4683 psp_enc_crt_xml.cf_charging_instformula(l_new_glccid,
4684 null,
4685 null,
4686 null,
4687 null,
4688 null);
4689 else
4690 l_account :=
4691 psp_enc_crt_xml.cf_charging_instformula(null,
4692 l_project_id,
4693 l_task_id,
4694 l_award_id,
4695 l_new_expenditure_type,
4696 l_exp_org_id);
4697 end if;
4698 fnd_message.set_name('PSP','PSP_SUSPENSE_AUTOPOP_FAIL');
4699 fnd_message.set_token('ORG_NAME',l_auto_org_name);
4700 fnd_message.set_token('EMPLOYEE_NAME',l_person_name);
4701 fnd_message.set_token('ASG_NUM',l_assignment_number);
4702 fnd_message.set_token('CHARGING_ACCOUNT',l_account);
4703 fnd_message.set_token('AUTOPOP_ERROR',l_auto_status);
4704 fnd_message.set_token('EFF_DATE',l_distribution_date);
4705 fnd_msg_pub.add;
4706 else
4707 if l_acct_type = 'E' then
4708 l_expenditure_type := l_new_expenditure_type;
4709 else
4710 l_gl_code_combination_id := l_new_glccid;
4711 end if;
4712 end if;
4713 end if;
4714
4715 if l_susp_ac_found = 'TRUE' then
4716 IF l_gl_code_combination_id IS NOT NULL THEN
4717 l_gl_project_flag := 'G';
4718 -- l_effective_date := p_period_end_date; --- uncommented for Bug 2663344 COMMENTED by Bug 7040943
4719 ELSE
4720 l_gl_project_flag := 'P';
4721 l_effective_date := l_distribution_date; --- added for Bug 2663344
4722 END IF;
4723
4724
4725 IF p_source_type = 'O' OR p_source_type = 'N' THEN
4726
4727 /* Added for Bug 3065866 */
4728
4729 UPDATE psp_distribution_lines
4730 SET pre_distribution_run_flag = gl_project_flag
4731 WHERE rowid = l_rowid;
4732
4733 /* End of changes for Bug 3065866*/
4734
4735 UPDATE psp_distribution_lines
4736 SET suspense_org_account_id = l_organization_account_id,
4737 suspense_reason_code = 'ST:' || l_trx_reject_code,
4738 gl_project_flag = l_gl_project_flag,
4739 status_code = 'N',
4740 effective_date = l_effective_date, ---uncommented this line for Bug 2663344
4741 suspense_auto_glccid = l_new_glccid, --- added suspense_auto for 5080403
4742 suspense_auto_exp_type = l_new_expenditure_type
4743 WHERE rowid = l_rowid;
4744 ELSIF p_source_type = 'P' THEN
4745 UPDATE psp_pre_gen_dist_lines
4746 SET suspense_org_account_id = l_organization_account_id,
4747 suspense_reason_code = 'ST:' || l_trx_reject_code,
4748 status_code = 'N',
4749 effective_date = l_effective_date, ---uncommented this line for Bug 2663344
4750 suspense_auto_glccid = l_new_glccid,
4751 suspense_auto_exp_type = l_new_expenditure_type
4752 WHERE rowid = l_rowid;
4753
4754 END IF;
4755 else -- added for 2479579
4756 l_susp_exception := l_susp_ac_found;
4757 end if;
4758 END IF; --- for 2428953
4759 END IF;
4760
4761 END LOOP;
4762 END LOOP;
4763 hr_utility.trace('update control record');
4764 UPDATE psp_payroll_controls
4765 SET ogm_dr_amount = nvl(ogm_dr_amount,0) + l_dr_summary_amount,
4766 ogm_cr_amount = nvl(ogm_cr_amount,0) + l_cr_summary_amount
4767 WHERE payroll_control_id = p_payroll_control_id;
4768
4769 -- Introduced for bug fix 2643228
4770 DELETE pa_transaction_interface_all
4771 WHERE transaction_source = p_txn_source
4772 AND batch_name = p_gms_batch_name;
4773
4774 DELETE gms_transaction_interface_all
4775 WHERE transaction_source = p_txn_source
4776 AND batch_name = p_gms_batch_name;
4777 -- End of bug fix 2643228
4778 IF l_suspense_ac_failed = 'Y' or
4779 nvl(l_auto_status,'X') in ('AUTO_POP_NA_ERROR', 'AUTO_POP_EXP_ERROR', 'AUTO_POP_NO_VALUE') then
4780 --- above check for autopop error 5080403
4781 if nvl(l_suspense_ac_failed,'N') = 'Y' then
4782 fnd_message.set_name('PSP','PSP_TR_GMS_SUSP_AC_REJECT');
4783 fnd_message.set_token('ORG_NAME',x_susp_failed_org_name);
4784 fnd_message.set_token('PAYROLL_DATE',x_susp_failed_date);
4785 fnd_message.set_token('ERROR_MSG',x_susp_failed_reject_code);
4786 fnd_msg_pub.add;
4787 end if;
4788
4789 /* Added this code for Bug 3065866 */
4790 IF p_source_type = 'O' OR p_source_type = 'N' THEN
4791
4792
4793
4794 UPDATE psp_distribution_lines
4795 SET suspense_org_account_id = NULL,
4796 suspense_reason_code = NULL,
4797 gl_project_flag = pre_distribution_run_flag,
4798 effective_date = decode(pre_distribution_run_flag,'G',
4799 p_period_end_date,distribution_date)
4800 WHERE suspense_reason_code like 'ST:%'
4801 AND summary_line_id
4802 IN ( SELECT summary_line_id
4803 FROM psp_summary_lines
4804 WHERE payroll_control_id = p_payroll_control_id);
4805 ELSIF p_source_type = 'P' THEN
4806 UPDATE psp_pre_gen_dist_lines
4807 SET suspense_org_account_id = NULL,
4808 suspense_reason_code = NULL,
4809 effective_date = decode(NVL(gl_code_combination_id,-999),gl_code_combination_id,
4810 p_period_end_date,distribution_date)
4811 WHERE suspense_reason_code like 'ST:%'
4812 AND summary_line_id
4813 IN (SELECT summary_line_id
4814 FROM psp_summary_lines
4815 WHERE payroll_control_id = p_payroll_control_id);
4816
4817 END IF;
4818 /* End of code for Bug 3065866 */
4819
4820 /* Introduced the followinbg check as part of Bug fix #1776606 */
4821 if p_mode = 'N' then
4822 /* introduced mark batch end Bug: 1929317 */
4823 mark_batch_end(p_source_type,
4824 g_source_code,
4825 g_time_period_id,
4826 g_batch_name,
4827 p_business_group_id,
4828 p_set_of_books_id,
4829 l_return_status);
4830 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4831 end if;
4832 END IF;
4833
4834 IF l_suspense_ac_not_found = 'Y' THEN
4835 /* commented for 2479579
4836 fnd_message.set_name('PSP','PSP_LD_SUSPENSE_AC_NOT_EXIST');
4837 fnd_message.set_token('ORG_NAME',x_susp_nf_org_name);
4838 fnd_message.set_token('PAYROLL_DATE',x_susp_nf_date);
4839 fnd_msg_pub.add; */
4840
4841 /* Added the following code for Bug 3065866 */
4842
4843 IF p_source_type = 'O' OR p_source_type = 'N' THEN
4844 UPDATE psp_distribution_lines
4845 SET suspense_org_account_id = NULL,
4846 suspense_reason_code = NULL
4847 WHERE suspense_reason_code like 'ST:%'
4848 AND summary_line_id
4849 IN( SELECT summary_line_id
4850 FROM psp_summary_lines
4851 WHERE payroll_control_id = p_payroll_control_id);
4852 ELSIF p_source_type = 'P' THEN
4853 UPDATE psp_pre_gen_dist_lines
4854 SET suspense_org_account_id = NULL,
4855 suspense_reason_code = NULL
4856 WHERE suspense_reason_code like 'ST:%'
4857 AND summary_line_id
4858 IN( SELECT summary_line_id
4859 FROM psp_summary_lines
4860 WHERE payroll_control_id = p_payroll_control_id);
4861 END IF;
4862 /* End of Bug 3065866 */
4863
4864
4865 /* Introduced the followinbg check as part of Bug fix #1776606 */
4866 if p_mode = 'N' then
4867 /* introduced mark batch end Bug: 1929317 */
4868 mark_batch_end(p_source_type,
4869 g_source_code,
4870 g_time_period_id,
4871 g_batch_name,
4872 p_business_group_id,
4873 p_set_of_books_id,
4874 l_return_status);
4875 --- RAISE FND_API.G_EXC_UNEXPECTED_ERROR; commented for 2479579
4876 -- introduced following if stmnt for 2479579
4877 if l_susp_exception = 'NO_G_AC' then
4878 RAISE no_global_acct_exists;
4879 elsif l_susp_exception = 'NO_DT_MCH' then
4880 RAISE no_val_date_matches;
4881 elsif l_susp_exception = 'NO_PROFL' then
4882 RAISE no_profile_exists;
4883 end if;
4884
4885 end if;
4886 END IF;
4887
4888 ELSIF l_cnt_gms_interface = 0 THEN
4889
4890 -- Bug 4369939: Performance fix START
4891 OPEN SUMMARY_LINES_CSR;
4892 FETCH SUMMARY_LINES_CSR bulk Collect into SUMMARY_LINES_REC.L_SUMMARY_LINE_ID,
4893 SUMMARY_LINES_rec.L_SUMMARY_LINE_ID_CHAR, SUMMARY_LINES_REC.L_GMS_BATCH_NAME;
4894 CLOSE SUMMARY_LINES_CSR;
4895
4896 FORALL i in 1.. SUMMARY_LINES_REC.L_SUMMARY_LINE_ID.count
4897 UPDATE PSP_SUMMARY_LINES PSL
4898 Set (PSL.STATUS_CODE, PSL.EXPENDITURE_ENDING_DATE,PSL.EXPENDITURE_ID,
4899 PSL.INTERFACE_ID,PSL.EXPENDITURE_ITEM_ID,PSL.TXN_INTERFACE_ID) =
4900 ( SELECT 'A', PTXN.EXPENDITURE_ENDING_DATE,PTXN.EXPENDITURE_ID, PTXN.INTERFACE_ID,
4901 PTXN.EXPENDITURE_ITEM_ID,PTXN.TXN_INTERFACE_ID
4902 FROM PA_TRANSACTION_INTERFACE_ALL PTXN
4903 WHERE PTXN.TRANSACTION_SOURCE = p_txn_source
4904 AND PTXN.ORIG_TRANSACTION_REFERENCE= SUMMARY_LINES_REC.L_SUMMARY_LINE_ID_CHAR(i)
4905 AND PTXN.BATCH_NAME = SUMMARY_LINES_REC.L_GMS_BATCH_NAME(i)
4906 )
4907 WHERE --GMS_BATCH_NAME = SUMMARY_LINES_REC.L_GMS_BATCH_NAME(i) AND
4908 PSL.SUMMARY_LINE_ID = SUMMARY_LINES_REC.L_SUMMARY_LINE_ID(i);
4909
4910 /*
4911 -- changed to update all sum lines at one shot for 2445196
4912 UPDATE psp_summary_lines PSL
4913 SET (PSL.status_code, PSL.expenditure_ending_date,PSL.expenditure_id,
4914 PSL.interface_id,PSL.expenditure_item_id,PSL.txn_interface_id) =
4915 (select 'A', PTXN.expenditure_ending_date,PTXN.expenditure_id,
4916 PTXN.interface_id,PTXN.expenditure_item_id,PTXN.txn_interface_id
4917 from pa_transaction_interface_all PTXN
4918 where PTXN.transaction_source = p_txn_source
4919 and PTXN.orig_transaction_reference= to_char(PSL.summary_line_id)
4920 and PTXN.batch_name = p_gms_batch_name)
4921 WHERE gms_batch_name = p_gms_batch_name;
4922 */
4923 -- Bug 4369939: Performance fix END
4924
4925 OPEN gms_tie_back_success_cur;
4926 LOOP
4927 FETCH gms_tie_back_success_cur INTO l_summary_line_id,
4928 l_dr_cr_flag,l_summary_amount;
4929
4930 IF gms_tie_back_success_cur%NOTFOUND THEN
4931 CLOSE gms_tie_back_success_cur;
4932 EXIT;
4933 END IF;
4934
4935 -- update records in psp_summary_lines as 'A' moved this stmnt from here to above for 2445196.
4936
4937 IF l_dr_cr_flag = 'D' THEN
4938 l_dr_summary_amount := l_dr_summary_amount + l_summary_amount;
4939 ELSIF l_dr_cr_flag = 'C' THEN
4940 -- credit is marked as -ve for posting to Oracle Projects
4941 l_cr_summary_amount := l_cr_summary_amount - l_summary_amount;
4942 END IF;
4943
4944 IF p_source_type = 'O' OR p_source_type = 'N' THEN
4945
4946 UPDATE psp_distribution_lines
4947 SET status_code = 'A' WHERE summary_line_id = l_summary_line_id;
4948
4949 -- move the transferred records to psp_distribution_lines_history
4950 INSERT INTO psp_distribution_lines_history
4951 (distribution_line_id,payroll_sub_line_id,distribution_date,
4952 effective_date,distribution_amount,status_code,suspense_reason_code,
4953 effort_report_id,version_num,schedule_line_id,summary_line_id,
4954 default_org_account_id,suspense_org_account_id,
4955 element_account_id,org_schedule_id,user_defined_field,
4956 default_reason_code,reversal_entry_flag,gl_project_flag,
4957 auto_expenditure_type, business_group_id, set_of_books_id,
4958 attribute_category, attribute1, attribute2, attribute3,
4959 attribute4, attribute5, attribute6, attribute7,
4960 attribute8, attribute9, attribute10,
4961 cap_excess_glccid, cap_excess_award_id, cap_excess_task_id,
4962 cap_excess_project_id, cap_excess_exp_type, cap_excess_exp_org_id,
4963 funding_source_code, annual_salary_cap, cap_excess_dist_line_id,
4964 suspense_auto_exp_type, suspense_auto_glccid, adj_account_flag)
4965 SELECT distribution_line_id,payroll_sub_line_id,distribution_date,
4966 effective_date,distribution_amount,status_code,suspense_reason_code,
4967 effort_report_id,version_num,schedule_line_id,summary_line_id,
4968 default_org_account_id,suspense_org_account_id,
4969 element_account_id,org_schedule_id,user_defined_field,
4970 default_reason_code,reversal_entry_flag,gl_project_flag,
4971 auto_expenditure_type, business_group_id, set_of_books_id,
4972 attribute_category, attribute1, attribute2, attribute3,
4973 attribute4, attribute5, attribute6, attribute7,
4974 attribute8, attribute9, attribute10,
4975 cap_excess_glccid, cap_excess_award_id, cap_excess_task_id,
4976 cap_excess_project_id, cap_excess_exp_type, cap_excess_exp_org_id,
4977 funding_source_code, annual_salary_cap, cap_excess_dist_line_id,
4978 suspense_auto_exp_type, suspense_auto_glccid, adj_account_flag
4979 FROM psp_distribution_lines
4980 WHERE status_code = 'A'
4981 AND summary_line_id = l_summary_line_id;
4982
4983 DELETE FROM psp_distribution_lines
4984 WHERE status_code = 'A'
4985 AND summary_line_id = l_summary_line_id;
4986 -- Moved the purging of xface lines from here below LOOP, for Bug 2445196
4987 ELSIF p_source_type = 'P' THEN
4988
4989 UPDATE psp_pre_gen_dist_lines
4990 SET status_code = 'A' WHERE summary_line_id = l_summary_line_id;
4991
4992 -- move the transferred records to psp_pre_gen_dist_lines_history
4993 INSERT INTO psp_pre_gen_dist_lines_history
4994 (pre_gen_dist_line_id,distribution_interface_id,person_id,assignment_id,
4995 element_type_id,distribution_date,effective_date,distribution_amount,
4996 dr_cr_flag,payroll_control_id,source_type,source_code,time_period_id,
4997 batch_name,status_code,set_of_books_id,
4998 gl_code_combination_id,project_id,expenditure_organization_id,
4999 expenditure_type,task_id,award_id,suspense_reason_code,
5000 effort_report_id,version_num,summary_line_id,suspense_org_account_id,
5001 user_defined_field,reversal_entry_flag, business_group_id,
5002 attribute_category, attribute1, attribute2, attribute3,
5003 attribute4, attribute5, attribute6, attribute7,
5004 attribute8, attribute9, attribute10,
5005 suspense_auto_exp_type, suspense_auto_glccid)
5006 SELECT pre_gen_dist_line_id,distribution_interface_id,person_id,assignment_id,
5007 element_type_id,distribution_date,effective_date,distribution_amount,
5008 dr_cr_flag,payroll_control_id,source_type,source_code,time_period_id,
5009 batch_name,status_code,set_of_books_id,
5010 gl_code_combination_id,project_id,expenditure_organization_id,
5011 expenditure_type,task_id,award_id,suspense_reason_code,
5012 effort_report_id,version_num,summary_line_id,suspense_org_account_id,
5013 user_defined_field,reversal_entry_flag, business_group_id,
5014 attribute_category, attribute1, attribute2, attribute3,
5015 attribute4, attribute5, attribute6, attribute7,
5016 attribute8, attribute9, attribute10,
5017 suspense_auto_exp_type, suspense_auto_glccid
5018 FROM psp_pre_gen_dist_lines
5019 WHERE status_code = 'A'
5020 AND summary_line_id = l_summary_line_id;
5021
5022 DELETE FROM psp_pre_gen_dist_lines
5023 WHERE status_code = 'A'
5024 AND summary_line_id = l_summary_line_id;
5025 --Moved delete xface stmnts from here to below for bug 2445196:
5026 END IF;
5027 END LOOP;
5028
5029 UPDATE psp_payroll_controls
5030 SET ogm_dr_amount = nvl(ogm_dr_amount,0) + l_dr_summary_amount,
5031 ogm_cr_amount = nvl(ogm_cr_amount,0) + l_cr_summary_amount
5032 WHERE payroll_control_id = p_payroll_control_id;
5033
5034 -- Introduced for bug fix 2643228
5035 DELETE pa_transaction_interface_all
5036 WHERE transaction_source = p_txn_source
5037 AND batch_name = p_gms_batch_name;
5038
5039 DELETE gms_transaction_interface_all
5040 WHERE transaction_source = p_txn_source
5041 AND batch_name = p_gms_batch_name;
5042 -- End of bug fix 2643228
5043 END IF;
5044 /***** Commented for bug fix 2643228
5045 -- introduced for 2445196
5046 delete pa_transaction_interface_all
5047 where transaction_source = p_txn_source
5048 and batch_name = p_gms_batch_name;
5049
5050 delete gms_transaction_interface_all
5051 where transaction_source = p_txn_source
5052 and batch_name = p_gms_batch_name;
5053 End of bug fix 2643228 *****/
5054 p_return_status := fnd_api.g_ret_sts_success;
5055 EXCEPTION
5056 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5057 --dbms_output.put_line('Gone to one level top ..................');
5058 g_error_api_path := 'GMS_TIE_BACK:'||g_error_api_path;
5059 p_return_status := fnd_api.g_ret_sts_unexp_error;
5060 /* Added Exceptions for bug 2056877 */
5061 WHEN NO_PROFILE_EXISTS THEN
5062 g_error_api_path := SUBSTR('GMS_TIE_BACK:'||g_error_api_path,1,230);
5063 fnd_message.set_name('PSP','PSP_NO_PROFILE_EXISTS');
5064 fnd_msg_pub.add;
5065 p_return_status := fnd_api.g_ret_sts_unexp_error;
5066
5067 WHEN NO_VAL_DATE_MATCHES THEN
5068 g_error_api_path := SUBSTR('GMS_TIE_BACK:'||g_error_api_path,1,230);
5069 fnd_message.set_name('PSP','PSP_NO_VAL_DATE_MATCHES');
5070 fnd_message.set_token('ORG_NAME',l_orig_org_name1);
5071 fnd_message.set_token('PAYROLL_DATE',l_distribution_date);
5072 fnd_msg_pub.add;
5073 p_return_status := fnd_api.g_ret_sts_unexp_error;
5074
5075 WHEN NO_GLOBAL_ACCT_EXISTS THEN
5076 g_error_api_path := SUBSTR('GMS_TIE_BACK:'||g_error_api_path,1,230);
5077 fnd_message.set_name('PSP','PSP_NO_GLOBAL_ACCT_EXISTS');
5078 fnd_message.set_token('ORG_NAME',l_orig_org_name1);
5079 fnd_message.set_token('PAYROLL_DATE',l_distribution_date);
5080 fnd_msg_pub.add;
5081 p_return_status := fnd_api.g_ret_sts_unexp_error; --End of Modification for Bug 2056877.
5082
5083 WHEN OTHERS THEN
5084 g_error_api_path := 'GMS_TIE_BACK:'||g_error_api_path;
5085 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','GMS_TIE_BACK');
5086 p_return_status := fnd_api.g_ret_sts_unexp_error;
5087 END;
5088
5089 ------------------ INSERT INTO GMS INTERFACE -----------------------------------------------
5090
5091 PROCEDURE insert_into_pa_interface(
5092 P_TRANSACTION_INTERFACE_ID IN NUMBER,
5093 P_TRANSACTION_SOURCE IN VARCHAR2,
5094 P_BATCH_NAME IN VARCHAR2,
5095 P_EXPENDITURE_ENDING_DATE IN DATE,
5096 P_EMPLOYEE_NUMBER IN VARCHAR2,
5097 P_ORGANIZATION_NAME IN VARCHAR2,
5098 P_EXPENDITURE_ITEM_DATE IN DATE,
5099 P_PROJECT_NUMBER IN VARCHAR2,
5100 P_TASK_NUMBER IN VARCHAR2,
5101 P_EXPENDITURE_TYPE IN VARCHAR2,
5102 P_QUANTITY IN NUMBER,
5103 P_RAW_COST IN NUMBER,
5104 P_EXPENDITURE_COMMENT IN VARCHAR2,
5105 P_TRANSACTION_STATUS_CODE IN VARCHAR2,
5106 P_ORIG_TRANSACTION_REFERENCE IN VARCHAR2,
5107 P_ORG_ID IN NUMBER,
5108 P_DENOM_CURRENCY_CODE IN VARCHAR2,
5109 P_DENOM_RAW_COST IN NUMBER,
5110 P_ATTRIBUTE1 IN VARCHAR2,
5111 P_ATTRIBUTE2 IN VARCHAR2,
5112 P_ATTRIBUTE3 IN VARCHAR2,
5113 P_ATTRIBUTE4 IN VARCHAR2, -- Introduced attributes 4 and 5 for bug fix 2908859
5114 P_ATTRIBUTE5 IN VARCHAR2,
5115 P_ATTRIBUTE6 IN VARCHAR2,
5116 P_ATTRIBUTE7 IN VARCHAR2,
5117 P_ATTRIBUTE8 IN VARCHAR2,
5118 P_ATTRIBUTE9 IN VARCHAR2,
5119 P_ATTRIBUTE10 IN VARCHAR2,
5120 P_ACCT_RATE_TYPE IN VARCHAR2, -- Introduced for bug fix 2916848
5121 P_ACCT_RATE_DATE IN DATE, -- Introduced for bug fix 2916848
5122 P_PERSON_BUSINESS_GROUP_ID IN NUMBER, -- Introduced for bug 2935850
5123 P_RETURN_STATUS OUT NOCOPY VARCHAR2) IS
5124
5125 BEGIN
5126
5127 -- dbms_output.put_line('batch name='||p_batch_name);
5128
5129 INSERT INTO PA_TRANSACTION_INTERFACE_ALL(
5130 TXN_INTERFACE_ID,
5131 TRANSACTION_SOURCE,
5132 BATCH_NAME,
5133 EXPENDITURE_ENDING_DATE,
5134 EMPLOYEE_NUMBER,
5135 ORGANIZATION_NAME,
5136 EXPENDITURE_ITEM_DATE,
5137 PROJECT_NUMBER,
5138 TASK_NUMBER,
5139 EXPENDITURE_TYPE,
5140 QUANTITY,
5141 RAW_COST,
5142 EXPENDITURE_COMMENT,
5143 TRANSACTION_STATUS_CODE,
5144 ORIG_TRANSACTION_REFERENCE,
5145 ORG_ID,
5146 DENOM_CURRENCY_CODE,
5147 DENOM_RAW_COST,
5148 ATTRIBUTE1,
5149 ATTRIBUTE2,
5150 ATTRIBUTE3,
5151 ATTRIBUTE4, -- Introduced attributes 4 and 5 for bug fix 2908859
5152 ATTRIBUTE5,
5153 ATTRIBUTE6,
5154 ATTRIBUTE7,
5155 ATTRIBUTE8,
5156 ATTRIBUTE9,
5157 ATTRIBUTE10,
5158 PERSON_BUSINESS_GROUP_ID,
5159 -- Introduced the following columns for bug fix 2916848
5160 ACCT_RATE_TYPE,
5161 ACCT_RATE_DATE)
5162 VALUES(
5163 P_TRANSACTION_INTERFACE_ID,
5164 P_TRANSACTION_SOURCE,
5165 P_BATCH_NAME,
5166 P_EXPENDITURE_ENDING_DATE,
5167 P_EMPLOYEE_NUMBER,
5168 P_ORGANIZATION_NAME,
5169 P_EXPENDITURE_ITEM_DATE,
5170 P_PROJECT_NUMBER,
5171 P_TASK_NUMBER,
5172 P_EXPENDITURE_TYPE,
5173 P_QUANTITY,
5174 P_RAW_COST,
5175 P_EXPENDITURE_COMMENT,
5176 P_TRANSACTION_STATUS_CODE,
5177 P_ORIG_TRANSACTION_REFERENCE,
5178 P_ORG_ID,
5179 P_DENOM_CURRENCY_CODE,
5180 P_DENOM_RAW_COST,
5181 P_ATTRIBUTE1,
5182 P_ATTRIBUTE2,
5183 P_ATTRIBUTE3,
5184 P_ATTRIBUTE4, -- Introduced attributes 4 and 5 for bug fix 2908859
5185 P_ATTRIBUTE5,
5186 P_ATTRIBUTE6,
5187 P_ATTRIBUTE7,
5188 P_ATTRIBUTE8,
5189 P_ATTRIBUTE9,
5190 P_ATTRIBUTE10,
5191 P_PERSON_BUSINESS_GROUP_ID,
5192 -- Introduced the following columns for bug fix 2916848
5193 P_ACCT_RATE_TYPE,
5194 DECODE(p_acct_rate_type, NULL, NULL, P_ACCT_RATE_DATE));
5195
5196 p_return_status := fnd_api.g_ret_sts_success;
5197 EXCEPTION
5198
5199 WHEN OTHERS THEN
5200 -- dbms_output.put_line('Error while inserting .........................');
5201 g_error_api_path := 'INSERT_INTO_PA_INTERFACE:'||g_error_api_path;
5202 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','INSERT_INTO_PA_INTERFACE');
5203 p_return_status := fnd_api.g_ret_sts_unexp_error;
5204 END;
5205
5206 /* Created this procedure on 4-Nov-2004.
5207 Following procedure is introduced for Effort reports Enhancement.
5208 Purpose of this procedure: Supercede employee effort report(s) if this
5209 S_AND_T processes distributions for persons/time periods
5210 for which effort reports already exist.
5211
5212 There is no COMMIT statement in this procedure, it will be called
5213 from mark_batch_end, and the calling procedure will COMMIT the data.
5214
5215 The volume of ERs superceded is expected to be low, normally
5216 customer generates ER only when all transactions are imported,
5217 and hence employees superceded are low.
5218
5219 Logic:
5220 - get all the ER requests that can potentially be superceded,
5221 by comparing the time periods of this process with ER periods.
5222 - get all persons for this ER request, for whom this S_AND_T has
5223 distributions
5224 - if no tolerance is setup, then all emps processed by S_and_T
5225 are superceded.
5226 - If tolerance is set as zero, then supercede all those persons
5227 whose new ER changed w.r.t to old (compare old and Fresh ER)
5228 - If tolerance is non-zero, but specified as either % or
5229 absolute amount, then re-create ER, and compare. If
5230 difference exceeds tolerance then supercede
5231 */
5232 PROCEDURE SUPERCEDE_ER(p_run_id in integer,
5233 errbuf in out nocopy varchar2,
5234 retcode in out nocopy varchar2,
5235 p_source_type in varchar2,
5236 p_source_code in varchar2,
5237 p_time_period_id in integer,
5238 p_batch_name in varchar2,
5239 p_return_status out nocopy varchar2) is
5240
5241 l_supercede_reqid_str varchar2(9000); --Bug 6037692
5242 l_run_id integer;
5243 i integer;
5244 j integer;
5245 t_person_table t_num_15_type;
5246 t_efforts_table t_num_15_type;
5247 t_sum_line_id t_num_15_type;
5248 t_tolerance_per t_num_15_type;
5249 t_tolerance_req t_num_15_type;
5250 TYPE t_num_15_type_ind IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
5251 t_tolerance_sline t_num_15_type_ind;
5252 t_request_id t_num_15_type_ind;
5253 t_template_id t_num_15_type_ind;
5254 t_tolerance_erid t_num_15_type_ind;
5255 l_S_and_T_reqid integer;
5256 l_sql_string varchar2(12000); --Bug 6037692
5257 l_tolerance_amt number;
5258 l_tolerance_percent number;
5259 l_superceded_flag boolean := false ;
5260
5261 --- get all ER template runs, that overlapp S_AND_T time periods.
5262 cursor check_er_template_h is
5263 Select distinct pth.template_id,
5264 pth.request_id
5265 From psp_payroll_controls ppc,
5266 Psp_report_templates_h pth,
5267 Per_time_periods ptp
5268 Where ppc.run_id = p_run_id
5269 And ppc.time_period_id = ptp.time_period_id
5270 And fnd_date.canonical_to_date(fnd_date.date_to_canonical(pth.parameter_value_3)) >= ptp.start_date
5271 And fnd_date.canonical_to_date(fnd_date.date_to_canonical(pth.parameter_value_2)) <= ptp.end_date;
5272
5273 cursor supercede_tolerance(p_template_id in integer) is
5274 select nvl(sprcd_tolerance_amt,-999),
5275 nvl(sprcd_tolerance_percent,-999)
5276 from psp_report_templates
5277 where template_id = p_template_id;
5278
5279
5280
5281 cursor adj_er_supercede is
5282 Select per.effort_report_id,
5283 per.person_id,
5284 min(pal.summary_line_id) summary_line_id
5285 From psp_adjustment_lines_history pal,
5286 Psp_eff_reports per,
5287 Psp_payroll_controls ppc
5288 Where pal.distribution_date between per.start_date and per.end_date
5289 And per.request_id in ( select -person_id from psp_supercede_persons_gt where person_id < 0)
5290 And ppc.run_id = p_run_id
5291 And pal.person_id = per.person_id
5292 And ppc.payroll_control_id = pal.payroll_control_id
5293 And per.status_code not in ('S','R')
5294 And pal.element_type_id in
5295 ((select petr.element_type_id from pay_element_type_rules petr, psp_report_template_details_h prth where
5296 petr.include_or_exclude ='I' and
5297 prth.request_id =per.request_id and prth.criteria_lookup_code='EST' and
5298 petr.element_Set_id = prth.criteria_value1 )
5299 union all (select pet1.element_type_id from
5300 pay_element_types_f pet1, pay_ele_classification_rules pecr,
5301 psp_report_template_details_h prth1
5302 where pet1.classification_id = pecr.classification_id and
5303 prth1.criteria_lookup_code='EST' and prth1.request_id =per.request_id and
5304 pecr.element_Set_id = prth1.criteria_value1 ))
5305 And pal.element_type_id not in
5306 (select petr1.element_type_id from pay_element_type_rules petr1,
5307 psp_report_template_Details_h prth2
5308 where petr1.include_or_exclude='E'
5309 and prth2.request_id = per.request_id
5310 and prth2.criteria_lookup_code='EST' and prth2.criteria_value1= petr1.element_Set_id )
5311 group by per.person_id, per.effort_report_id;
5312
5313 cursor pregen_er_supercede is
5314 Select per.effort_report_id,
5315 per.person_id,
5316 min(pregen.summary_line_id)
5317 From psp_pre_gen_dist_lines_history pregen,
5318 Psp_eff_reports per,
5319 Psp_payroll_controls ppc
5320 Where pregen.distribution_date between per.start_date and per.end_date
5321 And per.request_id in (select -person_id from psp_supercede_persons_gt where person_id < 0)
5322 And ppc.run_id = p_run_id
5323 And pregen.person_id = per.person_id
5324 And ppc.payroll_control_id = pregen.payroll_control_id
5325 And per.status_code not in ('S','R')
5326 And pregen.element_type_id in
5327 ((select petr.element_type_id from pay_element_type_rules petr, psp_report_template_details_h prth where
5328 petr.include_or_exclude ='I' and
5329 prth.request_id =per.request_id and prth.criteria_lookup_code='EST' and
5330 petr.element_Set_id = prth.criteria_value1
5331 )
5332 union all
5333 (select pet1.element_type_id from
5334 pay_element_types_f pet1, pay_ele_classification_rules pecr,
5335 psp_report_template_details_h prth1
5336 where pet1.classification_id = pecr.classification_id and
5337 prth1.criteria_lookup_code='EST' and prth1.request_id =per.request_id and
5338 pecr.element_Set_id = prth1.criteria_value1
5339 ))
5340 And pregen.element_type_id not in
5341 (select petr1.element_type_id from pay_element_type_rules petr1,
5342 psp_report_template_Details_h prth2
5343 where petr1.include_or_exclude='E'
5344 and prth2.request_id = per.request_id
5345 and prth2.criteria_lookup_code='EST' and prth2.criteria_value1= petr1.element_Set_id
5346 )
5347 group by per.person_id,per.effort_report_id;
5348
5349 cursor payroll_er_supercede is
5350 Select per.effort_report_id,
5351 per.person_id,
5352 MIN(dlh.summary_line_id) summary_line_id
5353 From psp_eff_reports per,
5354 Psp_distribution_lines_history DLH,
5355 Psp_payroll_controls ppc,
5356 psp_payroll_sub_lines psub,
5357 psp_payroll_lines ppl
5358 Where dlh.payroll_sub_line_id = psub.payroll_sub_line_id
5359 And per.request_id in (select -person_id from psp_supercede_persons_gt where person_id < 0)
5360 And psub.payroll_line_id = ppl.payroll_line_id
5361 And ppl.person_id = per.person_id
5362 And dlh.distribution_date between per.start_date and per.end_date
5363 And ppc.run_id = p_run_id
5364 And ppc.payroll_control_id = ppl.payroll_control_id
5365 And per.status_code not in ('S','R')
5366 And ppl.element_type_id in
5367 ((select petr.element_type_id from pay_element_type_rules petr, psp_report_template_details_h prth where
5368 petr.include_or_exclude ='I' and
5369 prth.request_id =per.request_id and prth.criteria_lookup_code='EST' and
5370 petr.element_Set_id = prth.criteria_value1
5371 )
5372 union all
5373 (select pet1.element_type_id from
5374 pay_element_types_f pet1, pay_ele_classification_rules pecr,
5375 psp_report_template_details_h prth1
5376 where pet1.classification_id = pecr.classification_id and
5377 prth1.criteria_lookup_code='EST' and prth1.request_id =per.request_id and
5378 pecr.element_Set_id = prth1.criteria_value1
5379 ))
5380 And ppl.element_type_id not in
5381 (select petr1.element_type_id from pay_element_type_rules petr1,
5382 psp_report_template_Details_h prth2
5383 where petr1.include_or_exclude='E'
5384 and prth2.request_id = per.request_id
5385 and prth2.criteria_lookup_code='EST' and prth2.criteria_value1= petr1.element_Set_id
5386 )
5387 group by per.person_id,per.effort_report_id;
5388
5389 cursor all_er_supercede is
5390 select effort_report_id,
5391 person_id,
5392 min(summary_line_id) summary_line_id
5393 from (
5394 Select per.effort_report_id,
5395 per.person_id,
5396 dlh.summary_line_id summary_line_id
5397 From psp_eff_reports per,
5398 Psp_distribution_lines_history DLH,
5399 Psp_payroll_controls ppc,
5400 psp_payroll_sub_lines psub,
5401 psp_payroll_lines ppl
5402 Where dlh.payroll_sub_line_id = psub.payroll_sub_line_id
5403 And per.request_id in (select -person_id from psp_supercede_persons_gt)
5404 And psub.payroll_line_id = ppl.payroll_line_id
5405 And ppl.person_id = per.person_id
5406 And dlh.distribution_date between per.start_date and per.end_date
5407 And ppc.run_id = p_run_id
5408 And ppc.payroll_control_id = ppl.payroll_control_id
5409 And per.status_code not in ('S','R')
5410 And ppl.element_type_id in
5411 ((select petr.element_type_id from pay_element_type_rules petr, psp_report_template_details_h prth where
5412 petr.include_or_exclude ='I' and
5413 prth.request_id =per.request_id and prth.criteria_lookup_code='EST' and
5414 petr.element_Set_id = prth.criteria_value1
5415 )
5416 union all
5417 (select pet1.element_type_id from
5418 pay_element_types_f pet1, pay_ele_classification_rules pecr,
5419 psp_report_template_details_h prth1
5420 where pet1.classification_id = pecr.classification_id and
5421 prth1.criteria_lookup_code='EST' and prth1.request_id =per.request_id
5422 and pecr.element_Set_id = prth1.criteria_value1
5423 ))
5424 And ppl.element_type_id not in
5425 (select petr1.element_type_id from pay_element_type_rules petr1,
5426 psp_report_template_Details_h prth2
5427 where petr1.include_or_exclude='E'
5428 and prth2.request_id = per.request_id
5429 and prth2.criteria_lookup_code='EST' and prth2.criteria_value1= petr1.element_Set_id
5430 )
5431 UNION ALL
5432 Select per.effort_report_id,
5433 per.person_id,
5434 pregen.summary_line_id summary_line_id
5435 From psp_pre_gen_dist_lines_history pregen,
5436 Psp_eff_reports per,
5437 Psp_payroll_controls ppc
5438 Where pregen.distribution_date between per.start_date and per.end_date
5439 And per.request_id in ( select -person_id from psp_supercede_persons_gt )
5440 And ppc.run_id = p_run_id
5441 And pregen.person_id = per.person_id
5442 And ppc.payroll_control_id = pregen.payroll_control_id
5443 And per.status_code not in ('S','R')
5444 And pregen.element_type_id in
5445 ((select petr.element_type_id from pay_element_type_rules petr, psp_report_template_details_h prth where
5446 petr.include_or_exclude ='I' and
5447 prth.request_id =per.request_id and prth.criteria_lookup_code='EST'
5448 and petr.element_Set_id = prth.criteria_value1
5449 )
5450 union all
5451 (select pet1.element_type_id from
5452 pay_element_types_f pet1, pay_ele_classification_rules pecr,
5453 psp_report_template_details_h prth1
5454 where pet1.classification_id = pecr.classification_id and
5455 prth1.criteria_lookup_code='EST' and prth1.request_id =per.request_id
5456 and pecr.element_Set_id = prth1.criteria_value1
5457 ))
5458 And pregen.element_type_id not in
5459 (select petr1.element_type_id from pay_element_type_rules petr1,
5460 psp_report_template_Details_h prth2
5461 where petr1.include_or_exclude='E'
5462 and prth2.request_id = per.request_id
5463 and prth2.criteria_lookup_code='EST' and prth2.criteria_value1= petr1.element_Set_id
5464 ))
5465 group by person_id,effort_report_id;
5466
5467 --- included asg check for uva asg matching
5468 cursor adj_asg_er_supercede is
5469 Select per.effort_report_id,
5470 per.person_id,
5471 min(pal.summary_line_id) summary_line_id
5472 From psp_adjustment_lines_history pal,
5473 Psp_eff_reports per,
5474 Psp_payroll_controls ppc,
5475 psp_eff_report_details perd
5476 Where pal.distribution_date between per.start_date and per.end_date
5477 and perd.effort_report_id = per.effort_report_id
5478 and perd.assignment_id = pal.assignment_id
5479 And per.request_id in ( select -person_id from psp_supercede_persons_gt where person_id < 0)
5480 And ppc.run_id = p_run_id
5481 And pal.person_id = per.person_id
5482 And ppc.payroll_control_id = pal.payroll_control_id
5483 And per.status_code not in ('S','R')
5484 And pal.element_type_id in
5485 ((select petr.element_type_id from pay_element_type_rules petr, psp_report_template_details_h prth where
5486 petr.include_or_exclude ='I'
5487 and prth.request_id =per.request_id and prth.criteria_lookup_code='EST'
5488 and petr.element_Set_id = prth.criteria_value1 )
5489 union all (select pet1.element_type_id from
5490 pay_element_types_f pet1, pay_ele_classification_rules pecr,
5491 psp_report_template_details_h prth1
5492 where pet1.classification_id = pecr.classification_id
5493 and prth1.criteria_lookup_code='EST' and prth1.request_id =per.request_id
5494 and pecr.element_Set_id = prth1.criteria_value1 ))
5495 And pal.element_type_id not in
5496 (select petr1.element_type_id from pay_element_type_rules petr1,
5497 psp_report_template_Details_h prth2
5498 where petr1.include_or_exclude='E'
5499 and prth2.request_id = per.request_id
5500 and prth2.criteria_lookup_code='EST' and prth2.criteria_value1= petr1.element_Set_id )
5501 group by per.person_id, per.effort_report_id;
5502
5503 cursor pregen_asg_er_supercede is
5504 Select per.effort_report_id,
5505 per.person_id,
5506 min(pregen.summary_line_id)
5507 From psp_pre_gen_dist_lines_history pregen,
5508 Psp_eff_reports per,
5509 Psp_payroll_controls ppc,
5510 psp_eff_report_details perd
5511 Where pregen.distribution_date between per.start_date and per.end_date
5512 and perd.effort_report_id = per.effort_report_id
5513 and perd.assignment_id = pregen.assignment_id
5514 And per.request_id in (select -person_id from psp_supercede_persons_gt where person_id < 0)
5515 And ppc.run_id = p_run_id
5516 And pregen.person_id = per.person_id
5517 And ppc.payroll_control_id = pregen.payroll_control_id
5518 And per.status_code not in ('S','R')
5519 And pregen.element_type_id in
5520 ((select petr.element_type_id from pay_element_type_rules petr, psp_report_template_details_h prth where
5521 petr.include_or_exclude ='I' and
5522 prth.request_id =per.request_id and prth.criteria_lookup_code='EST'
5523 and petr.element_Set_id = prth.criteria_value1
5524 )
5525 union all
5526 (select pet1.element_type_id from
5527 pay_element_types_f pet1, pay_ele_classification_rules pecr,
5528 psp_report_template_details_h prth1
5529 where pet1.classification_id = pecr.classification_id and
5530 prth1.criteria_lookup_code='EST' and prth1.request_id =per.request_id
5531 and pecr.element_Set_id = prth1.criteria_value1
5532 ))
5533 And pregen.element_type_id not in
5534 (select petr1.element_type_id from pay_element_type_rules petr1,
5535 psp_report_template_Details_h prth2
5536 where petr1.include_or_exclude='E'
5537 and prth2.request_id = per.request_id
5538 and prth2.criteria_lookup_code='EST' and prth2.criteria_value1= petr1.element_Set_id
5539 )
5540 group by per.person_id,per.effort_report_id;
5541
5542 cursor payroll_asg_er_supercede is
5543 Select per.effort_report_id,
5544 per.person_id,
5545 MIN(dlh.summary_line_id) summary_line_id
5546 From psp_eff_reports per,
5547 Psp_distribution_lines_history DLH,
5548 Psp_payroll_controls ppc,
5549 psp_payroll_sub_lines psub,
5550 psp_payroll_lines ppl,
5551 psp_eff_report_details perd
5552 Where dlh.payroll_sub_line_id = psub.payroll_sub_line_id
5553 and perd.effort_report_id = per.effort_report_id
5554 and perd.assignment_id = ppl.assignment_id
5555 And per.request_id in (select -person_id from psp_supercede_persons_gt where person_id < 0)
5556 And psub.payroll_line_id = ppl.payroll_line_id
5557 And ppl.person_id = per.person_id
5558 And dlh.distribution_date between per.start_date and per.end_date
5559 And ppc.run_id = p_run_id
5560 And ppc.payroll_control_id = ppl.payroll_control_id
5561 And per.status_code not in ('S','R')
5562 And ppl.element_type_id in
5563 ((select petr.element_type_id from pay_element_type_rules petr, psp_report_template_details_h prth where
5564 petr.include_or_exclude ='I'
5565 and prth.request_id =per.request_id and prth.criteria_lookup_code='EST'
5566 and petr.element_Set_id = prth.criteria_value1
5567 )
5568 union all
5569 (select pet1.element_type_id from
5570 pay_element_types_f pet1, pay_ele_classification_rules pecr,
5571 psp_report_template_details_h prth1
5572 where pet1.classification_id = pecr.classification_id and
5573 prth1.criteria_lookup_code='EST' and prth1.request_id =per.request_id
5574 and pecr.element_Set_id = prth1.criteria_value1
5575 ))
5576 And ppl.element_type_id not in
5577 (select petr1.element_type_id from pay_element_type_rules petr1,
5578 psp_report_template_Details_h prth2
5579 where petr1.include_or_exclude='E'
5580 and prth2.request_id = per.request_id
5581 and prth2.criteria_lookup_code='EST' and prth2.criteria_value1= petr1.element_Set_id
5582 )
5583 group by per.person_id,per.effort_report_id;
5584
5585
5586 cursor all_asg_er_supercede is
5587 select effort_report_id,
5588 person_id,
5589 min(summary_line_id) summary_line_id
5590 from (
5591 Select per.effort_report_id,
5592 per.person_id,
5593 dlh.summary_line_id summary_line_id
5594 From psp_eff_reports per,
5595 Psp_distribution_lines_history DLH,
5596 Psp_payroll_controls ppc,
5597 psp_payroll_sub_lines psub,
5598 psp_payroll_lines ppl,
5599 psp_eff_report_details perd
5600 Where dlh.payroll_sub_line_id = psub.payroll_sub_line_id
5601 and perd.effort_report_id = per.effort_report_id
5602 and perd.assignment_id = ppl.assignment_id
5603 And per.request_id in (select -person_id from psp_supercede_persons_gt)
5604 And psub.payroll_line_id = ppl.payroll_line_id
5605 And ppl.person_id = per.person_id
5606 And dlh.distribution_date between per.start_date and per.end_date
5607 And ppc.run_id = p_run_id
5608 And ppc.payroll_control_id = ppl.payroll_control_id
5609 And per.status_code not in ('S','R')
5610 And ppl.element_type_id in
5611 ((select petr.element_type_id from pay_element_type_rules petr, psp_report_template_details_h prth where
5612 petr.include_or_exclude ='I' and
5613 prth.request_id =per.request_id and prth.criteria_lookup_code='EST'
5614 and petr.element_Set_id = prth.criteria_value1
5615 )
5616 union all
5617 (select pet1.element_type_id from
5618 pay_element_types_f pet1, pay_ele_classification_rules pecr,
5619 psp_report_template_details_h prth1
5620 where pet1.classification_id = pecr.classification_id
5621 and prth1.criteria_lookup_code='EST' and prth1.request_id =per.request_id
5622 and pecr.element_Set_id = prth1.criteria_value1
5623 ))
5624 And ppl.element_type_id not in
5625 (select petr1.element_type_id from pay_element_type_rules petr1,
5626 psp_report_template_Details_h prth2
5627 where petr1.include_or_exclude='E'
5628 and prth2.request_id = per.request_id
5629 and prth2.criteria_lookup_code='EST' and prth2.criteria_value1= petr1.element_Set_id
5630 )
5631 UNION ALL
5632 Select per.effort_report_id,
5633 per.person_id,
5634 pregen.summary_line_id summary_line_id
5635 From psp_pre_gen_dist_lines_history pregen,
5636 Psp_eff_reports per,
5637 Psp_payroll_controls ppc,
5638 psp_eff_report_details perd
5639 Where pregen.distribution_date between per.start_date and per.end_date
5640 and perd.effort_report_id = per.effort_report_id
5641 and perd.assignment_id = pregen.assignment_id
5642 And per.request_id in ( select -person_id from psp_supercede_persons_gt )
5643 And ppc.run_id = p_run_id
5644 And pregen.person_id = per.person_id
5645 And ppc.payroll_control_id = pregen.payroll_control_id
5646 And per.status_code not in ('S','R')
5647 And pregen.element_type_id in
5648 ((select petr.element_type_id from pay_element_type_rules petr, psp_report_template_details_h prth where
5649 petr.include_or_exclude ='I'
5650 and prth.request_id =per.request_id and prth.criteria_lookup_code='EST'
5651 and petr.element_Set_id = prth.criteria_value1
5652 )
5653 union all
5654 (select pet1.element_type_id from
5655 pay_element_types_f pet1, pay_ele_classification_rules pecr,
5656 psp_report_template_details_h prth1
5657 where pet1.classification_id = pecr.classification_id
5658 and prth1.criteria_lookup_code='EST' and prth1.request_id =per.request_id
5659 and pecr.element_Set_id = prth1.criteria_value1
5660 ))
5661 And pregen.element_type_id not in
5662 (select petr1.element_type_id from pay_element_type_rules petr1,
5663 psp_report_template_Details_h prth2
5664 where petr1.include_or_exclude='E'
5665 and prth2.request_id = per.request_id
5666 and prth2.criteria_lookup_code='EST' and prth2.criteria_value1= petr1.element_Set_id
5667 ))
5668 group by person_id,effort_report_id;
5669 cursor check_emp_overlap is
5670 select count(*)
5671 from psp_Eff_reports per,
5672 psp_summary_lines psl
5673 where per.person_id = psl.person_id
5674 and psl.payroll_control_id in
5675 (select payroll_control_id
5676 from psp_payroll_controls
5677 where run_id = p_run_id)
5678 and rownum = 1
5679 and per.request_id in
5680 (select abs(person_id)
5681 from psp_supercede_persons_gt
5682 where person_id < 0);
5683 l_emp_overlap_count integer;
5684
5685 -- uva isue, supercede for matching asg option
5686 cursor check_emp_match_option is
5687 select count(*)
5688 from psp_report_templates_h
5689 where request_id in ( select -person_id from psp_supercede_persons_gt )
5690 and selection_match_level = 'EMP';
5691
5692 l_count_emp_match integer;
5693
5694 cursor get_eff_id(p_req_id in integer, p_per_id in integer) is
5695 select effort_report_id
5696 from psp_eff_reports
5697 where request_id = p_req_id and person_id = p_per_id;
5698 l_eff_id integer;
5699
5700 l_proj_segment varchar2(30);
5701 l_tsk_segment varchar2(30);
5702 l_awd_sgement varchar2(30);
5703 l_exp_org_segment varchar2(30);
5704 l_exp_type_segment varchar2(30);
5705 l_profile_bg_id Number := FND_PROFILE.VALUE('PER_BUSINESS_GROUP_ID');
5706
5707 CURSOR get_Con_Program_name_csr IS
5708 SELECT USER_CONCURRENT_PROGRAM_NAME
5709 FROM fnd_concurrent_programs_vl fcp
5710 WHERE CONCURRENT_PROGRAM_ID = fnd_global.CONC_PROGRAM_ID;
5711 l_Con_Program_name varchar2(240);
5712
5713
5714 PROCEDURE SEND_NOTIFICATIONS(p_supercede_reqid_str in varchar2,
5715 p_template_id in integer,
5716 p_SandT_reqid in integer,
5717 p_batch_name in varchar2,
5718 p_source_type in varchar2,
5719 p_source_code in varchar2,
5720 p_time_period_id in varchar2) is
5721
5722
5723 l_role_display varchar2(500);
5724 l_member_rname varchar2(500);
5725 l_approver_notify boolean;
5726 l_employee_notify boolean;
5727 l_init_notify boolean;
5728 l_frp_notify boolean;
5729 t_wf_roles t_varchar2_400_type;
5730 t_person_id t_num_15_type;
5731 l_template_name varchar2(240);
5732 l_distribution_source varchar2(260);
5733 l_time_period_name varchar2(100);
5734
5735 cursor get_template_name is
5736 select template_name
5737 from psp_report_templates
5738 where template_id = p_template_id;
5739
5740 cursor get_superceding_source is
5741 select description
5742 from psp_payroll_sources
5743 where source_type = p_source_type
5744 and source_code = p_source_code;
5745
5746 cursor get_time_period_name is
5747 select period_name
5748 from per_time_periods
5749 where time_period_id = p_time_period_id;
5750
5751 cursor get_frp_wf_names is
5752 select distinct wf.name,
5753 wf.orig_system_id
5754 from wf_roles wf,
5755 psp_report_templates_h h,
5756 psp_report_template_details_h dtl
5757 where wf.orig_system = 'PER'
5758 and to_char(wf.orig_system_id) = dtl.criteria_value1
5759 and dtl.criteria_lookup_type = 'PSP_SELECTION_CRITERIA'
5760 and dtl.criteria_lookup_code = 'FRP'
5761 and dtl.request_id = h.request_id
5762 and h.request_id in ( select -person_id
5763 from psp_supercede_persons_gt
5764 where person_id < 0)
5765 and h.final_recip_notified_flag = 'Y';
5766
5767 cursor get_init_wf_names is
5768 select distinct wf.name,
5769 wf.orig_system_id
5770 from wf_roles wf,
5771 psp_report_templates_h h
5772 where wf.orig_system = 'PER'
5773 and wf.orig_system_id = h.initiator_person_id
5774 and h.request_id in ( select -person_id
5775 from psp_supercede_persons_gt
5776 where person_id < 0)
5777 and exists (select 1 from psp_eff_reports per
5778 where per.request_id = h.request_id
5779 and per.superceding_request_id = p_SandT_reqid);
5780
5781 cursor get_per_wf_names is
5782 select distinct wf.name,
5783 er.person_id
5784 from wf_roles wf,
5785 psp_eff_reports er,
5786 psp_report_templates_h h
5787 where wf.orig_system = 'PER'
5788 and wf.orig_system_id = er.person_id
5789 and h.request_id = er.request_id
5790 and h.initiator_accept_flag = 'Y'
5791 and er.request_id in ( select -person_id
5792 from psp_supercede_persons_gt
5793 where person_id < 0)
5794 and er.superceding_request_id = p_SandT_reqid;
5795
5796 cursor get_app_wf_names is
5797 select distinct era.wf_role_name
5798 from psp_eff_report_approvals era,
5799 psp_eff_report_details erd,
5800 psp_eff_reports er,
5801 psp_report_templates_h h
5802 where erd.effort_report_detail_id = era.effort_report_detail_id
5803 and erd.effort_report_id = er.effort_report_id
5804 and er.request_id in ( select -person_id from psp_supercede_persons_gt where person_id < 0 )
5805 and er.superceding_request_id = p_SandT_reqid
5806 and era.approval_status <> 'R'
5807 and er.request_id = h.request_id
5808 and h.initiator_accept_flag = 'Y';
5809
5810 PROCEDURE GET_RECEIVER_TYPES(p_template_id in integer,
5811 p_initiator_notify out nocopy boolean,
5812 p_final_recip_notify out nocopy boolean,
5813 p_approver_notify out nocopy boolean,
5814 p_employee_notify out nocopy boolean) is
5815 cursor get_notify_types is
5816 select criteria_lookup_code
5817 from psp_report_template_details
5818 where template_id = p_template_id
5819 and criteria_lookup_type = 'PSP_SUPERCEDED_NOTIFICATION';
5820
5821 notify_type varchar2(10);
5822
5823 BEGIN
5824 p_approver_notify := false;
5825 p_initiator_notify := false;
5826 p_final_recip_notify := false;
5827 p_employee_notify := false;
5828 open get_notify_types;
5829 loop
5830 fetch get_notify_types into notify_type;
5831 if get_notify_types%notfound then
5832 if get_notify_types%rowcount = 0 then
5833 close get_notify_types;
5834 hr_utility.trace( 'SandT_Supercede--> GET_RECIVER_TYPES--> Superceded notifier types not found');
5835 return;
5836 end if;
5837 close get_notify_types;
5838 exit;
5839 end if;
5840 if notify_type = 'A' then
5841 p_approver_notify := true;
5842 hr_utility.trace( 'SandT_Supercede--> GET_RECIVER_TYPES--> p_apporver_notify');
5843 elsif notify_type = 'I' then
5844 p_initiator_notify := true;
5845 hr_utility.trace( 'SandT_Supercede--> GET_RECIVER_TYPES--> initiator_notify');
5846 elsif notify_type = 'F' then
5847 p_final_recip_notify := true;
5848 hr_utility.trace( 'SandT_Supercede--> GET_RECIVER_TYPES--> final_recip_notify');
5849 elsif notify_type = 'E' then
5850 p_employee_notify := true;
5851 hr_utility.trace( 'SandT_Supercede--> GET_RECIVER_TYPES--> p_employee_notify');
5852 end if;
5853 end loop;
5854
5855 EXCEPTION
5856 when others then
5857
5858 hr_utility.trace( 'SandT_Supercede-->send notifications --> GET_RECEIVER_TYPES when others '||sqlerrm);
5859 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','GET_RECEIVER_TYPES');
5860 raise;
5861 END GET_RECEIVER_TYPES;
5862
5863 PROCEDURE CALL_WF(p_supercede_reqid_str in varchar2,
5864 p_wf_user in varchar2,
5865 p_SandT_reqid in integer,
5866 p_person_id in integer,
5867 p_approver_type in varchar2,
5868 p_template_name in varchar2,
5869 p_batch_name in varchar2,
5870 p_superceding_source in varchar2,
5871 p_time_period_name in varchar2,
5872 p_source_type in varchar2,
5873 p_source_code in varchar2,
5874 p_time_period_id in varchar2) is
5875
5876 l_wf_itemkey integer;
5877 l_superceding_process varchar2(200);
5878 l_superceding_proc_param varchar2(500);
5879
5880 BEGIN
5881
5882 hr_utility.trace('SandT_Supercede--> send_notifications --> call_wf Parameters: p_supercede_reqid_str = '||
5883 p_supercede_reqid_str||', p_wf_user ='|| p_wf_user||', p_SandT_reqid='||
5884 p_SandT_reqid||
5885 ', p_person_id='||p_person_id||', p_approver_type = '||p_approver_type||
5886 ', p_source_type='|| p_source_type ||', p_source_code='|| p_source_code||
5887 ', p_time_period_id='||p_time_period_id);
5888
5889 select psp_wf_item_key_s.nextval
5890 into l_wf_itemkey
5891 from dual;
5892
5893 if p_source_type = 'A' then
5894 l_superceding_process := 'PSP: Summarize And Transfer Adjustments';
5895 l_superceding_proc_param := p_batch_name;
5896 else
5897 l_superceding_process := 'PSP: Summarize And Transfer Payroll Distributions';
5898 l_superceding_proc_param := p_source_type||', '||p_source_code||', '||
5899 g_payroll_id||', '||p_time_period_id||', '||p_batch_name;
5900 end if;
5901
5902 wf_engine.CreateProcess(itemtype => 'PSPERAVL',
5903 itemkey => l_wf_itemkey,
5904 process => 'SUPERCEDE_PROCESS');
5905
5906
5907 /*Added for bug 7004679 */
5908 wf_engine.setitemowner(itemtype => 'PSPERAVL',
5909 itemkey => l_wf_itemkey,
5910 owner => p_wf_user);
5911
5912
5913
5914 wf_engine.SetItemAttrText(itemtype => 'PSPERAVL',
5915 itemkey => l_wf_itemkey,
5916 aname => 'SUPERCEDING_PROC_NAME',
5917 avalue => l_superceding_process);
5918
5919 wf_engine.SetItemAttrText(itemtype => 'PSPERAVL',
5920 itemkey => l_wf_itemkey,
5921 aname => 'SUPERCEDING_PAYROLL_SOURCE',
5922 avalue => p_source_type);
5923
5924 wf_engine.SetItemAttrText(itemtype => 'PSPERAVL',
5925 itemkey => l_wf_itemkey,
5926 aname => 'SUPERCEDING_PROC_PARAM',
5927 avalue => l_superceding_proc_param);
5928
5929 wf_engine.SetItemAttrText(itemtype => 'PSPERAVL',
5930 itemkey => l_wf_itemkey,
5931 aname => 'SUPERCEDED_ER_REQ_ID_STR',
5932 avalue => p_supercede_reqid_str);
5933
5934 wf_engine.SetItemAttrNumber(itemtype => 'PSPERAVL',
5935 itemkey => l_wf_itemkey,
5936 aname => 'SUPERCEDING_S_AND_T_REQID',
5937 avalue => p_SandT_reqid);
5938
5939 wf_engine.SetItemAttrText(itemtype => 'PSPERAVL',
5940 itemkey => l_wf_itemkey,
5941 aname => 'SUPERCEDE_RECIPIENT_TYPE',
5942 avalue => p_approver_type); --- initiatior, final recipients,
5943 ---- employee, past approvers
5944 wf_engine.SetItemAttrText(itemType => 'PSPERAVL',
5945 itemkey => l_wf_itemkey,
5946 aname => 'TEMPLATE_NAME',
5947 avalue => l_template_name);
5948
5949 wf_engine.SetItemAttrNumber(itemtype => 'PSPERAVL',
5950 itemkey => l_wf_itemkey,
5951 aname => 'PERSON_ID',
5952 avalue => p_person_id);
5953
5954 wf_engine.SetItemAttrText(itemtype => 'PSPERAVL',
5955 itemkey => l_wf_itemkey,
5956 aname => 'APPROVER_ROLE_NAME',
5957 avalue => p_wf_user);
5958
5959 wf_engine.StartProcess(itemtype => 'PSPERAVL',
5960 itemkey => l_wf_itemkey);
5961 EXCEPTION
5962 when others then
5963 hr_utility.trace( 'SandT_Supercede-->send notifications --> call_wf when others '||sqlerrm);
5964 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','CALL_WF');
5965 raise;
5966 END CALL_WF;
5967
5968
5969 BEGIN -- send notifications
5970 hr_utility.trace( 'SandT_Supercede--> send_notifications--> Begin params : p_supercede_reqid_str= '||
5971 p_supercede_reqid_str ||', p_template_id = '||p_template_id ||
5972 ', p_SandT_reqid = '||p_SandT_reqid ||
5973 ', p_batch_name = '||p_batch_name ||
5974 ', p_source_type = '||p_source_type ||
5975 ', p_source_code = '|| p_source_code ||
5976 ', p_time_period_id = '|| p_time_period_id );
5977 hr_utility.trace( 'SandT_Supercede--> send_notifications-->get_receiver_types');
5978 get_receiver_types(p_template_id,
5979 l_init_notify,
5980 l_frp_notify,
5981 l_approver_notify,
5982 l_employee_notify);
5983
5984 open get_template_name;
5985 fetch get_template_name into l_template_name;
5986 close get_template_name;
5987
5988 open get_superceding_source;
5989 fetch get_superceding_source into l_distribution_source;
5990 close get_superceding_source;
5991
5992 if l_init_notify then
5993 open get_init_wf_names;
5994 fetch get_init_wf_names bulk collect into t_wf_roles, t_person_id;
5995 close get_init_wf_names;
5996
5997 for i in 1..t_wf_roles.count
5998 loop
5999 CALL_WF(p_supercede_reqid_str,
6000 t_wf_roles(i),
6001 p_SandT_reqid,
6002 t_person_id(i),
6003 'INIT',
6004 l_template_name,
6005 p_batch_name,
6006 l_distribution_source,
6007 l_time_period_name,
6008 p_source_type,
6009 p_source_code,
6010 p_time_period_id);
6011 end loop;
6012 end if;
6013
6014 if l_frp_notify then
6015 open get_frp_wf_names;
6016 fetch get_frp_wf_names bulk collect into t_wf_roles, t_person_id;
6017 close get_frp_wf_names;
6018
6019 for i in 1..t_wf_roles.count
6020 loop
6021 CALL_WF(p_supercede_reqid_str,
6022 t_wf_roles(i),
6023 p_SandT_reqid,
6024 t_person_id(i),
6025 'FRP',
6026 l_template_name,
6027 p_batch_name,
6028 l_distribution_source,
6029 l_time_period_name,
6030 p_source_type,
6031 p_source_code,
6032 p_time_period_id);
6033 end loop;
6034 end if;
6035
6036
6037 if l_employee_notify then
6038 open get_per_wf_names;
6039 fetch get_per_wf_names bulk collect into t_wf_roles, t_person_id;
6040 close get_per_wf_names;
6041
6042 for i in 1..t_wf_roles.count
6043 loop
6044 CALL_WF(p_supercede_reqid_str,
6045 t_wf_roles(i),
6046 p_SandT_reqid,
6047 t_person_id(i),
6048 'EMP',
6049 l_template_name,
6050 p_batch_name,
6051 l_distribution_source,
6052 l_time_period_name,
6053 p_source_type,
6054 p_source_code,
6055 p_time_period_id);
6056 end loop;
6057 end if;
6058
6059 hr_utility.trace( 'SandT_Supercede-->send_notifications--> has dynamic part for approver start');
6060 if l_approver_notify then
6061 open get_app_wf_names;
6062 fetch get_app_wf_names bulk collect into t_wf_roles;
6063 close get_app_wf_names;
6064 for i in 1..t_wf_roles.count
6065 loop
6066 CALL_WF(p_supercede_reqid_str,
6067 t_wf_roles(i),
6068 p_SandT_reqid,
6069 null,
6070 'APP',
6071 l_template_name,
6072 p_batch_name,
6073 l_distribution_source,
6074 l_time_period_name,
6075 p_source_type,
6076 p_source_code,
6077 p_time_period_id);
6078 end loop;
6079 end if;
6080 EXCEPTION
6081 when others then
6082 hr_utility.trace( 'SandT_Supercede-->send notifications when others '||sqlerrm);
6083 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS','SEND_NOTIFICATIONS');
6084 raise;
6085 END SEND_NOTIFICATIONS;
6086 BEGIN ----SUPERCEDE_ER
6087 --- comment trace.. debug
6088 ---hr_utility.trace_on('Y','ZX');
6089 hr_utility.trace( 'SandT_Supercede--> Begin p_run_id='||p_run_id);
6090 fnd_signon.set_session(to_char(sysdate,'dd-mon-yyyy'));
6091 p_return_status := fnd_api.g_ret_sts_success;
6092 l_S_and_T_reqid := fnd_global.conc_request_id;
6093 fnd_stats.gather_table_stats(ownname => 'PSP',
6094 tabname => 'PSP_SUPERCEDE_PERSONS_GT');
6095 open check_er_template_h;
6096 fetch check_er_template_h bulk collect into t_template_id, t_request_id;
6097 close check_er_template_h;
6098
6099 if t_template_id.count = 0 then
6100 return; --- no template found to supercede
6101 end if;
6102
6103 hr_utility.trace( 'SandT_Supercede--> template_id.count='||t_template_id.count);
6104
6105 l_supercede_reqid_str := null;
6106
6107 delete psp_supercede_persons_gt;
6108 for k in 1..t_template_id.count
6109 loop
6110 if t_template_id.count = k or --- supercede for distinct template
6111 (t_template_id.count > k and t_template_id(k) <> t_template_id(k+1)) then
6112 if l_supercede_reqid_str is null then
6113 l_supercede_reqid_str := t_request_id(k);
6114 else
6115 l_supercede_reqid_str := l_supercede_reqid_str ||', '|| t_request_id(k);
6116 end if;
6117 insert into psp_supercede_persons_gt
6118 (person_id)
6119 values ( -t_request_id(k));
6120
6121 open check_emp_overlap;
6122 fetch check_emp_overlap into l_emp_overlap_count;
6123 close check_emp_overlap;
6124 ---fnd_file.put_line(fnd_file.log,'before emp count');
6125 if l_emp_overlap_count > 0 then
6126
6127 open check_emp_match_option;
6128 fetch check_emp_match_option into l_count_emp_match;
6129 close check_emp_match_option;
6130 ---fnd_file.put_line(fnd_file.log,'l_count_emp_match = '||l_count_emp_match);
6131 hr_utility.trace( 'SandT_Supercede--> Main Loop Entered');
6132 hr_utility.trace( 'SandT_Supercede--> reqid string, p_source_type, template_id ='||
6133 l_supercede_reqid_str||':'||p_source_type||':'||t_template_id(k));
6134 if l_count_emp_match > 0 then
6135 if p_source_type = 'A' then --- from adjustments s_and_t process.
6136 open adj_er_supercede;
6137 fetch adj_er_supercede bulk collect into t_efforts_table, t_person_table, t_sum_line_id;
6138 close adj_er_Supercede;
6139 elsif p_source_type = 'P' then
6140 open pregen_er_supercede;
6141 fetch pregen_er_supercede bulk collect into t_efforts_table, t_person_table, t_sum_line_id;
6142 close pregen_er_Supercede;
6143 elsif p_source_type in ('N','O') then -- Introduced MIN() for bug fix 4024794
6144 open payroll_er_supercede;
6145 fetch payroll_er_supercede bulk collect into t_efforts_table, t_person_table, t_sum_line_id;
6146 close payroll_er_Supercede;
6147 else
6148 open all_er_supercede;
6149 fetch all_er_supercede bulk collect into t_efforts_table, t_person_table, t_sum_line_id;
6150 close all_er_Supercede;
6151 end if; --- source type adjustments
6152 else
6153 if p_source_type = 'A' then --- from adjustments s_and_t process.
6154 open adj_asg_er_supercede;
6155 fetch adj_asg_er_supercede bulk collect into t_efforts_table, t_person_table, t_sum_line_id;
6156 close adj_asg_er_Supercede;
6157 elsif p_source_type = 'P' then
6158 open pregen_asg_er_supercede;
6159 fetch pregen_asg_er_supercede bulk collect into t_efforts_table, t_person_table, t_sum_line_id;
6160 close pregen_asg_er_Supercede;
6161 elsif p_source_type in ('N','O') then
6162 open payroll_asg_er_supercede;
6163 fetch payroll_asg_er_supercede bulk collect into t_efforts_table, t_person_table, t_sum_line_id;
6164 close payroll_asg_er_Supercede;
6165 ---fnd_file.put_line(fnd_file.log,'t_efforts_table '||t_efforts_table.count);
6166 else
6167 open all_asg_er_supercede;
6168 fetch all_asg_er_supercede bulk collect into t_efforts_table, t_person_table, t_sum_line_id;
6169 close all_asg_er_Supercede;
6170 end if; --- source type adjustments
6171 end if;
6172 hr_utility.trace( 'SandT_Supercede--> loaded the superceded persons, count ='|| t_efforts_table.count);
6173 --fnd_file.put_line(fnd_file.log, 'SandT_Supercede--> loaded the superceded persons, count ='|| t_efforts_table.count);
6174 open supercede_tolerance(t_template_id(k));
6175 fetch supercede_tolerance into l_tolerance_amt, l_tolerance_percent;
6176 close supercede_tolerance;
6177 hr_utility.trace( 'SandT_Supercede--> get_tolerance limits AMT, %'||
6178 nvl(l_tolerance_amt,0)||','|| nvl(l_tolerance_percent,0));
6179
6180 if t_efforts_table.count > 0 then
6181 hr_utility.trace( 'SandT_Supercede--> t_efforts_table.count > 0');
6182 if l_tolerance_amt = -999 and l_tolerance_percent = -999 then
6183 --- if tolerance is not setup then all emps are superceded
6184 --- Summarize/Transfer run will be superceeded.
6185
6186 hr_utility.trace( 'SandT_Supercede--> Before update Eff table 1');
6187 i := 1;
6188 loop
6189 if i > t_efforts_table.count then
6190 exit;
6191 end if;
6192 hr_utility.trace( 'SandT_Supercede--> Effort report id ='||t_efforts_table(i));
6193
6194 OPEN get_Con_Program_name_csr;
6195 FETCH get_Con_Program_name_csr into l_Con_Program_name;
6196 CLOSE get_Con_Program_name_csr;
6197
6198 --Bug 4339561
6199 -- Pupulating Column superceding_program_name
6200 update psp_eff_reports
6201 set status_code = 'S',
6202 superceding_summary_line_id = t_sum_line_id(i),
6203 superceding_request_id = l_S_and_T_reqid,
6204 superceding_program_name = l_Con_Program_name
6205 where effort_report_id = t_efforts_table(i);
6206
6207 if sql%rowcount > 0 then
6208 l_superceded_flag := true;
6209 end if;
6210 hr_utility.trace( 'SandT_Supercede--> Updated the ER table, to put S');
6211 i := i + 1;
6212 end loop;
6213 else -- tolerance set to non null value
6214 --- load session temp table
6215 hr_utility.trace( 'SandT_Supercede--> purge GT table - 1');
6216 forall i in 1..t_person_table.count
6217 insert into psp_supercede_persons_gt
6218 (person_id)
6219 values (t_person_table(i));
6220 hr_utility.trace( 'SandT_Supercede--> insert into GT potential persons Number of recodrs=' ||t_person_table.count||'person_id =' ||t_person_table(1));
6221 savepoint populate_er_tables;
6222
6223 -- create fresh ER for comparison
6224 hr_utility.trace( 'SandT_Supercede--> before call to psp_create_eff_reports.populate_eff_tables');
6225 for n in 1..t_template_id.count
6226 loop
6227 if t_template_id(n) = t_template_id(k) then
6228 hr_utility.trace('SandT_Supercede--> call CREATE_EFF params : superced_request='||
6229 t_request_id(n)||' , template_id = '||t_template_id(n));
6230 psp_create_eff_reports.populate_eff_tables(errBuf ,
6231 retCode,
6232 null,
6233 t_request_id(n),
6234 null,
6235 'Y');
6236 hr_utility.trace('SandT_Supercede--> g_summarization_criteria = '|| PSP_CREATE_EFF_REPORTS.g_summarization_criteria);
6237
6238 end if;
6239 end loop;
6240 hr_utility.trace( 'SandT_Supercede--> after call to psp_create_eff_reports.populate_eff_tables');
6241
6242 if l_tolerance_amt <> -999 then --- tolerance_amt is not null then
6243 l_sql_string := ' begin
6244 select distinct er.request_id, er.person_id
6245 bulk collect into :reqtable, :pertable
6246 from psp_eff_report_details erd,
6247 psp_supercede_persons_gt gt,
6248 psp_eff_reports er
6249 where er.status_code not in
6250 ('||''''||'S'||''''||','||''''||'R'||''''||')
6251 and er.request_id in ('||l_supercede_reqid_str||')
6252 and er.effort_report_id = erd.effort_report_id
6253 and gt.person_id = er.person_id
6254 group by er.request_id, er.person_id '|| PSP_CREATE_EFF_REPORTS.g_summarization_criteria ||
6255 ' having abs(sum(decode(er.status_code,'||''''|| 'T'||''''||',
6256 -erd.actual_salary_amt,
6257 erd.actual_salary_amt))) > :l_tolerance_amt;
6258 end;';
6259
6260 --Bug 4319874 START
6261 -- Replacing the Dynamic Sql based on Configuration value
6262 IF PSP_GENERAL.GET_CONFIGURATION_OPTION_VALUE(l_profile_bg_id,'PSP_USE_GL_PTAOE_MAPPING') = 'Y' THEN
6263 PSP_GENERAL.GET_GL_PTAOE_MAPPING(p_business_group_id => l_profile_bg_id,
6264 p_proj_segment => l_proj_segment,
6265 p_tsk_segment => l_tsk_segment,
6266 p_awd_sgement => l_awd_sgement,
6267 p_exp_org_segment=> l_exp_org_segment,
6268 p_exp_type_segment => l_exp_type_segment);
6269 IF (l_proj_segment is null) OR (l_tsk_segment is null) OR (l_awd_sgement is null) OR
6270 (l_exp_org_segment is null) OR (l_exp_type_segment is null) THEN
6271 fnd_message.set_name('PSP', 'PSP_GL_PTAOE_NOT_MAPPED');
6272 raise fnd_api.g_exc_unexpected_error;
6273 END IF;
6274 l_sql_string := replace(l_sql_string,'psl','erd');
6275 l_sql_string := replace(l_sql_string,'gcc','erd');
6276 l_sql_string := replace(l_sql_string,l_proj_segment,'PROJECT_ID');
6277 l_sql_string := replace(l_sql_string,l_tsk_segment,'TASK_ID');
6278 l_sql_string := replace(l_sql_string,l_awd_sgement,'AWARD_ID');
6279 l_sql_string := replace(l_sql_string,l_exp_org_segment,'EXPENDITURE_ORGANIZATION_ID');
6280 l_sql_string := replace(l_sql_string,l_exp_type_segment,'EXPENDITURE_TYPE');
6281 ELSE
6282 l_sql_string := replace(l_sql_string,'psl','erd');
6283 l_sql_string := replace(l_sql_string,'gcc','erd');
6284 l_sql_string := replace(l_sql_string,'SEGMENT','GL_SEGMENT');
6285 END IF;
6286 -- Bug 4319874 : END
6287
6288
6289 hr_utility.trace( 'SandT_Supercede--> before exec immediate for tol amt'||l_sql_string);
6290 hr_utility.trace( 'SandT_Supercede--> sql_string ='||l_sql_string);
6291 execute immediate l_sql_string
6292 using out t_tolerance_req,
6293 out t_tolerance_per,
6294 in abs(l_tolerance_amt);
6295 hr_utility.trace( 'SandT_Supercede--> after exec immediate for tol amt = '||abs(l_tolerance_amt));
6296 else
6297 l_sql_string := ' begin
6298 select distinct er.request_id, er.person_id
6299 bulk collect into :reqtable, :pertable
6300 from psp_eff_report_details erd,
6301 psp_supercede_persons_gt gt,
6302 psp_eff_reports er
6303 where er.status_code not in
6304 ('||''''||'S'||''''||','||''''||'R'||''''||')
6305 and er.request_id in ('||l_supercede_reqid_str||')
6306 and gt.person_id = er.person_id
6307 and er.effort_report_id = erd.effort_report_id
6308 group by er.request_id, er.person_id '||PSP_CREATE_EFF_REPORTS.g_summarization_criteria ||
6309 ' having abs(sum(decode(er.status_code,'||''''|| 'T'||''''||',
6310 -erd.payroll_percent,
6311 erd.payroll_percent))) > :l_tolerance_percent;
6312 end;';
6313 --Bug 4319874 START
6314 -- Replacing the Dynamic Sql based on Configuration value
6315 IF PSP_GENERAL.GET_CONFIGURATION_OPTION_VALUE(l_profile_bg_id,'PSP_USE_GL_PTAOE_MAPPING') = 'Y' THEN
6316 PSP_GENERAL.GET_GL_PTAOE_MAPPING(p_business_group_id => l_profile_bg_id,
6317 p_proj_segment => l_proj_segment,
6318 p_tsk_segment => l_tsk_segment,
6319 p_awd_sgement => l_awd_sgement,
6320 p_exp_org_segment=> l_exp_org_segment,
6321 p_exp_type_segment => l_exp_type_segment);
6322 IF (l_proj_segment is null) OR (l_tsk_segment is null) OR (l_awd_sgement is null) OR
6323 (l_exp_org_segment is null) OR (l_exp_type_segment is null) THEN
6324 fnd_message.set_name('PSP', 'PSP_GL_PTAOE_NOT_MAPPED');
6325 raise fnd_api.g_exc_unexpected_error;
6326 END IF;
6327 l_sql_string := replace(l_sql_string,'psl','erd');
6328 l_sql_string := replace(l_sql_string,'gcc','erd');
6329 l_sql_string := replace(l_sql_string,l_proj_segment,'PROJECT_ID');
6330 l_sql_string := replace(l_sql_string,l_tsk_segment,'TASK_ID');
6331 l_sql_string := replace(l_sql_string,l_awd_sgement,'AWARD_ID');
6332 l_sql_string := replace(l_sql_string,l_exp_org_segment,'EXPENDITURE_ORGANIZATION_ID');
6333 l_sql_string := replace(l_sql_string,l_exp_type_segment,'EXPENDITURE_TYPE');
6334 ELSE
6335 l_sql_string := replace(l_sql_string,'psl','erd');
6336 l_sql_string := replace(l_sql_string,'gcc','erd');
6337 l_sql_string := replace(l_sql_string,'SEGMENT','GL_SEGMENT');
6338 END IF;
6339 -- Bug 4319874 : END
6340
6341
6342 hr_utility.trace( 'SandT_Supercede--> before exec immediate for tol %');
6343 hr_utility.trace( 'SandT_Supercede--> sql_string ='||l_sql_string);
6344 execute immediate l_sql_string
6345 using out t_tolerance_req,
6346 out t_tolerance_per,
6347 in abs(l_tolerance_percent);
6348 hr_utility.trace( 'SandT_Supercede--> after exec immediate for tol %');
6349 end if;
6350 ---- debug;
6351 ---commit; --- remove commit;
6352 rollback to populate_er_tables;
6353 hr_utility.trace( 'SandT_Supercede--> before tolerance_req.count = '||t_tolerance_req.count);
6354 for i in 1..t_tolerance_req.count
6355 loop
6356 hr_utility.trace( 'SandT999_Supercede--> before tolerance_req.count = '||t_tolerance_req.count);
6357 open get_eff_id(t_tolerance_req(i), t_tolerance_per(i));
6358 fetch get_eff_id into l_eff_id;
6359 close get_eff_id;
6360 hr_utility.trace( 'SandTTTTTTupercede--> before tolerance_req.count = '||t_tolerance_req.count);
6361 t_tolerance_erid(i) := l_eff_id;
6362 hr_utility.trace( 'Sand%%%%%%%%%%cede--> before tolerance_req.count = '||t_tolerance_req.count);
6363 end loop;
6364
6365 hr_utility.trace( 'SandT_Supercede--> before tolerance_erid.count = '||t_tolerance_erid.count);
6366 if t_tolerance_erid.count > 0 then
6367 for i in 1..t_tolerance_erid.count
6368 loop
6369 hr_utility.trace( 'SandT_Supercede--> tolerance_erid='||t_tolerance_erid(i));
6370 for j in 1..t_efforts_table.count
6371 loop
6372 if t_tolerance_erid(i) = t_efforts_table(j) then
6373 hr_utility.trace( 'SandT_Supercede--> MATCH t_Efforts_Table ='|| t_efforts_table(j));
6374 t_tolerance_sline(i) := t_sum_line_id(j);
6375 end if;
6376 end loop;
6377 end loop;
6378 -- found ERs to be superceded.
6379 i := 1;
6380 loop
6381 if i > t_tolerance_erid.count then
6382 exit;
6383 end if;
6384 hr_utility.trace( 'SandT_Supercede--> erid='|| t_tolerance_erid(i));
6385 if t_tolerance_sline.exists(i) then
6386 -- found ERs to be superceded.
6387
6388 OPEN get_Con_Program_name_csr;
6389 FETCH get_Con_Program_name_csr into l_Con_Program_name;
6390 CLOSE get_Con_Program_name_csr;
6391 --Bug 4339561
6392 -- Pupulating Column superceding_program_name
6393
6394 update psp_eff_reports
6395 set status_code = 'S',
6396 superceding_summary_line_id = t_tolerance_sline(i),
6397 superceding_request_id = l_S_and_T_reqid,
6398 superceding_program_name = l_Con_Program_name
6399 where effort_report_id = t_tolerance_erid(i);
6400 hr_utility.trace( 'SandT_Supercede--> Updated erid='|| t_tolerance_erid(i));
6401 if sql%rowcount > 0 then
6402 l_superceded_flag := true;
6403 end if;
6404 end if;
6405 i := i + 1;
6406 end loop;
6407 end if; --- non zero tolerance persons count > 0
6408 end if; -- tolerance = 0
6409 --- delete persons .. retain -persons_ids.. the request_ids.
6410 delete psp_supercede_persons_gt where person_id > 0;
6411 if l_superceded_flag then
6412 -- send superceding notifications
6413 send_notifications(l_supercede_reqid_str,
6414 t_template_id(k),
6415 l_S_and_T_reqid,
6416 p_batch_name ,
6417 p_source_type,
6418 p_source_code,
6419 p_time_period_id);
6420 l_superceded_flag := false;
6421 end if;
6422 end if; -- supercede persons count > 0
6423 l_supercede_reqid_str := null;
6424 delete psp_supercede_persons_gt;
6425 else
6426 l_supercede_reqid_str := null;
6427 delete psp_supercede_persons_gt;
6428 end if; --- only if s_and_t processes emps in er
6429 else --- more than on reqid for Template_id
6430 insert into psp_supercede_persons_gt (person_id) values ( -t_request_id(k));
6431 if l_supercede_reqid_str is null then
6432 l_supercede_reqid_str := t_request_id(k);
6433 else
6434 l_supercede_reqid_str := l_supercede_reqid_str ||', '|| t_request_id(k);
6435 end if;
6436 end if; -- new template
6437 end loop;
6438 delete psp_supercede_persons_gt;
6439 t_person_table := t_num_15_type(null);
6440 t_efforts_table := t_num_15_type(null);
6441 t_sum_line_id := t_num_15_type(null);
6442 t_person_table.delete;
6443 t_efforts_table.delete;
6444 t_sum_line_id.delete ;
6445 t_tolerance_erid.delete;
6446 t_request_id.delete;
6447 t_template_id.delete;
6448 t_tolerance_sline.delete;
6449 hr_utility.trace( 'SandT_Supercede--> EXITING');
6450 EXCEPTION
6451 when others then
6452 hr_utility.trace( 'SandT_Supercede--> when others in supercede_er'||sqlerrm) ;
6453 fnd_msg_pub.add_exc_msg('PSP_SUM_TRANS', 'SUPERCEDE_ER');
6454 p_return_status := fnd_api.g_ret_sts_unexp_error;
6455 END supercede_er;
6456
6457 END PSP_SUM_TRANS;