[Home] [Help]
PACKAGE BODY: APPS.PSP_ENC_SUM_TRAN
Source
1 PACKAGE BODY PSP_ENC_SUM_TRAN AS
2 /* $Header: PSPENSTB.pls 120.16.12020000.5 2013/03/27 00:38:00 lkodaman ship $ */
3
4 -- ##########################################################################
5 -- This procedure initiates the encumbrance summarization processes gl/ogm
6 -- ##########################################################################
7 g_control_rec_found VARCHAR2(10) := 'TRUE';
8 l_phase_status number := 0 ;
9 g_fatal number;
10 g_payroll_action_id number; /* Bug 2030232 */
11
12 g_currency_code VARCHAR(15); -- for Bug 2478000 Qubec fix
13
14 g_susp_prob varchar2(5) := NULL; --- 2479579
15
16 g_insert_str varchar2(5000); -- Introduced for bug fix 3233373
17 g_warning_message VARCHAR2(5000);
18
19 g_dff_grouping_option CHAR(1); -- Introduced for bug fix 2908859
20
21 g_def_end_date DATE;
22
23 g_precision NUMBER;
24 g_ext_precision NUMBER;
25 g_suspense_failed VARCHAR2(15);
26 g_process_complete BOOLEAN;
27 g_sa_autopop BOOLEAN;
28
29 g_bulk_row_count NUMBER(15);
30
31 PROCEDURE move_rej_lines_to_arch (p_payroll_action_id IN NUMBER);
32
33 PROCEDURE create_sum_lines (p_payroll_action_id IN NUMBER,
34 p_return_status OUT NOCOPY VARCHAR2);
35
36 PROCEDURE update_hierarchy_dates (p_payroll_action_id IN NUMBER,
37 p_return_status OUT NOCOPY VARCHAR2);
38
39 PROCEDURE add_st_warnings(p_start_date IN DATE DEFAULT NULL,
40 p_end_date IN DATE DEFAULT NULL,
41 p_assignment_id IN NUMBER DEFAULT NULL,
42 p_payroll_id IN NUMBER DEFAULT NULL,
43 p_element_type_id IN NUMBER DEFAULT NULL,
44 p_gl_ccid IN NUMBER DEFAULT NULL,
45 p_project_id IN NUMBER DEFAULT NULL,
46 p_task_id IN NUMBER DEFAULT NULL,
47 p_award_id IN NUMBER DEFAULT NULL,
48 p_exp_org_id IN NUMBER DEFAULT NULL,
49 p_exp_type IN VARCHAR2 DEFAULT NULL,
50 p_effective_date IN DATE DEFAULT NULL,
51 p_error_status IN VARCHAR2 DEFAULT NULL);
52
53 PROCEDURE log_st_warnings;
54
55 TYPE t_num_15_type IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
56 TYPE t_varchar_50_type IS TABLE OF VARCHAR2(50) INDEX BY BINARY_INTEGER;
57 TYPE t_varchar_150_type IS TABLE OF VARCHAR2(150) INDEX BY BINARY_INTEGER;
58 TYPE t_num_10d2_type IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
59 TYPE t_date_type IS TABLE OF DATE INDEX BY BINARY_INTEGER;
60
61 TYPE r_enc_rec IS RECORD
62 (assignment_id t_num_15_type,
63 payroll_id t_num_15_type,
64 element_type_id t_num_15_type,
65 hierarchy_code t_varchar_50_type,
66 gl_ccid t_num_15_type,
67 project_id t_num_15_type,
68 task_id t_num_15_type,
69 award_id t_num_15_type,
70 exp_org_id t_num_15_type,
71 exp_type t_varchar_50_type,
72 enc_start_date t_date_type,
73 enc_end_date t_date_type);
74
75 t_enc_lines r_enc_rec;
76 t_enc_nlines r_enc_rec;
77
78 TYPE r_asg_rec IS RECORD
79 (assignment_id t_num_15_type,
80 payroll_id t_num_15_type);
81
82 l_asgs r_asg_rec;
83
84 TYPE r_enc_susp_rec IS RECORD
85 (row_id t_num_15_type,
86 encumbrance_amount t_num_10d2_type,
87 enc_start_date t_date_type,
88 enc_end_date t_date_type);
89 t_enc_susp_lines r_enc_susp_rec;
90
91 TYPE r_warning_rec IS RECORD
92 (start_date t_date_type,
93 end_date t_date_type,
94 assignment_id t_num_15_type,
95 payroll_id t_num_15_type,
96 element_type_id t_num_15_type,
97 gl_ccid t_num_15_type,
98 project_id t_num_15_type,
99 task_id t_num_15_type,
100 award_id t_num_15_type,
101 exp_org_id t_num_15_type,
102 exp_type t_varchar_150_type,
103 effective_date t_date_type,
104 error_status t_varchar_150_type);
105 st_warnings r_warning_rec;
106
107 PROCEDURE enc_sum_trans(errbuf OUT NOCOPY VARCHAR2,
108 retcode OUT NOCOPY VARCHAR2,
109 p_payroll_action_id IN NUMBER,
110 p_business_group_id IN NUMBER,
111 p_set_of_books_id IN NUMBER) IS
112
113 l_return_status VARCHAR2(1);
114 l_msg_count NUMBER;
115 l_msg_data VARCHAR2(2000);
116 l_liq_check NUMBER;
117 l_gl_check NUMBER;
118 l_gms_check NUMBER;
119 l_last_update_date DATE;
120 l_last_updated_by NUMBER;
121 l_last_updated_login NUMBER;
122 l_request_id NUMBER;
123 l_sa_autopop VARCHAR2(1);
124
125 CURSOR autopop_config_cur IS
126 SELECT pcv_information7 suspense_account
127 FROM pqp_configuration_values
128 WHERE pcv_information_category = 'PSP_ENABLE_AUTOPOPULATION'
129 AND legislation_code IS NULL
130 AND NVL(business_group_id, p_business_group_id) = p_business_group_id
131 ORDER BY business_group_id;
132
133 CURSOR liq_check_cur IS
134 SELECT COUNT(1)
135 FROM psp_enc_processes
136 WHERE payroll_action_id = p_payroll_action_id
137 AND process_phase = 'liquidate';
138
139 CURSOR st_asgs_cur IS
140 SELECT DISTINCT assignment_id,
141 payroll_id
142 FROM psp_enc_summary_lines pesl
143 WHERE payroll_action_id = p_payroll_action_id
144 AND superceded_line_id IS NULL
145 AND status_code = 'N';
146
147 CURSOR def_end_date_cur IS
148 SELECT peed.period_end_date
149 FROM psp_enc_end_dates peed
150 WHERE peed.business_group_id = p_business_group_id
151 AND peed.set_of_books_id = p_set_of_books_id
152 AND peed.default_org_flag = 'Y';
153
154 CURSOR check_gl_lines IS
155 SELECT COUNT(1)
156 FROM psp_enc_summary_lines
157 WHERE payroll_action_id = p_payroll_action_id
158 AND superceded_line_id IS NULL
159 AND gl_code_combination_id IS NOT NULL
160 AND status_code = 'N';
161
162 CURSOR check_gms_lines IS
163 SELECT COUNT(1)
164 FROM psp_enc_summary_lines
165 WHERE payroll_action_id = p_payroll_action_id
166 AND superceded_line_id IS NULL
167 AND award_id IS NOT NULL
168 AND status_code = 'N';
169 BEGIN
170 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Entering enc_sum_trans p_payroll_action_id: ' || p_payroll_action_id || '
171 p_business_group_id: ' || p_business_group_id || '
172 p_set_of_books_id: ' || p_set_of_books_id);
173
174 g_error_api_path := '';
175 fnd_msg_pub.initialize;
176 psp_general.TRANSACTION_CHANGE_PURGEBLE; --2431917
177 g_business_group_id := p_business_group_id;
178 g_set_of_books_id := p_set_of_books_id;
179 g_payroll_action_id := p_payroll_action_id; /* for Bug 2030232 */
180
181 g_currency_code := psp_general.get_currency_code(p_business_group_id);-- For bug 2478000 Qubec fix
182 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'calling psp_general.get_currency_precision');
183 psp_general.get_currency_precision(g_currency_code, g_precision, g_ext_precision);
184
185 g_dff_grouping_option := psp_general.get_enc_dff_grouping_option(p_business_group_id); -- Introduced for bug fix 2908859
186 g_suspense_failed := 'FALSE';
187 g_process_complete := TRUE;
188
189 OPEN autopop_config_cur;
190 FETCH autopop_config_cur INTO l_sa_autopop;
191 IF (autopop_config_cur%ROWCOUNT = 0) THEN
192 l_sa_autopop := 'N';
193 END IF;
194 CLOSE autopop_config_cur;
195
196 g_sa_autopop := FALSE;
197 IF (l_sa_autopop = 'Y') THEN
198 g_sa_autopop := TRUE;
199 END IF;
200
201 OPEN def_end_date_cur;
202 FETCH def_end_date_cur INTO g_def_end_date;
203 CLOSE def_end_date_cur;
204
205 l_last_update_date := SYSDATE;
206 l_last_updated_by := NVL(FND_GLOBAL.USER_ID, -1);
207 l_last_updated_login := NVL(FND_GLOBAL.LOGIN_ID, -1);
208 l_request_id := fnd_global.conc_request_id;
209
210 INSERT INTO psp_enc_processes
211 (request_id, process_code, payroll_action_id,
212 process_status, process_phase, business_group_id,
213 set_of_books_id, creation_date, created_by,
214 last_update_date, last_updated_by, last_update_login)
215 SELECT l_request_id, 'ST', p_payroll_action_id,
216 'I', process_phase, p_business_group_id,
217 p_set_of_books_id, l_last_update_date, l_last_updated_by,
218 l_last_update_date, l_last_updated_by, l_last_updated_login
219 FROM psp_enc_processes pep
220 WHERE process_code IN ('CEL', 'LET')
221 AND payroll_action_id = p_payroll_action_id
222 AND NOT EXISTS (SELECT 1
223 FROM psp_enc_processes pep2
224 WHERE pep2.payroll_action_id = p_payroll_action_id
225 AND pep2.process_code = 'ST');
226
227 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Inserted row for process_code ST');
228
229 UPDATE psp_enc_processes
230 SET process_status = 'S',
231 process_phase = 'completed'
232 WHERE payroll_action_id = p_payroll_action_id
233 AND process_code IN ('CEL', 'LET');
234 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated original and current process status in psp_enc_processes');
235
236 OPEN st_asgs_cur;
237 FETCH st_asgs_cur BULK COLLECT INTO l_asgs.assignment_id, l_asgs.payroll_id;
238 CLOSE st_asgs_cur;
239
240 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' calling move_rej_lines_to_arch ');
241 move_rej_lines_to_arch(p_payroll_action_id);
242
243 OPEN liq_check_cur;
244 FETCH liq_check_cur INTO l_liq_check;
245 CLOSE liq_check_cur;
246 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' l_liq_check: '||l_liq_check);
247
248
249 IF (l_liq_check > 0) THEN
250 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling psp_enc_liq_tran.enc_liq_trans');
251 psp_enc_liq_tran.enc_liq_trans(p_payroll_action_id, p_business_group_id, p_set_of_books_id, l_return_status);
252
253 IF l_return_status NOT IN (fnd_api.g_ret_sts_error, fnd_api.g_ret_sts_success) THEN
254 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
255 END IF;
256 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' After psp_enc_liq_tran.enc_liq_trans');
257 END IF;
258
259 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling enc_batch_begin');
260 enc_batch_begin(p_payroll_action_id, l_return_status);
261
262 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
263 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
264 END IF;
265 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' After enc_batch_begin');
266
267 IF g_control_rec_found = 'FALSE' THEN
268 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling enc_batch_end');
269 enc_batch_end(p_payroll_action_id, l_return_status);
270
271 IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
272 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
273 END IF;
274 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' After enc_batch_end');
275 retcode := FND_API.G_RET_STS_SUCCESS;
276
277 psp_message_s.print_error(p_mode=>FND_FILE.log,
278 p_print_header=>FND_API.G_FALSE);
279 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving enc_sum_trans p_payroll_action_id: ' || p_payroll_action_id || '
280 p_business_group_id: ' || p_business_group_id || '
281 p_set_of_books_id: ' || p_set_of_books_id);
282 PSP_MESSAGE_S.Print_success;
283 return;
284 END IF;
285
286 -- Enh 2505778 LD, GMS Integration with PQH
287
288 if fnd_profile.value('PSP_ENC_ENABLE_PQH') ='Y' then
289 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling pqh_psp_integration.relieve_budget_commitments');
290 pqh_psp_integration.relieve_budget_commitments( 'S', l_return_status);
291 If l_return_status<>FND_API.G_RET_STS_SUCCESS THEN
292 fnd_message.set_name('PSP','PSP_ENC_PQH_ERROR');
293 fnd_msg_pub.add;
294 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
295 end if;
296 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' After pqh_psp_integration.relieve_budget_commitments');
297 end if;
298
299 -- FIRST NORMAL RUN
300 -- initiate the gl encumbrance summarization and transfer
301 -- call the user extension to populate attribute1 through attribute30
302 IF FND_PROFILE.VALUE('PSP_ST_EXTENSION_ENABLE') = 'Y' THEN
303 -- 2968684 added params to following proc
304 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling psp_st_ext.summary_ext_encumber');
305 psp_st_ext.summary_ext_encumber(p_payroll_action_id ,
306 p_business_group_id,
307 p_set_of_books_id);
308 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' After psp_st_ext.summary_ext_encumber');
309 END IF;
310
311 OPEN check_gl_lines;
312 FETCH check_gl_lines INTO l_gl_check;
313 CLOSE check_gl_lines;
314
315 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' l_gl_check: ' || l_gl_check);
316
317 IF (l_gl_check > 0) THEN
318 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling tr_to_gl_int');
319 tr_to_gl_int(p_payroll_action_id, l_return_status);
320
321 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
322 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
323 END IF;
324 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' After tr_to_gl_int');
325 END IF;
326
327 -- call the user extension to populate attribute1 through attribute30
328 IF FND_PROFILE.VALUE('PSP_ST_EXTENSION_ENABLE') = 'Y' THEN
329 -- 2968684 added params to following proc
330 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling psp_st_ext.summary_ext_encumber');
331 psp_st_ext.summary_ext_encumber(p_payroll_action_id ,
332 p_business_group_id,
333 p_set_of_books_id);
334 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' After psp_st_ext.summary_ext_encumber');
335 END IF;
336
337 -- initiate the ogm encumbrance summarization and transfer
338 OPEN check_gms_lines;
339 FETCH check_gms_lines INTO l_gms_check;
340 CLOSE check_gms_lines;
341 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' l_gms_check: ' || l_gms_check);
342
343 IF (l_gms_check > 0) THEN
344 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling tr_to_gms_int');
345 tr_to_gms_int(p_payroll_action_id, l_return_status);
346
347 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
348 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
349 END IF;
350 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' After tr_to_gms_int');
351 END IF;
352
353 -- SECOND RUN TO TAKE CARE OF TIE-BACK
354 -- initiate the suspense lines summarization
355 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling create_sum_lines');
356 create_sum_lines(p_payroll_action_id, l_return_status);
357
358 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
359 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
360 END IF;
361 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' After create_sum_lines');
362
363 -- call the user extension to populate attribute1 through attribute30
364 IF FND_PROFILE.VALUE('PSP_ST_EXTENSION_ENABLE') = 'Y' THEN
365 -- 2968684 added params to following proc
366 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling psp_st_ext.summary_ext_encumber');
367 psp_st_ext.summary_ext_encumber(p_payroll_action_id ,
368 p_business_group_id,
369 p_set_of_books_id);
370 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' After psp_st_ext.summary_ext_encumber');
371 END IF;
372
373 OPEN check_gl_lines;
374 FETCH check_gl_lines INTO l_gl_check;
375 CLOSE check_gl_lines;
376 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' l_gl_check: ' || l_gl_check);
377
378 IF (l_gl_check > 0) THEN
379 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling tr_to_gl_int');
380 tr_to_gl_int(p_payroll_action_id, l_return_status);
381
382 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
383 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
384 END IF;
385 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' After tr_to_gl_int');
386 END IF;
387
388 -- call the user extension to populate attribute1 through attribute30
389 IF FND_PROFILE.VALUE('PSP_ST_EXTENSION_ENABLE') = 'Y' THEN
390 -- 2968684 added params to following proc
391 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling psp_st_ext.summary_ext_encumber');
392 psp_st_ext.summary_ext_encumber(p_payroll_action_id ,
393 p_business_group_id,
394 p_set_of_books_id);
395 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' After psp_st_ext.summary_ext_encumber');
396 END IF;
397
398 OPEN check_gms_lines;
399 FETCH check_gms_lines INTO l_gms_check;
400 CLOSE check_gms_lines;
401 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' l_gms_check: ' || l_gms_check);
402
403 IF (l_gms_check > 0) THEN
404 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling tr_to_gms_int');
405 tr_to_gms_int(p_payroll_action_id, l_return_status);
406
407 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
408 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
409 END IF;
410 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' After tr_to_gms_int');
411 END IF;
412
413 g_suspense_failed := 'TRUE';
414 DELETE psp_enc_summary_lines
415 WHERE payroll_action_id = p_payroll_action_id
416 AND superceded_line_id IS NULL
417 AND status_code = 'N';
418 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted un-imported summary lines (' || SQL%ROWCOUNT || ')');
419
420 UPDATE psp_enc_lines
421 SET suspense_org_account_id = NULL,
422 gl_code_combination_id = orig_gl_code_combination_id,
423 project_id = orig_project_id,
424 task_id = orig_task_id,
425 award_id = orig_award_id,
426 expenditure_organization_id = orig_expenditure_org_id,
427 expenditure_type = orig_expenditure_type,
428 gl_project_flag = decode(orig_gl_code_combination_id,NULL,'P','G'),
429 encumbrance_date = prev_effective_date
430 WHERE payroll_action_id = p_payroll_action_id
431 AND suspense_reason_code like 'ES:%';
432
433 UPDATE psp_enc_lines
434 SET orig_gl_code_combination_id = NULL,
435 orig_project_id = NULL,
436 orig_task_id = NULL,
437 orig_award_id = NULL,
438 orig_expenditure_org_id = NULL,
439 orig_expenditure_type = NULL,
440 suspense_reason_code = NULL
441 WHERE suspense_reason_code like 'ES:%'
442 AND payroll_action_id = p_payroll_action_id;
443 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Reverted un-imported suspense postings posted in this process (' || SQL%ROWCOUNT || ')');
444
445 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling create_sum_lines');
446 create_sum_lines(p_payroll_action_id, l_return_status);
447
448 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
449 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
450 END IF;
451 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' After create_sum_lines');
452
453 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling enc_batch_end');
454 enc_batch_end(p_payroll_action_id, l_return_status);
455
456 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
457 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
458 END IF;
459 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' After enc_batch_end');
460 retcode := FND_API.G_RET_STS_SUCCESS;
461
462 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving enc_sum_trans p_payroll_action_id: ' || p_payroll_action_id || '
463 p_business_group_id: ' || p_business_group_id || '
464 p_set_of_books_id: ' || p_set_of_books_id);
465 PSP_MESSAGE_S.Print_success;
466 EXCEPTION
467 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
468 ROLLBACK; --Introduced as part of bug fix 1776606
469 g_error_api_path := 'ENC_SUM_TRANS:'||g_error_api_path;
470 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN','ENC_SUM_TRANS');
471 retcode := 2;
472
473 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving enc_sum_trans p_payroll_action_id: ' || p_payroll_action_id || '
474 p_business_group_id: ' || p_business_group_id || '
475 p_set_of_books_id: ' || p_set_of_books_id);
476 psp_message_s.print_error(p_mode => FND_FILE.LOG,
477 p_print_header => FND_API.G_TRUE);
478 return;
479
480 WHEN OTHERS THEN
481 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
482 ROLLBACK; --Introduced as part of bug fix 1776606
483 g_error_api_path := 'ENC_SUM_TRANS:'||g_error_api_path;
484 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN','ENC_SUM_TRANS');
485 retcode := 2;
486
487 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving enc_sum_trans p_payroll_action_id: ' || p_payroll_action_id || '
488 p_business_group_id: ' || p_business_group_id || '
489 p_set_of_books_id: ' || p_set_of_books_id);
490 psp_message_s.print_error(p_mode => FND_FILE.LOG,
491 p_print_header => FND_API.G_TRUE);
492 return;
493 END;
494
495 -- ##########################################################################
496 -- This procedure begins the encumbrance summarization process
497 -- This procedure generates a RUN_ID and updates PSP_ENC_CONTROLS table with
498 -- the RUN_ID and sets the ACTION_CODE = 'I' where
499 -- ACTION_TYPE in ('N', 'Q', 'U') and ACTION_CODE = 'N'
500 -- Included 'Q' for Quick Update Enh. 2143723
501 -- ##########################################################################
502
503 PROCEDURE enc_batch_begin(p_payroll_action_id IN NUMBER,
504 p_return_status OUT NOCOPY VARCHAR2
505 ) IS
506
507 CURSOR enc_control_cur IS
508 SELECT enc_control_id,
509 payroll_id,
510 time_period_id
511 FROM psp_enc_controls
512 WHERE payroll_action_id = p_payroll_action_id
513 -- WHERE payroll_id = nvl(p_payroll_id, payroll_id)
514 AND (total_dr_amount IS NOT NULL OR total_cr_amount IS NOT NULL)
515 AND action_type IN ('N', 'Q', 'U') -- Included 'Q' for Quick Upd. Enh. 2143723
516 AND action_code in ('N','I') --- 2444657
517 AND business_group_id = g_business_group_id
518 AND set_of_books_id = g_set_of_books_id;
519
520 enc_control_rec enc_control_cur%ROWTYPE;
521 l_bg_id NUMBER := g_business_group_id;
522 BEGIN
523 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'Entering Enc_Batch_begin ');
524 SELECT psp_st_run_id_s.nextval INTO g_run_id FROM dual;
525
526 OPEN enc_control_cur;
527 LOOP
528 FETCH enc_control_cur INTO enc_control_rec;
529
530 IF enc_control_cur%rowcount = 0 THEN
531 g_control_rec_found := 'FALSE';
532 fnd_message.set_name('PSP','PSP_ENC_NO_SUMM_REC_FOUND');
533 fnd_msg_pub.add;
534 -- p_return_status := fnd_api.g_ret_sts_unexp_error;
535 -- for bug fix 1868338 -- Subha
536 p_return_status := fnd_api.g_ret_sts_success;
537 CLOSE enc_control_cur;
538 EXIT;
539 END IF;
540 IF enc_control_cur%NOTFOUND THEN
541 CLOSE enc_control_cur;
542 p_return_status := fnd_api.g_ret_sts_success;
543 EXIT;
544 END IF;
545
546 UPDATE psp_enc_controls
547 SET action_code = 'I',
548 run_id = g_run_id
549 WHERE enc_control_id = enc_control_rec.enc_control_id
550 AND time_period_id = enc_control_rec.time_period_id;
551 END LOOP;
552
553 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'Leaving Enc_Batch_begin ');
554 EXCEPTION
555 /* Introduced as part of bug fix #1776606 */
556 when others then
557 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
558 g_error_api_path := 'ENC_BATCH_BEGIN:'||g_error_api_path;
559 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN','ENC_BATCH_BEGIN');
560 p_return_status := fnd_api.g_ret_sts_unexp_error;
561 RAISE;
562 END;
563 -- ##########################################################################
564 -- This procedure ends the encumbrance summarization process
565
566 -- This procedure updates the table PSP_ENC_CONTROLS with ACTION_CODE = 'P',
567 -- if the program is completed with a return code of success and if the
568 -- return code is failed it updates ACTION_CODE = 'N'.
569
570 -- When the program returns a failure status, it also updates PSP_ENC_LINES
571 -- with STATUS_CODE = 'N' and PSP_ENC_SUMMARY_LINES with STATUS_CODE = 'R'
572
573 -- ##########################################################################
574
575 PROCEDURE enc_batch_end (p_payroll_action_id IN NUMBER,
576 p_return_status OUT NOCOPY VARCHAR2) IS
577 CURSOR pending_line_cur IS
578 SELECT COUNT(1)
579 FROM psp_enc_summary_lines pesl
580 WHERE pesl.payroll_action_id = p_payroll_action_id
581 AND pesl.status_code = 'N';
582
583 CURSOR check_enc_lines IS
584 SELECT COUNT(1)
585 FROM psp_enc_lines
586 WHERE payroll_action_id = p_payroll_action_id
587 AND enc_start_date <= g_def_end_date;
588
589 l_pending_line_count NUMBER;
590 l_enc_lines_cnt NUMBER;
591 l_return_status VARCHAR2(1);
592 BEGIN
593 update_hierarchy_dates(p_payroll_action_id => p_payroll_action_id,
594 p_return_status => l_return_status);
595
596 IF (l_return_status <> fnd_api.g_ret_sts_success) THEN
597 RAISE fnd_api.g_exc_unexpected_error;
598 END IF;
599
600 log_st_warnings;
601
602 IF (g_process_complete) THEN
603 OPEN check_enc_lines;
604 FETCH check_enc_lines INTO l_enc_lines_cnt;
605 CLOSE check_enc_lines;
606
607 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' l_enc_lines_cnt: '||l_enc_lines_cnt);
608
609 IF (l_enc_lines_cnt = 0) THEN
610 DELETE psp_enc_lines
611 WHERE payroll_action_id = p_payroll_action_id;
612 END IF;
613 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'Calling move_rej_lines_to_arch');
614 move_rej_lines_to_arch(p_payroll_action_id);
615 END IF;
616
617 UPDATE psp_enc_controls pec
618 SET action_code = 'P'
619 WHERE payroll_action_id = p_payroll_action_id
620 AND NOT EXISTS (SELECT 1
621 FROM psp_enc_summary_lines pesl
622 WHERE pesl.payroll_action_id = p_payroll_action_id
623 AND pesl.enc_control_id = pec.enc_control_id
624 AND pesl.status_code = 'N');
625 IF (SQL%ROWCOUNT > 0) THEN
626 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated action_code to ''P'' count'||SQL%ROWCOUNT);
627 END IF;
628
629 UPDATE psp_enc_processes
630 SET process_status = 'P', process_phase = 'completed'
631 WHERE payroll_action_id = p_payroll_action_id
632 AND process_code = 'ST'
633 AND NOT EXISTS (SELECT 1
634 FROM psp_enc_summary_lines pesl
635 WHERE pesl.payroll_action_id = p_payroll_action_id
636 AND pesl.status_code = 'N');
637 IF (SQL%ROWCOUNT > 0) THEN
638 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process_phase to completed as no summarize and transfer is required');
639 END IF;
640
641 UPDATE psp_enc_processes
642 SET process_phase = 'summarize_transfer'
643 WHERE payroll_action_id = p_payroll_action_id
644 AND process_code = 'ST'
645 AND EXISTS (SELECT 1
646 FROM psp_enc_lines pel
647 WHERE pel.payroll_action_id = p_payroll_action_id);
648 IF (SQL%ROWCOUNT > 0) THEN
649 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process_phase to summarize and transfer re-processing');
650 END IF;
651
652 UPDATE psp_enc_processes
653 SET process_phase = 'liquidate'
654 WHERE payroll_action_id = p_payroll_action_id
655 AND process_code = 'ST'
656 AND EXISTS (SELECT 1
657 FROM psp_enc_summary_lines pesl
658 WHERE pesl.payroll_action_id = p_payroll_action_id
659 AND pesl.status_code = 'N'
660 AND pesl.superceded_line_id IS NOT NULL);
661 IF (SQL%ROWCOUNT > 0) THEN
662 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process_phase to liquidate for liquidation re-processing');
663 END IF;
664
665 UPDATE psp_enc_process_assignments pepa
666 SET assignment_status = 'P'
667 WHERE payroll_action_id = p_payroll_action_id
668 AND NOT EXISTS (SELECT 1
669 FROM psp_enc_summary_lines pesl
670 WHERE pesl.payroll_action_id = p_payroll_action_id
671 AND pesl.assignment_id = pepa.assignment_id
672 AND pesl.payroll_id = pepa.payroll_id
673 AND pesl.status_code = 'N');
674 IF (SQL%ROWCOUNT > 0) THEN
675 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated assignment_status to processed for summarized and transferred assignments count: '||SQL%ROWCOUNT);
676 END IF;
677
678 UPDATE psp_enc_process_assignments pepa
679 SET assignment_status = 'S'
680 WHERE payroll_action_id = p_payroll_action_id
681 AND EXISTS (SELECT 1
682 FROM psp_enc_summary_lines pesl
683 WHERE pesl.payroll_action_id = p_payroll_action_id
684 AND pesl.assignment_id = pepa.assignment_id
685 AND pesl.payroll_id = pepa.payroll_id
686 AND pesl.status_code = 'N'
687 AND pesl.superceded_line_id IS NULL);
688 IF (SQL%ROWCOUNT > 0) THEN
689 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated assignment_status to summarize and transfer for assignments to be summarized and transferred count: '||SQL%ROWCOUNT);
690 END IF;
691
692 UPDATE psp_enc_process_assignments pepa
693 SET assignment_status = 'L'
694 WHERE payroll_action_id = p_payroll_action_id
695 AND EXISTS (SELECT 1
696 FROM psp_enc_summary_lines pesl
697 WHERE pesl.payroll_action_id = p_payroll_action_id
698 AND pesl.assignment_id = pepa.assignment_id
699 AND pesl.payroll_id = pepa.payroll_id
700 AND pesl.status_code = 'N'
701 AND pesl.superceded_line_id IS NOT NULL);
702 IF (SQL%ROWCOUNT > 0) THEN
703 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated assignment_status to liquidate for assignments to be liquidated count: '||SQL%ROWCOUNT);
704 END IF;
705
706 COMMIT;
707
708 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Committing');
709 OPEN pending_line_cur;
710 FETCH pending_line_cur INTO l_pending_line_count;
711 CLOSE pending_line_cur;
712
713 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' l_pending_line_count'||l_pending_line_count);
714
715 IF (l_pending_line_count > 0) THEN
716 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Need to re-process');
717 RAISE fnd_api.g_exc_unexpected_error;
718 END IF;
719 p_return_status := fnd_api.g_ret_sts_success;
720 EXCEPTION
721 WHEN OTHERS THEN
722 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
723 g_error_api_path := 'ENC_BATCH_END:'||g_error_api_path;
724 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN','ENC_BATCH_END');
725 p_return_status := fnd_api.g_ret_sts_unexp_error;
726 END enc_batch_end;
727
728 /***** Commented for Create and Update multi thread enh.
729 PROCEDURE enc_batch_end(p_payroll_action_id IN NUMBER,
730 p_return_status OUT NOCOPY VARCHAR2
731 ) IS
732
733 CURSOR enc_control_cur IS
734 SELECT enc_control_id,
735 payroll_id,
736 time_period_id,
737 gl_phase,
738 gms_phase
739 FROM psp_enc_controls
740 WHERE payroll_action_id = p_payroll_action_id
741 -- WHERE payroll_id = nvl(p_payroll_id, payroll_id)
742 AND (total_dr_amount IS NOT NULL OR total_cr_amount IS NOT NULL)
743 AND action_type IN ('N', 'Q', 'U') -- Included 'Q' for Quick Upd. Enh. 2143723.
744 AND action_code = 'I'
745 AND run_id = nvl(g_run_id, run_id)
746 AND business_group_id = g_business_group_id
747 AND set_of_books_id = g_set_of_books_id;
748
749 CURSOR new_enc_summary_lines_cur(P_ENC_CONTROL_ID IN NUMBER) IS
750 SELECT enc_summary_line_id
751 FROM psp_enc_summary_lines
752 WHERE enc_control_id = p_enc_control_id
753 AND status_code = 'N';
754
755 enc_control_rec enc_control_cur%ROWTYPE;
756 / * Included as part of Bug fix #1776606 * /
757 CURSOR gl_gms_line_count_cur IS
758 SELECT count(*)
759 FROM psp_enc_lines pel
760 -- ,psp_enc_controls pec
761 WHERE pel.enc_control_id= enc_control_rec.enc_control_id
762 AND pel.time_period_id = enc_control_rec.time_period_id
763 AND pel.encumbrance_amount<>0
764 AND pel.business_group_id = g_business_group_id
765 AND pel.set_of_books_id = g_set_of_books_id;
766
767 l_status_code VARCHAR2(1);
768 / * Commented as part of Bug fix #1776606 * /
769 -- l_o_enc_sum NUMBER;
770 l_enc_summary_line_id NUMBER(10);
771 l_bg_id NUMBER := g_business_group_id;
772 / * Included as part of Bug fix #1776606 * /
773 l_line_count NUMBER(10);
774
775 BEGIN
776
777 OPEN enc_control_cur;
778 LOOP
779
780 FETCH enc_control_cur INTO enc_control_rec;
781 IF enc_control_cur%NOTFOUND THEN
782 CLOSE enc_control_cur;
783 EXIT;
784
785 END IF;
786
787 -- This part is used to mark the status_code of non-transferred summary lines to 'R'
788 -- and mark the corresponding status_code of encumbrance lines back to 'N'
789
790 IF (enc_control_rec.gl_phase is null and enc_control_rec.gms_phase is null) then
791 rollback;
792 / * ELSIF (enc_control_rec.gl_phase = 'Transfer' or enc_control_rec.gms_phase = 'Transfer') then
793 update psp_enc_controls
794 set action_code = 'I'
795 where enc_control_id = enc_control_rec.enc_control_id; * / --- commented for 2479579
796 ELSE
797
798 UPDATE psp_enc_summary_lines
799 SET status_code = 'R'
800 WHERE enc_control_id = enc_control_rec.enc_control_id
801 AND status_code = 'N';
802
803 -- This part is used to delete the rejected summary lines, mark the status_code
804 -- in psp_enc_controls to 'P' or 'N'
805 / * Commented as part of bug fix #1776606
806 SELECT nvl(sum(encumbrance_amount),0)
807 INTO l_o_enc_sum
808 FROM psp_enc_lines pel
809 -- ,psp_enc_controls pec
810 WHERE pel.enc_control_id = enc_control_rec.enc_control_id
811 AND pel.time_period_id = enc_control_rec.time_period_id
812 AND pel.business_group_id = g_business_group_id
813 AND pel.set_of_books_id = g_set_of_books_id; * /
814
815 OPEN gl_gms_line_count_cur;
816 FETCH gl_gms_line_count_cur INTO l_line_count;
817 CLOSE gl_gms_line_count_cur;
818
819 / * Included as part of bug fix #1776606 * /
820 IF l_line_count = 0 THEN
821 / * commented for 2445196: preserving this lines useful for debugging purposes
822 DELETE FROM psp_enc_summary_lines
823 WHERE enc_control_id = enc_control_rec.enc_control_id
824 AND status_code = 'R'; * /
825
826 UPDATE psp_enc_controls
827 SET action_code = 'P',
828 run_id = NULL
829 WHERE enc_control_id = enc_control_rec.enc_control_id;
830
831 ELSE
832 UPDATE psp_enc_controls
833 SET action_code = 'N',
834 run_id = NULL
835 WHERE enc_control_id = enc_control_rec.enc_control_id;
836 END IF;
837 / * Commented as part of Bug fix #1776606 * /
838 / * IF l_o_enc_sum = 0 THEN
839 DELETE FROM psp_enc_summary_lines
840 WHERE enc_control_id = enc_control_rec.enc_control_id
841 AND status_code = 'R';
842
843 UPDATE psp_enc_controls
844 SET action_code = 'P',
845 run_id = NULL
846 WHERE enc_control_id = enc_control_rec.enc_control_id;
847
848 ELSE
849 UPDATE psp_enc_controls
850 SET action_code = 'N',
851 run_id = NULL
852 WHERE enc_control_id = enc_control_rec.enc_control_id;
853 END IF; * /
854 END IF; -- IF PHASES ARE OTHER THAN NULL OR TRANSFER
855 END LOOP;
856
857 UPDATE psp_enc_processes
858 SET process_status = 'P', process_phase = 'completed'
859 WHERE payroll_action_id = p_payroll_action_id
860 AND NOT EXISTS (SELECT 1
861 FROM psp_enc_summary_lines pesl
862 WHERE pesl.payroll_action_id = p_payroll_action_id
863 AND pesl.status_code = 'N');
864 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process_phase to completed as no summarize and transfer is required');
865
866 UPDATE psp_enc_processes
867 SET process_phase = 'summarize_transfer'
868 WHERE payroll_action_id = p_payroll_action_id
869 AND EXISTS (SELECT 1
870 FROM psp_enc_summary_lines pesl
871 WHERE pesl.payroll_action_id = p_payroll_action_id
872 AND pesl.status_code = 'N'
873 AND pesl.superceded_line_id IS NULL);
874 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process_phase to summarize and transfer re-processing');
875
876 UPDATE psp_enc_processes
877 SET process_phase = 'liquidate'
878 WHERE payroll_action_id = p_payroll_action_id
879 AND EXISTS (SELECT 1
880 FROM psp_enc_summary_lines pesl
881 WHERE pesl.payroll_action_id = p_payroll_action_id
882 AND pesl.status_code = 'N'
883 AND pesl.superceded_line_id IS NOT NULL);
884 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated process_phase to liquidate for liqduidation re-processing');
885
886 COMMIT;
887 p_return_status := fnd_api.g_ret_sts_success;
888 EXCEPTION
889 / * Introduced as part of Bug fix #1776606 * /
890 WHEN others then
891 g_error_api_path := 'ENC_BATCH_END:'||g_error_api_path;
892 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN','ENC_BATCH_END');
893 p_return_status := fnd_api.g_ret_sts_unexp_error;
894 END;
895 End of comment for Create and Update multi thread enh. *****/
896
897 -- ##########################################################################
898 -- This procedure summarizes all the lines from psp_enc_lines
899 -- and inserts the summarized lines into psp_enc_summary_lines
900
901 -- Depending on the setup options, this procedure groups transactions from
902 -- PSP_ENC_LINES and inserts the summarized lines into PSP_ENC_SUMMARY_LINES
903
904 -- There are two setup options in PSP_ENC_SETUP_OPTIONS table called 'TIME_BASED_SUMM'
905 -- and 'CI_BASED_SUMM_GL' on which the procedure depends.
906
907 -- If the 'TIME_BASED_SUMM' = 1 and 'CI_BASED_SUMM_GL' = 3
908 -- then the summarization is done upto the assignment level for each time period
909
910 -- If the 'TIME_BASED_SUMM' = 1 and 'CI_BASED_SUMM_GL' = 2
911 -- then the summarization is done upto the employee level for each time period
912
913 -- If the 'TIME_BASED_SUMM' = 1 and 'CI_BASED_SUMM_GL' = 1
914 -- then the summarization is done upto the code combination level for each time period
915
916 -- If the 'TIME_BASED_SUMM' = 2 and 'CI_BASED_SUMM_GL' = 3
917 -- then the summarization is done upto the assignment level for each GL period
918
919 -- If the 'TIME_BASED_SUMM' = 2 and 'CI_BASED_SUMM_GL' = 2
920 -- then the summarization is done upto the employee level for each GL period
921
922 -- If the 'TIME_BASED_SUMM' = 2 and 'CI_BASED_SUMM_GL' = 1
923 -- then the summarization is done upto the code combination level for each GL period
924
925 -- ##########################################################################
926
927 /***** Commented for Create and Update multi thread enh.
928 PROCEDURE create_gl_enc_sum_lines(p_payroll_id IN NUMBER,
929 p_return_status OUT NOCOPY VARCHAR2
930 ) IS
931
932 CURSOR enc_control_cur IS
933 SELECT enc_control_id,
934 payroll_id,
935 time_period_id
936 FROM psp_enc_controls
937 WHERE payroll_id = nvl(p_payroll_id, payroll_id)
938 AND (total_dr_amount IS NOT NULL OR total_cr_amount IS NOT NULL)
939 AND action_type IN ('N', 'Q', 'U') -- Included 'Q' for Quick Upd. Enh. 2143723.
940 AND action_code = 'I'
941 AND run_id = g_run_id
942 AND business_group_id = g_business_group_id
943 AND set_of_books_id = g_set_of_books_id
944 AND (gl_phase is null or gl_phase = 'TieBack'); --- 2444657
945
946 CURSOR enc_sum_lines_p1_cur(p_enc_control_id IN NUMBER) IS
947 SELECT
948 -- ptp.end_date eff_dt, bug fix 1971612
949 pel.encumbrance_date eff_dt,
950 pel.dr_cr_flag,
951 sum(pel.encumbrance_amount) sum_amt,
952 pel.gl_project_flag,
953 pel.person_id,
954 pel.assignment_id,
955 -- pel.gl_code_combination_id gl_ccid Commented out for Bug 3194807
956 -- sob.set_of_books_id,
957 / * Uncommented the decode statement for Bug 3194807 * /
958 decode(suspense_org_account_id, null, pel.gl_code_combination_id, pos.gl_code_combination_id) gl_ccid,
959 -- Introduced DFF columns for bug fix 2908859
960 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute_category, pos.attribute_category), NULL) attribute_category,
961 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute1, pos.attribute1), NULL) attribute1,
962 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute2, pos.attribute2), NULL) attribute2,
963 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute3, pos.attribute3), NULL) attribute3,
964 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute4, pos.attribute4), NULL) attribute4,
965 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute5, pos.attribute5), NULL) attribute5,
966 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute6, pos.attribute6), NULL) attribute6,
967 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute7, pos.attribute7), NULL) attribute7,
968 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute8, pos.attribute8), NULL) attribute8,
969 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute9, pos.attribute9), NULL) attribute9,
970 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute10, pos.attribute10), NULL) attribute10
971 FROM PSP_ENC_LINES PEL,
972 PER_TIME_PERIODS PTP,
973 -- ,GL_SETS_OF_BOOKS SOB,
974 -- GL_CODE_COMBINATIONS GCC,
975 PSP_ORGANIZATION_ACCOUNTS POS
976 WHERE PEL.TIME_PERIOD_ID = PTP.TIME_PERIOD_ID
977 -- AND PEL.ENCUMBRANCE_DATE BETWEEN PTP.START_DATE AND PTP.END_DATE
978 -- Commented out for bug fix 1971612
979 AND PEL.GL_PROJECT_FLAG = 'G'
980 AND PEL.ENCUMBRANCE_AMOUNT <> 0
981 AND PEL.ENC_CONTROL_ID = p_enc_control_id
982 -- AND pel.gl_code_combination_id = gcc.code_combination_id
983 -- AND gcc.chart_of_accounts_id = sob.chart_of_accounts_id
984 AND pel.suspense_org_account_id = pos.organization_account_id(+)
985 GROUP BY
986 -- ptp.end_date, -- for bug fix 1971612
987 pel.encumbrance_date,
988 pel.person_id,
989 pel.assignment_id,
990 pel.dr_cr_flag,
991 pel.gl_project_flag,
992 -- pel.gl_code_combination_id; Commented out for Bug 3194807
993 -- sob.set_of_books_id,
994 DECODE(suspense_org_account_id, null, pel.gl_code_combination_id, pos.gl_code_combination_id),
995 -- Introduced DFF columns for bug fix 2908859
996 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute_category, pos.attribute_category), NULL),
997 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute1, pos.attribute1), NULL),
998 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute2, pos.attribute2), NULL),
999 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute3, pos.attribute3), NULL),
1000 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute4, pos.attribute4), NULL),
1001 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute5, pos.attribute5), NULL),
1002 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute6, pos.attribute6), NULL),
1003 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute7, pos.attribute7), NULL),
1004 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute8, pos.attribute8), NULL),
1005 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute9, pos.attribute9), NULL),
1006 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute10, pos.attribute10), NULL);
1007 / * Commented the following Cursors as part of Enh. 2143723
1008 CURSOR enc_sum_lines_p2_cur(p_enc_control_id IN NUMBER) IS
1009 SELECT
1010 --- ptp.end_date eff_dt, for bug fix 1971612
1011 pel.encumbrance_date eff_dt,
1012 pel.dr_cr_flag,
1013 sum(pel.encumbrance_amount) sum_amt,
1014 pel.gl_project_flag,
1015 pel.person_id,
1016 pel.gl_code_combination_id gl_ccid
1017 -- sob.set_of_books_id,
1018 -- decode(suspense_org_account_id, null, pel.gl_code_combination_id, pos.gl_code_combination_id) gl_ccid
1019 FROM PSP_ENC_LINES PEL,
1020 PER_TIME_PERIODS PTP
1021 -- ,GL_SETS_OF_BOOKS SOB,
1022 -- GL_CODE_COMBINATIONS GCC,
1023 -- PSP_ORGANIZATION_ACCOUNTS POS
1024 WHERE PEL.TIME_PERIOD_ID = PTP.TIME_PERIOD_ID
1025 -- AND PEL.ENCUMBRANCE_DATE BETWEEN PTP.START_DATE AND PTP.END_DATE
1026 -- Commented out for bug fix 1971612
1027 AND PEL.GL_PROJECT_FLAG = 'G'
1028 AND PEL.ENCUMBRANCE_AMOUNT <> 0
1029 AND PEL.ENC_CONTROL_ID = p_enc_control_id
1030 -- AND pel.gl_code_combination_id = gcc.code_combination_id
1031 -- AND gcc.chart_of_accounts_id = sob.chart_of_accounts_id
1032 -- AND pel.suspense_org_account_id = pos.organization_account_id(+)
1033 GROUP BY
1034 -- ptp.end_date, for bug fix 1971612
1035 pel.encumbrance_date,
1036 pel.person_id,
1037 pel.dr_cr_flag,
1038 pel.gl_project_flag,
1039 pel.gl_code_combination_id;
1040 -- ,sob.set_of_books_id,
1041 -- decode(suspense_org_account_id, null, pel.gl_code_combination_id, pos.gl_code_combination_id);
1042
1043 CURSOR enc_sum_lines_p3_cur(p_enc_control_id IN NUMBER) IS
1044 SELECT
1045 -- ptp.end_date eff_dt, for bug fix 1971612
1046 pel.encumbrance_date eff_dt,
1047 pel.dr_cr_flag,
1048 sum(pel.encumbrance_amount) sum_amt,
1049 pel.gl_project_flag,
1050 pel.gl_code_combination_id gl_ccid
1051 -- sob.set_of_books_id,
1052 -- decode(suspense_org_account_id, null, pel.gl_code_combination_id, pos.gl_code_combination_id) gl_ccid
1053 FROM PSP_ENC_LINES PEL,
1054 PER_TIME_PERIODS PTP
1055 -- ,GL_SETS_OF_BOOKS SOB,
1056 -- GL_CODE_COMBINATIONS GCC,
1057 -- PSP_ORGANIZATION_ACCOUNTS POS
1058 WHERE PEL.TIME_PERIOD_ID = PTP.TIME_PERIOD_ID
1059 -- AND PEL.ENCUMBRANCE_DATE BETWEEN PTP.START_DATE AND PTP.END_DATE
1060 -- Commented out for bug fix 1971612
1061 AND PEL.GL_PROJECT_FLAG = 'G'
1062 AND PEL.ENCUMBRANCE_AMOUNT <> 0
1063 AND PEL.ENC_CONTROL_ID = p_enc_control_id
1064 -- AND pel.suspense_org_account_id = pos.organization_account_id(+)
1065 GROUP BY
1066 -- ptp.end_date, for bug fix 1971612
1067 pel.encumbrance_date,
1068 pel.dr_cr_flag,
1069 pel.gl_project_flag,
1070 pel.gl_code_combination_id;
1071 -- ,sob.set_of_books_id,
1072 -- decode(suspense_org_account_id, null, pel.gl_code_combination_id, pos.gl_code_combination_id);
1073
1074 End of Enh. fix 2143723 *** /
1075
1076 / ******************************************************************************
1077
1078
1079 The Summarize by Gl period option is obsoleted
1080 per bug fix 1971612 /bug 1831493
1081
1082 CURSOR enc_sum_lines_g1_cur(p_enc_control_id IN NUMBER) IS
1083 SELECT glp.end_date eff_dt,
1084 pel.dr_cr_flag,
1085 sum(pel.encumbrance_amount) sum_amt,
1086 pel.gl_project_flag,
1087 pel.person_id,
1088 pel.assignment_id,
1089 pel.gl_code_combination_id gl_ccid
1090 -- ,sob.set_of_books_id,
1091 -- decode(suspense_org_account_id, null, pel.gl_code_combination_id, pos.gl_code_combination_id) gl_ccid
1092 FROM PSP_ENC_LINES PEL,
1093 GL_PERIODS GLP,
1094 GL_SETS_OF_BOOKS SOB,
1095 -- ,GL_CODE_COMBINATIONS GCC,
1096 -- PSP_ORGANIZATION_ACCOUNTS POS
1097 WHERE sob.accounted_period_type = glp.period_type
1098 AND sob.set_of_books_id = g_set_of_books_id
1099 AND PEL.GL_PROJECT_FLAG = 'G'
1100 AND PEL.ENCUMBRANCE_AMOUNT <> 0
1101 AND PEL.ENC_CONTROL_ID = p_enc_control_id
1102 AND PEL.ENCUMBRANCE_DATE BETWEEN GLP.START_DATE AND GLP.END_DATE
1103 AND pel.gl_code_combination_id = gcc.code_combination_id
1104 -- AND gcc.chart_of_accounts_id = sob.chart_of_accounts_id
1105 -- AND pel.suspense_org_account_id = pos.organization_account_id(+)
1106 GROUP BY sob.set_of_books_id,
1107 glp.end_date,
1108 pel.person_id,
1109 pel.assignment_id,
1110 pel.dr_cr_flag,
1111 pel.gl_project_flag,
1112 pel.gl_code_combination_id;
1113 -- decode(suspense_org_account_id, null, pel.gl_code_combination_id, pos.gl_code_combination_id);
1114
1115 CURSOR enc_sum_lines_g2_cur(p_enc_control_id IN NUMBER) IS
1116 SELECT sob.set_of_books_id,
1117 glp.end_date eff_dt,
1118 pel.dr_cr_flag,
1119 sum(pel.encumbrance_amount) sum_amt,
1120 pel.gl_project_flag,
1121 pel.person_id,
1122 pel.gl_code_combination_id gl_ccid
1123 -- ,decode(suspense_org_account_id, null, pel.gl_code_combination_id, pos.gl_code_combination_id) gl_ccid
1124 FROM PSP_ENC_LINES PEL,
1125 GL_PERIODS GLP,
1126 GL_SETS_OF_BOOKS SOB
1127 -- ,GL_CODE_COMBINATIONS GCC,
1128 -- PSP_ORGANIZATION_ACCOUNTS POS
1129 WHERE sob.set_of_books_id = g_set_of_books_id
1130 AND sob.accounted_period_type = glp.period_type
1131 AND PEL.GL_PROJECT_FLAG = 'G'
1132 AND PEL.ENCUMBRANCE_AMOUNT <> 0
1133 AND PEL.ENC_CONTROL_ID = p_enc_control_id
1134 AND PEL.ENCUMBRANCE_DATE BETWEEN GLP.START_DATE AND GLP.END_DATE
1135 -- AND pel.suspense_org_account_id = pos.organization_account_id(+)
1136 -- AND pel.gl_code_combination_id = gcc.code_combination_id
1137 -- AND gcc.chart_of_accounts_id = sob.chart_of_accounts_id
1138 GROUP BY sob.set_of_books_id,
1139 glp.end_date,
1140 pel.person_id,
1141 pel.dr_cr_flag,
1142 pel.gl_project_flag,
1143 pel.gl_code_combination_id;
1144 -- decode(suspense_org_account_id, null, pel.gl_code_combination_id, pos.gl_code_combination_id);
1145
1146 CURSOR enc_sum_lines_g3_cur(p_enc_control_id IN NUMBER) IS
1147 SELECT sob.set_of_books_id,
1148 glp.end_date eff_dt,
1149 pel.dr_cr_flag,
1150 sum(pel.encumbrance_amount) sum_amt,
1151 pel.gl_project_flag,
1152 pel.gl_code_combination_id gl_ccid
1153 -- ,decode(suspense_org_account_id, null, pel.gl_code_combination_id, pos.gl_code_combination_id) gl_ccid
1154 FROM PSP_ENC_LINES PEL,
1155 GL_PERIODS GLP,
1156 GL_SETS_OF_BOOKS SOB
1157 -- ,GL_CODE_COMBINATIONS GCC,
1158 -- PSP_ORGANIZATION_ACCOUNTS POS
1159 WHERE sob.set_of_books_id = g_set_of_books_id
1160 AND sob.accounted_period_type = glp.period_type
1161 AND PEL.GL_PROJECT_FLAG = 'G'
1162 AND PEL.ENCUMBRANCE_AMOUNT <> 0
1163 AND PEL.ENC_CONTROL_ID = p_enc_control_id
1164 AND PEL.ENCUMBRANCE_DATE BETWEEN GLP.START_DATE AND GLP.END_DATE
1165 -- AND pel.gl_code_combination_id = gcc.code_combination_id
1166 -- AND gcc.chart_of_accounts_id = sob.chart_of_accounts_id
1167 -- AND pel.suspense_org_account_id = pos.organization_account_id(+)
1168 GROUP BY sob.set_of_books_id,
1169 glp.end_date,
1170 pel.dr_cr_flag,
1171 pel.gl_project_flag,
1172 pel.gl_code_combination_id;
1173 -- ,decode(suspense_org_account_id, null, pel.gl_code_combination_id, pos.gl_code_combination_id);
1174
1175 l_time_para_value VARCHAR2(1);
1176 l_gl_para_value VARCHAR2(1);
1177 commented above variables as part of enh. Quick Upd. Enc., bug 2143723
1178
1179 ************************************************************************************** /
1180
1181 enc_sum_lines_p1_rec enc_sum_lines_p1_cur%ROWTYPE;
1182
1183 / ***********************************************************************************
1184 Commented cursors p2_cur and p3_cur as part of Enh. 2143723
1185
1186 enc_sum_lines_p2_rec enc_sum_lines_p2_cur%ROWTYPE;
1187 enc_sum_lines_p3_rec enc_sum_lines_p3_cur%ROWTYPE;
1188 enc_sum_lines_g1_rec enc_sum_lines_g1_cur%ROWTYPE;
1189 enc_sum_lines_g2_rec enc_sum_lines_g2_cur%ROWTYPE;
1190 enc_sum_lines_g3_rec enc_sum_lines_g3_cur%ROWTYPE;
1191
1192
1193 Commented out as part of bug fix 1971612/1831493 --gl period option obsolete
1194 *************************************************************************************** /
1195
1196 l_bg_id NUMBER(15) := g_business_group_id;
1197 l_set_of_books_id NUMBER(15);
1198 l_enc_summary_line_id NUMBER(10);
1199 l_return_status VARCHAR2(10);
1200 enc_control_rec enc_control_cur%ROWTYPE;
1201 l_error VARCHAR2(100);
1202 l_product VARCHAR2(3);
1203 l_gl_ccid NUMBER(15);
1204 BEGIN
1205 --insert_into_psp_stout( 'create gl_enc_sum_lines' );
1206 / * Commenting out the following code as Enc. Sum. and Tr. will not be based on Setup options
1207 but based on Person, Assignment and CI for each time period for Enh. 2143723
1208 BEGIN
1209 SELECT parameter_value
1210 INTO l_time_para_value
1211 FROM psp_enc_setup_options
1212 WHERE setup_parameter = 'TIME_BASED_SUMM'
1213 AND business_group_id = l_bg_id;
1214 EXCEPTION
1215 WHEN NO_DATA_FOUND THEN
1216 l_error := 'TIME_BASED_SUMM';
1217 l_product := 'PSP';
1218 fnd_message.set_name('PSP','PSP_TR_NOT_SET_UP');
1219 fnd_message.set_token('ERROR',l_error);
1220 fnd_message.set_token('PRODUCT',l_product);
1221 fnd_msg_pub.add;
1222 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1223 END;
1224
1225 BEGIN
1226 SELECT parameter_value
1227 INTO l_gl_para_value
1228 FROM psp_enc_setup_options
1229 WHERE setup_parameter = 'CI_BASED_SUMM_GL'
1230 AND business_group_id = l_bg_id;
1231 EXCEPTION
1232 WHEN NO_DATA_FOUND THEN
1233 l_error := 'CI_BASED_SUMM_GL';
1234 l_product := 'PSP';
1235 fnd_message.set_name('PSP','PSP_TR_NOT_SET_UP');
1236 fnd_message.set_token('ERROR',l_error);
1237 fnd_message.set_token('PRODUCT',l_product);
1238 fnd_msg_pub.add;
1239 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1240 END;
1241
1242 IF l_time_para_value = '1' and l_gl_para_value = '3' THEN
1243
1244 End of Enh. fix 2143723 * /
1245
1246 OPEN enc_control_cur;
1247 LOOP
1248 FETCH enc_control_cur INTO enc_control_rec;
1249 IF enc_control_cur%NOTFOUND THEN
1250 CLOSE enc_control_cur;
1251 EXIT;
1252 END IF;
1253
1254 OPEN enc_sum_lines_p1_cur(enc_control_rec.enc_control_id);
1255 LOOP
1256 FETCH enc_sum_lines_p1_cur INTO enc_sum_lines_p1_rec;
1257 IF enc_sum_lines_p1_cur%ROWCOUNT = 0 THEN
1258 CLOSE enc_sum_lines_p1_cur;
1259 EXIT;
1260 ELSIF enc_sum_lines_p1_cur%NOTFOUND THEN
1261 update psp_enc_controls
1262 set gl_phase = 'Summarize' ---NULL ... for 2444657
1263 where enc_control_id = enc_control_rec.enc_control_id;
1264 CLOSE enc_sum_lines_p1_cur;
1265 EXIT;
1266 END IF;
1267
1268 insert_into_enc_sum_lines(
1269 l_enc_summary_line_id,
1270 l_bg_id,
1271 enc_control_rec.enc_control_id,
1272 enc_control_rec.time_period_id,
1273 enc_sum_lines_p1_rec.person_id,
1274 enc_sum_lines_p1_rec.assignment_id,
1275 enc_sum_lines_p1_rec.eff_dt,
1276 -- enc_sum_lines_p1_rec.set_of_books_id,
1277 g_set_of_books_id,
1278 enc_sum_lines_p1_rec.gl_ccid,
1279 NULL,
1280 NULL,
1281 NULL,
1282 NULL,
1283 NULL,
1284 enc_sum_lines_p1_rec.sum_amt,
1285 enc_sum_lines_p1_rec.dr_cr_flag,
1286 'N',
1287 enc_control_rec.payroll_id,
1288 NULL,
1289 enc_sum_lines_p1_rec.gl_project_flag,
1290 enc_sum_lines_p1_rec.attribute_category, -- Introduced DFF columns for bug fix 2908859
1291 enc_sum_lines_p1_rec.attribute1,
1292 enc_sum_lines_p1_rec.attribute2,
1293 enc_sum_lines_p1_rec.attribute3,
1294 enc_sum_lines_p1_rec.attribute4,
1295 enc_sum_lines_p1_rec.attribute5,
1296 enc_sum_lines_p1_rec.attribute6,
1297 enc_sum_lines_p1_rec.attribute7,
1298 enc_sum_lines_p1_rec.attribute8,
1299 enc_sum_lines_p1_rec.attribute9,
1300 enc_sum_lines_p1_rec.attribute10,
1301 l_return_status);
1302
1303 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1304 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1305 END IF;
1306
1307 IF (g_dff_grouping_option = 'N') THEN -- Introduced for bug fix 2908859
1308 UPDATE psp_enc_lines
1309 SET enc_summary_line_id = l_enc_summary_line_id
1310 WHERE enc_control_id = enc_control_rec.enc_control_id
1311 AND payroll_id = enc_control_rec.payroll_id
1312 AND time_period_id = enc_control_rec.time_period_id
1313 AND person_id = enc_sum_lines_p1_rec.person_id
1314 AND assignment_id = enc_sum_lines_p1_rec.assignment_id
1315 AND dr_cr_flag = enc_sum_lines_p1_rec.dr_cr_flag
1316 AND gl_project_flag = enc_sum_lines_p1_rec.gl_project_flag
1317 AND trunc(encumbrance_date) = trunc(enc_sum_lines_p1_rec.eff_dt) --- added for 3462452
1318 -- Enhanced the following check to accomodate suspense postings done in this process for bug fix 3194807.
1319 -- ANd gl_code_combination_id =enc_sum_lines_p1_rec.gl_ccid;
1320 AND ( (suspense_org_account_id IS NOT NULL
1321 AND suspense_reason_code like 'ES:%'
1322 AND EXISTS (SELECT 1 FROM psp_organization_accounts poa
1323 WHERE poa.organization_account_id = suspense_org_account_id
1324 AND poa.gl_code_combination_id = enc_sum_lines_p1_rec.gl_ccid))
1325 OR gl_code_combination_id = enc_sum_lines_p1_rec.gl_ccid);
1326 -- Introduced ELSE portion for bug fix 2908859
1327 ELSE
1328 UPDATE psp_enc_lines
1329 SET enc_summary_line_id = l_enc_summary_line_id
1330 WHERE enc_control_id = enc_control_rec.enc_control_id
1331 AND payroll_id = enc_control_rec.payroll_id
1332 AND time_period_id = enc_control_rec.time_period_id
1333 AND person_id = enc_sum_lines_p1_rec.person_id
1334 AND assignment_id = enc_sum_lines_p1_rec.assignment_id
1335 AND dr_cr_flag = enc_sum_lines_p1_rec.dr_cr_flag
1336 AND gl_project_flag = enc_sum_lines_p1_rec.gl_project_flag
1337 AND trunc(encumbrance_date) = trunc(enc_sum_lines_p1_rec.eff_dt) --- added for 3462452
1338 AND ( (suspense_org_account_id IS NOT NULL
1339 AND suspense_reason_code like 'ES:%'
1340 AND EXISTS (SELECT 1 FROM psp_organization_accounts poa
1341 WHERE poa.organization_account_id = suspense_org_account_id
1342 AND poa.gl_code_combination_id = enc_sum_lines_p1_rec.gl_ccid
1343 AND NVL(poa.attribute_category, 'NULL') =
1344 NVL(enc_sum_lines_p1_rec.attribute_category, 'NULL')
1345 AND NVL(poa.attribute1, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute1, 'NULL')
1346 AND NVL(poa.attribute2, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute2, 'NULL')
1347 AND NVL(poa.attribute3, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute3, 'NULL')
1348 AND NVL(poa.attribute4, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute4, 'NULL')
1349 AND NVL(poa.attribute5, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute5, 'NULL')
1350 AND NVL(poa.attribute6, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute6, 'NULL')
1351 AND NVL(poa.attribute7, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute7, 'NULL')
1352 AND NVL(poa.attribute8, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute8, 'NULL')
1353 AND NVL(poa.attribute9, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute9, 'NULL')
1354 AND NVL(poa.attribute10, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute10, 'NULL')))
1355 OR ( gl_code_combination_id = enc_sum_lines_p1_rec.gl_ccid
1356 AND NVL(attribute_category, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute_category, 'NULL')
1357 AND NVL(attribute1, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute1, 'NULL')
1358 AND NVL(attribute2, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute2, 'NULL')
1359 AND NVL(attribute3, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute3, 'NULL')
1360 AND NVL(attribute4, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute4, 'NULL')
1361 AND NVL(attribute5, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute5, 'NULL')
1362 AND NVL(attribute6, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute6, 'NULL')
1363 AND NVL(attribute7, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute7, 'NULL')
1364 AND NVL(attribute8, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute8, 'NULL')
1365 AND NVL(attribute9, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute9, 'NULL')
1366 AND NVL(attribute10, 'NULL') = NVL(enc_sum_lines_p1_rec.attribute10, 'NULL')));
1367 -- Introduced ELSE portion for bug fix 2908859
1368 END IF;
1369 / * added the check on gl_code_combination_id since group by clause has it * /
1370
1371 END LOOP;
1372
1373 END LOOP;
1374
1375 / * Commenting the following as Enc Sum. and Tr. options is now obsolete for Enh. 2143723
1376
1377 ELSIF l_time_para_value = '1' and l_gl_para_value = '2' THEN
1378 OPEN enc_control_cur;
1379 LOOP
1380 FETCH enc_control_cur INTO enc_control_rec;
1381 IF enc_control_cur%NOTFOUND THEN
1382 CLOSE enc_control_cur;
1383 EXIT;
1384 END IF;
1385
1386 OPEN enc_sum_lines_p2_cur(enc_control_rec.enc_control_id);
1387 LOOP
1388 FETCH enc_sum_lines_p2_cur INTO enc_sum_lines_p2_rec;
1389 IF enc_sum_lines_p2_cur%ROWCOUNT = 0 THEN
1390 CLOSE enc_sum_lines_p2_cur;
1391 EXIT;
1392 ELSIF enc_sum_lines_p2_cur%NOTFOUND THEN
1393 update psp_enc_controls
1394 set gl_phase = 'Summarize' ---NULL for 2444657
1395 where enc_control_id = enc_control_rec.enc_control_id;
1396 CLOSE enc_sum_lines_p2_cur;
1397 EXIT;
1398 END IF;
1399 insert_into_enc_sum_lines(
1400 l_enc_summary_line_id,
1401 l_bg_id,
1402 enc_control_rec.enc_control_id,
1403 enc_control_rec.time_period_id,
1404 enc_sum_lines_p2_rec.person_id,
1405 NULL,
1406 enc_sum_lines_p2_rec.eff_dt,
1407 -- enc_sum_lines_p2_rec.set_of_books_id,
1408 g_set_of_books_id,
1409 enc_sum_lines_p2_rec.gl_ccid,
1410 NULL,
1411 NULL,
1412 NULL,
1413 NULL,
1414 NULL,
1415 enc_sum_lines_p2_rec.sum_amt,
1416 enc_sum_lines_p2_rec.dr_cr_flag,
1417 'N',
1418 enc_control_rec.payroll_id,
1419 NULL,
1420 enc_sum_lines_p2_rec.gl_project_flag,
1421 l_return_status);
1422
1423 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1424 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1425 END IF;
1426
1427 UPDATE psp_enc_lines
1428 SET enc_summary_line_id = l_enc_summary_line_id
1429 WHERE enc_control_id = enc_control_rec.enc_control_id
1430 AND payroll_id = enc_control_rec.payroll_id
1431 ANd time_period_id = enc_control_rec.time_period_id
1432 -- added check on gl_ccid - subha 22 Mar
1433 AND gl_code_combination_id = enc_sum_lines_p2_rec.gl_ccid
1434 AND person_id = enc_sum_lines_p2_rec.person_id
1435 AND dr_cr_flag = enc_sum_lines_p2_rec.dr_cr_flag
1436 AND gl_project_flag = enc_sum_lines_p2_rec.gl_project_flag;
1437
1438 END LOOP;
1439
1440 END LOOP;
1441 ELSIF l_time_para_value = '1' and l_gl_para_value = '1' THEN
1442 OPEN enc_control_cur;
1443 LOOP
1444 FETCH enc_control_cur INTO enc_control_rec;
1445
1446 IF enc_control_cur%NOTFOUND THEN
1447 CLOSE enc_control_cur;
1448 EXIT;
1449 END IF;
1450
1451 OPEN enc_sum_lines_p3_cur(enc_control_rec.enc_control_id);
1452 LOOP
1453 FETCH enc_sum_lines_p3_cur INTO enc_sum_lines_p3_rec;
1454 IF enc_sum_lines_p3_cur%ROWCOUNT = 0 THEN
1455 CLOSE enc_sum_lines_p3_cur;
1456 EXIT;
1457 ELSIF enc_sum_lines_p3_cur%NOTFOUND THEN
1458 update psp_enc_controls
1459 set gl_phase = 'Summarize' ---NULL commented for 2444657
1460 where enc_control_id = enc_control_rec.enc_control_id;
1461 CLOSE enc_sum_lines_p3_cur;
1462 EXIT;
1463 END IF;
1464 insert_into_enc_sum_lines(
1465 l_enc_summary_line_id,
1466 l_bg_id,
1467 enc_control_rec.enc_control_id,
1468 enc_control_rec.time_period_id,
1469 NULL,
1470 NULL,
1471 enc_sum_lines_p3_rec.eff_dt,
1472 -- enc_sum_lines_p3_rec.set_of_books_id,
1473 g_set_of_books_id,
1474 enc_sum_lines_p3_rec.gl_ccid,
1475 NULL,
1476 NULL,
1477 NULL,
1478 NULL,
1479 NULL,
1480 enc_sum_lines_p3_rec.sum_amt,
1481 enc_sum_lines_p3_rec.dr_cr_flag,
1482 'N',
1483 enc_control_rec.payroll_id,
1484 NULL,
1485 enc_sum_lines_p3_rec.gl_project_flag,
1486 l_return_status);
1487
1488 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1489 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1490 END IF;
1491
1492 UPDATE psp_enc_lines
1493 SET enc_summary_line_id = l_enc_summary_line_id
1494 WHERE enc_control_id = enc_control_rec.enc_control_id
1495 AND time_period_id = enc_control_rec.time_period_id
1496 AND payroll_id = enc_control_rec.payroll_id
1497 AND dr_cr_flag = enc_sum_lines_p3_rec.dr_cr_flag
1498 AND gl_code_combination_id = enc_sum_lines_p3_rec.gl_ccid
1499 AND gl_project_flag = enc_sum_lines_p3_rec.gl_project_flag;
1500
1501 END LOOP;
1502
1503 END LOOP;
1504
1505 / *
1506
1507 This code is obsolete and the summarize by gl_period option is no longer supported refer bug 1831493
1508
1509
1510 ELSIF l_time_para_value = '2' and l_gl_para_value = '3' THEN
1511 OPEN enc_control_cur;
1512 LOOP
1513 FETCH enc_control_cur INTO enc_control_rec;
1514 IF enc_control_cur%NOTFOUND THEN
1515 CLOSE enc_control_cur;
1516 EXIT;
1517 END IF;
1518
1519 OPEN enc_sum_lines_g1_cur(enc_control_rec.enc_control_id);
1520 LOOP
1521 FETCH enc_sum_lines_g1_cur INTO enc_sum_lines_g1_rec;
1522 IF enc_sum_lines_g1_cur%ROWCOUNT = 0 THEN
1523 CLOSE enc_sum_lines_g1_cur;
1524 EXIT;
1525 ELSIF enc_sum_lines_g1_cur%NOTFOUND THEN
1526 update psp_enc_controls
1527 set gl_phase = 'Summarize' --- replaced NULL for 2444657
1528 where enc_control_id = enc_control_rec.enc_control_id;
1529 CLOSE enc_sum_lines_g1_cur;
1530 EXIT;
1531 END IF;
1532 insert_into_enc_sum_lines(
1533 l_enc_summary_line_id,
1534 l_bg_id,
1535 enc_control_rec.enc_control_id,
1536 enc_control_rec.time_period_id,
1537 enc_sum_lines_g1_rec.person_id,
1538 enc_sum_lines_g1_rec.assignment_id,
1539 enc_sum_lines_g1_rec.eff_dt,
1540 g_set_of_books_id,
1541 enc_sum_lines_g1_rec.gl_ccid,
1542 NULL,
1543 NULL,
1544 NULL,
1545 NULL,
1546 NULL,
1547 enc_sum_lines_g1_rec.sum_amt,
1548 enc_sum_lines_g1_rec.dr_cr_flag,
1549 'N',
1550 enc_control_rec.payroll_id,
1551 NULL,
1552 enc_sum_lines_g1_rec.gl_project_flag,
1553 l_return_status);
1554
1555 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1556 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1557 END IF;
1558
1559 UPDATE psp_enc_lines
1560 SET enc_summary_line_id = l_enc_summary_line_id
1561 WHERE enc_control_id = enc_control_rec.enc_control_id
1562 AND time_period_id = enc_control_rec.time_period_id
1563 AND payroll_id = enc_control_rec.payroll_id
1564 AND person_id = enc_sum_lines_g1_rec.person_id
1565 AND assignment_id = enc_sum_lines_g1_rec.assignment_id
1566 AND dr_cr_flag = enc_sum_lines_g1_rec.dr_cr_flag
1567 AND gl_code_combination_id = enc_sum_lines_g1_rec.gl_ccid
1568 AND gl_project_flag = enc_sum_lines_g1_rec.gl_project_flag;
1569
1570 END LOOP;
1571
1572 END LOOP;
1573 ELSIF l_time_para_value = '2' and l_gl_para_value = '2' THEN
1574 OPEN enc_control_cur;
1575 LOOP
1576 FETCH enc_control_cur INTO enc_control_rec;
1577 IF enc_control_cur%NOTFOUND THEN
1578 CLOSE enc_control_cur;
1579 EXIT;
1580 END IF;
1581
1582 OPEN enc_sum_lines_g2_cur(enc_control_rec.enc_control_id);
1583 LOOP
1584 FETCH enc_sum_lines_g2_cur INTO enc_sum_lines_g2_rec;
1585 IF enc_sum_lines_g2_cur%ROWCOUNT = 0 THEN
1586 CLOSE enc_sum_lines_g2_cur;
1587 EXIT;
1588 ELSIF enc_sum_lines_g2_cur%NOTFOUND THEN
1589 update psp_enc_controls
1590 set gl_phase = 'Summarize' ---replaced NULL for 2444657
1591 where enc_control_id = enc_control_rec.enc_control_id;
1592 CLOSE enc_sum_lines_g2_cur;
1593 EXIT;
1594 END IF;
1595
1596 insert_into_enc_sum_lines(
1597 l_enc_summary_line_id,
1598 l_bg_id,
1599 enc_control_rec.enc_control_id,
1600 enc_control_rec.time_period_id,
1601 enc_sum_lines_g2_rec.person_id,
1602 NULL,
1603 enc_sum_lines_g2_rec.eff_dt,
1604 enc_sum_lines_g2_rec.set_of_books_id,
1605 enc_sum_lines_g2_rec.gl_ccid,
1606 NULL,
1607 NULL,
1608 NULL,
1609 NULL,
1610 NULL,
1611 enc_sum_lines_g2_rec.sum_amt,
1612 enc_sum_lines_g2_rec.dr_cr_flag,
1613 'N',
1614 enc_control_rec.payroll_id,
1615 NULL,
1616 enc_sum_lines_g2_rec.gl_project_flag,
1617 l_return_status);
1618
1619 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1620 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1621 END IF;
1622
1623 UPDATE psp_enc_lines
1624 SET enc_summary_line_id = l_enc_summary_line_id
1625 WHERE enc_control_id = enc_control_rec.enc_control_id
1626 AND payroll_id = enc_control_rec.payroll_id
1627 AND time_period_id = enc_control_rec.time_period_id
1628 AND person_id = enc_sum_lines_g2_rec.person_id
1629 AND dr_cr_flag = enc_sum_lines_g2_rec.dr_cr_flag
1630 AND gl_code_combination_id = enc_sum_lines_g2_rec.gl_ccid
1631 AND gl_project_flag = enc_sum_lines_g2_rec.gl_project_flag;
1632
1633 END LOOP;
1634
1635 END LOOP;
1636 ELSIF l_time_para_value = '2' and l_gl_para_value = '1' THEN
1637 OPEN enc_control_cur;
1638 LOOP
1639 FETCH enc_control_cur INTO enc_control_rec;
1640 IF enc_control_cur%NOTFOUND THEN
1641 CLOSE enc_control_cur;
1642 EXIT;
1643 END IF;
1644
1645 OPEN enc_sum_lines_g3_cur(enc_control_rec.enc_control_id);
1646 LOOP
1647 FETCH enc_sum_lines_g3_cur INTO enc_sum_lines_g3_rec;
1648 IF enc_sum_lines_g3_cur%ROWCOUNT = 0 THEN
1649 CLOSE enc_sum_lines_g3_cur;
1650 EXIT;
1651 ELSIF enc_sum_lines_g3_cur%NOTFOUND THEN
1652 update psp_enc_controls
1653 set gl_phase = 'Summarize' -- replaced NULL for 2444657
1654 where enc_control_id = enc_control_rec.enc_control_id;
1655 CLOSE enc_sum_lines_g3_cur;
1656 EXIT;
1657 END IF;
1658
1659 insert_into_enc_sum_lines(
1660 l_enc_summary_line_id,
1661 l_bg_id,
1662 enc_control_rec.enc_control_id,
1663 enc_control_rec.time_period_id,
1664 NULL,
1665 NULL,
1666 enc_sum_lines_g3_rec.eff_dt,
1667 enc_sum_lines_g3_rec.set_of_books_id,
1668 enc_sum_lines_g3_rec.gl_ccid,
1669 NULL,
1670 NULL,
1671 NULL,
1672 NULL,
1673 NULL,
1674 enc_sum_lines_g3_rec.sum_amt,
1675 enc_sum_lines_g3_rec.dr_cr_flag,
1676 'N',
1677 enc_control_rec.payroll_id,
1678 NULL,
1679 enc_sum_lines_g3_rec.gl_project_flag,
1680 l_return_status);
1681
1682 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1683 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1684 END IF;
1685
1686 UPDATE psp_enc_lines
1687 SET enc_summary_line_id = l_enc_summary_line_id
1688 WHERE enc_control_id = enc_control_rec.enc_control_id
1689 AND payroll_id = enc_control_rec.payroll_id
1690 AND time_period_id = enc_control_rec.time_period_id
1691 AND dr_cr_flag = enc_sum_lines_g3_rec.dr_cr_flag
1692 AND gl_code_combination_id = enc_sum_lines_g3_rec.gl_ccid
1693 AND gl_project_flag = enc_sum_lines_g3_rec.gl_project_flag;
1694
1695 END LOOP;
1696
1697 END LOOP;
1698
1699 END IF; -- Commented this END IF as part of Enh. 2143723
1700 *************************************************************************************************** /
1701
1702 p_return_status := fnd_api.g_ret_sts_success;
1703
1704 EXCEPTION
1705 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1706 g_error_api_path := 'CREATE_GL_ENC_SUM_LINES:'||g_error_api_path;
1707 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN','ENC_SUM_TRANS');
1708 p_return_status := fnd_api.g_ret_sts_unexp_error;
1709 WHEN OTHERS THEN
1710 g_error_api_path := 'CREATE_GL_ENC_SUM_LINES:'||g_error_api_path;
1711 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN','CREATE_GL_ENC_SUM_LINES');
1712 p_return_status := fnd_api.g_ret_sts_unexp_error;
1713 END;
1714 End of comment for Create and Update enh. *****/
1715
1716 -- ##########################################################################
1717 -- This procedure inserts records into psp_enc_summary_lines
1718 -- ##########################################################################
1719
1720 PROCEDURE insert_into_enc_sum_lines(
1721 p_enc_summary_line_id OUT NOCOPY NUMBER,
1722 p_business_group_id IN NUMBER,
1723 p_enc_control_id IN NUMBER,
1724 p_time_period_id IN NUMBER,
1725 p_person_id IN NUMBER,
1726 p_assignment_id IN NUMBER,
1727 p_effective_date IN DATE,
1728 p_set_of_books_id IN NUMBER,
1729 p_gl_code_combination_id IN NUMBER,
1730 p_project_id IN NUMBER,
1731 p_expenditure_organization_id IN NUMBER,
1732 p_expenditure_type IN VARCHAR2,
1733 p_task_id IN NUMBER,
1734 p_award_id IN NUMBER,
1735 p_summary_amount IN NUMBER,
1736 p_dr_cr_flag IN VARCHAR2,
1737 p_status_code IN VARCHAR2,
1738 p_payroll_id IN NUMBER,
1739 p_gl_period_id IN NUMBER,
1740 p_gl_project_flag IN VARCHAR2,
1741 p_attribute_category IN VARCHAR2, -- Introduced DFF columns for bug fix 2908859
1742 p_attribute1 IN VARCHAR2,
1743 p_attribute2 IN VARCHAR2,
1744 p_attribute3 IN VARCHAR2,
1745 p_attribute4 IN VARCHAR2,
1746 p_attribute5 IN VARCHAR2,
1747 p_attribute6 IN VARCHAR2,
1748 p_attribute7 IN VARCHAR2,
1749 p_attribute8 IN VARCHAR2,
1750 p_attribute9 IN VARCHAR2,
1751 p_attribute10 IN VARCHAR2,
1752 p_return_status OUT NOCOPY VARCHAR2
1753 ) IS
1754 BEGIN
1755 SELECT PSP_ENC_SUMMARY_LINES_S.NEXTVAL
1756 INTO P_ENC_SUMMARY_LINE_ID
1757 FROM DUAL;
1758 INSERT INTO PSP_ENC_SUMMARY_LINES(
1759 ENC_SUMMARY_LINE_ID,
1760 BUSINESS_GROUP_ID,
1761 ENC_CONTROL_ID,
1762 TIME_PERIOD_ID,
1763 PERSON_ID,
1764 ASSIGNMENT_ID,
1765 EFFECTIVE_DATE,
1766 SET_OF_BOOKS_ID,
1767 GL_CODE_COMBINATION_ID,
1768 PROJECT_ID,
1769 EXPENDITURE_ORGANIZATION_ID,
1770 EXPENDITURE_TYPE,
1771 TASK_ID,
1772 AWARD_ID,
1773 SUMMARY_AMOUNT,
1774 DR_CR_FLAG,
1775 STATUS_CODE,
1776 PAYROLL_ID,
1777 GL_PERIOD_ID,
1778 GL_PROJECT_FLAG,
1779 ATTRIBUTE_CATEGORY, -- Introduced DFF columns for bug fix 2908859
1780 ATTRIBUTE1,
1781 ATTRIBUTE2,
1782 ATTRIBUTE3,
1783 ATTRIBUTE4,
1784 ATTRIBUTE5,
1785 ATTRIBUTE6,
1786 ATTRIBUTE7,
1787 ATTRIBUTE8,
1788 ATTRIBUTE9,
1789 ATTRIBUTE10,
1790 LAST_UPDATE_DATE,
1791 LAST_UPDATED_BY,
1792 LAST_UPDATE_LOGIN,
1793 CREATED_BY,
1794 CREATION_DATE)
1795 VALUES(
1796 p_enc_summary_line_id,
1797 p_business_group_id,
1798 p_enc_control_id,
1799 p_time_period_id,
1800 nvl(p_person_id,NULL),
1801 nvl(p_assignment_id,NULL),
1802 p_effective_date,
1803 p_set_of_books_id,
1804 p_gl_code_combination_id,
1805 p_project_id,
1806 p_expenditure_organization_id,
1807 p_expenditure_type,
1808 p_task_id,
1809 p_award_id,
1810 p_summary_amount,
1811 p_dr_cr_flag,
1812 p_status_code,
1813 p_payroll_id,
1814 p_gl_period_id,
1815 p_gl_project_flag,
1816 p_attribute_category, -- Introduced DFF columns for bug fix 2908859
1817 p_attribute1,
1818 p_attribute2,
1819 p_attribute3,
1820 p_attribute4,
1821 p_attribute5,
1822 p_attribute6,
1823 p_attribute7,
1824 p_attribute8,
1825 p_attribute9,
1826 p_attribute10,
1827 SYSDATE,
1828 FND_GLOBAL.USER_ID,
1829 FND_GLOBAL.LOGIN_ID,
1830 FND_GLOBAL.USER_ID,
1831 SYSDATE);
1832 p_return_status := fnd_api.g_ret_sts_success;
1833 EXCEPTION
1834 WHEN OTHERS THEN
1835 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
1836 g_error_api_path := 'INSERT_INTO_ENC_SUM_LINES:'||g_error_api_path;
1837 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN','INSERT_INTO_ENC_SUM_LINES');
1838 p_return_status := fnd_api.g_ret_sts_unexp_error;
1839 END;
1840
1841 -- ##########################################################################
1842 -- This procedure transfers the summarized lines from psp_enc_summary_lines
1843 -- with gl_project_flag = 'G' to gl_interface
1844
1845 -- This procedure transfers the summarized lines from PSP_ENC_SUMMARY_LINES table
1846 -- to GL_INTERFACE table and kicks off the JOURNAL IMPORT program in GL and sends
1847 -- ENC_CONTROL_ID and END_DATE for the relevant TIME_PERIOD_ID
1848 -- and GROUP_ID into the tie back procedure
1849 -- ##########################################################################
1850 /****** Commented for Create and Update multi thread enh.
1851 PROCEDURE tr_to_gl_int(p_payroll_id IN NUMBER,
1852 p_return_status OUT NOCOPY VARCHAR2
1853 ) IS
1854
1855 CURSOR enc_control_cur IS
1856 SELECT enc_control_id,
1857 payroll_id,
1858 time_period_id,
1859 gl_phase --- added for 2444657
1860 FROM psp_enc_controls
1861 WHERE payroll_id = nvl(p_payroll_id, payroll_id)
1862 AND (total_dr_amount IS NOT NULL OR total_cr_amount IS NOT NULL)
1863 AND action_type IN ('N', 'Q', 'U') -- Included 'Q' for Quick Upd. Enh. 2143723.
1864 AND action_code = 'I'
1865 AND run_id = g_run_id
1866 AND business_group_id = g_business_group_id
1867 AND set_of_books_id = g_set_of_books_id
1868 AND gl_phase in ('Summarize', 'Transfer');
1869
1870 CURSOR int_cur(l_enc_control_id IN NUMBER) IS
1871 SELECT pesl.enc_summary_line_id,
1872 pesl.effective_date,
1873 pesl.gl_code_combination_id,
1874 pesl.summary_amount,
1875 pesl.dr_cr_flag,
1876 pesl.set_of_books_id,
1877 pesl.time_period_id,
1878 pesl.attribute1,
1879 pesl.attribute2,
1880 pesl.attribute3,
1881 pesl.attribute4,
1882 pesl.attribute5,
1883 pesl.attribute6,
1884 pesl.attribute7,
1885 pesl.attribute8,
1886 pesl.attribute9,
1887 pesl.attribute10,
1888 pesl.attribute11,
1889 pesl.attribute12,
1890 pesl.attribute13,
1891 pesl.attribute14,
1892 pesl.attribute15,
1893 pesl.attribute16,
1894 pesl.attribute17,
1895 pesl.attribute18,
1896 pesl.attribute19,
1897 pesl.attribute20,
1898 pesl.attribute21,
1899 pesl.attribute22,
1900 pesl.attribute23,
1901 pesl.attribute24,
1902 pesl.attribute25,
1903 pesl.attribute26,
1904 pesl.attribute27,
1905 pesl.attribute28,
1906 pesl.attribute29,
1907 pesl.attribute30
1908 FROM psp_enc_summary_lines pesl
1909 WHERE pesl.status_code = 'N'
1910 AND pesl.enc_control_id = l_enc_control_id
1911 AND pesl.payroll_id = p_payroll_id
1912 AND pesl.gl_code_combination_id is NOT NULL;
1913
1914 enc_control_rec enc_control_cur%ROWTYPE;
1915 int_rec int_cur%ROWTYPE;
1916
1917 l_bg_id NUMBER(15) := g_business_group_id;
1918 l_sob_id NUMBER(15);
1919 l_status VARCHAR2(50);
1920 l_acc_date DATE;
1921 l_user_je_cat VARCHAR2(25);
1922 l_user_je_source VARCHAR2(25);
1923 l_period_name VARCHAR2(35);
1924 l_period_end_dt DATE;
1925 l_enc_type_id NUMBER(15);
1926 l_ent_dr NUMBER;
1927 l_ent_cr NUMBER;
1928 l_group_id NUMBER;
1929 l_int_run_id NUMBER;
1930 l_ref1 VARCHAR2(100);
1931 l_ref4 VARCHAR2(100);
1932
1933 l_return_status VARCHAR2(10);
1934 req_id NUMBER(15);
1935 call_status BOOLEAN;
1936 rphase VARCHAR2(30);
1937 rstatus VARCHAR2(30);
1938 dphase VARCHAR2(30);
1939 dstatus VARCHAR2(30);
1940 message VARCHAR2(240);
1941 p_errbuf VARCHAR2(32767);
1942 p_retcode VARCHAR2(32767);
1943 return_back EXCEPTION;
1944 l_rec_count NUMBER := 0;
1945 l_error VARCHAR2(100);
1946 l_product VARCHAR2(3);
1947 l_value VARCHAR2(200);
1948 l_table VARCHAR2(100);
1949 l_rec_no number := 0;
1950 / * Following variable is added for Enh.Encumbrance Redesign Prorata * /
1951
1952 l_summarization_option VARCHAR2 (1) := nvl (fnd_profile.value('PSP_ENABLE_ENC_SUMM_GL'),'N');
1953
1954 TYPE GL_TIE_RECTYPE IS RECORD (
1955 R_CONTROL_ID NUMBER,
1956 R_END_DATE DATE,
1957 R_GROUP_ID NUMBER); ---- added group_id for 2444657, Summ. and Transfer will scoop all
1958 --- controls with 'I', 'N'. Those with 'N' will have
1959 -- new group_id, where as once with 'I' have old group_id
1960
1961
1962 GL_TIE_REC GL_TIE_RECTYPE;
1963
1964 TYPE GL_TIE_TABTYPE IS TABLE OF GL_TIE_REC%TYPE
1965 INDEX BY BINARY_INTEGER;
1966
1967 GL_TIE_TAB GL_TIE_TABTYPE;
1968
1969 -- Introduced the following for bug fix 4507892
1970 TYPE t_number_15_type IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
1971 TYPE r_enc_control_rec IS RECORD (enc_control_id t_number_15_type);
1972 r_enc_controls r_enc_control_rec;
1973
1974 CURSOR enc_control_id_cur IS
1975 SELECT DISTINCT enc_control_id
1976 FROM psp_enc_summary_lines
1977 WHERE group_id = l_group_id;
1978 -- End of changes for bug fix 4507892
1979 BEGIN
1980 gl_tie_tab.delete;
1981
1982 gl_je_source( l_user_je_source,
1983 l_return_status);
1984 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1985 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1986 END IF;
1987
1988 gl_je_cat( l_user_je_cat,
1989 l_return_status);
1990 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1991 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1992 END IF;
1993
1994 enc_type( l_enc_type_id,
1995 l_return_status);
1996 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1997 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1998 END IF;
1999
2000 SELECT gl_interface_control_s.nextval
2001 INTO l_group_id
2002 FROM dual;
2003
2004 OPEN enc_control_cur;
2005 LOOP
2006 FETCH enc_control_cur INTO enc_control_rec;
2007 IF enc_control_cur%NOTFOUND THEN
2008 CLOSE enc_control_cur;
2009 EXIT;
2010 END IF;
2011
2012 / * Moved this portion of the code outside the loop so as to take care of control record
2013 with no child records, Fixed as part of Enh. 2143723 (base bug 2124607).
2014 l_rec_no := l_rec_no +1;
2015
2016 gl_tie_tab(l_rec_no).r_control_id := enc_control_rec.enc_control_id;
2017
2018 UPDATE psp_enc_summary_lines
2019 SET group_id = l_group_id
2020 WHERE status_code = 'N'
2021 AND gl_code_combination_id is NOT NULL
2022 AND enc_control_id = enc_control_rec.enc_control_id;
2023 End of enh. fix 2143723 * /
2024
2025 -- For Bug 2478000
2026 -- The following was commented
2027 / *
2028 BEGIN
2029 SELECT currency_code
2030 INTO l_cur_code
2031 FROM gl_sets_of_books
2032 WHERE set_of_books_id = g_set_of_books_id;
2033 EXCEPTION
2034 WHEN NO_DATA_FOUND THEN
2035 l_error := 'CURRENCY CODE';
2036 l_product := 'GL';
2037 fnd_message.set_name('PSP','PSP_TR_NOT_SET_UP');
2038 fnd_message.set_token('ERROR',l_error);
2039 fnd_message.set_token('PRODUCT',l_product);
2040 fnd_msg_pub.add;
2041 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2042 END; * /
2043
2044 --End of bug 2478000
2045
2046 BEGIN
2047 SELECT period_name, end_date
2048 INTO l_period_name, l_period_end_dt
2049 FROM per_time_periods
2050 WHERE time_period_id = enc_control_rec.time_period_id;
2051 EXCEPTION
2052 WHEN NO_DATA_FOUND THEN
2053 l_value := 'time period id =';
2054 l_table := 'PER_TIME_PERIODS';
2055 fnd_message.set_name('PSP','PSP_TR_VALUE_NOT_FOUND');
2056 fnd_message.set_token('VALUE','l_value');
2057 fnd_message.set_token('TABLE','l_table');
2058 fnd_msg_pub.add;
2059 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2060 END;
2061
2062 ---l_rec_count := 0; -- commented for 2444657
2063 if enc_control_rec.gl_phase = 'Summarize' then ---2444657
2064 OPEN int_cur (enc_control_rec.enc_control_id);
2065 ---l_rec_count := 0;
2066 LOOP
2067 FETCH int_cur into int_rec;
2068 IF int_cur%NOTFOUND THEN
2069 CLOSE int_cur;
2070 EXIT;
2071 END IF;
2072
2073 l_sob_id := int_rec.set_of_books_id;
2074
2075 l_ref1 := l_period_name;
2076 l_ref4 := 'LD ENCUMBRANCE';
2077
2078 l_rec_count := l_rec_count + 1;
2079
2080 IF int_rec.dr_cr_flag = 'D' THEN
2081 l_ent_dr := int_rec.summary_amount;
2082 l_ent_cr := NULL;
2083 ELSIF int_rec.dr_cr_flag = 'C' THEN
2084 l_ent_dr := NULL;
2085 l_ent_cr := int_rec.summary_amount;
2086 END IF;
2087
2088 insert_into_gl_int(
2089 INT_REC.SET_OF_BOOKS_ID,
2090 INT_REC.EFFECTIVE_DATE,
2091 G_CURRENCY_CODE,
2092 L_USER_JE_CAT,
2093 L_USER_JE_SOURCE,
2094 L_ENC_TYPE_ID,
2095 INT_REC.GL_CODE_COMBINATION_ID,
2096 L_ENT_DR,
2097 L_ENT_CR,
2098 L_GROUP_ID,
2099 L_REF1,
2100 L_REF1,
2101 L_REF4,
2102 'E:' || INT_REC.ENC_SUMMARY_LINE_ID,
2103 L_REF4,
2104 INT_REC.ATTRIBUTE1,
2105 INT_REC.ATTRIBUTE2,
2106 INT_REC.ATTRIBUTE3,
2107 INT_REC.ATTRIBUTE4,
2108 INT_REC.ATTRIBUTE5,
2109 INT_REC.ATTRIBUTE6,
2110 INT_REC.ATTRIBUTE7,
2111 INT_REC.ATTRIBUTE8,
2112 INT_REC.ATTRIBUTE9,
2113 INT_REC.ATTRIBUTE10,
2114 INT_REC.ATTRIBUTE11,
2115 INT_REC.ATTRIBUTE12,
2116 INT_REC.ATTRIBUTE13,
2117 INT_REC.ATTRIBUTE14,
2118 INT_REC.ATTRIBUTE15,
2119 INT_REC.ATTRIBUTE16,
2120 INT_REC.ATTRIBUTE17,
2121 INT_REC.ATTRIBUTE18,
2122 INT_REC.ATTRIBUTE19,
2123 INT_REC.ATTRIBUTE20,
2124 INT_REC.ATTRIBUTE21,
2125 INT_REC.ATTRIBUTE22,
2126 INT_REC.ATTRIBUTE23,
2127 INT_REC.ATTRIBUTE24,
2128 INT_REC.ATTRIBUTE25,
2129 INT_REC.ATTRIBUTE26,
2130 INT_REC.ATTRIBUTE27,
2131 INT_REC.ATTRIBUTE28,
2132 INT_REC.ATTRIBUTE29,
2133 INT_REC.ATTRIBUTE30,
2134 L_RETURN_STATUS);
2135
2136 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2137 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2138 END IF;
2139 END LOOP; --int_cur loop
2140 end if; --- 2444657
2141 / * Commented out as part of bug fix #2142865
2142 gl_tie_tab(l_rec_no).r_end_date := l_period_end_dt;* /
2143 -- Introduced the following as part of Enh. 2143723 (base bug 2124607)
2144 -- (Code moved from inside int_cur loop to here)
2145 IF enc_control_rec.gl_phase = 'Summarize' THEN
2146 UPDATE psp_enc_summary_lines
2147 SET group_id = l_group_id
2148 WHERE status_code = 'N'
2149 AND gl_code_combination_id is NOT NULL
2150 AND enc_control_id = enc_control_rec.enc_control_id;
2151 if sql%rowcount > 0 then --- 2444657
2152 l_rec_no := l_rec_no +1;
2153 gl_tie_tab(l_rec_no).r_control_id := enc_control_rec.enc_control_id;
2154 gl_tie_tab(l_rec_no).r_end_date := l_period_end_dt;
2155 gl_tie_tab(l_rec_no).r_group_id := l_group_id; --- added for 2444657
2156 end if;
2157 ELSE
2158 l_rec_no := l_rec_no +1;
2159 gl_tie_tab(l_rec_no).r_control_id := enc_control_rec.enc_control_id;
2160 gl_tie_tab(l_rec_no).r_end_date := l_period_end_dt;
2161 select group_id
2162 into gl_tie_tab(l_rec_no).r_group_id
2163 from psp_enc_summary_lines
2164 where gl_code_combination_id is NOT NULL
2165 AND enc_control_id = enc_control_rec.enc_control_id
2166 AND rownum =1;
2167 END IF;
2168
2169 END LOOP; -- enc_cur
2170
2171 IF l_rec_count > 0 THEN --- replaced l_rec_no with l_rec_count ..2444657
2172
2173 SELECT GL_JOURNAL_IMPORT_S.NEXTVAL
2174 INTO l_int_run_id
2175 FROM dual;
2176
2177 insert into gl_interface_control(
2178 je_source_name,
2179 status,
2180 interface_run_id,
2181 group_id,
2182 set_of_books_id)
2183 VALUES (
2184 l_user_je_source,
2185 'S',
2186 l_int_run_id,
2187 l_group_id,
2188 l_sob_id
2189 );
2190 -- Commented out the commit as we commit after submitting the request, 11i
2191
2192 -- COMMIT;
2193 req_id := fnd_request.submit_request(
2194 'SQLGL',
2195 'GLLEZL',
2196 '',
2197 '',
2198 FALSE,
2199 to_char(l_int_run_id),
2200 to_char(l_sob_id),
2201 'N',
2202 '',
2203 '',
2204 l_summarization_option, --Added for Enh. Enc Redesign, Bug #2259310.
2205 'W'); -- Changed 'n' to 'W' for bug fix 2908859
2206
2207 IF req_id = 0 THEN
2208
2209 fnd_message.set_name('PSP','PSP_TR_GL_IMP_FAILED');
2210 fnd_msg_pub.add;
2211 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2212
2213 ELSE
2214 / ***** Converted the following UPDATE to BULK for R12 performance fixes
2215 UPDATE psp_enc_controls
2216 SET gl_phase = 'Transfer'
2217 WHERE enc_control_id in (select distinct enc_control_id
2218 from psp_enc_summary_lines
2219 where group_id = l_group_id);
2220 End of comment for bug fix 4507892 ***** /
2221
2222 -- Introduced the following for bug fix 4507892
2223 OPEN enc_control_id_cur;
2224 FETCH enc_control_id_cur BULK COLLECT INTO r_enc_controls.enc_control_id;
2225 CLOSE enc_control_id_cur;
2226
2227 FORALL I IN 1..r_enc_controls.enc_control_id.COUNT
2228 UPDATE psp_enc_controls
2229 SET gl_phase = 'Transfer'
2230 WHERE enc_control_id = r_enc_controls.enc_control_id(I);
2231
2232 r_enc_controls.enc_control_id.DELETE;
2233 -- End of changes for bug fix 4507892
2234
2235 COMMIT;
2236 call_status := fnd_concurrent.wait_for_request(req_id, 20, 0,
2237 rphase, rstatus, dphase, dstatus, message);
2238
2239 IF call_status = FALSE then
2240 fnd_message.set_name('PSP','PSP_TR_GL_IMP_FAILED');
2241 fnd_msg_pub.add;
2242 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2243 END IF;
2244 END IF;
2245 END IF; -- l_rec_count > 0 --- moved from below ... for 2444657
2246
2247 for i in 1..gl_tie_tab.count
2248 loop
2249 / * Commented as part of bug fix #1776606
2250 gl_enc_tie_back(gl_tie_tab(i).r_control_id,
2251 gl_tie_tab(i).r_end_date, l_group_id, g_business_group_id, g_set_of_books_id, l_return_status); * /
2252
2253 / * Included as part of Bug fix # 1776606 * /
2254 gl_enc_tie_back(gl_tie_tab(i).r_control_id,
2255 gl_tie_tab(i).r_end_date,
2256 gl_tie_tab(i).r_group_id, --- replaced l_group_id for 2444657,
2257 g_business_group_id, g_set_of_books_id, 'N',
2258 l_return_status);
2259 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2260 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2261 END IF;
2262
2263 end loop;
2264 / *
2265 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2266 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2267 END IF;
2268 -- moved inside the loop
2269
2270 For Bug fix 1776606
2271 * /
2272
2273 --- added this wrapper loop on delete gl_interface for 2444657
2274 --- this is to ensure that all interface recs are purged, incase
2275 -- the previous Ssummarize and Transfer did not
2276 for i in 1..gl_tie_tab.count
2277 loop
2278 if gl_tie_tab(i).r_group_id is not null then
2279 delete gl_interface
2280 where group_id = gl_tie_tab(i).r_group_id
2281 and user_je_source_name = l_user_je_source
2282 and set_of_books_id = l_sob_id;
2283
2284 for k in 1..gl_tie_tab.count
2285 loop
2286 if gl_tie_tab(i).r_group_id = gl_tie_tab(k).r_group_id and
2287 i <> k then
2288 gl_tie_tab(k).r_group_id := null;
2289 end if;
2290 end loop;
2291
2292 gl_tie_tab(i).r_group_id := null;
2293 end if;
2294 end loop;
2295 COMMIT; -- moved the commit from above for 2479579
2296 if g_susp_prob = 'Y' then -- introduced this IF stmnt for 2479579
2297 enc_batch_end(g_payroll_action_id,
2298 l_return_status);
2299 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2300 end if;
2301
2302 p_return_status := fnd_api.g_ret_sts_success;
2303
2304 EXCEPTION
2305 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2306 g_error_api_path := 'TR_TO_GL_INT:'||g_error_api_path;
2307 p_return_status := fnd_api.g_ret_sts_unexp_error;
2308
2309 WHEN RETURN_BACK THEN
2310 p_return_status := fnd_api.g_ret_sts_success;
2311
2312 WHEN OTHERS THEN
2313 g_error_api_path := 'TR_TO_GL_INT:'||g_error_api_path;
2314 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN','TR_TO_GL_INT');
2315 p_return_status := fnd_api.g_ret_sts_unexp_error;
2316 END;
2317 End of comment for Create and Update multi thread enh. *****/
2318
2319 -- Introduced the following modified tr_to_gl_int procedure for Create and Update multi thread enh.
2320 PROCEDURE tr_to_gl_int( p_payroll_action_id IN NUMBER,
2321 p_return_status OUT NOCOPY VARCHAR2) IS
2322 l_user_je_cat VARCHAR2(25);
2323 l_user_je_source VARCHAR2(25);
2324 l_enc_type_id NUMBER(15);
2325 l_group_id NUMBER;
2326 l_int_run_id NUMBER;
2327 l_return_status VARCHAR2(10);
2328 req_id NUMBER(15);
2329 call_status BOOLEAN;
2330 rphase VARCHAR2(30);
2331 rstatus VARCHAR2(30);
2332 dphase VARCHAR2(30);
2333 dstatus VARCHAR2(30);
2334 message VARCHAR2(240);
2335 l_tie_back_failed VARCHAR2(1);
2336 l_summarization_option VARCHAR2 (1);
2337
2338 TYPE t_number_15 IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
2339
2340 TYPE r_enc_controls_rec IS RECORD (enc_control_id t_number_15);
2341 r_enc_controls r_enc_controls_rec;
2342
2343 TYPE r_group_rec IS RECORD (group_id t_number_15);
2344 r_groups r_group_rec;
2345
2346 l_created_by NUMBER(15);
2347
2348 CURSOR gl_group_id_cur IS
2349 SELECT DISTINCT group_id
2350 FROM psp_enc_summary_lines pesl
2351 WHERE payroll_action_id = p_payroll_action_id
2352 AND status_code = 'N'
2353 AND superceded_line_id IS NULL
2354 AND gl_code_combination_id IS NOT NULL;
2355
2356 CURSOR enc_control_id_cur IS
2357 SELECT enc_control_id
2358 FROM psp_enc_controls
2359 WHERE payroll_action_id = p_payroll_action_id;
2360 BEGIN
2361 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Entering Transfer to GL Interface');
2362
2363 l_created_by := fnd_global.user_id;
2364 l_tie_back_failed := NULL;
2365 l_summarization_option := NVL(fnd_profile.value('PSP_ENABLE_ENC_SUMM_GL'),'N');
2366
2367 gl_je_source( l_user_je_source,
2368 l_return_status);
2369
2370 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2371 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2372 END IF;
2373
2374 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' l_user_je_source: ' || l_user_je_source);
2375
2376 gl_je_cat( l_user_je_cat,
2377 l_return_status);
2378 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2379 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2380 END IF;
2381
2382 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' l_user_je_cat: ' || l_user_je_cat);
2383
2384 enc_type( l_enc_type_id,
2385 l_return_status);
2386 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2387 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2388 END IF;
2389
2390 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' l_enc_type_id: ' || l_enc_type_id);
2391
2392 SELECT gl_interface_control_s.nextval
2393 INTO l_group_id
2394 FROM dual;
2395
2396 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' l_group_id: ' || l_group_id);
2397
2398 UPDATE psp_enc_summary_lines pesl
2399 SET group_id = l_group_id
2400 WHERE status_code = 'N'
2401 AND gl_code_combination_id IS NOT NULL
2402 AND group_id IS NULL
2403 AND superceded_line_id IS NULL
2404 AND NOT EXISTS (SELECT 1
2405 FROM psp_enc_summary_lines pesl2
2406 WHERE pesl2.payroll_action_id = p_payroll_action_id
2407 AND pesl2.assignment_id = pesl.assignment_id
2408 AND pesl2.time_period_id = pesl.time_period_id
2409 AND pesl2.status_code IN ('N', 'R')
2410 AND pesl2.superceded_line_id IS NOT NULL)
2411 AND payroll_action_id = p_payroll_action_id;
2412
2413 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated group_id in psp_enc_summary_lines for new liquidation lines count: '||sql%rowcount);
2414 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'Inserting into gl_interface');
2415 INSERT INTO gl_interface
2416 (status, set_of_books_id, accounting_date,
2417 currency_code, date_created, created_by,
2418 actual_flag, user_je_category_name, user_je_source_name,
2419 encumbrance_type_id, code_combination_id, entered_dr,
2420 entered_cr, group_id, reference1,
2421 reference2, reference4, reference6,
2422 reference10, attribute1, attribute2,
2423 attribute3, attribute4, attribute5,
2424 attribute6, attribute7, attribute8,
2425 attribute9, attribute10, attribute11,
2426 attribute12, attribute13, attribute14,
2427 attribute15, attribute16, attribute17,
2428 attribute18, attribute19, attribute20,
2429 reference21, reference22, reference23,
2430 reference24, reference25, reference26,
2431 reference27, reference28, reference29,
2432 reference30)
2433 SELECT 'NEW', pesl.set_of_books_id, pesl.effective_date,
2434 DECODE(pec.uom, 'M', g_currency_code, 'STAT'), SYSDATE, l_created_by,
2435 'E', l_user_je_cat, l_user_je_source,
2436 l_enc_type_id, pesl.gl_code_combination_id,
2437 TO_NUMBER(DECODE(dr_cr_flag, 'D', pesl.summary_amount, NULL)) debit_amount,
2438 TO_NUMBER(DECODE(dr_cr_flag, 'C', pesl.summary_amount, NULL)) credit_amount,
2439 l_group_id, pesl.enc_control_id,
2440 pesl.enc_control_id, 'LD ENCUMBRANCE', 'E:' || pesl.enc_summary_line_id,
2441 'LD ENCUMBRANCE', pesl.attribute1, pesl.attribute2,
2442 pesl.attribute3, pesl.attribute4, pesl.attribute5,
2443 pesl.attribute6, pesl.attribute7, pesl.attribute8,
2444 pesl.attribute9, pesl.attribute10, pesl.attribute11,
2445 pesl.attribute12, pesl.attribute13, pesl.attribute14,
2446 pesl.attribute15, pesl.attribute16, pesl.attribute17,
2447 pesl.attribute18, pesl.attribute19, pesl.attribute20,
2448 pesl.attribute21, pesl.attribute22, pesl.attribute23,
2449 pesl.attribute24, pesl.attribute25, pesl.attribute26,
2450 pesl.attribute27, pesl.attribute28, pesl.attribute29,
2451 pesl.attribute30
2452 FROM psp_enc_summary_lines pesl,
2453 psp_enc_controls pec
2454 WHERE pec.enc_control_id = pesl.enc_control_id
2455 AND pec.payroll_action_id = p_payroll_action_id
2456 AND pesl.status_code = 'N'
2457 AND pesl.gl_code_combination_id is NOT NULL
2458 AND pesl.superceded_line_id IS NULL
2459 AND pesl.group_id = l_group_id
2460 AND pesl.payroll_action_id = p_payroll_action_id;
2461
2462 IF (SQL%ROWCOUNT > 0) THEN
2463 SELECT GL_JOURNAL_IMPORT_S.NEXTVAL
2464 INTO l_int_run_id
2465 FROM DUAL;
2466
2467 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' l_int_run_id: ' || l_int_run_id);
2468
2469 INSERT INTO gl_interface_control
2470 (je_source_name, status, interface_run_id,
2471 group_id, set_of_books_id)
2472 VALUES (l_user_je_source, 'S', l_int_run_id,
2473 l_group_id, g_set_of_books_id);
2474
2475 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Inserted control record into gl_interface_control');
2476 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Before submitting Journal Import');
2477
2478 req_id := fnd_request.submit_request( 'SQLGL',
2479 'GLLEZL',
2480 '',
2481 '',
2482 FALSE,
2483 TO_CHAR(l_int_run_id),
2484 TO_CHAR(g_set_of_books_id),
2485 'N',
2486 '',
2487 '',
2488 l_summarization_option,
2489 'W');
2490
2491 IF req_id = 0 THEN
2492 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Journal Import submission failed');
2493 fnd_message.set_name('PSP','PSP_TR_GL_IMP_FAILED');
2494 fnd_msg_pub.add;
2495 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2496 ELSE
2497 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Submitted Journal Import (req_id: ' || req_id || ')');
2498 OPEN enc_control_id_cur;
2499 FETCH enc_control_id_cur BULK COLLECT INTO r_enc_controls.enc_control_id;
2500 CLOSE enc_control_id_cur;
2501
2502 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' r_enc_controls.enc_control_id.COUNT: ' || r_enc_controls.enc_control_id.COUNT);
2503
2504 FORALL I IN 1..r_enc_controls.enc_control_id.COUNT
2505 UPDATE psp_enc_controls
2506 SET gl_phase = 'Transfer'
2507 WHERE enc_control_id = r_enc_controls.enc_control_id(I);
2508
2509
2510 g_bulk_row_count :=0;
2511 FOR bulk_idx IN 1..r_enc_controls.enc_control_id.COUNT
2512 loop
2513 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
2514 end loop;
2515
2516 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated gl_phase to ''Transfer'' in psp_enc_controls count:'||g_bulk_row_count);
2517
2518 r_enc_controls.enc_control_id.DELETE;
2519
2520 COMMIT;
2521
2522 -- fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling gather_table_stats for psp_enc_summary_lines');
2523 --fnd_stats.gather_table_stats('PSP', 'PSP_ENC_SUMMARY_LINES');
2524 --fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Completed gather_table_stats for psp_enc_summary_lines');
2525
2526 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Waiting for Journal Import request to complete');
2527
2528 call_status := fnd_concurrent.wait_for_request(req_id, 10, 0, rphase, rstatus, dphase, dstatus, message);
2529
2530 IF call_status = FALSE THEN
2531 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Journal Import failed');
2532 fnd_message.set_name('PSP','PSP_TR_GL_IMP_FAILED');
2533 fnd_msg_pub.add;
2534 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2535 END IF;
2536 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Journal Import completed');
2537 END IF;
2538 END IF;
2539
2540 OPEN gl_group_id_cur;
2541 FETCH gl_group_id_cur BULK COLLECT INTO r_groups.group_id;
2542 CLOSE gl_group_id_cur;
2543
2544 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' r_groups.group_id.COUNT: ' || r_groups.group_id.COUNT);
2545
2546 FOR recno IN 1..r_groups.group_id.COUNT
2547 LOOP
2548 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling gl_enc_tie_back for group_id: ' || r_groups.group_id(recno));
2549
2550 gl_enc_tie_back(p_payroll_action_id,
2551 r_groups.group_id(recno),
2552 g_business_group_id,
2553 g_set_of_books_id,
2554 'N',
2555 l_return_status);
2556
2557 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2558 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2559 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' gl_enc_tie_back failed for group_id: ' || r_groups.group_id(recno));
2560 ELSE
2561 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' gl_enc_tie_back successful for group_id: ' || r_groups.group_id(recno));
2562 END IF;
2563 END LOOP;
2564
2565 FORALL recno IN 1..r_groups.group_id.COUNT
2566 DELETE gl_interface
2567 WHERE group_id = r_groups.group_id(recno)
2568 AND user_je_source_name = l_user_je_source
2569 AND set_of_books_id = g_set_of_books_id;
2570
2571 g_bulk_row_count :=0;
2572 FOR bulk_idx IN 1..r_groups.group_id.COUNT
2573 loop
2574 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
2575 end loop;
2576
2577 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted groups from gl_interface for which gl_enc_tie_back is complete count: '||g_bulk_row_count);
2578
2579 FORALL recno IN 1..r_groups.group_id.COUNT
2580 UPDATE psp_enc_summary_lines
2581 SET group_id = NULL
2582 WHERE group_id = r_groups.group_id(recno)
2583 AND status_code = 'N';
2584
2585 g_bulk_row_count :=0;
2586 FOR bulk_idx IN 1..r_groups.group_id.COUNT
2587 loop
2588 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
2589 end loop;
2590
2591 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Set the un-imported summary lines to New status count: '||g_bulk_row_count);
2592
2593 COMMIT;
2594 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' COMMITted gl_enc_tie_back');
2595
2596 p_return_status := fnd_api.g_ret_sts_success;
2597 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving TR_TO_GL_INT');
2598 EXCEPTION
2599 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2600 g_error_api_path := 'TR_TO_GL_INT:'||g_error_api_path;
2601 p_return_status := fnd_api.g_ret_sts_unexp_error;
2602 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving TR_TO_GL_INT');
2603 WHEN OTHERS THEN
2604 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
2605 g_error_api_path := 'TR_TO_GL_INT:'||g_error_api_path;
2606 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN','TR_TO_GL_INT');
2607 p_return_status := fnd_api.g_ret_sts_unexp_error;
2608 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving TR_TO_GL_INT');
2609 END tr_to_gl_int;
2610 -- End of changes for Create and Update multi thread enh.
2611
2612 -- ##########################################################################
2613 -- This procedure retrieves the user_je_source_name from gl_je_sources
2614 -- ##########################################################################
2615
2616 PROCEDURE gl_je_source( P_USER_JE_SOURCE_NAME OUT NOCOPY VARCHAR2,
2617 P_RETURN_STATUS OUT NOCOPY VARCHAR2) IS
2618 l_error VARCHAR2(100);
2619 l_product VARCHAR2(3);
2620 BEGIN
2621 SELECT user_je_source_name
2622 INTO p_user_je_source_name
2623 FROM gl_je_sources
2624 WHERE je_source_name = 'OLD';
2625 EXCEPTION
2626 WHEN NO_DATA_FOUND THEN
2627 l_error := 'JE SOURCES = OLD';
2628 l_product := 'GL';
2629 fnd_message.set_name('PSP','PSP_TR_NOT_SET_UP');
2630 fnd_message.set_token('ERROR',l_error);
2631 fnd_message.set_token('PRODUCT',l_product);
2632 fnd_msg_pub.add;
2633 p_return_status := fnd_api.g_ret_sts_unexp_error;
2634 WHEN OTHERS THEN
2635 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
2636 g_error_api_path := 'gl_je_source:'||g_error_api_path;
2637 fnd_msg_pub.add_exc_msg('psp_enc_sum_tran','gl_je_source');
2638 p_return_status := fnd_api.g_ret_sts_unexp_error;
2639 END;
2640
2641 -- ##########################################################################
2642 -- This procedure retrieves the user_je_category_name from gl_je_categories
2643 -- ##########################################################################
2644
2645 PROCEDURE gl_je_cat( P_USER_JE_CATEGORY_NAME OUT NOCOPY VARCHAR2,
2646 P_RETURN_STATUS OUT NOCOPY VARCHAR2) IS
2647 l_error VARCHAR2(100);
2648 l_product VARCHAR2(3);
2649 BEGIN
2650 SELECT user_je_category_name
2651 INTO p_user_je_category_name
2652 FROM gl_je_categories
2653 WHERE je_category_name = 'OLD';
2654 EXCEPTION
2655 WHEN NO_DATA_FOUND THEN
2656 l_error := 'JE CATEGORY = OLD';
2657 l_product := 'GL';
2658 fnd_message.set_name('PSP','PSP_TR_NOT_SET_UP');
2659 fnd_message.set_token('ERROR',l_error);
2660 fnd_message.set_token('PRODUCT',l_product);
2661 fnd_msg_pub.add;
2662 p_return_status := fnd_api.g_ret_sts_unexp_error;
2663 WHEN OTHERS THEN
2664 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
2665 g_error_api_path := 'gl_je_cat:'||g_error_api_path;
2666 fnd_msg_pub.add_exc_msg('psp_enc_sum_tran','gl_je_cat');
2667 p_return_status := fnd_api.g_ret_sts_unexp_error;
2668 END;
2669
2670 -- ##########################################################################
2671 -- This procedure retrieves the encumbrance_type_id from gl_encumbrance_types
2672 -- ##########################################################################
2673
2674 PROCEDURE enc_type( P_ENCUMBRANCE_TYPE_ID OUT NOCOPY VARCHAR2,
2675 P_RETURN_STATUS OUT NOCOPY VARCHAR2) IS
2676 l_error VARCHAR2(100);
2677 l_product VARCHAR2(3);
2678
2679 BEGIN
2680 SELECT encumbrance_type_id
2681 INTO p_encumbrance_type_id
2682 FROM gl_encumbrance_types
2683 WHERE encumbrance_type = 'OLD'
2684 AND enabled_flag = 'Y';
2685
2686 EXCEPTION
2687 WHEN NO_DATA_FOUND THEN
2688 l_error := 'ENCUMBRANCE TYPE = OLD';
2689 l_product := 'GL';
2690 fnd_message.set_name('PSP','PSP_TR_NOT_SET_UP');
2691 fnd_message.set_token('ERROR',l_error);
2692 fnd_message.set_token('PRODUCT',l_product);
2693 fnd_msg_pub.add;
2694 p_return_status := fnd_api.g_ret_sts_unexp_error;
2695 WHEN OTHERS THEN
2696 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
2697 g_error_api_path := 'enc_type:'||g_error_api_path;
2698 fnd_msg_pub.add_exc_msg('psp_enc_sum_tran','enc_type');
2699 p_return_status := fnd_api.g_ret_sts_unexp_error;
2700
2701 END;
2702
2703 -- ##########################################################################
2704 -- This procedure ties back all the transactions posted into Oracle General Ledger
2705 -- with Oracle Labor Distribution where the journal import is successful.
2706 -- In case of failure the transactions in Oracle Labor Distribution are turned
2707 -- back into their original state.
2708 -- ##########################################################################
2709
2710 /***** Commented for Create and Update multi thread enh.
2711 PROCEDURE gl_enc_tie_back(
2712 p_enc_control_id IN NUMBER,
2713 p_period_end_date IN DATE,
2714 p_group_id IN NUMBER,
2715 p_business_group_id IN NUMBER,
2716 p_set_of_books_id IN NUMBER,
2717 p_mode IN VARCHAR2, -- Included as part of Bug fix #1776606s
2718 p_return_status OUT NOCOPY VARCHAR2
2719 )IS
2720 / *
2721 CURSOR enc_control_cur IS
2722 SELECT enc_control_id,
2723 time_period_id
2724 FROM psp_enc_controls
2725 WHERE payroll_id = nvl(p_payroll_id, payroll_id)
2726 AND (total_dr_amount IS NOT NULL OR total_cr_amount IS NOT NULL)
2727 AND action_type IN ('N', 'Q', 'U') -- Included 'Q' for Quick Upd. Enh. 2143723.
2728 AND action_code = 'I'
2729 AND run_id = nvl(g_run_id, run_id)
2730 AND gl_phase = 'Transfer'
2731 AND business_group_id = nvl(g_business_group_id, business_group_id)
2732 AND set_of_books_id = nvl(g_set_of_books_id, set_of_books_id);
2733 * /
2734 CURSOR gl_tie_back_success_cur IS
2735 SELECT enc_summary_line_id,
2736 dr_cr_flag,
2737 summary_amount
2738 FROM psp_enc_summary_lines
2739 WHERE group_id = p_group_id
2740 and enc_control_id = p_enc_control_id;
2741
2742
2743 CURSOR gl_tie_back_reject_cur IS
2744 SELECT status,
2745 reference6
2746 FROM gl_interface
2747 WHERE user_je_source_name = 'OLD'
2748 AND set_of_books_id = p_set_of_books_id
2749 AND group_id = p_group_id
2750 AND reference6 IN (SELECT 'E:' || enc_summary_line_id -- Introduced for bug fix 3953230
2751 FROM psp_enc_summary_lines pesl
2752 WHERE pesl.enc_control_id = p_enc_control_id);
2753
2754 CURSOR assign_susp_ac_cur(P_ENC_LINE_ID IN NUMBER) IS
2755 SELECT pel.rowid,
2756 pel.encumbrance_date,
2757 pel.suspense_org_account_id
2758 FROM psp_enc_lines pel
2759 WHERE pel.enc_summary_line_id = p_enc_line_id
2760 and enc_control_id=p_enc_control_id ; -- this added to fix suspense ac postings
2761 -- bug fix 1671938
2762
2763 -- Get the Organization details ...
2764
2765 CURSOR get_susp_org_cur(P_ORG_ID IN VARCHAR2) IS
2766 SELECT hou.organization_id, hou.name, poa.gl_code_combination_id
2767 FROM hr_all_organization_units hou, psp_organization_accounts poa
2768 WHERE hou.organization_id = poa.organization_id
2769 AND poa.business_group_id = p_business_group_id
2770 AND poa.set_of_books_id = p_set_of_books_id
2771 AND poa.organization_account_id = p_org_id;
2772 / *
2773 CURSOR get_org_id_cur(P_LINE_ID IN NUMBER) IS
2774 SELECT hou.organization_id, hou.name
2775 FROM hr_all_organization_units hou,
2776 per_assignments_f paf,
2777 psp_enc_lines pel
2778 WHERE pel.enc_summary_line_id = p_line_id
2779 AND pel.assignment_id = paf.assignment_id
2780 AND pel.encumbrance_date BETWEEN paf.effective_start_date AND paf.effective_end_date
2781 AND paf.organization_id = hou.organization_id
2782 AND pel.encumbrance_date between
2783 hou.date_from and nvl(hou.date_to,pel.encumbrance_date);
2784 * /
2785
2786
2787 CURSOR get_org_id_cur(P_ROWID IN ROWID) IS
2788 SELECT hou.organization_id, hou.name
2789 FROM hr_all_organization_units hou,
2790 per_assignments_f paf,
2791 psp_enc_lines pel
2792 WHERE
2793 -- pel.enc_summary_line_id = p_line_id
2794 pel.rowid=p_rowid
2795 AND pel.assignment_id = paf.assignment_id
2796 AND pel.encumbrance_date BETWEEN paf.effective_start_date AND paf.effective_end_date
2797 AND paf.organization_id = hou.organization_id
2798 AND pel.encumbrance_date between
2799 hou.date_from and nvl(hou.date_to,pel.encumbrance_date);
2800
2801 -- bug fix 1671938
2802 l_orig_org_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
2803 l_orig_org_id number;
2804
2805 -- End of Get org id cursor Ravindra
2806 / *
2807 CURSOR assign_susp_ac_cur(P_ENC_SUMMARY_LINE_ID IN NUMBER) IS
2808 SELECT hou.name,
2809 hou.organization_id,
2810 pel.rowid,
2811 pel.assignment_id,
2812 pel.encumbrance_date,
2813 pel.suspense_org_account_id,
2814 pel.gl_code_combination_id
2815 FROM hr_organization_units hou,
2816 per_assignments_f paf,
2817 psp_enc_lines pel
2818 WHERE pel.enc_summary_line_id = p_enc_summary_line_id
2819 AND pel.assignment_id = paf.assignment_id
2820 AND pel.encumbrance_date BETWEEN paf.effective_start_date AND paf.effective_end_date
2821 AND paf.organization_id = hou.organization_id
2822 AND pel.business_group_id = g_business_group_id
2823 AND pel.set_of_books_id = g_set_of_books_id
2824 AND pel.encumbrance_date between hou.date_from and nvl(hou.date_to,pel.encumbrance_date);
2825 * /
2826
2827 CURSOR org_susp_ac_cur(P_ORGANIZATION_ID IN NUMBER,
2828 P_ENCUMBRANCE_DATE IN DATE) IS
2829 SELECT poa.organization_account_id,
2830 poa.gl_code_combination_id,
2831 poa.project_id,
2832 poa.expenditure_organization_id,
2833 poa.expenditure_type,
2834 poa.award_id,
2835 poa.task_id
2836 FROM psp_organization_accounts poa
2837 WHERE poa.organization_id = p_organization_id
2838 AND poa.business_group_id = p_business_group_id
2839 AND poa.set_of_books_id = p_set_of_books_id
2840 AND poa.account_type_code = 'S'
2841 AND p_encumbrance_date BETWEEN poa.start_date_active AND
2842 nvl(poa.end_date_active,p_encumbrance_date);
2843
2844 -- CURSOR global_susp_ac_cur(P_ENCUMBRANCE_DATE IN DATE) IS
2845 CURSOR global_susp_ac_cur(P_ORGANIZATION_ACCOUNT_ID IN NUMBER) IS --BUG 2056877
2846 SELECT poa.organization_account_id,
2847 poa.gl_code_combination_id,
2848 poa.project_id,
2849 poa.expenditure_organization_id,
2850 poa.expenditure_type,
2851 poa.award_id,
2852 poa.task_id
2853 FROM psp_organization_accounts poa
2854 WHERE
2855 / * poa.account_type_code = 'G'
2856 AND poa.business_group_id = p_business_group_id
2857 AND poa.set_of_books_id = p_set_of_books_id
2858 AND p_distribution_date BETWEEN poa.start_date_active AND
2859 nvl(poa.end_date_active,p_distribution_date); Bug 2056877.* /
2860 organization_account_id = p_organization_account_id; --Added for bug 2056877.
2861 l_organization_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
2862 l_organization_id NUMBER(15);
2863 l_rowid ROWID;
2864 l_assignment_id NUMBER(9);
2865 l_encumbrance_date DATE;
2866 l_suspense_org_account_id NUMBER(9);
2867 l_lines_glccid NUMBER(15);
2868 l_organization_account_id NUMBER(9);
2869 l_susp_glccid NUMBER(15);
2870 l_project_id NUMBER(15);
2871 l_expenditure_organization_id NUMBER(15);
2872 l_expenditure_type VARCHAR2(30);
2873 l_award_id NUMBER(15);
2874 l_task_id NUMBER(15);
2875 l_status VARCHAR2(50);
2876 l_reference6 VARCHAR2(100);
2877 l_enc_ref VARCHAR2(100);
2878 l_cnt_gl_interface NUMBER;
2879 l_enc_summary_line_id NUMBER(10);
2880 l_gl_project_flag VARCHAR2(1);
2881 l_suspense_ac_failed VARCHAR2(1) := 'N';
2882 l_suspense_ac_not_found VARCHAR2(1) := 'N';
2883 l_susp_ac_found VARCHAR2(10) := 'TRUE';
2884 l_summary_amount NUMBER;
2885 l_dr_summary_amount NUMBER := 0;
2886 l_cr_summary_amount NUMBER := 0;
2887 l_dr_cr_flag VARCHAR2(1);
2888 l_effective_date DATE;
2889 x_susp_failed_org_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
2890 x_susp_failed_status VARCHAR2(50);
2891 x_susp_failed_date DATE;
2892 x_lines_glccid NUMBER(15);
2893 x_susp_nf_org_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
2894 x_susp_nf_date DATE;
2895 l_return_status VARCHAR2(10);
2896 l_group_id NUMBER:=p_group_id; -- bug fix 1570575
2897 l_rec_cnt NUMBER := 0;
2898 x varchar2(2000);
2899 l_return_value VARCHAR2(30); --Added for bug 2056877.
2900 no_profile_exists EXCEPTION; --Added for bug 2056877.
2901 no_val_date_matches EXCEPTION; --Added for bug 2056877.
2902 no_global_acct_exists EXCEPTION; --Added for bug 2056877.
2903 l_susp_exception varchar2(50) := NULL; -- 2479579
2904
2905
2906
2907 FUNCTION PROCESS_COMPLETE RETURN BOOLEAN IS
2908 l_cnt NUMBER := 0;
2909 l_status VARCHAR2(30);
2910 begin
2911 select count(*)
2912 into l_cnt
2913 from gl_interface
2914 where user_je_source_name = 'OLD'
2915 and set_of_books_id = p_set_of_books_id
2916 and group_id = p_group_id
2917 and status = 'NEW';
2918
2919 if l_cnt = 0 then
2920 return TRUE;
2921 elsif l_cnt > 0 then
2922 -- -------------------------------------------------------------------------------------------
2923 -- If status = 'NEW' then the journal import process did not kick off
2924 -- for some reason. Return FALSE in this case. So cleanup the tables and try to transfer
2925 -- again after summarization in the second pass.
2926 -- -------------------------------------------------------------------------------------------
2927
2928 delete from gl_interface
2929 where user_je_source_name = 'OLD'
2930 and set_of_books_id = p_set_of_books_id
2931 and group_id = p_group_id;
2932
2933 delete from psp_enc_summary_lines
2934 where group_id = p_group_id
2935 and enc_control_id = p_enc_control_id;
2936
2937 return FALSE;
2938 end if;
2939
2940 exception
2941 when others then
2942 return TRUE;
2943 end PROCESS_COMPLETE;
2944
2945 BEGIN
2946
2947 IF (PROCESS_COMPLETE) THEN
2948
2949 SELECT count(*)
2950 INTO l_cnt_gl_interface
2951 FROM gl_interface
2952 WHERE user_je_source_name = 'OLD'
2953 AND set_of_books_id = p_set_of_books_id
2954 AND group_id = p_group_id;
2955
2956 IF l_cnt_gl_interface > 0 THEN
2957 / * Start bug#2142865 Moved the code after loop to above * /
2958 UPDATE psp_enc_controls
2959 SET gl_phase = 'TieBack'
2960 WHERE run_id = g_run_id;
2961 / * End bug#2142865 * /
2962 OPEN gl_tie_back_reject_cur;
2963 LOOP
2964 FETCH gl_tie_back_reject_cur INTO l_status,l_enc_ref;
2965 IF gl_tie_back_reject_cur%NOTFOUND THEN
2966 CLOSE gl_tie_back_reject_cur;
2967 EXIT;
2968 END IF;
2969
2970 l_reference6 := substr(l_enc_ref, 3);
2971
2972 UPDATE psp_enc_summary_lines
2973 SET interface_status = l_status,
2974 status_code = 'R'
2975 WHERE enc_summary_line_id = to_number(l_reference6);
2976
2977 OPEN assign_susp_ac_cur(to_number(l_reference6));
2978 LOOP
2979 FETCH assign_susp_ac_cur INTO l_rowid, l_encumbrance_date,l_suspense_org_account_id;
2980
2981 IF assign_susp_ac_cur%NOTFOUND THEN
2982 CLOSE assign_susp_ac_cur;
2983 EXIT;
2984 END IF;
2985
2986 if l_suspense_org_account_id is not null then
2987 OPEN get_susp_org_cur(l_suspense_org_account_id);
2988 FETCH get_susp_org_cur into l_organization_id, l_organization_name,
2989 l_lines_glccid;
2990 CLOSE get_susp_org_cur;
2991 end if;
2992
2993 / * --- This is not needed as the enc lines are always in status 'N'
2994 * /
2995
2996 IF l_status = 'P' OR substr(l_status,1,1) = 'W' THEN
2997 null;
2998 --- fIx for bug 1671938/1888408
2999
3000 / *
3001 UPDATE psp_enc_lines
3002 SET status_code = 'N'
3003 WHERE rowid = l_rowid;
3004 -- if the suspense a/c failed,update the status of the whole batch and display the error
3005
3006 ELSIF l_suspense_org_account_id IS NOT NULL AND *** /
3007
3008 ELSIF l_suspense_org_account_id IS NOT NULL AND
3009 (l_status <> 'P' OR substr(l_status,1,1) <> 'W') THEN
3010 x_susp_failed_org_name := l_organization_name;
3011 x_susp_failed_status := l_status;
3012 x_susp_failed_date := l_encumbrance_date;
3013 l_suspense_ac_failed := 'Y';
3014
3015 / * Commented the following for Bug 3194807
3016
3017 UPDATE psp_enc_lines
3018 SET suspense_reason_code = l_status,
3019 status_code = 'N'
3020 WHERE rowid = l_rowid;
3021
3022 * /
3023
3024 ELSE
3025
3026 l_susp_ac_found := 'TRUE';
3027
3028 OPEN get_org_id_cur(l_rowid);
3029 FETCH get_org_id_cur into l_orig_org_id, l_orig_org_name;
3030 close get_org_id_cur;
3031
3032 OPEN org_susp_ac_cur(l_orig_org_id,l_encumbrance_date);
3033 FETCH org_susp_ac_cur INTO l_organization_account_id,l_susp_glccid,l_project_id,
3034 l_expenditure_organization_id, l_expenditure_type, l_award_id,l_task_id;
3035
3036 -- OPEN org_susp_ac_cur(l_organization_id,l_encumbrance_date);
3037 -- FETCH org_susp_ac_cur INTO l_organization_account_id,l_susp_glccid,l_project_id,l_award_id, l_task_id;
3038 IF org_susp_ac_cur%NOTFOUND THEN
3039 / * Following code is added for bug 2056877 ,Added validation for generic suspense account * /
3040 l_return_value := psp_general.find_global_suspense(l_encumbrance_date,
3041 p_business_group_id,
3042 p_set_of_books_id,
3043 l_organization_account_id );
3044 / * --------------------------------------------------------------------
3045 Valid return values are
3046 PROFILE_VAL_DATE_MATCHES Profile and Value and Date matching 'G'
3047 NO_PROFILE_EXISTS No Profile
3048 NO_VAL_DATE_MATCHES Profile and Either Value/date do not
3049 match with 'G'
3050 NO_GLOBAL_ACCT_EXISTS No 'G' exists
3051 ---------------------------------------------------------------------- * /
3052 / * start added for bug # 2142865 * /
3053 / * IF l_return_value <> 'PROFILE_VAL_DATE_MATCHES' THEN
3054 IF p_mode='N' THEN
3055 enc_batch_end(g_payroll_id ,l_return_status);
3056 END IF;
3057 END IF ; commented for 2479579 * /
3058 / * end for bug # 2142865 * /
3059
3060 IF l_return_value = 'PROFILE_VAL_DATE_MATCHES' THEN
3061 ---- OPEN global_susp_ac_cur(l_encumbrance_date);
3062 OPEN global_susp_ac_cur(l_organization_account_id); --Bug 2056877
3063 FETCH global_susp_ac_cur INTO l_organization_account_id,l_susp_glccid,l_project_id,
3064 l_expenditure_organization_id, l_expenditure_type, l_award_id, l_task_id;
3065
3066 IF global_susp_ac_cur%NOTFOUND THEN
3067 / * l_susp_ac_found := 'FALSE';
3068 l_suspense_ac_not_found := 'Y';
3069 x_susp_nf_org_name := l_orig_org_name;
3070 x_susp_nf_date := l_encumbrance_date; Commented for bug 2056877 * /
3071 -- commented following line and added two new lines for 2479579
3072 -- RAISE no_global_acct_exists; --Added for bug 2056877
3073 l_suspense_ac_not_found := 'Y';
3074 l_susp_ac_found := 'NO_G_AC';
3075 END IF;
3076 CLOSE global_susp_ac_cur;
3077 ELSIF l_return_value = 'NO_GLOBAL_ACCT_EXISTS' THEN
3078 -- RAISE no_global_acct_exists; commented this line and added two new lines for 2479579
3079 l_suspense_ac_not_found := 'Y';
3080 l_susp_ac_found := 'NO_G_AC';
3081 ELSIF l_return_value = 'NO_VAL_DATE_MATCHES' THEN
3082 -- RAISE no_val_date_matches; commented this line and added two new lines for 2479579
3083 l_suspense_ac_not_found := 'Y';
3084 l_susp_ac_found := 'NO_DT_MCH';
3085 ELSIF l_return_value = 'NO_PROFILE_EXISTS' THEN
3086 -- RAISE no_profile_exists; commented this line and added two new lines for 2479579
3087 l_suspense_ac_not_found := 'Y';
3088 l_susp_ac_found := 'NO_PROFL';
3089 END IF; -- Bug 2056877.
3090 END IF;
3091 CLOSE org_susp_ac_cur;
3092
3093 IF l_susp_ac_found = 'TRUE' THEN
3094
3095 IF l_susp_glccid IS NOT NULL THEN
3096 l_gl_project_flag := 'G';
3097 l_effective_date := p_period_end_date;
3098 ELSE
3099 l_gl_project_flag := 'P';
3100
3101 psp_general.poeta_effective_date(l_encumbrance_date,
3102 l_project_id,
3103 l_award_id,
3104 l_task_id,
3105 l_effective_date,
3106 l_return_status);
3107 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3108 --dbms_output.put_line('poeta call failed ');
3109 --insert_into_psp_stout( 'poeta call failed ');
3110 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3111 END IF;
3112
3113 END IF;
3114
3115 -- assign the organization suspense account and gl status
3116 / * For Bug fix 3194807 * /
3117
3118 UPDATE psp_enc_lines
3119 SET prev_effective_date = encumbrance_date
3120 WHERE rowid = l_rowid;
3121 / * End of changes for Bug fix 3194807 * /
3122
3123 UPDATE psp_enc_lines
3124 SET suspense_org_account_id = l_organization_account_id,
3125 suspense_reason_code = 'ES:' || l_status,
3126 gl_project_flag = l_gl_project_flag,
3127 -- encumbrance_date = l_encumbrance_date, for Bug 3194807
3128 encumbrance_date = l_effective_date,
3129 / * Commented for Bug fix 3194807
3130 schedule_line_id = null,
3131 org_schedule_id = null,
3132 default_org_account_id = null,
3133 element_account_id = null,
3134 gl_code_combination_id = decode(l_gl_project_flag, 'P', null, l_susp_glccid),
3135 project_id = decode(l_gl_project_flag, 'P', l_project_id, null),
3136 expenditure_organization_id = decode(l_gl_project_flag, 'P', l_expenditure_organization_id, null),
3137 expenditure_type = decode(l_gl_project_flag, 'P', l_expenditure_type, null),
3138 task_id = decode(l_gl_project_flag, 'P', l_task_id, null),
3139 award_id = decode(l_gl_project_flag, 'P', l_award_id, null), commented for bug 3194807 * /
3140 status_code = 'N'
3141 WHERE rowid = l_rowid;
3142 ELSE -- 2479579 added this else stmnt
3143 l_susp_exception := l_susp_ac_found;
3144 END IF;
3145 END IF;
3146 END LOOP;
3147 END LOOP;
3148 / * Commented as a part of bug#2142865
3149 Moved the same code up
3150 UPDATE psp_enc_controls
3151 SET gl_phase = 'TieBack'
3152 WHERE enc_control_id = p_enc_control_id;* /
3153 / * GL encumbrance does not have reversal lines: bug 2030232
3154 IF l_reversal_ac_failed = 'Y' THEN
3155 fnd_message.set_name('PSP','PSP_GL_REVERSE_AC_REJECT');
3156 fnd_message.set_token('GLCCID',x_lines_glccid);
3157 fnd_msg_pub.add;
3158 -- Included the following check as part of Bug fix #1776606 --
3159 IF p_mode = 'N' THEN
3160 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3161 END IF;
3162 END IF;
3163 * /
3164
3165 IF l_suspense_ac_failed = 'Y' THEN
3166 g_susp_prob := 'Y'; -- for 2479579
3167 fnd_message.set_name('PSP','PSP_TR_GL_SUSP_AC_REJECT');
3168 fnd_message.set_token('ORG_NAME',x_susp_failed_org_name);
3169 fnd_message.set_token('PAYROLL_DATE',x_susp_failed_date);
3170 fnd_message.set_token('ERROR_MSG',x_susp_failed_status);
3171 fnd_msg_pub.add;
3172
3173
3174 / * Added the following for Bug 3194807 * /
3175
3176 UPDATE psp_enc_lines
3177 SET suspense_org_account_id = NULL,
3178 suspense_reason_code = NULL,
3179 gl_project_flag = decode(gl_code_combination_id,NULL,'P','G'),
3180 encumbrance_date = prev_effective_date
3181 WHERE suspense_reason_code like 'ES:%'
3182 AND enc_summary_line_id
3183 IN (SELECT enc_summary_line_id
3184 FROM psp_enc_summary_lines
3185 WHERE enc_control_id = p_enc_control_id);
3186
3187
3188 / * End of code changes for Bug 3194807 * /
3189
3190 END IF;
3191 -- uncommented for 2479579, which was earlier commented for bug # 2142865
3192 IF l_suspense_ac_not_found = 'Y' THEN
3193 g_susp_prob := 'Y'; -- for 2479579
3194 / * commented this message stack for 2479579
3195 fnd_message.set_name('PSP','PSP_LD_SUSPENSE_AC_NOT_EXIST');
3196 fnd_message.set_token('ORG_NAME',x_susp_nf_org_name);
3197 fnd_message.set_token('PAYROLL_DATE',x_susp_nf_date);
3198 fnd_msg_pub.add; * /
3199 ---added following if stmnt for 2479579
3200 IF l_susp_exception = 'NO_G_AC' then
3201 RAISE no_global_acct_exists;
3202 ELSIF l_susp_exception = 'NO_DT_MCH' then
3203 RAISE no_val_date_matches;
3204 ELSIF l_susp_exception = 'NO_PROFL' then
3205 RAISE no_profile_exists;
3206 END IF;
3207
3208 END IF;
3209
3210 ELSIF l_cnt_gl_interface = 0 THEN
3211 --
3212 OPEN gl_tie_back_success_cur;
3213 LOOP
3214 FETCH gl_tie_back_success_cur INTO l_enc_summary_line_id,
3215 l_dr_cr_flag,l_summary_amount;
3216 IF gl_tie_back_success_cur%NOTFOUND THEN
3217 CLOSE gl_tie_back_success_cur;
3218 EXIT;
3219 END IF;
3220
3221 l_rec_cnt := l_rec_cnt + 1;
3222 -- update records in psp_enc_summary_lines as 'A'
3223 UPDATE psp_enc_summary_lines
3224 SET status_code = 'A'
3225 WHERE enc_summary_line_id = l_enc_summary_line_id;
3226
3227 IF l_dr_cr_flag = 'D' THEN
3228 l_dr_summary_amount := l_dr_summary_amount + l_summary_amount;
3229 ELSIF l_dr_cr_flag = 'C' THEN
3230 l_cr_summary_amount := l_cr_summary_amount + l_summary_amount;
3231 END IF;
3232
3233 UPDATE psp_enc_lines
3234 SET status_code = 'A'
3235 WHERE enc_summary_line_id = l_enc_summary_line_id
3236 AND enc_control_id = p_enc_control_id;
3237
3238 / * Introduced this cursor for Bug fix 3194807 * /
3239 UPDATE psp_enc_lines
3240 SET gl_code_combination_id = (SELECT poa.gl_code_combination_id
3241 FROM psp_organization_accounts poa
3242 where poa.organization_account_id = suspense_org_account_id),
3243 project_id = NULL,
3244 task_id = NULL,
3245 award_id = NULL,
3246 expenditure_organization_id = NULL,
3247 expenditure_type = NULL
3248 WHERE enc_summary_line_id = l_enc_summary_line_id
3249 AND suspense_reason_code LIKE 'ES:%';
3250 / * End of code Changes for Bug fix 3194807 * /
3251
3252
3253 -- move the transferred records to psp_enc_lines_history
3254 -- Added enc_start_date ,enc_end_date columns for Enh. Enc Redesign Prorata,Bug #2259310.
3255 -- Introduced DFF columns for bug fix 2908859
3256 INSERT INTO psp_enc_lines_history
3257 (enc_line_id,business_group_id,enc_element_type_id,encumbrance_date,
3258 dr_cr_flag,encumbrance_amount,status_code,enc_line_type,schedule_line_id,org_schedule_id,
3259 default_org_account_id,suspense_org_account_id,element_account_id,gl_project_flag,
3260 enc_summary_line_id,person_id,assignment_id,award_id,task_id,expenditure_type,
3261 expenditure_organization_id,project_id,gl_code_combination_id,time_period_id,payroll_id,
3262 set_of_books_id,default_reason_code,suspense_reason_code,enc_control_id,change_flag,last_update_date,
3263 last_updated_by,last_update_login,created_by,creation_date,enc_start_date,enc_end_date,
3264 attribute_category, attribute1, attribute2, attribute3,
3265 attribute4, attribute5, attribute6, attribute7,
3266 attribute8, attribute9, attribute10)
3267 SELECT enc_line_id,business_group_id,enc_element_type_id,encumbrance_date,
3268 dr_cr_flag,encumbrance_amount,status_code,enc_line_type,schedule_line_id,org_schedule_id,
3269 default_org_account_id,suspense_org_account_id,element_account_id,gl_project_flag,
3270 enc_summary_line_id,person_id,assignment_id,award_id,task_id,expenditure_type,
3271 expenditure_organization_id,project_id,gl_code_combination_id,time_period_id,payroll_id,
3272 set_of_books_id,default_reason_code,suspense_reason_code,enc_control_id,change_flag,last_update_date,
3273 last_updated_by,last_update_login,created_by,creation_date,enc_start_date,enc_end_date,
3274 attribute_category, attribute1, attribute2, attribute3,
3275 attribute4, attribute5, attribute6, attribute7,
3276 attribute8, attribute9, attribute10
3277 FROM psp_enc_lines
3278 WHERE status_code = 'A'
3279 AND enc_summary_line_id = l_enc_summary_line_id
3280 AND enc_control_id = p_enc_control_id;
3281
3282 DELETE FROM psp_enc_lines
3283 WHERE status_code = 'A'
3284 AND enc_summary_line_id = l_enc_summary_line_id
3285 AND enc_control_id = p_enc_control_id;
3286
3287 END LOOP;
3288
3289 UPDATE psp_enc_controls
3290 SET summ_gl_dr_amount = l_dr_summary_amount,
3291 summ_gl_cr_amount = l_cr_summary_amount,
3292 gl_phase = 'TieBack'
3293 WHERE enc_control_id = p_enc_control_id;
3294 l_rec_cnt := 0;
3295 END IF;
3296 -- END LOOP; -- ENC_CONTROL_CUR
3297 END IF; -- If (PROCESS_COMPLETE)
3298 p_return_status := fnd_api.g_ret_sts_success;
3299 EXCEPTION
3300 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3301 g_error_api_path := 'GL_ENC_TIE_BACK:'||g_error_api_path;
3302 p_return_status := fnd_api.g_ret_sts_unexp_error;
3303
3304 / * Added Exceptions for bug 2056877 * /
3305 WHEN NO_PROFILE_EXISTS THEN
3306 g_error_api_path := SUBSTR('GL_ENC_TIE_BACK:'||g_error_api_path,1,230);
3307 fnd_message.set_name('PSP','PSP_NO_PROFILE_EXISTS');
3308 fnd_msg_pub.add;
3309 -- p_return_status := fnd_api.g_ret_sts_unexp_error; commented and intro success for 2479579
3310 p_return_status := fnd_api.g_ret_sts_success;
3311
3312 WHEN NO_VAL_DATE_MATCHES THEN
3313 g_error_api_path := SUBSTR('GL_ENC_TIE_BACK:'||g_error_api_path,1,230);
3314 fnd_message.set_name('PSP','PSP_NO_VAL_DATE_MATCHES');
3315 fnd_message.set_token('ORG_NAME',l_orig_org_name);
3316 fnd_message.set_token('PAYROLL_DATE',l_encumbrance_date);
3317 fnd_msg_pub.add;
3318 -- p_return_status := fnd_api.g_ret_sts_unexp_error; commented and intro success for 2479579
3319 p_return_status := fnd_api.g_ret_sts_success;
3320
3321 WHEN NO_GLOBAL_ACCT_EXISTS THEN
3322 g_error_api_path := SUBSTR('GL_ENC_TIE_BACK:'||g_error_api_path,1,230);
3323 fnd_message.set_name('PSP','PSP_NO_GLOBAL_ACCT_EXISTS');
3324 fnd_message.set_token('ORG_NAME',l_orig_org_name);
3325 fnd_message.set_token('PAYROLL_DATE',l_encumbrance_date);
3326 fnd_msg_pub.add;
3327 -- p_return_status := fnd_api.g_ret_sts_unexp_error; commented and intro success for 2479579
3328 p_return_status := fnd_api.g_ret_sts_success;
3329
3330 WHEN OTHERS THEN
3331 g_error_api_path := 'GL_ENC_TIE_BACK:'||g_error_api_path;
3332 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN','GL_ENC_TIE_BACK');
3333 p_return_status := fnd_api.g_ret_sts_unexp_error;
3334
3335 END;
3336 End of comment for Create and Update multi thread enh. *****/
3337
3338 -- Introduced the following modified gl_enc_tie_back procedure for Create and Update multi thread enh.
3339 PROCEDURE gl_enc_tie_back( p_payroll_action_id IN NUMBER,
3340 p_group_id IN NUMBER,
3341 p_business_group_id IN NUMBER,
3342 p_set_of_books_id IN NUMBER,
3343 p_mode IN VARCHAR2,
3344 p_return_status OUT NOCOPY VARCHAR2) IS
3345 CURSOR int_count_cur IS
3346 SELECT COUNT(1)
3347 FROM gl_interface
3348 WHERE user_je_source_name = 'OLD'
3349 AND set_of_books_id = p_set_of_books_id
3350 AND group_id = p_group_id;
3351
3352 CURSOR gl_tie_back_success_cur IS
3353 SELECT enc_summary_line_id,
3354 enc_control_id,
3355 dr_cr_flag,
3356 summary_amount
3357 FROM psp_enc_summary_lines
3358 WHERE group_id = p_group_id;
3359
3360 CURSOR gl_tie_back_reject_cur IS
3361 SELECT status,
3362 TO_NUMBER(trim(substr(reference6,3)))
3363 FROM gl_interface
3364 WHERE user_je_source_name = 'OLD'
3365 AND set_of_books_id = p_set_of_books_id
3366 AND group_id = p_group_id;
3367
3368 CURSOR assign_susp_ac_cur IS
3369 SELECT pel.rowid,
3370 pel.encumbrance_date,
3371 pel.enc_start_date,
3372 pel.enc_end_date,
3373 pel.assignment_id,
3374 pel.payroll_id,
3375 pel.enc_element_type_id,
3376 pel.gl_code_combination_id,
3377 pel.suspense_org_account_id,
3378 pesl.interface_status,
3379 ptp.end_date
3380 FROM psp_enc_lines pel,
3381 psp_enc_summary_lines pesl,
3382 per_time_periods ptp
3383 WHERE pel.payroll_action_id = p_payroll_action_id
3384 AND pel.enc_summary_line_id = pesl.enc_summary_line_id
3385 AND pesl.payroll_action_id = p_payroll_action_id
3386 AND pesl.status_code = 'R'
3387 AND pesl.group_id = p_group_id
3388 AND ptp.time_period_id = pel.time_period_id
3389 ORDER BY 5, 6, 7, 8, 3;
3390
3391 CURSOR get_susp_org_cur(P_ORG_ID IN VARCHAR2) IS
3392 SELECT hou.organization_id, hou.name, poa.gl_code_combination_id
3393 FROM hr_all_organization_units hou,
3394 psp_organization_accounts poa
3395 WHERE hou.organization_id = poa.organization_id
3396 AND poa.business_group_id = p_business_group_id
3397 AND poa.set_of_books_id = p_set_of_books_id
3398 AND poa.organization_account_id = p_org_id;
3399
3400 CURSOR get_org_id_cur(P_ROWID IN ROWID) IS
3401 SELECT hou.organization_id, hou.name
3402 FROM hr_all_organization_units hou,
3403 per_assignments_f paf,
3404 psp_enc_lines pel
3405 WHERE pel.rowid=p_rowid
3406 AND pel.assignment_id = paf.assignment_id
3407 AND pel.encumbrance_date BETWEEN paf.effective_start_date AND paf.effective_end_date
3408 AND paf.organization_id = hou.organization_id
3409 AND pel.encumbrance_date BETWEEN hou.date_from AND NVL(hou.date_to, pel.encumbrance_date);
3410
3411 CURSOR org_susp_ac_cur(P_ORGANIZATION_ID IN NUMBER,
3412 P_ENCUMBRANCE_DATE IN DATE) IS
3413 SELECT poa.organization_account_id,
3414 poa.gl_code_combination_id,
3415 poa.project_id,
3416 poa.expenditure_organization_id,
3417 poa.expenditure_type,
3418 poa.award_id,
3419 poa.task_id
3420 FROM psp_organization_accounts poa
3421 WHERE poa.organization_id = p_organization_id
3422 AND poa.business_group_id = p_business_group_id
3423 AND poa.set_of_books_id = p_set_of_books_id
3424 AND poa.account_type_code = 'S'
3425 AND p_encumbrance_date BETWEEN poa.start_date_active AND NVL(poa.end_date_active, p_encumbrance_date);
3426
3427 CURSOR global_susp_ac_cur(P_ORGANIZATION_ACCOUNT_ID IN NUMBER) IS
3428 SELECT poa.organization_account_id,
3429 poa.gl_code_combination_id,
3430 poa.project_id,
3431 poa.expenditure_organization_id,
3432 poa.expenditure_type,
3433 poa.award_id,
3434 poa.task_id
3435 FROM psp_organization_accounts poa
3436 WHERE organization_account_id = p_organization_account_id;
3437
3438 l_encumbrance_date DATE;
3439 l_lines_glccid NUMBER(15);
3440 l_organization_account_id NUMBER(9);
3441 l_susp_glccid NUMBER(15);
3442 l_orig_org_name hr_all_organization_units_tl.name%TYPE;
3443 l_orig_org_id NUMBER(15);
3444 l_cnt_gl_interface NUMBER;
3445 l_gl_project_flag VARCHAR2(1);
3446 l_suspense_ac_failed VARCHAR2(1);
3447 l_suspense_ac_not_found VARCHAR2(1);
3448 l_susp_ac_found VARCHAR2(10);
3449 l_organization_name hr_all_organization_units_tl.name%TYPE;
3450 l_organization_id NUMBER(15);
3451 l_return_value VARCHAR2(30);
3452 l_effective_date DATE;
3453 no_profile_exists EXCEPTION;
3454 no_val_date_matches EXCEPTION;
3455 no_global_acct_exists EXCEPTION;
3456 l_susp_exception VARCHAR2(50);
3457 l_project_id NUMBER(15);
3458 l_expenditure_organization_id NUMBER(15);
3459 l_expenditure_type VARCHAR2(30);
3460 l_award_id NUMBER(15);
3461 l_task_id NUMBER(15);
3462 l_return_status VARCHAR2(1);
3463
3464 TYPE t_rowid IS TABLE OF ROWID INDEX BY BINARY_INTEGER;
3465 TYPE t_date IS TABLE OF DATE INDEX BY BINARY_INTEGER;
3466 TYPE t_number IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
3467 TYPE t_number_15 IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
3468 TYPE t_char_300 IS TABLE OF VARCHAR2(300) INDEX BY BINARY_INTEGER;
3469
3470 TYPE r_interface_rec IS RECORD
3471 (status t_char_300,
3472 enc_summary_line_id t_number_15,
3473 dr_cr_flag t_char_300,
3474 summary_amount t_number,
3475 enc_control_id t_number_15);
3476 r_interface r_interface_rec;
3477
3478 TYPE r_suspense_ac_rec IS RECORD
3479 (row_id t_rowid,
3480 encumbrance_date t_date,
3481 enc_start_date t_date,
3482 enc_end_date t_date,
3483 assignment_id t_number_15,
3484 element_type_id t_number_15,
3485 payroll_id t_number_15,
3486 gl_code_combination_id t_number_15,
3487 suspense_org_account_id t_number_15,
3488 interface_status t_char_300,
3489 end_date t_date);
3490 r_suspense_ac r_suspense_ac_rec;
3491
3492 FUNCTION PROCESS_COMPLETE RETURN BOOLEAN IS
3493 l_cnt NUMBER;
3494 CURSOR int_count_cur IS
3495 SELECT COUNT(1)
3496 FROM gl_interface
3497 WHERE user_je_source_name = 'OLD'
3498 AND set_of_books_id = p_set_of_books_id
3499 AND group_id = p_group_id
3500 AND status = 'NEW';
3501
3502 TYPE t_number_15 IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
3503
3504 TYPE r_enc_control_rec IS RECORD
3505 (enc_control_id t_number_15);
3506 r_enc_controls r_enc_control_rec;
3507
3508 TYPE r_superceded_line_rec IS RECORD (superceded_line_id t_number_15);
3509 r_superceded_lines r_superceded_line_rec;
3510
3511 CURSOR enc_controls_cur IS
3512 SELECT DISTINCT enc_control_id
3513 FROM psp_enc_summary_lines
3514 WHERE group_id = p_group_id;
3515 BEGIN
3516 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Entering GL_ENC_TIE_BACK.PROCESS_COMPLETE');
3517
3518 OPEN int_count_cur;
3519 FETCH int_count_cur INTO l_cnt;
3520 CLOSE int_count_cur;
3521
3522 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' l_cnt: ' || l_cnt);
3523
3524 IF l_cnt = 0 THEN
3525 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving GL_ENC_TIE_BACK.PROCESS_COMPLETE');
3526 RETURN TRUE;
3527 ELSIF l_cnt > 0 THEN
3528 DELETE FROM gl_interface
3529 WHERE user_je_source_name = 'OLD'
3530 AND set_of_books_id = p_set_of_books_id
3531 AND group_id = p_group_id;
3532 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted from gl_interface count: '||sql%rowcount);
3533
3534 DELETE FROM psp_enc_summary_lines
3535 WHERE group_id = p_group_id;
3536 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted from psp_enc_summary_lines '||sql%rowcount);
3537 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving GL_ENC_TIE_BACK.PROCESS_COMPLETE');
3538 RETURN FALSE;
3539 END IF;
3540
3541 END PROCESS_COMPLETE;
3542
3543 BEGIN
3544 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Entering GL_ENC_TIE_BACK procedure');
3545 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' p_group_id: ' || p_group_id);
3546 l_suspense_ac_failed := 'N';
3547 l_susp_ac_found := 'TRUE';
3548 l_susp_exception := NULL;
3549 l_suspense_ac_not_found := 'N';
3550
3551 IF (PROCESS_COMPLETE) THEN
3552 OPEN int_count_cur;
3553 FETCH int_count_cur INTO l_cnt_gl_interface;
3554 CLOSE int_count_cur;
3555
3556 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' l_cnt_gl_interface: ' || l_cnt_gl_interface);
3557
3558 IF (l_cnt_gl_interface > 0) THEN
3559 OPEN gl_tie_back_reject_cur;
3560 FETCH gl_tie_back_reject_cur BULK COLLECT INTO r_interface.status, r_interface.enc_summary_line_id;
3561 CLOSE gl_tie_back_reject_cur;
3562
3563 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' r_interface.status.COUNT: ' || r_interface.status.COUNT);
3564
3565 FORALL recno IN 1..r_interface.status.COUNT
3566 UPDATE psp_enc_summary_lines
3567 SET interface_status = r_interface.status(recno),
3568 status_code = 'R'
3569 WHERE enc_summary_line_id = r_interface.enc_summary_line_id(recno)
3570 AND r_interface.status(recno) <> 'P'
3571 AND SUBSTR(r_interface.status(recno), 1, 1) <> 'W';
3572
3573 g_bulk_row_count :=0;
3574 FOR bulk_idx IN 1..r_interface.status.COUNT
3575 loop
3576 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
3577 end loop;
3578
3579 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated rejected lines status in psp_enc_summary_lines count: ' ||g_bulk_row_count);
3580
3581 OPEN assign_susp_ac_cur;
3582 FETCH assign_susp_ac_cur BULK COLLECT INTO r_suspense_ac.row_id, r_suspense_ac.encumbrance_date,
3583 r_suspense_ac.enc_start_date, r_suspense_ac.enc_end_date, r_suspense_ac.assignment_id,
3584 r_suspense_ac.payroll_id, r_suspense_ac.element_type_id,
3585 r_suspense_ac.gl_code_combination_id, r_suspense_ac.suspense_org_account_id,
3586 r_suspense_ac.interface_status, r_suspense_ac.end_date;
3587 CLOSE assign_susp_ac_cur;
3588
3589 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'r_suspense_ac.row_id.COUNT : '||r_suspense_ac.row_id.COUNT);
3590
3591 FOR recno IN 1..r_suspense_ac.row_id.COUNT
3592 LOOP
3593 IF r_suspense_ac.suspense_org_account_id(recno) IS NOT NULL THEN
3594 OPEN get_susp_org_cur(r_suspense_ac.suspense_org_account_id(recno));
3595 FETCH get_susp_org_cur INTO l_organization_id, l_organization_name, l_lines_glccid;
3596 CLOSE get_susp_org_cur;
3597
3598 l_suspense_ac_failed := 'Y';
3599 g_susp_prob := 'Y';
3600 fnd_message.set_name('PSP', 'PSP_TR_GL_SUSP_AC_REJECT');
3601 fnd_message.set_token('ORG_NAME', l_organization_name);
3602 fnd_message.set_token('PAYROLL_DATE', r_suspense_ac.encumbrance_date(recno));
3603 fnd_message.set_token('ERROR_MSG', r_suspense_ac.interface_status(recno));
3604 fnd_msg_pub.add;
3605 ELSE
3606 l_susp_ac_found := 'TRUE';
3607
3608 OPEN get_org_id_cur(r_suspense_ac.row_id(recno));
3609 FETCH get_org_id_cur INTO l_orig_org_id, l_orig_org_name;
3610 CLOSE get_org_id_cur;
3611
3612
3613
3614 OPEN org_susp_ac_cur(l_orig_org_id, r_suspense_ac.encumbrance_date(recno));
3615 FETCH org_susp_ac_cur INTO l_organization_account_id,l_susp_glccid,l_project_id,
3616 l_expenditure_organization_id, l_expenditure_type, l_award_id, l_task_id;
3617
3618 IF org_susp_ac_cur%NOTFOUND THEN
3619 l_return_value := psp_general.find_global_suspense(r_suspense_ac.encumbrance_date(recno),
3620 p_business_group_id,
3621 p_set_of_books_id,
3622 l_organization_account_id);
3623
3624 IF l_return_value = 'PROFILE_VAL_DATE_MATCHES' THEN
3625 OPEN global_susp_ac_cur(l_organization_account_id);
3626 FETCH global_susp_ac_cur INTO l_organization_account_id,l_susp_glccid,l_project_id,
3627 l_expenditure_organization_id, l_expenditure_type, l_award_id, l_task_id;
3628
3629 IF global_susp_ac_cur%NOTFOUND THEN
3630 l_encumbrance_date := r_suspense_ac.encumbrance_date(recno);
3631 l_suspense_ac_not_found := 'Y';
3632 l_susp_ac_found := 'NO_G_AC';
3633 END IF;
3634 CLOSE global_susp_ac_cur;
3635 ELSIF l_return_value = 'NO_GLOBAL_ACCT_EXISTS' THEN
3636 l_encumbrance_date := r_suspense_ac.encumbrance_date(recno);
3637 l_suspense_ac_not_found := 'Y';
3638 l_susp_ac_found := 'NO_G_AC';
3639 ELSIF l_return_value = 'NO_VAL_DATE_MATCHES' THEN
3640 l_encumbrance_date := r_suspense_ac.encumbrance_date(recno);
3641 l_suspense_ac_not_found := 'Y';
3642 l_susp_ac_found := 'NO_DT_MCH';
3643 ELSIF l_return_value = 'NO_PROFILE_EXISTS' THEN
3644 l_encumbrance_date := r_suspense_ac.encumbrance_date(recno);
3645 l_suspense_ac_not_found := 'Y';
3646 l_susp_ac_found := 'NO_PROFL';
3647 END IF;
3648 END IF;
3649 CLOSE org_susp_ac_cur;
3650
3651 IF l_susp_ac_found = 'TRUE' THEN
3652 IF l_susp_glccid IS NOT NULL THEN
3653 l_gl_project_flag := 'G';
3654 l_effective_date := r_suspense_ac.end_date(recno);
3655 ELSE
3656 l_gl_project_flag := 'P';
3657 psp_general.poeta_effective_date(r_suspense_ac.encumbrance_date(recno),
3658 l_project_id, l_award_id, l_task_id, l_effective_date,
3659 l_return_status);
3660 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3661 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3662 END IF;
3663 END IF;
3664
3665 UPDATE psp_enc_lines
3666 SET prev_effective_date = encumbrance_date,
3667 orig_gl_code_combination_id = gl_code_combination_id,
3668 orig_project_id = project_id,
3669 orig_task_id = task_id,
3670 orig_award_id = award_id,
3671 orig_expenditure_org_id = expenditure_organization_id,
3672 orig_expenditure_type = expenditure_type
3673 WHERE rowid = r_suspense_ac.row_id(recno)
3674 AND enc_start_date <= g_def_end_date;
3675
3676 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'updated psp_enc_lines count'||sql%rowcount);
3677
3678 UPDATE psp_enc_lines
3679 SET suspense_org_account_id = l_organization_account_id,
3680 gl_code_combination_id = l_susp_glccid,
3681 project_id = l_project_id,
3682 task_id = l_task_id,
3683 award_id = l_award_id,
3684 expenditure_organization_id = l_expenditure_organization_id,
3685 expenditure_type = l_expenditure_type,
3686 suspense_reason_code = 'ES:' || r_suspense_ac.interface_status(recno),
3687 gl_project_flag = l_gl_project_flag,
3688 encumbrance_date = l_effective_date,
3689 status_code = 'N'
3690 WHERE rowid = r_suspense_ac.row_id(recno)
3691 AND enc_start_date <= g_def_end_date;
3692
3693 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'updated psp_enc_lines1 count'||sql%rowcount);
3694
3695 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'add_st_warnings');
3696 add_st_warnings(p_assignment_id => r_suspense_ac.assignment_id(recno),
3697 p_payroll_id => r_suspense_ac.payroll_id(recno),
3698 p_element_type_id => r_suspense_ac.element_type_id(recno),
3699 p_start_date => r_suspense_ac.enc_start_date(recno),
3700 p_end_date => r_suspense_ac.enc_end_date(recno),
3701 p_effective_date => r_suspense_ac.encumbrance_date(recno),
3702 p_gl_ccid => r_suspense_ac.gl_code_combination_id(recno),
3703 p_error_status => r_suspense_ac.interface_status(recno));
3704 ELSE
3705 l_susp_exception := l_susp_ac_found;
3706 END IF;
3707 END IF;
3708 END LOOP;
3709
3710 IF l_suspense_ac_failed = 'Y' THEN
3711 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'Suspence account failed');
3712 UPDATE psp_enc_lines
3713 SET suspense_org_account_id = NULL,
3714 gl_code_combination_id = orig_gl_code_combination_id,
3715 project_id = orig_project_id,
3716 task_id = orig_task_id,
3717 award_id = orig_award_id,
3718 expenditure_organization_id = orig_expenditure_org_id,
3719 expenditure_type = orig_expenditure_type,
3720 gl_project_flag = decode(orig_gl_code_combination_id,NULL,'P','G'),
3721 encumbrance_date = prev_effective_date
3722 WHERE suspense_reason_code like 'ES:%'
3723 AND enc_summary_line_id IN (SELECT enc_summary_line_id
3724 FROM psp_enc_summary_lines pesl
3725 WHERE pesl.payroll_action_id = p_payroll_action_id
3726 AND pesl.group_id = p_group_id
3727 AND status_code = 'R');
3728 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'updated psp_enc_lines2 count'||sql%rowcount);
3729
3730 UPDATE psp_enc_lines
3731 SET orig_gl_code_combination_id = NULL,
3732 orig_project_id = NULL,
3733 orig_task_id = NULL,
3734 orig_award_id = NULL,
3735 orig_expenditure_org_id = NULL,
3736 orig_expenditure_type = NULL,
3737 suspense_reason_code = NULL
3738 WHERE suspense_reason_code like 'ES:%'
3739 AND enc_summary_line_id IN (SELECT enc_summary_line_id
3740 FROM psp_enc_summary_lines pesl
3741 WHERE pesl.payroll_action_id = p_payroll_action_id
3742 AND pesl.group_id = p_group_id
3743 AND status_code = 'R');
3744
3745 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'updated psp_enc_lines3 count'||sql%rowcount);
3746
3747 END IF;
3748
3749 IF l_suspense_ac_not_found = 'Y' THEN
3750 g_susp_prob := 'Y';
3751 IF l_susp_exception = 'NO_G_AC' THEN
3752 RAISE no_global_acct_exists;
3753 ELSIF l_susp_exception = 'NO_DT_MCH' THEN
3754 RAISE no_val_date_matches;
3755 ELSIF l_susp_exception = 'NO_PROFL' THEN
3756 RAISE no_profile_exists;
3757 END IF;
3758 END IF;
3759
3760 FORALL recno IN 1..r_interface.status.COUNT
3761 UPDATE psp_enc_controls
3762 SET gl_phase = 'TieBack'
3763 WHERE enc_control_id IN (SELECT pesl.enc_control_id
3764 FROM psp_enc_summary_lines pesl
3765 WHERE pesl.enc_summary_line_id = r_interface.enc_summary_line_id(recno));
3766
3767 g_bulk_row_count :=0;
3768 FOR bulk_idx IN 1..r_interface.status.COUNT
3769 loop
3770 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
3771 end loop;
3772
3773 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' TieBack count: '||g_bulk_row_count);
3774
3775 FORALL recno IN 1..r_interface.status.COUNT
3776 UPDATE psp_enc_controls
3777 SET gl_phase = 'Summarize'
3778 WHERE enc_control_id IN (SELECT pesl.enc_control_id
3779 FROM psp_enc_summary_lines pesl
3780 WHERE pesl.enc_summary_line_id = r_interface.enc_summary_line_id(recno)
3781 AND pesl.status_code = 'N');
3782
3783 g_bulk_row_count :=0;
3784 FOR bulk_idx IN 1..r_interface.status.COUNT
3785 loop
3786 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
3787 end loop;
3788
3789 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Summarize count: '||g_bulk_row_count);
3790 ELSIF (l_cnt_gl_interface = 0) THEN
3791 OPEN gl_tie_back_success_cur;
3792 FETCH gl_tie_back_success_cur BULK COLLECT INTO r_interface.enc_summary_line_id, r_interface.enc_control_id, r_interface.dr_cr_flag, r_interface.summary_amount;
3793 CLOSE gl_tie_back_success_cur;
3794
3795 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' r_interface.enc_summary_line_id.COUNT: ' || r_interface.enc_summary_line_id.COUNT);
3796
3797 FORALL recno IN 1..r_interface.enc_summary_line_id.COUNT
3798 UPDATE psp_enc_summary_lines
3799 SET status_code = 'A'
3800 WHERE enc_summary_line_id = r_interface.enc_summary_line_id(recno);
3801
3802 g_bulk_row_count :=0;
3803 FOR bulk_idx IN 1..r_interface.enc_summary_line_id.COUNT
3804 loop
3805 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
3806 end loop;
3807
3808 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated status_code to ''A'' in psp_enc_summary_lines count: '||g_bulk_row_count);
3809
3810 FORALL recno IN 1..r_interface.enc_summary_line_id.COUNT
3811 INSERT INTO psp_enc_lines_history
3812 (enc_line_id, business_group_id, enc_element_type_id, encumbrance_date,
3813 dr_cr_flag, encumbrance_amount, status_code, enc_line_type,
3814 schedule_line_id, org_schedule_id, default_org_account_id, suspense_org_account_id,
3815 element_account_id, gl_project_flag, enc_summary_line_id, person_id,
3816 assignment_id, award_id, task_id, expenditure_type,
3817 expenditure_organization_id, project_id, gl_code_combination_id, time_period_id,
3818 payroll_id, set_of_books_id, default_reason_code, suspense_reason_code,
3819 enc_control_id, change_flag, last_update_date, last_updated_by,
3820 last_update_login, created_by, creation_date, enc_start_date,
3821 enc_end_date, attribute_category, attribute1, attribute2,
3822 attribute3, attribute4, attribute5, attribute6,
3823 attribute7, attribute8, attribute9, attribute10,
3824 payroll_action_id, hierarchy_code, hierarchy_start_date, hierarchy_end_date,
3825 orig_gl_code_combination_id, orig_project_id, orig_task_id, orig_award_id,
3826 orig_expenditure_org_id, orig_expenditure_type)
3827 SELECT enc_line_id, business_group_id, enc_element_type_id, encumbrance_date,
3828 dr_cr_flag, encumbrance_amount, 'A', enc_line_type,
3829 schedule_line_id, org_schedule_id, default_org_account_id, suspense_org_account_id,
3830 element_account_id, gl_project_flag, enc_summary_line_id, person_id,
3831 assignment_id, award_id, task_id, expenditure_type,
3832 expenditure_organization_id, project_id, gl_code_combination_id, time_period_id,
3833 payroll_id, set_of_books_id, default_reason_code, suspense_reason_code,
3834 enc_control_id, change_flag, last_update_date, last_updated_by,
3835 last_update_login, created_by, creation_date, enc_start_date,
3836 enc_end_date, attribute_category, attribute1, attribute2,
3837 attribute3, attribute4, attribute5, attribute6,
3838 attribute7, attribute8, attribute9, attribute10,
3839 payroll_action_id, hierarchy_code, hierarchy_start_date, hierarchy_end_date,
3840 orig_gl_code_combination_id, orig_project_id, orig_task_id, orig_award_id,
3841 orig_expenditure_org_id, orig_expenditure_type
3842 FROM psp_enc_lines
3843 WHERE enc_summary_line_id = r_interface.enc_summary_line_id(recno);
3844
3845 g_bulk_row_count :=0;
3846 FOR bulk_idx IN 1..r_interface.enc_summary_line_id.COUNT
3847 loop
3848 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
3849 end loop;
3850
3851 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Copied successfully summarized and transferred lines into psp_enc_lines_history count: '||g_bulk_row_count);
3852
3853 FORALL recno IN 1..r_interface.enc_summary_line_id.COUNT
3854 DELETE FROM psp_enc_lines
3855 WHERE enc_summary_line_id = r_interface.enc_summary_line_id(recno);
3856
3857 g_bulk_row_count :=0;
3858 FOR bulk_idx IN 1..r_interface.enc_summary_line_id.COUNT
3859 loop
3860 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
3861 end loop;
3862
3863 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted lines from psp_enc_lines that are summarized and trasnferred to target systems count: '||g_bulk_row_count);
3864
3865
3866
3867 FORALL recno IN 1..r_interface.enc_control_id.COUNT
3868 UPDATE psp_enc_controls pec
3869 SET gl_phase = 'TieBack',
3870 summ_gl_dr_amount = NVL(summ_gl_dr_amount, 0) + DECODE(r_interface.dr_cr_flag(recno), 'D', r_interface.summary_amount(recno), 0),
3871 summ_gl_cr_amount = NVL(summ_gl_cr_amount, 0) + DECODE(r_interface.dr_cr_flag(recno), 'C', r_interface.summary_amount(recno), 0)
3872 WHERE enc_control_id = r_interface.enc_control_id(recno);
3873
3874 g_bulk_row_count :=0;
3875 FOR bulk_idx IN 1..r_interface.enc_control_id.COUNT
3876 loop
3877 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
3878 end loop;
3879
3880 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated gl_phase, summ_gl_dr_amount, summ_gl_cr_amount in psp_enc_controls count: '||g_bulk_row_count);
3881 END IF;
3882 ELSE
3883 g_process_complete := FALSE;
3884 END IF;
3885
3886 p_return_status := fnd_api.g_ret_sts_success;
3887 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving GL_ENC_TIE_BACK');
3888 EXCEPTION
3889 WHEN NO_PROFILE_EXISTS THEN
3890 g_error_api_path := SUBSTR('GL_ENC_TIE_BACK:'||g_error_api_path,1,230);
3891 fnd_message.set_name('PSP','PSP_NO_PROFILE_EXISTS');
3892 fnd_msg_pub.add;
3893 p_return_status := fnd_api.g_ret_sts_success;
3894 WHEN NO_VAL_DATE_MATCHES THEN
3895 g_error_api_path := SUBSTR('GL_ENC_TIE_BACK:'||g_error_api_path,1,230);
3896 fnd_message.set_name('PSP','PSP_NO_VAL_DATE_MATCHES');
3897 fnd_message.set_token('ORG_NAME',l_orig_org_name);
3898 fnd_message.set_token('PAYROLL_DATE',l_encumbrance_date);
3899 fnd_msg_pub.add;
3900 p_return_status := fnd_api.g_ret_sts_success;
3901 WHEN NO_GLOBAL_ACCT_EXISTS THEN
3902 g_error_api_path := SUBSTR('GL_ENC_TIE_BACK:'||g_error_api_path,1,230);
3903 fnd_message.set_name('PSP','PSP_NO_GLOBAL_ACCT_EXISTS');
3904 fnd_message.set_token('ORG_NAME',l_orig_org_name);
3905 fnd_message.set_token('PAYROLL_DATE',l_encumbrance_date);
3906 fnd_msg_pub.add;
3907 p_return_status := fnd_api.g_ret_sts_success;
3908 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
3909 g_error_api_path := 'GL_ENC_TIE_BACK:'||g_error_api_path;
3910 p_return_status := fnd_api.g_ret_sts_unexp_error;
3911 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving GL_ENC_TIE_BACK');
3912 WHEN OTHERS THEN
3913 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
3914 g_error_api_path := 'GL_ENC_TIE_BACK:'||g_error_api_path;
3915 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN','GL_ENC_TIE_BACK');
3916 p_return_status := fnd_api.g_ret_sts_unexp_error;
3917 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving GL_ENC_TIE_BACK');
3918 END gl_enc_tie_back;
3919 -- End of changes for Create and Update multi thread enh.
3920
3921 -- ##########################################################################
3922 -- This procedure inserts data into gl_interface
3923 -- ##########################################################################
3924
3925
3926 PROCEDURE insert_into_gl_int (
3927 P_SET_OF_BOOKS_ID IN NUMBER,
3928 P_ACCOUNTING_DATE IN DATE,
3929 P_CURRENCY_CODE IN VARCHAR2,
3930 P_USER_JE_CATEGORY_NAME IN VARCHAR2,
3931 P_USER_JE_SOURCE_NAME IN VARCHAR2,
3932 P_ENCUMBRANCE_TYPE_ID IN NUMBER,
3933 P_CODE_COMBINATION_ID IN NUMBER,
3934 P_ENTERED_DR IN NUMBER,
3935 P_ENTERED_CR IN NUMBER,
3936 P_GROUP_ID IN NUMBER,
3937 P_REFERENCE1 IN VARCHAR2,
3938 P_REFERENCE2 IN VARCHAR2,
3939 P_REFERENCE4 IN VARCHAR2,
3940 P_REFERENCE6 IN VARCHAR2,
3941 P_REFERENCE10 IN VARCHAR2,
3942 P_ATTRIBUTE1 IN VARCHAR2,
3943 P_ATTRIBUTE2 IN VARCHAR2,
3944 P_ATTRIBUTE3 IN VARCHAR2,
3945 P_ATTRIBUTE4 IN VARCHAR2,
3946 P_ATTRIBUTE5 IN VARCHAR2,
3947 P_ATTRIBUTE6 IN VARCHAR2,
3948 P_ATTRIBUTE7 IN VARCHAR2,
3949 P_ATTRIBUTE8 IN VARCHAR2,
3950 P_ATTRIBUTE9 IN VARCHAR2,
3951 P_ATTRIBUTE10 IN VARCHAR2,
3952 P_ATTRIBUTE11 IN VARCHAR2,
3953 P_ATTRIBUTE12 IN VARCHAR2,
3954 P_ATTRIBUTE13 IN VARCHAR2,
3955 P_ATTRIBUTE14 IN VARCHAR2,
3956 P_ATTRIBUTE15 IN VARCHAR2,
3957 P_ATTRIBUTE16 IN VARCHAR2,
3958 P_ATTRIBUTE17 IN VARCHAR2,
3959 P_ATTRIBUTE18 IN VARCHAR2,
3960 P_ATTRIBUTE19 IN VARCHAR2,
3961 P_ATTRIBUTE20 IN VARCHAR2,
3962 P_ATTRIBUTE21 IN VARCHAR2,
3963 P_ATTRIBUTE22 IN VARCHAR2,
3964 P_ATTRIBUTE23 IN VARCHAR2,
3965 P_ATTRIBUTE24 IN VARCHAR2,
3966 P_ATTRIBUTE25 IN VARCHAR2,
3967 P_ATTRIBUTE26 IN VARCHAR2,
3968 P_ATTRIBUTE27 IN VARCHAR2,
3969 P_ATTRIBUTE28 IN VARCHAR2,
3970 P_ATTRIBUTE29 IN VARCHAR2,
3971 P_ATTRIBUTE30 IN VARCHAR2,
3972 P_RETURN_STATUS OUT NOCOPY VARCHAR2) IS
3973 BEGIN
3974
3975 INSERT INTO GL_INTERFACE(
3976 STATUS,
3977 SET_OF_BOOKS_ID,
3978 ACCOUNTING_DATE,
3979 CURRENCY_CODE,
3980 DATE_CREATED,
3981 CREATED_BY,
3982 ACTUAL_FLAG,
3983 USER_JE_CATEGORY_NAME,
3984 USER_JE_SOURCE_NAME,
3985 ENCUMBRANCE_TYPE_ID,
3986 CODE_COMBINATION_ID,
3987 ENTERED_DR,
3988 ENTERED_CR,
3989 GROUP_ID,
3990 REFERENCE1,
3991 REFERENCE2,
3992 REFERENCE4,
3993 REFERENCE6,
3994 REFERENCE10,
3995 ATTRIBUTE1,
3996 ATTRIBUTE2,
3997 ATTRIBUTE3,
3998 ATTRIBUTE4,
3999 ATTRIBUTE5,
4000 ATTRIBUTE6,
4001 ATTRIBUTE7,
4002 ATTRIBUTE8,
4003 ATTRIBUTE9,
4004 ATTRIBUTE10,
4005 ATTRIBUTE11,
4006 ATTRIBUTE12,
4007 ATTRIBUTE13,
4008 ATTRIBUTE14,
4009 ATTRIBUTE15,
4010 ATTRIBUTE16,
4011 ATTRIBUTE17,
4012 ATTRIBUTE18,
4013 ATTRIBUTE19,
4014 ATTRIBUTE20,
4015 REFERENCE21,
4016 REFERENCE22,
4017 REFERENCE23,
4018 REFERENCE24,
4019 REFERENCE25,
4020 REFERENCE26,
4021 REFERENCE27,
4022 REFERENCE28,
4023 REFERENCE29,
4024 REFERENCE30)
4025 VALUES(
4026 'NEW',
4027 P_SET_OF_BOOKS_ID,
4028 P_ACCOUNTING_DATE,
4029 P_CURRENCY_CODE,
4030 SYSDATE,
4031 FND_GLOBAL.USER_ID,
4032 'E',
4033 P_USER_JE_CATEGORY_NAME,
4034 P_USER_JE_SOURCE_NAME,
4035 P_ENCUMBRANCE_TYPE_ID,
4036 P_CODE_COMBINATION_ID,
4037 P_ENTERED_DR,
4038 P_ENTERED_CR,
4039 P_GROUP_ID,
4040 P_REFERENCE1,
4041 P_REFERENCE2,
4042 P_REFERENCE4,
4043 P_REFERENCE6,
4044 P_REFERENCE10,
4045 P_ATTRIBUTE1,
4046 P_ATTRIBUTE2,
4047 P_ATTRIBUTE3,
4048 P_ATTRIBUTE4,
4049 P_ATTRIBUTE5,
4050 P_ATTRIBUTE6,
4051 P_ATTRIBUTE7,
4052 P_ATTRIBUTE8,
4053 P_ATTRIBUTE9,
4054 P_ATTRIBUTE10,
4055 P_ATTRIBUTE11,
4056 P_ATTRIBUTE12,
4057 P_ATTRIBUTE13,
4058 P_ATTRIBUTE14,
4059 P_ATTRIBUTE15,
4060 P_ATTRIBUTE16,
4061 P_ATTRIBUTE17,
4062 P_ATTRIBUTE18,
4063 P_ATTRIBUTE19,
4064 P_ATTRIBUTE20,
4065 P_ATTRIBUTE21,
4066 P_ATTRIBUTE22,
4067 P_ATTRIBUTE23,
4068 P_ATTRIBUTE24,
4069 P_ATTRIBUTE25,
4070 P_ATTRIBUTE26,
4071 P_ATTRIBUTE27,
4072 P_ATTRIBUTE28,
4073 P_ATTRIBUTE29,
4074 P_ATTRIBUTE30);
4075
4076 p_return_status := fnd_api.g_ret_sts_success;
4077
4078 EXCEPTION
4079 WHEN OTHERS THEN
4080 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
4081 -- dbms_output.put_line('Error while inserting into gl_interface..........');
4082 g_error_api_path := 'insert_into_gl_int:'||g_error_api_path;
4083 fnd_msg_pub.add_exc_msg('psp_enc_sum_tran','insert_into_gl_int');
4084 p_return_status := fnd_api.g_ret_sts_unexp_error;
4085
4086
4087 END;
4088
4089 -- ##########################################################################
4090 -- This procedure summarizes all the lines from psp_enc_lines
4091 -- where gl_project_flag = 'P' and inserts the summarized lines
4092 -- into psp_enc_summary_lines
4093
4094 -- Depending on the setup options, this procedure groups transactions from
4095 -- PSP_ENC_LINES and inserts the summarized lines into PSP_ENC_SUMMARY_LINES
4096
4097 -- There are two setup options in PSP_ENC_SETUP_OPTIONS table called 'TIME_BASED_SUMM'
4098 -- and 'CI_BASED_SUMM_OGM' on which the procedure depends.
4099
4100 -- If the 'TIME_BASED_SUMM' = 1 and 'CI_BASED_SUMM_OGM' = 1
4101 -- then the summarization is done upto the employee level for each time period
4102
4103 -- If the 'TIME_BASED_SUMM' = 2 and 'CI_BASED_SUMM_OGM' = 1
4104 -- then the summarization is done upto the employee level for each GL period
4105
4106 -- ##########################################################################
4107
4108 /**** Commented for Create and Update Multi thread
4109 PROCEDURE create_gms_enc_sum_lines( p_payroll_id IN NUMBER,
4110 p_return_status OUT NOCOPY VARCHAR2
4111 ) IS
4112
4113 CURSOR enc_control_cur IS
4114 SELECT enc_control_id,
4115 payroll_id,
4116 time_period_id
4117 FROM psp_enc_controls
4118 WHERE payroll_id = nvl(p_payroll_id, payroll_id)
4119 AND (total_dr_amount IS NOT NULL OR total_cr_amount IS NOT NULL)
4120 AND action_type IN ('N', 'Q', 'U') -- Included 'Q' for Quick Upd. Enh. 2143723.
4121 AND action_code = 'I'
4122 AND run_id = g_run_id
4123 AND business_group_id = g_business_group_id
4124 AND set_of_books_id = g_set_of_books_id
4125 AND (gms_phase is null or gms_phase = 'TieBack'); --- 2444657
4126
4127 CURSOR enc_sum_lines_p_cur(
4128 p_enc_control_id IN NUMBER
4129 )IS
4130 SELECT
4131 -- ptp.end_date eff_dt, for bug fix 1971612
4132 pel.encumbrance_date eff_dt,
4133 pel.dr_cr_flag,
4134 sum(pel.encumbrance_amount) sum_amt,
4135 pel.gl_project_flag,
4136 pel.person_id,
4137 pel.assignment_id, -- Included for Enh. 2143723
4138 decode(suspense_org_account_id,NULL,pel.project_id,poa.project_id) project_id,
4139 decode(suspense_org_account_id,NULL,pel.task_id,poa.task_id) task_id ,
4140 decode(suspense_org_account_id,NULL,pel.award_id,poa.award_id)award_id ,
4141 decode(suspense_org_account_id,NULL,pel.expenditure_type,poa.expenditure_type) expenditure_type ,
4142 decode(suspense_org_account_id,NULL,pel.expenditure_organization_id,poa.expenditure_organization_id)
4143 expenditure_organization_id,
4144 -- Introduced DFF columns for bug fix 2908859
4145 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute_category, poa.attribute_category), NULL) attribute_category,
4146 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute1, poa.attribute1), NULL) attribute1,
4147 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute2, poa.attribute2), NULL) attribute2,
4148 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute3, poa.attribute3), NULL) attribute3,
4149 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute4, poa.attribute4), NULL) attribute4,
4150 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute5, poa.attribute5), NULL) attribute5,
4151 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute6, poa.attribute6), NULL) attribute6,
4152 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute7, poa.attribute7), NULL) attribute7,
4153 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute8, poa.attribute8), NULL) attribute8,
4154 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute9, poa.attribute9), NULL) attribute9,
4155 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute10, poa.attribute10), NULL) attribute10
4156 / * pel.project_id,
4157 pel.task_id,
4158 pel.award_id,
4159 pel.expenditure_type,
4160 pel.expenditure_organization_id * /
4161 -- ,pai.set_of_books_id
4162 FROM PSP_ENC_LINES PEL,
4163 PER_TIME_PERIODS PTP,
4164 PSP_ORGANIZATION_ACCOUNTS POA
4165 -- ,PA_IMPLEMENTATIONS_ALL PAI
4166 WHERE PEL.TIME_PERIOD_ID = PTP.TIME_PERIOD_ID
4167 -- AND PEL.ENCUMBRANCE_DATE BETWEEN PTP.START_DATE AND PTP.END_DATE
4168 -- Commented out for bug fix 1971612
4169 AND PEL.GL_PROJECT_FLAG = 'P'
4170 AND PEL.ENCUMBRANCE_AMOUNT <> 0
4171 AND PEL.ENC_CONTROL_ID = p_enc_control_id
4172 -- Refined the following condition for bug fix 3233373
4173 AND ( (suspense_org_account_id IS NULL AND PEL.AWARD_ID IS NOT NULL)
4174 OR (poa.award_id IS NOT NULL))
4175 -- End of bug fix 3233373
4176 AND PEL.SUSPENSE_ORG_ACCOUNT_ID = POA.ORGANIZATION_ACCOUNT_ID(+)
4177 -- AND PEL.BUSINESS_GROUP_ID = PAI.BUSINESS_GROUP_ID
4178 -- AND PAI.SET_OF_BOOKS_ID = g_set_of_books_id
4179 GROUP BY
4180 -- ptp.end_date,
4181 pel.encumbrance_date,
4182 -- pel.project_id,
4183 -- pel.task_id,
4184 -- pel.award_id,
4185 -- pel.expenditure_type,
4186 -- pel.expenditure_organization_id,
4187 DECODE(suspense_org_account_id,NULL,pel.project_id,poa.project_id),
4188 DECODE(suspense_org_account_id,NULL,pel.task_id,poa.task_id),
4189 DECODE(suspense_org_account_id,NULL,pel.award_id,poa.award_id) ,
4190 DECODE(suspense_org_account_id,NULL,pel.expenditure_type,poa.expenditure_type) ,
4191 DECODE(suspense_org_account_id,NULL,pel.expenditure_organization_id,poa.expenditure_organization_id),
4192 pel.person_id,
4193 pel.assignment_id, -- Included for Enh. 2143723
4194 pel.dr_cr_flag,
4195 pel.gl_project_flag,
4196 -- Introduced DFF columns for bug fix 2908859
4197 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute_category, poa.attribute_category), NULL),
4198 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute1, poa.attribute1), NULL),
4199 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute2, poa.attribute2), NULL),
4200 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute3, poa.attribute3), NULL),
4201 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute4, poa.attribute4), NULL),
4202 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute5, poa.attribute5), NULL),
4203 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute6, poa.attribute6), NULL),
4204 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute7, poa.attribute7), NULL),
4205 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute8, poa.attribute8), NULL),
4206 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute9, poa.attribute9), NULL),
4207 DECODE(g_dff_grouping_option, 'Y', DECODE(suspense_org_account_id, NULL, pel.attribute10, poa.attribute10), NULL);
4208 -- ,pai.set_of_books_id;
4209
4210 / *
4211 Code commented out as this is obsolete now
4212 Bug fix 1971612/1831493
4213
4214 CURSOR enc_sum_lines_g_cur(
4215 p_enc_control_id IN NUMBER
4216 ) IS
4217 SELECT glp.end_date eff_dt,
4218 pel.dr_cr_flag,
4219 sum(pel.encumbrance_amount) sum_amt,
4220 pel.gl_project_flag,
4221 pel.person_id,
4222 pel.project_id,
4223 pel.task_id,
4224 pel.award_id,
4225 pel.expenditure_type,
4226 pel.expenditure_organization_id,
4227 pai.set_of_books_id
4228 FROM PSP_ENC_LINES PEL,
4229 GL_PERIODS GLP,
4230 PA_IMPLEMENTATIONS_ALL PAI
4231 WHERE PEL.BUSINESS_GROUP_ID = PAI.BUSINESS_GROUP_ID
4232 AND GLP.PERIOD_TYPE = PAI.PA_PERIOD_TYPE
4233 AND PEL.ENCUMBRANCE_DATE BETWEEN GLP.START_DATE AND GLP.END_DATE
4234 AND PEL.GL_PROJECT_FLAG = 'P'
4235 AND PEL.ENCUMBRANCE_AMOUNT <> 0
4236 AND PEL.ENC_CONTROL_ID = p_enc_control_id
4237 AND PAI.SET_OF_BOOKS_ID = g_set_of_books_id
4238 AND PEL.AWARD_ID IS NOT NULL
4239 GROUP BY glp.end_date,
4240 pel.project_id,
4241 pel.task_id,
4242 pel.award_id,
4243 pel.expenditure_type,
4244 pel.expenditure_organization_id,
4245 pel.person_id,
4246 pel.dr_cr_flag,
4247 pel.gl_project_flag,
4248 pai.set_of_books_id;
4249
4250
4251 l_time_para_value VARCHAR2(1);
4252 l_ogm_para_value VARCHAR2(1);
4253
4254 commented the above variable as part of Enh. 2143723
4255 * /
4256
4257 l_bg_id NUMBER := g_business_group_id;
4258 enc_control_rec enc_control_cur%ROWTYPE;
4259 enc_sum_lines_p_rec enc_sum_lines_p_cur%ROWTYPE;
4260
4261 /**************************************************************************
4262 enc_sum_lines_g_rec enc_sum_lines_g_cur%ROWTYPE;
4263
4264 Bug fix 1971613 /Bug 1831493
4265 ***************************************************************************** /
4266
4267 l_enc_summary_line_id NUMBER(10);
4268 l_return_status VARCHAR2(10);
4269 l_error VARCHAR2(100);
4270 l_product VARCHAR2(3);
4271
4272 BEGIN
4273
4274 / * Commented the following code as Enc. Sum. and Tr. setup options are obsolete as part of Enh. 2143723
4275
4276 BEGIN
4277 SELECT parameter_value
4278 INTO l_time_para_value
4279 FROM psp_enc_setup_options
4280 WHERE setup_parameter = 'TIME_BASED_SUMM'
4281 AND business_group_id = l_bg_id;
4282 EXCEPTION
4283 WHEN NO_DATA_FOUND THEN
4284 l_error := 'TIME_BASED_SUMM';
4285 l_product := 'PSP';
4286 fnd_message.set_name('PSP','PSP_TR_NOT_SET_UP');
4287 fnd_message.set_token('ERROR',l_error);
4288 fnd_message.set_token('PRODUCT',l_product);
4289 fnd_msg_pub.add;
4290 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4291 END;
4292
4293 BEGIN
4294 SELECT parameter_value
4295 INTO l_ogm_para_value
4296 FROM psp_enc_setup_options
4297 WHERE setup_parameter = 'CI_BASED_SUMM_OGM'
4298 AND business_group_id = l_bg_id;
4299 EXCEPTION
4300 WHEN NO_DATA_FOUND THEN
4301 l_error := 'CI_BASED_SUMM_OGM';
4302 l_product := 'PSP';
4303 fnd_message.set_name('PSP','PSP_TR_NOT_SET_UP');
4304 fnd_message.set_token('ERROR',l_error);
4305 fnd_message.set_token('PRODUCT',l_product);
4306 fnd_msg_pub.add;
4307 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4308 END;
4309
4310 IF l_time_para_value = '1' and l_ogm_para_value = '1' THEN
4311 End of Enh. fix 2143723 * /
4312
4313 OPEN enc_control_cur;
4314 LOOP
4315 FETCH enc_control_cur INTO enc_control_rec;
4316 IF enc_control_cur%NOTFOUND THEN
4317 CLOSE enc_control_cur;
4318 EXIT;
4319 END IF;
4320
4321 OPEN enc_sum_lines_p_cur(enc_control_rec.enc_control_id);
4322 LOOP
4323 FETCH enc_sum_lines_p_cur INTO enc_sum_lines_p_rec;
4324 IF enc_sum_lines_p_cur%ROWCOUNT = 0 THEN
4325 CLOSE enc_sum_lines_p_cur;
4326 EXIT;
4327 ELSIF enc_sum_lines_p_cur%NOTFOUND THEN
4328 update psp_enc_controls
4329 set gms_phase = 'Summarize' ---NULL commented for 2444657
4330 where enc_control_id = enc_control_rec.enc_control_id;
4331 CLOSE enc_sum_lines_p_cur;
4332 EXIT;
4333 END IF;
4334
4335 IF enc_sum_lines_p_rec.dr_cr_flag = 'C' THEN
4336 enc_sum_lines_p_rec.sum_amt := 0 - enc_sum_lines_p_rec.sum_amt;
4337 END IF;
4338 insert_into_enc_sum_lines(
4339 l_enc_summary_line_id,
4340 L_BG_ID,
4341 enc_control_rec.enc_control_id,
4342 enc_control_rec.time_period_id,
4343 enc_sum_lines_p_rec.person_id,
4344 enc_sum_lines_p_rec.assignment_id, --Included for Enh. 2143723
4345 enc_sum_lines_p_rec.eff_dt,
4346 -- enc_sum_lines_p_rec.set_of_books_id,
4347 g_set_of_books_id,
4348 NULL,
4349 enc_sum_lines_p_rec.project_id,
4350 enc_sum_lines_p_rec.expenditure_organization_id,
4351 enc_sum_lines_p_rec.expenditure_type,
4352 enc_sum_lines_p_rec.task_id,
4353 enc_sum_lines_p_rec.award_id,
4354 enc_sum_lines_p_rec.sum_amt,
4355 enc_sum_lines_p_rec.dr_cr_flag,
4356 'N',
4357 enc_control_rec.payroll_id,
4358 NULL,
4359 enc_sum_lines_p_rec.gl_project_flag,
4360 enc_sum_lines_p_rec.attribute_category, -- Introduced DFF columns for bug fix 2908859
4361 enc_sum_lines_p_rec.attribute1,
4362 enc_sum_lines_p_rec.attribute2,
4363 enc_sum_lines_p_rec.attribute3,
4364 enc_sum_lines_p_rec.attribute4,
4365 enc_sum_lines_p_rec.attribute5,
4366 enc_sum_lines_p_rec.attribute6,
4367 enc_sum_lines_p_rec.attribute7,
4368 enc_sum_lines_p_rec.attribute8,
4369 enc_sum_lines_p_rec.attribute9,
4370 enc_sum_lines_p_rec.attribute10,
4371 p_return_status);
4372 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4373 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4374 END IF;
4375
4376 IF (g_dff_grouping_option = 'N') THEN -- Introduced for bug fix 2908859
4377 UPDATE psp_enc_lines
4378 SET enc_summary_line_id = l_enc_summary_line_id
4379 WHERE -- project_id = enc_sum_lines_p_rec.project_id Commented for bug fix 3194807
4380 -- Introduced the suspense_org_account verification for bug fix 3194807
4381 ( (suspense_org_account_id IS NOT NULL
4382 AND suspense_reason_code like 'ES:%'
4383 AND EXISTS (SELECT 1 FROM psp_organization_accounts poa
4384 WHERE poa.organization_account_id = suspense_org_account_id
4385 AND poa.project_id = enc_sum_lines_p_rec.project_id
4386 AND poa.task_id = enc_sum_lines_p_rec.task_id
4387 AND poa.expenditure_organization_id = enc_sum_lines_p_rec.expenditure_organization_id
4388 AND poa.expenditure_type = enc_sum_lines_p_rec.expenditure_type
4389 AND poa.award_id = enc_sum_lines_p_rec.award_id))
4390 OR (project_id = enc_sum_lines_p_rec.project_id
4391 AND task_id = enc_sum_lines_p_rec.task_id
4392 AND expenditure_organization_id = enc_sum_lines_p_rec.expenditure_organization_id
4393 AND expenditure_type = enc_sum_lines_p_rec.expenditure_type
4394 AND award_id = enc_sum_lines_p_rec.award_id))
4395 -- AND task_id = enc_sum_lines_p_rec.task_id Commented for bug fix 3194807
4396 AND enc_control_id = enc_control_rec.enc_control_id
4397 AND time_period_id = enc_control_rec.time_period_id
4398 -- AND award_id = enc_sum_lines_p_rec.award_id Commented for bug fix 3194807
4399 -- AND expenditure_type = enc_sum_lines_p_rec.expenditure_type Commented for bug fix 3194807
4400 -- AND expenditure_organization_id = enc_sum_lines_p_rec.expenditure_organization_id Commented for bug fix 3194807
4401 AND person_id = enc_sum_lines_p_rec.person_id
4402 -- Included the following chek for Enh. 2143723
4403 AND assignment_id = enc_sum_lines_p_rec.assignment_id
4404 AND dr_cr_flag = enc_sum_lines_p_rec.dr_cr_flag
4405 AND gl_project_flag = enc_sum_lines_p_rec.gl_project_flag
4406 AND trunc(encumbrance_date) = trunc(enc_sum_lines_p_rec.eff_dt); ---- bug 3462452
4407 -- AND set_of_books_id = enc_sum_lines_p_rec.set_of_books_id;
4408 -- Introduced ELSE portion for bug fix 2908859
4409 ELSE
4410 UPDATE psp_enc_lines
4411 SET enc_summary_line_id = l_enc_summary_line_id
4412 WHERE enc_control_id = enc_control_rec.enc_control_id
4413 AND payroll_id = enc_control_rec.payroll_id
4414 AND time_period_id = enc_control_rec.time_period_id
4415 AND person_id = enc_sum_lines_p_rec.person_id
4416 AND assignment_id = enc_sum_lines_p_rec.assignment_id
4417 AND dr_cr_flag = enc_sum_lines_p_rec.dr_cr_flag
4418 AND gl_project_flag = enc_sum_lines_p_rec.gl_project_flag
4419 AND trunc(encumbrance_date) = trunc(enc_sum_lines_p_rec.eff_dt) --- added for 3462452
4420 AND ( (suspense_org_account_id IS NOT NULL
4421 AND suspense_reason_code like 'ES:%'
4422 AND EXISTS (SELECT 1 FROM psp_organization_accounts poa
4423 WHERE poa.organization_account_id = suspense_org_account_id
4424 AND poa.project_id = enc_sum_lines_p_rec.project_id
4425 AND poa.task_id = enc_sum_lines_p_rec.task_id
4426 AND poa.expenditure_organization_id = enc_sum_lines_p_rec.expenditure_organization_id
4427 AND poa.expenditure_type = enc_sum_lines_p_rec.expenditure_type
4428 AND poa.award_id = enc_sum_lines_p_rec.award_id
4429 AND NVL(poa.attribute_category, 'NULL') =
4430 NVL(enc_sum_lines_p_rec.attribute_category, 'NULL')
4431 AND NVL(poa.attribute1, 'NULL') = NVL(enc_sum_lines_p_rec.attribute1, 'NULL')
4432 AND NVL(poa.attribute2, 'NULL') = NVL(enc_sum_lines_p_rec.attribute2, 'NULL')
4433 AND NVL(poa.attribute3, 'NULL') = NVL(enc_sum_lines_p_rec.attribute3, 'NULL')
4434 AND NVL(poa.attribute4, 'NULL') = NVL(enc_sum_lines_p_rec.attribute4, 'NULL')
4435 AND NVL(poa.attribute5, 'NULL') = NVL(enc_sum_lines_p_rec.attribute5, 'NULL')
4436 AND NVL(poa.attribute6, 'NULL') = NVL(enc_sum_lines_p_rec.attribute6, 'NULL')
4437 AND NVL(poa.attribute7, 'NULL') = NVL(enc_sum_lines_p_rec.attribute7, 'NULL')
4438 AND NVL(poa.attribute8, 'NULL') = NVL(enc_sum_lines_p_rec.attribute8, 'NULL')
4439 AND NVL(poa.attribute9, 'NULL') = NVL(enc_sum_lines_p_rec.attribute9, 'NULL')
4440 AND NVL(poa.attribute10, 'NULL') = NVL(enc_sum_lines_p_rec.attribute10, 'NULL')))
4441 OR ( project_id = enc_sum_lines_p_rec.project_id
4442 AND task_id = enc_sum_lines_p_rec.task_id
4443 AND expenditure_organization_id = enc_sum_lines_p_rec.expenditure_organization_id
4444 AND expenditure_type = enc_sum_lines_p_rec.expenditure_type
4445 AND award_id = enc_sum_lines_p_rec.award_id
4446 AND NVL(attribute_category, 'NULL') = NVL(enc_sum_lines_p_rec.attribute_category, 'NULL')
4447 AND NVL(attribute1, 'NULL') = NVL(enc_sum_lines_p_rec.attribute1, 'NULL')
4448 AND NVL(attribute2, 'NULL') = NVL(enc_sum_lines_p_rec.attribute2, 'NULL')
4449 AND NVL(attribute3, 'NULL') = NVL(enc_sum_lines_p_rec.attribute3, 'NULL')
4450 AND NVL(attribute4, 'NULL') = NVL(enc_sum_lines_p_rec.attribute4, 'NULL')
4451 AND NVL(attribute5, 'NULL') = NVL(enc_sum_lines_p_rec.attribute5, 'NULL')
4452 AND NVL(attribute6, 'NULL') = NVL(enc_sum_lines_p_rec.attribute6, 'NULL')
4453 AND NVL(attribute7, 'NULL') = NVL(enc_sum_lines_p_rec.attribute7, 'NULL')
4454 AND NVL(attribute8, 'NULL') = NVL(enc_sum_lines_p_rec.attribute8, 'NULL')
4455 AND NVL(attribute9, 'NULL') = NVL(enc_sum_lines_p_rec.attribute9, 'NULL')
4456 AND NVL(attribute10, 'NULL') = NVL(enc_sum_lines_p_rec.attribute10, 'NULL')));
4457 -- Introduced ELSE portion for bug fix 2908859
4458 END IF;
4459 END LOOP;
4460
4461 END LOOP;
4462
4463
4464 / *********************************************************************************************
4465
4466 THe Summarize by gl _period option is obsolete nad no longer supported , refer bug
4467 ELSIF l_time_para_value = '2' and l_ogm_para_value = '1' THEN
4468
4469 OPEN enc_control_cur;
4470 LOOP
4471 FETCH enc_control_cur INTO enc_control_rec;
4472 IF enc_control_cur%NOTFOUND THEN
4473 CLOSE enc_control_cur;
4474 EXIT;
4475 END IF;
4476
4477 OPEN enc_sum_lines_g_cur(enc_control_rec.enc_control_id);
4478 LOOP
4479 FETCH enc_sum_lines_g_cur INTO enc_sum_lines_g_rec;
4480 IF enc_sum_lines_g_cur%ROWCOUNT = 0 THEN
4481 CLOSE enc_sum_lines_g_cur;
4482 EXIT;
4483 ELSIF enc_sum_lines_g_cur%NOTFOUND THEN
4484 update psp_enc_controls
4485 set gms_phase = NULL
4486 where enc_control_id = enc_control_rec.enc_control_id;
4487 CLOSE enc_sum_lines_g_cur;
4488 EXIT;
4489 END IF;
4490 insert_into_enc_sum_lines(
4491 l_enc_summary_line_id,
4492 l_bg_id,
4493 enc_control_rec.enc_control_id,
4494 enc_control_rec.time_period_id,
4495 enc_sum_lines_g_rec.person_id,
4496 NULL,
4497 enc_sum_lines_g_rec.eff_dt,
4498 enc_sum_lines_g_rec.set_of_books_id,
4499 NULL,
4500 enc_sum_lines_g_rec.project_id,
4501 enc_sum_lines_g_rec.expenditure_organization_id,
4502 enc_sum_lines_g_rec.expenditure_type,
4503 enc_sum_lines_g_rec.task_id,
4504 enc_sum_lines_g_rec.award_id,
4505 enc_sum_lines_g_rec.sum_amt,
4506 enc_sum_lines_g_rec.dr_cr_flag,
4507 'N',
4508 enc_control_rec.payroll_id,
4509 NULL,
4510 enc_sum_lines_g_rec.gl_project_flag,
4511 l_return_status);
4512 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
4513 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4514 END IF;
4515
4516 UPDATE psp_enc_lines
4517 SET enc_summary_line_id = l_enc_summary_line_id
4518 WHERE project_id = enc_sum_lines_g_rec.project_id
4519 AND task_id = enc_sum_lines_g_rec.task_id
4520 AND enc_control_id = enc_control_rec.enc_control_id
4521 AND time_period_id = enc_control_rec.time_period_id
4522 AND award_id = enc_sum_lines_g_rec.award_id
4523 AND expenditure_type = enc_sum_lines_g_rec.expenditure_type
4524 AND expenditure_organization_id = enc_sum_lines_g_rec.expenditure_organization_id
4525 AND person_id = enc_sum_lines_g_rec.person_id
4526 AND dr_cr_flag = enc_sum_lines_g_rec.dr_cr_flag
4527 AND gl_project_flag = enc_sum_lines_g_rec.gl_project_flag;
4528 --AND set_of_books_id = enc_sum_lines_g_rec.set_of_books_id;
4529 END LOOP;
4530
4531 END LOOP;
4532 END IF; Commented this END IF as part of Enh. 2143723
4533 ********************************************************************************** /
4534
4535 --COMMIT;
4536 p_return_status := fnd_api.g_ret_sts_success;
4537
4538 EXCEPTION
4539 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
4540 g_error_api_path := 'CREATE_GMS_ENC_SUM_LINES:'||g_error_api_path;
4541 p_return_status := fnd_api.g_ret_sts_unexp_error;
4542
4543 WHEN OTHERS THEN
4544 g_error_api_path := 'CREATE_GMS_ENC_SUM_LINES:'||g_error_api_path;
4545 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN','CREATE_GMS_ENC_SUM_LINES');
4546 p_return_status := fnd_api.g_ret_sts_unexp_error;
4547
4548 END;
4549 End of comment for Create and Update multi thread *****/
4550
4551 -- ##########################################################################
4552 -- This procedure transfers summarized lines from psp_enc_summary_lines
4553 -- with gl_project_flag = 'P' to pa_transaction_interface
4554
4555 -- This procedure transfers lines from PSP_ENC_SUMMARY_LINES into PA_TRANSACTION_INTERFACE,
4556 -- kicks off the TRANSACTION IMPORT program in GMS and sends ENC_CONTROL_ID, END_DATE for
4557 -- the relevant TIME_PERIOD_ID and GMS_BATCH_NAME into the tie back procedure.
4558 -- ##########################################################################
4559 -- Introduced the following modified procedure for Create and Update multi thread
4560 PROCEDURE tr_to_gms_int(p_payroll_action_id IN NUMBER,
4561 p_return_status OUT NOCOPY VARCHAR2) IS
4562 l_tr_source VARCHAR2(30);
4563 l_exp_end_dt DATE;
4564 l_return_status VARCHAR2(50);
4565 req_id NUMBER(15);
4566 call_status BOOLEAN;
4567 rphase VARCHAR2(30);
4568 rstatus VARCHAR2(30);
4569 dphase VARCHAR2(30);
4570 dstatus VARCHAR2(30);
4571 message VARCHAR2(240);
4572 p_errbuf VARCHAR2(32767);
4573 p_retcode VARCHAR2(32767);
4574 return_back EXCEPTION;
4575 l_rec_count NUMBER;
4576 l_error VARCHAR2(100);
4577 l_product VARCHAR2(3);
4578 l_value VARCHAR2(200);
4579 l_table VARCHAR2(100);
4580 l_rec_no NUMBER;
4581 l_effective_date DATE;
4582 l_tie_back_failed VARCHAR2(1);
4583 l_gms_batch_name VARCHAR2(10);
4584 l_raise_error BOOLEAN;
4585
4586 CURSOR int_cur IS
4587 SELECT pa_txn_interface_s.NEXTVAL,
4588 pesl.enc_summary_line_id,
4589 pesl.effective_date,
4590 pesl.time_period_id,
4591 pesl.person_id,
4592 pesl.project_id,
4593 pesl.task_id,
4594 pesl.award_id,
4595 pesl.expenditure_type,
4596 pesl.expenditure_organization_id,
4597 DECODE(pec.uom, 'M', g_currency_code, 'STAT') currency_code,
4598 TO_NUMBER(DECODE(pec.uom, 'H', pesl.summary_amount, 1)) quantity,
4599 TO_NUMBER(DECODE(pec.uom, 'M', pesl.summary_amount, 0)) summary_amount,
4600 pesl.dr_cr_flag,
4601 pesl.attribute2,
4602 pesl.attribute3,
4603 pesl.attribute6,
4604 pesl.attribute7,
4605 pesl.attribute8,
4606 pesl.attribute9,
4607 pesl.attribute10,
4608 pesl.expenditure_item_id,
4609 hou.name exp_org_name,
4610 ppa.segment1 project_number,
4611 ppa.org_id operating_unit,
4612 pt.task_number,
4613 TO_CHAR(pesl.enc_control_id) || ':' || ptp.period_name expenditure_comment,
4614 ptp.period_name,
4615 ptp.end_date,
4616 pesl.effective_date,
4617 pesl.gms_batch_name,
4618 DECODE(pec.uom, 'H', DECODE(SIGN(summary_amount), -1, 'Y')) unmatched_nve_txn_flag, --6242618
4619 papf.employee_number --Added for Bug 10126350
4620 FROM psp_enc_summary_lines pesl,
4621 hr_organization_units hou,
4622 pa_projects_all ppa,
4623 pa_tasks_expend_v pt, -- Bug : 16391366 (20/03/2013)
4624 per_time_periods ptp,
4625 psp_enc_controls pec
4626 ,per_all_people_f papf --Added for Bug 10126350
4627 WHERE pec.payroll_action_id = p_payroll_action_id
4628 AND pec.enc_control_id = pesl.enc_control_id
4629 AND pesl.status_code = 'N'
4630 AND pesl.gl_code_combination_id IS NULL
4631 AND pesl.award_id IS NOT NULL
4632 AND pesl.superceded_line_id IS NULL
4633 AND pesl.expenditure_organization_id = hou.organization_id (+)
4634 AND pesl.project_id = ppa.project_id (+)
4635 AND pesl.task_id = pt.task_id (+)
4636 AND pesl.time_period_id = ptp.time_period_id
4637 AND gms_batch_name IS NOT NULL
4638 AND papf.person_id = pesl.person_id --Added for Bug 10126350
4639 AND pesl.effective_date between papf.effective_start_date and papf.effective_end_date --Added for Bug 10126350
4640 ;
4641
4642 TYPE GMS_TIE_RECTYPE IS RECORD
4643 (R_CONTROL_ID NUMBER,
4644 R_END_DATE DATE,
4645 R_GMS_BATCH_NAME VARCHAR2(80));
4646
4647 GMS_TIE_REC GMS_TIE_RECTYPE;
4648
4649 TYPE GMS_TIE_TABTYPE IS TABLE OF GMS_TIE_REC%TYPE INDEX BY BINARY_INTEGER;
4650
4651 GMS_TIE_TAB GMS_TIE_TABTYPE;
4652 gms_rec gms_transaction_interface_all%ROWTYPE;
4653 l_txn_source varchar2(30);
4654 l_gms_transaction_source VARCHAR2(30);
4655 l_org_id NUMBER(15);
4656 l_txn_interface_id NUMBER;
4657 l_gms_install BOOLEAN DEFAULT gms_install.enabled;
4658
4659 TYPE t_number IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
4660 TYPE t_number_15 IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
4661 TYPE t_char_300 IS TABLE OF VARCHAR2(300) INDEX BY BINARY_INTEGER;
4662 TYPE t_date IS TABLE OF DATE INDEX BY BINARY_INTEGER;
4663
4664 TYPE r_enc_control_rec IS RECORD (enc_control_id t_number_15);
4665 r_enc_controls r_enc_control_rec;
4666
4667 CURSOR enc_control_id_cur IS
4668 SELECT DISTINCT enc_control_id
4669 FROM psp_enc_summary_lines
4670 WHERE payroll_action_id = p_payroll_action_id
4671 AND superceded_line_id IS NULL
4672 AND gms_batch_name IS NOT NULL;
4673
4674 CURSOR transaction_source_cur IS
4675 SELECT transaction_source
4676 FROM pa_transaction_sources
4677 WHERE transaction_source = 'GOLDE';
4678
4679 CURSOR gms_batch_name_cur IS
4680 SELECT DISTINCT gms_batch_name
4681 FROM psp_enc_summary_lines pesl
4682 WHERE payroll_action_id = p_payroll_action_id
4683 AND status_code = 'N'
4684 AND superceded_line_id IS NULL
4685 AND gl_code_combination_id IS NULL;
4686
4687 CURSOR employee_number_cur IS
4688 SELECT DISTINCT pesl.person_id,
4689 papf.employee_number
4690 FROM per_all_people_f papf,
4691 psp_enc_summary_lines pesl
4692 WHERE pesl.payroll_action_id = p_payroll_action_id
4693 AND papf.person_id = pesl.person_id
4694 AND pesl.superceded_line_id IS NULL
4695 AND pesl.gms_batch_name IS NOT NULL
4696 AND pesl.effective_date BETWEEN papf.effective_start_date AND papf.effective_end_date;
4697
4698 TYPE r_gms_batch_rec IS RECORD (gms_batch_name t_char_300);
4699 r_gms_batch r_gms_batch_rec;
4700
4701 TYPE t_person IS RECORD
4702 (person_id t_number_15,
4703 employee_number t_char_300);
4704 r_person t_person;
4705
4706 TYPE t_interface IS RECORD
4707 (txn_interface_id t_number_15,
4708 enc_summary_line_id t_number_15,
4709 effective_date t_date,
4710 time_period_id t_number_15,
4711 person_id t_number_15,
4712 project_id t_number_15,
4713 task_id t_number_15,
4714 award_id t_number_15,
4715 expenditure_type t_char_300,
4716 expenditure_organization_id t_number_15,
4717 currency_code t_char_300,
4718 quantity t_number,
4719 summary_amount t_number,
4720 unmatched_nve_txn_flag t_char_300,
4721 dr_cr_flag t_char_300,
4722 attribute2 t_char_300,
4723 attribute3 t_char_300,
4724 attribute6 t_char_300,
4725 attribute7 t_char_300,
4726 attribute8 t_char_300,
4727 attribute9 t_char_300,
4728 attribute10 t_char_300,
4729 expenditure_item_id t_number_15,
4730 employee_number t_char_300,
4731 exp_org_name t_char_300,
4732 project_number t_char_300,
4733 operating_unit t_char_300,
4734 task_number t_char_300,
4735 expenditure_comment t_char_300,
4736 period_name t_char_300,
4737 end_date t_date,
4738 gms_overriding_date t_date,
4739 exp_end_date t_date,
4740 gms_batch_name t_char_300);
4741
4742 r_interface t_interface;
4743
4744 -- R12 MOAC Uptake
4745 TYPE org_id_type IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
4746 org_id_tab org_id_type;
4747
4748 TYPE gms_batch_name_type IS TABLE OF VARCHAR2(10) INDEX BY BINARY_INTEGER;
4749 gms_batch_name_tab gms_batch_name_type;
4750
4751 TYPE req_id_TYPE is TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
4752 req_id_tab req_id_TYPE;
4753
4754 TYPE call_status_TYPE IS TABLE OF BOOLEAN INDEX BY BINARY_INTEGER;
4755 call_status_tab call_status_TYPE;
4756
4757 CURSOR operating_unit_csr IS
4758 SELECT DISTINCT org_id
4759 FROM psp_enc_summary_lines
4760 WHERE status_code = 'N'
4761 AND gl_code_combination_id IS NULL
4762 AND gms_batch_name IS NULL
4763 AND payroll_action_id = p_payroll_action_id;
4764
4765 BEGIN
4766 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Entering TR_TO_GMS_INT');
4767
4768 l_tie_back_failed:= NULL;
4769 l_rec_no := 0;
4770 l_rec_count := 0;
4771
4772 IF (l_gms_install) THEN
4773 OPEN transaction_source_cur;
4774 FETCH transaction_source_cur INTO l_gms_transaction_source;
4775 CLOSE transaction_source_cur;
4776
4777 IF (l_gms_transaction_source IS NULL) THEN
4778 fnd_message.set_name('PSP','PSP_TR_NOT_SET_UP');
4779 fnd_message.set_token('ERROR','TRANSACTION SOURCE = GOLDE');
4780 fnd_message.set_token('PRODUCT','GMS');
4781 fnd_msg_pub.add;
4782 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4783 END IF;
4784 END IF;
4785
4786 -- R12 MOAC Uptake
4787 org_id_tab.delete;
4788 gms_batch_name_tab.delete;
4789 req_id_tab.delete;
4790 call_status_tab.delete;
4791
4792 OPEN operating_unit_csr;
4793 FETCH operating_unit_csr BULK COLLECT INTO org_id_tab;
4794 CLOSE operating_unit_csr;
4795 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' org_id_tab.COUNT: ' || org_id_tab.COUNT);
4796
4797 FOR I in 1..org_id_tab.COUNT
4798 LOOP
4799 SELECT TO_CHAR(psp_gms_batch_name_s.NEXTVAL)
4800 INTO gms_batch_name_tab(i)
4801 FROM DUAL;
4802 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' gms_batch_name_tab(' || I || '): ' || gms_batch_name_tab(i));
4803 END LOOP;
4804
4805
4806 FORALL I IN 1..org_id_tab.count
4807 UPDATE psp_enc_summary_lines pesl
4808 SET gms_batch_name = gms_batch_name_tab(i)
4809 WHERE status_code = 'N'
4810 AND gl_code_combination_id IS NULL
4811 AND gms_batch_name IS NULL
4812 ANd superceded_line_id IS NULL
4813 AND NOT EXISTS (SELECT 1
4814 FROM psp_enc_summary_lines pesl2
4815 WHERE pesl2.payroll_action_id = p_payroll_action_id
4816 AND pesl2.assignment_id = pesl.assignment_id
4817 AND pesl2.time_period_id = pesl.time_period_id
4818 AND pesl2.status_code IN ('N', 'R')
4819 AND pesl2.superceded_line_id IS NOT NULL)
4820 AND payroll_action_id = p_payroll_action_id
4821 AND org_id = org_id_tab(i);
4822
4823 g_bulk_row_count :=0;
4824 FOR bulk_idx IN 1..org_id_tab.count
4825 loop
4826 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
4827 end loop;
4828
4829 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'updating psp_enc_summary_lines setting status_code N count: '||g_bulk_row_count);
4830
4831 OPEN int_cur;
4832 FETCH int_cur BULK COLLECT INTO r_interface.txn_interface_id, r_interface.enc_summary_line_id,
4833 r_interface.effective_date, r_interface.time_period_id,
4834 r_interface.person_id, r_interface.project_id,
4835 r_interface.task_id, r_interface.award_id,
4836 r_interface.expenditure_type, r_interface.expenditure_organization_id,
4837 r_interface.currency_code, r_interface.quantity,
4838 r_interface.summary_amount, r_interface.dr_cr_flag,
4839 r_interface.attribute2, r_interface.attribute3,
4840 r_interface.attribute6, r_interface.attribute7,
4841 r_interface.attribute8, r_interface.attribute9,
4842 r_interface.attribute10, r_interface.expenditure_item_id,
4843 r_interface.exp_org_name, r_interface.project_number,
4844 r_interface.operating_unit, r_interface.task_number,
4845 r_interface.expenditure_comment, r_interface.period_name,
4846 r_interface.end_date, r_interface.gms_overriding_date,
4847 r_interface.gms_batch_name,r_interface.unmatched_nve_txn_flag,
4848 r_interface.employee_number --Added for Bug 10126350
4849 ;
4850 CLOSE int_cur;
4851
4852 /*
4853 FOR I IN 1..r_interface.txn_interface_id.count
4854 LOOP
4855 FOR J IN 1..org_id_tab.count
4856 LOOP
4857 IF org_id_tab(J) = r_interface.operating_unit(I) THEN
4858 r_interface.gms_batch_name(I) := gms_batch_name_tab(J);
4859 EXIT;
4860 END IF;
4861 END LOOP;
4862 END LOOP;
4863 */
4864
4865 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' r_interface.txn_interface_id.COUNT: ' || r_interface.txn_interface_id.COUNT);
4866 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Verifying interface records for errors');
4867
4868 -- Commented the following for Bug 10126350
4869 /*
4870 OPEN employee_number_cur;
4871 FETCH employee_number_cur BULK COLLECT INTO r_person.person_id, r_person.employee_number;
4872 CLOSE employee_number_cur;
4873 */
4874 l_raise_error := FALSE;
4875 FOR recno IN 1..r_interface.txn_interface_id.COUNT
4876 LOOP
4877 -- Commented the following for Bug 10126350
4878 /* FOR emp_recno IN 1..r_person.person_id.COUNT
4879 LOOP
4880 IF (r_interface.person_id(recno) = r_person.person_id(emp_recno)) THEN
4881 r_interface.employee_number(recno) := r_person.employee_number(emp_recno);
4882 EXIT;
4883 END IF;
4884 END LOOP;
4885 */
4886
4887
4888 IF r_interface.employee_number(recno) IS NULL THEN
4889 fnd_message.set_name('PSP','PSP_TR_VALUE_NOT_FOUND');
4890 fnd_message.set_token('VALUE', 'person_id: ' || r_interface.person_id(recno));
4891 fnd_message.set_token('TABLE', 'PER_PEOPLE_F');
4892 fnd_msg_pub.add;
4893 l_raise_error := TRUE;
4894 END IF;
4895
4896 IF r_interface.exp_org_name(recno) IS NULL THEN
4897 fnd_message.set_name('PSP','PSP_TR_VALUE_NOT_FOUND');
4898 fnd_message.set_token('VALUE', 'org_id: ' || r_interface.expenditure_organization_id(recno));
4899 fnd_message.set_token('TABLE', 'HR_ORGANIZATION_UNITS');
4900 fnd_msg_pub.add;
4901 l_raise_error := TRUE;
4902 END IF;
4903
4904 IF r_interface.operating_unit(recno) IS NULL THEN
4905 fnd_message.set_name('PSP','PSP_ORG_VALUE_NOT_FOUND');
4906 fnd_message.set_token('VALUE', 'project_id: ' || r_interface.project_id(recno));
4907 fnd_message.set_token('TABLE', 'PA_PROJECTS_ALL');
4908 fnd_msg_pub.add;
4909 l_raise_error := TRUE;
4910 END IF;
4911
4912 IF r_interface.project_number(recno) IS NULL THEN
4913 fnd_message.set_name('PSP','PSP_TR_VALUE_NOT_FOUND');
4914 fnd_message.set_token('VALUE', 'project_id: ' || r_interface.project_id(recno));
4915 fnd_message.set_token('TABLE', 'PA_PROJECTS_ALL');
4916 fnd_msg_pub.add;
4917 l_raise_error := TRUE;
4918 END IF;
4919
4920 IF r_interface.task_number(recno) IS NULL THEN
4921 fnd_message.set_name('PSP','PSP_TR_VALUE_NOT_FOUND');
4922 fnd_message.set_token('VALUE', 'task_id: ' || r_interface.task_id(recno));
4923 fnd_message.set_token('TABLE', 'PA_TASKS');
4924 fnd_msg_pub.add;
4925 l_raise_error := TRUE;
4926 END IF;
4927 END LOOP;
4928
4929 IF l_raise_error THEN
4930 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Interface records have errors');
4931 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4932 END IF;
4933
4934 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Completed interface records for errors');
4935 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Computing PA week ending date(s)');
4936
4937 FOR recno IN 1..r_interface.txn_interface_id.COUNT
4938 LOOP
4939 psp_general.get_gms_effective_date(r_interface.person_id(recno), r_interface.gms_overriding_date(recno));
4940 -- set the context to single to call pa_utils function
4941 mo_global.set_policy_context('S', r_interface.operating_unit(recno) );
4942 r_interface.exp_end_date(recno) := pa_utils.getweekending(r_interface.gms_overriding_date(recno));
4943 END LOOP;
4944 -- set the context again to multiple
4945 mo_global.set_policy_context('M', null);
4946
4947 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Completed computation of PA week ending date(s)');
4948
4949 FORALL recno IN 1..r_interface.txn_interface_id.COUNT
4950 UPDATE psp_enc_summary_lines pesl
4951 SET gms_posting_override_date = r_interface.gms_overriding_date(recno)
4952 WHERE pesl.enc_summary_line_id = r_interface.enc_summary_line_id(recno)
4953 AND TRUNC(r_interface.effective_date(recno)) <> TRUNC(r_interface.gms_overriding_date(recno));
4954
4955 g_bulk_row_count :=0;
4956 FOR bulk_idx IN 1..r_interface.txn_interface_id.COUNT
4957 loop
4958 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
4959 end loop;
4960
4961 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated GMS Override Date count: '||g_bulk_row_count);
4962
4963 FORALL recno IN 1..r_interface.txn_interface_id.COUNT
4964 INSERT INTO pa_transaction_interface_all
4965 (txn_interface_id, transaction_source,
4966 batch_name, expenditure_ending_date,
4967 employee_number, organization_name,
4968 expenditure_item_date, project_number,
4969 task_number, expenditure_type,
4970 quantity, raw_cost,
4971 expenditure_comment, transaction_status_code,
4972 orig_transaction_reference, org_id,
4973 denom_currency_code, denom_raw_cost,
4974 attribute1, attribute2,
4975 attribute3, attribute6,
4976 attribute7, attribute8,
4977 attribute9, attribute10,
4978 person_business_group_id,unmatched_negative_txn_flag)
4979 VALUES (r_interface.txn_interface_id(recno), l_gms_transaction_source,
4980 r_interface.gms_batch_name(recno), r_interface.exp_end_date(recno),
4981 r_interface.employee_number(recno), r_interface.exp_org_name(recno),
4982 r_interface.gms_overriding_date(recno), r_interface.project_number(recno),
4983 r_interface.task_number(recno), r_interface.expenditure_type(recno),
4984 1, r_interface.summary_amount(recno),
4985 r_interface.expenditure_comment(recno), 'P',
4986 'E:' || r_interface.enc_summary_line_id(recno), r_interface.operating_unit(recno),
4987 g_currency_code, r_interface.summary_amount(recno),
4988 NULL, NULL,
4989 r_interface.attribute3(recno), r_interface.attribute6(recno),
4990 r_interface.attribute7(recno), r_interface.attribute8(recno),
4991 r_interface.attribute9(recno), r_interface.attribute10(recno),
4992 g_business_group_id,r_interface.unmatched_nve_txn_flag(recno));
4993
4994 g_bulk_row_count :=0;
4995 FOR bulk_idx IN 1..r_interface.txn_interface_id.COUNT
4996 loop
4997 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
4998 end loop;
4999
5000 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Inserted into pa_transaction_interface_all '||g_bulk_row_count);
5001
5002 FOR recno IN 1..r_interface.txn_interface_id.COUNT
5003 LOOP
5004 GMS_REC.TXN_INTERFACE_ID := r_interface.txn_interface_id(recno);
5005 GMS_REC.BATCH_NAME := r_interface.gms_batch_name(recno);
5006 GMS_REC.TRANSACTION_SOURCE := l_gms_transaction_source;
5007 GMS_REC.EXPENDITURE_ENDING_DATE := r_interface.exp_end_date(recno);
5008 GMS_REC.EXPENDITURE_ITEM_DATE := r_interface.effective_date(recno);
5009 GMS_REC.PROJECT_NUMBER := r_interface.project_number(recno);
5010 GMS_REC.TASK_NUMBER := r_interface.task_number(recno);
5011 GMS_REC.AWARD_ID := r_interface.award_id(recno);
5012 GMS_REC.EXPENDITURE_TYPE := r_interface.expenditure_type(recno);
5013 GMS_REC.TRANSACTION_STATUS_CODE := 'P';
5014 GMS_REC.ORIG_TRANSACTION_REFERENCE := 'E:'|| r_interface.enc_summary_line_id(recno);
5015 GMS_REC.ORG_ID := r_interface.operating_unit(recno);
5016 GMS_REC.SYSTEM_LINKAGE := NULL;
5017 GMS_REC.USER_TRANSACTION_SOURCE := NULL;
5018 GMS_REC.TRANSACTION_TYPE := NULL;
5019 GMS_REC.BURDENABLE_RAW_COST := r_interface.summary_amount(recno);
5020 GMS_REC.FUNDING_PATTERN_ID := NULL;
5021 GMS_REC.ORIGINAL_ENCUMBRANCE_ITEM_ID := r_interface.expenditure_item_id(recno);
5022
5023 gms_transactions_pub.LOAD_GMS_XFACE_API(gms_rec, l_return_status);
5024
5025 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5026 fnd_message.set_name('PSP','PSP_GMS_XFACE_FAILED');
5027 fnd_msg_pub.add;
5028 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5029 END IF;
5030 END LOOP;
5031 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Inserted into gms_transaction_interface_all by calling gms_transactions_pub.LOAD_GMS_XFACE_API');
5032 IF r_interface.txn_interface_id.COUNT > 0 THEN
5033
5034 FOR request_counter IN 1..org_id_tab.count
5035 LOOP
5036 -- set the context to single to call submit_request
5037 mo_global.set_policy_context('S', org_id_tab(request_counter) );
5038 fnd_request.set_org_id (org_id_tab(request_counter) );
5039 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'Calling Transaction import process for org_id: '||org_id_tab(request_counter));
5040 req_id_tab(request_counter) := fnd_request.submit_request
5041 ('PA',
5042 'PAXTRTRX',
5043 NULL,
5044 NULL,
5045 FALSE,
5046 l_gms_transaction_source,
5047 gms_batch_name_tab(request_counter));
5048
5049 IF req_id_tab(request_counter) = 0 THEN
5050 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Submission of Transaction Import Failed');
5051 fnd_message.set_name('PSP','PSP_TR_GMS_IMP_FAILED');
5052 fnd_msg_pub.add;
5053 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5054 ELSE
5055 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Submitted Transaction Import');
5056
5057 OPEN enc_control_id_cur;
5058 FETCH enc_control_id_cur BULK COLLECT INTO r_enc_controls.enc_control_id;
5059 CLOSE enc_control_id_cur;
5060
5061 FORALL I IN 1..r_enc_controls.enc_control_id.COUNT
5062 UPDATE psp_enc_controls
5063 SET gms_phase = 'Transfer'
5064 WHERE enc_control_id = r_enc_controls.enc_control_id(I);
5065
5066 g_bulk_row_count :=0;
5067 FOR bulk_idx IN 1..r_enc_controls.enc_control_id.COUNT
5068 loop
5069 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
5070 end loop;
5071
5072 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated gms_phase to ''Transfer'' in psp_enc_controls count ' ||g_bulk_row_count);
5073
5074 r_enc_controls.enc_control_id.DELETE;
5075 END IF;
5076 END LOOP;
5077 COMMIT;
5078 -- set the context again to multiple
5079 mo_global.set_policy_context('M', null);
5080
5081 -- fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling gather_table_stats for psp_enc_summary_lines');
5082 -- fnd_stats.gather_table_stats('PSP', 'PSP_ENC_SUMMARY_LINES');
5083 -- fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Completed gather_table_stats for psp_enc_summary_lines');
5084
5085 FOR I IN 1..org_id_tab.count
5086 LOOP
5087 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Waiting for comlpetion of Transaction Import');
5088 call_status := fnd_concurrent.wait_for_request(req_id_tab(I), 10, 0, rphase, rstatus, dphase, dstatus, message);
5089
5090 IF call_status = FALSE then
5091 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Transaction Import failed');
5092 fnd_message.set_name('PSP','PSP_TR_GMS_IMP_FAILED');
5093 fnd_msg_pub.add;
5094 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5095 END IF;
5096 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Transaction Import completed');
5097 END LOOP;
5098 END IF;
5099
5100 OPEN gms_batch_name_cur;
5101 FETCH gms_batch_name_cur BULK COLLECT INTO r_gms_batch.gms_batch_name;
5102 CLOSE gms_batch_name_cur;
5103
5104 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' r_gms_batch.gms_batch_name.COUNT: ' || r_gms_batch.gms_batch_name.COUNT);
5105
5106 FOR recno IN 1..r_gms_batch.gms_batch_name.COUNT
5107 LOOP
5108 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Calling gms_enc_tie_back for gms_batch_name: ' || r_gms_batch.gms_batch_name(recno));
5109 gms_enc_tie_back(p_payroll_action_id,
5110 r_gms_batch.gms_batch_name(recno),
5111 g_business_group_id,
5112 g_set_of_books_id,
5113 l_return_status);
5114
5115 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5116 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' gms_enc_tie_back failed for gms_batch_name: ' || r_gms_batch.gms_batch_name(recno));
5117 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5118 END IF;
5119 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' gms_enc_tie_back successful for gms_batch_name: ' || r_gms_batch.gms_batch_name(recno));
5120 END LOOP;
5121
5122 FORALL recno IN 1..r_gms_batch.gms_batch_name.COUNT
5123 UPDATE psp_enc_summary_lines pesl
5124 SET (pesl.expenditure_id, pesl.expenditure_item_id, pesl.expenditure_ending_date,
5125 pesl.txn_interface_id, pesl.interface_id) =
5126 (SELECT ptxn.expenditure_id, ptxn.expenditure_item_id, ptxn.expenditure_ending_date,
5127 ptxn.txn_interface_id, ptxn.interface_id
5128 FROM pa_transaction_interface_all ptxn
5129 WHERE ptxn.transaction_source = 'GOLDE'
5130 AND ptxn.batch_name = r_gms_batch.gms_batch_name(recno)
5131 AND ptxn.orig_transaction_reference = 'E:' || TO_CHAR(pesl.enc_summary_line_id))
5132 WHERE pesl.gms_batch_name = r_gms_batch.gms_batch_name(recno);
5133
5134 g_bulk_row_count :=0;
5135 FOR bulk_idx IN 1..r_gms_batch.gms_batch_name.COUNT
5136 loop
5137 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
5138 end loop;
5139
5140 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'update psp_enc_summary_lines setting encumbrance_item_id count: '||g_bulk_row_count);
5141
5142
5143 FORALL recno IN 1..r_gms_batch.gms_batch_name.COUNT
5144 DELETE pa_transaction_interface_all
5145 WHERE batch_name = r_gms_batch.gms_batch_name(recno)
5146 AND transaction_source = 'GOLDE';
5147
5148 g_bulk_row_count :=0;
5149 FOR bulk_idx IN 1..r_gms_batch.gms_batch_name.COUNT
5150 loop
5151 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
5152 end loop;
5153
5154 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'delete from pa_transaction_interface_all count:'||g_bulk_row_count);
5155
5156
5157
5158 FORALL recno IN 1..r_gms_batch.gms_batch_name.COUNT
5159 DELETE gms_transaction_interface_all
5160 WHERE batch_name = r_gms_batch.gms_batch_name(recno)
5161 AND transaction_source = 'GOLDE';
5162
5163 g_bulk_row_count :=0;
5164 FOR bulk_idx IN 1..r_gms_batch.gms_batch_name.COUNT
5165 loop
5166 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
5167 end loop;
5168
5169 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'delete from gms_transaction_interface_all count:'||g_bulk_row_count);
5170
5171
5172
5173 FORALL recno IN 1..r_gms_batch.gms_batch_name.COUNT
5174 UPDATE psp_enc_summary_lines
5175 SET gms_batch_name = NULL
5176 WHERE gms_batch_name = r_gms_batch.gms_batch_name(recno)
5177 AND status_code = 'N';
5178
5179 g_bulk_row_count :=0;
5180 FOR bulk_idx IN 1..r_gms_batch.gms_batch_name.COUNT
5181 loop
5182 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
5183 end loop;
5184
5185 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'setting gms_batch_name to null count:'||g_bulk_row_count);
5186
5187
5188
5189 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Set the un-imported summary lines to New status');
5190
5191 COMMIT;
5192 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Committing');
5193
5194 p_return_status := fnd_api.g_ret_sts_success;
5195 EXCEPTION
5196 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5197 g_error_api_path := 'TR_TO_GMS_INT:'||g_error_api_path;
5198 p_return_status := fnd_api.g_ret_sts_unexp_error;
5199
5200 WHEN RETURN_BACK THEN
5201 p_return_status := fnd_api.g_ret_sts_success;
5202
5203 WHEN OTHERS THEN
5204 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
5205 g_error_api_path := 'TR_TO_GMS_INT:'||g_error_api_path;
5206 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN','TR_TO_GMS_INT');
5207 p_return_status := fnd_api.g_ret_sts_unexp_error;
5208 END tr_to_gms_int;
5209 -- End of comment for Create and Update multi thread
5210
5211 -- ##########################################################################
5212 -- This procedure ties back all the transactions posted into Oracle Grants Mgmt.
5213 -- with Oracle Labor Distribution where the import is successful.
5214 -- In case of failure the transactions in Oracle Labor Distribution are turned
5215 -- back into their original state.
5216 -- ##########################################################################
5217
5218 /***** Commented for Create and Update multi thread enh.
5219 PROCEDURE gms_enc_tie_back( p_enc_control_id IN NUMBER,
5220 p_period_end_date IN DATE,
5221 p_gms_batch_name IN VARCHAR2,
5222 p_business_group_id IN NUMBER,
5223 p_set_of_books_id IN NUMBER,
5224 p_mode IN VARCHAR2, -- Included as part of Bug fix #1776606
5225 p_return_status OUT NOCOPY VARCHAR2) IS
5226
5227 CURSOR gms_tie_back_success_cur IS
5228 SELECT enc_summary_line_id,
5229 dr_cr_flag,
5230 summary_amount
5231 FROM psp_enc_summary_lines
5232 WHERE gms_batch_name = p_gms_batch_name
5233 and enc_control_id = p_enc_control_id;
5234
5235 CURSOR gms_tie_back_reject_cur IS
5236 SELECT nvl(transaction_rejection_code,'P'),
5237 orig_transaction_reference,
5238 transaction_status_code
5239 FROM pa_transaction_interface_all
5240 WHERE transaction_source = 'GOLDE'
5241 AND batch_name = p_gms_batch_name
5242 AND orig_transaction_reference IN (SELECT 'E:' || enc_summary_line_id --added subqry for 3953230
5243 FROM psp_enc_summary_lines pesl
5244 WHERE pesl.enc_control_id = p_enc_control_id);
5245
5246 CURSOR assign_susp_ac_cur(P_ENC_LINE_ID IN NUMBER) IS
5247 SELECT pel.rowid,
5248 pel.encumbrance_date,
5249 pel.suspense_org_account_id
5250 FROM psp_enc_lines pel
5251 WHERE pel.enc_summary_line_id = p_enc_line_id
5252 and pel.enc_control_id=p_enc_control_id;
5253 -- bUg fix 1671938
5254
5255 -- Get the Organization details ...
5256
5257 CURSOR get_susp_org_cur(P_ORG_ID IN VARCHAR2) IS
5258 SELECT hou.organization_id, hou.name
5259 FROM hr_all_organization_units hou, psp_organization_accounts poa
5260 WHERE hou.organization_id = poa.organization_id
5261 AND poa.business_group_id = p_business_group_id
5262 AND poa.set_of_books_id = p_set_of_books_id
5263 AND poa.organization_account_id = p_org_id;
5264 / *
5265 CURSOR get_org_id_cur(P_LINE_ID IN NUMBER) IS
5266 SELECT hou.organization_id, hou.name
5267 FROM hr_all_organization_units hou,
5268 per_assignments_f paf,
5269 psp_enc_lines pel
5270 WHERE pel.enc_summary_line_id = p_line_id
5271 AND pel.assignment_id = paf.assignment_id
5272 AND pel.encumbrance_date BETWEEN paf.effective_start_date AND paf.effective_end_date
5273 AND paf.organization_id = hou.organization_id
5274 AND pel.encumbrance_date between
5275 hou.date_from and nvl(hou.date_to,pel.encumbrance_date);
5276 -- bUg fIx 1671938
5277 * /
5278
5279 CURSOR get_org_id_cur(P_ROWID IN ROWID) IS
5280 SELECT hou.organization_id, hou.name
5281 FROM hr_all_organization_units hou,
5282 per_assignments_f paf,
5283 psp_enc_lines pel
5284 WHERE
5285 -- pel.enc_summary_line_id = p_line_id
5286 pel.rowid=p_rowid
5287 AND pel.assignment_id = paf.assignment_id
5288 AND pel.encumbrance_date BETWEEN paf.effective_start_date AND paf.effective_end_date
5289 AND paf.organization_id = hou.organization_id
5290 AND pel.encumbrance_date between
5291 hou.date_from and nvl(hou.date_to,pel.encumbrance_date);
5292
5293
5294
5295 l_orig_org_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
5296 l_orig_org_id number;
5297
5298 -- End of Get org id cursor Ravindra
5299 / * CURSOR assign_susp_ac_cur(P_ENC_SUMMARY_LINE_ID IN NUMBER) IS
5300 SELECT hou.name,
5301 hou.organization_id,
5302 pel.rowid,
5303 pel.assignment_id,
5304 pel.encumbrance_date,
5305 pel.suspense_org_account_id
5306 FROM hr_organization_units hou,
5307 per_assignments_f paf,
5308 psp_enc_lines pel,
5309 WHERE pel.enc_summary_line_id = p_enc_summary_line_id
5310 AND pel.assignment_id = paf.assignment_id
5311 AND pel.encumbrance_date BETWEEN paf.effective_start_date AND paf.effective_end_date
5312 AND pel.business_group_id = g_business_group_id
5313 AND pel.set_of_books_id = g_set_of_books_id
5314 AND paf.organization_id = hou.organization_id;
5315 * /
5316
5317 CURSOR org_susp_ac_cur(P_ORGANIZATION_ID IN NUMBER,
5318 P_ENCUMBRANCE_DATE IN DATE) IS
5319 SELECT poa.organization_account_id,
5320 poa.gl_code_combination_id,
5321 poa.project_id,
5322 poa.expenditure_organization_id,
5323 poa.expenditure_type,
5324 poa.award_id,
5325 poa.task_id
5326 FROM psp_organization_accounts poa
5327 WHERE poa.organization_id = p_organization_id
5328 AND poa.business_group_id = p_business_group_id
5329 AND poa.set_of_books_id = p_set_of_books_id
5330 AND poa.account_type_code = 'S'
5331 -- AND poa.award_id is not null for Bug Fix 1776606
5332 AND p_encumbrance_date BETWEEN poa.start_date_active AND
5333 nvl(poa.end_date_active,p_encumbrance_date);
5334
5335 -- CURSOR global_susp_ac_cur(P_ENCUMBRANCE_DATE IN DATE) IS
5336 CURSOR global_susp_ac_cur(P_ORGANIZATION_ACCOUNT_ID IN NUMBER) IS --BUG 2056877.
5337 SELECT poa.organization_account_id,
5338 poa.gl_code_combination_id,
5339 poa.project_id,
5340 poa.expenditure_organization_id,
5341 poa.expenditure_type,
5342 poa.award_id,
5343 poa.task_id
5344 FROM psp_organization_accounts poa
5345 WHERE
5346 / * poa.account_type_code = 'G'
5347 AND poa.business_group_id = p_business_group_id
5348 AND poa.set_of_books_id = p_set_of_books_id
5349 -- AND poa.award_id is not null For Bug fix 1776606
5350 AND p_encumbrance_date BETWEEN poa.start_date_active AND
5351 nvl(poa.end_date_active,p_encumbrance_date); Bug 2056877 * /
5352 organization_account_id = p_organization_account_id; --Added for bug 2056877.
5353
5354
5355 l_organization_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
5356 l_organization_id NUMBER(15);
5357 l_rowid ROWID;
5358 l_assignment_id NUMBER(9);
5359 l_encumbrance_date DATE;
5360 l_suspense_org_account_id NUMBER(9);
5361
5362 l_organization_account_id NUMBER(9);
5363 l_gl_code_combination_id NUMBER(15);
5364 l_project_id NUMBER(15);
5365 l_expenditure_organization_id NUMBER(15);
5366 l_expenditure_type VARCHAR2(30);
5367 l_award_id NUMBER(15);
5368 l_task_id NUMBER(15);
5369 l_cnt_gms_interface NUMBER;
5370 l_enc_summary_line_id NUMBER(10);
5371 l_gl_project_flag VARCHAR2(1);
5372 l_suspense_ac_failed VARCHAR2(1) := 'N';
5373 l_suspense_ac_not_found VARCHAR2(1) := 'N';
5374 l_susp_ac_found VARCHAR2(10) := 'TRUE';
5375 l_summary_amount NUMBER;
5376 l_dr_summary_amount NUMBER := 0;
5377 l_cr_summary_amount NUMBER := 0;
5378 l_dr_cr_flag VARCHAR2(1);
5379 l_trx_status_code VARCHAR2(2); / * Bug 2030232:Gms bug 1961436 * /
5380 l_trx_reject_code VARCHAR2(30);
5381 l_orig_trx_reference VARCHAR2(30);
5382 l_enc_ref VARCHAR2(30);
5383 l_effective_date DATE;
5384
5385 x_susp_failed_org_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
5386 x_susp_failed_reject_code VARCHAR2(30);
5387 x_susp_failed_date DATE;
5388 x_susp_nf_org_name hr_all_organization_units_tl.name%TYPE; -- Bug 2447912: Modified declaration
5389 x_susp_nf_date DATE;
5390 l_return_status VARCHAR2(10);
5391 l_no_run NUMBER;
5392 l_susp_glccid NUMBER(15);
5393 l_no_complete NUMBER;
5394 l_return_value VARCHAR2(30); --Added for bug 2056877.
5395 no_profile_exists EXCEPTION; --Added for bug 2056877.
5396 no_val_date_matches EXCEPTION; --Added for bug 2056877.
5397 no_global_acct_exists EXCEPTION; --Added for bug 2056877.
5398 l_susp_exception varchar2(50); -- added for 2479579
5399
5400
5401 FUNCTION PROCESS_COMPLETE RETURN VARCHAR2 IS
5402 l_cnt NUMBER;
5403 l_status VARCHAR2(30);
5404 begin
5405
5406 select count(*), transaction_status_code
5407 into l_cnt, l_status
5408 from pa_transaction_interface_all
5409 where transaction_source = 'GOLDE'
5410 and batch_name = (select distinct gms_batch_name
5411 from psp_enc_summary_lines
5412 where enc_control_id = p_enc_control_id
5413 and gms_batch_name is not null)
5414 and transaction_status_code in ('P', 'I')
5415 group by transaction_status_code ;
5416
5417 if l_cnt = 0 then
5418 return 'COMPLETE';
5419 elsif l_cnt > 0 then
5420 if l_status = 'P' then
5421
5422 -- -------------------------------------------------------------------------------------------
5423 -- If transaction_status_code = 'P' then the transaction import process did not kick off
5424 -- for some reason. Return 'NOT_RUN' in this case. So cleanup the tables and try to transfer
5425 -- again after summarization in the second pass.
5426 -- -------------------------------------------------------------------------------------------
5427
5428 delete from pa_transaction_interface_all
5429 where transaction_source = 'GOLDE'
5430 and batch_name = p_gms_batch_name;
5431
5432 delete from gms_transaction_interface_all
5433 where transaction_source = 'GOLDE'
5434 and batch_name = p_gms_batch_name;
5435
5436 delete from psp_enc_summary_lines
5437 where gms_batch_name = p_gms_batch_name
5438 and enc_control_id = p_enc_control_id;
5439
5440 return 'NOT_RUN';
5441
5442 elsif l_status = 'I' then
5443
5444 -- -------------------------------------------------------------------------------------------
5445 -- If transaction_status_code = 'I' then the transaction import process did not complete
5446 -- the Post Processing extension. So return 'NOT_COMPLETE' in this case. User needs to complete
5447 -- this process by running the transaction import manually and re-start the LD process.
5448 -- -------------------------------------------------------------------------------------------
5449
5450 return 'NOT_COMPLETE';
5451
5452 end if;
5453 end if;
5454
5455 exception
5456 when others then
5457 return 'COMPLETE';
5458 end PROCESS_COMPLETE;
5459
5460 BEGIN
5461
5462 if (PROCESS_COMPLETE not in ('NOT_COMPLETE', 'NOT_RUN')) then
5463
5464 SELECT count(*)
5465 INTO l_cnt_gms_interface
5466 FROM pa_transaction_interface_all
5467 WHERE transaction_source = 'GOLDE'
5468 AND batch_name = p_gms_batch_name
5469 AND transaction_status_code in ('R', 'PI', 'PR', 'PO');
5470
5471 IF l_cnt_gms_interface > 0 THEN
5472 / * Start bug#2142865 Added the code to update the gms_phase * /
5473 UPDATE psp_enc_controls
5474 SET gms_phase = 'TieBack'
5475 WHERE run_id = g_run_id;
5476 / * End bug#2142865 * /
5477 OPEN gms_tie_back_reject_cur;
5478 LOOP --loop1 count in pa_tr_int > 1
5479 FETCH gms_tie_back_reject_cur INTO l_trx_reject_code, l_enc_ref, l_trx_status_code;
5480 IF gms_tie_back_reject_cur%NOTFOUND THEN
5481 CLOSE gms_tie_back_reject_cur;
5482 EXIT;
5483 END IF;
5484
5485 l_orig_trx_reference := substr(l_enc_ref, 3);
5486
5487 IF l_trx_status_code in ('R', 'PI', 'PR', 'PO') THEN
5488 UPDATE psp_enc_summary_lines
5489 SET interface_status = l_trx_reject_code, status_code = 'R'
5490 WHERE enc_summary_line_id = to_number(l_orig_trx_reference);
5491 ELSIF l_trx_status_code = 'A' THEN
5492 UPDATE psp_enc_summary_lines
5493 SET interface_status = l_trx_reject_code, status_code = 'A'
5494 WHERE enc_summary_line_id = to_number(l_orig_trx_reference);
5495 -- END IF;
5496
5497 SELECT summary_amount, dr_cr_flag
5498 INTO l_summary_amount, l_dr_cr_flag
5499 FROM psp_enc_summary_lines
5500 WHERE enc_summary_line_id = to_number(l_orig_trx_reference);
5501
5502 IF l_dr_cr_flag = 'D' THEN
5503 l_dr_summary_amount := l_dr_summary_amount + l_summary_amount;
5504 ELSIF l_dr_cr_flag = 'C' THEN
5505 l_cr_summary_amount := l_cr_summary_amount - l_summary_amount;
5506 END IF;
5507
5508 END IF;
5509
5510 OPEN assign_susp_ac_cur(l_orig_trx_reference);
5511 LOOP --loop2 assign suspense account
5512
5513 FETCH assign_susp_ac_cur INTO l_rowid, l_encumbrance_date, l_suspense_org_account_id;
5514
5515 IF assign_susp_ac_cur%NOTFOUND THEN
5516 CLOSE assign_susp_ac_cur;
5517 EXIT;
5518 END IF;
5519
5520 IF l_trx_status_code = 'A' THEN
5521
5522 UPDATE psp_enc_lines
5523 SET status_code = 'A'
5524 WHERE rowid = l_rowid;
5525
5526 -- move the transferred records to psp_enc_lines_history
5527 -- Added enc_start_date ,enc_end_date columns for Enh. Enc Redesign Prorata,Bug #2259310
5528 --dbms_output.put_line('moving rec into enc lines hist');
5529 --insert_into_psp_stout( 'moving rec into enc lines hist');
5530 -- Introduced DFF columns for bug fix 2908859
5531 INSERT INTO psp_enc_lines_history
5532 (enc_line_id,business_group_id,enc_element_type_id,encumbrance_date,
5533 dr_cr_flag,encumbrance_amount,status_code,enc_line_type,schedule_line_id,org_schedule_id,
5534 default_org_account_id,suspense_org_account_id,element_account_id,gl_project_flag,
5535 enc_summary_line_id,person_id,assignment_id,award_id,task_id,expenditure_type,
5536 expenditure_organization_id,project_id,gl_code_combination_id,time_period_id,payroll_id,
5537 set_of_books_id,default_reason_code,suspense_reason_code,enc_control_id,change_flag,last_update_date,
5538 last_updated_by,last_update_login,created_by,creation_date,enc_start_date,enc_end_date,
5539 attribute_category, attribute1, attribute2, attribute3,
5540 attribute4, attribute5, attribute6, attribute7,
5541 attribute8, attribute9, attribute10)
5542 SELECT enc_line_id,business_group_id,enc_element_type_id,encumbrance_date,
5543 dr_cr_flag,encumbrance_amount,status_code,enc_line_type,schedule_line_id,org_schedule_id,
5544 default_org_account_id,suspense_org_account_id,element_account_id,gl_project_flag,
5545 enc_summary_line_id,person_id,assignment_id,award_id,task_id,expenditure_type,
5546 expenditure_organization_id,project_id,gl_code_combination_id,time_period_id,payroll_id,
5547 set_of_books_id,default_reason_code,suspense_reason_code,enc_control_id,change_flag,last_update_date,
5548 last_updated_by,last_update_login,created_by,creation_date,enc_start_date,enc_end_date,
5549 attribute_category, attribute1, attribute2, attribute3,
5550 attribute4, attribute5, attribute6, attribute7,
5551 attribute8, attribute9, attribute10
5552 FROM psp_enc_lines
5553 WHERE status_code = 'A'
5554 AND enc_summary_line_id = to_number(l_orig_trx_reference)
5555 AND enc_control_id = p_enc_control_id;
5556
5557 DELETE FROM psp_enc_lines
5558 WHERE status_code = 'A'
5559 AND enc_summary_line_id = to_number(l_orig_trx_reference)
5560 AND enc_control_id = p_enc_control_id;
5561
5562 / **************************************************************************************
5563 For Bug 2290051 - Commenting out purging of Interface tables for accepted Summary Lines
5564 -- purge the interface tables for Accepted summary lines
5565
5566 DELETE from pa_transaction_interface_all
5567 where transaction_source = 'GOLDE'
5568 and batch_name = p_gms_batch_name
5569 and transaction_status_code = 'A'
5570 and orig_transaction_reference = l_enc_ref;
5571
5572 DELETE from gms_transaction_interface_all
5573 where transaction_source = 'GOLDE'
5574 and batch_name = p_gms_batch_name
5575 and transaction_status_code = 'A'
5576 and orig_transaction_reference = l_enc_ref;
5577
5578 **************************************************************************************** /
5579
5580 -- if a suspense a/c failed,update the status of the whole batch and display the error
5581
5582 ELSIF l_suspense_org_account_id IS NOT NULL AND l_trx_status_code <> 'A' THEN
5583
5584 OPEN get_susp_org_cur(l_suspense_org_account_id);
5585 FETCH get_susp_org_cur into l_organization_id, l_organization_name;
5586 CLOSE get_susp_org_cur;
5587
5588 x_susp_failed_org_name := l_organization_name;
5589 x_susp_failed_reject_code := l_trx_reject_code;
5590 x_susp_failed_date := l_encumbrance_date;
5591 l_suspense_ac_failed := 'Y';
5592
5593
5594 / *Commented for Bug 3914807
5595 UPDATE psp_enc_lines
5596 SET suspense_reason_code = 'ES:' || l_trx_reject_code,
5597 status_code = 'N'
5598 WHERE rowid = l_rowid; * /
5599
5600 ELSE
5601 l_susp_ac_found := 'TRUE';
5602 OPEN get_org_id_cur(l_rowid);
5603 FETCH get_org_id_cur into l_orig_org_id, l_orig_org_name;
5604
5605 -- IF get_org_id_cur%NOTFOUND then
5606 CLOSE get_org_id_cur;
5607 -- END IF;
5608
5609 OPEN org_susp_ac_cur(l_orig_org_id, l_encumbrance_date);
5610 FETCH org_susp_ac_cur INTO l_organization_account_id,l_susp_glccid,l_project_id, l_expenditure_organization_id, l_expenditure_type, l_award_id,l_task_id;
5611
5612 IF org_susp_ac_cur%NOTFOUND THEN
5613 / * Following code is added for bug 2056877 ,Added validation for generic suspense account * /
5614 l_return_value := psp_general.find_global_suspense(l_encumbrance_date,
5615 p_business_group_id,
5616 p_set_of_books_id,
5617 l_organization_account_id);
5618 / * --------------------------------------------------------------------
5619 Valid return values are
5620 PROFILE_VAL_DATE_MATCHES Profile and Value and Date matching 'G'
5621 NO_PROFILE_EXISTS No Profile
5622 NO_VAL_DATE_MATCHES Profile and Either Value/date do not
5623 match with 'G'
5624 NO_GLOBAL_ACCT_EXISTS No 'G' exists
5625 ---------------------------------------------------------------------- * /
5626 / *start Added for Bug#2142685. * /
5627 / * IF l_return_value <> 'PROFILE_VAL_DATE_MATCHES' THEN
5628 IF p_mode='N' THEN
5629 enc_batch_end(g_payroll_id,l_return_status);
5630 END IF;
5631 END IF; 2479579 * /
5632 / * End Bug#2142865 * /
5633 IF l_return_value = 'PROFILE_VAL_DATE_MATCHES' THEN
5634 -- OPEN global_susp_ac_cur(l_encumbrance_date);
5635 OPEN global_susp_ac_cur(l_organization_account_id); -- Bug 2056877.
5636 FETCH global_susp_ac_cur INTO l_organization_account_id,l_susp_glccid,
5637 l_project_id, l_expenditure_organization_id, l_expenditure_type, l_award_id,l_task_id;
5638 IF global_susp_ac_cur%NOTFOUND THEN
5639 / * l_susp_ac_found := 'FALSE';
5640 l_suspense_ac_not_found := 'Y';
5641 x_susp_nf_org_name := l_orig_org_name;
5642 x_susp_nf_date := l_encumbrance_date; Bug 2056877* /
5643 -- added following two lines for 2479579
5644 l_suspense_ac_not_found := 'Y';
5645 l_susp_ac_found := 'NO_G_AC';
5646 END IF;
5647 CLOSE global_susp_ac_cur;
5648 ELSIF l_return_value = 'NO_GLOBAL_ACCT_EXISTS' THEN
5649 -- RAISE no_global_acct_exists; commented this line and added two new lines for 2479579
5650 l_suspense_ac_not_found := 'Y';
5651 l_susp_ac_found := 'NO_G_AC';
5652 ELSIF l_return_value = 'NO_VAL_DATE_MATCHES' THEN
5653 -- RAISE no_val_date_matches; commented this line and added two new lines for 2479579
5654 l_suspense_ac_not_found := 'Y';
5655 l_susp_ac_found := 'NO_DT_MCH';
5656 ELSIF l_return_value = 'NO_PROFILE_EXISTS' THEN
5657 -- RAISE no_profile_exists; commented this line and added two new lines for 2479579
5658 l_suspense_ac_not_found := 'Y';
5659 l_susp_ac_found := 'NO_PROFL';
5660 END IF; -- Bug 2056877.
5661 END IF;
5662 CLOSE org_susp_ac_cur;
5663
5664
5665 IF l_susp_ac_found = 'TRUE' THEN
5666
5667 --CLOSE org_susp_ac_cur;
5668 IF l_susp_glccid IS NOT NULL THEN
5669 l_gl_project_flag := 'G';
5670 l_effective_date := p_period_end_date;
5671 ELSE
5672 l_gl_project_flag := 'P';
5673 psp_general.poeta_effective_date(l_encumbrance_date,
5674 l_project_id,
5675 l_award_id,
5676 l_task_id,
5677 l_effective_date,
5678 l_return_status);
5679 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5680 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5681 END IF;
5682
5683 END IF;
5684 / * For Bug fix 3194807 * /
5685
5686 UPDATE psp_enc_lines
5687 SET prev_effective_date = encumbrance_date
5688 WHERE rowid = l_rowid;
5689 / * End of Bug fix 3198407 * /
5690
5691 UPDATE psp_enc_lines
5692 SET suspense_org_account_id = l_organization_account_id,
5693 suspense_reason_code = 'ES:' || l_trx_reject_code,
5694 gl_project_flag = l_gl_project_flag,
5695 -- encumbrance_date = l_encumbrance_date, Commented for Bug 3194807
5696 encumbrance_date = l_effective_date,
5697 / *Commented for Bug 3194807
5698 schedule_line_id = null,
5699 org_schedule_id = null,
5700 default_org_account_id = null,
5701 element_account_id = null,
5702 gl_code_combination_id = decode(l_gl_project_flag, 'P', null, l_susp_glccid),
5703 project_id = decode(l_gl_project_flag, 'P', l_project_id, null),
5704 expenditure_organization_id = decode(l_gl_project_flag, 'P', l_expenditure_organization_id, null),
5705 expenditure_type = decode(l_gl_project_flag, 'P', l_expenditure_type, null),
5706 task_id = decode(l_gl_project_flag, 'P', l_task_id, null),
5707 award_id = decode(l_gl_project_flag, 'P', l_award_id, null), * /
5708 status_code = 'N'
5709 WHERE rowid = l_rowid;
5710 else -- 2479579
5711 l_susp_exception := l_susp_ac_found;
5712 END IF;
5713 END IF;
5714
5715 END LOOP; --end loop2 assign suspense account
5716 END LOOP; -- end loop1
5717
5718 UPDATE psp_enc_controls
5719 SET summ_ogm_dr_amount = l_dr_summary_amount,
5720 summ_ogm_cr_amount = l_cr_summary_amount
5721 --gms_phase = 'TieBack' Commented for Bug#2142865 , same moved above
5722 WHERE enc_control_id = p_enc_control_id;
5723
5724 --COMMIT;
5725
5726 IF l_suspense_ac_failed = 'Y' THEN
5727 g_susp_prob := 'Y'; -- for 2479579
5728 fnd_message.set_name('PSP','PSP_TR_GMS_SUSP_AC_REJECT');
5729 fnd_message.set_token('ORG_NAME',x_susp_failed_org_name);
5730 fnd_message.set_token('PAYROLL_DATE',x_susp_failed_date);
5731 fnd_message.set_token('ERROR_MSG',x_susp_failed_reject_code);
5732 fnd_msg_pub.add;
5733
5734
5735 / * Added the following for Bug 3194807 * /
5736
5737 UPDATE psp_enc_lines
5738 SET suspense_org_account_id = NULL,
5739 suspense_reason_code = NULL,
5740 gl_project_flag = decode(gl_code_combination_id,NULL,'P','G'),
5741 encumbrance_date = prev_effective_date
5742 WHERE suspense_reason_code like 'ES:%'
5743 AND enc_summary_line_id
5744 IN (SELECT enc_summary_line_id
5745 FROM psp_enc_summary_lines
5746 WHERE enc_control_id = p_enc_control_id);
5747
5748
5749 / * End of code changes for Bug 3194807 * /
5750
5751 END IF;
5752
5753
5754 -- uncommented for 2479579, which was earlier commented for bug # 2142865
5755 IF l_suspense_ac_not_found = 'Y' THEN
5756 g_susp_prob := 'Y'; -- for 2479579
5757 / * commented this message stack for 2479579
5758 fnd_message.set_name('PSP','PSP_LD_SUSPENSE_AC_NOT_EXIST');
5759 fnd_message.set_token('ORG_NAME',x_susp_nf_org_name);
5760 fnd_message.set_token('PAYROLL_DATE',x_susp_nf_date);
5761 fnd_msg_pub.add; * /
5762 / * Included the following check as part of Bug fix #1776606 * /
5763 ---added following if stmnt for 2479579
5764 IF l_susp_exception = 'NO_G_AC' then
5765 RAISE no_global_acct_exists;
5766 ELSIF l_susp_exception = 'NO_DT_MCH' then
5767 RAISE no_val_date_matches;
5768 ELSIF l_susp_exception = 'NO_PROFL' then
5769 RAISE no_profile_exists;
5770 END IF;
5771
5772 END IF;
5773
5774
5775 ELSIF l_cnt_gms_interface = 0 THEN
5776
5777 OPEN gms_tie_back_success_cur;
5778 LOOP
5779 FETCH gms_tie_back_success_cur INTO l_enc_summary_line_id,
5780 l_dr_cr_flag,l_summary_amount;
5781
5782 IF gms_tie_back_success_cur%NOTFOUND THEN
5783 CLOSE gms_tie_back_success_cur;
5784 EXIT;
5785 END IF;
5786 -- update records in psp_summary_lines as 'A'
5787
5788 UPDATE psp_enc_summary_lines
5789 SET status_code = 'A'
5790 WHERE enc_summary_line_id = l_enc_summary_line_id;
5791
5792 IF l_dr_cr_flag = 'D' THEN
5793 l_dr_summary_amount := l_dr_summary_amount + l_summary_amount;
5794 ELSIF l_dr_cr_flag = 'C' THEN
5795 -- credit is marked as -ve for posting to Oracle Projects
5796 l_cr_summary_amount := l_cr_summary_amount - l_summary_amount;
5797 END IF;
5798
5799 UPDATE psp_enc_lines
5800 SET status_code = 'A'
5801 WHERE enc_summary_line_id = l_enc_summary_line_id
5802 AND enc_control_id = p_enc_control_id;
5803
5804 / * Introduced this cursor for Bug fix 3194807 * /
5805
5806 UPDATE psp_enc_lines
5807 SET (gl_code_combination_id,project_id,task_id,award_id,expenditure_organization_id,expenditure_type)
5808 = (select NULL,poa.project_id,poa.task_id,poa.award_id,poa.expenditure_organization_id,poa.expenditure_type
5809 from psp_organization_accounts poa
5810 where poa.organization_account_id = suspense_org_account_id
5811 and enc_summary_line_id = l_enc_summary_line_id)
5812 WHERE enc_summary_line_id= l_enc_summary_line_id
5813 AND suspense_reason_code like 'ES:%';
5814
5815
5816 / * End of code Changes for Bug fix 3194807 * /
5817
5818
5819 -- move the transferred records to psp_enc_lines_history
5820 -- Added enc_start_date ,enc_end_date columns for Enh. Enc Redesign Prorata,Bug #2259310
5821 -- Introduced DFF columns for bug fix 2908859
5822 INSERT INTO psp_enc_lines_history
5823 (enc_line_id,business_group_id,enc_element_type_id,encumbrance_date,
5824 dr_cr_flag,encumbrance_amount,status_code,enc_line_type,schedule_line_id,org_schedule_id,
5825 default_org_account_id,suspense_org_account_id,element_account_id,gl_project_flag,
5826 enc_summary_line_id,person_id,assignment_id,award_id,task_id,expenditure_type,
5827 expenditure_organization_id,project_id,gl_code_combination_id,time_period_id,payroll_id,
5828 set_of_books_id,default_reason_code,suspense_reason_code,enc_control_id,change_flag,last_update_date,
5829 last_updated_by,last_update_login,created_by,creation_date,enc_start_date,enc_end_date,
5830 attribute_category, attribute1, attribute2, attribute3,
5831 attribute4, attribute5, attribute6, attribute7,
5832 attribute8, attribute9, attribute10)
5833 SELECT enc_line_id,business_group_id,enc_element_type_id,encumbrance_date,
5834 dr_cr_flag,encumbrance_amount,status_code,enc_line_type,schedule_line_id,org_schedule_id,
5835 default_org_account_id,suspense_org_account_id,element_account_id,gl_project_flag,
5836 enc_summary_line_id,person_id,assignment_id,award_id,task_id,expenditure_type,
5837 expenditure_organization_id,project_id,gl_code_combination_id,time_period_id,payroll_id,
5838 set_of_books_id,default_reason_code,suspense_reason_code,enc_control_id,change_flag,last_update_date,
5839 last_updated_by,last_update_login,created_by,creation_date,enc_start_date,enc_end_date,
5840 attribute_category, attribute1, attribute2, attribute3,
5841 attribute4, attribute5, attribute6, attribute7,
5842 attribute8, attribute9, attribute10
5843 FROM psp_enc_lines
5844 WHERE status_code = 'A'
5845 AND enc_summary_line_id = l_enc_summary_line_id
5846 AND enc_control_id = p_enc_control_id;
5847
5848 DELETE FROM psp_enc_lines
5849 WHERE status_code = 'A'
5850 AND enc_summary_line_id = l_enc_summary_line_id
5851 AND enc_control_id = p_enc_control_id;
5852
5853 -- commented For Bug 2290051
5854 / * DELETE from pa_transaction_interface_all
5855 where transaction_source = 'GOLDE'
5856 and batch_name = p_gms_batch_name
5857 and transaction_status_code = 'A'
5858 and orig_transaction_reference = 'E:' || to_char(l_enc_summary_line_id);
5859
5860 DELETE from gms_transaction_interface_all
5861 where transaction_source = 'GOLDE'
5862 and batch_name = p_gms_batch_name
5863 and transaction_status_code = 'A'
5864 and orig_transaction_reference = 'E:' || to_char(l_enc_summary_line_id); * /
5865 END LOOP;
5866
5867 UPDATE psp_enc_controls
5868 SET summ_ogm_dr_amount = l_dr_summary_amount,
5869 summ_ogm_cr_amount = l_cr_summary_amount,
5870 gms_phase = 'TieBack'
5871 WHERE enc_control_id = p_enc_control_id;
5872
5873 END IF;
5874 END IF; -- IF (PROCESS_COMPLETE)
5875
5876 p_return_status := fnd_api.g_ret_sts_success;
5877 EXCEPTION
5878 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
5879 g_error_api_path := 'GMS_ENC_TIE_BACK:'||g_error_api_path;
5880 p_return_status := fnd_api.g_ret_sts_unexp_error;
5881
5882 / * Added Exceptions for bug 2056877 * /
5883 WHEN NO_PROFILE_EXISTS THEN
5884 g_error_api_path := SUBSTR('GMS_ENC_TIE_BACK:'||g_error_api_path,1,230);
5885 fnd_message.set_name('PSP','PSP_NO_PROFILE_EXISTS');
5886 fnd_msg_pub.add;
5887 --p_return_status := fnd_api.g_ret_sts_unexp_error; commented and intro success for 2479579
5888 p_return_status := fnd_api.g_ret_sts_success;
5889
5890 WHEN NO_VAL_DATE_MATCHES THEN
5891 g_error_api_path := SUBSTR('GMS_ENC_TIE_BACK:'||g_error_api_path,1,230);
5892 fnd_message.set_name('PSP','PSP_NO_VAL_DATE_MATCHES');
5893 fnd_message.set_token('ORG_NAME',l_orig_org_name);
5894 fnd_message.set_token('PAYROLL_DATE',l_encumbrance_date);
5895 fnd_msg_pub.add;
5896 --p_return_status := fnd_api.g_ret_sts_unexp_error; commented and intro success for 2479579
5897 p_return_status := fnd_api.g_ret_sts_success;
5898
5899 WHEN NO_GLOBAL_ACCT_EXISTS THEN
5900 g_error_api_path := SUBSTR('GMS_ENC_TIE_BACK:'||g_error_api_path,1,230);
5901 fnd_message.set_name('PSP','PSP_NO_GLOBAL_ACCT_EXISTS');
5902 fnd_message.set_token('ORG_NAME',l_orig_org_name);
5903 fnd_message.set_token('PAYROLL_DATE',l_encumbrance_date);
5904 fnd_msg_pub.add;
5905 -- p_return_status := fnd_api.g_ret_sts_unexp_error; commented and intro success for 2479579
5906 p_return_status := fnd_api.g_ret_sts_success;
5907
5908 WHEN OTHERS THEN
5909 g_error_api_path := 'GMS_ENC_TIE_BACK:'||g_error_api_path;
5910 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN','GMS_ENC_TIE_BACK');
5911 p_return_status := fnd_api.g_ret_sts_unexp_error;
5912
5913 END;
5914 End of comment for Create and Update multi thread enh. *****/
5915 -- Introduced the following modified gms_enc_tie_back procedure for Create and Update multi thread enh.
5916 PROCEDURE gms_enc_tie_back( p_payroll_action_id IN NUMBER,
5917 p_gms_batch_name IN VARCHAR2,
5918 p_business_group_id IN NUMBER,
5919 p_set_of_books_id IN NUMBER,
5920 p_return_status OUT NOCOPY VARCHAR2) IS
5921 CURSOR gms_tie_back_success_cur IS
5922 SELECT enc_control_id,
5923 enc_summary_line_id,
5924 dr_cr_flag,
5925 TO_NUMBER(DECODE(dr_cr_flag, 'C', -summary_amount, summary_amount)) summary_amount
5926 FROM psp_enc_summary_lines
5927 WHERE gms_batch_name = p_gms_batch_name;
5928
5929 CURSOR gms_tie_back_reject_cur IS
5930 SELECT NVL(transaction_rejection_code,'P'),
5931 TO_NUMBER(SUBSTR(orig_transaction_reference, 3)),
5932 transaction_status_code
5933 FROM pa_transaction_interface_all
5934 WHERE transaction_source = 'GOLDE'
5935 AND batch_name = p_gms_batch_name;
5936
5937 CURSOR assign_susp_ac_cur IS
5938 SELECT pel.rowid,
5939 pel.encumbrance_date,
5940 pel.enc_start_date,
5941 pel.enc_end_date,
5942 pel.person_id,
5943 pel.assignment_id,
5944 pel.payroll_id,
5945 pel.enc_element_type_id,
5946 pel.project_id,
5947 pel.task_id,
5948 pel.award_id,
5949 pel.expenditure_organization_id,
5950 pel.expenditure_type,
5951 pel.suspense_org_account_id,
5952 pesl.interface_status,
5953 ptp.end_date
5954 FROM psp_enc_lines pel,
5955 psp_enc_summary_lines pesl,
5956 per_time_periods ptp
5957 WHERE pel.payroll_action_id = p_payroll_action_id
5958 AND pel.enc_summary_line_id = pesl.enc_summary_line_id
5959 AND pesl.payroll_action_id = p_payroll_action_id
5960 AND pesl.status_code = 'R'
5961 AND pesl.gms_batch_name = p_gms_batch_name
5962 AND ptp.time_period_id = pel.time_period_id
5963 ORDER BY 5, 6, 7, 8, 9, 10, 11, 12, 3;
5964
5965 CURSOR get_susp_org_cur(P_ORG_ID IN VARCHAR2) IS
5966 SELECT hou.organization_id, hou.name, poa.gl_code_combination_id
5967 FROM hr_all_organization_units hou,
5968 psp_organization_accounts poa
5969 WHERE hou.organization_id = poa.organization_id
5970 AND poa.business_group_id = p_business_group_id
5971 AND poa.set_of_books_id = p_set_of_books_id
5972 AND poa.organization_account_id = p_org_id;
5973
5974 CURSOR get_org_id_cur(P_ROWID IN ROWID) IS
5975 SELECT hou.organization_id, hou.name
5976 FROM hr_all_organization_units hou,
5977 per_assignments_f paf,
5978 psp_enc_lines pel
5979 WHERE pel.rowid=p_rowid
5980 AND pel.assignment_id = paf.assignment_id
5981 AND pel.encumbrance_date BETWEEN paf.effective_start_date AND paf.effective_end_date
5982 AND paf.organization_id = hou.organization_id
5983 AND pel.encumbrance_date BETWEEN hou.date_from AND NVL(hou.date_to, pel.encumbrance_date);
5984
5985 CURSOR org_susp_ac_cur(P_ORGANIZATION_ID IN NUMBER,
5986 P_ENCUMBRANCE_DATE IN DATE) IS
5987 SELECT poa.organization_account_id,
5988 poa.gl_code_combination_id,
5989 poa.project_id,
5990 poa.expenditure_organization_id,
5991 poa.expenditure_type,
5992 poa.award_id,
5993 poa.task_id
5994 FROM psp_organization_accounts poa
5995 WHERE poa.organization_id = p_organization_id
5996 AND poa.business_group_id = p_business_group_id
5997 AND poa.set_of_books_id = p_set_of_books_id
5998 AND poa.account_type_code = 'S'
5999 AND p_encumbrance_date BETWEEN poa.start_date_active AND NVL(poa.end_date_active, p_encumbrance_date);
6000
6001 CURSOR global_susp_ac_cur(P_ORGANIZATION_ACCOUNT_ID IN NUMBER) IS
6002 SELECT poa.organization_account_id,
6003 poa.gl_code_combination_id,
6004 poa.project_id,
6005 poa.expenditure_organization_id,
6006 poa.expenditure_type,
6007 poa.award_id,
6008 poa.task_id
6009 FROM psp_organization_accounts poa
6010 WHERE organization_account_id = p_organization_account_id;
6011
6012 CURSOR txn_interface_count_cur IS
6013 SELECT COUNT(1)
6014 FROM pa_transaction_interface_all
6015 WHERE transaction_source = 'GOLDE'
6016 AND batch_name = p_gms_batch_name
6017 AND transaction_status_code in ('R', 'PI', 'PO', 'PR');
6018
6019 CURSOR get_success_recs_cur IS
6020 SELECT enc_control_id,
6021 enc_summary_line_id,
6022 dr_cr_flag,
6023 TO_NUMBER(DECODE(dr_cr_flag, 'C', -summary_amount, summary_amount)) summary_amount
6024 FROM psp_enc_summary_lines
6025 WHERE gms_batch_name = p_gms_batch_name
6026 AND status_code = 'A';
6027
6028 l_encumbrance_date DATE;
6029 l_lines_glccid NUMBER(15);
6030 l_organization_account_id NUMBER(9);
6031 l_susp_glccid NUMBER(15);
6032 l_new_gl_code_combination_id NUMBER(15);
6033 l_orig_org_name hr_all_organization_units_tl.name%TYPE;
6034 l_orig_org_id NUMBER(15);
6035 l_cnt_gl_interface NUMBER;
6036 l_autopop_status VARCHAR2(1);
6037 l_gl_project_flag VARCHAR2(1);
6038 l_suspense_ac_failed VARCHAR2(1);
6039 l_suspense_ac_not_found VARCHAR2(1);
6040 l_susp_ac_found VARCHAR2(10);
6041 l_organization_name hr_all_organization_units_tl.name%TYPE;
6042 l_organization_id NUMBER(15);
6043 l_return_value VARCHAR2(30);
6044 l_autopop_error VARCHAR2(30);
6045 l_effective_date DATE;
6046 no_profile_exists EXCEPTION;
6047 no_val_date_matches EXCEPTION;
6048 no_global_acct_exists EXCEPTION;
6049 suspense_autopop_failed EXCEPTION;
6050 l_susp_exception VARCHAR2(50);
6051 l_project_id NUMBER(15);
6052 l_expenditure_organization_id NUMBER(15);
6053 l_expenditure_type VARCHAR2(30);
6054 l_new_expenditure_type VARCHAR2(30);
6055 l_award_id NUMBER(15);
6056 l_task_id NUMBER(15);
6057 l_return_status VARCHAR2(1);
6058 l_cnt_gms_interface NUMBER;
6059 l_project_number pa_projects_all.segment1%TYPE;
6060 l_task_number VARCHAR2(300); -- pa_tasks.task_number%TYPE; -- Bug 16391366 (27/03/2013)
6061 l_award_number gms_awards_all.award_number%TYPE;
6062 l_exp_org_name hr_organization_units.name%TYPE;
6063 l_gl_description VARCHAR2(4000);
6064
6065 CURSOR project_number_cur IS
6066 SELECT SEGMENT1
6067 FROM pa_projects_all
6068 WHERE project_id = l_project_id;
6069
6070 CURSOR award_number_cur IS
6071 SELECT award_number
6072 FROM gms_awards_all
6073 WHERE award_id = l_award_id;
6074
6075 CURSOR task_number_cur Is
6076 SELECT task_number
6077 FROM pa_tasks_expend_v -- Bug : 16391366 (20/03/2013)
6078 WHERE task_id = l_task_id;
6079
6080 CURSOR exp_org_name_cur IS
6081 SELECT name
6082 FROM hr_organization_units
6083 WHERE organization_id = l_expenditure_organization_id;
6084
6085 TYPE t_rowid IS TABLE OF ROWID INDEX BY BINARY_INTEGER;
6086 TYPE t_date IS TABLE OF DATE INDEX BY BINARY_INTEGER;
6087 TYPE t_number IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
6088 TYPE t_number_15 IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
6089 TYPE t_char_300 IS TABLE OF VARCHAR2(300) INDEX BY BINARY_INTEGER;
6090
6091 TYPE r_tieback_rec IS RECORD
6092 (enc_summary_line_id t_number_15,
6093 enc_control_id t_number_15,
6094 reason_code t_char_300,
6095 txn_status_code t_char_300,
6096 dr_cr_flag t_char_300,
6097 summary_amount t_number);
6098
6099 r_reject_recs r_tieback_rec;
6100 r_success_recs r_tieback_rec;
6101
6102 TYPE r_interface_rec IS RECORD
6103 (status t_char_300,
6104 enc_summary_line_id t_number_15,
6105 dr_cr_flag t_char_300,
6106 summary_amount t_number,
6107 enc_control_id t_number_15);
6108 r_interface r_interface_rec;
6109
6110 TYPE r_suspense_ac_rec IS RECORD
6111 (row_id t_rowid,
6112 encumbrance_date t_date,
6113 enc_start_date t_date,
6114 enc_end_date t_date,
6115 person_id t_number_15,
6116 assignment_id t_number_15,
6117 element_type_id t_number_15,
6118 payroll_id t_number_15,
6119 project_id t_number_15,
6120 task_id t_number_15,
6121 award_id t_number_15,
6122 expenditure_organization_id t_number_15,
6123 expenditure_type t_char_300,
6124 suspense_org_account_id t_number_15,
6125 interface_status t_char_300,
6126 end_date t_date);
6127 r_suspense_ac r_suspense_ac_rec;
6128
6129 FUNCTION PROCESS_COMPLETE RETURN BOOLEAN IS
6130 l_cnt NUMBER;
6131 l_status VARCHAR2(30);
6132
6133 TYPE t_number_15 IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
6134 TYPE r_superceded_line_rec IS RECORD (superceded_line_id t_number_15);
6135 r_superceded_lines r_superceded_line_rec;
6136
6137 CURSOR transaction_status_cur IS
6138 SELECT COUNT(*),
6139 transaction_status_code
6140 FROM pa_transaction_interface_all
6141 WHERE transaction_source='GOLDE'
6142 AND batch_name = p_gms_batch_name
6143 AND transaction_Status_code in ('P','I')
6144 GROUP BY transaction_status_code;
6145 BEGIN
6146 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Entering GMS_ENC_TIE_BACK.PROCESS_COMPLETE');
6147
6148 OPEN transaction_status_cur;
6149 FETCH transaction_status_cur INTO l_cnt, l_status;
6150 IF (transaction_status_cur%ROWCOUNT = 0) THEN
6151 l_cnt := 0;
6152 END IF;
6153 CLOSE transaction_status_cur;
6154
6155 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' l_cnt: ' || l_cnt);
6156
6157 IF l_cnt = 0 THEN
6158 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving GMS_ENC_TIE_BACK.PROCESS_COMPLETE');
6159 RETURN TRUE;
6160 ELSIF l_cnt > 0 THEN
6161 IF l_status = 'P' THEN
6162 DELETE FROM pa_transaction_interface_all
6163 WHERE transaction_source = 'GOLDE'
6164 AND batch_name = p_gms_batch_name;
6165 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted from pa_trancsaction_interface_all count: '||sql%rowcount);
6166
6167 DELETE FROM gms_transaction_interface_all
6168 WHERE transaction_source = 'GOLDE'
6169 AND batch_name = p_gms_batch_name;
6170 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted from gms_trancsaction_interface_all count: '||sql%rowcount);
6171 DELETE FROM psp_enc_summary_lines
6172 WHERE gms_batch_name = p_gms_batch_name;
6173 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted from psp_enc_summary_lines count: '||sql%rowcount);
6174
6175 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving GMS_ENC_TIE_BACK.PROCESS_COMPLETE count: '||sql%rowcount);
6176 RETURN FALSE;
6177 ELSIF l_status = 'I' THEN
6178 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving GMS_ENC_TIE_BACK.PROCESS_COMPLETE count: '||sql%rowcount);
6179 RETURN FALSE;
6180 END IF;
6181 END IF;
6182
6183 END PROCESS_COMPLETE;
6184 BEGIN
6185 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Entering GMS_ENC_TIE_BACK');
6186
6187 IF (PROCESS_COMPLETE) THEN
6188 OPEN txn_interface_count_cur;
6189 FETCH txn_interface_count_cur INTO l_cnt_gms_interface;
6190 CLOSE txn_interface_count_cur;
6191 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' l_cnt_gms_interface: ' || l_cnt_gms_interface);
6192
6193 IF l_cnt_gms_interface > 0 THEN
6194 OPEN gms_tie_back_reject_cur;
6195 FETCH gms_tie_back_reject_cur BULK COLLECT INTO r_reject_recs.reason_code, r_reject_recs.enc_summary_line_id,
6196 r_reject_recs.txn_status_code;
6197 CLOSE gms_tie_back_reject_cur;
6198
6199 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' r_reject_recs.enc_summary_line_id.COUNT: ' || r_reject_recs.enc_summary_line_id.COUNT);
6200
6201 FORALL recno IN 1..r_reject_recs.enc_summary_line_id.COUNT
6202 UPDATE psp_enc_summary_lines
6203 SET interface_status = r_reject_recs.reason_code(recno),
6204 status_code = 'R'
6205 WHERE enc_summary_line_id = r_reject_recs.enc_summary_line_id(recno)
6206 AND r_reject_recs.txn_status_code(recno) IN ('R', 'PI', 'PO', 'PR');
6207
6208
6209 g_bulk_row_count :=0;
6210 FOR bulk_idx IN 1..r_reject_recs.enc_summary_line_id.COUNT
6211 loop
6212 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
6213 end loop;
6214
6215 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated interface_status with reject reason code in psp_enc_summary_lines count: '||g_bulk_row_count);
6216
6217 FORALL recno IN 1..r_reject_recs.enc_summary_line_id.COUNT
6218 UPDATE psp_enc_summary_lines
6219 SET interface_status = r_reject_recs.reason_code(recno),
6220 status_code = 'A'
6221 WHERE enc_summary_line_id = r_reject_recs.enc_summary_line_id(recno)
6222 AND r_reject_recs.txn_status_code(recno) = 'A';
6223
6224
6225 g_bulk_row_count :=0;
6226 FOR bulk_idx IN 1..r_reject_recs.enc_summary_line_id.COUNT
6227 loop
6228 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
6229 end loop;
6230
6231 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated status_code to ''A'' for accepted records in psp_enc_summary_lines count: '||g_bulk_row_count);
6232
6233 OPEN get_success_recs_cur;
6234 FETCH get_success_recs_cur BULK COLLECT INTO r_success_recs.enc_control_id, r_success_recs.enc_summary_line_id,
6235 r_success_recs.dr_cr_flag, r_success_recs.summary_amount;
6236 CLOSE get_success_recs_cur;
6237
6238 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' r_success_recs.enc_summary_line_id.COUNT: ' || r_success_recs.enc_summary_line_id.COUNT);
6239
6240 FORALL recno IN 1..r_success_recs.enc_summary_line_id.COUNT
6241 INSERT INTO psp_enc_lines_history
6242 (enc_line_id, business_group_id, enc_element_type_id, encumbrance_date,
6243 dr_cr_flag, encumbrance_amount, status_code, enc_line_type,
6244 schedule_line_id, org_schedule_id, default_org_account_id, suspense_org_account_id,
6245 element_account_id, gl_project_flag, enc_summary_line_id, person_id,
6246 assignment_id, award_id, task_id, expenditure_type,
6247 expenditure_organization_id, project_id, gl_code_combination_id, time_period_id,
6248 payroll_id, set_of_books_id, default_reason_code, suspense_reason_code,
6249 enc_control_id, change_flag, last_update_date, last_updated_by,
6250 last_update_login, created_by, creation_date, enc_start_date,
6251 enc_end_date, attribute_category, attribute1, attribute2,
6252 attribute3, attribute4, attribute5, attribute6,
6253 attribute7, attribute8, attribute9, attribute10,
6254 payroll_action_id, hierarchy_code, hierarchy_start_date, hierarchy_end_date,
6255 orig_gl_code_combination_id, orig_project_id, orig_task_id, orig_award_id,
6256 orig_expenditure_org_id, orig_expenditure_type)
6257 SELECT enc_line_id, business_group_id, enc_element_type_id, encumbrance_date,
6258 dr_cr_flag, encumbrance_amount, 'A', enc_line_type,
6259 schedule_line_id, org_schedule_id, default_org_account_id, suspense_org_account_id,
6260 element_account_id, gl_project_flag, enc_summary_line_id, person_id,
6261 assignment_id, award_id, task_id, expenditure_type,
6262 expenditure_organization_id, project_id, gl_code_combination_id, time_period_id,
6263 payroll_id, set_of_books_id, default_reason_code, suspense_reason_code,
6264 enc_control_id, change_flag, last_update_date, last_updated_by,
6265 last_update_login, created_by, creation_date, enc_start_date,
6266 enc_end_date, attribute_category, attribute1, attribute2,
6267 attribute3, attribute4, attribute5, attribute6,
6268 attribute7, attribute8, attribute9, attribute10,
6269 payroll_action_id, hierarchy_code, hierarchy_start_date, hierarchy_end_date,
6270 orig_gl_code_combination_id, orig_project_id, orig_task_id, orig_award_id,
6271 orig_expenditure_org_id, orig_expenditure_type
6272 FROM psp_enc_lines
6273 WHERE enc_summary_line_id = r_success_recs.enc_summary_line_id(recno);
6274 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Copied successfully summarized and transferred lines into psp_enc_lines_history');
6275
6276
6277 g_bulk_row_count :=0;
6278 FOR bulk_idx IN 1..r_success_recs.enc_summary_line_id.COUNT
6279 loop
6280 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
6281 end loop;
6282
6283 FORALL recno IN 1..r_success_recs.enc_summary_line_id.COUNT
6284 DELETE FROM psp_enc_lines
6285 WHERE enc_summary_line_id = r_success_recs.enc_summary_line_id(recno);
6286 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted lines from psp_enc_lines that are summarized and trasnferred to target systems count: '||g_bulk_row_count);
6287
6288 OPEN assign_susp_ac_cur;
6289 FETCH assign_susp_ac_cur BULK COLLECT INTO r_suspense_ac.row_id, r_suspense_ac.encumbrance_date,
6290 r_suspense_ac.enc_start_date, r_suspense_ac.enc_end_date, r_suspense_ac.person_id,
6291 r_suspense_ac.assignment_id, r_suspense_ac.payroll_id, r_suspense_ac.element_type_id,
6292 r_suspense_ac.project_id, r_suspense_ac.task_id, r_suspense_ac.award_id,
6293 r_suspense_ac.expenditure_organization_id, r_suspense_ac.expenditure_type,
6294 r_suspense_ac.suspense_org_account_id, r_suspense_ac.interface_status,
6295 r_suspense_ac.end_date;
6296 CLOSE assign_susp_ac_cur;
6297
6298 FOR recno IN 1..r_suspense_ac.row_id.COUNT
6299 LOOP
6300 IF r_suspense_ac.suspense_org_account_id(recno) IS NOT NULL THEN
6301 OPEN get_susp_org_cur(r_suspense_ac.suspense_org_account_id(recno));
6302 FETCH get_susp_org_cur INTO l_organization_id, l_organization_name, l_lines_glccid;
6303 CLOSE get_susp_org_cur;
6304
6305 l_suspense_ac_failed := 'Y';
6306 g_susp_prob := 'Y';
6307 fnd_message.set_name('PSP', 'PSP_TR_GMS_SUSP_AC_REJECT');
6308 fnd_message.set_token('ORG_NAME', l_organization_name);
6309 fnd_message.set_token('PAYROLL_DATE', r_suspense_ac.encumbrance_date(recno));
6310 fnd_message.set_token('ERROR_MSG', r_suspense_ac.interface_status(recno));
6311 fnd_msg_pub.add;
6312 ELSE
6313 l_susp_ac_found := 'TRUE';
6314
6315 OPEN get_org_id_cur(r_suspense_ac.row_id(recno));
6316 FETCH get_org_id_cur INTO l_orig_org_id, l_orig_org_name;
6317 CLOSE get_org_id_cur;
6318
6319 OPEN org_susp_ac_cur(l_orig_org_id, r_suspense_ac.encumbrance_date(recno));
6320 FETCH org_susp_ac_cur INTO l_organization_account_id,l_susp_glccid,l_project_id,
6321 l_expenditure_organization_id, l_expenditure_type, l_award_id, l_task_id;
6322
6323 IF org_susp_ac_cur%NOTFOUND THEN
6324 l_return_value := psp_general.find_global_suspense(r_suspense_ac.encumbrance_date(recno),
6325 p_business_group_id,
6326 p_set_of_books_id,
6327 l_organization_account_id);
6328
6329 IF l_return_value = 'PROFILE_VAL_DATE_MATCHES' THEN
6330 OPEN global_susp_ac_cur(l_organization_account_id);
6331 FETCH global_susp_ac_cur INTO l_organization_account_id,l_susp_glccid,l_project_id,
6332 l_expenditure_organization_id, l_expenditure_type, l_award_id, l_task_id;
6333
6334 IF global_susp_ac_cur%NOTFOUND THEN
6335 l_encumbrance_date := r_suspense_ac.encumbrance_date(recno);
6336 l_suspense_ac_not_found := 'Y';
6337 l_susp_ac_found := 'NO_G_AC';
6338 END IF;
6339 CLOSE global_susp_ac_cur;
6340 ELSIF l_return_value = 'NO_GLOBAL_ACCT_EXISTS' THEN
6341 l_encumbrance_date := r_suspense_ac.encumbrance_date(recno);
6342 l_suspense_ac_not_found := 'Y';
6343 l_susp_ac_found := 'NO_G_AC';
6344 ELSIF l_return_value = 'NO_VAL_DATE_MATCHES' THEN
6345 l_encumbrance_date := r_suspense_ac.encumbrance_date(recno);
6346 l_suspense_ac_not_found := 'Y';
6347 l_susp_ac_found := 'NO_DT_MCH';
6348 ELSIF l_return_value = 'NO_PROFILE_EXISTS' THEN
6349 l_encumbrance_date := r_suspense_ac.encumbrance_date(recno);
6350 l_suspense_ac_not_found := 'Y';
6351 l_susp_ac_found := 'NO_PROFL';
6352 END IF;
6353 END IF;
6354 CLOSE org_susp_ac_cur;
6355
6356 IF l_susp_ac_found = 'TRUE' THEN
6357 IF l_susp_glccid IS NOT NULL THEN
6358 l_gl_project_flag := 'G';
6359 l_effective_date := r_suspense_ac.end_date(recno);
6360
6361 IF (g_sa_autopop) THEN
6362 psp_autopop.main(p_acct_type => 'N',
6363 p_person_id => r_suspense_ac.person_id(recno),
6364 p_assignment_id => r_suspense_ac.assignment_id(recno),
6365 p_element_type_id => r_suspense_ac.element_type_id(recno),
6366 p_project_id => l_project_id,
6367 p_expenditure_organization_id => l_expenditure_organization_id,
6368 p_task_id => l_task_id,
6369 p_award_id => l_award_id,
6370 p_expenditure_type => l_expenditure_type,
6371 p_gl_code_combination_id => l_susp_glccid,
6372 p_payroll_date => l_effective_date,
6373 p_set_of_books_id => g_set_of_books_id,
6374 p_business_group_id => g_business_group_id,
6375 ret_expenditure_type => l_new_expenditure_type,
6376 ret_gl_code_combination_id => l_new_gl_code_combination_id,
6377 retcode => l_autopop_status);
6378
6379 IF (l_autopop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
6380 (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
6381 l_susp_exception := 'AUTOPOP';
6382 l_suspense_ac_not_found := 'Y';
6383 l_autopop_error := 'AUTO_POP_EXP_ERROR';
6384 IF (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
6385 l_autopop_error := 'AUTO_POP_NO_VALUE';
6386 END IF;
6387 l_gl_description := psp_general.get_gl_values(g_set_of_books_id, l_susp_glccid);
6388 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_AUTOPOP');
6389 fnd_message.set_token('START_DATE', l_effective_date);
6390 fnd_message.set_token('END_DATE', l_effective_date);
6391 fnd_message.set_token('GL', l_gl_description);
6392 fnd_message.set_token('AUTOPOP_STATUS', l_autopop_error);
6393 g_warning_message := fnd_message.get;
6394 fnd_file.put_line(fnd_file.log, g_warning_message);
6395 ELSE
6396 l_susp_glccid := l_new_gl_code_combination_id;
6397 END IF;
6398 END IF;
6399 ELSE
6400 l_gl_project_flag := 'P';
6401 psp_general.poeta_effective_date(r_suspense_ac.encumbrance_date(recno),
6402 l_project_id, l_award_id, l_task_id, l_effective_date,
6403 l_return_status);
6404 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6405 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6406 END IF;
6407 IF (g_sa_autopop) THEN
6408 psp_autopop.main(p_acct_type => 'E',
6409 p_person_id => r_suspense_ac.person_id(recno),
6410 p_assignment_id => r_suspense_ac.assignment_id(recno),
6411 p_element_type_id => r_suspense_ac.element_type_id(recno),
6412 p_project_id => l_project_id,
6413 p_expenditure_organization_id => l_expenditure_organization_id,
6414 p_task_id => l_task_id,
6415 p_award_id => l_award_id,
6416 p_expenditure_type => l_expenditure_type,
6417 p_gl_code_combination_id => l_susp_glccid,
6418 p_payroll_date => l_effective_date,
6419 p_set_of_books_id => g_set_of_books_id,
6420 p_business_group_id => g_business_group_id,
6421 ret_expenditure_type => l_new_expenditure_type,
6422 ret_gl_code_combination_id => l_new_gl_code_combination_id,
6423 retcode => l_autopop_status);
6424
6425 IF (l_autopop_status = FND_API.G_RET_STS_UNEXP_ERROR) OR
6426 (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
6427 l_susp_exception := 'AUTOPOP';
6428 l_suspense_ac_not_found := 'Y';
6429 l_autopop_error := 'AUTO_POP_EXP_ERROR';
6430 IF (l_autopop_status = FND_API.G_RET_STS_ERROR) THEN
6431 l_autopop_error := 'AUTO_POP_NO_VALUE';
6432 END IF;
6433 OPEN project_number_cur;
6434 FETCH project_number_cur INTO l_project_number;
6435 CLOSE project_number_cur;
6436
6437 OPEN award_number_cur;
6438 FETCH award_number_cur INTO l_award_number;
6439 CLOSE award_number_cur;
6440
6441 OPEN task_number_cur;
6442 FETCH task_number_cur INTO l_task_number;
6443 CLOSE task_number_cur;
6444
6445 OPEN exp_org_name_cur;
6446 FETCH exp_org_name_cur INTO l_exp_org_name;
6447 CLOSE exp_org_name_cur;
6448
6449 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_AP_PATEO');
6450 fnd_message.set_token('START_DATE', l_effective_date);
6451 fnd_message.set_token('END_DATE', l_effective_date);
6452 fnd_message.set_token('PJ', l_project_number);
6453 fnd_message.set_token('TK', l_task_number);
6454 fnd_message.set_token('AW', l_award_number);
6455 fnd_message.set_token('EO', l_exp_org_name);
6456 fnd_message.set_token('ET', l_expenditure_type);
6457 fnd_message.set_token('AUTOPOP_STATUS', l_autopop_error);
6458 g_warning_message := fnd_message.get;
6459 fnd_file.put_line(fnd_file.log, g_warning_message);
6460 ELSE
6461 l_expenditure_type := l_new_expenditure_type;
6462 END IF;
6463 END IF;
6464 END IF;
6465
6466 UPDATE psp_enc_lines
6467 SET prev_effective_date = encumbrance_date,
6468 prev_enc_end_date = enc_end_date,
6469 prev_encumbrance_amount = encumbrance_amount,
6470 orig_gl_code_combination_id = gl_code_combination_id,
6471 orig_project_id = project_id,
6472 orig_task_id = task_id,
6473 orig_award_id = award_id,
6474 orig_expenditure_org_id = expenditure_organization_id,
6475 orig_expenditure_type = expenditure_type
6476 WHERE rowid = r_suspense_ac.row_id(recno);
6477
6478 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'updated psp_enc_lines4 count'||sql%rowcount);
6479
6480 UPDATE psp_enc_lines
6481 SET suspense_org_account_id = l_organization_account_id,
6482 gl_code_combination_id = l_susp_glccid,
6483 project_id = l_project_id,
6484 task_id = l_task_id,
6485 award_id = l_award_id,
6486 expenditure_organization_id = l_expenditure_organization_id,
6487 expenditure_type = l_expenditure_type,
6488 suspense_reason_code = 'ES:' || r_suspense_ac.interface_status(recno),
6489 gl_project_flag = l_gl_project_flag,
6490 encumbrance_date = l_effective_date,
6491 enc_end_date = LEAST(enc_end_date, g_def_end_date),
6492 encumbrance_amount = (encumbrance_amount * (psp_general.business_days(enc_start_date, LEAST(enc_end_date, g_def_end_date)) / psp_general.business_days(enc_start_date, enc_end_date))),
6493 status_code = 'N'
6494 WHERE rowid = r_suspense_ac.row_id(recno);
6495
6496 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'updated psp_enc_lines5 count'||sql%rowcount);
6497 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || 'add_st_warnings');
6498 add_st_warnings(p_assignment_id => r_suspense_ac.assignment_id(recno),
6499 p_payroll_id => r_suspense_ac.payroll_id(recno),
6500 p_element_type_id => r_suspense_ac.element_type_id(recno),
6501 p_start_date => r_suspense_ac.enc_start_date(recno),
6502 p_end_date => r_suspense_ac.enc_end_date(recno),
6503 p_effective_date => r_suspense_ac.encumbrance_date(recno),
6504 p_project_id => r_suspense_ac.project_id(recno),
6505 p_task_id => r_suspense_ac.task_id(recno),
6506 p_award_id => r_suspense_ac.award_id(recno),
6507 p_exp_org_id => r_suspense_ac.expenditure_organization_id(recno),
6508 p_exp_type => r_suspense_ac.expenditure_type(recno),
6509 p_error_status => r_suspense_ac.interface_status(recno));
6510 ELSE
6511 l_susp_exception := l_susp_ac_found;
6512 END IF;
6513 END IF;
6514 END LOOP;
6515
6516 IF l_suspense_ac_failed = 'Y' THEN
6517 UPDATE psp_enc_lines
6518 SET suspense_org_account_id = NULL,
6519 gl_code_combination_id = orig_gl_code_combination_id,
6520 project_id = orig_project_id,
6521 task_id = orig_task_id,
6522 award_id = orig_award_id,
6523 expenditure_organization_id = orig_expenditure_org_id,
6524 expenditure_type = orig_expenditure_type,
6525 gl_project_flag = decode(orig_gl_code_combination_id,NULL,'P','G'),
6526 encumbrance_date = prev_effective_date,
6527 enc_end_date = NVL(prev_enc_end_date, enc_end_date),
6528 encumbrance_amount = NVL(prev_encumbrance_amount, encumbrance_amount)
6529 WHERE suspense_reason_code like 'ES:%'
6530 AND enc_summary_line_id IN (SELECT enc_summary_line_id
6531 FROM psp_enc_summary_lines pesl
6532 WHERE pesl.payroll_action_id = p_payroll_action_id
6533 AND pesl.gms_batch_name = p_gms_batch_name
6534 AND status_code = 'R');
6535 UPDATE psp_enc_lines
6536 SET orig_gl_code_combination_id = NULL,
6537 orig_project_id = NULL,
6538 orig_task_id = NULL,
6539 orig_award_id = NULL,
6540 orig_expenditure_org_id = NULL,
6541 orig_expenditure_type = NULL,
6542 suspense_reason_code = NULL,
6543 prev_enc_end_date = NULL,
6544 prev_encumbrance_amount = NULL
6545 WHERE suspense_reason_code like 'ES:%'
6546 AND enc_summary_line_id IN (SELECT enc_summary_line_id
6547 FROM psp_enc_summary_lines pesl
6548 WHERE pesl.payroll_action_id = p_payroll_action_id
6549 AND pesl.gms_batch_name = p_gms_batch_name
6550 AND status_code = 'R');
6551 END IF;
6552
6553 IF l_suspense_ac_not_found = 'Y' THEN
6554 g_susp_prob := 'Y';
6555 IF l_susp_exception = 'NO_G_AC' THEN
6556 RAISE no_global_acct_exists;
6557 ELSIF l_susp_exception = 'NO_DT_MCH' THEN
6558 RAISE no_val_date_matches;
6559 ELSIF l_susp_exception = 'NO_PROFL' THEN
6560 RAISE no_profile_exists;
6561 ELSIF l_susp_exception = 'AUTOPOP' THEN
6562 RAISE suspense_autopop_failed;
6563 END IF;
6564 END IF;
6565
6566 FORALL recno IN 1..r_success_recs.enc_summary_line_id.COUNT
6567 UPDATE psp_enc_controls pec
6568 SET summ_ogm_dr_amount = NVL(pec.summ_ogm_dr_amount, 0) + DECODE(r_success_recs.dr_cr_flag(recno), 'D', r_success_recs.summary_amount(recno), 0),
6569 summ_ogm_cr_amount = NVL(pec.summ_ogm_cr_amount, 0) + DECODE(r_success_recs.dr_cr_flag(recno), 'C', r_success_recs.summary_amount(recno), 0)
6570 WHERE enc_control_id = r_success_recs.enc_control_id(recno);
6571
6572 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Update summ_ogm_cr_amount, summ_ogm_dr_amount in psp_enc_controls');
6573
6574 r_reject_recs.enc_summary_line_id.DELETE;
6575 r_reject_recs.enc_control_id.DELETE;
6576 r_reject_recs.reason_code.DELETE;
6577 r_reject_recs.txn_status_code.DELETE;
6578 r_success_recs.enc_summary_line_id.DELETE;
6579 r_success_recs.enc_control_id.DELETE;
6580 r_success_recs.reason_code.DELETE;
6581 r_success_recs.txn_status_code.DELETE;
6582 ELSIF l_cnt_gms_interface = 0 THEN
6583 OPEN gms_tie_back_success_cur;
6584 FETCH gms_tie_back_success_cur BULK COLLECT INTO r_success_recs.enc_control_id, r_success_recs.enc_summary_line_id,
6585 r_success_recs.dr_cr_flag, r_success_recs.summary_amount;
6586 CLOSE gms_tie_back_success_cur;
6587
6588 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' r_success_recs.enc_summary_line_id.COUNT: ' || r_success_recs.enc_summary_line_id.COUNT);
6589
6590 FORALL recno IN 1..r_success_recs.enc_summary_line_id.COUNT
6591 UPDATE psp_enc_summary_lines
6592 SET status_code = 'A'
6593 WHERE enc_summary_line_id = r_success_recs.enc_summary_line_id(recno);
6594
6595 g_bulk_row_count :=0;
6596 FOR bulk_idx IN 1..r_success_recs.enc_summary_line_id.COUNT
6597 loop
6598 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
6599 end loop;
6600
6601 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated status_code to ''A'' in psp_enc_summary_lines count: '||g_bulk_row_count);
6602
6603
6604
6605 FORALL recno IN 1..r_success_recs.enc_summary_line_id.COUNT
6606 INSERT INTO psp_enc_lines_history
6607 (enc_line_id, business_group_id, enc_element_type_id, encumbrance_date,
6608 dr_cr_flag, encumbrance_amount, status_code, enc_line_type,
6609 schedule_line_id, org_schedule_id, default_org_account_id, suspense_org_account_id,
6610 element_account_id, gl_project_flag, enc_summary_line_id, person_id,
6611 assignment_id, award_id, task_id, expenditure_type,
6612 expenditure_organization_id, project_id, gl_code_combination_id, time_period_id,
6613 payroll_id, set_of_books_id, default_reason_code, suspense_reason_code,
6614 enc_control_id, change_flag, last_update_date, last_updated_by,
6615 last_update_login, created_by, creation_date, enc_start_date,
6616 enc_end_date, attribute_category, attribute1, attribute2,
6617 attribute3, attribute4, attribute5, attribute6,
6618 attribute7, attribute8, attribute9, attribute10,
6619 payroll_action_id, hierarchy_code, hierarchy_start_date, hierarchy_end_date)
6620 SELECT enc_line_id, business_group_id, enc_element_type_id, encumbrance_date,
6621 dr_cr_flag, encumbrance_amount, 'A', enc_line_type,
6622 schedule_line_id, org_schedule_id, default_org_account_id, suspense_org_account_id,
6623 element_account_id, gl_project_flag, enc_summary_line_id, person_id,
6624 assignment_id, award_id, task_id, expenditure_type,
6625 expenditure_organization_id, project_id, gl_code_combination_id, time_period_id,
6626 payroll_id, set_of_books_id, default_reason_code, suspense_reason_code,
6627 enc_control_id, change_flag, last_update_date, last_updated_by,
6628 last_update_login, created_by, creation_date, enc_start_date,
6629 enc_end_date, attribute_category, attribute1, attribute2,
6630 attribute3, attribute4, attribute5, attribute6,
6631 attribute7, attribute8, attribute9, attribute10,
6632 payroll_action_id, hierarchy_code, hierarchy_start_date, hierarchy_end_date
6633 FROM psp_enc_lines
6634 WHERE enc_summary_line_id = r_success_recs.enc_summary_line_id(recno);
6635
6636 g_bulk_row_count :=0;
6637 FOR bulk_idx IN 1..r_success_recs.enc_summary_line_id.COUNT
6638 loop
6639 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
6640 end loop;
6641
6642 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Copied successfully summarized and transferred lines into psp_enc_lines_history count: '||g_bulk_row_count);
6643
6644 FORALL recno IN 1..r_success_recs.enc_summary_line_id.COUNT
6645 DELETE FROM psp_enc_lines
6646 WHERE enc_summary_line_id = r_success_recs.enc_summary_line_id(recno);
6647
6648 g_bulk_row_count :=0;
6649 FOR bulk_idx IN 1..r_success_recs.enc_summary_line_id.COUNT
6650 loop
6651 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
6652 end loop;
6653 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted lines from psp_enc_lines that are summarized and trasnferred to target systems'||g_bulk_row_count);
6654
6655 FORALL recno IN 1..r_success_recs.enc_summary_line_id.COUNT
6656 UPDATE psp_enc_controls pec
6657 SET gms_phase = 'TieBack',
6658 summ_ogm_dr_amount = NVL(pec.summ_ogm_dr_amount, 0) + DECODE(r_success_recs.dr_cr_flag(recno), 'D', r_success_recs.summary_amount(recno), 0),
6659 summ_ogm_cr_amount = NVL(pec.summ_ogm_cr_amount, 0) + DECODE(r_success_recs.dr_cr_flag(recno), 'C', r_success_recs.summary_amount(recno), 0)
6660 WHERE enc_control_id = r_success_recs.enc_control_id(recno);
6661
6662 g_bulk_row_count :=0;
6663 FOR bulk_idx IN 1..r_success_recs.enc_summary_line_id.COUNT
6664 loop
6665 g_bulk_row_count := g_bulk_row_count + SQL%BULK_ROWCOUNT(bulk_idx);
6666 end loop;
6667
6668 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated summ_ogm_cr_amount, summ_ogm_dr_amount, gms_phase in psp_enc_controls count: '||g_bulk_row_count);
6669
6670 r_success_recs.enc_summary_line_id.DELETE;
6671 r_success_recs.enc_control_id.DELETE;
6672 r_success_recs.reason_code.DELETE;
6673 r_success_recs.txn_status_code.DELETE;
6674 END IF;
6675 ELSE
6676 g_process_complete := FALSE;
6677 END IF;
6678
6679 p_return_status := fnd_api.g_ret_sts_success;
6680 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving GMS_ENC_TIE_BACK');
6681 EXCEPTION
6682 WHEN NO_PROFILE_EXISTS THEN
6683 g_error_api_path := SUBSTR('GMS_ENC_TIE_BACK:'||g_error_api_path,1,230);
6684 fnd_message.set_name('PSP','PSP_NO_PROFILE_EXISTS');
6685 fnd_msg_pub.add;
6686 p_return_status := fnd_api.g_ret_sts_success;
6687 WHEN NO_VAL_DATE_MATCHES THEN
6688 g_error_api_path := SUBSTR('GMS_ENC_TIE_BACK:'||g_error_api_path,1,230);
6689 fnd_message.set_name('PSP','PSP_NO_VAL_DATE_MATCHES');
6690 fnd_message.set_token('ORG_NAME',l_orig_org_name);
6691 fnd_message.set_token('PAYROLL_DATE',l_encumbrance_date);
6692 fnd_msg_pub.add;
6693 p_return_status := fnd_api.g_ret_sts_success;
6694 WHEN NO_GLOBAL_ACCT_EXISTS THEN
6695 g_error_api_path := SUBSTR('GMS_ENC_TIE_BACK:'||g_error_api_path,1,230);
6696 fnd_message.set_name('PSP','PSP_NO_GLOBAL_ACCT_EXISTS');
6697 fnd_message.set_token('ORG_NAME',l_orig_org_name);
6698 fnd_message.set_token('PAYROLL_DATE',l_encumbrance_date);
6699 fnd_msg_pub.add;
6700 p_return_status := fnd_api.g_ret_sts_success;
6701 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
6702 g_error_api_path := 'GMS_ENC_TIE_BACK:'||g_error_api_path;
6703 p_return_status := fnd_api.g_ret_sts_unexp_error;
6704 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving GMS_ENC_TIE_BACK');
6705 WHEN OTHERS THEN
6706 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
6707 g_error_api_path := 'GMS_ENC_TIE_BACK:'||g_error_api_path;
6708 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN','GMS_ENC_TIE_BACK');
6709 p_return_status := fnd_api.g_ret_sts_unexp_error;
6710 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving GMS_ENC_TIE_BACK');
6711 END gms_enc_tie_back;
6712 -- End of changes for Create and Update multi thread enh.
6713
6714 PROCEDURE create_sum_lines (p_payroll_action_id IN NUMBER,
6715 p_return_status OUT NOCOPY VARCHAR2) IS
6716 l_last_updated_by NUMBER(15);
6717 l_last_update_login NUMBER(15);
6718
6719 CURSOR sum_lines_cur IS
6720 SELECT pel.enc_control_id,
6721 pel.time_period_id,
6722 pel.person_id,
6723 pel.assignment_id,
6724 pel.payroll_id,
6725 pel.encumbrance_date,
6726 pel.gl_code_combination_id,
6727 pel.project_id,
6728 pel.task_id,
6729 pel.award_id,
6730 pel.expenditure_type,
6731 pel.expenditure_organization_id,
6732 SUM(pel.encumbrance_amount),
6733 pel.dr_cr_flag,
6734 pel.gl_project_flag,
6735 DECODE(g_dff_grouping_option, 'Y', pel.attribute_category, NULL) attribute_category,
6736 DECODE(g_dff_grouping_option, 'Y', pel.attribute1, NULL) attribute1,
6737 DECODE(g_dff_grouping_option, 'Y', pel.attribute2, NULL) attribute2,
6738 DECODE(g_dff_grouping_option, 'Y', pel.attribute3, NULL) attribute3,
6739 DECODE(g_dff_grouping_option, 'Y', pel.attribute4, NULL) attribute4,
6740 DECODE(g_dff_grouping_option, 'Y', pel.attribute5, NULL) attribute5,
6741 DECODE(g_dff_grouping_option, 'Y', pel.attribute6, NULL) attribute6,
6742 DECODE(g_dff_grouping_option, 'Y', pel.attribute7, NULL) attribute7,
6743 DECODE(g_dff_grouping_option, 'Y', pel.attribute8, NULL) attribute8,
6744 DECODE(g_dff_grouping_option, 'Y', pel.attribute9, NULL) attribute9,
6745 DECODE(g_dff_grouping_option, 'Y', pel.attribute10, NULL) attribute10,
6746 pa.org_id
6747 FROM PSP_ENC_LINES pel,
6748 pa_projects_all pa
6749 WHERE pel.ENCUMBRANCE_AMOUNT <> 0
6750 AND pel.payroll_action_id = p_payroll_action_id
6751 AND (g_suspense_failed = 'TRUE' OR pel.suspense_reason_code LIKE 'ES:%')
6752 AND (g_suspense_failed = 'TRUE' OR enc_start_date <= g_def_end_date)
6753 AND pa.project_id (+) = pel.project_id
6754 GROUP BY pel.enc_control_id,
6755 pel.time_period_id,
6756 pel.person_id,
6757 pel.assignment_id,
6758 pel.payroll_id,
6759 pel.encumbrance_date,
6760 pel.gl_code_combination_id,
6761 pel.project_id,
6762 pel.task_id,
6763 pel.award_id,
6764 pel.expenditure_type,
6765 pel.expenditure_organization_id,
6766 pel.dr_cr_flag,
6767 pel.gl_project_flag,
6768 DECODE(g_dff_grouping_option, 'Y', pel.attribute_category, NULL),
6769 DECODE(g_dff_grouping_option, 'Y', pel.attribute1, NULL),
6770 DECODE(g_dff_grouping_option, 'Y', pel.attribute2, NULL),
6771 DECODE(g_dff_grouping_option, 'Y', pel.attribute3, NULL),
6772 DECODE(g_dff_grouping_option, 'Y', pel.attribute4, NULL),
6773 DECODE(g_dff_grouping_option, 'Y', pel.attribute5, NULL),
6774 DECODE(g_dff_grouping_option, 'Y', pel.attribute6, NULL),
6775 DECODE(g_dff_grouping_option, 'Y', pel.attribute7, NULL),
6776 DECODE(g_dff_grouping_option, 'Y', pel.attribute8, NULL),
6777 DECODE(g_dff_grouping_option, 'Y', pel.attribute9, NULL),
6778 DECODE(g_dff_grouping_option, 'Y', pel.attribute10, NULL),
6779 pa.org_id;
6780
6781 TYPE sum_lines_rec is RECORD
6782 (enc_summary_line_id t_num_15_type,
6783 enc_control_id t_num_15_type,
6784 time_period_id t_num_15_type,
6785 person_id t_num_15_type,
6786 assignment_id t_num_15_type,
6787 payroll_id t_num_15_type,
6788 effective_date t_date_type,
6789 gl_code_combination_id t_num_15_type,
6790 project_id t_num_15_type,
6791 task_id t_num_15_type,
6792 award_id t_num_15_type,
6793 expenditure_organization_id t_num_15_type,
6794 expenditure_type t_varchar_50_type,
6795 summary_amount t_num_10d2_type,
6796 dr_cr_flag t_varchar_50_type,
6797 gl_project_flag t_varchar_50_type,
6798 attribute_category t_varchar_50_type,
6799 attribute1 t_varchar_150_type,
6800 attribute2 t_varchar_150_type,
6801 attribute3 t_varchar_150_type,
6802 attribute4 t_varchar_150_type,
6803 attribute5 t_varchar_150_type,
6804 attribute6 t_varchar_150_type,
6805 attribute7 t_varchar_150_type,
6806 attribute8 t_varchar_150_type,
6807 attribute9 t_varchar_150_type,
6808 attribute10 t_varchar_150_type,
6809 org_id t_num_15_type);
6810 t_sum_lines sum_lines_rec;
6811 BEGIN
6812 l_last_updated_by := fnd_global.user_id;
6813 l_last_update_login := fnd_global.login_id;
6814
6815 OPEN sum_lines_cur;
6816 FETCH sum_lines_cur BULK COLLECT INTO t_sum_lines.enc_control_id,
6817 t_sum_lines.time_period_id, t_sum_lines.person_id,
6818 t_sum_lines.assignment_id, t_sum_lines.payroll_id,
6819 t_sum_lines.effective_date, t_sum_lines.gl_code_combination_id,
6820 t_sum_lines.project_id, t_sum_lines.task_id,
6821 t_sum_lines.award_id, t_sum_lines.expenditure_type,
6822 t_sum_lines.expenditure_organization_id, t_sum_lines.summary_amount,
6823 t_sum_lines.dr_cr_flag, t_sum_lines.gl_project_flag,
6824 t_sum_lines.attribute_category, t_sum_lines.attribute1,
6825 t_sum_lines.attribute2, t_sum_lines.attribute3,
6826 t_sum_lines.attribute4, t_sum_lines.attribute5,
6827 t_sum_lines.attribute6, t_sum_lines.attribute7,
6828 t_sum_lines.attribute8, t_sum_lines.attribute9,
6829 t_sum_lines.attribute10, t_sum_lines.org_id;
6830 CLOSE sum_lines_cur;
6831
6832 FOR recno IN 1..t_sum_lines.enc_control_id.COUNT
6833 LOOP
6834 SELECT psp_enc_summary_lines_s.NEXTVAL INTO t_sum_lines.enc_summary_line_id(recno) FROM DUAL;
6835 END LOOP;
6836
6837 FORALL recno IN 1..t_sum_lines.enc_control_id.COUNT
6838 INSERT INTO psp_enc_summary_lines
6839 (enc_summary_line_id, business_group_id, enc_control_id,
6840 time_period_id, person_id, assignment_id,
6841 effective_date, set_of_books_id, gl_code_combination_id,
6842 project_id, task_id, award_id,
6843 expenditure_organization_id, expenditure_type, summary_amount,
6844 dr_cr_flag, status_code, payroll_id,
6845 gl_project_flag,
6846 attribute_category, attribute1, attribute2,
6847 attribute3, attribute4, attribute5,
6848 attribute6, attribute7, attribute8,
6849 attribute9, attribute10, org_id,
6850 payroll_action_id, last_update_date, last_updated_by,
6851 last_update_login, created_by, creation_date)
6852 VALUES (t_sum_lines.enc_summary_line_id(recno), g_business_group_id,
6853 t_sum_lines.enc_control_id(recno), t_sum_lines.time_period_id(recno),
6854 t_sum_lines.person_id(recno), t_sum_lines.assignment_id(recno),
6855 t_sum_lines.effective_date(recno), g_set_of_books_id,
6856 t_sum_lines.gl_code_combination_id(recno), t_sum_lines.project_id(recno),
6857 t_sum_lines.task_id(recno), t_sum_lines.award_id(recno),
6858 t_sum_lines.expenditure_organization_id(recno), t_sum_lines.expenditure_type(recno),
6859 t_sum_lines.summary_amount(recno), t_sum_lines.dr_cr_flag(recno),
6860 'N', t_sum_lines.payroll_id(recno), t_sum_lines.gl_project_flag(recno),
6861 t_sum_lines.attribute_category(recno), t_sum_lines.attribute1(recno),
6862 t_sum_lines.attribute2(recno), t_sum_lines.attribute3(recno),
6863 t_sum_lines.attribute4(recno), t_sum_lines.attribute5(recno),
6864 t_sum_lines.attribute6(recno), t_sum_lines.attribute7(recno),
6865 t_sum_lines.attribute8(recno), t_sum_lines.attribute9(recno),
6866 t_sum_lines.attribute10(recno), t_sum_lines.org_id(recno),
6867 p_payroll_action_id, SYSDATE,
6868 l_last_updated_by, l_last_update_login,
6869 l_last_updated_by, SYSDATE);
6870 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' No of Summary lines created (t_sum_lines.enc_control_id.COUNT): ' || t_sum_lines.enc_control_id.COUNT);
6871
6872 IF (g_dff_grouping_option = 'Y') THEN
6873 FORALL recno IN 1..t_sum_lines.enc_summary_line_id.COUNT
6874 UPDATE psp_enc_lines pel
6875 SET enc_summary_line_id = t_sum_lines.enc_summary_line_id(recno)
6876 WHERE payroll_action_id = p_payroll_action_id
6877 AND pel.enc_control_id = t_sum_lines.enc_control_id(recno)
6878 AND pel.time_period_id = t_sum_lines.time_period_id(recno)
6879 AND pel.person_id = t_sum_lines.person_id(recno)
6880 AND pel.encumbrance_date = t_sum_lines.effective_date(recno)
6881 AND NVL(pel.gl_code_combination_id, -99) = NVL(t_sum_lines.gl_code_combination_id(recno), -99)
6882 AND NVL(pel.project_id, -99) = NVL(t_sum_lines.project_id(recno), -99)
6883 AND NVL(pel.task_id, -99) = NVL(t_sum_lines.task_id(recno), -99)
6884 AND NVL(pel.award_id, -99) = NVL(t_sum_lines.award_id(recno), -99)
6885 AND NVL(pel.expenditure_type, 'NULL') = NVL(t_sum_lines.expenditure_type(recno), 'NULL')
6886 AND NVL(pel.expenditure_organization_id, -99) = NVL(t_sum_lines.expenditure_organization_id(recno), -99)
6887 AND pel.dr_cr_flag = t_sum_lines.dr_cr_flag(recno)
6888 AND pel.gl_project_flag = t_sum_lines.gl_project_flag(recno)
6889 AND NVL(pel.attribute_category, 'NULL') = NVL(t_sum_lines.attribute_category(recno), 'NULL')
6890 AND NVL(pel.attribute1, 'NULL') = NVL(t_sum_lines.attribute1(recno), 'NULL')
6891 AND NVL(pel.attribute2, 'NULL') = NVL(t_sum_lines.attribute2(recno), 'NULL')
6892 AND NVL(pel.attribute3, 'NULL') = NVL(t_sum_lines.attribute3(recno), 'NULL')
6893 AND NVL(pel.attribute4, 'NULL') = NVL(t_sum_lines.attribute4(recno), 'NULL')
6894 AND NVL(pel.attribute5, 'NULL') = NVL(t_sum_lines.attribute5(recno), 'NULL')
6895 AND NVL(pel.attribute6, 'NULL') = NVL(t_sum_lines.attribute6(recno), 'NULL')
6896 AND NVL(pel.attribute7, 'NULL') = NVL(t_sum_lines.attribute7(recno), 'NULL')
6897 AND NVL(pel.attribute8, 'NULL') = NVL(t_sum_lines.attribute8(recno), 'NULL')
6898 AND NVL(pel.attribute9, 'NULL') = NVL(t_sum_lines.attribute9(recno), 'NULL')
6899 AND NVL(pel.attribute10, 'NULL') = NVL(t_sum_lines.attribute10(recno), 'NULL');
6900 ELSE
6901 FORALL recno IN 1..t_sum_lines.enc_summary_line_id.COUNT
6902 UPDATE psp_enc_lines pel
6903 SET enc_summary_line_id = t_sum_lines.enc_summary_line_id(recno)
6904 WHERE payroll_action_id = p_payroll_action_id
6905 AND pel.enc_control_id = t_sum_lines.enc_control_id(recno)
6906 AND pel.time_period_id = t_sum_lines.time_period_id(recno)
6907 AND pel.person_id = t_sum_lines.person_id(recno)
6908 AND pel.encumbrance_date = t_sum_lines.effective_date(recno)
6909 AND NVL(pel.gl_code_combination_id, -99) = NVL(t_sum_lines.gl_code_combination_id(recno), -99)
6910 AND NVL(pel.project_id, -99) = NVL(t_sum_lines.project_id(recno), -99)
6911 AND NVL(pel.task_id, -99) = NVL(t_sum_lines.task_id(recno), -99)
6912 AND NVL(pel.award_id, -99) = NVL(t_sum_lines.award_id(recno), -99)
6913 AND NVL(pel.expenditure_type, 'NULL') = NVL(t_sum_lines.expenditure_type(recno), 'NULL')
6914 AND NVL(pel.expenditure_organization_id, -99) = NVL(t_sum_lines.expenditure_organization_id(recno), -99)
6915 AND pel.dr_cr_flag = t_sum_lines.dr_cr_flag(recno)
6916 AND pel.gl_project_flag = t_sum_lines.gl_project_flag(recno);
6917 END IF;
6918 p_return_status := fnd_api.g_ret_sts_success;
6919 EXCEPTION
6920 WHEN OTHERS THEN
6921 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
6922 g_error_api_path := SUBSTR('CREATE_SUM_LINES:' || g_error_api_path,1,230);
6923 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN', 'CREATE_SUM_LINES');
6924 p_return_status := fnd_api.g_ret_sts_unexp_error;
6925 END create_sum_lines;
6926
6927 PROCEDURE update_hierarchy_dates (p_payroll_action_id IN NUMBER,
6928 p_return_status OUT NOCOPY VARCHAR2) IS
6929 CURSOR hierarchy_dates_cur (p_assignment_id IN NUMBER,
6930 p_payroll_id IN NUMBER) IS
6931 SELECT DISTINCT enc_element_type_id,
6932 hierarchy_code,
6933 NVL(gl_code_combination_id, -99),
6934 NVL(project_id, -99),
6935 NVL(task_id, -99),
6936 NVL(award_id, -99),
6937 NVL(expenditure_organization_id, -99),
6938 NVL(expenditure_type, '-99'),
6939 enc_start_date,
6940 enc_end_date
6941 FROM psp_enc_lines_history pelh
6942 WHERE change_flag = 'N'
6943 AND assignment_id = p_assignment_id
6944 AND payroll_id = p_payroll_id
6945 ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
6946
6947 l_nlines_counter NUMBER(15);
6948 BEGIN
6949 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Entering UPDATE_HIERARCHY_DATES');
6950 l_nlines_counter := 0;
6951
6952 FOR asg_no IN 1..l_asgs.payroll_id.COUNT
6953 LOOP
6954 UPDATE psp_enc_lines_history pelh
6955 SET change_flag = 'N'
6956 WHERE EXISTS (SELECT 1
6957 FROM psp_enc_summary_lines pesl
6958 WHERE pesl.enc_summary_line_id = pelh.enc_summary_line_id
6959 AND status_code = 'A')
6960 AND assignment_id = l_asgs.assignment_id(asg_no)
6961 AND payroll_id = l_asgs.payroll_id(asg_no);
6962
6963 UPDATE psp_enc_lines_history pelh
6964 SET hierarchy_code = 'SA'
6965 WHERE change_flag = 'N'
6966 AND hierarchy_code <> 'SA'
6967 AND suspense_org_account_id IS NOT NULL
6968 AND assignment_id = l_asgs.assignment_id(asg_no)
6969 AND payroll_id = l_asgs.payroll_id(asg_no);
6970
6971 OPEN hierarchy_dates_cur(l_asgs.assignment_id(asg_no),
6972 l_asgs.payroll_id(asg_no));
6973 FETCH hierarchy_dates_cur BULK COLLECT INTO t_enc_lines.element_type_id,
6974 t_enc_lines.hierarchy_code, t_enc_lines.gl_ccid, t_enc_lines.project_id,
6975 t_enc_lines.task_id, t_enc_lines.award_id, t_enc_lines.exp_org_id,
6976 t_enc_lines.exp_type, t_enc_lines.enc_start_date, t_enc_lines.enc_end_date;
6977 CLOSE hierarchy_dates_cur;
6978
6979 IF (t_enc_lines.element_type_id.COUNT > 0) THEN
6980 l_nlines_counter := l_nlines_counter + 1;
6981 t_enc_nlines.assignment_id(l_nlines_counter) := l_asgs.assignment_id(asg_no);
6982 t_enc_nlines.payroll_id(l_nlines_counter) := l_asgs.payroll_id(asg_no);
6983 t_enc_nlines.element_type_id(l_nlines_counter) := t_enc_lines.element_type_id(1);
6984 t_enc_nlines.hierarchy_code(l_nlines_counter) := t_enc_lines.hierarchy_code(1);
6985 t_enc_nlines.gl_ccid(l_nlines_counter) := t_enc_lines.gl_ccid(1);
6986 t_enc_nlines.project_id(l_nlines_counter) := t_enc_lines.project_id(1);
6987 t_enc_nlines.task_id(l_nlines_counter) := t_enc_lines.task_id(1);
6988 t_enc_nlines.award_id(l_nlines_counter) := t_enc_lines.award_id(1);
6989 t_enc_nlines.exp_org_id(l_nlines_counter) := t_enc_lines.exp_org_id(1);
6990 t_enc_nlines.exp_type(l_nlines_counter) := t_enc_lines.exp_type(1);
6991 t_enc_nlines.enc_start_date(l_nlines_counter) := t_enc_lines.enc_start_date(1);
6992 t_enc_nlines.enc_end_date(l_nlines_counter) := t_enc_lines.enc_end_date(1);
6993 FOR recno IN 2..t_enc_lines.element_type_id.COUNT
6994 LOOP
6995 IF (t_enc_lines.element_type_id(recno) = t_enc_lines.element_type_id(recno-1) AND
6996 t_enc_lines.hierarchy_code(recno) = t_enc_lines.hierarchy_code(recno-1) AND
6997 t_enc_lines.gl_ccid(recno) = t_enc_lines.gl_ccid(recno-1) AND
6998 t_enc_lines.project_id(recno) = t_enc_lines.project_id(recno-1) AND
6999 t_enc_lines.task_id(recno) = t_enc_lines.task_id(recno-1) AND
7000 t_enc_lines.award_id(recno) = t_enc_lines.award_id(recno-1) AND
7001 t_enc_lines.exp_org_id(recno) = t_enc_lines.exp_org_id(recno-1) AND
7002 t_enc_lines.exp_type(recno) = t_enc_lines.exp_type(recno-1) AND
7003 t_enc_lines.enc_start_date(recno) -1 <= t_enc_lines.enc_end_date(recno-1)) THEN
7004 t_enc_nlines.enc_end_date(l_nlines_counter) := GREATEST(t_enc_lines.enc_end_date(recno), t_enc_lines.enc_end_date(recno-1));
7005 ELSE
7006 l_nlines_counter := l_nlines_counter + 1;
7007 t_enc_nlines.assignment_id(l_nlines_counter) := l_asgs.assignment_id(asg_no);
7008 t_enc_nlines.payroll_id(l_nlines_counter) := l_asgs.payroll_id(asg_no);
7009 t_enc_nlines.element_type_id(l_nlines_counter) := t_enc_lines.element_type_id(recno);
7010 t_enc_nlines.hierarchy_code(l_nlines_counter) := t_enc_lines.hierarchy_code(recno);
7011 t_enc_nlines.gl_ccid(l_nlines_counter) := t_enc_lines.gl_ccid(recno);
7012 t_enc_nlines.project_id(l_nlines_counter) := t_enc_lines.project_id(recno);
7013 t_enc_nlines.task_id(l_nlines_counter) := t_enc_lines.task_id(recno);
7014 t_enc_nlines.award_id(l_nlines_counter) := t_enc_lines.award_id(recno);
7015 t_enc_nlines.exp_org_id(l_nlines_counter) := t_enc_lines.exp_org_id(recno);
7016 t_enc_nlines.exp_type(l_nlines_counter) := t_enc_lines.exp_type(recno);
7017 t_enc_nlines.enc_start_date(l_nlines_counter) := t_enc_lines.enc_start_date(recno);
7018 t_enc_nlines.enc_end_date(l_nlines_counter) := t_enc_lines.enc_end_date(recno);
7019 END IF;
7020 END LOOP;
7021 END IF;
7022
7023 t_enc_lines.assignment_id.DELETE;
7024 t_enc_lines.payroll_id.DELETE;
7025 t_enc_lines.element_type_id.DELETE;
7026 t_enc_lines.hierarchy_code.DELETE;
7027 t_enc_lines.gl_ccid.DELETE;
7028 t_enc_lines.project_id.DELETE;
7029 t_enc_lines.task_id.DELETE;
7030 t_enc_lines.award_id.DELETE;
7031 t_enc_lines.exp_org_id.DELETE;
7032 t_enc_lines.exp_type.DELETE;
7033 t_enc_lines.enc_start_date.DELETE;
7034 t_enc_lines.enc_end_date.DELETE;
7035 END LOOP;
7036
7037 FOR recno IN 1..t_enc_nlines.element_type_id.COUNT
7038 LOOP
7039 IF (t_enc_nlines.gl_ccid(recno) = -99) THEN
7040 t_enc_nlines.gl_ccid(recno) := NULL;
7041 ELSE
7042 t_enc_nlines.project_id(recno) := NULL;
7043 t_enc_nlines.task_id(recno) := NULL;
7044 t_enc_nlines.award_id(recno) := NULL;
7045 t_enc_nlines.exp_org_id(recno) := NULL;
7046 t_enc_nlines.exp_type(recno) := NULL;
7047 END IF;
7048 END LOOP;
7049
7050 FORALL recno IN 1..t_enc_nlines.element_type_id.COUNT
7051 UPDATE psp_enc_lines_history
7052 SET hierarchy_start_date = t_enc_nlines.enc_start_date(recno),
7053 hierarchy_end_date = t_enc_nlines.enc_end_date(recno)
7054 WHERE assignment_id = t_enc_nlines.assignment_id(recno)
7055 AND payroll_id = t_enc_nlines.payroll_id(recno)
7056 AND change_flag = 'N'
7057 AND enc_element_type_id = t_enc_nlines.element_type_id(recno)
7058 AND hierarchy_code = t_enc_nlines.hierarchy_code(recno)
7059 AND ( ( gl_code_combination_id IS NOT NULL
7060 AND gl_code_combination_id = t_enc_nlines.gl_ccid(recno))
7061 OR ( project_id = t_enc_nlines.project_id(recno)
7062 AND task_id = t_enc_nlines.task_id(recno)
7063 AND award_id = t_enc_nlines.award_id(recno)
7064 AND expenditure_organization_id = t_enc_nlines.exp_org_id(recno)
7065 AND expenditure_type = t_enc_nlines.exp_type(recno)))
7066 AND enc_start_date <= t_enc_nlines.enc_end_date(recno)
7067 AND enc_end_date >= t_enc_nlines.enc_start_date(recno);
7068
7069 p_return_status := fnd_api.g_ret_sts_success;
7070 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving UPDATE_HIERARCHY_DATES');
7071 EXCEPTION
7072 WHEN OTHERS THEN
7073 fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
7074 g_error_api_path := SUBSTR(' UPDATE_HIERARCHY_DATES:'||g_error_api_path,1,230);
7075 fnd_msg_pub.add_exc_msg('PSP_ENC_SUM_TRAN', ' UPDATE_HIERARCHY_DATES');
7076 p_return_status := fnd_api.g_ret_sts_unexp_error;
7077 fnd_file.put_line(fnd_file.log, 'SQLCODE: ' || SQLCODE || ' SQLERRM: ' || SQLERRM);
7078 fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Leaving UPDATE_HIERARCHY_DATES');
7079 END update_hierarchy_dates;
7080
7081 PROCEDURE log_st_warnings IS
7082 l_request_id NUMBER(15);
7083 l_person_id NUMBER(15);
7084 l_organization_id NUMBER(15);
7085 l_assignment_number per_all_assignments_f.assignment_number%TYPE;
7086 l_payroll_name pay_all_payrolls_f.payroll_name%TYPE;
7087 l_full_name per_all_people_f.full_name%TYPE;
7088 l_organization_name hr_organization_units.name%TYPE;
7089 l_element_name pay_element_types_f.element_name%TYPE;
7090 l_project_number pa_projects_all.segment1%TYPE;
7091 l_task_number VARCHAR2(300); -- pa_tasks.task_number%TYPE; -- Bug 16391366 (27/03/2013)
7092 l_award_number gms_awards_all.award_number%TYPE;
7093 l_exp_org_name hr_organization_units.name%TYPE;
7094 l_gl_description VARCHAR2(4000);
7095 l_return_status VARCHAR2(1);
7096
7097 CURSOR asg_number_cur (p_assignment_id IN NUMBER,
7098 p_payroll_id IN NUMBER,
7099 p_effective_date IN DATE) IS
7100 SELECT assignment_number,
7101 person_id,
7102 organization_id
7103 FROM per_all_assignments_f
7104 WHERE assignment_id = p_assignment_id
7105 AND payroll_id = p_payroll_id
7106 AND effective_end_date >= p_effective_date
7107 AND ROWNUM = 1;
7108
7109 CURSOR payroll_name_cur (p_payroll_id IN NUMBER) IS
7110 SELECT payroll_name
7111 FROM pay_all_payrolls_f
7112 WHERE payroll_id = p_payroll_id
7113 AND business_group_id = g_business_group_id
7114 AND gl_set_of_books_id = g_set_of_books_id;
7115
7116 CURSOR person_name_cur (p_effective_date IN DATE) IS
7117 SELECT full_name
7118 FROM per_all_people_f
7119 WHERE person_id = l_person_id
7120 AND effective_end_date >= p_effective_date
7121 AND ROWNUM = 1;
7122
7123 CURSOR org_name_cur IS
7124 SELECT name
7125 FROM hr_organization_units
7126 WHERE organization_id = l_organization_id;
7127
7128 CURSOR project_number_cur (p_project_id IN NUMBER) IS
7129 SELECT SEGMENT1
7130 FROM pa_projects_all
7131 WHERE project_id = p_project_id;
7132
7133 CURSOR award_number_cur (p_award_id IN NUMBER) IS
7134 SELECT award_number
7135 FROM gms_awards_all
7136 WHERE award_id = p_award_id;
7137
7138 CURSOR task_number_cur (p_task_id IN NUMBER) IS
7139 SELECT task_number
7140 FROM pa_tasks_expend_v -- Bug 16391366
7141 WHERE task_id = p_task_id;
7142
7143 CURSOR exp_org_name_cur (p_expenditure_org_id IN NUMBER) IS
7144 SELECT name
7145 FROM hr_organization_units
7146 WHERE organization_id = p_expenditure_org_id;
7147
7148 CURSOR element_name_cur (p_element_type_id IN NUMBER) IS
7149 SELECT element_name
7150 FROM pay_element_types_f
7151 WHERE element_type_id = p_element_type_id
7152 AND ROWNUM = 1;
7153 BEGIN
7154 l_request_id := fnd_global.conc_request_id;
7155
7156 FOR recno IN 1..st_warnings.assignment_id.COUNT
7157 LOOP
7158 OPEN asg_number_cur(st_warnings.assignment_id(recno), st_warnings.payroll_id(recno), st_warnings.start_date(recno));
7159 FETCH asg_number_cur INTO l_assignment_number, l_person_id, l_organization_id;
7160 CLOSE asg_number_cur;
7161
7162 OPEN payroll_name_cur(st_warnings.payroll_id(recno));
7163 FETCH payroll_name_cur INTO l_payroll_name;
7164 CLOSE payroll_name_cur;
7165
7166 OPEN person_name_cur(st_warnings.start_date(recno));
7167 FETCH person_name_cur INTO l_full_name;
7168 CLOSE person_name_cur;
7169
7170 OPEN org_name_cur;
7171 FETCH org_name_cur INTO l_organization_name;
7172 CLOSE org_name_cur;
7173
7174 OPEN element_name_cur(st_warnings.element_type_id(recno));
7175 FETCH element_name_cur INTO l_element_name;
7176 CLOSE element_name_cur;
7177
7178 IF (st_warnings.project_id(recno) IS NOT NULL) THEN
7179 OPEN project_number_cur(st_warnings.project_id(recno));
7180 FETCH project_number_cur INTO l_project_number;
7181 CLOSE project_number_cur;
7182
7183 OPEN award_number_cur(st_warnings.award_id(recno));
7184 FETCH award_number_cur INTO l_award_number;
7185 CLOSE award_number_cur;
7186
7187 OPEN task_number_cur(st_warnings.task_id(recno));
7188 FETCH task_number_cur INTO l_task_number;
7189 CLOSE task_number_cur;
7190
7191 OPEN exp_org_name_cur(st_warnings.exp_org_id(recno));
7192 FETCH exp_org_name_cur INTO l_exp_org_name;
7193 CLOSE exp_org_name_cur;
7194
7195 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_INV_PATEO');
7196 fnd_message.set_token('PJ', l_project_number);
7197 fnd_message.set_token('TK', l_task_number);
7198 fnd_message.set_token('AW', l_award_number);
7199 fnd_message.set_token('EO', l_exp_org_name);
7200 fnd_message.set_token('ET', st_warnings.exp_type(recno));
7201 fnd_message.set_token('START_DATE', st_warnings.start_date(recno));
7202 fnd_message.set_token('END_DATE', st_warnings.end_date(recno));
7203 fnd_message.set_token('EFFECTIVE_DATE', st_warnings.effective_date(recno));
7204 fnd_message.set_token('ERROR_STATUS', st_warnings.error_status(recno));
7205 g_warning_message := fnd_message.get;
7206 ELSE
7207 l_gl_description := psp_general.get_gl_description(g_set_of_books_id, st_warnings.gl_ccid(recno));
7208
7209 fnd_message.set_name('PSP', 'PSP_SUSPENSE_REASON_INV_GL');
7210 fnd_message.set_token('GL', l_gl_description);
7211 fnd_message.set_token('START_DATE', st_warnings.start_date(recno));
7212 fnd_message.set_token('END_DATE', st_warnings.end_date(recno));
7213 fnd_message.set_token('EFFECTIVE_DATE', st_warnings.effective_date(recno));
7214 fnd_message.set_token('ERROR_STATUS', st_warnings.error_status(recno));
7215 g_warning_message := fnd_message.get;
7216 END IF;
7217
7218 psp_general.add_report_error
7219 (p_request_id => l_request_id,
7220 p_message_level => 'W',
7221 p_source_id => st_warnings.assignment_id(recno),
7222 p_source_name => l_assignment_number,
7223 p_parent_source_id => l_person_id,
7224 p_parent_source_name => l_full_name,
7225 p_error_message => g_warning_message,
7226 p_payroll_action_id => g_payroll_action_id,
7227 p_value1 => st_warnings.payroll_id(recno),
7228 p_information1 => l_payroll_name,
7229 p_value2 => l_organization_id,
7230 p_value3 => st_warnings.element_type_id(recno),
7231 p_information2 => l_organization_name,
7232 p_information3 => l_element_name,
7233 p_information4 => fnd_date.date_to_canonical(st_warnings.start_date(recno)),
7234 p_information5 => fnd_date.date_to_canonical(st_warnings.end_date(recno)),
7235 p_information6 => 'SA',
7236 p_return_status => l_return_status);
7237 END LOOP;
7238 END log_st_warnings;
7239
7240 PROCEDURE add_st_warnings(p_start_date IN DATE DEFAULT NULL,
7241 p_end_date IN DATE DEFAULT NULL,
7242 p_assignment_id IN NUMBER DEFAULT NULL,
7243 p_payroll_id IN NUMBER DEFAULT NULL,
7244 p_element_type_id IN NUMBER DEFAULT NULL,
7245 p_gl_ccid IN NUMBER DEFAULT NULL,
7246 p_project_id IN NUMBER DEFAULT NULL,
7247 p_task_id IN NUMBER DEFAULT NULL,
7248 p_award_id IN NUMBER DEFAULT NULL,
7249 p_exp_org_id IN NUMBER DEFAULT NULL,
7250 p_exp_type IN VARCHAR2 DEFAULT NULL,
7251 p_effective_date IN DATE DEFAULT NULL,
7252 p_error_status IN VARCHAR2 DEFAULT NULL) IS
7253 l_warning_ind NUMBER(15);
7254 BEGIN
7255 l_warning_ind := st_warnings.start_date.COUNT;
7256 fnd_file.put_line(fnd_file.log, 'Entering add_st_warnings');
7257 hr_utility.trace('p_start_date: ' || p_start_date || ' p_end_date: ' || p_end_date ||
7258 ' p_assignment_id: ' || p_assignment_id || ' p_payroll_id: ' || p_payroll_id ||
7259 ' p_element_type_id: ' || p_element_type_id || ' p_gl_ccid: ' || p_gl_ccid ||
7260 ' p_project_id: ' || p_project_id || ' p_task_id: ' || p_task_id ||
7261 ' p_award_id:' || p_award_id || ' p_exp_org_id: ' || p_exp_org_id ||
7262 ' p_exp_type: ' || p_exp_type || ' p_effective_date: ' || p_effective_date ||
7263 ' p_error_status: ' || p_error_status);
7264
7265 IF (p_project_id IS NOT NULL) THEN
7266 LOOP
7267 EXIT WHEN l_warning_ind = 0;
7268 EXIT WHEN (( (st_warnings.end_date(l_warning_ind) = (p_start_date -1) OR
7269 ( (st_warnings.end_date(l_warning_ind) >= p_start_date) AND
7270 (st_warnings.start_date(l_warning_ind) <= p_end_date)))) AND
7271 (st_warnings.assignment_id(l_warning_ind) = p_assignment_id) AND
7272 (st_warnings.payroll_id(l_warning_ind) = p_payroll_id) AND
7273 (st_warnings.element_type_id(l_warning_ind) = p_element_type_id) AND
7274 (st_warnings.project_id(l_warning_ind) = p_project_id) AND
7275 (st_warnings.task_id(l_warning_ind) = p_task_id) AND
7276 (st_warnings.award_id(l_warning_ind) = p_award_id) AND
7277 (st_warnings.exp_org_id(l_warning_ind) = p_exp_org_id) AND
7278 (st_warnings.exp_type(l_warning_ind) = p_exp_type) AND
7279 (st_warnings.error_status(l_warning_ind) = p_error_status));
7280 l_warning_ind := l_warning_ind - 1;
7281 END LOOP;
7282 ELSE
7283 LOOP
7284 EXIT WHEN l_warning_ind = 0;
7285 EXIT WHEN (( (st_warnings.end_date(l_warning_ind) = (p_start_date -1) OR
7286 ( (st_warnings.end_date(l_warning_ind) >= p_start_date) AND
7287 (st_warnings.start_date(l_warning_ind) <= p_end_date)))) AND
7288 (st_warnings.gl_ccid(l_warning_ind) = p_gl_ccid) AND
7289 (st_warnings.error_status(l_warning_ind) = p_error_status));
7290 l_warning_ind := l_warning_ind - 1;
7291 END LOOP;
7292 END IF;
7293
7294 IF (l_warning_ind = 0) THEN
7295 l_warning_ind := st_warnings.start_date.COUNT + 1;
7296 st_warnings.start_date(l_warning_ind) := p_start_date;
7297 st_warnings.end_date(l_warning_ind) := p_end_date;
7298 st_warnings.assignment_id(l_warning_ind) := p_assignment_id;
7299 st_warnings.payroll_id(l_warning_ind) := p_payroll_id;
7300 st_warnings.element_type_id(l_warning_ind) := p_element_type_id;
7301 st_warnings.gl_ccid(l_warning_ind) := p_gl_ccid;
7302 st_warnings.project_id(l_warning_ind) := p_project_id;
7303 st_warnings.task_id(l_warning_ind) := p_task_id;
7304 st_warnings.award_id(l_warning_ind) := p_award_id;
7305 st_warnings.exp_org_id(l_warning_ind) := p_exp_org_id;
7306 st_warnings.exp_type(l_warning_ind) := p_exp_type;
7307 st_warnings.effective_date(l_warning_ind) := p_effective_date;
7308 st_warnings.error_status(l_warning_ind) := p_error_status;
7309 ELSE
7310 st_warnings.end_date(l_warning_ind) := p_end_date;
7311 st_warnings.effective_date(l_warning_ind) := p_effective_date;
7312 END IF;
7313
7314 hr_utility.trace('st_warnings.start_date.COUNT: ' || st_warnings.start_date.COUNT);
7315 fnd_file.put_line(fnd_file.log, 'Leaving add_st_warnings');
7316 END add_st_warnings;
7317
7318 PROCEDURE move_rej_lines_to_arch (p_payroll_action_id IN NUMBER) IS
7319 BEGIN
7320 INSERT INTO PSP_ENC_SUMMARY_LINES_ARCH
7321 (enc_summary_line_id, business_group_id, gms_batch_name,
7322 time_period_id, person_id, assignment_id,
7323 effective_date, set_of_books_id, gl_code_combination_id,
7324 project_id, expenditure_organization_id, expenditure_type,
7325 task_id, award_id, summary_amount,
7326 dr_cr_flag, group_id, interface_status,
7327 payroll_id, gl_period_id, gl_project_flag,
7328 attribute_category, attribute1, attribute2,
7329 attribute3, attribute4, attribute5,
7330 attribute6, attribute7, attribute8,
7331 attribute9, attribute10, attribute11,
7332 attribute12, attribute13, attribute14,
7333 attribute15, attribute16, attribute17,
7334 attribute18, attribute19, attribute20,
7335 attribute21, attribute22, attribute23,
7336 attribute24, attribute25, attribute26,
7337 attribute27, attribute28, attribute29,
7338 attribute30, reject_reason_code, enc_control_id,
7339 status_code, last_update_date, last_updated_by,
7340 last_update_login, created_by, creation_date,
7341 suspense_org_account_id, superceded_line_id, gms_posting_override_date,
7342 gl_posting_override_date, expenditure_id, expenditure_item_id,
7343 expenditure_ending_date, interface_id, txn_interface_id,
7344 payroll_action_id, liquidate_request_id, proposed_termination_date,
7345 update_flag)
7346 SELECT enc_summary_line_id, business_group_id, gms_batch_name,
7347 time_period_id, person_id, assignment_id,
7348 effective_date, set_of_books_id, gl_code_combination_id,
7349 project_id, expenditure_organization_id, expenditure_type,
7350 task_id, award_id, summary_amount,
7351 dr_cr_flag, group_id, interface_status,
7352 payroll_id, gl_period_id, gl_project_flag,
7353 attribute_category, attribute1, attribute2,
7354 attribute3, attribute4, attribute5,
7355 attribute6, attribute7, attribute8,
7356 attribute9, attribute10, attribute11,
7357 attribute12, attribute13, attribute14,
7358 attribute15, attribute16, attribute17,
7359 attribute18, attribute19, attribute20,
7360 attribute21, attribute22, attribute23,
7361 attribute24, attribute25, attribute26,
7362 attribute27, attribute28, attribute29,
7363 attribute30, reject_reason_code, enc_control_id,
7364 status_code, last_update_date, last_updated_by,
7365 last_update_login, created_by, creation_date,
7366 suspense_org_account_id, superceded_line_id, gms_posting_override_date,
7367 gl_posting_override_date, expenditure_id, expenditure_item_id,
7368 expenditure_ending_date, interface_id, txn_interface_id,
7369 payroll_action_id, liquidate_request_id, proposed_termination_date,
7370 update_flag
7371 FROM psp_enc_summary_lines
7372 WHERE payroll_action_id = p_payroll_action_id
7373 AND status_code = 'R';
7374
7375 IF (SQL%ROWCOUNT > 0) THEN
7376 fnd_file.put_line(fnd_file.log, 'Moved rejected lines (if any) to archival table as they are no longer useful count '|| sql%rowcount);
7377 END IF;
7378
7379 DELETE psp_enc_summary_lines
7380 WHERE payroll_action_id = p_payroll_action_id
7381 AND status_code = 'R';
7382
7383 fnd_file.put_line(fnd_file.log, 'Deleted rows from psp_enc_summary_lines with rejection code R'||sql%rowcount);
7384
7385 END move_rej_lines_to_arch;
7386 END psp_enc_sum_tran;