[Home] [Help]
PACKAGE BODY: APPS.PJI_FM_PLAN_MAINT_T_PVT
Source
1 PACKAGE BODY PJI_FM_PLAN_MAINT_T_PVT AS
2 /* $Header: PJIPP03B.pls 120.30.12020000.2 2012/08/07 06:33:32 udshanmu ship $ */
3
4
5 g_package_name VARCHAR2(100) := 'PJI_FM_PLAN_MAINT_T_PVT';
6 g_module_name VARCHAR2(100) := 'pji.plsql.PJI_FM_PLAN_MAINT_PVT';
7 P_PA_DEBUG_MODE varchar2(1) := NVL(FND_PROFILE.value('PA_DEBUG_MODE'), 'N');
8
9 g_prorating_format VARCHAR2(30) := 'S';
10 -- S Start date, E End date, D (daily) Period.
11 -- Based on plan version.
12
13 g_currency_conversion_rule VARCHAR2(30) := 'S';
14 -- S Start date, E End date.
15 -- Based on plan version.
16
17 g_global_curr_1_enabled VARCHAR2(30) := 'T';
18 g_global_curr_2_enabled VARCHAR2(30) := 'T';
19
20 g_global1_currency_code VARCHAR2(30) := NULL; -- g_global1_currency_code;
21 g_global2_currency_code VARCHAR2(30) := NULL; -- 'CAD';
22
23 g_global1_currency_mau NUMBER := NULL; -- 0.01;
24 g_global2_currency_mau NUMBER := NULL; -- 0.01;
25
26 g_labor_mau NUMBER := 0.01;
27
28 g_ent_start_period_id NUMBER := NULL;
29 g_ent_start_period_name VARCHAR2(100) := NULL;
30 g_ent_start_date date := NULL;
31 g_ent_END_date date := NULL;
32 g_global_start_date date := NULL;
33
34 g_global_start_J NUMBER := NULL;
35 g_ent_start_J NUMBER := NULL;
36 g_ent_END_J NUMBER := NULL;
37
38 g_worker_id NUMBER := 1; -- NULL;
39 g_default_prg_level NUMBER := 0;
40
41 g_people_resclass_code VARCHAR2(6) := 'PEOPLE';
42 g_equip_resclass_code VARCHAR2(9) := 'EQUIPMENT';
43
44 g_start_str VARCHAR2(1) := 'S';
45 g_end_str VARCHAR2(1) := 'E';
46 g_pa_cal_str VARCHAR2(1) := 'P';
47 g_gl_cal_str VARCHAR2(1) := 'G';
48 -- 'N'ntimeph_str VARCHAR2(1) := 'N';
49 g_ent_cal_str VARCHAR2(1) := 'E';
50
51 g_yes VARCHAR2(1) := 'Y';
52 g_no VARCHAR2(1) := 'N'; -- Same as g_nontimeph_str.
53 g_all VARCHAR2(1) := 'A';
54 g_lowest_level VARCHAR2(1) := 'L';
55 g_top_level VARCHAR2(1) := 'T';
56 g_rolled_up VARCHAR2(1) := 'R';
57
58 g_all_timeph_code VARCHAR2(3) := 'ALL';
59 g_cost_timeph_code VARCHAR2(4) := 'COST';
60 g_rev_timeph_code VARCHAR2(7) := 'REVENUE';
61
62 g_ntp_period_name VARCHAR2(10) := 'XXX';
63
64 ------------------------------------------------------------------
65 ------------------------------------------------------------------
66 -- Helper Apis Specification --
67 ------------------------------------------------------------------
68 ------------------------------------------------------------------
69
70 PROCEDURE UPDATE_TPFG1_CURR_RCDS;
71
72 PROCEDURE CLEANUP_FP_RMAP_FPR;
73
74 PROCEDURE CLEANUP_AC_RMAP_FPR;
75
76 PROCEDURE PRINT_TIME (p_tag IN VARCHAR2);
77
78 PROCEDURE PRINT_NUM_WBSRLPRCDS_INPJP1;
79
80 PROCEDURE INSERT_NTP_CAL_RECORD ( x_max_plnver_id OUT NOCOPY NUMBER );
81
82 PROCEDURE DELETE_NTP_CAL_RECORD ( p_max_plnver_id IN NUMBER );
83
84 ------------------------------------------------------------------
85 ------------------------------------------------------------------
86 -- Helper Apis Implementation --
87 ------------------------------------------------------------------
88 ------------------------------------------------------------------
89
90 PROCEDURE COPY_PRIMARY
91 (
92 p_source_fp_version_ids IN SYSTEM.pa_num_tbl_type := pji_empty_num_tbl
93 , p_dest_fp_version_ids IN SYSTEM.pa_num_tbl_type := pji_empty_num_tbl
94 , p_source_fp_version_status IN SYSTEM.pa_VARCHAR2_30_tbl_type := pji_empty_VARCHAR2_30_tbl
95 , p_dest_fp_version_status IN SYSTEM.pa_VARCHAR2_30_tbl_type := pji_empty_VARCHAR2_30_tbl
96 , p_commit IN VARCHAR2 := 'F'
97 ) IS
98
99 l_dest_plan_type_ids SYSTEM.pa_num_tbl_type := pji_empty_num_tbl;
100 l_dest_project_ids SYSTEM.pa_num_tbl_type := pji_empty_num_tbl;
101 l_src_count NUMBER;
102 l_dest_count NUMBER;
103 l_src_project_ids SYSTEM.pa_num_tbl_type := pji_empty_num_tbl;
104
105 BEGIN
106
107 l_src_count := p_source_fp_version_ids.COUNT;
108 l_dest_count := p_dest_fp_version_ids.COUNT;
109
110 print_time ( ' l_src_count ' || l_src_count || ' l_dest_count ' || l_dest_count );
111
112 IF (l_src_count <> l_dest_count) THEN
113 print_time(' l_src_count <> l_dest_count, returning. ');
114 RETURN;
115 ELSIF (l_src_count = 0 OR l_dest_count = 0) THEN
116 print_time('Either or both of l_src_count or l_src_count are null, returning. ');
117 RETURN;
118 END IF;
119
120 l_dest_project_ids.EXTEND(l_src_count);
121 l_dest_plan_type_ids.EXTEND(l_src_count);
122 l_src_project_ids.EXTEND(l_src_count);
123
124 FOR i IN 1..l_src_count LOOP
125
126 SELECT fin_plan_type_id, project_id
127 INTO l_dest_plan_type_ids(i)
128 ,l_dest_project_ids(i)
129 FROM pa_budget_versions
130 WHERE budget_version_id = p_dest_fp_version_ids(i);
131
132 SELECT project_id
133 INTO l_src_project_ids(i)
134 FROM pa_budget_versions
135 WHERE budget_version_id = p_source_fp_version_ids(i);
136
137 print_time ( ' i = ' || i ) ;
138 print_time ( 'Spvi= ' || p_source_fp_version_ids(i));
139 print_time ( 'Dpvi= ' || p_dest_fp_version_ids(i));
140 print_time ( 'Dpti= ' || l_dest_plan_type_ids(i));
141 print_time ( 'Dpti= ' || l_src_project_ids(i));
142
143 END LOOP;
144
145
146 PJI_FM_PLAN_MAINT.DELETE_ALL_PVT (
147 p_fp_version_ids => p_dest_fp_version_ids
148 , p_commit => 'F');
149 print_time('Deleted the fact data and related metadata for destination plan versions.');
150
151 CLEANUP_INTERIM_TABLES;
152 print_time(' Interim tables cleaned up. 0.01 .. ');
153
154 EXTRACT_FIN_PLAN_VERSIONS(
155 p_fp_version_ids => p_dest_fp_version_ids
156 , p_slice_type => 'PRI'
157 );
158 print_time('Populated ver3 table.');
159
160
161 FORALL I IN 1..p_source_fp_version_ids.COUNT
162 INSERT INTO pji_fp_aggr_pjp1_t
163 (
164 WORKER_ID
165 , PROJECT_ID
166 , PROJECT_ORG_ID
167 , PROJECT_ORGANIZATION_ID
168 , PROJECT_ELEMENT_ID
169 , TIME_ID
170 , PERIOD_TYPE_ID
171 , CALENDAR_TYPE
172 , RBS_AGGR_LEVEL
173 , WBS_ROLLUP_FLAG
174 , PRG_ROLLUP_FLAG
175 , CURR_RECORD_TYPE_ID
176 , CURRENCY_CODE
177 , RBS_ELEMENT_ID
178 , RBS_VERSION_ID
179 , PLAN_VERSION_ID
180 , PLAN_TYPE_ID
181 , RAW_COST
182 , BRDN_COST
183 , REVENUE
184 , BILL_RAW_COST
185 , BILL_BRDN_COST
186 , BILL_LABOR_RAW_COST
187 , BILL_LABOR_BRDN_COST
188 , BILL_LABOR_HRS
189 , EQUIPMENT_RAW_COST
190 , EQUIPMENT_BRDN_COST
191 , CAPITALIZABLE_RAW_COST
192 , CAPITALIZABLE_BRDN_COST
193 , LABOR_RAW_COST
194 , LABOR_BRDN_COST
195 , LABOR_HRS
196 , LABOR_REVENUE
197 , EQUIPMENT_HOURS
198 , BILLABLE_EQUIPMENT_HOURS
199 , SUP_INV_COMMITTED_COST
200 , PO_COMMITTED_COST
201 , PR_COMMITTED_COST
202 , OTH_COMMITTED_COST
203 , ACT_LABOR_HRS
204 , ACT_EQUIP_HRS
205 , ACT_LABOR_BRDN_COST
206 , ACT_EQUIP_BRDN_COST
207 , ACT_BRDN_COST
208 , ACT_RAW_COST
209 , ACT_REVENUE
210 , ACT_LABOR_RAW_COST
211 , ACT_EQUIP_RAW_COST
212 , ETC_LABOR_HRS
213 , ETC_EQUIP_HRS
214 , ETC_LABOR_BRDN_COST
215 , ETC_EQUIP_BRDN_COST
216 , ETC_BRDN_COST
217 , ETC_RAW_COST
218 , ETC_LABOR_RAW_COST
219 , ETC_EQUIP_RAW_COST
220 , CUSTOM1
221 , CUSTOM2
222 , CUSTOM3
223 , CUSTOM4
224 , CUSTOM5
225 , CUSTOM6
226 , CUSTOM7
227 , CUSTOM8
228 , CUSTOM9
229 , CUSTOM10
230 , CUSTOM11
231 , CUSTOM12
232 , CUSTOM13
233 , CUSTOM14
234 , CUSTOM15
235 , PLAN_TYPE_CODE /* 4471527 */
236 )
237 ( SELECT
238 g_worker_id
239 , l_dest_project_ids(i)
240 , rl.PROJECT_ORG_ID
241 , rl.PROJECT_ORGANIZATION_ID
242 , rl.PROJECT_ELEMENT_ID
243 , rl.TIME_ID
244 , rl.PERIOD_TYPE_ID
245 , rl.CALENDAR_TYPE
246 , rl.RBS_AGGR_LEVEL
247 , rl.WBS_ROLLUP_FLAG
248 , rl.PRG_ROLLUP_FLAG
249 , BITAND(rl.CURR_RECORD_TYPE_ID, 28)
250 , rl.CURRENCY_CODE
251 , rl.RBS_ELEMENT_ID
252 , rl.RBS_VERSION_ID
253 , p_dest_fp_version_ids(i)
254 , l_dest_plan_type_ids(i)
255 , rl.RAW_COST
256 , rl.BRDN_COST
257 , rl.REVENUE
258 , rl.BILL_RAW_COST
259 , rl.BILL_BRDN_COST
260 , rl.BILL_LABOR_RAW_COST
261 , rl.BILL_LABOR_BRDN_COST
262 , rl.BILL_LABOR_HRS
263 , rl.EQUIPMENT_RAW_COST
264 , rl.EQUIPMENT_BRDN_COST
265 , rl.CAPITALIZABLE_RAW_COST
266 , rl.CAPITALIZABLE_BRDN_COST
267 , rl.LABOR_RAW_COST
268 , rl.LABOR_BRDN_COST
269 , rl.LABOR_HRS
270 , rl.LABOR_REVENUE
271 , rl.EQUIPMENT_HOURS
272 , rl.BILLABLE_EQUIPMENT_HOURS
273 , rl.SUP_INV_COMMITTED_COST
274 , rl.PO_COMMITTED_COST
275 , rl.PR_COMMITTED_COST
276 , rl.OTH_COMMITTED_COST
277 , rl.ACT_LABOR_HRS
278 , rl.ACT_EQUIP_HRS
279 , rl.ACT_LABOR_BRDN_COST
280 , rl.ACT_EQUIP_BRDN_COST
281 , rl.ACT_BRDN_COST
282 , rl.ACT_RAW_COST
283 , rl.ACT_REVENUE
284 , rl.ACT_LABOR_RAW_COST
285 , rl.ACT_EQUIP_RAW_COST
286 , rl.ETC_LABOR_HRS
287 , rl.ETC_EQUIP_HRS
288 , rl.ETC_LABOR_BRDN_COST
289 , rl.ETC_EQUIP_BRDN_COST
290 , rl.ETC_BRDN_COST
291 , rl.ETC_RAW_COST
292 , rl.ETC_LABOR_RAW_COST
293 , rl.ETC_EQUIP_RAW_COST
294 , rl.CUSTOM1
295 , rl.CUSTOM2
296 , rl.CUSTOM3
297 , rl.CUSTOM4
298 , rl.CUSTOM5
299 , rl.CUSTOM6
300 , rl.CUSTOM7
301 , rl.CUSTOM8
302 , rl.CUSTOM9
303 , rl.CUSTOM10
304 , rl.CUSTOM11
305 , rl.CUSTOM12
306 , rl.CUSTOM13
307 , rl.CUSTOM14
308 , rl.CUSTOM15
309 , rl.PLAN_TYPE_CODE /* 4471527 */
310 FROM
311 pji_fp_xbs_accum_f rl
312 , pji_fm_extr_plnver3_t ver3
313 WHERE 1=1
314 AND rl.project_id = l_src_project_ids(i)
315 AND rl.plan_version_id = p_source_fp_version_ids(i)
316 AND rl.plan_type_code = ver3.plan_type_code /* 4471527 */
317 AND ( (rl.rbs_aggr_level = 'T')
318 OR (rl.rbs_aggr_level = 'L' AND wbs_rollup_flag = 'N' ))
319 AND BITAND(rl.CURR_RECORD_TYPE_ID, 28) > 0
320 AND rl.calendar_type in (ver3.time_phased_type_code, 'A')
321 AND ver3.plan_version_id = p_dest_fp_version_ids(i)
322 );
323
324 print_time('# records in pjp1_t are ' || SQL%ROWCOUNT);
325
326 POPULATE_WBS_HDR; print_time(' 2.1 .. ');
327
328 UPDATE_WBS_HDR; print_time(' 2.11 .. ');
329
330 POPULATE_RBS_HDR; print_time(' 2.2 .. ');
331
332 MERGE_INTO_FP_FACT; print_time(' 2.01 .. ');
333
334 CLEANUP_INTERIM_TABLES; print_time(' 2.3 .. ');
335
336
337 IF (p_commit = 'T') THEN
338 COMMIT;
339 END IF;
340
341 EXCEPTION
342 WHEN OTHERS THEN
343 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
344 p_procedure_name => 'COPY_PRIMARY');
345 RAISE;
346 END;
347
348
349
350 PROCEDURE COPY_PLANS
351 (
352 p_source_fp_version_ids IN SYSTEM.pa_num_tbl_type := pji_empty_num_tbl
353 , p_dest_fp_version_ids IN SYSTEM.pa_num_tbl_type := pji_empty_num_tbl
354 , p_source_fp_version_status IN SYSTEM.pa_VARCHAR2_30_tbl_type := pji_empty_VARCHAR2_30_tbl
355 , p_dest_fp_version_status IN SYSTEM.pa_VARCHAR2_30_tbl_type := pji_empty_VARCHAR2_30_tbl
356 , p_commit IN VARCHAR2 := 'F'
357 ) IS
358
359 l_dest_plan_type_ids SYSTEM.pa_num_tbl_type := pji_empty_num_tbl;
360 l_dest_project_ids SYSTEM.pa_num_tbl_type := pji_empty_num_tbl;
361 l_src_count NUMBER;
362 l_dest_count NUMBER;
363
364 BEGIN
365
366 l_src_count := p_source_fp_version_ids.COUNT;
367 l_dest_count := p_dest_fp_version_ids.COUNT;
368
369 print_time ( ' l_src_count ' || l_src_count || ' l_dest_count ' || l_dest_count );
370
371 IF (l_src_count <> l_dest_count) THEN
372 print_time(' l_src_count <> l_dest_count, returning. ');
373 RETURN;
374 ELSIF (l_src_count = 0 OR l_dest_count = 0) THEN
375 print_time('Either or both of l_src_count or l_src_count are null, returning. ');
376 RETURN;
377 END IF;
378
379 l_dest_project_ids.EXTEND(l_src_count);
380 l_dest_plan_type_ids.EXTEND(l_dest_count);
381
382
383 FOR i IN 1..p_source_fp_version_ids.COUNT LOOP
384 SELECT fin_plan_type_id, project_id
385 INTO l_dest_plan_type_ids(i)
386 , l_dest_project_ids(i)
387 FROM pa_budget_versions
388 WHERE budget_version_id = p_dest_fp_version_ids(i);
389
390 print_time ( ' i = ' || i ) ;
391 print_time ( 'Spvi= ' || p_source_fp_version_ids(i));
392 print_time ( 'Dpvi= ' || p_dest_fp_version_ids(i));
393 print_time ( 'Dpti= ' || l_dest_plan_type_ids(i));
394
395 END LOOP;
396
397 FORALL i IN 1..p_dest_fp_version_ids.COUNT
398 DELETE FROM PJI_FP_XBS_ACCUM_F
399 WHERE plan_version_id = p_dest_fp_version_ids(i)
400 AND project_id = l_dest_project_ids(i);
401
402 FORALL i IN 1..p_dest_fp_version_ids.COUNT
403 DELETE FROM pji_rollup_level_status
404 WHERE plan_version_id = p_dest_fp_version_ids(i);
405
406 CLEANUP_INTERIM_TABLES; print_time(' 2.3 .. ');
407
408 FORALL I IN 1..p_source_fp_version_ids.COUNT
409 INSERT INTO pji_fp_aggr_pjp1_t
410 (
411 worker_id
412 , PROJECT_ID
413 , PROJECT_ORG_ID
414 , PROJECT_ORGANIZATION_ID
415 , PROJECT_ELEMENT_ID
416 , TIME_ID
417 , PERIOD_TYPE_ID
418 , CALENDAR_TYPE
419 , RBS_AGGR_LEVEL
420 , WBS_ROLLUP_FLAG
421 , PRG_ROLLUP_FLAG
422 , CURR_RECORD_TYPE_ID
423 , CURRENCY_CODE
424 , RBS_ELEMENT_ID
425 , RBS_VERSION_ID
426 , PLAN_VERSION_ID
427 , PLAN_TYPE_ID
428 , RAW_COST
429 , BRDN_COST
430 , REVENUE
431 , BILL_RAW_COST
432 , BILL_BRDN_COST
433 , BILL_LABOR_RAW_COST
434 , BILL_LABOR_BRDN_COST
435 , BILL_LABOR_HRS
436 , EQUIPMENT_RAW_COST
437 , EQUIPMENT_BRDN_COST
438 , CAPITALIZABLE_RAW_COST
439 , CAPITALIZABLE_BRDN_COST
440 , LABOR_RAW_COST
441 , LABOR_BRDN_COST
442 , LABOR_HRS
443 , LABOR_REVENUE
444 , EQUIPMENT_HOURS
445 , BILLABLE_EQUIPMENT_HOURS
446 , SUP_INV_COMMITTED_COST
447 , PO_COMMITTED_COST
448 , PR_COMMITTED_COST
449 , OTH_COMMITTED_COST
450 , ACT_LABOR_HRS
451 , ACT_EQUIP_HRS
452 , ACT_LABOR_BRDN_COST
453 , ACT_EQUIP_BRDN_COST
454 , ACT_BRDN_COST
455 , ACT_RAW_COST
456 , ACT_REVENUE
457 , ACT_LABOR_RAW_COST
458 , ACT_EQUIP_RAW_COST
459 , ETC_LABOR_HRS
460 , ETC_EQUIP_HRS
461 , ETC_LABOR_BRDN_COST
462 , ETC_EQUIP_BRDN_COST
463 , ETC_BRDN_COST
464 , ETC_RAW_COST
465 , ETC_LABOR_RAW_COST
466 , ETC_EQUIP_RAW_COST
467 , CUSTOM1
468 , CUSTOM2
469 , CUSTOM3
470 , CUSTOM4
471 , CUSTOM5
472 , CUSTOM6
473 , CUSTOM7
474 , CUSTOM8
475 , CUSTOM9
476 , CUSTOM10
477 , CUSTOM11
478 , CUSTOM12
479 , CUSTOM13
480 , CUSTOM14
481 , CUSTOM15
482 , PLAN_TYPE_CODE /* 4471527 */
483 )
484 (
485 SELECT
486 g_worker_id
487 , rl.PROJECT_ID
488 , rl.PROJECT_ORG_ID
489 , rl.PROJECT_ORGANIZATION_ID
490 , rl.PROJECT_ELEMENT_ID
491 , rl.TIME_ID
492 , rl.PERIOD_TYPE_ID
493 , rl.CALENDAR_TYPE
494 , rl.RBS_AGGR_LEVEL
495 , rl.WBS_ROLLUP_FLAG
496 , rl.PRG_ROLLUP_FLAG
497 , rl.CURR_RECORD_TYPE_ID
498 , rl.CURRENCY_CODE
499 , rl.RBS_ELEMENT_ID
500 , rl.RBS_VERSION_ID
501 , p_dest_fp_version_ids(i)
502 , l_dest_plan_type_ids(i)
503 , rl.RAW_COST
504 , rl.BRDN_COST
505 , rl.REVENUE
506 , rl.BILL_RAW_COST
507 , rl.BILL_BRDN_COST
508 , rl.BILL_LABOR_RAW_COST
509 , rl.BILL_LABOR_BRDN_COST
510 , rl.BILL_LABOR_HRS
511 , rl.EQUIPMENT_RAW_COST
512 , rl.EQUIPMENT_BRDN_COST
513 , rl.CAPITALIZABLE_RAW_COST
514 , rl.CAPITALIZABLE_BRDN_COST
515 , rl.LABOR_RAW_COST
516 , rl.LABOR_BRDN_COST
517 , rl.LABOR_HRS
518 , rl.LABOR_REVENUE
519 , rl.EQUIPMENT_HOURS
520 , rl.BILLABLE_EQUIPMENT_HOURS
521 , rl.SUP_INV_COMMITTED_COST
522 , rl.PO_COMMITTED_COST
523 , rl.PR_COMMITTED_COST
524 , rl.OTH_COMMITTED_COST
525 , rl.ACT_LABOR_HRS
526 , rl.ACT_EQUIP_HRS
527 , rl.ACT_LABOR_BRDN_COST
528 , rl.ACT_EQUIP_BRDN_COST
529 , rl.ACT_BRDN_COST
530 , rl.ACT_RAW_COST
531 , rl.ACT_REVENUE
532 , rl.ACT_LABOR_RAW_COST
533 , rl.ACT_EQUIP_RAW_COST
534 , rl.ETC_LABOR_HRS
535 , rl.ETC_EQUIP_HRS
536 , rl.ETC_LABOR_BRDN_COST
537 , rl.ETC_EQUIP_BRDN_COST
538 , rl.ETC_BRDN_COST
539 , rl.ETC_RAW_COST
540 , rl.ETC_LABOR_RAW_COST
541 , rl.ETC_EQUIP_RAW_COST
542 , rl.CUSTOM1
543 , rl.CUSTOM2
544 , rl.CUSTOM3
545 , rl.CUSTOM4
546 , rl.CUSTOM5
547 , rl.CUSTOM6
548 , rl.CUSTOM7
549 , rl.CUSTOM8
550 , rl.CUSTOM9
551 , rl.CUSTOM10
552 , rl.CUSTOM11
553 , rl.CUSTOM12
554 , rl.CUSTOM13
555 , rl.CUSTOM14
556 , rl.CUSTOM15
557 , rl.PLAN_TYPE_CODE /* 4471527 */
558 FROM
559 pji_fp_xbs_accum_f rl
560 WHERE 1=1
561 AND ( (rl.rbs_aggr_level = g_top_level) OR (rl.rbs_aggr_level = g_lowest_level AND wbs_rollup_flag = 'N' ))
562 AND rl.plan_version_id = p_source_fp_version_ids(i));
563
564 EXTRACT_FIN_PLAN_VERSIONS(
565 p_fp_version_ids => p_dest_fp_version_ids
566 , p_slice_type => 'PRI'
567 ); print_time(' 2.01 .. ');
568
569 POPULATE_WBS_HDR; print_time(' 2.1 .. ');
570
571 UPDATE_WBS_HDR; print_time(' 2.11 .. ');
572
573 POPULATE_RBS_HDR; print_time(' 2.2 .. ');
574
575 MERGE_INTO_FP_FACT;
576
577 CLEANUP_INTERIM_TABLES; print_time(' 2.3 .. ');
578
579
580 IF (p_commit = 'T') THEN
581 COMMIT;
582 END IF;
583
584 EXCEPTION
585 WHEN OTHERS THEN
586 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
587 p_procedure_name => 'COPY_PLANS');
588 RAISE;
589 END;
590
591
592 PROCEDURE COPY_PRIMARY_SINGLE
593 (
594 p_source_plan_ver_id IN NUMBER := NULL
595 , p_target_plan_ver_id IN NUMBER := NULL
596 , p_commit IN VARCHAR2 := 'F') IS
597
598 l_dest_fp_version_ids SYSTEM.pa_num_tbl_type := SYSTEM.pa_num_tbl_type();
599
600 l_dest_plan_type_id NUMBER := NULL;
601 l_dest_project_id NUMBER := NULL;
602
603 BEGIN
604
605 print_time ( ' COPY_PRIMARY_SINGLE api 001 ' || p_source_plan_ver_id || ' ' || p_target_plan_ver_id );
606
607 SELECT fin_plan_type_id, project_id
608 INTO l_dest_plan_type_id, l_dest_project_id
609 FROM pa_budget_versions
610 WHERE budget_version_id = p_target_plan_ver_id;
611
612 DELETE FROM PJI_FP_XBS_ACCUM_F
613 WHERE plan_version_id = p_target_plan_ver_id
614 AND project_id = l_dest_project_id;
615
616 DELETE FROM pji_rollup_level_status
617 WHERE plan_version_id = p_target_plan_ver_id;
618
619 CLEANUP_INTERIM_TABLES;
620 print_time(' 1.9 .. ');
621
622 INSERT INTO pji_fp_aggr_pjp1_t
623 (
624 worker_id
625 , PROJECT_ID
626 , PROJECT_ORG_ID
627 , PROJECT_ORGANIZATION_ID
628 -- , PARTITION_ID
629 , PROJECT_ELEMENT_ID
630 , TIME_ID
631 , PERIOD_TYPE_ID
632 , CALENDAR_TYPE
633 , RBS_AGGR_LEVEL
634 , WBS_ROLLUP_FLAG
635 , PRG_ROLLUP_FLAG
636 , CURR_RECORD_TYPE_ID
637 , CURRENCY_CODE
638 , RBS_ELEMENT_ID
639 , RBS_VERSION_ID
640 , PLAN_VERSION_ID
641 , PLAN_TYPE_ID
642 , RAW_COST
643 , BRDN_COST
644 , REVENUE
645 , BILL_RAW_COST
646 , BILL_BRDN_COST
647 , BILL_LABOR_RAW_COST
648 , BILL_LABOR_BRDN_COST
649 , BILL_LABOR_HRS
650 , EQUIPMENT_RAW_COST
651 , EQUIPMENT_BRDN_COST
652 , CAPITALIZABLE_RAW_COST
653 , CAPITALIZABLE_BRDN_COST
654 , LABOR_RAW_COST
655 , LABOR_BRDN_COST
656 , LABOR_HRS
657 , LABOR_REVENUE
658 , EQUIPMENT_HOURS
659 , BILLABLE_EQUIPMENT_HOURS
660 , SUP_INV_COMMITTED_COST
661 , PO_COMMITTED_COST
662 , PR_COMMITTED_COST
663 , OTH_COMMITTED_COST
664 , ACT_LABOR_HRS
665 , ACT_EQUIP_HRS
666 , ACT_LABOR_BRDN_COST
667 , ACT_EQUIP_BRDN_COST
668 , ACT_BRDN_COST
669 , ACT_RAW_COST
670 , ACT_REVENUE
671 , ACT_LABOR_RAW_COST
672 , ACT_EQUIP_RAW_COST
673 , ETC_LABOR_HRS
674 , ETC_EQUIP_HRS
675 , ETC_LABOR_BRDN_COST
676 , ETC_EQUIP_BRDN_COST
677 , ETC_BRDN_COST
678 , ETC_RAW_COST
679 , ETC_LABOR_RAW_COST
680 , ETC_EQUIP_RAW_COST
681 , CUSTOM1
682 , CUSTOM2
683 , CUSTOM3
684 , CUSTOM4
685 , CUSTOM5
686 , CUSTOM6
687 , CUSTOM7
688 , CUSTOM8
689 , CUSTOM9
690 , CUSTOM10
691 , CUSTOM11
692 , CUSTOM12
693 , CUSTOM13
694 , CUSTOM14
695 , CUSTOM15
696 , PLAN_TYPE_CODE /* 4471527 */
697 )
698 (
699 SELECT
700 g_worker_id
701 , rl.PROJECT_ID
702 , rl.PROJECT_ORG_ID
703 , rl.PROJECT_ORGANIZATION_ID
704 -- , rl.PARTITION_ID
705 , rl.PROJECT_ELEMENT_ID
706 , rl.TIME_ID
707 , rl.PERIOD_TYPE_ID
708 , rl.CALENDAR_TYPE
709 , rl.RBS_AGGR_LEVEL
710 , rl.WBS_ROLLUP_FLAG
711 , rl.PRG_ROLLUP_FLAG
712 , rl.CURR_RECORD_TYPE_ID
713 , rl.CURRENCY_CODE
714 , rl.RBS_ELEMENT_ID
715 , rl.RBS_VERSION_ID
716 , p_target_plan_ver_id
717 , l_dest_plan_type_id plan_type_id
718 , rl.RAW_COST
719 , rl.BRDN_COST
720 , rl.REVENUE
721 , rl.BILL_RAW_COST
722 , rl.BILL_BRDN_COST
723 , rl.BILL_LABOR_RAW_COST
724 , rl.BILL_LABOR_BRDN_COST
725 , rl.BILL_LABOR_HRS
726 , rl.EQUIPMENT_RAW_COST
727 , rl.EQUIPMENT_BRDN_COST
728 , rl.CAPITALIZABLE_RAW_COST
729 , rl.CAPITALIZABLE_BRDN_COST
730 , rl.LABOR_RAW_COST
731 , rl.LABOR_BRDN_COST
732 , rl.LABOR_HRS
733 , rl.LABOR_REVENUE
734 , rl.EQUIPMENT_HOURS
735 , rl.BILLABLE_EQUIPMENT_HOURS
736 , rl.SUP_INV_COMMITTED_COST
737 , rl.PO_COMMITTED_COST
738 , rl.PR_COMMITTED_COST
739 , rl.OTH_COMMITTED_COST
740 , rl.ACT_LABOR_HRS
741 , rl.ACT_EQUIP_HRS
742 , rl.ACT_LABOR_BRDN_COST
743 , rl.ACT_EQUIP_BRDN_COST
744 , rl.ACT_BRDN_COST
745 , rl.ACT_RAW_COST
746 , rl.ACT_REVENUE
747 , rl.ACT_LABOR_RAW_COST
748 , rl.ACT_EQUIP_RAW_COST
749 , rl.ETC_LABOR_HRS
750 , rl.ETC_EQUIP_HRS
751 , rl.ETC_LABOR_BRDN_COST
752 , rl.ETC_EQUIP_BRDN_COST
753 , rl.ETC_BRDN_COST
754 , rl.ETC_RAW_COST
755 , rl.ETC_LABOR_RAW_COST
756 , rl.ETC_EQUIP_RAW_COST
757 , rl.CUSTOM1
758 , rl.CUSTOM2
759 , rl.CUSTOM3
760 , rl.CUSTOM4
761 , rl.CUSTOM5
762 , rl.CUSTOM6
763 , rl.CUSTOM7
764 , rl.CUSTOM8
765 , rl.CUSTOM9
766 , rl.CUSTOM10
767 , rl.CUSTOM11
768 , rl.CUSTOM12
769 , rl.CUSTOM13
770 , rl.CUSTOM14
771 , rl.CUSTOM15
772 , rl.PLAN_TYPE_CODE /* 4471527 */
773 FROM pji_fp_xbs_accum_f rl
774 WHERE 1=1
775 AND rl.plan_version_id = p_source_plan_ver_id
776 AND ( (rl.rbs_aggr_level = g_top_level) OR (rl.rbs_aggr_level = g_lowest_level AND wbs_rollup_flag = 'N' ))
777 ) ;
778
779 print_time ( ' COPY_PRIMARY_SINGLE api 002 ' );
780
781
782 l_dest_fp_version_ids := SYSTEM.pa_num_tbl_type(p_target_plan_ver_id);
783
784 EXTRACT_FIN_PLAN_VERSIONS(
785 p_fp_version_ids => l_dest_fp_version_ids
786 , p_slice_type => 'PRI'
787 ); print_time ( ' COPY_PRIMARY_SINGLE api 003 ' );
788
789 POPULATE_WBS_HDR; print_time(' 2.1 .. ');
790
791 UPDATE_WBS_HDR; print_time(' 2.11 .. ');
792
793 POPULATE_RBS_HDR; print_time(' 2.2 .. ');
794
795 MERGE_INTO_FP_FACT;
796
797 CLEANUP_INTERIM_TABLES; print_time(' 2.3 .. ');
798
799 print_time ( ' COPY_PRIMARY_SINGLE api 004 ' || sql%rowcount);
800
801
802 IF (p_commit = 'T') THEN
803 COMMIT;
804 END IF;
805
806 print_time ( ' COPY_PRIMARY_SINGLE api 005 ');
807
808 EXCEPTION
809 WHEN OTHERS THEN
810 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
811 p_procedure_name => 'COPY_PRIMARY_SINGLE');
812 RAISE;
813 END;
814
815
816 --
817 -- Get the budget versions that need to be extracted INTO a temp table.
818 -- This is to set scope for extraction as well as track time/curr dangling records
819 -- in the case of secondary slice creation.
820 --
821 PROCEDURE EXTRACT_FIN_PLAN_VERS_BULK(
822 p_slice_type IN VARCHAR2 := NULL -- 'PRI' or 'SEC' or 'SECRBS'
823 ) IS
824 BEGIN
825
826 print_time('EXTRACT_FIN_PLAN_VERS_BULK : Begin ' );
827
828 IF ( p_slice_type NOT IN ('PRI', 'SEC', 'SECRBS') ) THEN
829 print_time('EXTRACT_FIN_PLAN_VERSIONS : Invalid slice type. Exitting. ' );
830 RETURN;
831 END IF;
832
833
834 IF ( p_slice_type = 'PRI') THEN
835
836 INSERT INTO PJI_FM_EXTR_PLNVER3_T
837 (
838 PROJECT_ID ,
839 PLAN_VERSION_ID ,
840 WBS_STRUCT_VERSION_ID ,
841 RBS_STRUCT_VERSION_ID ,
842 PLAN_TYPE_CODE , /* 4471527 */
843 PLAN_TYPE_ID ,
844 TIME_PHASED_TYPE_CODE ,
845 TIME_DANGLING_FLAG ,
846 RATE_DANGLING_FLAG ,
847 PROJECT_TYPE_CLASS ,
848 WP_FLAG ,
849 CURRENT_FLAG ,
850 ORIGINAL_FLAG ,
851 CURRENT_ORIGINAL_FLAG ,
852 BASELINED_FLAG ,
853 SECONDARY_RBS_FLAG
854 )
855 SELECT
856 bv.project_id project_id
857 , bv.budget_version_id plan_version_id
858 , DECODE ( NVL(bv.wp_version_flag, 'N')
859 , 'Y', bv.project_structure_version_id
860 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
861 ) wbs_struct_version_id
862 , fpo.rbs_version_id rbs_struct_version_id
863 -- , to_char(fpo.fin_plan_type_id) plan_type_code
864 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
865 , fpo.fin_plan_type_id plan_type_id
866 , DECODE(bv.version_type
867 , g_all_timeph_code, fpo.all_time_phased_code
868 , g_cost_timeph_code, fpo.cost_time_phased_code
869 , g_rev_timeph_code, fpo.revenue_time_phased_code
870 ) time_phased_type_code
871 , NULL time_dangling_flag -- to be used for dangling check.
872 , NULL rate_dangling_flag -- to be used for dangling check.
873 , NULL PROJECT_TYPE_CLASS
874 , NVL(bv.wp_version_flag, 'N') is_wp_flag
875 , bv.current_flag current_flag
876 , bv.original_flag original_flag
877 , bv.current_original_flag current_original_flag
878 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
879 , 'N' SECONDARY_RBS_FLAG
880 FROM
881 pa_budget_versions bv -- @pjdev115 bv
882 , pa_proj_fp_options fpo -- @pjdev115 fpo
883 , pa_projects_all ppa -- @pjdev115 ppa
884 WHERE 1=1
885 AND ppa.project_id = bv.project_id
886 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
887 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
888 AND fpo.project_id = bv.project_id
889 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
890 AND bv.budget_version_id = fpo.fin_plan_version_id
891 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
892 AND bv.version_type IN ( g_all_timeph_code , g_cost_timeph_code , g_rev_timeph_code) -- Eg of other version type is ORG_FORECAST.
893 -- AND bv.pji_summarized_flag = 'N'
894 ;
895
896 ELSIF ( p_slice_type = 'SEC') THEN
897
898 INSERT INTO PJI_FM_EXTR_PLNVER3_T
899 (
900 PROJECT_ID ,
901 PLAN_VERSION_ID ,
902 WBS_STRUCT_VERSION_ID ,
903 RBS_STRUCT_VERSION_ID ,
904 PLAN_TYPE_CODE ,
905 PLAN_TYPE_ID ,
906 TIME_PHASED_TYPE_CODE ,
907 TIME_DANGLING_FLAG ,
908 RATE_DANGLING_FLAG ,
909 PROJECT_TYPE_CLASS ,
910 WP_FLAG ,
911 CURRENT_FLAG ,
912 ORIGINAL_FLAG ,
913 CURRENT_ORIGINAL_FLAG ,
914 BASELINED_FLAG ,
915 SECONDARY_RBS_FLAG
916 )
917 SELECT
918 bv.project_id project_id
919 , bv.budget_version_id plan_version_id
920 , DECODE ( NVL(bv.wp_version_flag, 'N')
921 , 'Y', bv.project_structure_version_id
922 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
923 ) wbs_struct_version_id
924 , fpo.rbs_version_id rbs_struct_version_id
925 -- , to_char(fpo.fin_plan_type_id) plan_type_code
926 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
927 , fpo.fin_plan_type_id plan_type_id
928 , DECODE(bv.version_type
929 , g_all_timeph_code, fpo.all_time_phased_code
930 , g_cost_timeph_code, fpo.cost_time_phased_code
931 , g_rev_timeph_code, fpo.revenue_time_phased_code
932 ) time_phased_type_code
933 , NULL time_dangling_flag -- to be used for dangling check.
934 , NULL rate_dangling_flag -- to be used for dangling check.
935 , NULL PROJECT_TYPE_CLASS
936 , NVL(bv.wp_version_flag, 'N') is_wp_flag
937 , bv.current_flag current_flag
938 , bv.original_flag original_flag
939 , bv.current_original_flag current_original_flag
940 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
941 , 'N' SECONDARY_RBS_FLAG
942 FROM
943 pa_budget_versions bv -- @pjdev115 bv
944 , pa_proj_fp_options fpo -- @pjdev115 fpo -- is there a work plan options table?
945 , pa_projects_all ppa -- @pjdev115 ppa
946 WHERE 1=1
947 AND ppa.project_id = bv.project_id
948 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
949 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
950 AND fpo.project_id = bv.project_id
951 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
952 AND bv.budget_version_id = fpo.fin_plan_version_id
953 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
954 AND bv.version_type IN ( g_all_timeph_code , g_cost_timeph_code , g_rev_timeph_code) -- Eg of other version type is ORG_FORECAST.
955 -- AND bv.pji_summarized_flag = 'P' -- For plan baselining, don't check for summarized flag.
956 -- Temporarily taking this condition out for global currency conversion.
957 AND bv.budget_status_code = 'B'
958 AND NVL(bv.wp_version_flag, 'N') = 'N';
959
960
961 ELSIF ( p_slice_type = 'SECRBS') THEN
962
963 INSERT INTO PJI_FM_EXTR_PLNVER3_T
964 (
965 PROJECT_ID ,
966 PLAN_VERSION_ID ,
967 WBS_STRUCT_VERSION_ID ,
968 RBS_STRUCT_VERSION_ID ,
969 PLAN_TYPE_CODE ,
970 PLAN_TYPE_ID ,
971 TIME_PHASED_TYPE_CODE ,
972 TIME_DANGLING_FLAG ,
973 RATE_DANGLING_FLAG ,
974 PROJECT_TYPE_CLASS ,
975 WP_FLAG ,
976 CURRENT_FLAG ,
977 ORIGINAL_FLAG ,
978 CURRENT_ORIGINAL_FLAG ,
979 BASELINED_FLAG ,
980 SECONDARY_RBS_FLAG
981 )
982 SELECT
983 bv.project_id project_id
984 , bv.budget_version_id plan_version_id
985 , DECODE ( NVL(bv.wp_version_flag, 'N')
986 , 'Y', bv.project_structure_version_id
987 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
988 ) wbs_struct_version_id
989 , rpa.rbs_version_id rbs_struct_version_id
990 -- , fpo.rbs_version_id rbs_struct_version_id
991 -- , to_char(fpo.fin_plan_type_id) plan_type_code
992 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
993 , fpo.fin_plan_type_id plan_type_id
994 , DECODE(bv.version_type
995 , g_all_timeph_code, fpo.all_time_phased_code
996 , g_cost_timeph_code, fpo.cost_time_phased_code
997 , g_rev_timeph_code, fpo.revenue_time_phased_code
998 ) time_phased_type_code
999 , NULL time_dangling_flag -- to be used for dangling check.
1000 , NULL rate_dangling_flag -- to be used for dangling check.
1001 , NULL PROJECT_TYPE_CLASS
1002 , NVL(bv.wp_version_flag, 'N') is_wp_flag
1003 , bv.current_flag current_flag
1004 , bv.original_flag original_flag
1005 , bv.current_original_flag current_original_flag
1006 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
1007 , 'Y' SECONDARY_RBS_FLAG
1008 FROM
1009 pa_budget_versions bv -- @pjdev115 bv
1010 , pa_proj_fp_options fpo -- @pjdev115 fpo -- is there a work plan options table?
1011 , pa_projects_all ppa -- @pjdev115 ppa
1012 , PA_RBS_PRJ_ASSIGNMENTS rpa
1013 WHERE 1=1
1014 AND ppa.project_id = bv.project_id
1015 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
1016 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
1017 AND fpo.project_id = bv.project_id
1018 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
1019 AND bv.budget_version_id = fpo.fin_plan_version_id
1020 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
1021 AND bv.version_type IN ( g_all_timeph_code , g_cost_timeph_code , g_rev_timeph_code) -- Eg of other version type is ORG_FORECAST.
1022 -- AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
1023 -- Temporarily taking this condition out for global currency conversion.
1024 AND bv.budget_status_code = 'B'
1025 AND rpa.project_id = bv.project_id
1026 -- AND DECODE ( rpa.wp_usage_flag, 'Y', 'Y', 'X') = NVL(bv.wp_version_flag, 'N')
1027 -- AND DECODE ( rpa.fp_usage_flag, 'Y', 'N', 'X') = NVL(bv.wp_version_flag, 'N')
1028 AND rpa.assignment_status = 'ACTIVE'
1029 AND rpa.rbs_version_id <> NVL(fpo.rbs_version_id, -1)
1030 AND NVL(bv.wp_version_flag, 'N') = 'N'
1031 AND rpa.reporting_usage_flag = 'Y';
1032
1033 END IF;
1034
1035
1036 print_time('EXTRACT_FIN_PLAN_VERS_BULK : End .. rows processed ' || SQL%ROWCOUNT );
1037
1038 EXCEPTION
1039 WHEN OTHERS THEN
1040 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
1041 p_procedure_name => 'EXTRACT_FIN_PLAN_VERS_BULK');
1042 print_time('EXTRACT_FIN_PLAN_VERS_BULK : Exception: ' || sqlerrm );
1043 RAISE;
1044 END;
1045
1046
1047 --
1048 -- Get the budget versions that need to be extracted INTO a temp table.
1049 -- This is to set scope for extraction as well as track time/curr dangling records
1050 -- in the case of secondary slice creation.
1051 --
1052 PROCEDURE EXTRACT_FIN_PLAN_VERSIONS(
1053 p_fp_version_ids IN SYSTEM.pa_num_tbl_type := pji_empty_num_tbl
1054 , p_slice_type IN VARCHAR2 := NULL -- 'PRI' or 'SEC' or 'SECRBS'
1055 ) IS
1056 l_count NUMBER;
1057 BEGIN
1058
1059 print_time('EXTRACT_FIN_PLAN_VERSIONS : Begin ' );
1060
1061 IF (p_slice_type NOT IN ( 'PRI', 'SEC', 'SECRBS' )) THEN
1062 print_time('EXTRACT_FIN_PLAN_VERSIONS : Invalid slice type. Exitting. ' );
1063 RETURN;
1064 END IF;
1065
1066 print_time('EXTRACT_FIN_PLAN_VERSIONS : l_count is ... ' || p_fp_version_ids.COUNT );
1067
1068 IF (p_slice_type = 'PRI') THEN
1069
1070 FOR I IN 1..p_fp_version_ids.COUNT LOOP
1071
1072 INSERT INTO PJI_FM_EXTR_PLNVER3_T ver3
1073 (
1074 PROJECT_ID ,
1075 PLAN_VERSION_ID ,
1076 WBS_STRUCT_VERSION_ID ,
1077 RBS_STRUCT_VERSION_ID ,
1078 PLAN_TYPE_CODE ,
1079 PLAN_TYPE_ID ,
1080 TIME_PHASED_TYPE_CODE ,
1081 TIME_DANGLING_FLAG ,
1082 RATE_DANGLING_FLAG ,
1083 PROJECT_TYPE_CLASS ,
1084 WP_FLAG ,
1085 CURRENT_FLAG ,
1086 ORIGINAL_FLAG ,
1087 CURRENT_ORIGINAL_FLAG ,
1088 BASELINED_FLAG ,
1089 SECONDARY_RBS_FLAG
1090 )
1091 SELECT
1092 bv.project_id project_id
1093 , bv.budget_version_id plan_version_id
1094 , DECODE ( NVL(bv.wp_version_flag, 'N')
1095 , 'Y', bv.project_structure_version_id
1096 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
1097 ) wbs_struct_version_id
1098 , fpo.rbs_version_id rbs_struct_version_id
1099 -- , to_char(fpo.fin_plan_type_id) plan_type_code
1100 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
1101 , fpo.fin_plan_type_id plan_type_id
1102 , DECODE(bv.version_type
1103 , g_all_timeph_code, fpo.all_time_phased_code
1104 , g_cost_timeph_code, fpo.cost_time_phased_code
1105 , g_rev_timeph_code, fpo.revenue_time_phased_code
1106 ) time_phased_type_code
1107 , NULL time_dangling_flag -- to be used for dangling check.
1108 , NULL rate_dangling_flag -- to be used for dangling check.
1109 , NULL PROJECT_TYPE_CLASS
1110 , NVL(bv.wp_version_flag, 'N') is_wp_flag
1111 , bv.current_flag current_flag
1112 , bv.original_flag original_flag
1113 , bv.current_original_flag current_original_flag
1114 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
1115 , 'N' SECONDARY_RBS_FLAG
1116 FROM
1117 pa_budget_versions bv -- @pjdev115 bv
1118 , pa_proj_fp_options fpo -- @pjdev115 fpo
1119 , pa_projects_all ppa -- @pjdev115 ppa
1120 WHERE 1=1
1121 AND ppa.project_id = bv.project_id
1122 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
1123 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
1124 -- Ask VR: How about WP version.. are they picked up with this condition??
1125 AND fpo.project_id = bv.project_id
1126 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
1127 AND bv.budget_version_id = fpo.fin_plan_version_id
1128 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
1129 AND bv.version_type IN ( g_all_timeph_code , g_cost_timeph_code , g_rev_timeph_code) -- Eg of other version type is ORG_FORECAST.
1130 -- AND bv.pji_summarized_flag = 'N'
1131 AND bv.budget_version_id = p_fp_version_ids(i) ;
1132
1133 END LOOP;
1134
1135 ELSIF (p_slice_type = 'SEC') THEN
1136
1137 FOR I IN 1..p_fp_version_ids.COUNT LOOP
1138
1139 INSERT INTO PJI_FM_EXTR_PLNVER3_T ver3
1140 (
1141 PROJECT_ID ,
1142 PLAN_VERSION_ID ,
1143 WBS_STRUCT_VERSION_ID ,
1144 RBS_STRUCT_VERSION_ID ,
1145 PLAN_TYPE_CODE ,
1146 PLAN_TYPE_ID ,
1147 TIME_PHASED_TYPE_CODE ,
1148 TIME_DANGLING_FLAG ,
1149 RATE_DANGLING_FLAG ,
1150 PROJECT_TYPE_CLASS ,
1151 WP_FLAG ,
1152 CURRENT_FLAG ,
1153 ORIGINAL_FLAG ,
1154 CURRENT_ORIGINAL_FLAG ,
1155 BASELINED_FLAG ,
1156 SECONDARY_RBS_FLAG
1157 )
1158 SELECT
1159 bv.project_id project_id
1160 , bv.budget_version_id plan_version_id
1161 , DECODE ( NVL(bv.wp_version_flag, 'N')
1162 , 'Y', bv.project_structure_version_id
1163 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
1164 ) wbs_struct_version_id
1165 , fpo.rbs_version_id rbs_struct_version_id
1166 -- , to_char(fpo.fin_plan_type_id) plan_type_code
1167 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
1168 , fpo.fin_plan_type_id plan_type_id
1169 , DECODE(bv.version_type
1170 , g_all_timeph_code, fpo.all_time_phased_code
1171 , g_cost_timeph_code, fpo.cost_time_phased_code
1172 , g_rev_timeph_code, fpo.revenue_time_phased_code
1173 ) time_phased_type_code
1174 , NULL time_dangling_flag -- to be used for dangling check.
1175 , NULL rate_dangling_flag -- to be used for dangling check.
1176 , NULL PROJECT_TYPE_CLASS
1177 , NVL(bv.wp_version_flag, 'N') is_wp_flag
1178 , bv.current_flag current_flag
1179 , bv.original_flag original_flag
1180 , bv.current_original_flag current_original_flag
1181 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
1182 , 'N' SECONDARY_RBS_FLAG
1183 FROM
1184 pa_budget_versions bv -- @pjdev115 bv
1185 , pa_proj_fp_options fpo -- @pjdev115 fpo
1186 , pa_projects_all ppa -- @pjdev115 ppa
1187 WHERE 1=1
1188 AND ppa.project_id = bv.project_id
1189 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
1190 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
1191 -- Ask VR: How about WP version.. are they picked up with this condition??
1192 AND fpo.project_id = bv.project_id
1193 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
1194 AND bv.budget_version_id = fpo.fin_plan_version_id
1195 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
1196 AND bv.version_type IN ( g_all_timeph_code , g_cost_timeph_code , g_rev_timeph_code) -- Eg of other version type is ORG_FORECAST.
1197 -- AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
1198 -- Temporarily taking this condition out for global currency conversion.
1199 AND bv.budget_status_code = 'B'
1200 AND NVL(bv.wp_version_flag, 'N') = 'N'
1201 AND bv.budget_version_id = p_fp_version_ids(i) ;
1202
1203 END LOOP;
1204
1205
1206 ELSIF (p_slice_type = 'SECRBS') THEN
1207
1208 FOR I IN 1..p_fp_version_ids.COUNT LOOP
1209
1210 INSERT INTO PJI_FM_EXTR_PLNVER3_T ver3
1211 (
1212 PROJECT_ID ,
1213 PLAN_VERSION_ID ,
1214 WBS_STRUCT_VERSION_ID ,
1215 RBS_STRUCT_VERSION_ID ,
1216 PLAN_TYPE_CODE ,
1217 PLAN_TYPE_ID ,
1218 TIME_PHASED_TYPE_CODE ,
1219 TIME_DANGLING_FLAG ,
1220 RATE_DANGLING_FLAG ,
1221 PROJECT_TYPE_CLASS ,
1222 WP_FLAG ,
1223 CURRENT_FLAG ,
1224 ORIGINAL_FLAG ,
1225 CURRENT_ORIGINAL_FLAG ,
1226 BASELINED_FLAG ,
1227 SECONDARY_RBS_FLAG
1228 )
1229 SELECT
1230 bv.project_id project_id
1231 , bv.budget_version_id plan_version_id
1232 , DECODE ( NVL(bv.wp_version_flag, 'N')
1233 , 'Y', bv.project_structure_version_id
1234 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
1235 ) wbs_struct_version_id
1236 , rpa.rbs_version_id rbs_struct_version_id
1237 -- , to_char(fpo.fin_plan_type_id) plan_type_code
1238 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
1239 , fpo.fin_plan_type_id plan_type_id
1240 , DECODE(bv.version_type
1241 , g_all_timeph_code, fpo.all_time_phased_code
1242 , g_cost_timeph_code, fpo.cost_time_phased_code
1243 , g_rev_timeph_code, fpo.revenue_time_phased_code
1244 ) time_phased_type_code
1245 , NULL time_dangling_flag -- to be used for dangling check.
1246 , NULL rate_dangling_flag -- to be used for dangling check.
1247 , NULL PROJECT_TYPE_CLASS
1248 , NVL(bv.wp_version_flag, 'N') is_wp_flag
1249 , bv.current_flag current_flag
1250 , bv.original_flag original_flag
1251 , bv.current_original_flag current_original_flag
1252 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
1253 , 'Y' SECONDARY_RBS_FLAG
1254 FROM
1255 pa_budget_versions bv -- @pjdev115 bv
1256 , pa_proj_fp_options fpo -- @pjdev115 fpo
1257 , pa_projects_all ppa -- @pjdev115 ppa
1258 , PA_RBS_PRJ_ASSIGNMENTS rpa
1259 WHERE 1=1
1260 AND ppa.project_id = bv.project_id
1261 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
1262 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
1263 -- Ask VR: How about WP version.. are they picked up with this condition??
1264 AND fpo.project_id = bv.project_id
1265 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
1266 AND bv.budget_version_id = fpo.fin_plan_version_id
1267 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
1268 AND bv.version_type IN ( g_all_timeph_code , g_cost_timeph_code , g_rev_timeph_code) -- Eg of other version type is ORG_FORECAST.
1269 -- AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
1270 -- Temporarily taking this condition out for global currency conversion.
1271 AND bv.budget_status_code = 'B'
1272 AND rpa.project_id = bv.project_id
1273 AND rpa.assignment_status = 'ACTIVE'
1274 AND rpa.rbs_version_id <> NVL(fpo.rbs_version_id, -1)
1275 AND rpa.reporting_usage_flag = 'Y'
1276 AND NVL(bv.wp_version_flag, 'N') = 'N'
1277 AND bv.budget_version_id = p_fp_version_ids(i)
1278 AND bv.project_id = rpa.project_id;
1279
1280 END LOOP;
1281
1282 END IF;
1283
1284 print_time('EXTRACT_FIN_PLAN_VERSIONS : l_count is ... ' || SQL%ROWCOUNT );
1285
1286 print_time('EXTRACT_FIN_PLAN_VERSIONS : End' );
1287
1288 EXCEPTION
1289 WHEN OTHERS THEN
1290 print_time('EXTRACT_FIN_PLAN_VERSIONS : Exception: ' || sqlerrm );
1291 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
1292 p_procedure_name => 'EXTRACT_FIN_PLAN_VERSIONS');
1293 RAISE;
1294 END;
1295
1296
1297 --
1298 -- Insert -3, -4 versions into ver3.
1299 --
1300 PROCEDURE EXTRACT_CB_CO_PLAN_VERSIONS IS
1301 BEGIN
1302
1303 INSERT INTO pji_fm_extr_plnver3_t
1304 (
1305 project_id
1306 , plan_version_id
1307 , wbs_struct_version_id
1308 , rbs_struct_version_id
1309 , plan_type_id
1310 , plan_type_code
1311 , time_phased_type_code
1312 , time_dangling_flag
1313 , rate_dangling_flag
1314 , project_type_class
1315 , wp_flag
1316 , current_flag
1317 , original_flag
1318 , current_original_flag
1319 , baselined_flag
1320 , secondary_rbs_flag
1321 , lp_flag
1322 )
1323 SELECT DISTINCT
1324 project_id
1325 , -3 -- plan_version_id
1326 , wbs_struct_version_id
1327 , rbs_struct_version_id
1328 , plan_type_id
1329 , plan_type_code /* 4471527 */
1330 , time_phased_type_code
1331 , NULL -- time dangling flag
1332 , NULL -- rate dangling flag
1333 , NULL -- project type class
1334 , wp_flag -- wp flag
1335 , current_flag -- curr flag
1336 , 'N' -- original_flag -- orig flag
1337 , 'N' -- current_original_flag -- corr orig flag
1338 , baselined_flag -- baselined flag
1339 , secondary_rbs_flag -- sec rbs flag
1340 , lp_flag -- lp flag
1341 FROM pji_fm_extr_plnver3_t
1342 WHERE wp_flag = 'N'
1343 AND baselined_flag = 'Y'
1344 AND current_flag = 'Y'
1345 AND plan_version_id > 0
1346 AND rate_dangling_flag IS NULL
1347 AND time_dangling_flag IS NULL
1348 UNION ALL
1349 SELECT DISTINCT
1350 project_id
1351 , -4 -- plan_version_id
1352 , wbs_struct_version_id
1353 , rbs_struct_version_id
1354 , plan_type_id
1355 , plan_type_code /* 4471527 */
1356 , time_phased_type_code
1357 , NULL -- time dangling flag
1358 , NULL -- rate dangling flag
1359 , NULL -- project type class
1360 , wp_flag -- wp flag
1361 , current_flag -- curr flag
1362 , original_flag -- orig flag
1363 , current_original_flag -- corr orig flag
1364 , 'N' -- baselined_flag -- baselined flag
1365 , secondary_rbs_flag -- sec rbs flag
1366 , lp_flag -- lp flag
1367 FROM pji_fm_extr_plnver3_t
1368 WHERE wp_flag = 'N'
1369 AND baselined_flag = 'Y'
1370 AND current_original_flag = 'Y'
1371 AND plan_version_id > 0
1372 AND rate_dangling_flag IS NULL
1373 AND time_dangling_flag IS NULL;
1374
1375 print_time ( ' # -3, -4 records inserted into ver3 is ' || SQL%ROWCOUNT );
1376
1377 END;
1378
1379
1380 --
1381 -- Extract the period level plan amounts for PA/GL/non time phased entries from budget lines
1382 -- for the primary RBS for this plan version into pji_fp_aggr_pjp1_t.
1383 -- EXTRACT_PLAN_AMOUNTS_PRIRBS
1384 PROCEDURE EXTRACT_PLAN_AMOUNTS_PRIRBS IS
1385 l_count NUMBER;
1386 l_max_plnver_id NUMBER := NULL;
1387 /*l_per_analysis_flag varchar2(2); /* Added for bug 8708651
1388 Commented for bug 9048716 */
1389 l_plan_version_id SYSTEM.pa_num_tbl_type;
1390 l_resource_list_id SYSTEM.pa_num_tbl_type;
1391
1392 CURSOR res_list IS
1393 SELECT /*+ ordered */ b.plan_version_id, decode(b.plan_type_code, 'C', a.cost_resource_list_id,
1394 'R', a.revenue_resource_list_id,
1395 'A', a.all_resource_list_id) resource_list_id
1396 FROM PJI_FM_EXTR_PLNVER3_T b, pa_proj_fp_options a
1397 WHERE b.project_id = a.project_id
1398 AND b.PLAN_TYPE_ID = a.FIN_PLAN_TYPE_ID
1399 AND b.plan_version_id = a.fin_plan_version_id;
1400 l_count1 NUMBER;
1401 BEGIN
1402
1403 print_time('EXTRACT_PLAN_AMOUNTS_PRIRBS : Begin' );
1404 print_time('EXTRACT_PLAN_AMOUNTS_PRIRBS : Begin worker id is ... ' || 1);
1405
1406 IF P_PA_DEBUG_MODE = 'Y' THEN
1407 pa_debug.write('EXTRACT_PLAN_AMOUNTS_PRIRBS: ' || g_module_name,'Inside EXTRACT_PLAN_AMOUNTS_PRIRBS' ,1);
1408 END IF;
1409 /* Added for bug 8708651
1410 l_per_analysis_flag := PJI_UTILS.GET_SETUP_PARAMETER('PER_ANALYSIS_FLAG');
1411 Commented for bug 9048716 */
1412
1413 INSERT_NTP_CAL_RECORD ( x_max_plnver_id => l_max_plnver_id );
1414
1415 IF (l_max_plnver_id IS NULL) THEN
1416 RETURN;
1417 END IF;
1418
1419 -- cbs change
1420 OPEN res_list;
1421 FETCH res_list BULK COLLECT INTO l_plan_version_id, l_resource_list_id;
1422 CLOSE res_list;
1423
1424 FORALL i IN l_plan_version_id.FIRST..l_plan_version_id.LAST
1425 UPDATE PJI_FM_EXTR_PLNVER3_T t
1426 SET worker_id = -99
1427 WHERE plan_version_id = l_plan_version_id(i)
1428 AND EXISTS (SELECT 1
1429 FROM pa_resource_lists_all_bg
1430 WHERE resource_list_id = l_resource_list_id(i)
1431 AND nvl(resource_class_flag,'Y') = 'N');
1432
1433 -- End cbs change
1434
1435
1436 INSERT INTO PJI_FP_AGGR_PJP1_T
1437 (
1438 WORKER_ID
1439 , PROJECT_ID
1440 , PROJECT_ORG_ID
1441 , PROJECT_ORGANIZATION_ID
1442 , PROJECT_ELEMENT_ID
1443 , TIME_ID
1444 , PERIOD_TYPE_ID
1445 , CALENDAR_TYPE
1446 , RBS_AGGR_LEVEL
1447 , WBS_ROLLUP_FLAG
1448 , PRG_ROLLUP_FLAG
1449 , CURR_RECORD_TYPE_ID
1450 , CURRENCY_CODE
1451 , RBS_ELEMENT_ID
1452 , RBS_VERSION_ID
1453 , PLAN_VERSION_ID
1454 , PLAN_TYPE_ID
1455 , RAW_COST
1456 , BRDN_COST
1457 , REVENUE
1458 , BILL_RAW_COST
1459 , BILL_BRDN_COST
1460 , BILL_LABOR_RAW_COST
1461 , BILL_LABOR_BRDN_COST
1462 , BILL_LABOR_HRS
1463 , EQUIPMENT_RAW_COST
1464 , EQUIPMENT_BRDN_COST
1465 , CAPITALIZABLE_RAW_COST
1466 , CAPITALIZABLE_BRDN_COST
1467 , LABOR_RAW_COST
1468 , LABOR_BRDN_COST
1469 , LABOR_HRS
1470 , LABOR_REVENUE
1471 , EQUIPMENT_HOURS
1472 , BILLABLE_EQUIPMENT_HOURS
1473 , SUP_INV_COMMITTED_COST
1474 , PO_COMMITTED_COST
1475 , PR_COMMITTED_COST
1476 , OTH_COMMITTED_COST
1477 , ACT_LABOR_HRS
1478 , ACT_EQUIP_HRS
1479 , ACT_LABOR_BRDN_COST
1480 , ACT_EQUIP_BRDN_COST
1481 , ACT_BRDN_COST
1482 , ACT_RAW_COST
1483 , ACT_REVENUE
1484 , ACT_LABOR_RAW_COST
1485 , ACT_EQUIP_RAW_COST
1486 , ETC_LABOR_HRS
1487 , ETC_EQUIP_HRS
1488 , ETC_LABOR_BRDN_COST
1489 , ETC_EQUIP_BRDN_COST
1490 , ETC_BRDN_COST
1491 , ETC_RAW_COST
1492 , ETC_LABOR_RAW_COST
1493 , ETC_EQUIP_RAW_COST
1494 , CUSTOM1
1495 , CUSTOM2
1496 , CUSTOM3
1497 , CUSTOM4
1498 , CUSTOM5
1499 , CUSTOM6
1500 , CUSTOM7
1501 , CUSTOM8
1502 , CUSTOM9
1503 , CUSTOM10
1504 , CUSTOM11
1505 , CUSTOM12
1506 , CUSTOM13
1507 , CUSTOM14
1508 , CUSTOM15
1509 , LINE_TYPE
1510 , RATE_DANGLING_FLAG
1511 , TIME_DANGLING_FLAG
1512 -- , START_DATE
1513 -- , END_DATE
1514 , PRG_LEVEL
1515 , PLAN_TYPE_CODE /* 4471527 */
1516 )
1517 SELECT
1518 g_worker_id WORKER_ID
1519 , plr.PROJECT_ID
1520 , plr.PROJECT_ORG_ID
1521 , plr.project_ORGANIZATION_ID
1522 , plr.WBS_ELEMENT_ID
1523 , decode(vers.time_phased_type_code
1524 , 'N', -1
1525 , pji_time.cal_period_id) time_id /* Modified for bug 9048716 */
1526 , decode(vers.time_phased_type_code
1527 , g_pa_cal_str, 32
1528 , g_gl_cal_str, 32
1529 , 'N', 2048
1530 , -1) /* Modified for bug 9048716 */
1531 , decode(vers.time_phased_type_code
1532 , g_pa_cal_str, g_pa_cal_str
1533 , g_gl_cal_str, g_gl_cal_str
1534 , 'N', g_all
1535 , 'X') /* Modified for bug 9048716 */
1536 , g_lowest_level RBS_AGGR_LEVEL
1537 , 'N' WBS_ROLLUP_FLAG
1538 , 'N' PRG_ROLLUP_FLAG
1539 , plr.CURR_RECORD_TYPE -- curr code missing.
1540 , plr.currency_code
1541 , plr.RBS_ELEMENT_ID
1542 , plr.RBS_STRUCT_VERSION_ID
1543 , plr.BUDGET_VERSION_ID
1544 , plr.plan_type_id
1545 , SUM(plr.RAW_COST)
1546 , SUM(plr.BRDN_COST)
1547 , SUM(plr.REVENUE)
1548 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) BILL_RAW_COST
1549 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) BILL_BRDN_COST
1550 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_people_resclass_code, plr.raw_cost, 0 ) ) BILL_LABOR_RAW_COST
1551 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_people_resclass_code , plr.BRDN_COST, 0 ) ) BILL_LABOR_BRDN_COST
1552 -- , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'Y' || g_people_resclass_code, plr.quantity, 0 ) ) BILL_LABOR_HRS -- bug 6039785
1553 , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'Y' || g_people_resclass_code,
1554 DECODE ( plr.billable_flag,'Y',plr.quantity,0) , 0 ) ) BILL_LABOR_HRS -- bug 6039785
1555 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code , plr.raw_cost, 0 ) ) EQUIPMENT_RAW_COST
1556 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code , plr.BRDN_COST, 0 ) ) EQUIPMENT_BRDN_COST
1557 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) CAPITALIZABLE_RAW_COST
1558 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) CAPITALIZABLE_BRDN_COST
1559 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.raw_cost, 0 ) ) LABOR_RAW_COST
1560 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.BRDN_COST, 0 ) ) LABOR_BRDN_COST
1561 /* , SUM ( DECODE ( plr.resource_class, g_people_resclass_code,
1562 DECODE ( vers.wp_flag, 'N',
1563 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
1564 plr.quantity),
1565 0 ) ) labor_hrs */ -- bug 6039785
1566 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, DECODE(plr.billable_flag,'Y',
1567 DECODE ( vers.wp_flag, 'N',
1568 DECODE ( plr.billable_flag, 'Y', plr.quantity, 0 ),
1569 plr.quantity),
1570 0 ),
1571 0 ) ) labor_hrs -- bug 6039785
1572 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.revenue, 0 ) ) LABOR_REVENUE
1573 /* , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code,
1574 DECODE ( vers.wp_flag, 'N',
1575 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
1576 plr.quantity),
1577
1578 0 ) ) EQUIPMENT_HOURS */ -- bug 6039785
1579 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code, DECODE(plr.billable_flag,'Y',
1580 DECODE ( vers.wp_flag, 'N',
1581 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
1582 plr.quantity),
1583 0 ),
1584 0 ) ) EQUIPMENT_HOURS -- bug 6039785
1585 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YEQUIPMENT', plr.quantity, 0 ) ) BILLABLE_EQUIPMENT_HOURS */ -- bug 6039785
1586 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YEQUIPMENT',
1587 DECODE ( plr.billable_flag,'Y',plr.quantity,0), 0 ) ) BILLABLE_EQUIPMENT_HOURS -- bug 6039785
1588 , NULL SUP_INV_COMMITTED_COST
1589 , NULL PO_COMMITTED_COST
1590 , NULL PR_COMMITTED_COST
1591 , NULL OTH_COMMITTED_COST
1592 /* , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
1593 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
1594 0 ) ) ) ACT_LABOR_HRS */ -- bug 6039785
1595 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
1596 DECODE (plr.billable_flag ,'Y',
1597 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
1598 0 ),
1599 0 ) ) ) ACT_LABOR_HRS -- bug 6039785
1600 /* , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
1601 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
1602 0 ) ) ) ACT_EQUIP_HOURS */ -- bug 6039785
1603 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
1604 DECODE (plr.billable_flag ,'Y',
1605 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
1606 0 ),
1607 0 ) ) ) ACT_EQUIP_HOURS -- bug 6039785
1608 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.actual_BRDN_COST, 0 ) ) ) ACT_LABOR_BRDN_COST
1609 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.actual_BRDN_COST, 0 ) ) ) ACT_EQUIPMENT_BRDN_COST
1610 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, plr.actual_brdn_cost ) ) ACT_BRDN_COST
1611 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, plr.actual_raw_cost ) ) ACT_RAW_COST
1612 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, plr.actual_revenue ) ) ACT_REVENUE
1613 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.actual_RAW_COST, 0 ) ) ) ACT_LABOR_RAW_COST
1614 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.actual_RAW_COST, 0 ) ) ) ACT_EQUIPMENT_RAW_COST
1615 /* , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
1616 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
1617 0 ) ) ) ETC_LABOR_HRS */ -- bug 6039785
1618 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
1619 DECODE (plr.billable_flag ,'Y',
1620 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
1621 0 ),
1622 0 ) ) ) ETC_LABOR_HRS -- bug 6039785
1623 /* , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
1624 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
1625 0 ) ) ) ETC_EQUIP_HOURS */ -- bug 6039785
1626 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
1627 DECODE (plr.billable_flag ,'Y',
1628 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
1629 0 ),
1630 0 ) ) ) ETC_EQUIP_HOURS -- bug 6039785
1631 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.etc_BRDN_COST, 0 ) ) ) ETC_LABOR_BRDN_COST
1632 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.etc_BRDN_COST, 0 ) ) ) ETC_EQUIP_BRDN_COST
1633 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, plr.etc_brdn_cost ) ) ETC_BRDN_COST
1634 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, plr.etc_raw_cost ) ) ETC_RAW_COST
1635 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.etc_raw_COST, 0 ) ) ) ETC_LABOR_raw_COST
1636 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.etc_raw_COST, 0 ) ) ) ETC_EQUIP_raw_COST
1637 , NULL CUSTOM1
1638 , NULL CUSTOM2
1639 , NULL CUSTOM3
1640 , NULL CUSTOM4
1641 , NULL CUSTOM5
1642 , NULL CUSTOM6
1643 , NULL CUSTOM7
1644 , NULL CUSTOM8
1645 , NULL CUSTOM9
1646 , NULL CUSTOM10
1647 , NULL CUSTOM11
1648 , NULL CUSTOM12
1649 , NULL CUSTOM13
1650 , NULL CUSTOM14
1651 , NULL CUSTOM15
1652 , DECODE(vers.time_phased_type_code, g_pa_cal_str, 'OF', g_gl_cal_str, 'OF', 'N', 'NTP', 'X') -- LINE_TYPE
1653 , NULL time_dangling_flag
1654 , NULL rate_dangling_flag
1655 -- , plr.start_date
1656 -- , plr.end_date
1657 , g_default_prg_level prg_level
1658 , plr.plan_type_code /* 4471527 */
1659 FROM
1660 ( ----- First inline view plr .............
1661 select
1662 collapse_bl.PROJECT_ID -- , 1 partition_id
1663 , collapse_bl.WBS_ELEMENT_ID -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
1664 , SUM(collapse_bl.CURR_RECORD_TYPE_ID) CURR_RECORD_TYPE
1665 , collapse_bl.RBS_ELEMENT_ID
1666 , collapse_bl.RBS_STRUCT_VERSION_ID
1667 , collapse_bl.plan_type_id
1668 , collapse_bl.BUDGET_VERSION_ID
1669 , collapse_bl.PROJECT_ORGANIZATION_ID
1670 , collapse_bl.PROJECT_ORG_ID
1671 , collapse_bl.RESOURCE_ASSIGNMENT_ID
1672 , collapse_bl.BILLABLE_FLAG
1673 , collapse_bl.RESOURCE_CLASS -- , CALENDAR_TYPE -- , CALENDAR_ID
1674 , collapse_bl.TIME_PHASED_TYPE_CODE
1675 , collapse_bl.CURRENCY_CODE
1676 , max(collapse_bl.raw_cost) raw_cost
1677 , max(collapse_bl.BRDN_COST) BRDN_COST
1678 , max(collapse_bl.revenue) revenue
1679 , max(collapse_bl.actual_raw_cost) actual_raw_cost
1680 , max(collapse_bl.actual_BRDN_COST) actual_BRDN_COST
1681 , max(collapse_bl.actual_revenue) actual_revenue
1682 , max(collapse_bl.etc_raw_cost) etc_raw_cost
1683 , max(collapse_bl.etc_BRDN_COST) etc_BRDN_COST
1684 , max(collapse_bl.etc_revenue) etc_revenue
1685 , max(collapse_bl.quantity) quantity
1686 , max(collapse_bl.actual_quantity) actual_quantity
1687 , max(collapse_bl.etc_quantity) etc_quantity
1688 , collapse_bl.start_date start_date
1689 , collapse_bl.end_date end_date
1690 , collapse_bl.period_name period_name -- , TRACK_AS_LABOR_FLAG track_as_labor_flag
1691 , collapse_bl.row_id
1692 , collapse_bl.plan_type_code plan_type_code /* 4471527 */
1693 from
1694 ( ----- Second inline view 'collapse_bl' begin .............
1695 select
1696 spread_bl.row_id row_id
1697 , spread_bl.PROJECT_ID
1698 , spread_bl.BUDGET_VERSION_ID
1699 , spread_bl.RESOURCE_ASSIGNMENT_ID
1700 , spread_bl.WBS_ELEMENT_ID
1701 , spread_bl.RBS_ELEMENT_ID
1702 , spread_bl.WBS_STRUCT_VERSION_ID
1703 , spread_bl.RBS_STRUCT_VERSION_ID
1704 , spread_bl.plan_type_id
1705 , spread_bl.BILLABLE_FLAG
1706 , spread_bl.RESOURCE_CLASS -- , spread_bl.CALENDAR_TYPE -- , pji_time.CALENDAR_ID
1707 , spread_bl.PROJECT_ORGANIZATION_ID
1708 , spread_bl.PROJECT_ORG_ID
1709 , spread_bl.TIME_PHASED_TYPE_CODE
1710 , DECODE( invert.INVERT_ID
1711 , 4, spread_bl.func_CURRENCY_CODE
1712 , 8, spread_bl.PRJ_CURRENCY_CODE
1713 , 16, spread_bl.TXN_CURRENCY_CODE ) CURRENCY_CODE
1714 , invert.INVERT_ID CURR_RECORD_TYPE_ID
1715 , DECODE ( invert.INVERT_ID
1716 , 4, spread_bl.func_raw_cost
1717 , 8, spread_bl.PRJ_raw_cost
1718 , 16, spread_bl.TXN_raw_cost) raw_cost
1719 , DECODE ( invert.INVERT_ID
1720 , 4, spread_bl.func_BRDN_COST
1721 , 8, spread_bl.PRJ_BRDN_COST
1722 , 16, spread_bl.TXN_BRDN_COST ) BRDN_COST
1723 , DECODE ( invert.INVERT_ID
1724 , 4, spread_bl.func_revenue
1725 , 8, spread_bl.PRJ_revenue
1726 , 16, spread_bl.TXN_revenue ) revenue
1727 , DECODE ( invert.INVERT_ID
1728 , 4, spread_bl.func_actual_raw_cost
1729 , 8, spread_bl.prj_actual_raw_cost
1730 , 16, spread_bl.txn_actual_raw_cost ) actual_raw_cost
1731 , DECODE ( invert.INVERT_ID
1732 , 4, spread_bl.func_actual_brdn_cost
1733 , 8, spread_bl.prj_actual_brdn_cost
1734 , 16, spread_bl.txn_actual_brdn_cost ) actual_brdn_cost
1735 , DECODE ( invert.INVERT_ID
1736 , 4, spread_bl.func_actual_revenue
1737 , 8, spread_bl.prj_actual_revenue
1738 , 16, spread_bl.txn_actual_revenue ) actual_revenue
1739 , DECODE ( invert.INVERT_ID
1740 , 4, spread_bl.func_etc_raw_cost
1741 , 8, spread_bl.prj_etc_raw_cost
1742 , 16, spread_bl.txn_etc_raw_cost ) etc_raw_cost
1743 , DECODE ( invert.INVERT_ID
1744 , 4, spread_bl.func_etc_brdn_cost
1745 , 8, spread_bl.prj_etc_brdn_cost
1746 , 16, spread_bl.txn_etc_brdn_cost ) etc_brdn_cost
1747 , DECODE ( invert.INVERT_ID
1748 , 4, spread_bl.func_etc_revenue
1749 , 8, spread_bl.prj_etc_revenue
1750 , 16, spread_bl.txn_etc_revenue ) etc_revenue
1751 , spread_bl.quantity quantity
1752 , spread_bl.actual_quantity actual_quantity
1753 , spread_bl.etc_quantity etc_quantity
1754 , spread_bl.start_date start_date
1755 , spread_bl.end_date end_date
1756 , spread_bl.period_name period_name
1757 -- , spread_bl.TRACK_AS_LABOR_FLAG track_as_labor_flag
1758 , spread_bl.plan_type_code /* 4471527 */
1759 from
1760 ( ----- Third inline view 'spread_bl' .............
1761 -- Added HINT For bug 3828698
1762 SELECT /*+ LEADING(VER) USE_NL(VER,PPA,PEVS,RA,BL)*/
1763 ra.project_id
1764 , bl.rowid row_id
1765 , ra.budget_version_id
1766 , bl.resource_asSIGNment_id
1767 , DECODE(ra.task_id, 0, pevs.proj_element_id, ra.task_id) wbs_element_id
1768 , NVL(ra.rbs_element_id, -1) rbs_element_id
1769 , ver.wbs_struct_version_id wbs_struct_version_id
1770 , NVL(ver.rbs_struct_version_id, -1) rbs_struct_version_id
1771 , ver.plan_type_id plan_type_id
1772 , ra.rate_based_flag billable_flag
1773 -- cbs change
1774 , decode(nvl(ver.worker_id, -1), -99, '1'||ra.resource_class_code, ra.resource_class_code) resource_class
1775 -- End cbs change
1776 , bl.txn_currency_code txn_currency_code
1777 , bl.txn_raw_cost txn_raw_cost
1778 , bl.txn_burdened_COST txn_brdn_COST
1779 , bl.txn_revenue txn_revenue
1780 , DECODE(ver.wp_flag, 'N', bl.txn_init_raw_cost, NULL) txn_actual_raw_cost -- new
1781 , DECODE(ver.wp_flag, 'N', bl.txn_init_burdened_cost, NULL) txn_actual_brdn_cost -- new
1782 , DECODE(ver.wp_flag, 'N', bl.txn_init_revenue, NULL) txn_actual_revenue -- new
1783 , DECODE(ver.wp_flag, 'N', (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0)), NULL) txn_etc_raw_cost -- new
1784 , DECODE(ver.wp_flag, 'N', (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0)), NULL) txn_etc_brdn_cost -- new
1785 , DECODE(ver.wp_flag, 'N', (bl.txn_revenue - NVL(bl.txn_init_revenue, 0)), NULL) txn_etc_revenue -- new
1786 , bl.project_currency_code prj_currency_code
1787 , bl.project_raw_cost prj_raw_cost
1788 , bl.project_burdened_COST prj_BRDN_COST
1789 , bl.project_revenue prj_revenue
1790 , DECODE(ver.wp_flag, 'N', bl.project_init_raw_cost, NULL) prj_actual_raw_cost -- new
1791 , DECODE(ver.wp_flag, 'N', bl.project_init_burdened_cost, NULL) prj_actual_brdn_cost -- new
1792 , DECODE(ver.wp_flag, 'N', bl.project_init_revenue, NULL) prj_actual_revenue -- new
1793 , DECODE(ver.wp_flag, 'N', (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0)), NULL) prj_etc_raw_cost -- new
1794 , DECODE(ver.wp_flag, 'N', (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0)), NULL) prj_etc_brdn_cost -- new
1795 , DECODE(ver.wp_flag, 'N', (bl.project_revenue - NVL(bl.project_init_revenue, 0)), NULL) prj_etc_revenue -- new
1796 , bl.projfunc_currency_code func_currency_code
1797 , bl.raw_cost func_raw_cost
1798 , bl.burdened_COST func_BRDN_COST
1799 , bl.revenue func_revenue
1800 , DECODE(ver.wp_flag, 'N', bl.init_raw_cost , NULL) func_actual_raw_cost -- new
1801 , DECODE(ver.wp_flag, 'N', bl.init_burdened_cost , NULL) func_actual_brdn_cost -- new
1802 , DECODE(ver.wp_flag, 'N', bl.init_revenue , NULL) func_actual_revenue -- new
1803 , DECODE(ver.wp_flag, 'N', (bl.raw_cost - NVL(bl.init_raw_cost, 0)), NULL) func_etc_raw_cost -- new
1804 , DECODE(ver.wp_flag, 'N', (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)), NULL) func_etc_brdn_cost -- new
1805 , DECODE(ver.wp_flag, 'N', (bl.revenue - NVL(bl.init_revenue, 0)), NULL) func_etc_revenue -- new
1806 , g_global1_currency_code glb1_currency_code
1807 , NULL glb1_raw_cost
1808 , NULL glb1_BRDN_COST
1809 , NULL glb1_revenue
1810 , g_global2_currency_code glb2_currency_code
1811 , NULL glb2_raw_cost
1812 , NULL glb1_BRDN_COST
1813 , NULL glb1_revenue
1814 , bl.quantity quantity
1815 , DECODE(ver.wp_flag, 'N', bl.init_quantity, NULL) actual_quantity -- new
1816 , DECODE(ver.wp_flag, 'N', (bl.quantity - NVL(bl.init_quantity, 0)), NULL) etc_quantity -- new
1817 , DECODE(ver.time_phased_type_code, 'N', bl.start_date, NULL) start_date
1818 , DECODE(ver.time_phased_type_code, 'N', bl.end_date, NULL) end_date
1819 , nvl(bl.period_name,g_ntp_period_name) period_name /* Added nvl for 4174366*/
1820 , ver.time_phased_type_code time_phased_type_code
1821 , ppa.org_id project_org_id
1822 , ppa.carrying_out_organization_id project_organization_id
1823 , ver.plan_type_code plan_type_code /* 4471527 */
1824 FROM
1825 PA_BUDGET_LINES bl
1826 , pa_resource_asSIGNments ra
1827 , PJI_FM_EXTR_PLNVER3_T ver
1828 , pa_projects_all ppa
1829 , PA_PROJ_ELEM_VER_STRUCTURE pevs
1830 WHERE
1831 ra.resource_asSIGNment_id = bl.resource_asSIGNment_id
1832 AND ra.project_id = ver.PROJECT_ID
1833 AND ra.budget_version_id = ver.plan_version_id
1834 AND ver.project_id = ppa.project_id
1835 AND txn_currency_code IS NOT NULL
1836 AND bl.project_currency_code IS NOT NULL
1837 AND bl.projfunc_currency_code IS NOT NULL
1838 AND pevs.element_version_id = ver.wbs_struct_version_id
1839 AND ver.project_id = pevs.project_id -- fix for bug 4149422 in EXTRACT_PLAN_AMOUNTS_PRIRBS
1840 AND ver.secondary_rbs_flag = 'N'
1841 ) spread_bl
1842 ---- end of third inline view 'spread_bl'...........
1843 ,
1844 (
1845 select 4 INVERT_ID from dual union all
1846 select 8 INVERT_ID from dual union all
1847 select 16 INVERT_ID from dual where PJI_UTILS.GET_SETUP_PARAMETER('TXN_CURR_FLAG') = 'Y'
1848 ) invert
1849 ) collapse_bl
1850 ---- End of second inline view 'collapse_bl' ..........
1851 GROUP BY
1852 collapse_bl.PROJECT_ID
1853 , collapse_bl.WBS_ELEMENT_ID
1854 -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
1855 , collapse_bl.RBS_ELEMENT_ID
1856 , collapse_bl.RBS_STRUCT_VERSION_ID
1857 , collapse_bl.plan_type_id
1858 , collapse_bl.BUDGET_VERSION_ID
1859 , collapse_bl.PROJECT_ORGANIZATION_ID
1860 , collapse_bl.PROJECT_ORG_ID
1861 , collapse_bl.RESOURCE_ASSIGNMENT_ID
1862 , collapse_bl.BILLABLE_FLAG
1863 , collapse_bl.RESOURCE_CLASS
1864 , collapse_bl.TIME_PHASED_TYPE_CODE
1865 , collapse_bl.CURRENCY_CODE
1866 , collapse_bl.start_date
1867 , collapse_bl.end_date
1868 , collapse_bl.period_name
1869 , collapse_bl.row_id
1870 , collapse_bl.plan_type_code /* 4471527 */
1871 ) plr
1872 ---- End of first inline view plr ..........
1873 , PJI_ORG_EXTR_INFO orginfo
1874 , PJI_FM_EXTR_PLNVER3_T vers
1875 , pji_time_cal_period_v pji_time
1876 WHERE 1=1
1877 -- AND orginfo.projfunc_currency_mau is not NULL
1878 AND plr.project_org_id = orginfo.org_id
1879 AND plr.project_id = vers.project_id
1880 AND plr.budget_version_id = vers.plan_version_id
1881 AND plr.plan_type_code = vers.plan_type_code /*4471527 */
1882 AND DECODE(vers.time_phased_type_code
1883 , g_pa_cal_str, orginfo.pa_calendar_id
1884 , g_gl_cal_str, orginfo.gl_calendar_id
1885 , -l_max_plnver_id ) = pji_time.calendar_id
1886 AND plr.period_name = pji_time.name
1887 AND vers.time_phased_type_code IN (g_pa_cal_str, g_gl_cal_str, 'N')
1888 GROUP BY
1889 plr.PROJECT_ID
1890 , plr.PROJECT_ORG_ID
1891 , plr.project_ORGANIZATION_ID
1892 , plr.WBS_ELEMENT_ID
1893 , decode(vers.time_phased_type_code
1894 , 'N', -1
1895 , pji_time.cal_period_id) /* Modified for bug 9048716 */
1896 , decode(vers.time_phased_type_code
1897 , g_pa_cal_str, 32
1898 , g_gl_cal_str, 32
1899 , 'N', 2048
1900 , -1) /* Modified for bug 9048716 */
1901 , decode(vers.time_phased_type_code
1902 , g_pa_cal_str, g_pa_cal_str
1903 , g_gl_cal_str, g_gl_cal_str
1904 , 'N', g_all
1905 , 'X') -- CALENDAR_TYPE /* Modified for bug 9048716 */
1906 , plr.CURR_RECORD_TYPE -- curr code missing.
1907 , plr.currency_code
1908 , plr.RBS_ELEMENT_ID
1909 , plr.RBS_STRUCT_VERSION_ID
1910 , plr.BUDGET_VERSION_ID
1911 , plr.plan_type_id
1912 , DECODE(vers.time_phased_type_code, g_pa_cal_str, 'OF', g_gl_cal_str, 'OF', 'N', 'NTP', 'X')
1913 , plr.plan_type_code; /* 4471527 */
1914
1915 IF P_PA_DEBUG_MODE = 'Y' THEN
1916 pa_debug.write('EXTRACT_PLAN_AMOUNTS_PRIRBS: ' || g_module_name,'EXTRACT_PLAN_AMOUNTS_PRIRBS count : '||SQL%ROWCOUNT ,1);
1917 END IF;
1918 -- cbs change
1919 UPDATE PJI_FM_EXTR_PLNVER3_T t
1920 SET worker_id = null
1921 WHERE worker_id = -99;
1922 -- End cbs change
1923
1924
1925
1926 print_time('EXTRACT_PLAN_AMOUNTS_PRIRBS : l_count ' || SQL%ROWCOUNT);
1927
1928 DELETE_NTP_CAL_RECORD ( p_max_plnver_id => l_max_plnver_id );
1929
1930 print_time('EXTRACT_PLAN_AMOUNTS_PRIRBS : End' );
1931
1932 EXCEPTION
1933 WHEN OTHERS THEN
1934 print_time('EXTRACT_PLAN_AMOUNTS_PRIRBS : Exception ' || SQLERRM );
1935 print_time('EXTRACT_PLAN_AMOUNTS_PRIRBS : Begin worker id is ... ' || 1);
1936 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
1937 p_procedure_name => 'EXTRACT_PLAN_AMOUNTS_PRIRBS');
1938 RAISE;
1939 END;
1940
1941
1942 --
1943 -- Extract the period level plan amounts for PA/GL/non time phased entries from budget lines
1944 -- for the secondary RBS for this plan version into pji_fp_aggr_pjp1_t.
1945 -- EXTRACT_PLAN_AMOUNTS_SECRBS
1946 PROCEDURE EXTRACT_PLAN_AMOUNTS_SECRBS IS
1947 BEGIN
1948
1949 NULL;
1950
1951 EXCEPTION
1952 WHEN OTHERS THEN
1953 print_time('EXTRACT_PLAN_AMOUNTS_SECRBS : Exception ' || SQLERRM );
1954 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
1955 p_procedure_name => 'EXTRACT_PLAN_AMOUNTS_SECRBS');
1956 RAISE;
1957 END;
1958
1959 --EXTRACT_PLAN_AMTS_SECRBS_GLC12
1960
1961 PROCEDURE EXTRACT_PLAN_AMTS_SECRBS_GLC12 IS
1962 BEGIN
1963
1964 print_time ( ' EXTRACT_PLAN_AMTS_SECRBS_GLC12 begin. Inserted rows # is: ' || SQL%ROWCOUNT );
1965
1966 PJI_PJP_FP_CURR_WRAP.get_global_currency_info (
1967 x_currency_conversion_rule => g_currency_conversion_rule
1968 , x_prorating_format => g_prorating_format
1969 , x_global1_currency_code => g_global1_currency_code
1970 , x_global2_currency_code => g_global2_currency_code
1971 , x_global1_currency_mau => g_global1_currency_mau
1972 , x_global2_currency_mau => g_global2_currency_mau ) ;
1973
1974
1975 print_time(' Got global currency settings. ');
1976 print_time(' g_currency_conversion_rule ' || g_currency_conversion_rule || ' g_prorating_format ' || g_prorating_format );
1977 print_time(' g_global1_currency_code ' || g_global1_currency_code || ' g_global2_currency_code ' || g_global2_currency_code );
1978 print_time(' g_global1_currency_mau ' || g_global1_currency_mau || ' g_global2_currency_mau ' || g_global2_currency_mau ) ;
1979
1980 -- cbs change -- Bug 13736073
1981 IF P_PA_DEBUG_MODE = 'Y' THEN
1982 pa_debug.write('EXTRACT_PLAN_AMTS_SECRBS_GLC12: ' || g_module_name,'Before calling SET_RES_CLASS_FLAG' ,1);
1983 END IF;
1984
1985 PJI_FM_PLAN_MAINT_PVT.SET_RES_CLASS_FLAG;
1986
1987 IF P_PA_DEBUG_MODE = 'Y' THEN
1988 pa_debug.write('EXTRACT_PLAN_AMTS_SECRBS_GLC12: ' || g_module_name,'After calling SET_RES_CLASS_FLAG' ,1);
1989 END IF;
1990 -- End cbs change
1991
1992 INSERT INTO PJI_FP_AGGR_PJP1_T
1993 (
1994 WORKER_ID
1995 , PROJECT_ID
1996 , PROJECT_ORG_ID
1997 , PROJECT_ORGANIZATION_ID
1998 , PROJECT_ELEMENT_ID
1999 , TIME_ID
2000 , PERIOD_TYPE_ID
2001 , CALENDAR_TYPE
2002 , RBS_AGGR_LEVEL
2003 , WBS_ROLLUP_FLAG
2004 , PRG_ROLLUP_FLAG
2005 , CURR_RECORD_TYPE_ID
2006 , CURRENCY_CODE
2007 , RBS_ELEMENT_ID
2008 , RBS_VERSION_ID
2009 , PLAN_VERSION_ID
2010 , PLAN_TYPE_ID
2011 , RAW_COST
2012 , BRDN_COST
2013 , REVENUE
2014 , BILL_RAW_COST
2015 , BILL_BRDN_COST
2016 , BILL_LABOR_RAW_COST
2017 , BILL_LABOR_BRDN_COST
2018 , BILL_LABOR_HRS
2019 , EQUIPMENT_RAW_COST
2020 , EQUIPMENT_BRDN_COST
2021 , CAPITALIZABLE_RAW_COST
2022 , CAPITALIZABLE_BRDN_COST
2023 , LABOR_RAW_COST
2024 , LABOR_BRDN_COST
2025 , LABOR_HRS
2026 , LABOR_REVENUE
2027 , EQUIPMENT_HOURS
2028 , BILLABLE_EQUIPMENT_HOURS
2029 , SUP_INV_COMMITTED_COST
2030 , PO_COMMITTED_COST
2031 , PR_COMMITTED_COST
2032 , OTH_COMMITTED_COST
2033 , ACT_LABOR_HRS
2034 , ACT_EQUIP_HRS
2035 , ACT_LABOR_BRDN_COST
2036 , ACT_EQUIP_BRDN_COST
2037 , ACT_BRDN_COST
2038 , ACT_RAW_COST
2039 , ACT_REVENUE
2040 , ACT_LABOR_RAW_COST
2041 , ACT_EQUIP_RAW_COST
2042 , ETC_LABOR_HRS
2043 , ETC_EQUIP_HRS
2044 , ETC_LABOR_BRDN_COST
2045 , ETC_EQUIP_BRDN_COST
2046 , ETC_BRDN_COST
2047 , ETC_RAW_COST
2048 , ETC_LABOR_RAW_COST
2049 , ETC_EQUIP_RAW_COST
2050 , CUSTOM1
2051 , CUSTOM2
2052 , CUSTOM3
2053 , CUSTOM4
2054 , CUSTOM5
2055 , CUSTOM6
2056 , CUSTOM7
2057 , CUSTOM8
2058 , CUSTOM9
2059 , CUSTOM10
2060 , CUSTOM11
2061 , CUSTOM12
2062 , CUSTOM13
2063 , CUSTOM14
2064 , CUSTOM15
2065 , LINE_TYPE
2066 , TIME_DANGLING_FLAG
2067 , RATE_DANGLING_FLAG
2068 , START_DATE
2069 , END_DATE
2070 , PRG_LEVEL
2071 , PLAN_TYPE_CODE
2072 )
2073 SELECT
2074 g_worker_id WORKER_ID
2075 , plr.PROJECT_ID
2076 , plr.PROJECT_ORG_ID
2077 , plr.project_ORGANIZATION_ID
2078 , plr.WBS_ELEMENT_ID
2079 , plr.time_id
2080 , plr.period_type_id -- period type id...
2081 , plr.CALENDAR_TYPE
2082 , g_lowest_level RBS_AGGR_LEVEL
2083 , 'N' WBS_ROLLUP_FLAG
2084 , 'N' PRG_ROLLUP_FLAG
2085 , plr.CURR_RECORD_TYPE
2086 , plr.currency_code
2087 , plr.RBS_ELEMENT_ID
2088 , plr.RBS_STRUCT_VERSION_ID
2089 , plr.plan_version_id
2090 , plr.plan_type_id
2091 , SUM(plr.RAW_COST)
2092 , SUM(plr.BRDN_COST)
2093 , SUM(plr.REVENUE)
2094 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) BILL_RAW_COST
2095 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) BILL_BRDN_COST
2096 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_people_resclass_code, plr.raw_cost, 0 ) ) BILL_LABOR_RAW_COST
2097 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_people_resclass_code , plr.BRDN_COST, 0 ) ) BILL_LABOR_BRDN_COST
2098 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'Y' || g_people_resclass_code, plr.quantity, 0 ) ) BILL_LABOR_HRS */ -- bug 6039785
2099 , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'Y' || g_people_resclass_code,
2100 DECODE(plr.billable_flag,'Y',plr.quantity,0) , 0 ) ) BILL_LABOR_HRS -- bug 6039785
2101 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code , plr.raw_cost, 0 ) ) EQUIPMENT_RAW_COST
2102 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code , plr.BRDN_COST, 0 ) ) EQUIPMENT_BRDN_COST
2103 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) CAPITALIZABLE_RAW_COST
2104 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) CAPITALIZABLE_BRDN_COST
2105 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.raw_cost, 0 ) ) LABOR_RAW_COST
2106 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.BRDN_COST, 0 ) ) LABOR_BRDN_COST
2107 /* , SUM ( DECODE ( plr.resource_class, g_people_resclass_code,
2108 DECODE ( vers.wp_flag, 'N',
2109 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
2110 plr.quantity),
2111 0 ) ) labor_hrs */ -- bug 6039785
2112 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, DECODE(plr.billable_flag,'Y',
2113 DECODE ( vers.wp_flag, 'N',
2114 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
2115 plr.quantity),
2116 0 ),
2117 0 ) ) labor_hrs -- bug 6039785
2118 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.revenue, 0 ) ) LABOR_REVENUE
2119 /* , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code,
2120 DECODE ( vers.wp_flag, 'N',
2121 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
2122 plr.quantity),
2123
2124 0 ) ) EQUIPMENT_HOURS */ -- bug 6039785
2125 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code, DECODE(plr.billable_flag,'Y',
2126 DECODE ( vers.wp_flag, 'N',
2127 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
2128 plr.quantity),
2129 0 ),
2130 0 ) ) EQUIPMENT_HOURS -- bug 6039785
2131 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_equip_resclass_code, plr.quantity, 0 ) ) BILLABLE_EQUIPMENT_HOURS */ -- bug 6039785
2132 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_equip_resclass_code,
2133 DECODE(plr.billable_flag,'Y',plr.quantity,0) , 0 ) ) BILLABLE_EQUIPMENT_HOURS -- bug 6039785
2134 , TO_NUMBER(NULL) SUP_INV_COMMITTED_COST
2135 , TO_NUMBER(NULL) PO_COMMITTED_COST
2136 , TO_NUMBER(NULL) PR_COMMITTED_COST
2137 , TO_NUMBER(NULL) OTH_COMMITTED_COST
2138 /* , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
2139 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
2140 0 ) ) ) ACT_LABOR_HRS */ -- bug 6039785
2141 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
2142 DECODE (plr.billable_flag ,'Y',
2143 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
2144 0 ),
2145 0 ) ) ) ACT_LABOR_HRS -- bug 6039785
2146 /* , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
2147 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
2148 0 ) ) ) ACT_EQUIP_HOURS */ -- bug 6039785
2149 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
2150 DECODE (plr.billable_flag ,'Y',
2151 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
2152 0 ),
2153 0 ) ) ) ACT_EQUIP_HOURS -- bug 6039785
2154 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.actual_BRDN_COST, 0 ) ) ) ACT_LABOR_BRDN_COST
2155 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.actual_BRDN_COST, 0 ) ) ) ACT_EQUIPMENT_BRDN_COST
2156 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, plr.actual_brdn_cost ) ) ACT_BRDN_COST
2157 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, plr.actual_raw_cost ) ) ACT_RAW_COST
2158 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, plr.actual_revenue ) ) ACT_REVENUE
2159 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.actual_RAW_COST, 0 ) ) ) ACT_LABOR_RAW_COST
2160 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.actual_RAW_COST, 0 ) ) ) ACT_EQUIPMENT_RAW_COST
2161 /* , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
2162 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
2163 0 ) ) ) ETC_LABOR_HRS */ -- bug 6039785
2164 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
2165 DECODE (plr.billable_flag ,'Y',
2166 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
2167 0 ),
2168 0 ) ) ) ETC_LABOR_HRS -- bug 6039785
2169 /* , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
2170 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
2171 0 ) ) ) ETC_EQUIP_HOURS */ -- bug 6039785
2172 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
2173 DECODE (plr.billable_flag ,'Y',
2174 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
2175 0 ),
2176 0 ) ) ) ETC_EQUIP_HOURS -- bug 6039785
2177 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.etc_BRDN_COST, 0 ) ) ) ETC_LABOR_BRDN_COST
2178 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.etc_BRDN_COST, 0 ) ) ) ETC_EQUIP_BRDN_COST
2179 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, plr.etc_brdn_cost ) ) ETC_BRDN_COST
2180 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, plr.etc_raw_cost ) ) ETC_RAW_COST
2181 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.etc_raw_COST, 0 ) ) ) ETC_LABOR_raw_COST
2182 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.etc_raw_COST, 0 ) ) ) ETC_EQUIP_raw_COST
2183 , TO_NUMBER(NULL) CUSTOM1
2184 , TO_NUMBER(NULL) CUSTOM2
2185 , TO_NUMBER(NULL) CUSTOM3
2186 , TO_NUMBER(NULL) CUSTOM4
2187 , TO_NUMBER(NULL) CUSTOM5
2188 , TO_NUMBER(NULL) CUSTOM6
2189 , TO_NUMBER(NULL) CUSTOM7
2190 , TO_NUMBER(NULL) CUSTOM8
2191 , TO_NUMBER(NULL) CUSTOM9
2192 , TO_NUMBER(NULL) CUSTOM10
2193 , TO_NUMBER(NULL) CUSTOM11
2194 , TO_NUMBER(NULL) CUSTOM12
2195 , TO_NUMBER(NULL) CUSTOM13
2196 , TO_NUMBER(NULL) CUSTOM14
2197 , TO_NUMBER(NULL) CUSTOM15
2198 , plr.LINE_TYPE
2199 , NULL time_dangling_flag
2200 , decode(sign(plr.rate),-1,'Y',NULL) ||decode(sign(plr.rate2),-1,'Y',NULL) rate_dangling_flag
2201 , plr.start_date
2202 , plr.end_date
2203 , g_default_prg_level prg_level
2204 , plr.plan_type_code plan_type_code /* 4471527 */
2205 FROM
2206 ( ----- First inline view plr .............
2207 select
2208 collapse_bl.PROJECT_ID -- , 1 partition_id
2209 , collapse_bl.WBS_ELEMENT_ID -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
2210 , SUM(collapse_bl.CURR_RECORD_TYPE_ID) CURR_RECORD_TYPE
2211 , collapse_bl.RBS_ELEMENT_ID
2212 , collapse_bl.RBS_STRUCT_VERSION_ID
2213 , collapse_bl.plan_type_id
2214 , collapse_bl.plan_version_id
2215 , collapse_bl.time_id
2216 , collapse_bl.PROJECT_ORGANIZATION_ID
2217 , collapse_bl.PROJECT_ORG_ID
2218 , collapse_bl.RESOURCE_ASSIGNMENT_ID
2219 , collapse_bl.BILLABLE_FLAG
2220 , collapse_bl.RESOURCE_CLASS -- , CALENDAR_TYPE -- , CALENDAR_ID
2221 , collapse_bl.TIME_PHASED_TYPE_CODE
2222 , collapse_bl.CURRENCY_CODE
2223 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.raw_cost))) raw_cost
2224 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.BRDN_COST))) BRDN_COST
2225 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.revenue))) revenue
2226 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.actual_raw_cost))) actual_raw_cost
2227 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.actual_BRDN_COST))) actual_BRDN_COST
2228 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.actual_revenue))) actual_revenue
2229 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.etc_raw_cost))) etc_raw_cost
2230 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.etc_BRDN_COST))) etc_BRDN_COST
2231 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.etc_revenue))) etc_revenue
2232 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.quantity))) quantity
2233 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.actual_quantity))) actual_quantity
2234 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.etc_quantity))) etc_quantity
2235 , collapse_bl.start_date start_date
2236 , collapse_bl.end_date end_date
2237 -- , collapse_bl.period_name period_name -- , TRACK_AS_LABOR_FLAG track_as_labor_flag
2238 , collapse_bl.line_type
2239 , collapse_bl.calendar_type
2240 , collapse_bl.period_type_id
2241 , collapse_bl.row_id
2242 ,collapse_bl.rate rate
2243 ,collapse_bl.rate2 rate2
2244 , collapse_bl.plan_type_code plan_type_code /* 4471527 */
2245 from
2246 ( ----- Second inline view 'collapse_bl' begin .............
2247 select
2248 spread_bl.row_id row_id
2249 , spread_bl.PROJECT_ID
2250 , spread_bl.BUDGET_VERSION_ID plan_version_id
2251 , spread_bl.time_id
2252 , spread_bl.RESOURCE_ASSIGNMENT_ID
2253 , spread_bl.WBS_ELEMENT_ID
2254 , spread_bl.RBS_ELEMENT_ID
2255 , spread_bl.WBS_STRUCT_VERSION_ID
2256 , spread_bl.RBS_STRUCT_VERSION_ID
2257 , spread_bl.plan_type_id
2258 , spread_bl.BILLABLE_FLAG
2259 , spread_bl.RESOURCE_CLASS
2260 , spread_bl.PROJECT_ORGANIZATION_ID
2261 , spread_bl.PROJECT_ORG_ID
2262 , spread_bl.TIME_PHASED_TYPE_CODE
2263 , DECODE( invert.INVERT_ID
2264 , 1, spread_bl.glb1_CURRENCY_CODE
2265 , 2, spread_bl.glb2_CURRENCY_CODE
2266 , 4, spread_bl.func_CURRENCY_CODE
2267 , 8, spread_bl.PRJ_CURRENCY_CODE
2268 , 16, spread_bl.TXN_CURRENCY_CODE ) CURRENCY_CODE
2269 , invert.INVERT_ID CURR_RECORD_TYPE_ID
2270 , DECODE ( invert.INVERT_ID
2271 , 1, spread_bl.glb1_raw_cost
2272 , 2, spread_bl.glb2_raw_cost
2273 , 4, spread_bl.func_raw_cost
2274 , 8, spread_bl.PRJ_raw_cost
2275 , 16, spread_bl.TXN_raw_cost) raw_cost
2276 , DECODE ( invert.INVERT_ID
2277 , 1, spread_bl.glb1_brdn_cost
2278 , 2, spread_bl.glb2_brdn_cost
2279 , 4, spread_bl.func_BRDN_COST
2280 , 8, spread_bl.PRJ_BRDN_COST
2281 , 16, spread_bl.TXN_BRDN_COST ) BRDN_COST
2282 , DECODE ( invert.INVERT_ID
2283 , 1, spread_bl.glb1_revenue
2284 , 2, spread_bl.glb2_revenue
2285 , 4, spread_bl.func_revenue
2286 , 8, spread_bl.PRJ_revenue
2287 , 16, spread_bl.TXN_revenue ) revenue
2288 , DECODE ( invert.INVERT_ID
2289 , 1, spread_bl.glb1_actual_raw_cost
2290 , 2, spread_bl.glb2_actual_raw_cost
2291 , 4, spread_bl.func_actual_raw_cost
2292 , 8, spread_bl.prj_actual_raw_cost
2293 , 16, spread_bl.txn_actual_raw_cost ) actual_raw_cost
2294 , DECODE ( invert.INVERT_ID
2295 , 1, spread_bl.glb1_actual_brdn_cost
2296 , 2, spread_bl.glb2_actual_brdn_cost
2297 , 4, spread_bl.func_actual_brdn_cost
2298 , 8, spread_bl.prj_actual_brdn_cost
2299 , 16, spread_bl.txn_actual_brdn_cost ) actual_brdn_cost
2300 , DECODE ( invert.INVERT_ID
2301 , 1, spread_bl.glb1_actual_revenue
2302 , 2, spread_bl.glb2_actual_revenue
2303 , 4, spread_bl.func_actual_revenue
2304 , 8, spread_bl.prj_actual_revenue
2305 , 16, spread_bl.txn_actual_revenue ) actual_revenue
2306 , DECODE ( invert.INVERT_ID
2307 , 1, spread_bl.glb1_etc_raw_cost
2308 , 2, spread_bl.glb2_etc_raw_cost
2309 , 4, spread_bl.func_etc_raw_cost
2310 , 8, spread_bl.prj_etc_raw_cost
2311 , 16, spread_bl.txn_etc_raw_cost ) etc_raw_cost
2312 , DECODE ( invert.INVERT_ID
2313 , 1, spread_bl.glb1_etc_brdn_cost
2314 , 2, spread_bl.glb2_etc_brdn_cost
2315 , 4, spread_bl.func_etc_brdn_cost
2316 , 8, spread_bl.prj_etc_brdn_cost
2317 , 16, spread_bl.txn_etc_brdn_cost ) etc_brdn_cost
2318 , DECODE ( invert.INVERT_ID
2319 , 1, spread_bl.glb1_etc_revenue
2320 , 2, spread_bl.glb2_etc_revenue
2321 , 4, spread_bl.func_etc_revenue
2322 , 8, spread_bl.prj_etc_revenue
2323 , 16, spread_bl.txn_etc_revenue ) etc_revenue
2324 , spread_bl.quantity quantity
2325 , spread_bl.actual_quantity actual_quantity
2326 , spread_bl.etc_quantity etc_quantity
2327 , spread_bl.start_date start_date
2328 , spread_bl.end_date end_date
2329 , spread_bl.line_type line_type
2330 , spread_bl.period_type_id
2331 , spread_bl.calendar_type
2332 ,decode(invert.invert_id,1,spread_bl.rate,1) rate
2333 ,decode(invert.invert_id,2,spread_bl.rate2,1) rate2
2334 ,spread_bl.plan_type_code plan_type_code /* 4471527 */
2335 from
2336 ( ----- Third inline view 'spread_bl' .............
2337 SELECT
2338 ra.project_id
2339 , bl.rowid row_id
2340 , ra.budget_version_id
2341 , prd.cal_period_id time_id
2342 , bl.resource_asSIGNment_id
2343 , DECODE(ra.task_id, 0, pevs.proj_element_id, ra.task_id) wbs_element_id
2344 , NVL(map.element_id, -1) rbs_element_id -- !! changed.
2345 , ver.wbs_struct_version_id wbs_struct_version_id
2346 , NVL(ver.rbs_struct_version_id, -1) rbs_struct_version_id -- !! changed.
2347 , ver.plan_type_id plan_type_id
2348 , ra.rate_based_flag billable_flag
2349 -- cbs change -- Bug 13736073
2350 , decode(PJI_FM_PLAN_MAINT_PVT.g_res_class_flag,'N',decode(PJI_FM_PLAN_MAINT_PVT.get_res_class_flag(ra.budget_version_id), 'N',
2351 '1'||ra.resource_class_code, ra.resource_class_code),ra.resource_class_code) resource_class
2352 -- End cbs change
2353 , DECODE(ver.time_phased_type_code
2354 , g_pa_cal_str, 32
2355 , g_gl_cal_str, 32
2356 , 'N', 2048
2357 , -1) period_type_id
2358 , DECODE(ver.time_phased_type_code
2359 , g_pa_cal_str, g_pa_cal_str
2360 , g_gl_cal_str, g_gl_cal_str
2361 , 'N', g_all
2362 , 'X') CALENDAR_TYPE
2363 , bl.txn_currency_code txn_currency_code
2364 , bl.txn_raw_cost txn_raw_cost
2365 , bl.txn_burdened_COST txn_brdn_COST
2366 , bl.txn_revenue txn_revenue
2367 , DECODE(ver.wp_flag, 'N', bl.txn_init_raw_cost, TO_NUMBER(NULL)) txn_actual_raw_cost -- new
2368 , DECODE(ver.wp_flag, 'N', bl.txn_init_burdened_cost, TO_NUMBER(NULL)) txn_actual_brdn_cost -- new
2369 , DECODE(ver.wp_flag, 'N', bl.txn_init_revenue, TO_NUMBER(NULL)) txn_actual_revenue -- new
2370 , DECODE(ver.wp_flag, 'N', (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0)), TO_NUMBER(NULL)) txn_etc_raw_cost -- new
2371 , DECODE(ver.wp_flag, 'N', (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0)), TO_NUMBER(NULL)) txn_etc_brdn_cost -- new
2372 , DECODE(ver.wp_flag, 'N', (bl.txn_revenue - NVL(bl.txn_init_revenue, 0)), TO_NUMBER(NULL)) txn_etc_revenue -- new
2373 , bl.project_currency_code prj_currency_code
2374 , bl.project_raw_cost prj_raw_cost
2375 , bl.project_burdened_COST prj_BRDN_COST
2376 , bl.project_revenue prj_revenue
2377 , DECODE(ver.wp_flag, 'N', bl.project_init_raw_cost, TO_NUMBER(NULL)) prj_actual_raw_cost -- new
2378 , DECODE(ver.wp_flag, 'N', bl.project_init_burdened_cost, TO_NUMBER(NULL)) prj_actual_brdn_cost -- new
2379 , DECODE(ver.wp_flag, 'N', bl.project_init_revenue, TO_NUMBER(NULL)) prj_actual_revenue -- new
2380 , DECODE(ver.wp_flag, 'N', (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0)), TO_NUMBER(NULL)) prj_etc_raw_cost -- new
2381 , DECODE(ver.wp_flag, 'N', (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0)), TO_NUMBER(NULL)) prj_etc_brdn_cost -- new
2382 , DECODE(ver.wp_flag, 'N', (bl.project_revenue - NVL(bl.project_init_revenue, 0)), TO_NUMBER(NULL)) prj_etc_revenue -- new
2383 , bl.projfunc_currency_code func_currency_code
2384 , bl.raw_cost func_raw_cost
2385 , bl.burdened_COST func_BRDN_COST
2386 , bl.revenue func_revenue
2387 , DECODE(ver.wp_flag, 'N', bl.init_raw_cost , TO_NUMBER(NULL)) func_actual_raw_cost -- new
2388 , DECODE(ver.wp_flag, 'N', bl.init_burdened_cost , TO_NUMBER(NULL)) func_actual_brdn_cost -- new
2389 , DECODE(ver.wp_flag, 'N', bl.init_revenue , TO_NUMBER(NULL)) func_actual_revenue -- new
2390 , DECODE(ver.wp_flag, 'N', (bl.raw_cost - NVL(bl.init_raw_cost, 0)), TO_NUMBER(NULL)) func_etc_raw_cost -- new
2391 , DECODE(ver.wp_flag, 'N', (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)), TO_NUMBER(NULL)) func_etc_brdn_cost -- new
2392 , DECODE(ver.wp_flag, 'N', (bl.revenue - NVL(bl.init_revenue, 0)), TO_NUMBER(NULL)) func_etc_revenue -- new
2393 , g_global1_currency_code glb1_currency_code -- g_global1_currency_code glb1_currency_code
2394 , DECODE (g_global1_currency_code
2395 , bl.txn_currency_code
2396 , bl.txn_raw_cost
2397 , bl.project_currency_code
2398 , bl.project_raw_cost
2399 , bl.projfunc_currency_code
2400 , bl.raw_cost
2401 , ROUND((rates.rate * raw_cost )/rates.mau)*rates.mau
2402 ) glb1_raw_cost
2403 , DECODE (g_global1_currency_code
2404 , bl.txn_currency_code
2405 , bl.txn_burdened_cost
2406 , bl.project_currency_code
2407 , bl.project_burdened_cost
2408 , bl.projfunc_currency_code
2409 , bl.burdened_cost
2410 , ROUND((rates.rate * burdened_cost )/rates.mau)*rates.mau
2411 ) glb1_BRDN_COST
2412 , DECODE (g_global1_currency_code
2413 , bl.txn_currency_code
2414 , bl.txn_revenue
2415 , bl.project_currency_code
2416 , bl.project_revenue
2417 , bl.projfunc_currency_code
2418 , bl.revenue
2419 , ROUND((rates.rate * revenue )/rates.mau)*rates.mau
2420 ) glb1_revenue
2421 , DECODE(ver.wp_flag
2422 , 'N'
2423 , DECODE (g_global1_currency_code
2424 , bl.txn_currency_code
2425 , bl.txn_init_raw_cost
2426 , bl.project_currency_code
2427 , bl.project_init_raw_cost
2428 , bl.projfunc_currency_code
2429 , bl.init_raw_cost
2430 , ROUND((rates.rate * bl.init_raw_cost )/rates.mau)*rates.mau
2431 )
2432 , TO_NUMBER(NULL)) glb1_actual_raw_cost
2433 , DECODE(ver.wp_flag
2434 , 'N'
2435 , DECODE (g_global1_currency_code
2436 , bl.txn_currency_code
2437 , bl.txn_init_burdened_cost
2438 , bl.project_currency_code
2439 , bl.project_init_burdened_cost
2440 , bl.projfunc_currency_code
2441 , bl.init_burdened_cost
2442 , ROUND((rates.rate * bl.init_burdened_cost )/rates.mau)*rates.mau
2443 )
2444 , TO_NUMBER(NULL)) glb1_actual_brdn_cost
2445 , DECODE(ver.wp_flag
2446 , 'N'
2447 , DECODE (g_global1_currency_code
2448 , bl.txn_currency_code
2449 , bl.txn_init_revenue
2450 , bl.project_currency_code
2451 , bl.project_init_revenue
2452 , bl.projfunc_currency_code
2453 , bl.init_revenue
2454 , ROUND((rates.rate * bl.init_revenue )/rates.mau)*rates.mau
2455 )
2456 , TO_NUMBER(NULL)) glb1_actual_revenue
2457 , DECODE(ver.wp_flag
2458 , 'N'
2459 , DECODE (g_global1_currency_code
2460 , bl.txn_currency_code
2461 , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0))
2462 , bl.project_currency_code
2463 , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0))
2464 , bl.projfunc_currency_code
2465 , (bl.raw_cost - NVL(bl.init_raw_cost, 0))
2466 , ROUND((rates.rate * (bl.raw_cost - NVL(bl.init_raw_cost, 0)) )/rates.mau)*rates.mau
2467 )
2468 , TO_NUMBER(NULL)) glb1_etc_raw_cost
2469 , DECODE(ver.wp_flag
2470 , 'N'
2471 , DECODE (g_global1_currency_code
2472 , bl.txn_currency_code
2473 , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0))
2474 , bl.project_currency_code
2475 , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0))
2476 , bl.projfunc_currency_code
2477 , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0))
2478 , ROUND((rates.rate * (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)) )/rates.mau)*rates.mau
2479 )
2480 , TO_NUMBER(NULL)) glb1_etc_brdn_cost
2481 , DECODE(ver.wp_flag
2482 , 'N'
2483 , DECODE (g_global1_currency_code
2484 , bl.txn_currency_code
2485 , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0))
2486 , bl.project_currency_code
2487 , (bl.project_revenue - NVL(bl.project_init_revenue, 0))
2488 , bl.projfunc_currency_code
2489 , (bl.revenue - NVL(bl.init_revenue, 0))
2490 , ROUND((rates.rate * (bl.revenue - NVL(bl.init_revenue, 0)) )/rates.mau)*rates.mau
2491 )
2492 , TO_NUMBER(NULL)) glb1_etc_revenue
2493 , g_global2_currency_code glb2_currency_code -- g_global2_currency_code glb2_currency_code
2494 , DECODE (g_global2_currency_code
2495 , bl.txn_currency_code
2496 , bl.txn_raw_cost
2497 , bl.project_currency_code
2498 , bl.project_raw_cost
2499 , bl.projfunc_currency_code
2500 , bl.raw_cost
2501 , ROUND((rates.rate2 * raw_cost )/rates.mau2)*rates.mau2
2502 ) glb2_raw_cost
2503 , DECODE (g_global2_currency_code
2504 , bl.txn_currency_code
2505 , bl.txn_burdened_cost
2506 , bl.project_currency_code
2507 , bl.project_burdened_cost
2508 , bl.projfunc_currency_code
2509 , bl.burdened_cost
2510 , ROUND((rates.rate2 * burdened_cost )/rates.mau2)*rates.mau2
2511 ) glb2_BRDN_COST
2512 , DECODE (g_global2_currency_code
2513 , bl.txn_currency_code
2514 , bl.txn_revenue
2515 , bl.project_currency_code
2516 , bl.project_revenue
2517 , bl.projfunc_currency_code
2518 , bl.revenue
2519 , ROUND((rates.rate2 * revenue )/rates.mau2)*rates.mau2
2520 ) glb2_revenue
2521 , DECODE(ver.wp_flag
2522 , 'N'
2523 , DECODE (g_global2_currency_code
2524 , bl.txn_currency_code
2525 , bl.txn_init_raw_cost
2526 , bl.project_currency_code
2527 , bl.project_init_raw_cost
2528 , bl.projfunc_currency_code
2529 , bl.init_raw_cost
2530 , ROUND((rates.rate2 * bl.init_raw_cost )/rates.mau2)*rates.mau2
2531 )
2532 , TO_NUMBER(NULL)) glb2_actual_raw_cost
2533 , DECODE(ver.wp_flag
2534 , 'N'
2535 , DECODE (g_global2_currency_code
2536 , bl.txn_currency_code
2537 , bl.txn_init_burdened_cost
2538 , bl.project_currency_code
2539 , bl.project_init_burdened_cost
2540 , bl.projfunc_currency_code
2541 , bl.init_burdened_cost
2542 , ROUND((rates.rate2 * bl.init_burdened_cost )/rates.mau2)*rates.mau2
2543 )
2544 , TO_NUMBER(NULL)) glb2_actual_brdn_cost
2545 , DECODE(ver.wp_flag
2546 , 'N'
2547 , DECODE (g_global2_currency_code
2548 , bl.txn_currency_code
2549 , bl.txn_init_revenue
2550 , bl.project_currency_code
2551 , bl.project_init_revenue
2552 , bl.projfunc_currency_code
2553 , bl.init_revenue
2554 , ROUND((rates.rate2 * bl.init_revenue )/rates.mau2)*rates.mau2
2555 )
2556 , TO_NUMBER(NULL)) glb2_actual_revenue
2557 , DECODE(ver.wp_flag
2558 , 'N'
2559 , DECODE (g_global2_currency_code
2560 , bl.txn_currency_code
2561 , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0))
2562 , bl.project_currency_code
2563 , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0))
2564 , bl.projfunc_currency_code
2565 , (bl.raw_cost - NVL(bl.init_raw_cost, 0))
2566 , ROUND((rates.rate2 * (bl.raw_cost - NVL(bl.init_raw_cost, 0)) )/rates.mau2)*rates.mau2
2567 )
2568 , TO_NUMBER(NULL)) glb2_etc_raw_cost
2569 , DECODE(ver.wp_flag
2570 , 'N'
2571 , DECODE (g_global2_currency_code
2572 , bl.txn_currency_code
2573 , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0))
2574 , bl.project_currency_code
2575 , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0))
2576 , bl.projfunc_currency_code
2577 , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0))
2578 , ROUND((rates.rate2 * (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)) )/rates.mau2)*rates.mau2
2579 )
2580 , TO_NUMBER(NULL)) glb2_etc_brdn_cost
2581 , DECODE(ver.wp_flag
2582 , 'N'
2583 , DECODE (g_global2_currency_code
2584 , bl.txn_currency_code
2585 , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0))
2586 , bl.project_currency_code
2587 , (bl.project_revenue - NVL(bl.project_init_revenue, 0))
2588 , bl.projfunc_currency_code
2589 , (bl.revenue - NVL(bl.init_revenue, 0))
2590 , ROUND((rates.rate2 * (bl.revenue - NVL(bl.init_revenue, 0)) )/rates.mau2)*rates.mau2
2591 )
2592 , TO_NUMBER(NULL)) glb2_etc_revenue
2593 , bl.quantity quantity
2594 , DECODE(ver.wp_flag, 'N', bl.init_quantity, TO_NUMBER(NULL)) actual_quantity -- new
2595 , DECODE(ver.wp_flag, 'N', (bl.quantity - NVL(bl.init_quantity, 0)), TO_NUMBER(NULL)) etc_quantity -- new
2596 , TO_DATE(NULL) START_DATE
2597 , TO_DATE(NULL) END_date
2598 , ver.time_phased_type_code time_phased_type_code
2599 , ppa.org_id project_org_id
2600 , ppa.carrying_out_organization_id project_organization_id
2601 , DECODE(ver.time_phased_type_code, g_pa_cal_str, 'OF', g_gl_cal_str, 'OF', 'N', 'NTP', 'X') line_type
2602 ,decode(ver.rate_dangling_flag,'Y',-1,1) rate
2603 ,decode(ver.rate_dangling_flag,'Y',-1,1) rate2
2604 , ver.plan_type_code plan_type_code /* 4471527 */
2605 FROM
2606 PA_BUDGET_LINES bl
2607 , pa_resource_asSIGNments ra
2608 , PJI_FM_EXTR_PLNVER3_T ver
2609 , pa_projects_all ppa
2610 , PA_PROJ_ELEM_VER_STRUCTURE pevs
2611 , PJI_FM_AGGR_DLY_RATES_T rates
2612 , pji_time_cal_period_v prd
2613 , PJI_ORG_EXTR_INFO oei
2614 , pji_fp_txn_accum_header hdr
2615 , pa_rbs_txn_accum_map map
2616 , pji_pjp_rbs_header rhdr
2617 WHERE 1=1
2618 AND ra.resource_asSIGNment_id = bl.resource_asSIGNment_id
2619 AND ra.project_id = ver.PROJECT_ID
2620 AND ra.budget_version_id = ver.plan_version_id
2621 AND ver.project_id = ppa.project_id
2622 AND txn_currency_code IS NOT NULL
2623 AND bl.project_currency_code IS NOT NULL
2624 AND bl.projfunc_currency_code IS NOT NULL
2625 AND pevs.element_version_id = ver.wbs_struct_version_id
2626 AND ver.secondary_rbs_flag = 'Y'
2627 AND ver.wp_flag = 'N'
2628 AND oei.org_id = ppa.org_id
2629 AND ver.time_phased_type_code IN (g_pa_cal_str, g_gl_cal_str)
2630 AND DECODE ( ver.time_phased_type_code
2631 , g_pa_cal_str, oei.pa_calendar_id
2632 , g_gl_cal_str, oei.gl_calendar_id) = prd.calendar_id
2633 AND bl.period_name = prd.name
2634 AND rates.time_id = prd.cal_period_id
2635 AND ra.txn_accum_header_id = hdr.txn_accum_header_id
2636 AND ra.txn_accum_header_id = map.txn_accum_header_id
2637 AND map.struct_version_id = rhdr.rbs_version_id
2638 AND ra.budget_version_id = rhdr.plan_version_id
2639 AND ppa.project_id = ra.project_id
2640 AND ver.rbs_struct_version_id = rhdr.rbs_version_id
2641 AND ver.project_id = pevs.project_id -- Fix for bug: 4149422 in EXTRACT_PLAN_AMTS_SECRBS_GLC12
2642 UNION ALL
2643 SELECT
2644 ra.project_id
2645 , bl.rowid row_id
2646 , ra.budget_version_id
2647 , -1 time_id
2648 , bl.resource_asSIGNment_id
2649 , DECODE(ra.task_id, 0, pevs.proj_element_id, ra.task_id) wbs_element_id
2650 , NVL(map.element_id, -1) rbs_element_id -- !! changed.
2651 , ver.wbs_struct_version_id wbs_struct_version_id
2652 , NVL(ver.rbs_struct_version_id, -1) rbs_struct_version_id -- !! changed.
2653 , ver.plan_type_id plan_type_id
2654 , ra.rate_based_flag billable_flag
2655 -- cbs change -- Bug 13736073
2656 , decode(PJI_FM_PLAN_MAINT_PVT.g_res_class_flag,'N',decode(PJI_FM_PLAN_MAINT_PVT.get_res_class_flag(ra.budget_version_id), 'N',
2657 '1'||ra.resource_class_code, ra.resource_class_code),ra.resource_class_code) resource_class
2658 -- End cbs change
2659 , DECODE(ver.time_phased_type_code
2660 , g_pa_cal_str, 32
2661 , g_gl_cal_str, 32
2662 , 'N', 2048
2663 , -1) period_type_id
2664 , DECODE(ver.time_phased_type_code
2665 , g_pa_cal_str, g_pa_cal_str
2666 , g_gl_cal_str, g_gl_cal_str
2667 , 'N', g_all
2668 , 'X') CALENDAR_TYPE
2669 , bl.txn_currency_code txn_currency_code
2670 , bl.txn_raw_cost txn_raw_cost
2671 , bl.txn_burdened_COST txn_brdn_COST
2672 , bl.txn_revenue txn_revenue
2673 , DECODE(ver.wp_flag, 'N', bl.txn_init_raw_cost, TO_NUMBER(NULL)) txn_actual_raw_cost -- new
2674 , DECODE(ver.wp_flag, 'N', bl.txn_init_burdened_cost, TO_NUMBER(NULL)) txn_actual_brdn_cost -- new
2675 , DECODE(ver.wp_flag, 'N', bl.txn_init_revenue, TO_NUMBER(NULL)) txn_actual_revenue -- new
2676 , DECODE(ver.wp_flag, 'N', (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0)), TO_NUMBER(NULL)) txn_etc_raw_cost -- new
2677 , DECODE(ver.wp_flag, 'N', (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0)), TO_NUMBER(NULL)) txn_etc_brdn_cost -- new
2678 , DECODE(ver.wp_flag, 'N', (bl.txn_revenue - NVL(bl.txn_init_revenue, 0)), TO_NUMBER(NULL)) txn_etc_revenue -- new
2679 , bl.project_currency_code prj_currency_code
2680 , bl.project_raw_cost prj_raw_cost
2681 , bl.project_burdened_COST prj_BRDN_COST
2682 , bl.project_revenue prj_revenue
2683 , DECODE(ver.wp_flag, 'N', bl.project_init_raw_cost, TO_NUMBER(NULL)) prj_actual_raw_cost -- new
2684 , DECODE(ver.wp_flag, 'N', bl.project_init_burdened_cost, TO_NUMBER(NULL)) prj_actual_brdn_cost -- new
2685 , DECODE(ver.wp_flag, 'N', bl.project_init_revenue, TO_NUMBER(NULL)) prj_actual_revenue -- new
2686 , DECODE(ver.wp_flag, 'N', (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0)), TO_NUMBER(NULL)) prj_etc_raw_cost -- new
2687 , DECODE(ver.wp_flag, 'N', (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0)), TO_NUMBER(NULL)) prj_etc_brdn_cost -- new
2688 , DECODE(ver.wp_flag, 'N', (bl.project_revenue - NVL(bl.project_init_revenue, 0)), TO_NUMBER(NULL)) prj_etc_revenue -- new
2689 , bl.projfunc_currency_code func_currency_code
2690 , bl.raw_cost func_raw_cost
2691 , bl.burdened_COST func_BRDN_COST
2692 , bl.revenue func_revenue
2693 , DECODE(ver.wp_flag, 'N', bl.init_raw_cost , TO_NUMBER(NULL)) func_actual_raw_cost -- new
2694 , DECODE(ver.wp_flag, 'N', bl.init_burdened_cost , TO_NUMBER(NULL)) func_actual_brdn_cost -- new
2695 , DECODE(ver.wp_flag, 'N', bl.init_revenue , TO_NUMBER(NULL)) func_actual_revenue -- new
2696 , DECODE(ver.wp_flag, 'N', (bl.raw_cost - NVL(bl.init_raw_cost, 0)), TO_NUMBER(NULL)) func_etc_raw_cost -- new
2697 , DECODE(ver.wp_flag, 'N', (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)), TO_NUMBER(NULL)) func_etc_brdn_cost -- new
2698 , DECODE(ver.wp_flag, 'N', (bl.revenue - NVL(bl.init_revenue, 0)), TO_NUMBER(NULL)) func_etc_revenue -- new
2699 , g_global1_currency_code glb1_currency_code -- g_global1_currency_code glb1_currency_code
2700 , DECODE (g_global1_currency_code
2701 , bl.txn_currency_code
2702 , bl.txn_raw_cost
2703 , bl.project_currency_code
2704 , bl.project_raw_cost
2705 , bl.projfunc_currency_code
2706 , bl.raw_cost
2707 , ROUND((rates.rate * raw_cost )/rates.mau)*rates.mau
2708 ) glb1_raw_cost
2709 , DECODE (g_global1_currency_code
2710 , bl.txn_currency_code
2711 , bl.txn_burdened_cost
2712 , bl.project_currency_code
2713 , bl.project_burdened_cost
2714 , bl.projfunc_currency_code
2715 , bl.burdened_cost
2716 , ROUND((rates.rate * burdened_cost )/rates.mau)*rates.mau
2717 ) glb1_BRDN_COST
2718 , DECODE (g_global1_currency_code
2719 , bl.txn_currency_code
2720 , bl.txn_revenue
2721 , bl.project_currency_code
2722 , bl.project_revenue
2723 , bl.projfunc_currency_code
2724 , bl.revenue
2725 , ROUND((rates.rate * revenue )/rates.mau)*rates.mau
2726 ) glb1_revenue
2727 , DECODE(ver.wp_flag
2728 , 'N'
2729 , DECODE (g_global1_currency_code
2730 , bl.txn_currency_code
2731 , bl.txn_init_raw_cost
2732 , bl.project_currency_code
2733 , bl.project_init_raw_cost
2734 , bl.projfunc_currency_code
2735 , bl.init_raw_cost
2736 , ROUND((rates.rate * bl.init_raw_cost )/rates.mau)*rates.mau
2737 )
2738 , TO_NUMBER(NULL)) glb1_actual_raw_cost
2739 , DECODE(ver.wp_flag
2740 , 'N'
2741 , DECODE (g_global1_currency_code
2742 , bl.txn_currency_code
2743 , bl.txn_init_burdened_cost
2744 , bl.project_currency_code
2745 , bl.project_init_burdened_cost
2746 , bl.projfunc_currency_code
2747 , bl.init_burdened_cost
2748 , ROUND((rates.rate * bl.init_burdened_cost )/rates.mau)*rates.mau
2749 )
2750 , TO_NUMBER(NULL)) glb1_actual_brdn_cost
2751 , DECODE(ver.wp_flag
2752 , 'N'
2753 , DECODE (g_global1_currency_code
2754 , bl.txn_currency_code
2755 , bl.txn_init_revenue
2756 , bl.project_currency_code
2757 , bl.project_init_revenue
2758 , bl.projfunc_currency_code
2759 , bl.init_revenue
2760 , ROUND((rates.rate * bl.init_revenue )/rates.mau)*rates.mau
2761 )
2762 , TO_NUMBER(NULL)) glb1_actual_revenue
2763 , DECODE(ver.wp_flag
2764 , 'N'
2765 , DECODE (g_global1_currency_code
2766 , bl.txn_currency_code
2767 , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0))
2768 , bl.project_currency_code
2769 , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0))
2770 , bl.projfunc_currency_code
2771 , (bl.raw_cost - NVL(bl.init_raw_cost, 0))
2772 , ROUND((rates.rate * (bl.raw_cost - NVL(bl.init_raw_cost, 0)) )/rates.mau)*rates.mau
2773 )
2774 , TO_NUMBER(NULL)) glb1_etc_raw_cost
2775 , DECODE(ver.wp_flag
2776 , 'N'
2777 , DECODE (g_global1_currency_code
2778 , bl.txn_currency_code
2779 , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0))
2780 , bl.project_currency_code
2781 , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0))
2782 , bl.projfunc_currency_code
2783 , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0))
2784 , ROUND((rates.rate * (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)) )/rates.mau)*rates.mau
2785 )
2786 , TO_NUMBER(NULL)) glb1_etc_brdn_cost
2787 , DECODE(ver.wp_flag
2788 , 'N'
2789 , DECODE (g_global1_currency_code
2790 , bl.txn_currency_code
2791 , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0))
2792 , bl.project_currency_code
2793 , (bl.project_revenue - NVL(bl.project_init_revenue, 0))
2794 , bl.projfunc_currency_code
2795 , (bl.revenue - NVL(bl.init_revenue, 0))
2796 , ROUND((rates.rate * (bl.revenue - NVL(bl.init_revenue, 0)) )/rates.mau)*rates.mau
2797 )
2798 , TO_NUMBER(NULL)) glb1_etc_revenue
2799 , g_global2_currency_code glb2_currency_code -- g_global2_currency_code glb2_currency_code
2800 , DECODE (g_global2_currency_code
2801 , bl.txn_currency_code
2802 , bl.txn_raw_cost
2803 , bl.project_currency_code
2804 , bl.project_raw_cost
2805 , bl.projfunc_currency_code
2806 , bl.raw_cost
2807 , ROUND((rates.rate2 * raw_cost )/rates.mau2)*rates.mau2
2808 ) glb2_raw_cost
2809 , DECODE (g_global2_currency_code
2810 , bl.txn_currency_code
2811 , bl.txn_burdened_cost
2812 , bl.project_currency_code
2813 , bl.project_burdened_cost
2814 , bl.projfunc_currency_code
2815 , bl.burdened_cost
2816 , ROUND((rates.rate2 * burdened_cost )/rates.mau2)*rates.mau2
2817 ) glb2_BRDN_COST
2818 , DECODE (g_global2_currency_code
2819 , bl.txn_currency_code
2820 , bl.txn_revenue
2821 , bl.project_currency_code
2822 , bl.project_revenue
2823 , bl.projfunc_currency_code
2824 , bl.revenue
2825 , ROUND((rates.rate2 * revenue )/rates.mau2)*rates.mau2
2826 ) glb2_revenue
2827 , DECODE(ver.wp_flag
2828 , 'N'
2829 , DECODE (g_global2_currency_code
2830 , bl.txn_currency_code
2831 , bl.txn_init_raw_cost
2832 , bl.project_currency_code
2833 , bl.project_init_raw_cost
2834 , bl.projfunc_currency_code
2835 , bl.init_raw_cost
2836 , ROUND((rates.rate2 * bl.init_raw_cost )/rates.mau2)*rates.mau2
2837 )
2838 , TO_NUMBER(NULL)) glb2_actual_raw_cost
2839 , DECODE(ver.wp_flag
2840 , 'N'
2841 , DECODE (g_global2_currency_code
2842 , bl.txn_currency_code
2843 , bl.txn_init_burdened_cost
2844 , bl.project_currency_code
2845 , bl.project_init_burdened_cost
2846 , bl.projfunc_currency_code
2847 , bl.init_burdened_cost
2848 , ROUND((rates.rate2 * bl.init_burdened_cost )/rates.mau2)*rates.mau2
2849 )
2850 , TO_NUMBER(NULL)) glb2_actual_brdn_cost
2851 , DECODE(ver.wp_flag
2852 , 'N'
2853 , DECODE (g_global2_currency_code
2854 , bl.txn_currency_code
2855 , bl.txn_init_revenue
2856 , bl.project_currency_code
2857 , bl.project_init_revenue
2858 , bl.projfunc_currency_code
2859 , bl.init_revenue
2860 , ROUND((rates.rate2 * bl.init_revenue )/rates.mau2)*rates.mau2
2861 )
2862 , TO_NUMBER(NULL)) glb2_actual_revenue
2863 , DECODE(ver.wp_flag
2864 , 'N'
2865 , DECODE (g_global2_currency_code
2866 , bl.txn_currency_code
2867 , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0))
2868 , bl.project_currency_code
2869 , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0))
2870 , bl.projfunc_currency_code
2871 , (bl.raw_cost - NVL(bl.init_raw_cost, 0))
2872 , ROUND((rates.rate2 * (bl.raw_cost - NVL(bl.init_raw_cost, 0)) )/rates.mau2)*rates.mau2
2873 )
2874 , TO_NUMBER(NULL)) glb2_etc_raw_cost
2875 , DECODE(ver.wp_flag
2876 , 'N'
2877 , DECODE (g_global2_currency_code
2878 , bl.txn_currency_code
2879 , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0))
2880 , bl.project_currency_code
2881 , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0))
2882 , bl.projfunc_currency_code
2883 , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0))
2884 , ROUND((rates.rate2 * (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)) )/rates.mau2)*rates.mau2
2885 )
2886 , TO_NUMBER(NULL)) glb2_etc_brdn_cost
2887 , DECODE(ver.wp_flag
2888 , 'N'
2889 , DECODE (g_global2_currency_code
2890 , bl.txn_currency_code
2891 , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0))
2892 , bl.project_currency_code
2893 , (bl.project_revenue - NVL(bl.project_init_revenue, 0))
2894 , bl.projfunc_currency_code
2895 , (bl.revenue - NVL(bl.init_revenue, 0))
2896 , ROUND((rates.rate2 * (bl.revenue - NVL(bl.init_revenue, 0)) )/rates.mau2)*rates.mau2
2897 )
2898 , TO_NUMBER(NULL)) glb2_etc_revenue
2899 , bl.quantity quantity
2900 , DECODE(ver.wp_flag, 'N', bl.init_quantity, TO_NUMBER(NULL)) actual_quantity -- new
2901 , DECODE(ver.wp_flag, 'N', (bl.quantity - NVL(bl.init_quantity, 0)), TO_NUMBER(NULL)) etc_quantity -- new
2902 , ra.planning_start_date start_date
2903 , ra.planning_END_date end_date
2904 , ver.time_phased_type_code time_phased_type_code
2905 , ppa.org_id project_org_id
2906 , ppa.carrying_out_organization_id project_organization_id
2907 , 'NTP' line_type
2908 ,decode(ver.rate_dangling_flag,'Y',-1,1) rate
2909 ,decode(ver.rate_dangling_flag,'Y',-1,1) rate2
2910 , ver.plan_type_code plan_type_code /* 4471527 */
2911 FROM
2912 PA_BUDGET_LINES bl
2913 , pa_resource_asSIGNments ra
2914 , PJI_FM_EXTR_PLNVER3_T ver
2915 , pa_projects_all ppa
2916 , PA_PROJ_ELEM_VER_STRUCTURE pevs
2917 , PJI_FM_AGGR_DLY_RATES_T rates
2918 -- , pji_time_cal_period prd
2919 -- , PJI_ORG_EXTR_INFO oei
2920 , pji_fp_txn_accum_header hdr
2921 , pa_rbs_txn_accum_map map
2922 , pji_pjp_rbs_header rhdr
2923 WHERE 1=1
2924 AND ra.resource_asSIGNment_id = bl.resource_asSIGNment_id
2925 AND ra.project_id = ver.PROJECT_ID
2926 AND ra.budget_version_id = ver.plan_version_id
2927 AND ver.project_id = ppa.project_id
2928 AND txn_currency_code IS NOT NULL
2929 AND bl.project_currency_code IS NOT NULL
2930 AND bl.projfunc_currency_code IS NOT NULL
2931 AND ver.project_id = pevs.project_id -- Fix for bug : 4149422 in EXTRACT_PLAN_AMTS_SECRBS_GLC12
2932 AND pevs.element_version_id = ver.wbs_struct_version_id
2933 AND ver.secondary_rbs_flag = 'Y'
2934 AND ver.wp_flag = 'N'
2935 -- AND oei.org_id = ppa.org_id
2936 AND ver.time_phased_type_code = 'N' -- IN (g_pa_cal_str, g_gl_cal_str)
2937 AND rates.time_id = DECODE ( g_currency_conversion_rule
2938 , g_start_str
2939 , TO_NUMBER(to_CHAR(ra.planning_start_date, 'J'))
2940 , g_end_str
2941 , TO_NUMBER(to_CHAR(ra.planning_end_date, 'J')) )
2942 AND ra.txn_accum_header_id = hdr.txn_accum_header_id
2943 AND ra.txn_accum_header_id = map.txn_accum_header_id
2944 AND map.struct_version_id = rhdr.rbs_version_id
2945 AND ra.budget_version_id = rhdr.plan_version_id
2946 AND ppa.project_id = ra.project_id
2947 AND ver.rbs_struct_version_id = rhdr.rbs_version_id
2948 ) spread_bl
2949 ---- end of third inline view 'spread_bl'...........
2950 ,
2951 (
2952 select 1 INVERT_ID from dual where PJI_UTILS.GET_SETUP_PARAMETER('GLOBAL_CURR1_FLAG') = 'Y' union all /* Added for bug 8708651 */
2953 select 2 INVERT_ID from dual where PJI_UTILS.GET_SETUP_PARAMETER('GLOBAL_CURR2_FLAG') = 'Y' union all
2954 select 4 INVERT_ID from dual union all
2955 select 8 INVERT_ID from dual union all
2956 select 16 INVERT_ID from dual where PJI_UTILS.GET_SETUP_PARAMETER('TXN_CURR_FLAG') = 'Y'
2957 ) invert
2958 ) collapse_bl
2959 ---- End of second inline view 'collapse_bl' ..........
2960 GROUP BY
2961 collapse_bl.PROJECT_ID
2962 , collapse_bl.time_id
2963 , collapse_bl.WBS_ELEMENT_ID
2964 -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
2965 , collapse_bl.RBS_ELEMENT_ID
2966 , collapse_bl.RBS_STRUCT_VERSION_ID
2967 , collapse_bl.plan_type_id
2968 , collapse_bl.plan_version_id
2969 , collapse_bl.PROJECT_ORGANIZATION_ID
2970 , collapse_bl.PROJECT_ORG_ID
2971 , collapse_bl.RESOURCE_ASSIGNMENT_ID
2972 , collapse_bl.BILLABLE_FLAG
2973 , collapse_bl.RESOURCE_CLASS
2974 , collapse_bl.TIME_PHASED_TYPE_CODE
2975 , collapse_bl.CURRENCY_CODE
2976 , collapse_bl.start_date
2977 , collapse_bl.end_date
2978 , collapse_bl.row_id
2979 , collapse_bl.line_type
2980 , collapse_bl.calendar_type
2981 , collapse_bl.period_type_id
2982 ,collapse_bl.rate
2983 ,collapse_bl.rate2
2984 , collapse_bl.plan_type_code /* 4471527 */
2985 ) plr
2986 ---- End of first inline view plr ..........
2987 , pji_fm_extr_plnver3_t vers
2988 WHERE 1=1
2989 AND vers.plan_version_id = plr.plan_version_id
2990 AND vers.plan_type_code = plr.plan_type_code /*4471527 */
2991 -- AND plr.CURR_RECORD_TYPE IS NOT NULL
2992 AND vers.rbs_struct_version_id = plr.rbs_struct_version_id
2993 AND plr.currency_code IS NOT NULL
2994 GROUP BY
2995 plr.PROJECT_ID
2996 , plr.PROJECT_ORG_ID
2997 , plr.project_ORGANIZATION_ID
2998 , plr.WBS_ELEMENT_ID
2999 , plr.time_id
3000 , plr.period_type_id
3001 , plr.CALENDAR_TYPE
3002 , plr.CURR_RECORD_TYPE -- curr code missing.
3003 , plr.currency_code
3004 , plr.RBS_ELEMENT_ID
3005 , plr.RBS_STRUCT_VERSION_ID
3006 , plr.plan_version_id
3007 , plr.plan_type_id
3008 , plr.start_date
3009 , plr.end_date
3010 , plr.line_type
3011 ,decode(sign(plr.rate),-1,'Y',NULL) ||decode(sign(plr.rate2),-1,'Y',NULL)
3012 , plr.plan_type_code ; /* 4471527 */
3013
3014
3015 print_time ( ' EXTRACT_PLAN_AMTS_SECRBS_GLC12 end. Inserted rows # is: ' || SQL%ROWCOUNT );
3016
3017 EXCEPTION
3018 WHEN OTHERS THEN
3019 print_time('EXTRACT_PLAN_AMOUNTS_SECRBS : Exception ' || SQLERRM );
3020 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
3021 p_procedure_name => 'EXTRACT_PLAN_AMTS_SECRBS_GLC12');
3022 RAISE;
3023 END;
3024
3025 --EXTRACT_PLAN_AMTS_PRIRBS_GLC12
3026
3027 PROCEDURE EXTRACT_PLAN_AMTS_PRIRBS_GLC12 IS
3028 BEGIN
3029
3030 print_time ( ' EXTRACT_PLAN_AMTS_PRIRBS_GLC12 begin. Inserted rows # is: ' || SQL%ROWCOUNT );
3031
3032 PJI_PJP_FP_CURR_WRAP.get_global_currency_info (
3033 x_currency_conversion_rule => g_currency_conversion_rule
3034 , x_prorating_format => g_prorating_format
3035 , x_global1_currency_code => g_global1_currency_code
3036 , x_global2_currency_code => g_global2_currency_code
3037 , x_global1_currency_mau => g_global1_currency_mau
3038 , x_global2_currency_mau => g_global2_currency_mau ) ;
3039
3040
3041 print_time(' Got global currency settings. ');
3042 print_time(' g_currency_conversion_rule ' || g_currency_conversion_rule || ' g_prorating_format ' || g_prorating_format );
3043 print_time(' g_global1_currency_code ' || g_global1_currency_code || ' g_global2_currency_code ' || g_global2_currency_code );
3044 print_time(' g_global1_currency_mau ' || g_global1_currency_mau || ' g_global2_currency_mau ' || g_global2_currency_mau ) ;
3045 -- cbs change -- Bug 13736073
3046 IF P_PA_DEBUG_MODE = 'Y' THEN
3047 pa_debug.write('EXTRACT_PLAN_AMTS_PRIRBS_GLC12: ' || g_module_name,'Before calling SET_RES_CLASS_FLAG' ,1);
3048 END IF;
3049
3050 PJI_FM_PLAN_MAINT_PVT.SET_RES_CLASS_FLAG;
3051
3052 IF P_PA_DEBUG_MODE = 'Y' THEN
3053 pa_debug.write('EXTRACT_PLAN_AMTS_PRIRBS_GLC12: ' || g_module_name,'After calling SET_RES_CLASS_FLAG' ,1);
3054 END IF;
3055 -- End cbs change
3056
3057 INSERT INTO PJI_FP_AGGR_PJP1_T
3058 (
3059 WORKER_ID
3060 , PROJECT_ID
3061 , PROJECT_ORG_ID
3062 , PROJECT_ORGANIZATION_ID
3063 , PROJECT_ELEMENT_ID
3064 , TIME_ID
3065 , PERIOD_TYPE_ID
3066 , CALENDAR_TYPE
3067 , RBS_AGGR_LEVEL
3068 , WBS_ROLLUP_FLAG
3069 , PRG_ROLLUP_FLAG
3070 , CURR_RECORD_TYPE_ID
3071 , CURRENCY_CODE
3072 , RBS_ELEMENT_ID
3073 , RBS_VERSION_ID
3074 , PLAN_VERSION_ID
3075 , PLAN_TYPE_ID
3076 , RAW_COST
3077 , BRDN_COST
3078 , REVENUE
3079 , BILL_RAW_COST
3080 , BILL_BRDN_COST
3081 , BILL_LABOR_RAW_COST
3082 , BILL_LABOR_BRDN_COST
3083 , BILL_LABOR_HRS
3084 , EQUIPMENT_RAW_COST
3085 , EQUIPMENT_BRDN_COST
3086 , CAPITALIZABLE_RAW_COST
3087 , CAPITALIZABLE_BRDN_COST
3088 , LABOR_RAW_COST
3089 , LABOR_BRDN_COST
3090 , LABOR_HRS
3091 , LABOR_REVENUE
3092 , EQUIPMENT_HOURS
3093 , BILLABLE_EQUIPMENT_HOURS
3094 , SUP_INV_COMMITTED_COST
3095 , PO_COMMITTED_COST
3096 , PR_COMMITTED_COST
3097 , OTH_COMMITTED_COST
3098 , ACT_LABOR_HRS
3099 , ACT_EQUIP_HRS
3100 , ACT_LABOR_BRDN_COST
3101 , ACT_EQUIP_BRDN_COST
3102 , ACT_BRDN_COST
3103 , ACT_RAW_COST
3104 , ACT_REVENUE
3105 , ACT_LABOR_RAW_COST
3106 , ACT_EQUIP_RAW_COST
3107 , ETC_LABOR_HRS
3108 , ETC_EQUIP_HRS
3109 , ETC_LABOR_BRDN_COST
3110 , ETC_EQUIP_BRDN_COST
3111 , ETC_BRDN_COST
3112 , ETC_RAW_COST
3113 , ETC_LABOR_RAW_COST
3114 , ETC_EQUIP_RAW_COST
3115 , CUSTOM1
3116 , CUSTOM2
3117 , CUSTOM3
3118 , CUSTOM4
3119 , CUSTOM5
3120 , CUSTOM6
3121 , CUSTOM7
3122 , CUSTOM8
3123 , CUSTOM9
3124 , CUSTOM10
3125 , CUSTOM11
3126 , CUSTOM12
3127 , CUSTOM13
3128 , CUSTOM14
3129 , CUSTOM15
3130 , LINE_TYPE
3131 , RATE_DANGLING_FLAG
3132 , TIME_DANGLING_FLAG
3133 , START_DATE
3134 , END_DATE
3135 , PRG_LEVEL
3136 , PLAN_TYPE_CODE
3137 )
3138 SELECT
3139 g_worker_id WORKER_ID
3140 , plr.PROJECT_ID
3141 , plr.PROJECT_ORG_ID
3142 , plr.project_ORGANIZATION_ID
3143 , plr.WBS_ELEMENT_ID
3144 , plr.time_id
3145 , plr.period_type_id -- period type id...
3146 , plr.CALENDAR_TYPE
3147 , g_lowest_level RBS_AGGR_LEVEL
3148 , 'N' WBS_ROLLUP_FLAG
3149 , 'N' PRG_ROLLUP_FLAG
3150 , plr.CURR_RECORD_TYPE
3151 , plr.currency_code
3152 , plr.RBS_ELEMENT_ID
3153 , plr.RBS_STRUCT_VERSION_ID
3154 , plr.plan_version_id
3155 , plr.plan_type_id
3156 , SUM(plr.RAW_COST)
3157 , SUM(plr.BRDN_COST)
3158 , SUM(plr.REVENUE)
3159 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) BILL_RAW_COST
3160 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) BILL_BRDN_COST
3161 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_people_resclass_code, plr.raw_cost, 0 ) ) BILL_LABOR_RAW_COST
3162 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_people_resclass_code , plr.BRDN_COST, 0 ) ) BILL_LABOR_BRDN_COST
3163 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'Y' || g_people_resclass_code, plr.quantity, 0 ) ) BILL_LABOR_HRS */ -- bug 6039785
3164 , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'Y' || g_people_resclass_code,
3165 DECODE(plr.billable_flag,'Y',plr.quantity,0), 0 ) ) BILL_LABOR_HRS -- bug 6039785
3166 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code , plr.raw_cost, 0 ) ) EQUIPMENT_RAW_COST
3167 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code , plr.BRDN_COST, 0 ) ) EQUIPMENT_BRDN_COST
3168 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) CAPITALIZABLE_RAW_COST
3169 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) CAPITALIZABLE_BRDN_COST
3170 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.raw_cost, 0 ) ) LABOR_RAW_COST
3171 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.BRDN_COST, 0 ) ) LABOR_BRDN_COST
3172 /* , SUM ( DECODE ( plr.resource_class, g_people_resclass_code,
3173 DECODE ( vers.wp_flag, 'N',
3174 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
3175 plr.quantity),
3176 0 ) ) labor_hrs */ -- bug 6039785
3177 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, DECODE(plr.billable_flag ,'Y',
3178 DECODE ( vers.wp_flag, 'N',
3179 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
3180 plr.quantity),
3181 0 ),
3182 0 ) ) labor_hrs -- bug 6039785
3183 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.revenue, 0 ) ) LABOR_REVENUE
3184 /* , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code,
3185 DECODE ( vers.wp_flag, 'N',
3186 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
3187 plr.quantity),
3188
3189 0 ) ) EQUIPMENT_HOURS */ -- bug 6039785
3190 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code, DECODE(plr.billable_flag ,'Y',
3191 DECODE ( vers.wp_flag, 'N',
3192 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
3193 plr.quantity),
3194 0 ),
3195 0 ) ) EQUIPMENT_HOURS -- bug 6039785
3196 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_equip_resclass_code, plr.quantity, 0 ) ) BILLABLE_EQUIPMENT_HOURS */ -- bug 6039785
3197 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_equip_resclass_code,
3198 DECODE(plr.billable_flag,'Y',plr.quantity,0), 0 ) ) BILLABLE_EQUIPMENT_HOURS -- bug 6039785
3199 , TO_NUMBER(NULL) SUP_INV_COMMITTED_COST
3200 , TO_NUMBER(NULL) PO_COMMITTED_COST
3201 , TO_NUMBER(NULL) PR_COMMITTED_COST
3202 , TO_NUMBER(NULL) OTH_COMMITTED_COST
3203 /* , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
3204 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
3205 0 ) ) ) ACT_LABOR_HRS */ -- bug 6039785
3206 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
3207 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
3208 0 ) ) ) ACT_LABOR_HRS -- bug 6039785
3209 /* , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
3210 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
3211 0 ) ) ) ACT_EQUIP_HOURS */ -- bug 6039785
3212 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
3213 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
3214 0 ) ) ) ACT_EQUIP_HOURS -- bug 6039785
3215 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.actual_BRDN_COST, 0 ) ) ) ACT_LABOR_BRDN_COST
3216 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.actual_BRDN_COST, 0 ) ) ) ACT_EQUIPMENT_BRDN_COST
3217 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, plr.actual_brdn_cost ) ) ACT_BRDN_COST
3218 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, plr.actual_raw_cost ) ) ACT_RAW_COST
3219 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, plr.actual_revenue ) ) ACT_REVENUE
3220 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.actual_RAW_COST, 0 ) ) ) ACT_LABOR_RAW_COST
3221 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.actual_RAW_COST, 0 ) ) ) ACT_EQUIPMENT_RAW_COST
3222 /* , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
3223 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
3224 0 ) ) ) ETC_LABOR_HRS */ -- bug 6039785
3225 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
3226 DECODE (plr.billable_flag ,'Y',
3227 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
3228 0 ),
3229 0 ) ) ) ETC_LABOR_HRS -- bug 6039785
3230 /* , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
3231 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
3232 0 ) ) ) ETC_EQUIP_HOURS */ -- bug 6039785
3233 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
3234 DECODE (plr.billable_flag ,'Y',
3235 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
3236 0 ),
3237 0 ) ) ) ETC_EQUIP_HOURS -- bug 6039785
3238 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.etc_BRDN_COST, 0 ) ) ) ETC_LABOR_BRDN_COST
3239 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.etc_BRDN_COST, 0 ) ) ) ETC_EQUIP_BRDN_COST
3240 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, plr.etc_brdn_cost ) ) ETC_BRDN_COST
3241 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, plr.etc_raw_cost ) ) ETC_RAW_COST
3242 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.etc_raw_COST, 0 ) ) ) ETC_LABOR_raw_COST
3243 , SUM ( DECODE ( vers.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.etc_raw_COST, 0 ) ) ) ETC_EQUIP_raw_COST
3244 , TO_NUMBER(NULL) CUSTOM1
3245 , TO_NUMBER(NULL) CUSTOM2
3246 , TO_NUMBER(NULL) CUSTOM3
3247 , TO_NUMBER(NULL) CUSTOM4
3248 , TO_NUMBER(NULL) CUSTOM5
3249 , TO_NUMBER(NULL) CUSTOM6
3250 , TO_NUMBER(NULL) CUSTOM7
3251 , TO_NUMBER(NULL) CUSTOM8
3252 , TO_NUMBER(NULL) CUSTOM9
3253 , TO_NUMBER(NULL) CUSTOM10
3254 , TO_NUMBER(NULL) CUSTOM11
3255 , TO_NUMBER(NULL) CUSTOM12
3256 , TO_NUMBER(NULL) CUSTOM13
3257 , TO_NUMBER(NULL) CUSTOM14
3258 , TO_NUMBER(NULL) CUSTOM15
3259 , plr.LINE_TYPE
3260 , NULL time_dangling_flag
3261 , decode(sign(plr.rate),-1,'Y',NULL) ||decode(sign(plr.rate2),-1,'Y',NULL) rate_dangling_flag
3262 , plr.start_date
3263 , plr.end_date
3264 , g_default_prg_level prg_level
3265 , plr.plan_type_code plan_type_code /* 4471527 */
3266 FROM
3267 ( ----- First inline view plr .............
3268 select
3269 collapse_bl.PROJECT_ID -- , 1 partition_id
3270 , collapse_bl.WBS_ELEMENT_ID -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
3271 , SUM(collapse_bl.CURR_RECORD_TYPE_ID) CURR_RECORD_TYPE
3272 , collapse_bl.RBS_ELEMENT_ID
3273 , collapse_bl.RBS_STRUCT_VERSION_ID
3274 , collapse_bl.plan_type_id
3275 , collapse_bl.plan_version_id
3276 , collapse_bl.time_id
3277 , collapse_bl.PROJECT_ORGANIZATION_ID
3278 , collapse_bl.PROJECT_ORG_ID
3279 , collapse_bl.RESOURCE_ASSIGNMENT_ID
3280 , collapse_bl.BILLABLE_FLAG
3281 , collapse_bl.RESOURCE_CLASS -- , CALENDAR_TYPE -- , CALENDAR_ID
3282 , collapse_bl.TIME_PHASED_TYPE_CODE
3283 , collapse_bl.CURRENCY_CODE
3284 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.raw_cost))) raw_cost
3285 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.BRDN_COST))) BRDN_COST
3286 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.revenue))) revenue
3287 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.actual_raw_cost))) actual_raw_cost
3288 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.actual_BRDN_COST))) actual_BRDN_COST
3289 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.actual_revenue))) actual_revenue
3290 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.etc_raw_cost))) etc_raw_cost
3291 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.etc_BRDN_COST))) etc_BRDN_COST
3292 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.etc_revenue))) etc_revenue
3293 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.quantity))) quantity
3294 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.actual_quantity))) actual_quantity
3295 , decode(sign(collapse_bl.rate),-1,0,decode(sign(collapse_bl.rate2),-1,0,max(collapse_bl.etc_quantity))) etc_quantity
3296 , collapse_bl.start_date start_date
3297 , collapse_bl.end_date end_date
3298 -- , collapse_bl.period_name period_name -- , TRACK_AS_LABOR_FLAG track_as_labor_flag
3299 , collapse_bl.line_type
3300 , collapse_bl.calendar_type
3301 , collapse_bl.period_type_id
3302 , collapse_bl.row_id
3303 ,collapse_bl.rate rate
3304 ,collapse_bl.rate2 rate2
3305 ,collapse_bl.plan_type_code plan_type_code /* 4471527 */
3306 from
3307 ( ----- Second inline view 'collapse_bl' begin .............
3308 select
3309 spread_bl.row_id row_id
3310 , spread_bl.PROJECT_ID
3311 , spread_bl.BUDGET_VERSION_ID plan_version_id
3312 , spread_bl.time_id
3313 , spread_bl.RESOURCE_ASSIGNMENT_ID
3314 , spread_bl.WBS_ELEMENT_ID
3315 , spread_bl.RBS_ELEMENT_ID
3316 , spread_bl.WBS_STRUCT_VERSION_ID
3317 , spread_bl.RBS_STRUCT_VERSION_ID
3318 , spread_bl.plan_type_id
3319 , spread_bl.BILLABLE_FLAG
3320 , spread_bl.RESOURCE_CLASS
3321 , spread_bl.PROJECT_ORGANIZATION_ID
3322 , spread_bl.PROJECT_ORG_ID
3323 , spread_bl.TIME_PHASED_TYPE_CODE
3324 , DECODE( invert.INVERT_ID
3325 , 1, spread_bl.glb1_CURRENCY_CODE
3326 , 2, spread_bl.glb2_CURRENCY_CODE
3327 , 4, spread_bl.func_CURRENCY_CODE
3328 , 8, spread_bl.PRJ_CURRENCY_CODE
3329 , 16, spread_bl.TXN_CURRENCY_CODE ) CURRENCY_CODE
3330 , invert.INVERT_ID CURR_RECORD_TYPE_ID
3331 , DECODE ( invert.INVERT_ID
3332 , 1, spread_bl.glb1_raw_cost
3333 , 2, spread_bl.glb2_raw_cost
3334 , 4, spread_bl.func_raw_cost
3335 , 8, spread_bl.PRJ_raw_cost
3336 , 16, spread_bl.TXN_raw_cost) raw_cost
3337 , DECODE ( invert.INVERT_ID
3338 , 1, spread_bl.glb1_brdn_cost
3339 , 2, spread_bl.glb2_brdn_cost
3340 , 4, spread_bl.func_BRDN_COST
3341 , 8, spread_bl.PRJ_BRDN_COST
3342 , 16, spread_bl.TXN_BRDN_COST ) BRDN_COST
3343 , DECODE ( invert.INVERT_ID
3344 , 1, spread_bl.glb1_revenue
3345 , 2, spread_bl.glb2_revenue
3346 , 4, spread_bl.func_revenue
3347 , 8, spread_bl.PRJ_revenue
3348 , 16, spread_bl.TXN_revenue ) revenue
3349 , DECODE ( invert.INVERT_ID
3350 , 1, spread_bl.glb1_actual_raw_cost
3351 , 2, spread_bl.glb2_actual_raw_cost
3352 , 4, spread_bl.func_actual_raw_cost
3353 , 8, spread_bl.prj_actual_raw_cost
3354 , 16, spread_bl.txn_actual_raw_cost ) actual_raw_cost
3355 , DECODE ( invert.INVERT_ID
3356 , 1, spread_bl.glb1_actual_brdn_cost
3357 , 2, spread_bl.glb2_actual_brdn_cost
3358 , 4, spread_bl.func_actual_brdn_cost
3359 , 8, spread_bl.prj_actual_brdn_cost
3360 , 16, spread_bl.txn_actual_brdn_cost ) actual_brdn_cost
3361 , DECODE ( invert.INVERT_ID
3362 , 1, spread_bl.glb1_actual_revenue
3363 , 2, spread_bl.glb2_actual_revenue
3364 , 4, spread_bl.func_actual_revenue
3365 , 8, spread_bl.prj_actual_revenue
3366 , 16, spread_bl.txn_actual_revenue ) actual_revenue
3367 , DECODE ( invert.INVERT_ID
3368 , 1, spread_bl.glb1_etc_raw_cost
3369 , 2, spread_bl.glb2_etc_raw_cost
3370 , 4, spread_bl.func_etc_raw_cost
3371 , 8, spread_bl.prj_etc_raw_cost
3372 , 16, spread_bl.txn_etc_raw_cost ) etc_raw_cost
3373 , DECODE ( invert.INVERT_ID
3374 , 1, spread_bl.glb1_etc_brdn_cost
3375 , 2, spread_bl.glb2_etc_brdn_cost
3376 , 4, spread_bl.func_etc_brdn_cost
3377 , 8, spread_bl.prj_etc_brdn_cost
3378 , 16, spread_bl.txn_etc_brdn_cost ) etc_brdn_cost
3379 , DECODE ( invert.INVERT_ID
3380 , 1, spread_bl.glb1_etc_revenue
3381 , 2, spread_bl.glb2_etc_revenue
3382 , 4, spread_bl.func_etc_revenue
3383 , 8, spread_bl.prj_etc_revenue
3384 , 16, spread_bl.txn_etc_revenue ) etc_revenue
3385 , spread_bl.quantity quantity
3386 , spread_bl.actual_quantity actual_quantity
3387 , spread_bl.etc_quantity etc_quantity
3388 , spread_bl.start_date start_date
3389 , spread_bl.end_date end_date
3390 , spread_bl.line_type line_type
3391 , spread_bl.period_type_id
3392 , spread_bl.calendar_type
3393 ,decode(invert.invert_id,1,spread_bl.rate,1) rate
3394 ,decode(invert.invert_id,2,spread_bl.rate2,1) rate2
3395 , spread_bl.plan_type_code plan_type_code /* 4471527 */
3396 from
3397 ( ----- Third inline view 'spread_bl' .............
3398 SELECT
3399 ra.project_id
3400 , bl.rowid row_id
3401 , ra.budget_version_id
3402 , prd.cal_period_id time_id
3403 , bl.resource_asSIGNment_id
3404 , DECODE(ra.task_id, 0, pevs.proj_element_id, ra.task_id) wbs_element_id
3405 , NVL(ra.rbs_element_id, -1) rbs_element_id
3406 , ver.wbs_struct_version_id wbs_struct_version_id
3407 , NVL(ver.rbs_struct_version_id, -1) rbs_struct_version_id
3408 , ver.plan_type_id plan_type_id
3409 , ra.rate_based_flag billable_flag
3410 -- cbs change --Bug 13736073
3411 , decode(PJI_FM_PLAN_MAINT_PVT.g_res_class_flag,'N',decode(PJI_FM_PLAN_MAINT_PVT.get_res_class_flag(ra.budget_version_id), 'N',
3412 '1'||ra.resource_class_code, ra.resource_class_code),ra.resource_class_code) resource_class
3413 -- End cbs change
3414 , DECODE(ver.time_phased_type_code
3415 , g_pa_cal_str, 32
3416 , g_gl_cal_str, 32
3417 , 'N', 2048
3418 , -1) period_type_id
3419 , DECODE(ver.time_phased_type_code
3420 , g_pa_cal_str, g_pa_cal_str
3421 , g_gl_cal_str, g_gl_cal_str
3422 , 'N', g_all
3423 , 'X') CALENDAR_TYPE
3424 , bl.txn_currency_code txn_currency_code
3425 , bl.txn_raw_cost txn_raw_cost
3426 , bl.txn_burdened_COST txn_brdn_COST
3427 , bl.txn_revenue txn_revenue
3428 , DECODE(ver.wp_flag, 'N', bl.txn_init_raw_cost, TO_NUMBER(NULL)) txn_actual_raw_cost -- new
3429 , DECODE(ver.wp_flag, 'N', bl.txn_init_burdened_cost, TO_NUMBER(NULL)) txn_actual_brdn_cost -- new
3430 , DECODE(ver.wp_flag, 'N', bl.txn_init_revenue, TO_NUMBER(NULL)) txn_actual_revenue -- new
3431 , DECODE(ver.wp_flag, 'N', (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0)), TO_NUMBER(NULL)) txn_etc_raw_cost -- new
3432 , DECODE(ver.wp_flag, 'N', (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0)), TO_NUMBER(NULL)) txn_etc_brdn_cost -- new
3433 , DECODE(ver.wp_flag, 'N', (bl.txn_revenue - NVL(bl.txn_init_revenue, 0)), TO_NUMBER(NULL)) txn_etc_revenue -- new
3434 , bl.project_currency_code prj_currency_code
3435 , bl.project_raw_cost prj_raw_cost
3436 , bl.project_burdened_COST prj_BRDN_COST
3437 , bl.project_revenue prj_revenue
3438 , DECODE(ver.wp_flag, 'N', bl.project_init_raw_cost, TO_NUMBER(NULL)) prj_actual_raw_cost -- new
3439 , DECODE(ver.wp_flag, 'N', bl.project_init_burdened_cost, TO_NUMBER(NULL)) prj_actual_brdn_cost -- new
3440 , DECODE(ver.wp_flag, 'N', bl.project_init_revenue, TO_NUMBER(NULL)) prj_actual_revenue -- new
3441 , DECODE(ver.wp_flag, 'N', (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0)), TO_NUMBER(NULL)) prj_etc_raw_cost -- new
3442 , DECODE(ver.wp_flag, 'N', (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0)), TO_NUMBER(NULL)) prj_etc_brdn_cost -- new
3443 , DECODE(ver.wp_flag, 'N', (bl.project_revenue - NVL(bl.project_init_revenue, 0)), TO_NUMBER(NULL)) prj_etc_revenue -- new
3444 , bl.projfunc_currency_code func_currency_code
3445 , bl.raw_cost func_raw_cost
3446 , bl.burdened_COST func_BRDN_COST
3447 , bl.revenue func_revenue
3448 , DECODE(ver.wp_flag, 'N', bl.init_raw_cost , TO_NUMBER(NULL)) func_actual_raw_cost -- new
3449 , DECODE(ver.wp_flag, 'N', bl.init_burdened_cost , TO_NUMBER(NULL)) func_actual_brdn_cost -- new
3450 , DECODE(ver.wp_flag, 'N', bl.init_revenue , TO_NUMBER(NULL)) func_actual_revenue -- new
3451 , DECODE(ver.wp_flag, 'N', (bl.raw_cost - NVL(bl.init_raw_cost, 0)), TO_NUMBER(NULL)) func_etc_raw_cost -- new
3452 , DECODE(ver.wp_flag, 'N', (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)), TO_NUMBER(NULL)) func_etc_brdn_cost -- new
3453 , DECODE(ver.wp_flag, 'N', (bl.revenue - NVL(bl.init_revenue, 0)), TO_NUMBER(NULL)) func_etc_revenue -- new
3454 , g_global1_currency_code glb1_currency_code -- g_global1_currency_code glb1_currency_code
3455 , DECODE (g_global1_currency_code
3456 , bl.txn_currency_code
3457 , bl.txn_raw_cost
3458 , bl.project_currency_code
3459 , bl.project_raw_cost
3460 , bl.projfunc_currency_code
3461 , bl.raw_cost
3462 , ROUND((rates.rate * raw_cost )/rates.mau)*rates.mau
3463 ) glb1_raw_cost
3464 , DECODE (g_global1_currency_code
3465 , bl.txn_currency_code
3466 , bl.txn_burdened_cost
3467 , bl.project_currency_code
3468 , bl.project_burdened_cost
3469 , bl.projfunc_currency_code
3470 , bl.burdened_cost
3471 , ROUND((rates.rate * burdened_cost )/rates.mau)*rates.mau
3472 ) glb1_BRDN_COST
3473 , DECODE (g_global1_currency_code
3474 , bl.txn_currency_code
3475 , bl.txn_revenue
3476 , bl.project_currency_code
3477 , bl.project_revenue
3478 , bl.projfunc_currency_code
3479 , bl.revenue
3480 , ROUND((rates.rate * revenue )/rates.mau)*rates.mau
3481 ) glb1_revenue
3482 , DECODE(ver.wp_flag
3483 , 'N'
3484 , DECODE (g_global1_currency_code
3485 , bl.txn_currency_code
3486 , bl.txn_init_raw_cost
3487 , bl.project_currency_code
3488 , bl.project_init_raw_cost
3489 , bl.projfunc_currency_code
3490 , bl.init_raw_cost
3491 , ROUND((rates.rate * bl.init_raw_cost )/rates.mau)*rates.mau
3492 )
3493 , NULL) glb1_actual_raw_cost
3494 , DECODE(ver.wp_flag
3495 , 'N'
3496 , DECODE (g_global1_currency_code
3497 , bl.txn_currency_code
3498 , bl.txn_init_burdened_cost
3499 , bl.project_currency_code
3500 , bl.project_init_burdened_cost
3501 , bl.projfunc_currency_code
3502 , bl.init_burdened_cost
3503 , ROUND((rates.rate * bl.init_burdened_cost )/rates.mau)*rates.mau
3504 )
3505 , NULL) glb1_actual_brdn_cost
3506 , DECODE(ver.wp_flag
3507 , 'N'
3508 , DECODE (g_global1_currency_code
3509 , bl.txn_currency_code
3510 , bl.txn_init_revenue
3511 , bl.project_currency_code
3512 , bl.project_init_revenue
3513 , bl.projfunc_currency_code
3514 , bl.init_revenue
3515 , ROUND((rates.rate * bl.init_revenue )/rates.mau)*rates.mau
3516 )
3517 , NULL) glb1_actual_revenue
3518 , DECODE(ver.wp_flag
3519 , 'N'
3520 , DECODE (g_global1_currency_code
3521 , bl.txn_currency_code
3522 , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0))
3523 , bl.project_currency_code
3524 , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0))
3525 , bl.projfunc_currency_code
3526 , (bl.raw_cost - NVL(bl.init_raw_cost, 0))
3527 , ROUND((rates.rate * (bl.raw_cost - NVL(bl.init_raw_cost, 0)) )/rates.mau)*rates.mau
3528 )
3529 , NULL) glb1_etc_raw_cost
3530 , DECODE(ver.wp_flag
3531 , 'N'
3532 , DECODE (g_global1_currency_code
3533 , bl.txn_currency_code
3534 , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0))
3535 , bl.project_currency_code
3536 , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0))
3537 , bl.projfunc_currency_code
3538 , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0))
3539 , ROUND((rates.rate * (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)) )/rates.mau)*rates.mau
3540 )
3541 , NULL) glb1_etc_brdn_cost
3542 , DECODE(ver.wp_flag
3543 , 'N'
3544 , DECODE (g_global1_currency_code
3545 , bl.txn_currency_code
3546 , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0))
3547 , bl.project_currency_code
3548 , (bl.project_revenue - NVL(bl.project_init_revenue, 0))
3549 , bl.projfunc_currency_code
3550 , (bl.revenue - NVL(bl.init_revenue, 0))
3551 , ROUND((rates.rate * (bl.revenue - NVL(bl.init_revenue, 0)) )/rates.mau)*rates.mau
3552 )
3553 , NULL) glb1_etc_revenue
3554 , g_global2_currency_code glb2_currency_code -- g_global2_currency_code glb2_currency_code
3555 , DECODE (g_global2_currency_code
3556 , bl.txn_currency_code
3557 , bl.txn_raw_cost
3558 , bl.project_currency_code
3559 , bl.project_raw_cost
3560 , bl.projfunc_currency_code
3561 , bl.raw_cost
3562 , ROUND((rates.rate2 * raw_cost )/rates.mau2)*rates.mau2
3563 ) glb2_raw_cost
3564 , DECODE (g_global2_currency_code
3565 , bl.txn_currency_code
3566 , bl.txn_burdened_cost
3567 , bl.project_currency_code
3568 , bl.project_burdened_cost
3569 , bl.projfunc_currency_code
3570 , bl.burdened_cost
3571 , ROUND((rates.rate2 * burdened_cost )/rates.mau2)*rates.mau2
3572 ) glb2_BRDN_COST
3573 , DECODE (g_global2_currency_code
3574 , bl.txn_currency_code
3575 , bl.txn_revenue
3576 , bl.project_currency_code
3577 , bl.project_revenue
3578 , bl.projfunc_currency_code
3579 , bl.revenue
3580 , ROUND((rates.rate2 * revenue )/rates.mau2)*rates.mau2
3581 ) glb2_revenue
3582 , DECODE(ver.wp_flag
3583 , 'N'
3584 , DECODE (g_global2_currency_code
3585 , bl.txn_currency_code
3586 , bl.txn_init_raw_cost
3587 , bl.project_currency_code
3588 , bl.project_init_raw_cost
3589 , bl.projfunc_currency_code
3590 , bl.init_raw_cost
3591 , ROUND((rates.rate2 * bl.init_raw_cost )/rates.mau2)*rates.mau2
3592 )
3593 , TO_NUMBER(NULL)) glb2_actual_raw_cost
3594 , DECODE(ver.wp_flag
3595 , 'N'
3596 , DECODE (g_global2_currency_code
3597 , bl.txn_currency_code
3598 , bl.txn_init_burdened_cost
3599 , bl.project_currency_code
3600 , bl.project_init_burdened_cost
3601 , bl.projfunc_currency_code
3602 , bl.init_burdened_cost
3603 , ROUND((rates.rate2 * bl.init_burdened_cost )/rates.mau2)*rates.mau2
3604 )
3605 , TO_NUMBER(NULL)) glb2_actual_brdn_cost
3606 , DECODE(ver.wp_flag
3607 , 'N'
3608 , DECODE (g_global2_currency_code
3609 , bl.txn_currency_code
3610 , bl.txn_init_revenue
3611 , bl.project_currency_code
3612 , bl.project_init_revenue
3613 , bl.projfunc_currency_code
3614 , bl.init_revenue
3615 , ROUND((rates.rate2 * bl.init_revenue )/rates.mau2)*rates.mau2
3616 )
3617 , TO_NUMBER(NULL)) glb2_actual_revenue
3618 , DECODE(ver.wp_flag
3619 , 'N'
3620 , DECODE (g_global2_currency_code
3621 , bl.txn_currency_code
3622 , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0))
3623 , bl.project_currency_code
3624 , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0))
3625 , bl.projfunc_currency_code
3626 , (bl.raw_cost - NVL(bl.init_raw_cost, 0))
3627 , ROUND((rates.rate2 * (bl.raw_cost - NVL(bl.init_raw_cost, 0)) )/rates.mau2)*rates.mau2
3628 )
3629 , TO_NUMBER(NULL)) glb2_etc_raw_cost
3630 , DECODE(ver.wp_flag
3631 , 'N'
3632 , DECODE (g_global2_currency_code
3633 , bl.txn_currency_code
3634 , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0))
3635 , bl.project_currency_code
3636 , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0))
3637 , bl.projfunc_currency_code
3638 , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0))
3639 , ROUND((rates.rate2 * (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)) )/rates.mau2)*rates.mau2
3640 )
3641 , TO_NUMBER(NULL)) glb2_etc_brdn_cost
3642 , DECODE(ver.wp_flag
3643 , 'N'
3644 , DECODE (g_global2_currency_code
3645 , bl.txn_currency_code
3646 , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0))
3647 , bl.project_currency_code
3648 , (bl.project_revenue - NVL(bl.project_init_revenue, 0))
3649 , bl.projfunc_currency_code
3650 , (bl.revenue - NVL(bl.init_revenue, 0))
3651 , ROUND((rates.rate2 * (bl.revenue - NVL(bl.init_revenue, 0)) )/rates.mau2)*rates.mau2
3652 )
3653 , TO_NUMBER(NULL)) glb2_etc_revenue
3654 , bl.quantity quantity
3655 , DECODE(ver.wp_flag, 'N', bl.init_quantity, TO_NUMBER(NULL)) actual_quantity -- new
3656 , DECODE(ver.wp_flag, 'N', (bl.quantity - NVL(bl.init_quantity, 0)), TO_NUMBER(NULL)) etc_quantity -- new
3657 , TO_DATE(NULL) start_date -- bl.start_date
3658 , TO_DATE(NULL) end_date -- bl.END_date
3659 , ver.time_phased_type_code time_phased_type_code
3660 , ppa.org_id project_org_id
3661 , ppa.carrying_out_organization_id project_organization_id
3662 , DECODE(ver.time_phased_type_code, g_pa_cal_str, 'OF', g_gl_cal_str, 'OF', 'N', 'NTP', 'X') line_type
3663 ,decode(ver.rate_dangling_flag,'Y',-1,1) rate
3664 ,decode(ver.rate_dangling_flag,'Y',-1,1) rate2
3665 , ver.plan_type_code plan_type_code /* 4471527 */
3666 FROM
3667 PA_BUDGET_LINES bl
3668 , pa_resource_asSIGNments ra
3669 , PJI_FM_EXTR_PLNVER3_T ver
3670 , pa_projects_all ppa
3671 , PA_PROJ_ELEM_VER_STRUCTURE pevs
3672 , PJI_FM_AGGR_DLY_RATES_T rates
3673 , pji_time_cal_period_v prd
3674 , PJI_ORG_EXTR_INFO oei
3675 WHERE 1=1
3676 AND ra.resource_asSIGNment_id = bl.resource_asSIGNment_id
3677 AND ra.project_id = ver.PROJECT_ID
3678 AND ra.budget_version_id = ver.plan_version_id
3679 AND ver.project_id = ppa.project_id
3680 AND txn_currency_code IS NOT NULL
3681 AND bl.project_currency_code IS NOT NULL
3682 AND bl.projfunc_currency_code IS NOT NULL
3683 AND pevs.element_version_id = ver.wbs_struct_version_id
3684 AND ver.secondary_rbs_flag = 'N'
3685 AND ver.wp_flag = 'N'
3686 AND oei.org_id = ppa.org_id
3687 AND ver.time_phased_type_code IN (g_pa_cal_str, g_gl_cal_str)
3688 AND DECODE ( ver.time_phased_type_code
3689 , g_pa_cal_str, oei.pa_calendar_id
3690 , g_gl_cal_str, oei.gl_calendar_id) = prd.calendar_id
3691 AND bl.period_name = prd.name
3692 AND rates.time_id = prd.cal_period_id
3693 -- AND DECODE(ra.task_id, 0, pevs.proj_element_id, ra.task_id) = 7474
3694 -- AND ra.rbs_element_id = 10266
3695 -- AND ver.plan_version_id = 2909
3696 AND ver.project_id = pevs.project_id -- Fix for bug : 4149422 in EXTRACT_PLAN_AMTS_PRIRBS_GLC12
3697 UNION ALL
3698 SELECT
3699 ra.project_id
3700 , bl.rowid row_id
3701 , ra.budget_version_id
3702 , -1 time_id
3703 , bl.resource_asSIGNment_id
3704 , DECODE(ra.task_id, 0, pevs.proj_element_id, ra.task_id) wbs_element_id
3705 , NVL(ra.rbs_element_id, -1) rbs_element_id
3706 , ver.wbs_struct_version_id wbs_struct_version_id
3707 , NVL(ver.rbs_struct_version_id, -1) rbs_struct_version_id
3708 , ver.plan_type_id plan_type_id
3709 , ra.rate_based_flag billable_flag
3710 -- cbs change -- Bug 13736073
3711 , decode(PJI_FM_PLAN_MAINT_PVT.g_res_class_flag,'N',decode(PJI_FM_PLAN_MAINT_PVT.get_res_class_flag(ra.budget_version_id), 'N',
3712 '1'||ra.resource_class_code, ra.resource_class_code),ra.resource_class_code) resource_class
3713 -- End cbs change
3714 , 2048 period_type_id
3715 , g_all CALENDAR_TYPE
3716 , bl.txn_currency_code txn_currency_code
3717 , bl.txn_raw_cost txn_raw_cost
3718 , bl.txn_burdened_COST txn_brdn_COST
3719 , bl.txn_revenue txn_revenue
3720 , DECODE(ver.wp_flag, 'N' , bl.txn_init_raw_cost, TO_NUMBER(NULL)) txn_actual_raw_cost -- new
3721 , DECODE(ver.wp_flag, 'N' , bl.txn_init_burdened_cost, TO_NUMBER(NULL)) txn_actual_brdn_cost -- new
3722 , DECODE(ver.wp_flag, 'N' , bl.txn_init_revenue, TO_NUMBER(NULL)) txn_actual_revenue -- new
3723 , DECODE(ver.wp_flag, 'N' , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0)), TO_NUMBER(NULL)) txn_etc_raw_cost -- new
3724 , DECODE(ver.wp_flag, 'N' , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0)), TO_NUMBER(NULL)) txn_etc_brdn_cost -- new
3725 , DECODE(ver.wp_flag, 'N' , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0)), TO_NUMBER(NULL)) txn_etc_revenue -- new
3726 , bl.project_currency_code prj_currency_code
3727 , bl.project_raw_cost prj_raw_cost
3728 , bl.project_burdened_COST prj_BRDN_COST
3729 , bl.project_revenue prj_revenue
3730 , DECODE(ver.wp_flag, 'N' , bl.project_init_raw_cost, TO_NUMBER(NULL)) prj_actual_raw_cost -- new
3731 , DECODE(ver.wp_flag, 'N' , bl.project_init_burdened_cost, TO_NUMBER(NULL)) prj_actual_brdn_cost -- new
3732 , DECODE(ver.wp_flag, 'N' , bl.project_init_revenue, TO_NUMBER(NULL)) prj_actual_revenue -- new
3733 , DECODE(ver.wp_flag, 'N' , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0)), TO_NUMBER(NULL)) prj_etc_raw_cost -- new
3734 , DECODE(ver.wp_flag, 'N' , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0)), TO_NUMBER(NULL)) prj_etc_brdn_cost -- new
3735 , DECODE(ver.wp_flag, 'N' , (bl.project_revenue - NVL(bl.project_init_revenue, 0)), TO_NUMBER(NULL)) prj_etc_revenue -- new
3736 , bl.projfunc_currency_code func_currency_code
3737 , bl.raw_cost func_raw_cost
3738 , bl.burdened_COST func_BRDN_COST
3739 , bl.revenue func_revenue
3740 , DECODE(ver.wp_flag, 'N' , bl.init_raw_cost , TO_NUMBER(NULL)) func_actual_raw_cost -- new
3741 , DECODE(ver.wp_flag, 'N' , bl.init_burdened_cost , TO_NUMBER(NULL)) func_actual_brdn_cost -- new
3742 , DECODE(ver.wp_flag, 'N' , bl.init_revenue , TO_NUMBER(NULL)) func_actual_revenue -- new
3743 , DECODE(ver.wp_flag, 'N' , (bl.raw_cost - NVL(bl.init_raw_cost, 0)), TO_NUMBER(NULL)) func_etc_raw_cost -- new
3744 , DECODE(ver.wp_flag, 'N' , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)), TO_NUMBER(NULL)) func_etc_brdn_cost -- new
3745 , DECODE(ver.wp_flag, 'N' , (bl.revenue - NVL(bl.init_revenue, 0)), TO_NUMBER(NULL)) func_etc_revenue -- new
3746 , g_global1_currency_code glb1_currency_code -- g_global1_currency_code glb1_currency_code
3747 , DECODE (g_global1_currency_code
3748 , bl.txn_currency_code
3749 , bl.txn_raw_cost
3750 , bl.project_currency_code
3751 , bl.project_raw_cost
3752 , bl.projfunc_currency_code
3753 , bl.raw_cost
3754 , ROUND((rates.rate * raw_cost )/rates.mau)*rates.mau
3755 ) glb1_raw_cost
3756 , DECODE (g_global1_currency_code
3757 , bl.txn_currency_code
3758 , bl.txn_burdened_cost
3759 , bl.project_currency_code
3760 , bl.project_burdened_cost
3761 , bl.projfunc_currency_code
3762 , bl.burdened_cost
3763 , ROUND((rates.rate * burdened_cost )/rates.mau)*rates.mau
3764 ) glb1_BRDN_COST
3765 , DECODE (g_global1_currency_code
3766 , bl.txn_currency_code
3767 , bl.txn_revenue
3768 , bl.project_currency_code
3769 , bl.project_revenue
3770 , bl.projfunc_currency_code
3771 , bl.revenue
3772 , ROUND((rates.rate * revenue )/rates.mau)*rates.mau
3773 ) glb1_revenue
3774 , DECODE(ver.wp_flag
3775 , 'N'
3776 , DECODE (g_global1_currency_code
3777 , bl.txn_currency_code
3778 , bl.txn_init_raw_cost
3779 , bl.project_currency_code
3780 , bl.project_init_raw_cost
3781 , bl.projfunc_currency_code
3782 , bl.init_raw_cost
3783 , ROUND((rates.rate * bl.init_raw_cost )/rates.mau)*rates.mau
3784 )
3785 , NULL) glb1_actual_raw_cost
3786 , DECODE(ver.wp_flag
3787 , 'N'
3788 , DECODE (g_global1_currency_code
3789 , bl.txn_currency_code
3790 , bl.txn_init_burdened_cost
3791 , bl.project_currency_code
3792 , bl.project_init_burdened_cost
3793 , bl.projfunc_currency_code
3794 , bl.init_burdened_cost
3795 , ROUND((rates.rate * bl.init_burdened_cost )/rates.mau)*rates.mau
3796 )
3797 , NULL) glb1_actual_brdn_cost
3798 , DECODE(ver.wp_flag
3799 , 'N'
3800 , DECODE (g_global1_currency_code
3801 , bl.txn_currency_code
3802 , bl.txn_init_revenue
3803 , bl.project_currency_code
3804 , bl.project_init_revenue
3805 , bl.projfunc_currency_code
3806 , bl.init_revenue
3807 , ROUND((rates.rate * bl.init_revenue )/rates.mau)*rates.mau
3808 )
3809 , NULL) glb1_actual_revenue
3810 , DECODE(ver.wp_flag
3811 , 'N'
3812 , DECODE (g_global1_currency_code
3813 , bl.txn_currency_code
3814 , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0))
3815 , bl.project_currency_code
3816 , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0))
3817 , bl.projfunc_currency_code
3818 , (bl.raw_cost - NVL(bl.init_raw_cost, 0))
3819 , ROUND((rates.rate * (bl.raw_cost - NVL(bl.init_raw_cost, 0)) )/rates.mau)*rates.mau
3820 )
3821 , NULL) glb1_etc_raw_cost
3822 , DECODE(ver.wp_flag
3823 , 'N'
3824 , DECODE (g_global1_currency_code
3825 , bl.txn_currency_code
3826 , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0))
3827 , bl.project_currency_code
3828 , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0))
3829 , bl.projfunc_currency_code
3830 , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0))
3831 , ROUND((rates.rate * (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)) )/rates.mau)*rates.mau
3832 )
3833 , NULL) glb1_etc_brdn_cost
3834 , DECODE(ver.wp_flag
3835 , 'N'
3836 , DECODE (g_global1_currency_code
3837 , bl.txn_currency_code
3838 , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0))
3839 , bl.project_currency_code
3840 , (bl.project_revenue - NVL(bl.project_init_revenue, 0))
3841 , bl.projfunc_currency_code
3842 , (bl.revenue - NVL(bl.init_revenue, 0))
3843 , ROUND((rates.rate * (bl.revenue - NVL(bl.init_revenue, 0)) )/rates.mau)*rates.mau
3844 )
3845 , NULL) glb1_etc_revenue
3846 , g_global2_currency_code glb2_currency_code -- g_global2_currency_code glb2_currency_code
3847 , DECODE (g_global2_currency_code
3848 , bl.txn_currency_code
3849 , bl.txn_raw_cost
3850 , bl.project_currency_code
3851 , bl.project_raw_cost
3852 , bl.projfunc_currency_code
3853 , bl.raw_cost
3854 , ROUND((rates.rate2 * raw_cost )/rates.mau2)*rates.mau2
3855 ) glb2_raw_cost
3856 , DECODE (g_global2_currency_code
3857 , bl.txn_currency_code
3858 , bl.txn_burdened_cost
3859 , bl.project_currency_code
3860 , bl.project_burdened_cost
3861 , bl.projfunc_currency_code
3862 , bl.burdened_cost
3863 , ROUND((rates.rate2 * burdened_cost )/rates.mau2)*rates.mau2
3864 ) glb2_BRDN_COST
3865 , DECODE (g_global2_currency_code
3866 , bl.txn_currency_code
3867 , bl.txn_revenue
3868 , bl.project_currency_code
3869 , bl.project_revenue
3870 , bl.projfunc_currency_code
3871 , bl.revenue
3872 , ROUND((rates.rate2 * revenue )/rates.mau2)*rates.mau2
3873 ) glb2_revenue
3874 , DECODE(ver.wp_flag
3875 , 'N'
3876 , DECODE (g_global2_currency_code
3877 , bl.txn_currency_code
3878 , bl.txn_init_raw_cost
3879 , bl.project_currency_code
3880 , bl.project_init_raw_cost
3881 , bl.projfunc_currency_code
3882 , bl.init_raw_cost
3883 , ROUND((rates.rate2 * bl.init_raw_cost )/rates.mau2)*rates.mau2
3884 )
3885 , TO_NUMBER(NULL)) glb2_actual_raw_cost
3886 , DECODE(ver.wp_flag
3887 , 'N'
3888 , DECODE (g_global2_currency_code
3889 , bl.txn_currency_code
3890 , bl.txn_init_burdened_cost
3891 , bl.project_currency_code
3892 , bl.project_init_burdened_cost
3893 , bl.projfunc_currency_code
3894 , bl.init_burdened_cost
3895 , ROUND((rates.rate2 * bl.init_burdened_cost )/rates.mau2)*rates.mau2
3896 )
3897 , TO_NUMBER(NULL)) glb2_actual_brdn_cost
3898 , DECODE(ver.wp_flag
3899 , 'N'
3900 , DECODE (g_global2_currency_code
3901 , bl.txn_currency_code
3902 , bl.txn_init_revenue
3903 , bl.project_currency_code
3904 , bl.project_init_revenue
3905 , bl.projfunc_currency_code
3906 , bl.init_revenue
3907 , ROUND((rates.rate2 * bl.init_revenue )/rates.mau2)*rates.mau2
3908 )
3909 , TO_NUMBER(NULL)) glb2_actual_revenue
3910 , DECODE(ver.wp_flag
3911 , 'N'
3912 , DECODE (g_global2_currency_code
3913 , bl.txn_currency_code
3914 , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0))
3915 , bl.project_currency_code
3916 , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0))
3917 , bl.projfunc_currency_code
3918 , (bl.raw_cost - NVL(bl.init_raw_cost, 0))
3919 , ROUND((rates.rate2 * (bl.raw_cost - NVL(bl.init_raw_cost, 0)) )/rates.mau2)*rates.mau2
3920 )
3921 , TO_NUMBER(NULL)) glb2_etc_raw_cost
3922 , DECODE(ver.wp_flag
3923 , 'N'
3924 , DECODE (g_global2_currency_code
3925 , bl.txn_currency_code
3926 , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0))
3927 , bl.project_currency_code
3928 , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0))
3929 , bl.projfunc_currency_code
3930 , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0))
3931 , ROUND((rates.rate2 * (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)) )/rates.mau2)*rates.mau2
3932 )
3933 , TO_NUMBER(NULL)) glb2_etc_brdn_cost
3934 , DECODE(ver.wp_flag
3935 , 'N'
3936 , DECODE (g_global2_currency_code
3937 , bl.txn_currency_code
3938 , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0))
3939 , bl.project_currency_code
3940 , (bl.project_revenue - NVL(bl.project_init_revenue, 0))
3941 , bl.projfunc_currency_code
3942 , (bl.revenue - NVL(bl.init_revenue, 0))
3943 , ROUND((rates.rate2 * (bl.revenue - NVL(bl.init_revenue, 0)) )/rates.mau2)*rates.mau2
3944 )
3945 , TO_NUMBER(NULL)) glb2_etc_revenue
3946 , bl.quantity quantity
3947 , DECODE(ver.wp_flag, 'N' , bl.init_quantity, TO_NUMBER(NULL)) actual_quantity -- new
3948 , DECODE(ver.wp_flag, 'N' , (bl.quantity - NVL(bl.init_quantity, 0)), TO_NUMBER(NULL)) etc_quantity -- new
3949 , ra.planning_start_date
3950 , ra.planning_END_date
3951 , ver.time_phased_type_code time_phased_type_code
3952 , ppa.org_id project_org_id
3953 , ppa.carrying_out_organization_id project_organization_id
3954 , 'NTP' line_type
3955 ,decode(ver.rate_dangling_flag,'Y',-1,1) rate
3956 ,decode(ver.rate_dangling_flag,'Y',-1,1) rate2
3957 , ver.plan_type_code plan_type_code /* 4471527 */
3958 FROM
3959 PA_BUDGET_LINES bl
3960 , pa_resource_asSIGNments ra
3961 , PJI_FM_EXTR_PLNVER3_T ver
3962 , pa_projects_all ppa
3963 , PA_PROJ_ELEM_VER_STRUCTURE pevs
3964 , PJI_FM_AGGR_DLY_RATES_T rates
3965 WHERE 1=1
3966 AND ra.resource_asSIGNment_id = bl.resource_asSIGNment_id
3967 AND ra.project_id = ver.PROJECT_ID
3968 AND ra.budget_version_id = ver.plan_version_id
3969 AND ver.project_id = ppa.project_id
3970 AND txn_currency_code IS NOT NULL
3971 AND bl.project_currency_code IS NOT NULL
3972 AND bl.projfunc_currency_code IS NOT NULL
3973 AND ver.project_id = pevs.project_id -- Fix for bug : 4149422 in EXTRACT_PLAN_AMTS_PRIRBS_GLC12
3974 AND pevs.element_version_id = ver.wbs_struct_version_id
3975 AND ver.secondary_rbs_flag = 'N'
3976 AND ver.wp_flag = 'N'
3977 AND ver.time_phased_type_code = 'N'
3978 AND rates.time_id = DECODE ( g_currency_conversion_rule
3979 , 'S'
3980 , TO_NUMBER(to_CHAR(ra.planning_start_date, 'J'))
3981 , 'E'
3982 , TO_NUMBER(to_CHAR(ra.planning_end_date, 'J')) )
3983 ) spread_bl
3984 ---- end of third inline view 'spread_bl'...........
3985 ,
3986 (
3987 select 1 INVERT_ID from dual where PJI_UTILS.GET_SETUP_PARAMETER('GLOBAL_CURR1_FLAG') = 'Y' union all /* Added for bug 8708651 */
3988 select 2 INVERT_ID from dual where PJI_UTILS.GET_SETUP_PARAMETER('GLOBAL_CURR2_FLAG') = 'Y' union all
3989 select 4 INVERT_ID from dual union all
3990 select 8 INVERT_ID from dual union all
3991 select 16 INVERT_ID from dual where PJI_UTILS.GET_SETUP_PARAMETER('TXN_CURR_FLAG') = 'Y'
3992 ) invert
3993 ) collapse_bl -- WHERE wbs_element_id = 7474 -- and rbs_element_id = 10266 -- and budget_version_id = 2909
3994 ---- End of second inline view 'collapse_bl' ..........
3995 GROUP BY
3996 collapse_bl.PROJECT_ID
3997 , collapse_bl.time_id
3998 , collapse_bl.WBS_ELEMENT_ID
3999 -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
4000 , collapse_bl.RBS_ELEMENT_ID
4001 , collapse_bl.RBS_STRUCT_VERSION_ID
4002 , collapse_bl.plan_type_id
4003 , collapse_bl.plan_version_id
4004 , collapse_bl.PROJECT_ORGANIZATION_ID
4005 , collapse_bl.PROJECT_ORG_ID
4006 , collapse_bl.RESOURCE_ASSIGNMENT_ID
4007 , collapse_bl.BILLABLE_FLAG
4008 , collapse_bl.RESOURCE_CLASS
4009 , collapse_bl.TIME_PHASED_TYPE_CODE
4010 , collapse_bl.CURRENCY_CODE
4011 , collapse_bl.start_date
4012 , collapse_bl.end_date
4013 , collapse_bl.row_id
4014 , collapse_bl.line_type
4015 , collapse_bl.calendar_type
4016 , collapse_bl.period_type_id
4017 ,collapse_bl.rate
4018 ,collapse_bl.rate2
4019 ,collapse_bl.plan_type_code /* 4471527 */
4020 ) plr
4021 ---- End of first inline view plr ..........
4022 , pji_fm_extr_plnver3_t vers
4023 WHERE 1=1
4024 AND vers.plan_version_id = plr.plan_version_id
4025 AND vers.plan_type_code = plr.plan_type_code /*4471527 */
4026 AND NVL(vers.rbs_struct_version_id, -1) = plr.rbs_struct_version_id
4027 -- AND plr.CURR_RECORD_TYPE IS NOT NULL
4028 AND plr.currency_code IS NOT NULL
4029 GROUP BY
4030 plr.PROJECT_ID
4031 , plr.PROJECT_ORG_ID
4032 , plr.project_ORGANIZATION_ID
4033 , plr.WBS_ELEMENT_ID
4034 , plr.time_id
4035 , plr.period_type_id
4036 , plr.CALENDAR_TYPE
4037 , plr.CURR_RECORD_TYPE -- curr code missing.
4038 , plr.currency_code
4039 , plr.RBS_ELEMENT_ID
4040 , plr.RBS_STRUCT_VERSION_ID
4041 , plr.plan_version_id
4042 , plr.plan_type_id
4043 , plr.start_date
4044 , plr.end_date
4045 , plr.line_type
4046 ,decode(sign(plr.rate),-1,'Y',NULL) ||decode(sign(plr.rate2),-1,'Y',NULL)
4047 , plr.plan_type_code; /* 4471527 */
4048
4049 print_time ( ' EXTRACT_PLAN_AMTS_PRIRBS_GLC12 end. Inserted rows # is: ' || SQL%ROWCOUNT );
4050
4051 EXCEPTION
4052 WHEN OTHERS THEN
4053 print_time('EXTRACT_PLAN_AMTS_PRIRBS_GLC12 : Exception ' || SQLERRM );
4054 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
4055 p_procedure_name => 'EXTRACT_PLAN_AMTS_PRIRBS_GLC12');
4056 RAISE;
4057 END;
4058
4059
4060 PROCEDURE REVERSE_PLAN_AMTS IS
4061 BEGIN
4062
4063 print_time ( '.....Begin REVERSE_PLAN_AMTS. ' );
4064
4065 INSERT INTO pji_fp_aggr_pjp1_t fact
4066 (
4067 WORKER_ID
4068 , PRG_LEVEL
4069 , PROJECT_ID
4070 , PROJECT_ORG_ID
4071 , PROJECT_ORGANIZATION_ID
4072 , PROJECT_ELEMENT_ID
4073 , TIME_ID
4074 , PERIOD_TYPE_ID
4075 , CALENDAR_TYPE
4076 , RBS_AGGR_LEVEL
4077 , WBS_ROLLUP_FLAG
4078 , PRG_ROLLUP_FLAG
4079 , CURR_RECORD_TYPE_ID
4080 , CURRENCY_CODE
4081 , RBS_ELEMENT_ID
4082 , RBS_VERSION_ID
4083 , PLAN_VERSION_ID
4084 , PLAN_TYPE_ID
4085 , RAW_COST
4086 , BRDN_COST
4087 , REVENUE
4088 , BILL_RAW_COST
4089 , BILL_BRDN_COST
4090 , BILL_LABOR_RAW_COST
4091 , BILL_LABOR_BRDN_COST
4092 , BILL_LABOR_HRS
4093 , EQUIPMENT_RAW_COST
4094 , EQUIPMENT_BRDN_COST
4095 , CAPITALIZABLE_RAW_COST
4096 , CAPITALIZABLE_BRDN_COST
4097 , LABOR_RAW_COST
4098 , LABOR_BRDN_COST
4099 , LABOR_HRS
4100 , LABOR_REVENUE
4101 , EQUIPMENT_HOURS
4102 , BILLABLE_EQUIPMENT_HOURS
4103 , SUP_INV_COMMITTED_COST
4104 , PO_COMMITTED_COST
4105 , PR_COMMITTED_COST
4106 , OTH_COMMITTED_COST
4107 , ACT_LABOR_HRS
4108 , ACT_EQUIP_HRS
4109 , ACT_LABOR_BRDN_COST
4110 , ACT_EQUIP_BRDN_COST
4111 , ACT_BRDN_COST
4112 , ACT_RAW_COST
4113 , ACT_REVENUE
4114 , ACT_LABOR_RAW_COST
4115 , ACT_EQUIP_RAW_COST
4116 , ETC_LABOR_HRS
4117 , ETC_EQUIP_HRS
4118 , ETC_LABOR_BRDN_COST
4119 , ETC_EQUIP_BRDN_COST
4120 , ETC_BRDN_COST
4121 , ETC_RAW_COST
4122 , ETC_LABOR_RAW_COST
4123 , ETC_EQUIP_RAW_COST
4124 , CUSTOM1
4125 , CUSTOM2
4126 , CUSTOM3
4127 , CUSTOM4
4128 , CUSTOM5
4129 , CUSTOM6
4130 , CUSTOM7
4131 , CUSTOM8
4132 , CUSTOM9
4133 , CUSTOM10
4134 , CUSTOM11
4135 , CUSTOM12
4136 , CUSTOM13
4137 , CUSTOM14
4138 , CUSTOM15
4139 , LINE_TYPE
4140 , PLAN_TYPE_CODE
4141 )
4142 SELECT -- Reversal from fact for primary slice.
4143 g_worker_id
4144 , g_default_prg_level
4145 , fact.PROJECT_ID
4146 , fact.PROJECT_ORG_ID
4147 , fact.PROJECT_ORGANIZATION_ID
4148 , fact.PROJECT_ELEMENT_ID
4149 , fact.TIME_ID
4150 , fact.PERIOD_TYPE_ID
4151 , fact.CALENDAR_TYPE
4152 , fact.RBS_AGGR_LEVEL
4153 , fact.WBS_ROLLUP_FLAG
4154 , fact.PRG_ROLLUP_FLAG
4155 , fact.CURR_RECORD_TYPE_ID CURR_RECORD_TYPE_ID
4156 , fact.CURRENCY_CODE
4157 , fact.RBS_ELEMENT_ID
4158 , fact.RBS_VERSION_ID
4159 , fact.PLAN_VERSION_ID
4160 , fact.PLAN_TYPE_ID
4161 , -fact.RAW_COST
4162 , -fact.BRDN_COST
4163 , -fact.REVENUE
4164 , -fact.BILL_RAW_COST
4165 , -fact.BILL_BRDN_COST
4166 , -fact.BILL_LABOR_RAW_COST
4167 , -fact.BILL_LABOR_BRDN_COST
4168 , -fact.BILL_LABOR_HRS
4169 , -fact.EQUIPMENT_RAW_COST
4170 , -fact.EQUIPMENT_BRDN_COST
4171 , -fact.CAPITALIZABLE_RAW_COST
4172 , -fact.CAPITALIZABLE_BRDN_COST
4173 , -fact.LABOR_RAW_COST
4174 , -fact.LABOR_BRDN_COST
4175 , -fact.LABOR_HRS
4176 , -fact.LABOR_REVENUE
4177 , -fact.EQUIPMENT_HOURS
4178 , -fact.BILLABLE_EQUIPMENT_HOURS
4179 , -fact.SUP_INV_COMMITTED_COST
4180 , -fact.PO_COMMITTED_COST
4181 , -fact.PR_COMMITTED_COST
4182 , -fact.OTH_COMMITTED_COST
4183 , - fact.ACT_LABOR_HRS
4184 , -fact.ACT_EQUIP_HRS
4185 , -fact.ACT_LABOR_BRDN_COST
4186 , -fact.ACT_EQUIP_BRDN_COST
4187 , -fact.ACT_BRDN_COST
4188 , -fact.ACT_RAW_COST
4189 , -fact.ACT_REVENUE
4190 , -fact.ACT_LABOR_RAW_COST
4191 , -fact.ACT_EQUIP_RAW_COST
4192 , -fact.ETC_LABOR_HRS
4193 , -fact.ETC_EQUIP_HRS
4194 , -fact.ETC_LABOR_BRDN_COST
4195 , -fact.ETC_EQUIP_BRDN_COST
4196 , -fact.ETC_BRDN_COST
4197 , -fact.ETC_RAW_COST
4198 , -fact.ETC_LABOR_RAW_COST
4199 , -fact.ETC_EQUIP_RAW_COST
4200 , -fact.CUSTOM1
4201 , -fact.CUSTOM2
4202 , -fact.CUSTOM3
4203 , -fact.CUSTOM4
4204 , -fact.CUSTOM5
4205 , -fact.CUSTOM6
4206 , -fact.CUSTOM7
4207 , -fact.CUSTOM8
4208 , -fact.CUSTOM9
4209 , -fact.CUSTOM10
4210 , -fact.CUSTOM11
4211 , -fact.CUSTOM12
4212 , -fact.CUSTOM13
4213 , -fact.CUSTOM14
4214 , -fact.CUSTOM15
4215 , g_ntp_period_name
4216 , fact.plan_type_code /* 4471527 */
4217 FROM
4218 pji_fp_xbs_accum_f fact
4219 , pji_fm_extr_plnver3_t ver
4220 WHERE 1=1
4221 AND fact.plan_version_id = ver.plan_version_id
4222 AND fact.plan_type_code = ver.plan_type_code /* 4471527 */
4223 AND fact.project_id = ver.project_id
4224 AND fact.rbs_aggr_level = g_lowest_level
4225 AND fact.wbs_rollup_flag = 'N'
4226 AND ver.secondary_rbs_flag = 'N'
4227 AND (
4228 ((ver.time_phased_type_code IN ('P', 'G')) AND (fact.period_type_id = 32))
4229 OR ((ver.time_phased_type_code = 'N') AND (fact.period_type_id = 2048))
4230 );
4231
4232 print_time ( '.....End REVERSE_PLAN_AMTS. # rows = ' || SQL%ROWCOUNT );
4233
4234 EXCEPTION
4235 WHEN OTHERS THEN
4236 print_time('REVERSE_PLAN_AMTS : Exception ' || SQLERRM );
4237 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
4238 p_procedure_name => 'REVERSE_PLAN_AMTS');
4239 RAISE;
4240 END;
4241
4242
4243 PROCEDURE DELETE_PRI_NONTIMEPH_ENTDAMTS IS
4244 BEGIN
4245
4246 DELETE FROM pji_fp_aggr_pjp1_t
4247 WHERE 1=1
4248 AND period_type_id = 32
4249 AND time_id = -1
4250 AND worker_id = g_worker_id;
4251
4252 EXCEPTION
4253 WHEN OTHERS THEN
4254 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
4255 p_procedure_name => 'RETRIEVE_RL_SECSLC_TIMEPH');
4256 RAISE;
4257 END;
4258
4259
4260 --
4261 -- Inserts into FP reporting lines fact the data in the interim pjp1 table.
4262 --
4263 PROCEDURE INSERT_INTO_FP_FACT ( p_slice_type IN VARCHAR2 := NULL) IS
4264 l_last_update_date date := SYSDATE;
4265 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
4266 l_creation_date date := SYSDATE;
4267 l_created_by NUMBER := FND_GLOBAL.USER_ID;
4268 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
4269 BEGIN
4270
4271 IF ( (p_slice_type = 'PRI') OR (p_slice_type IS NULL) ) THEN
4272
4273 MERGE_INTO_FP_FACT;
4274
4275 ELSIF (p_slice_type = 'SEC') THEN
4276
4277 DELETE FROM pji_fp_aggr_pjp1_t
4278 WHERE line_type = 'OF'
4279 AND worker_id = g_worker_id; -- Data in entered calendar should not be rolled up.
4280
4281 MERGE_INTO_FP_FACT;
4282
4283 END IF;
4284
4285 EXCEPTION
4286 WHEN OTHERS THEN
4287 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
4288 p_procedure_name => 'INSERT_INTO_FP_FACT');
4289 RAISE;
4290 END;
4291
4292
4293 PROCEDURE GET_PRI_SLICE_DATA(
4294 p_fp_version_ids IN SYSTEM.pa_num_tbl_type := pji_empty_num_tbl
4295 , p_commit IN VARCHAR2 := 'F') IS
4296 BEGIN
4297
4298 FORALL I IN p_fp_version_ids.FIRST..p_fp_version_ids.LAST
4299 INSERT INTO PJI_FP_AGGR_PJP1_T
4300 (
4301 WORKER_ID
4302 , PROJECT_ID
4303 , PROJECT_ORG_ID
4304 , PROJECT_ORGANIZATION_ID
4305 -- , PARTITION_ID
4306 , PROJECT_ELEMENT_ID
4307 , TIME_ID
4308 , PERIOD_TYPE_ID
4309 , CALENDAR_TYPE
4310 , RBS_AGGR_LEVEL
4311 , WBS_ROLLUP_FLAG
4312 , PRG_ROLLUP_FLAG
4313 , CURR_RECORD_TYPE_ID
4314 , CURRENCY_CODE
4315 , RBS_ELEMENT_ID
4316 , RBS_VERSION_ID
4317 , PLAN_VERSION_ID
4318 , PLAN_TYPE_ID
4319 , RAW_COST
4320 , BRDN_COST
4321 , REVENUE
4322 , BILL_RAW_COST
4323 , BILL_BRDN_COST
4324 , BILL_LABOR_RAW_COST
4325 , BILL_LABOR_BRDN_COST
4326 , BILL_LABOR_HRS
4327 , EQUIPMENT_RAW_COST
4328 , EQUIPMENT_BRDN_COST
4329 , CAPITALIZABLE_RAW_COST
4330 , CAPITALIZABLE_BRDN_COST
4331 , LABOR_RAW_COST
4332 , LABOR_BRDN_COST
4333 , LABOR_HRS
4334 , LABOR_REVENUE
4335 , EQUIPMENT_HOURS
4336 , BILLABLE_EQUIPMENT_HOURS
4337 , SUP_INV_COMMITTED_COST
4338 , PO_COMMITTED_COST
4339 , PR_COMMITTED_COST
4340 , OTH_COMMITTED_COST
4341 , ACT_LABOR_HRS
4342 , ACT_EQUIP_HRS
4343 , ACT_LABOR_BRDN_COST
4344 , ACT_EQUIP_BRDN_COST
4345 , ACT_BRDN_COST
4346 , ACT_RAW_COST
4347 , ACT_REVENUE
4348 , ACT_LABOR_RAW_COST
4349 , ACT_EQUIP_RAW_COST
4350 , ETC_LABOR_HRS
4351 , ETC_EQUIP_HRS
4352 , ETC_LABOR_BRDN_COST
4353 , ETC_EQUIP_BRDN_COST
4354 , ETC_BRDN_COST
4355 , ETC_RAW_COST
4356 , ETC_LABOR_RAW_COST
4357 , ETC_EQUIP_RAW_COST
4358 , CUSTOM1
4359 , CUSTOM2
4360 , CUSTOM3
4361 , CUSTOM4
4362 , CUSTOM5
4363 , CUSTOM6
4364 , CUSTOM7
4365 , CUSTOM8
4366 , CUSTOM9
4367 , CUSTOM10
4368 , CUSTOM11
4369 , CUSTOM12
4370 , CUSTOM13
4371 , CUSTOM14
4372 , CUSTOM15
4373 , PRG_LEVEL
4374 , PLAN_TYPE_CODE /* 4471527 */
4375 )
4376 (
4377 SELECT
4378 g_worker_id
4379 , rl.PROJECT_ID
4380 , rl.PROJECT_ORG_ID
4381 , rl.PROJECT_ORGANIZATION_ID
4382 -- , rl.PARTITION_ID
4383 , rl.PROJECT_ELEMENT_ID
4384 , rl.TIME_ID
4385 , rl.PERIOD_TYPE_ID
4386 , rl.CALENDAR_TYPE
4387 , rl.RBS_AGGR_LEVEL
4388 , rl.WBS_ROLLUP_FLAG
4389 , rl.PRG_ROLLUP_FLAG
4390 , rl.CURR_RECORD_TYPE_ID
4391 , rl.CURRENCY_CODE
4392 , rl.RBS_ELEMENT_ID
4393 , rl.RBS_VERSION_ID
4394 , rl.PLAN_VERSION_ID
4395 , rl.PLAN_TYPE_ID
4396 , rl.RAW_COST
4397 , rl.BRDN_COST
4398 , rl.REVENUE
4399 , rl.BILL_RAW_COST
4400 , rl.BILL_BRDN_COST
4401 , rl.BILL_LABOR_RAW_COST
4402 , rl.BILL_LABOR_BRDN_COST
4403 , rl.BILL_LABOR_HRS
4404 , rl.EQUIPMENT_RAW_COST
4405 , rl.EQUIPMENT_BRDN_COST
4406 , rl.CAPITALIZABLE_RAW_COST
4407 , rl.CAPITALIZABLE_BRDN_COST
4408 , rl.LABOR_RAW_COST
4409 , rl.LABOR_BRDN_COST
4410 , rl.LABOR_HRS
4411 , rl.LABOR_REVENUE
4412 , rl.EQUIPMENT_HOURS
4413 , rl.BILLABLE_EQUIPMENT_HOURS
4414 , rl.SUP_INV_COMMITTED_COST
4415 , rl.PO_COMMITTED_COST
4416 , rl.PR_COMMITTED_COST
4417 , rl.OTH_COMMITTED_COST
4418 , rl.ACT_LABOR_HRS
4419 , rl.ACT_EQUIP_HRS
4420 , rl.ACT_LABOR_BRDN_COST
4421 , rl.ACT_EQUIP_BRDN_COST
4422 , rl.ACT_BRDN_COST
4423 , rl.ACT_RAW_COST
4424 , rl.ACT_REVENUE
4425 , rl.ACT_LABOR_RAW_COST
4426 , rl.ACT_EQUIP_RAW_COST
4427 , rl.ETC_LABOR_HRS
4428 , rl.ETC_EQUIP_HRS
4429 , rl.ETC_LABOR_BRDN_COST
4430 , rl.ETC_EQUIP_BRDN_COST
4431 , rl.ETC_BRDN_COST
4432 , rl.ETC_RAW_COST
4433 , rl.ETC_LABOR_RAW_COST
4434 , rl.ETC_EQUIP_RAW_COST
4435 , rl.CUSTOM1
4436 , rl.CUSTOM2
4437 , rl.CUSTOM3
4438 , rl.CUSTOM4
4439 , rl.CUSTOM5
4440 , rl.CUSTOM6
4441 , rl.CUSTOM7
4442 , rl.CUSTOM8
4443 , rl.CUSTOM9
4444 , rl.CUSTOM10
4445 , rl.CUSTOM11
4446 , rl.CUSTOM12
4447 , rl.CUSTOM13
4448 , rl.CUSTOM14
4449 , rl.CUSTOM15
4450 , g_default_prg_level
4451 , rl.PLAN_TYPE_CODE /* 4471527 */
4452 FROM
4453 pji_fp_xbs_accum_f rl
4454 , pa_budget_versions bv -- @pjdev115 bv
4455 , pa_proj_fp_options fpo -- @pjdev115 fpo
4456 WHERE
4457 rl.project_id = bv.project_id
4458 AND bv.version_type IS NOT NULL
4459 AND bv.fin_plan_type_id IS NOT NULL
4460 AND fpo.project_id = bv.project_id
4461 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
4462 AND bv.budget_version_id = fpo.fin_plan_version_id
4463 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION'
4464 AND rl.calendar_type =
4465 DECODE( bv.version_type
4466 , g_all_timeph_code, fpo.all_time_phased_code
4467 , g_cost_timeph_code, fpo.cost_time_phased_code
4468 , g_rev_timeph_code, fpo.revenue_time_phased_code
4469 )
4470 AND rl.plan_version_id = p_fp_version_ids(i));
4471
4472
4473 EXCEPTION
4474 WHEN OTHERS THEN
4475 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
4476 p_procedure_name => 'GET_PRI_SLICE_DATA');
4477 RAISE;
4478 END;
4479
4480
4481 PROCEDURE INSERT_ACTUALS_FROM_PREVPLAN IS
4482 BEGIN
4483
4484 NULL;
4485
4486 EXCEPTION
4487 WHEN OTHERS THEN
4488 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
4489 p_procedure_name => 'GET_PRI_SLICE_DATA');
4490 RAISE;
4491 END;
4492
4493
4494 PROCEDURE UPDATE_ACTUALS_TO_NULL IS
4495 BEGIN
4496
4497 UPDATE PJI_FM_EXTR_PLAN_LINES bl
4498 SET
4499 bl.act_txn_raw_cost = NULL
4500 , bl.act_txn_burdened_cost = NULL
4501 , bl.act_txn_revenue = NULL
4502 , bl.act_prj_raw_cost = NULL
4503 , bl.act_prj_burdened_cost = NULL
4504 , bl.act_prj_revenue = NULL
4505 , bl.act_pfc_raw_cost = NULL
4506 , bl.act_pfc_burdened_cost = NULL
4507 , bl.act_pfc_revenue = NULL
4508 , bl.act_quantity = NULL
4509 WHERE 1=1
4510 AND bl.rowid IN ( SELECT extr_lines_rowid FROM pji_fp_rmap_fpr_update_t);
4511
4512 EXCEPTION
4513 WHEN OTHERS THEN
4514 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
4515 p_procedure_name => 'UPDATE_ACTUALS_TO_NULL');
4516 RAISE;
4517 END;
4518
4519 -- RETRIEVE_DELTA_SLICE
4520 PROCEDURE RETRIEVE_DELTA_SLICE IS
4521 l_count NUMBER := NULL;
4522 l_count1 NUMBER := NULL;
4523 l_count2 NUMBER := NULL;
4524
4525 l_count_temp NUMBER := NULL;
4526 l_max_plnver_id NUMBER := NULL;
4527 /* l_per_analysis_flag varchar2(2); /* Added for bug 8708651
4528 Commented for bug 9048716 */
4529
4530 CURSOR c_struct_ver_ids IS
4531 SELECT wbs_struct_version_id
4532 FROM PJI_FM_EXTR_PLNVER3_T;
4533
4534 BEGIN
4535
4536 /* l_per_analysis_flag := PJI_UTILS.GET_SETUP_PARAMETER('PER_ANALYSIS_FLAG'); /* Added for bug 8708651
4537 Commented for bug 9048716*/
4538
4539 print_time('........RETRIEVE_DELTA_SLICE : Begin.' );
4540
4541 IF P_PA_DEBUG_MODE = 'Y' THEN
4542 pa_debug.write('RETRIEVE_DELTA_SLICE: ' || g_module_name,'Inside RETRIEVE_DELTA_SLICE' ,1);
4543 END IF;
4544
4545 INSERT_NTP_CAL_RECORD ( x_max_plnver_id => l_max_plnver_id );
4546
4547 IF (l_max_plnver_id IS NULL) THEN
4548 RETURN;
4549 END IF;
4550
4551 INSERT INTO PJI_FP_AGGR_PJP1_T
4552 (
4553 WORKER_ID
4554 , PROJECT_ID
4555 , PROJECT_ORG_ID
4556 , PROJECT_ORGANIZATION_ID
4557 , PROJECT_ELEMENT_ID
4558 , TIME_ID
4559 , PERIOD_TYPE_ID
4560 , CALENDAR_TYPE
4561 , RBS_AGGR_LEVEL
4562 , WBS_ROLLUP_FLAG
4563 , PRG_ROLLUP_FLAG
4564 , CURR_RECORD_TYPE_ID
4565 , CURRENCY_CODE
4566 , RBS_ELEMENT_ID
4567 , RBS_VERSION_ID
4568 , PLAN_VERSION_ID
4569 , PLAN_TYPE_ID
4570 , RAW_COST
4571 , BRDN_COST
4572 , REVENUE
4573 , BILL_RAW_COST
4574 , BILL_BRDN_COST
4575 , BILL_LABOR_RAW_COST
4576 , BILL_LABOR_BRDN_COST
4577 , BILL_LABOR_HRS
4578 , EQUIPMENT_RAW_COST
4579 , EQUIPMENT_BRDN_COST
4580 , CAPITALIZABLE_RAW_COST
4581 , CAPITALIZABLE_BRDN_COST
4582 , LABOR_RAW_COST
4583 , LABOR_BRDN_COST
4584 , LABOR_HRS
4585 , LABOR_REVENUE
4586 , EQUIPMENT_HOURS
4587 , BILLABLE_EQUIPMENT_HOURS
4588 , SUP_INV_COMMITTED_COST
4589 , PO_COMMITTED_COST
4590 , PR_COMMITTED_COST
4591 , OTH_COMMITTED_COST
4592 , ACT_LABOR_HRS
4593 , ACT_EQUIP_HRS
4594 , ACT_LABOR_BRDN_COST
4595 , ACT_EQUIP_BRDN_COST
4596 , ACT_BRDN_COST
4597 , ACT_RAW_COST
4598 , ACT_REVENUE
4599 , ACT_LABOR_RAW_COST
4600 , ACT_EQUIP_RAW_COST
4601 , ETC_LABOR_HRS
4602 , ETC_EQUIP_HRS
4603 , ETC_LABOR_BRDN_COST
4604 , ETC_EQUIP_BRDN_COST
4605 , ETC_BRDN_COST
4606 , ETC_RAW_COST
4607 , ETC_LABOR_RAW_COST
4608 , ETC_EQUIP_RAW_COST
4609 , CUSTOM1
4610 , CUSTOM2
4611 , CUSTOM3
4612 , CUSTOM4
4613 , CUSTOM5
4614 , CUSTOM6
4615 , CUSTOM7
4616 , CUSTOM8
4617 , CUSTOM9
4618 , CUSTOM10
4619 , CUSTOM11
4620 , CUSTOM12
4621 , CUSTOM13
4622 , CUSTOM14
4623 , CUSTOM15
4624 , LINE_TYPE
4625 , RATE_DANGLING_FLAG
4626 , TIME_DANGLING_FLAG
4627 -- , START_DATE
4628 -- , END_DATE
4629 , PRG_LEVEL
4630 , PLAN_TYPE_CODE /* 4471527 */
4631 )
4632 SELECT
4633 g_worker_id
4634 , plr.PROJECT_ID
4635 , plr.PROJECT_ORG_ID
4636 , plr.project_ORGANIZATION_ID
4637 , plr.WBS_ELEMENT_ID
4638 , decode(plr.time_phased_type_code -- change from vers to plr for bug 4604617
4639 , 'N', -1
4640 , pji_time.cal_period_id) time_id /* Modified for bug 9048716 */
4641 , decode(vers.time_phased_type_code
4642 , g_pa_cal_str, 32
4643 , g_gl_cal_str, 32
4644 , 'N', 2048
4645 , -1) period_type_id /* Modified for bug 9048716 */
4646 , decode(vers.time_phased_type_code
4647 , g_pa_cal_str, g_pa_cal_str
4648 , g_gl_cal_str, g_gl_cal_str
4649 , 'N', g_all
4650 , 'X') /* Modified for bug 9048716 */
4651 , g_lowest_level RBS_AGGR_LEVEL
4652 , 'N' WBS_ROLLUP_FLAG
4653 , 'N' PRG_ROLLUP_FLAG
4654 , plr.CURR_RECORD_TYPE -- curr code missing.
4655 , plr.currency_code
4656 , plr.RBS_ELEMENT_ID
4657 , plr.RBS_STRUCT_VERSION_ID
4658 , plr.BUDGET_VERSION_ID
4659 , plr.plan_type_id
4660 , SUM(plr.RAW_COST)
4661 , SUM(plr.BRDN_COST)
4662 , SUM(plr.REVENUE)
4663 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) -- BILL_RAW_COST
4664 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) -- BILL_BRDN_COST
4665 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_people_resclass_code, plr.raw_cost, 0 ) ) -- BILL_LABOR_RAW_COST
4666 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_people_resclass_code , plr.BRDN_COST, 0 ) ) -- BILL_LABOR_BRDN_COST
4667 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'Y' || g_people_resclass_code, plr.quantity, 0 ) ) -- BILL_LABOR_HRS */ -- bug 6039785
4668 , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'Y' || g_people_resclass_code,
4669 DECODE(plr.billable_flag,'Y',plr.quantity,0) , 0 ) ) -- BILL_LABOR_HRS -- bug 6039785
4670 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code , plr.raw_cost, 0 ) ) -- EQUIPMENT_RAW_COST
4671 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code , plr.BRDN_COST, 0 ) ) -- EQUIPMENT_BRDN_COST
4672 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) -- CAPITALIZABLE_RAW_COST
4673 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) -- CAPITALIZABLE_BRDN_COST
4674 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.raw_cost, 0 ) ) -- LABOR_RAW_COST
4675 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.BRDN_COST, 0 ) ) -- LABOR_BRDN_COST
4676 /* , SUM ( DECODE ( plr.resource_class, g_people_resclass_code,
4677 DECODE ( vers.wp_flag, 'N',
4678 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
4679 plr.quantity),
4680 0 ) ) -- labor_hrs */ -- bug 6039785
4681 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, DECODE(plr.billable_flag,'Y',
4682 DECODE ( vers.wp_flag, 'N',
4683 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
4684 plr.quantity),
4685 0 ),
4686 0 ) ) -- labor_hrs -- bug 6039785
4687 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.revenue, 0 ) ) -- LABOR_REVENUE
4688 /* , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code,
4689 DECODE ( vers.wp_flag, 'N',
4690 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
4691 plr.quantity),
4692 0 ) ) EQUIPMENT_HOURS */ -- bug 6039785
4693 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code,
4694 DECODE ( vers.wp_flag, 'N',
4695 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
4696 plr.quantity),
4697 0 ) ) EQUIPMENT_HOURS -- bug 6039785
4698 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YEQUIPMENT', plr.quantity, 0 ) ) */ -- BILLABLE_EQUIPMENT_HOURS -- bug 6039785
4699 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YEQUIPMENT',
4700 DECODE(plr.billable_flag,'Y',plr.quantity,0), 0 ) ) -- BILLABLE_EQUIPMENT_HOURS -- bug 6039785
4701 , NULL -- SUP_INV_COMMITTED_COST
4702 , NULL -- PO_COMMITTED_COST
4703 , NULL -- PR_COMMITTED_COST
4704 , NULL -- OTH_COMMITTED_COST
4705 /* , SUM ( DECODE ( plr.resource_class, g_people_resclass_code,
4706 DECODE ( vers.wp_flag, 'N',
4707 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
4708 plr.actual_quantity),
4709 0 ) ) ACT_LABOR_HRS */ -- bug 6039785
4710 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code,
4711 DECODE (plr.billable_flag ,'Y',
4712 DECODE ( vers.wp_flag, 'N',
4713 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
4714 plr.actual_quantity),
4715 0 ),
4716 0 ) ) ACT_LABOR_HRS -- bug 6039785
4717 /* , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code,
4718 DECODE ( vers.wp_flag, 'N',
4719 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
4720 plr.actual_quantity),
4721 0 ) ) ACT_EQUIP_HOURS */ -- bug 6039785
4722 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code,
4723 DECODE ( vers.wp_flag, 'N',
4724 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
4725 plr.actual_quantity),
4726 0 ) ) ACT_EQUIP_HOURS -- bug 6039785
4727 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.actual_BRDN_COST, 0 ) ) ACT_LABOR_BRDN_COST
4728 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code , plr.actual_BRDN_COST, 0 ) ) ACT_EQUIPMENT_BRDN_COST
4729 , SUM ( plr.actual_brdn_cost ) ACT_BRDN_COST
4730 , SUM ( plr.actual_raw_cost ) ACT_RAW_COST
4731 , SUM ( plr.actual_revenue ) ACT_REVENUE
4732 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.actual_RAW_COST, 0 ) ) ACT_LABOR_RAW_COST
4733 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code , plr.actual_RAW_COST, 0 ) ) ACT_EQUIPMENT_RAW_COST
4734 /* , SUM ( DECODE ( plr.resource_class, g_people_resclass_code,
4735 DECODE ( vers.wp_flag, 'N',
4736 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
4737 plr.ETC_quantity),
4738 g_equip_resclass_code, decode(plr.etc_quantity, null, null,0), NULL ) ) ETC_LABOR_HRS */ -- bug 6039785
4739 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code,
4740 DECODE (plr.billable_flag ,'Y',
4741 DECODE ( vers.wp_flag, 'N',
4742 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
4743 plr.ETC_quantity),
4744 0),
4745 g_equip_resclass_code, decode(plr.etc_quantity, null, null,0), NULL ) ) ETC_LABOR_HRS -- bug 6039785
4746 /* , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code,
4747 DECODE ( vers.wp_flag, 'N',
4748 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
4749 plr.ETC_quantity),
4750 g_people_resclass_code, decode(plr.etc_quantity, null, null, 0), NULL ) ) ETC_EQUIP_HOURS */ -- bug 6039785
4751 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code,
4752 DECODE (plr.billable_flag ,'Y', -- Bug 6348091
4753 DECODE ( vers.wp_flag, 'N',
4754 --DECODE (plr.billable_flag ,'Y', --Bug 6348091
4755 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
4756 plr.ETC_quantity),
4757 0),
4758 g_people_resclass_code, decode(plr.etc_quantity, null, null, 0), NULL ) ) ETC_EQUIP_HOURS -- bug 6039785
4759 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.etc_BRDN_COST, g_equip_resclass_code, decode(plr.etc_BRDN_COST, null, null, 0), NULL ) ) ETC_LABOR_BRDN_COST
4760 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code, plr.etc_BRDN_COST, g_people_resclass_code, decode(plr.etc_BRDN_COST, null, null, 0), NULL ) ) ETC_EQUIP_BRDN_COST
4761 , SUM ( plr.etc_brdn_cost ) ETC_BRDN_COST
4762 , SUM ( plr.etc_raw_cost ) ETC_RAW_COST
4763 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.etc_raw_COST, g_equip_resclass_code, decode(plr.etc_RAW_COST, null, null, 0), NULL ) ) ETC_LABOR_raw_COST
4764 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code, plr.etc_raw_COST, g_people_resclass_code, decode(plr.etc_RAW_COST, null, null, 0), NULL ) ) ETC_EQUIP_raw_COST
4765 , NULL CUSTOM1
4766 , NULL CUSTOM2
4767 , NULL CUSTOM3
4768 , NULL CUSTOM4
4769 , NULL CUSTOM5
4770 , NULL CUSTOM6
4771 , NULL CUSTOM7
4772 , NULL CUSTOM8
4773 , NULL CUSTOM9
4774 , NULL CUSTOM10
4775 , NULL CUSTOM11
4776 , NULL CUSTOM12
4777 , NULL CUSTOM13
4778 , NULL CUSTOM14
4779 , NULL CUSTOM15
4780 , 'OF' -- LINE_TYPE
4781 , NULL -- rate_dangling_flag
4782 , NULL -- time_dangling_flag
4783 , g_default_prg_level
4784 , plr.plan_type_code plan_type_code /* 4471527 */
4785 FROM
4786 ( ----- First inline view plr .............
4787 select
4788 collapse_bl.PROJECT_ID
4789 -- , 1 partition_id
4790 , collapse_bl.WBS_ELEMENT_ID
4791 -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
4792 , SUM(collapse_bl.CURR_RECORD_TYPE_ID) CURR_RECORD_TYPE
4793 , collapse_bl.RBS_ELEMENT_ID
4794 , collapse_bl.RBS_STRUCT_VERSION_ID
4795 , collapse_bl.plan_type_id
4796 , collapse_bl.BUDGET_VERSION_ID
4797 , collapse_bl.PROJECT_ORGANIZATION_ID
4798 , collapse_bl.PROJECT_ORG_ID
4799 , collapse_bl.BILLABLE_FLAG
4800 , collapse_bl.RESOURCE_CLASS
4801 , collapse_bl.TIME_PHASED_TYPE_CODE
4802 , collapse_bl.CURRENCY_CODE
4803 , max(collapse_bl.raw_cost) raw_cost
4804 , max(collapse_bl.BRDN_COST) BRDN_COST
4805 , max(collapse_bl.revenue) revenue
4806 , max(collapse_bl.act_raw_cost) actual_raw_cost
4807 , max(collapse_bl.act_BRDN_COST) actual_BRDN_COST
4808 , max(collapse_bl.act_revenue) actual_revenue
4809 , max(collapse_bl.etc_BRDN_COST) etc_raw_COST
4810 , max(collapse_bl.etc_BRDN_COST) etc_BRDN_COST
4811 , max(collapse_bl.quantity) quantity
4812 , max(collapse_bl.act_quantity) actual_quantity
4813 , max(collapse_bl.etc_quantity) etc_quantity
4814 , collapse_bl.start_date start_date
4815 , collapse_bl.end_date end_date
4816 , collapse_bl.period_name period_name
4817 -- , TRACK_AS_LABOR_FLAG track_as_labor_flag
4818 , collapse_bl.row_id
4819 , collapse_bl.plan_type_code plan_type_code /* 4471527 */
4820 from
4821 ( ----- Second inline view 'collapse_bl' begin .............
4822 select
4823 spread_bl.row_id row_id
4824 , spread_bl.PROJECT_ID
4825 , spread_bl.BUDGET_VERSION_ID
4826 -- , spread_bl.RESOURCE_ASSIGNMENT_ID
4827 , spread_bl.WBS_ELEMENT_ID
4828 , spread_bl.RBS_ELEMENT_ID
4829 , spread_bl.WBS_STRUCT_VERSION_ID
4830 , spread_bl.RBS_STRUCT_VERSION_ID
4831 , spread_bl.plan_type_id
4832 , spread_bl.BILLABLE_FLAG
4833 , spread_bl.RESOURCE_CLASS
4834 -- , spread_bl.CALENDAR_TYPE
4835 -- , pji_time.CALENDAR_ID
4836 , spread_bl.PROJECT_ORGANIZATION_ID
4837 , spread_bl.PROJECT_ORG_ID
4838 , spread_bl.TIME_PHASED_TYPE_CODE
4839 , DECODE( invert.INVERT_ID
4840 , 4, spread_bl.func_CURRENCY_CODE
4841 , 8, spread_bl.PRJ_CURRENCY_CODE
4842 , 16, spread_bl.TXN_CURRENCY_CODE ) CURRENCY_CODE
4843 , invert.INVERT_ID CURR_RECORD_TYPE_ID
4844 , DECODE ( invert.INVERT_ID
4845 , 4, spread_bl.func_raw_cost
4846 , 8, spread_bl.PRJ_raw_cost
4847 , 16, spread_bl.TXN_raw_cost) raw_cost
4848 , DECODE ( invert.INVERT_ID
4849 , 4, spread_bl.func_BRDN_COST
4850 , 8, spread_bl.PRJ_BRDN_COST
4851 , 16, spread_bl.TXN_BRDN_COST ) BRDN_COST
4852 , DECODE ( invert.INVERT_ID
4853 , 4, spread_bl.func_revenue
4854 , 8, spread_bl.PRJ_revenue
4855 , 16, spread_bl.TXN_revenue ) revenue
4856 , DECODE ( invert.INVERT_ID
4857 , 4, spread_bl.act_func_raw_cost
4858 , 8, spread_bl.act_PRJ_raw_cost
4859 , 16, spread_bl.act_TXN_raw_cost) act_raw_cost
4860 , DECODE ( invert.INVERT_ID
4861 , 4, spread_bl.act_func_BRDN_COST
4862 , 8, spread_bl.act_PRJ_BRDN_COST
4863 , 16, spread_bl.act_TXN_BRDN_COST ) act_BRDN_COST
4864 , DECODE ( invert.INVERT_ID
4865 , 4, spread_bl.act_func_revenue
4866 , 8, spread_bl.act_PRJ_revenue
4867 , 16, spread_bl.act_TXN_revenue ) act_revenue
4868 , DECODE ( invert.INVERT_ID
4869 , 4, spread_bl.etc_func_brdn_cost
4870 , 8, spread_bl.etc_PRJ_brdn_cost
4871 , 16, spread_bl.etc_TXN_brdn_cost ) etc_brdn_cost
4872 , DECODE ( invert.INVERT_ID
4873 , 4, spread_bl.etc_pfc_raw_cost
4874 , 8, spread_bl.etc_PRJ_raw_cost
4875 , 16, spread_bl.etc_TXN_raw_cost) etc_raw_cost
4876 , spread_bl.quantity quantity
4877 , spread_bl.act_quantity act_quantity
4878 , spread_bl.etc_quantity etc_quantity
4879 , spread_bl.start_date start_date
4880 , spread_bl.end_date end_date
4881 , spread_bl.period_name period_name
4882 -- , spread_bl.TRACK_AS_LABOR_FLAG track_as_labor_flag
4883 , spread_bl.plan_type_code plan_type_code /* 4471527 */
4884 from
4885 ( ----- Third inline view 'spread_bl' .............
4886 -- Added hint for bug 3828698
4887 SELECT
4888 bl.project_id
4889 , bl.rowid row_id
4890 , bl.plan_version_id budget_version_id
4891 -- , bl.resource_asSIGNment_id
4892 , DECODE(bl.project_element_id, 0, pevs.proj_element_id, bl.project_element_id) wbs_element_id
4893 , NVL(bl.rbs_element_id, -1) rbs_element_id
4894 , bl.struct_ver_id wbs_struct_version_id
4895 , DECODE( bl.rbs_element_id
4896 , NULL
4897 , -1
4898 , NVL(ver.rbs_struct_version_id, -1)
4899 ) rbs_struct_version_id
4900 , bl.plan_type_id plan_type_id -- ver.plan_type_id
4901 , bl.rate_based_flag billable_flag -- ra.rate_based_flag billable_flag
4902 , bl.resource_class_code resource_class -- ra.resource_class_code resource_class
4903 , bl.txn_currency_code txn_currency_code
4904 , bl.txn_raw_cost txn_raw_cost
4905 , bl.txn_burdened_COST txn_BRDN_COST
4906 , bl.txn_revenue txn_revenue
4907 , bl.act_txn_raw_cost act_txn_raw_cost
4908 , bl.act_txn_burdened_cost act_txn_brdn_cost
4909 , bl.act_txn_revenue act_txn_revenue
4910 , bl.etc_txn_burdened_cost etc_txn_brdn_cost
4911 , bl.prj_currency_code prj_currency_code
4912 , bl.prj_raw_cost prj_raw_cost
4913 , bl.prj_burdened_COST prj_BRDN_COST
4914 , bl.prj_revenue prj_revenue
4915 , bl.act_prj_raw_cost act_prj_raw_cost
4916 , bl.act_prj_burdened_cost act_prj_brdn_cost
4917 , bl.act_prj_revenue act_prj_revenue
4918 , bl.etc_prj_burdened_cost etc_prj_brdn_cost
4919 , bl.pfc_currency_code func_currency_code
4920 , bl.pfc_raw_cost func_raw_cost
4921 , bl.pfc_burdened_COST func_BRDN_COST
4922 , bl.pfc_revenue func_revenue
4923 , bl.act_pfc_raw_cost act_func_raw_cost
4924 , bl.act_pfc_burdened_cost act_func_brdn_cost
4925 , bl.act_pfc_revenue act_func_revenue
4926 , bl.etc_pfc_burdened_cost etc_func_brdn_cost
4927 , bl.ETC_TXN_RAW_COST ETC_TXN_RAW_COST
4928 , bl.ETC_PRJ_RAW_COST ETC_PRJ_RAW_COST
4929 , bl.ETC_PFC_RAW_COST ETC_PFC_RAW_COST
4930 , 'DEF' glb1_currency_code
4931 , NULL glb1_raw_cost
4932 , NULL glb1_BRDN_COST
4933 , NULL glb1_revenue
4934 , 'ACB' glb2_currency_code
4935 , NULL glb2_raw_cost
4936 , NULL glb1_BRDN_COST
4937 , NULL glb1_revenue
4938 , bl.quantity quantity
4939 , bl.act_quantity act_quantity
4940 , bl.etc_quantity etc_quantity
4941 , DECODE(ver.time_phased_type_code, 'N', bl.start_date, NULL) start_date
4942 , DECODE(ver.time_phased_type_code, 'N', bl.end_date, NULL) end_date
4943 , NVL(bl.period_name, g_ntp_period_name) period_name
4944 , NVL(bl.calendar_type, ver.time_phased_type_code) time_phased_type_code
4945 , bl.project_org_id project_org_id
4946 , ppa.carrying_out_organization_id project_organization_id
4947 , ver.plan_type_code plan_type_code /* 4471527 */
4948 FROM
4949 PJI_FM_EXTR_PLAN_LINES bl
4950 , PJI_FM_EXTR_PLNVER3_T ver
4951 , pa_projects_all ppa
4952 , PA_PROJ_ELEM_VER_STRUCTURE pevs
4953 , pji_fp_rmap_fpr_update_t rwid
4954 WHERE 1=1
4955 AND bl.project_id = ver.project_id
4956 AND bl.plan_version_id = ver.plan_version_id
4957 AND bl.plan_type_id = ver.plan_type_id
4958 AND ppa.project_id = ver.project_id
4959 AND bl.project_id = ppa.project_id -- Added for bug 3828698
4960 AND ppa.project_id = pevs.project_id -- Added for bug 3838698
4961 AND bl.TXN_CURRENCY_CODE IS NOT NULL
4962 AND bl.prj_currency_code IS NOT NULL
4963 AND bl.pfc_currency_code IS NOT NULL
4964 AND pevs.element_version_id = ver.wbs_struct_version_id
4965 AND pevs.project_id = ver.project_id -- Fix for bug : 4149422 in RETRIEVE_DELTA_SLICE
4966 AND bl.ROWID = rwid.extr_lines_rowid
4967 ) spread_bl
4968 ---- end of third inline view 'spread_bl'...........
4969 ,
4970 (
4971 select 4 INVERT_ID from dual union all
4972 select 8 INVERT_ID from dual union all
4973 select 16 INVERT_ID from dual where PJI_UTILS.GET_SETUP_PARAMETER('TXN_CURR_FLAG') = 'Y'
4974 ) invert
4975 ) collapse_bl
4976 ---- End of second inline view 'collapse_bl' ..........
4977 GROUP BY
4978 collapse_bl.PROJECT_ID
4979 , collapse_bl.WBS_ELEMENT_ID
4980 -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
4981 , collapse_bl.RBS_ELEMENT_ID
4982 , collapse_bl.RBS_STRUCT_VERSION_ID
4983 , collapse_bl.plan_type_id
4984 , collapse_bl.BUDGET_VERSION_ID
4985 , collapse_bl.PROJECT_ORGANIZATION_ID
4986 , collapse_bl.PROJECT_ORG_ID
4987 , collapse_bl.BILLABLE_FLAG
4988 , collapse_bl.RESOURCE_CLASS
4989 , collapse_bl.TIME_PHASED_TYPE_CODE
4990 , collapse_bl.CURRENCY_CODE
4991 , collapse_bl.start_date
4992 , collapse_bl.end_date
4993 , collapse_bl.period_name
4994 , collapse_bl.row_id
4995 , collapse_bl.plan_type_code /* 4471527 */
4996 ) plr
4997 ---- End of first inline view plr ..........
4998 , PJI_ORG_EXTR_INFO orginfo
4999 , PJI_FM_EXTR_PLNVER3_T vers
5000 , pji_time_cal_period_v pji_time
5001 WHERE 1=1
5002 AND plr.project_org_id = orginfo.org_id
5003 AND plr.project_id = vers.project_id
5004 AND plr.budget_version_id = vers.plan_version_id
5005 AND plr.plan_type_code = vers.plan_type_code /*4471527 */
5006 AND DECODE(plr.time_phased_type_code -- change from vers to plr for bug 4604617
5007 , g_pa_cal_str, orginfo.pa_calendar_id
5008 , g_gl_cal_str, orginfo.gl_calendar_id
5009 , -l_max_plnver_id ) = pji_time.calendar_id
5010 AND plr.period_name = pji_time.name
5011 AND plr.time_phased_type_code IN (g_pa_cal_str, g_gl_cal_str, 'N')
5012 GROUP BY
5013 plr.PROJECT_ID
5014 , plr.WBS_ELEMENT_ID
5015 , decode(plr.time_phased_type_code
5016 , 'N', -1
5017 , pji_time.cal_period_id) /* Modified for bug 9048716 */
5018 , decode(vers.time_phased_type_code
5019 , g_pa_cal_str, 32
5020 , g_gl_cal_str, 32
5021 , 'N', 2048
5022 , -1) /* Modified for bug 9048716 */
5023 , decode(vers.time_phased_type_code
5024 , g_pa_cal_str, g_pa_cal_str
5025 , g_gl_cal_str, g_gl_cal_str
5026 , 'N', g_all
5027 , 'X') /* Modified for bug 9048716 */
5028 , plr.CURR_RECORD_TYPE -- curr code missing.
5029 , plr.currency_code
5030 , plr.RBS_ELEMENT_ID
5031 , plr.RBS_STRUCT_VERSION_ID
5032 , plr.plan_type_id
5033 , plr.BUDGET_VERSION_ID
5034 , plr.project_ORGANIZATION_ID
5035 , plr.project_ORG_ID
5036 , plr.plan_type_code ; /* 4471527 */
5037
5038 print_time('count is ... ' || SQL%ROWCOUNT );
5039
5040 DELETE_NTP_CAL_RECORD ( p_max_plnver_id => l_max_plnver_id );
5041
5042 print_time('........RETRIEVE_DELTA_SLICE : End.' );
5043
5044 EXCEPTION
5045 WHEN OTHERS THEN
5046 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
5047 p_procedure_name => 'RETRIEVE_DELTA_SLICE');
5048 print_time('........RETRIEVE_DELTA_SLICE : Exception ' || sqlerrm );
5049 RAISE;
5050 END;
5051
5052
5053 PROCEDURE POPULATE_PLN_VER_TABLE IS
5054 l_count NUMBER := 0;
5055 BEGIN
5056
5057 print_time('........POPULATE_PLN_VER_TABLE : Begin.' );
5058
5059 INSERT INTO PJI_FM_EXTR_PLNVER3_T
5060 (
5061 PROJECT_ID ,
5062 PLAN_VERSION_ID ,
5063 WBS_STRUCT_VERSION_ID ,
5064 RBS_STRUCT_VERSION_ID ,
5065 PLAN_TYPE_CODE ,
5066 PLAN_TYPE_ID ,
5067 TIME_PHASED_TYPE_CODE ,
5068 TIME_DANGLING_FLAG ,
5069 RATE_DANGLING_FLAG ,
5070 PROJECT_TYPE_CLASS ,
5071 WP_FLAG ,
5072 CURRENT_FLAG ,
5073 ORIGINAL_FLAG ,
5074 CURRENT_ORIGINAL_FLAG ,
5075 BASELINED_FLAG ,
5076 SECONDARY_RBS_FLAG
5077 )
5078 SELECT DISTINCT
5079 epl.project_id
5080 , epl.plan_version_id
5081 , DECODE ( NVL(bv.wp_version_flag, 'N')
5082 , 'Y', bv.project_structure_version_id
5083 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
5084 ) wbs_struct_version_id
5085 -- , epl.struct_ver_id
5086 , fpo.rbs_version_id -- epl.rbs_version_id
5087 -- , to_char(epl.plan_type_id) -- pln type code
5088 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
5089 , epl.plan_type_id
5090 , DECODE(bv.version_type
5091 , g_all_timeph_code, fpo.all_time_phased_code
5092 , g_cost_timeph_code, fpo.cost_time_phased_code
5093 , g_rev_timeph_code, fpo.revenue_time_phased_code
5094 ) time_phased_type_code
5095 , null -- time dangling..
5096 , null -- time dangling..
5097 , null -- project type class is not used currently..
5098 , DECODE(bv.wp_version_flag, 'Y', 'Y', 'N') is_wp_flag
5099 , bv.current_flag current_flag
5100 , bv.original_flag original_flag
5101 , bv.current_original_flag current_original_flag
5102 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
5103 , 'N'
5104 FROM PJI_FM_EXTR_PLAN_LINES epl
5105 , pa_budget_versions bv
5106 , pa_proj_fp_options fpo
5107 WHERE
5108 epl.plan_version_id = bv.budget_version_id
5109 AND fpo.project_id = bv.project_id
5110 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
5111 AND bv.budget_version_id = fpo.fin_plan_version_id
5112 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION'
5113 AND epl.rowid IN ( SELECT extr_lines_rowid FROM pji_fp_rmap_fpr_update_t);
5114
5115
5116 print_time('count is ... ' || SQL%ROWCOUNT );
5117
5118 print_time('........POPULATE_PLN_VER_TABLE : End.' );
5119
5120 EXCEPTION
5121 WHEN OTHERS THEN
5122 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
5123 p_procedure_name => 'POPULATE_PLN_VER_TABLE');
5124 print_time('........POPULATE_PLN_VER_TABLE : Exception: ' || sqlerrm );
5125 RAISE;
5126 END;
5127
5128
5129 PROCEDURE GET_GLOBAL_EXCHANGE_RATES IS
5130
5131 l_gl1_cur_code VARCHAR2(15) := g_global1_currency_code;
5132 l_gl2_cur_code VARCHAR2(15) := g_global2_currency_code;
5133 l_gl1_mau NUMBER := g_global1_currency_mau;
5134 l_gl2_mau NUMBER := g_global2_currency_mau;
5135
5136 BEGIN
5137
5138 print_time('........GET_GLOBAL_EXCHANGE_RATES: Begin. ' );
5139
5140 PJI_PJP_FP_CURR_WRAP.get_global_currency_info (
5141 x_currency_conversion_rule => g_currency_conversion_rule
5142 , x_prorating_format => g_prorating_format
5143 , x_global1_currency_code => g_global1_currency_code
5144 , x_global2_currency_code => g_global2_currency_code
5145 , x_global1_currency_mau => g_global1_currency_mau
5146 , x_global2_currency_mau => g_global2_currency_mau ) ;
5147
5148 l_gl1_cur_code := g_global1_currency_code;
5149 l_gl2_cur_code := g_global2_currency_code;
5150 l_gl1_mau := g_global1_currency_mau;
5151 l_gl2_mau := g_global2_currency_mau;
5152
5153 print_time(' Got global currency settings. ');
5154 print_time(' g_currency_conversion_rule ' || g_currency_conversion_rule || ' g_prorating_format ' || g_prorating_format );
5155 print_time(' g_global1_currency_code ' || g_global1_currency_code || ' g_global2_currency_code ' || g_global2_currency_code );
5156 print_time(' g_global1_currency_mau ' || g_global1_currency_mau || ' g_global2_currency_mau ' || g_global2_currency_mau ) ;
5157
5158
5159 DELETE FROM PJI_FM_AGGR_DLY_RATES_T
5160 WHERE worker_id = g_worker_id;
5161 -- Removed pa_resource_assignments join and Added joins with pji_org_extr_info
5162 -- for bug 4149422
5163 -- SQL for getting rates for time phased budgets.
5164 PJI_UTILS.g_max_roll_days := 1500; /*5155692 */
5165
5166 INSERT INTO PJI_FM_AGGR_DLY_RATES_T (
5167 WORKER_ID ,
5168 PF_CURRENCY_CODE ,
5169 TIME_ID ,
5170 RATE ,
5171 MAU ,
5172 RATE2 ,
5173 MAU2)
5174 SELECT worker_id,
5175 projfunc_currency_code,
5176 time_id,
5177 PJI_UTILS.GET_GLOBAL_RATE_PRIMARY (temp.projfunc_currency_code
5178 , DECODE ( g_currency_conversion_rule
5179 , 'S'
5180 , temp.start_date
5181 , 'E'
5182 , temp.end_date ))
5183 rate1,
5184 l_gl1_mau mau1,
5185 DECODE ( PJI_UTILS.GET_SETUP_PARAMETER('GLOBAL_CURR2_FLAG'),
5186 'Y',
5187 PJI_UTILS.GET_GLOBAL_RATE_SECONDARY (temp.projfunc_currency_code,
5188 DECODE ( g_currency_conversion_rule
5189 , 'S'
5190 , temp.start_date
5191 , 'E'
5192 , temp.end_date ) ),
5193 NULL
5194 )
5195 rate2,
5196 l_gl2_mau mau2
5197 FROM (
5198 SELECT DISTINCT
5199 g_worker_id worker_id
5200 , ppa.projfunc_currency_code
5201 , cal_period_id time_id
5202 , DECODE( g_currency_conversion_rule
5203 , 'S'
5204 , prd.start_date
5205 , TO_DATE(NULL)
5206 ) start_date
5207 , DECODE( g_currency_conversion_rule
5208 , 'E'
5209 , prd.end_date
5210 , TO_DATE(NULL)
5211 ) end_date
5212 , l_gl1_mau mau1
5213 , l_gl2_mau mau2
5214 FROM pa_budget_lines bl
5215 , pa_budget_versions bv -- added for bug 5842896
5216 , pji_time_cal_period_v prd
5217 , PJI_FM_EXTR_PLNVER3_T ver
5218 , pa_projects_all ppa
5219 ,PJI_ORG_EXTR_INFO inf
5220 WHERE bl.budget_version_id = ver.plan_version_id
5221 AND bl.budget_version_id = bv.budget_version_id -- added for bug 5842896
5222 AND bv.project_id = ppa.project_id -- added for bug 5842896
5223 AND ver.time_phased_type_code IN ('P', 'G')
5224 AND bl.period_name = prd.name
5225 AND ver.wp_flag = 'N'
5226 AND ver.baselined_flag = 'Y'
5227 AND ver.project_id = ppa.project_id
5228 -- Fix for bug : 4149422
5229 AND ppa.org_id = inf.org_id
5230 AND DECODE (ver.time_phased_type_code
5231 , 'P'
5232 , inf.pa_calendar_id
5233 , 'G'
5234 , inf.gl_calendar_id) = prd.calendar_id
5235 and budget_type_code is null --25-JUN-2009 cklee fixed bug:6915879
5236 UNION ALL
5237 SELECT DISTINCT
5238 g_worker_id worker_id
5239 , ppa.projfunc_currency_code
5240 , DECODE ( g_currency_conversion_rule
5241 , 'S'
5242 , TO_NUMBER(to_CHAR(ra.planning_start_date, 'J'))
5243 , 'E'
5244 , TO_NUMBER(to_CHAR(ra.planning_end_date, 'J')) ) time_id
5245 , DECODE( g_currency_conversion_rule
5246 , 'S'
5247 , ra.planning_start_date
5248 , TO_DATE(NULL)
5249 ) start_date
5250 , DECODE( g_currency_conversion_rule
5251 , 'E'
5252 , ra.planning_end_date
5253 , TO_DATE(NULL)
5254 ) end_date
5255 , l_gl1_mau mau1
5256 , l_gl2_mau mau2
5257 FROM pa_resource_assignments ra
5258 , PJI_FM_EXTR_PLNVER3_T ver
5259 , pa_projects_all ppa
5260 WHERE ra.budget_version_id = ver.plan_version_id
5261 AND ver.wp_flag = 'N'
5262 AND ver.baselined_flag = 'Y'
5263 AND ver.time_phased_type_code = 'N'
5264 AND ver.project_id = ppa.project_id
5265 ) temp;
5266
5267 PJI_UTILS.g_max_roll_days := NULL; /*5155692 */
5268
5269 /* See if any line with negative rate was derived. If so then update the
5270 corresponding line in ver3 as rate dangling*/
5271
5272 UPDATE PJI_FM_EXTR_PLNVER3_T ver
5273 SET rate_dangling_flag = 'Y'
5274 WHERE (project_id,plan_version_id) IN
5275 ( SELECT project_id,budget_version_id
5276 FROM PA_BUDGET_LINES bl,
5277 pji_time_cal_period_v prd,
5278 PJI_FM_AGGR_DLY_RATES_T rates
5279 WHERE rates.time_id=prd.cal_period_id
5280 AND bl.period_name = prd.name
5281 AND (sign(rates.rate)=-1 OR sign(rates.rate2) = -1)
5282 AND ver.time_phased_type_code IN ('P', 'G')
5283 UNION ALL
5284 SELECT project_id,budget_version_id
5285 FROM pa_resource_assignments ra,
5286 PJI_FM_AGGR_DLY_RATES_T rates
5287 WHERE rates.time_id= DECODE ( g_currency_conversion_rule
5288 , 'S'
5289 , TO_NUMBER(to_CHAR(ra.planning_start_date, 'J'))
5290 , 'E'
5291 , TO_NUMBER(to_CHAR(ra.planning_end_date, 'J')) )
5292 AND (sign(rates.rate)=-1 OR sign(rates.rate2) = -1)
5293 AND ver.time_phased_type_code = 'N'
5294 )
5295 AND ver.wp_flag = 'N'
5296 AND ver.baselined_flag = 'Y';
5297
5298
5299 print_time('........GET_GLOBAL_EXCHANGE_RATES: End. ' );
5300
5301 EXCEPTION
5302 WHEN OTHERS THEN
5303 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
5304 p_procedure_name => 'GET_GLOBAL_EXCHANGE_RATES');
5305 print_time('........GET_GLOBAL_EXCHANGE_RATES: Exception: ' || sqlerrm );
5306 RAISE;
5307 END;
5308
5309
5310 PROCEDURE DELETE_GLOBAL_EXCHANGE_RATES IS
5311 BEGIN
5312
5313 print_time('........DELETE_GLOBAL_EXCHANGE_RATES: Begin. ' );
5314
5315 DELETE FROM PJI_FM_AGGR_DLY_RATES_T
5316 WHERE worker_id = g_worker_id;
5317
5318 print_time('........DELETE_GLOBAL_EXCHANGE_RATES: End. # rows is.. ' || SQL%ROWCOUNT );
5319
5320 EXCEPTION
5321 WHEN OTHERS THEN
5322 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
5323 p_procedure_name => 'DELETE_GLOBAL_EXCHANGE_RATES');
5324 print_time('........DELETE_GLOBAL_EXCHANGE_RATES: Exception: ' || sqlerrm );
5325 RAISE;
5326 END;
5327
5328
5329 /*
5330 PROCEDURE UPDATE_CURR_RCD_TYPES_GL1_GL2
5331 IS BEGIN
5332
5333 -- Algorithm is as follows:
5334 -- ------------------------
5335 -- 1. Get all relevant rows from rpting lines into tmp1 table (GET_PRI_SLICE_DATA already did this).
5336 -- 2. Create/Update records as needed based on exchange rates as follows.
5337 -- SQL 1: Update existing rcds for TXN if GL1/GL2 are equal to TXN.
5338 -- SQL 2: Update existing rcds for PRJ if GL1/GL2 are equal to PRJ and PRJ<>TXN.
5339 -- SQL 3: Update existing rcds for FUNC if GL1/GL2 are equal to FUNC and FUNC<> TXN/PRJ and PRJ<>TXN and 1, 2 don't hold true.
5340 -- SQL 4: Create new rcds using existing records for TXN if GL1/GL2 are not in (TXN, PRJ, FUNC).
5341 -- SQL 5: Update existing rcds for GL1 if GL2 is equal to GL1, etc.
5342 -- SQL 6: Create new rcds using existing records for TXN if GL2 is not in (TXN, PRJ, FUNC, GL1).
5343 --3. Merge the new records into rpting lines.
5344
5345 PJI_FM_PLAN_MAINT_T_PVT.GET_GLOBAL_EXCHANGE_RATES;
5346
5347 PJI_FM_PLAN_MAINT_T_PVT.CONV_TO_GLOBAL_CURRENCIES;
5348
5349 -- This wont work!!!
5350 -- PJI_FM_PLAN_MAINT.MERGE_INTO_REPORTING_LNS_FACT;
5351 -- This wont work!!!
5352
5353 EXCEPTION
5354 WHEN OTHERS THEN
5355 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
5356 p_procedure_name => 'UPDATE_CURR_RCD_TYPES_GL1_GL2');
5357 RAISE;
5358 END;
5359 */
5360
5361
5362 --
5363 -- Stubbed api.
5364 --
5365 /*
5366 PROCEDURE CONV_TO_GLOBAL_CURRENCIES IS
5367 l_return_status VARCHAR2(1);
5368 l_ver3_is_empty VARCHAR2(1);
5369 BEGIN
5370
5371 print_time('........CONV_TO_GLOBAL_CURRENCIES: Begin. ' );
5372
5373 --
5374 -- IF ver3 is empty, return.
5375 --
5376 l_ver3_is_empty := PJI_FM_PLAN_MAINT.CHECK_VER3_NOT_EMPTY ( p_online => 'T');
5377 IF (l_ver3_is_empty = 'T') THEN
5378 print_time ( ' ver3 is empty, nothing to process. Returning. ');
5379 RETURN;
5380 END IF;
5381
5382 --
5383 -- Get currency conversion rules, global currency codes and gl maus.
5384 --
5385 PJI_PJP_FP_CURR_WRAP.get_global_currency_info (
5386 x_currency_conversion_rule => g_currency_conversion_rule
5387 , x_prorating_format => g_prorating_format
5388 , x_global1_currency_code => g_global1_currency_code
5389 , x_global2_currency_code => g_global2_currency_code
5390 , x_global1_currency_mau => g_global1_currency_mau
5391 , x_global2_currency_mau => g_global2_currency_mau ) ;
5392
5393 --
5394 -- Todo: Remove hardcoded currency codes after making code work if one of the global currencies is null.
5395 --
5396 SELECT DECODE(g_global1_currency_code, NULL, 'USD', g_global1_currency_code)
5397 INTO g_global1_currency_code
5398 FROM DUAL;
5399
5400 SELECT DECODE(g_global2_currency_code, NULL, 'USD', g_global2_currency_code)
5401 INTO g_global2_currency_code
5402 FROM DUAL;
5403
5404 print_time(' Got global currency settings. ');
5405 print_time(' g_currency_conversion_rule ' || g_currency_conversion_rule || ' g_prorating_format ' || g_prorating_format );
5406 print_time(' g_global1_currency_code ' || g_global1_currency_code || ' g_global1_currency_code ' || g_global1_currency_code );
5407 print_time(' g_global1_currency_mau ' || g_global1_currency_mau || ' g_global1_currency_mau ' || g_global1_currency_mau ) ;
5408
5409
5410 --
5411 -- IF GL1 and GL2 currencies are not setup correctly, then return.
5412 --
5413 IF (g_global1_currency_code IS NULL AND g_global2_currency_code IS NULL) THEN
5414 print_time('Both global 1 currency and global 2 currency are not defined. Returning from conversion to Global currencies.');
5415 -- MARK_DANGLING_PLAN_VERSIONS; -- !!! Todo. Mark dangling versions.
5416 RETURN;
5417 END IF;
5418
5419 --
5420 -- Delete Smart Slice.
5421 --
5422 PJI_FM_XBS_ACCUM_MAINT.DELETE_SMART_SLICE (
5423 p_online_flag => 'Y'
5424 , x_return_status => l_return_status ) ;
5425 print_time(' Deleted smart slice rollups. # rows deleted is.. ' || SQL%ROWCOUNT);
5426
5427
5428 --
5429 -- Gets exchange rates for entries in fact for all those rows in fact and pjp1 based on
5430 -- if the currency code is same as functional currency code. Rates are based on start/end
5431 -- dates based on plan amt conversion. For non time phased amounts, it is based on
5432 -- start end dates for that period.
5433 --
5434 GET_GLOBAL_EXCHANGE_RATES;
5435 print_time(' Got exchange rates for global currencies. ');
5436
5437
5438 --
5439 -- Inserts rows present in fact and pjp1 into pjp1 with inserted row worker id as
5440 -- g_worker_id.
5441 -- Logic is as follows:
5442 --
5443 -- SQL1: Reverse primary slice from fact for only those rows whose crti can be updated.
5444 -- SQL2: Insert pri slice LNN from fact where CRTI can simply be updated.
5445 -- SQL3: Insert GL1/2 currency record into pjp1 from fact whose crti cannot be updated
5446 -- (meaning, whose func curr <> gl1, gl2).
5447 --
5448 -- SQL4: Insert primary slice from pjp0 for only those rows whose crti cannot be updated.
5449 -- SQL5: Insert pri slice LNN from pjp0 whose CRTI can simply be updated with updated crti.
5450 -- SQL6: Insert GL1/2 currency record into pjp1 from pjp0 whose crti cannot be updated
5451 -- (meaning, whose func curr <> gl1, gl2).
5452 --
5453 CREATE_GL1_GL2_CURR_RCDS;
5454 print_time(' Converted functional currency amounts to global 1, 2 currency amounts. ');
5455
5456
5457 --
5458 -- Proration to other calendars.
5459 --
5460 PRORATE_TO_ALL_CALENDARS;
5461 print_time(' Prorated to all other calendars. ');
5462
5463
5464 --
5465 -- RBS rollup.
5466 --
5467 PJI_FM_PLAN_MAINT_T_PVT.ROLLUP_FPR_RBS_T_SLICE;
5468 print_time(' Created RBS rollup slice. ');
5469
5470
5471 --
5472 -- WBS rollup.
5473 --
5474 PJI_FM_PLAN_MAINT_T_PVT.CREATE_WBSRLP;
5475 print_time(' Created WBS rollup slice. ');
5476
5477
5478 --
5479 -- Calendar rollup.
5480 --
5481 PJI_FM_PLAN_CAL_RLPS_T.CREATE_FP_PA_PRI_ROLLUP;
5482 print_time(' PA calendar rollup. ');
5483
5484 PJI_FM_PLAN_CAL_RLPS_T.CREATE_FP_GL_PRI_ROLLUP;
5485 print_time(' GL calendar rollup. ');
5486
5487 PJI_FM_PLAN_CAL_RLPS_T.CREATE_FP_ALLT_PRI_AGGREGATE;
5488 print_time(' All time slice rollup. ');
5489
5490 PJI_FM_PLAN_CAL_RLPS_T.CREATE_FP_ENT_ROLLUP;
5491 print_time(' Enterprise calendar rollup. ');
5492
5493 --
5494 -- Mark pji summarized flag in pa budget versions table.
5495 -- If rates are missing or GL1/GL2 definitions are missing, then mark those plans as 'P'
5496 --
5497 MARK_DANGLING_PLAN_VERSIONS;
5498
5499 print_time('........CONV_TO_GLOBAL_CURRENCIES: End. ' );
5500
5501 EXCEPTION
5502 WHEN OTHERS THEN
5503 print_time('........CONV_TO_GLOBAL_CURRENCIES: Exception ' || sqlerrm );
5504 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
5505 p_procedure_name => 'CONV_TO_GLOBAL_CURRENCIES');
5506 RAISE;
5507 END;
5508 */
5509
5510
5511 PROCEDURE DELETE_DNGLRATE_PLNVER_DATA IS
5512 BEGIN
5513
5514 DELETE FROM pji_fp_aggr_pjp1_t
5515 WHERE plan_version_id IN
5516 (
5517 SELECT DISTINCT plan_version_id
5518 FROM pji_fp_aggr_pjp1_t
5519 WHERE worker_id = g_worker_id
5520 AND rate_dangling_flag IS NOT NULL )
5521 AND worker_id = g_worker_id;
5522
5523 EXCEPTION
5524 WHEN OTHERS THEN
5525 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
5526 p_procedure_name => 'DELETE_DNGLRATE_PLNVER_DATA');
5527 RAISE;
5528 END;
5529
5530
5531 /*
5532 --
5533 -- Inserts rows present in fact and pjp1 into pjp1 with inserted row worker id as
5534 -- g_worker_id.
5535 -- Logic is as follows:
5536 --
5537 -- SQL1: Reverse primary slice from fact for only those rows whose crti can be updated.
5538 -- SQL2: Insert pri slice LNN from fact where CRTI can simply be updated.
5539 -- SQL3: Insert GL1/2 currency record into pjp1 from fact whose crti cannot be updated
5540 -- (meaning, whose func curr <> gl1, gl2).
5541 --
5542 -- SQL4: Insert primary slice from pjp0 for only those rows whose crti cannot be updated.
5543 -- SQL5: Insert pri slice LNN from pjp0 whose CRTI can simply be updated with updated crti.
5544 -- SQL6: Insert GL1/2 currency record into pjp1 from pjp0 whose crti cannot be updated
5545 -- (meaning, whose func curr <> gl1, gl2).
5546 --
5547 PROCEDURE CREATE_GL1_GL2_CURR_RCDS IS
5548 BEGIN
5549
5550 print_time('........CREATE_GL1_GL2_CURR_RCDS: Begin. ' );
5551
5552
5553
5554 INSERT INTO PJI_FP_AGGR_PJP1_T
5555 (
5556 WORKER_ID
5557 , PROJECT_ID
5558 , PROJECT_ORG_ID
5559 , PROJECT_ORGANIZATION_ID
5560 , PROJECT_ELEMENT_ID
5561 , TIME_ID
5562 , PERIOD_TYPE_ID
5563 , CALENDAR_TYPE
5564 , RBS_AGGR_LEVEL
5565 , WBS_ROLLUP_FLAG
5566 , PRG_ROLLUP_FLAG
5567 , CURR_RECORD_TYPE_ID
5568 , CURRENCY_CODE
5569 , RBS_ELEMENT_ID
5570 , RBS_VERSION_ID
5571 , PLAN_VERSION_ID
5572 , PLAN_TYPE_ID
5573 , RAW_COST
5574 , BRDN_COST
5575 , REVENUE
5576 , BILL_RAW_COST
5577 , BILL_BRDN_COST
5578 , BILL_LABOR_RAW_COST
5579 , BILL_LABOR_BRDN_COST
5580 , BILL_LABOR_HRS
5581 , EQUIPMENT_RAW_COST
5582 , EQUIPMENT_BRDN_COST
5583 , CAPITALIZABLE_RAW_COST
5584 , CAPITALIZABLE_BRDN_COST
5585 , LABOR_RAW_COST
5586 , LABOR_BRDN_COST
5587 , LABOR_HRS
5588 , LABOR_REVENUE
5589 , EQUIPMENT_HOURS
5590 , BILLABLE_EQUIPMENT_HOURS
5591 , SUP_INV_COMMITTED_COST
5592 , PO_COMMITTED_COST
5593 , PR_COMMITTED_COST
5594 , OTH_COMMITTED_COST
5595 , ACT_LABOR_HRS
5596 , ACT_EQUIP_HRS
5597 , ACT_LABOR_BRDN_COST
5598 , ACT_EQUIP_BRDN_COST
5599 , ACT_BRDN_COST
5600 , ACT_RAW_COST
5601 , ACT_REVENUE
5602 , ACT_LABOR_RAW_COST
5603 , ACT_EQUIP_RAW_COST
5604 , ETC_LABOR_HRS
5605 , ETC_EQUIP_HRS
5606 , ETC_LABOR_BRDN_COST
5607 , ETC_EQUIP_BRDN_COST
5608 , ETC_BRDN_COST
5609 , ETC_RAW_COST
5610 , ETC_LABOR_RAW_COST
5611 , ETC_EQUIP_RAW_COST
5612 , CUSTOM1
5613 , CUSTOM2
5614 , CUSTOM3
5615 , CUSTOM4
5616 , CUSTOM5
5617 , CUSTOM6
5618 , CUSTOM7
5619 , CUSTOM8
5620 , CUSTOM9
5621 , CUSTOM10
5622 , CUSTOM11
5623 , CUSTOM12
5624 , CUSTOM13
5625 , CUSTOM14
5626 , CUSTOM15
5627 , LINE_TYPE
5628 , RATE_DANGLING_FLAG
5629 , TIME_DANGLING_FLAG
5630 -- , START_DATE
5631 -- , END_DATE
5632 , PRG_LEVEL
5633 , PLAN_TYPE_CODE -- 4471527
5634 )
5635 SELECT
5636 g_worker_id WORKER_ID
5637 , PROJECT_ID
5638 , PROJECT_ORG_ID
5639 , PROJECT_ORGANIZATION_ID
5640 , PROJECT_ELEMENT_ID
5641 , TIME_ID
5642 , PERIOD_TYPE_ID
5643 , CALENDAR_TYPE
5644 , RBS_AGGR_LEVEL
5645 , WBS_ROLLUP_FLAG
5646 , PRG_ROLLUP_FLAG
5647 , SUM(CURR_RECORD_TYPE_ID)
5648 , CURRENCY_CODE
5649 , RBS_ELEMENT_ID
5650 , RBS_VERSION_ID
5651 , PLAN_VERSION_ID
5652 , PLAN_TYPE_ID
5653 , max(RAW_COST)
5654 , max(BRDN_COST)
5655 , max(REVENUE)
5656 , max(BILL_RAW_COST)
5657 , max(BILL_BRDN_COST)
5658 , max(BILL_LABOR_RAW_COST)
5659 , max(BILL_LABOR_BRDN_COST)
5660 , max(BILL_LABOR_HRS)
5661 , max(EQUIPMENT_RAW_COST)
5662 , max(EQUIPMENT_BRDN_COST)
5663 , max(CAPITALIZABLE_RAW_COST)
5664 , max(CAPITALIZABLE_BRDN_COST)
5665 , max(LABOR_RAW_COST)
5666 , max(LABOR_BRDN_COST)
5667 , max(LABOR_HRS)
5668 , max(LABOR_REVENUE)
5669 , max(EQUIPMENT_HOURS)
5670 , max(BILLABLE_EQUIPMENT_HOURS)
5671 , max(SUP_INV_COMMITTED_COST)
5672 , max(PO_COMMITTED_COST)
5673 , max(PR_COMMITTED_COST)
5674 , max(OTH_COMMITTED_COST)
5675 , max(ACT_LABOR_HRS)
5676 , max(ACT_EQUIP_HRS)
5677 , max(ACT_LABOR_BRDN_COST)
5678 , max(ACT_EQUIP_BRDN_COST)
5679 , max(ACT_BRDN_COST)
5680 , max(ACT_RAW_COST)
5681 , max(ACT_REVENUE)
5682 , max(ACT_LABOR_RAW_COST)
5683 , max(ACT_EQUIP_RAW_COST)
5684 , max(ETC_LABOR_HRS)
5685 , max(ETC_EQUIP_HRS)
5686 , max(ETC_LABOR_BRDN_COST)
5687 , max(ETC_EQUIP_BRDN_COST)
5688 , max(ETC_BRDN_COST)
5689 , max(ETC_RAW_COST)
5690 , max(ETC_LABOR_RAW_COST)
5691 , max(ETC_EQUIP_RAW_COST)
5692 , max(CUSTOM1)
5693 , max(CUSTOM2)
5694 , max(CUSTOM3)
5695 , max(CUSTOM4)
5696 , max(CUSTOM5)
5697 , max(CUSTOM6)
5698 , max(CUSTOM7)
5699 , max(CUSTOM8)
5700 , max(CUSTOM9)
5701 , max(CUSTOM10)
5702 , max(CUSTOM11)
5703 , max(CUSTOM12)
5704 , max(CUSTOM13)
5705 , max(CUSTOM14)
5706 , max(CUSTOM15)
5707 , 'CF' LINE_TYPE
5708 , RATE_DANGLING_FLAG
5709 , TIME_DANGLING_FLAG
5710 -- , START_DATE
5711 -- , END_DATE
5712 , g_default_prg_level PRG_LEVEL
5713 , PLAN_TYPE_CODE -- 4471527
5714 FROM
5715 (
5716 SELECT -- SQL1: Reversal of LNN Slice data in fact
5717 fact.PROJECT_ID
5718 , fact.PROJECT_ORG_ID
5719 , fact.PROJECT_ORGANIZATION_ID
5720 , fact.PROJECT_ELEMENT_ID
5721 , fact.TIME_ID
5722 , fact.PERIOD_TYPE_ID
5723 , fact.CALENDAR_TYPE
5724 , fact.RBS_AGGR_LEVEL
5725 , fact.WBS_ROLLUP_FLAG
5726 , fact.PRG_ROLLUP_FLAG
5727 , fact.CURR_RECORD_TYPE_ID
5728 , fact.CURRENCY_CODE
5729 , fact.RBS_ELEMENT_ID
5730 , fact.RBS_VERSION_ID
5731 , fact.PLAN_VERSION_ID
5732 , fact.PLAN_TYPE_ID
5733 , - RAW_COST RAW_COST
5734 , - BRDN_COST BRDN_COST
5735 , - REVENUE REVENUE
5736 , - BILL_RAW_COST BILL_RAW_COST
5737 , - BILL_BRDN_COST BILL_BRDN_COST
5738 , - BILL_LABOR_RAW_COST BILL_LABOR_RAW_COST
5739 , - BILL_LABOR_BRDN_COST BILL_LABOR_BRDN_COST
5740 , - BILL_LABOR_HRS BILL_LABOR_HRS
5741 , - EQUIPMENT_RAW_COST EQUIPMENT_RAW_COST
5742 , - EQUIPMENT_BRDN_COST EQUIPMENT_BRDN_COST
5743 , - CAPITALIZABLE_RAW_COST CAPITALIZABLE_RAW_COST
5744 , - CAPITALIZABLE_BRDN_COST CAPITALIZABLE_BRDN_COST
5745 , - LABOR_RAW_COST LABOR_RAW_COST
5746 , - LABOR_BRDN_COST LABOR_BRDN_COST
5747 , - LABOR_HRS LABOR_HRS
5748 , - LABOR_REVENUE LABOR_REVENUE
5749 , - EQUIPMENT_HOURS EQUIPMENT_HOURS
5750 , - BILLABLE_EQUIPMENT_HOURS BILLABLE_EQUIPMENT_HOURS
5751 , - SUP_INV_COMMITTED_COST SUP_INV_COMMITTED_COST
5752 , - PO_COMMITTED_COST PO_COMMITTED_COST
5753 , - PR_COMMITTED_COST PR_COMMITTED_COST
5754 , - OTH_COMMITTED_COST OTH_COMMITTED_COST
5755 , - ACT_LABOR_HRS ACT_LABOR_HRS
5756 , - ACT_EQUIP_HRS ACT_EQUIP_HRS
5757 , - ACT_LABOR_BRDN_COST ACT_LABOR_BRDN_COST
5758 , - ACT_EQUIP_BRDN_COST ACT_EQUIP_BRDN_COST
5759 , - ACT_BRDN_COST ACT_BRDN_COST
5760 , - ACT_RAW_COST ACT_RAW_COST
5761 , - ACT_REVENUE ACT_REVENUE
5762 , - ACT_LABOR_RAW_COST ACT_LABOR_RAW_COST
5763 , - ACT_EQUIP_RAW_COST ACT_EQUIP_RAW_COST
5764 , - ETC_LABOR_HRS ETC_LABOR_HRS
5765 , - ETC_EQUIP_HRS ETC_EQUIP_HRS
5766 , - ETC_LABOR_BRDN_COST ETC_LABOR_BRDN_COST
5767 , - ETC_EQUIP_BRDN_COST ETC_EQUIP_BRDN_COST
5768 , - ETC_BRDN_COST ETC_BRDN_COST
5769 , - ETC_RAW_COST ETC_RAW_COST
5770 , - ETC_LABOR_RAW_COST ETC_LABOR_RAW_COST
5771 , - ETC_EQUIP_RAW_COST ETC_EQUIP_RAW_COST
5772 , - CUSTOM1 CUSTOM1
5773 , - CUSTOM2 CUSTOM2
5774 , - CUSTOM3 CUSTOM3
5775 , - CUSTOM4 CUSTOM4
5776 , - CUSTOM5 CUSTOM5
5777 , - CUSTOM6 CUSTOM6
5778 , - CUSTOM7 CUSTOM7
5779 , - CUSTOM8 CUSTOM8
5780 , - CUSTOM9 CUSTOM9
5781 , - CUSTOM10 CUSTOM10
5782 , - CUSTOM11 CUSTOM11
5783 , - CUSTOM12 CUSTOM12
5784 , - CUSTOM13 CUSTOM13
5785 , - CUSTOM14 CUSTOM14
5786 , - CUSTOM15 CUSTOM15
5787 -- , 'OF' LINE_TYPE
5788 , null RATE_DANGLING_FLAG
5789 , null TIME_DANGLING_FLAG
5790 -- , 0 prg_level
5791 , fact.plan_type_code plan_type_code -- 4471527
5792 FROM pji_fp_xbs_accum_f fact
5793 , pji_fm_extr_plnver3_t ver3
5794 WHERE 1=1
5795 AND rbs_aggr_level = g_lowest_level
5796 AND wbs_rollup_flag = 'N'
5797 AND prg_rollup_flag = 'N'
5798 AND fact.project_id = ver3.project_id
5799 AND fact.plan_version_id = ver3.plan_version_id
5800 AND fact.plan_type_code = ver3.plan_type_code --4471527
5801 AND fact.currency_code IN (g_global1_currency_code, g_global2_currency_code)
5802 UNION ALL
5803 SELECT -- SQL4: Insert GL1/2 currency record into pjp1 from pjp0 where func curr <> gl1, gl2.
5804 fact.PROJECT_ID
5805 , PROJECT_ORG_ID
5806 , PROJECT_ORGANIZATION_ID
5807 , PROJECT_ELEMENT_ID
5808 , fact.TIME_ID
5809 , PERIOD_TYPE_ID
5810 , CALENDAR_TYPE
5811 , RBS_AGGR_LEVEL
5812 , WBS_ROLLUP_FLAG
5813 , PRG_ROLLUP_FLAG
5814 , DECODE ( curr.curr_code
5815 , g_global1_currency_code, 2 + DECODE ( g_global1_currency_code, g_global2_currency_code, 1, 0)
5816 , g_global2_currency_code, 1 ) CURR_RECORD_TYPE_ID
5817 , curr.curr_code CURRENCY_CODE
5818 , RBS_ELEMENT_ID
5819 , RBS_VERSION_ID
5820 , fact.PLAN_VERSION_ID
5821 , fact.PLAN_TYPE_ID
5822 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) *RAW_COST/curr.mau )*curr.mau RAW_COST -- curr.mau -- rates.mau rates.mau2
5823 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) *BRDN_COST/curr.mau )*curr.mau BRDN_COST
5824 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) *REVENUE/curr.mau )*curr.mau REVENUE
5825 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) *BILL_RAW_COST/curr.mau )*curr.mau BILL_RAW_COST
5826 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) *BILL_BRDN_COST/curr.mau )*curr.mau BILL_BRDN_COST
5827 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) *BILL_LABOR_RAW_COST/curr.mau )*curr.mau BILL_LABOR_RAW_COST
5828 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) *BILL_LABOR_BRDN_COST/curr.mau )*curr.mau BILL_LABOR_BRDN_COST
5829 , BILL_LABOR_HRS
5830 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * EQUIPMENT_RAW_COST/curr.mau )*curr.mau EQUIPMENT_RAW_COST
5831 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * EQUIPMENT_BRDN_COST/curr.mau )*curr.mau EQUIPMENT_BRDN_COST
5832 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * CAPITALIZABLE_RAW_COST/curr.mau )*curr.mau CAPITALIZABLE_RAW_COST
5833 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * CAPITALIZABLE_BRDN_COST/curr.mau )*curr.mau CAPITALIZABLE_BRDN_COST
5834 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * LABOR_RAW_COST/curr.mau )*curr.mau LABOR_RAW_COST
5835 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * LABOR_BRDN_COST/curr.mau )*curr.mau LABOR_BRDN_COST
5836 , LABOR_HRS
5837 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * LABOR_REVENUE/curr.mau )*curr.mau LABOR_REVENUE
5838 , EQUIPMENT_HOURS
5839 , BILLABLE_EQUIPMENT_HOURS
5840 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * SUP_INV_COMMITTED_COST/curr.mau )*curr.mau SUP_INV_COMMITTED_COST
5841 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * PO_COMMITTED_COST/curr.mau )*curr.mau PO_COMMITTED_COST
5842 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * PR_COMMITTED_COST/curr.mau )*curr.mau PR_COMMITTED_COST
5843 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * OTH_COMMITTED_COST/curr.mau )*curr.mau OTH_COMMITTED_COST
5844 , ACT_LABOR_HRS
5845 , ACT_EQUIP_HRS
5846 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ACT_LABOR_BRDN_COST/curr.mau )*curr.mau ACT_LABOR_BRDN_COST
5847 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ACT_EQUIP_BRDN_COST/curr.mau )*curr.mau ACT_EQUIP_BRDN_COST
5848 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ACT_BRDN_COST/curr.mau )*curr.mau ACT_BRDN_COST
5849 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ACT_RAW_COST/curr.mau )*curr.mau ACT_RAW_COST
5850 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ACT_REVENUE/curr.mau )*curr.mau ACT_REVENUE
5851 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ACT_LABOR_RAW_COST/curr.mau )*curr.mau ACT_LABOR_RAW_COST
5852 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ACT_EQUIP_RAW_COST/curr.mau )*curr.mau ACT_EQUIP_RAW_COST
5853 , ETC_LABOR_HRS
5854 , ETC_EQUIP_HRS
5855 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ETC_LABOR_BRDN_COST/curr.mau )*curr.mau ETC_LABOR_BRDN_COST
5856 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ETC_EQUIP_BRDN_COST/curr.mau )*curr.mau ETC_EQUIP_BRDN_COST
5857 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ETC_BRDN_COST/curr.mau )*curr.mau ETC_BRDN_COST
5858 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ETC_RAW_COST/curr.mau )*curr.mau ETC_RAW_COST
5859 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ETC_LABOR_RAW_COST/curr.mau )*curr.mau ETC_LABOR_RAW_COST
5860 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ETC_EQUIP_RAW_COST/curr.mau )*curr.mau ETC_EQUIP_RAW_COST
5861 , CUSTOM1
5862 , CUSTOM2
5863 , CUSTOM3
5864 , CUSTOM4
5865 , CUSTOM5
5866 , CUSTOM6
5867 , CUSTOM7
5868 , CUSTOM8
5869 , CUSTOM9
5870 , CUSTOM10
5871 , CUSTOM11
5872 , CUSTOM12
5873 , CUSTOM13
5874 , CUSTOM14
5875 , CUSTOM15
5876 -- , 'OG' LINE_TYPE
5877 , DECODE ( DECODE (curr.curr_code
5878 , g_global1_currency_code, rates.rate
5879 , g_global2_currency_code, rates.rate2 )
5880 , NULL, curr.curr_code
5881 , NULL) rate_dangling_flag
5882 , null TIME_DANGLING_FLAG
5883 -- , 0 prg_level
5884 , fact.plan_type_code plan_type_code -- 4471527
5885 FROM pji_fp_aggr_pjp1_t fact
5886 , pa_projects_all ppa
5887 , ( SELECT g_global1_currency_code curr_code, 0.01 mau FROM DUAL
5888 UNION
5889 SELECT g_global2_currency_code curr_code, 0.01 mau FROM DUAL
5890 ) curr
5891 , PJI_FM_AGGR_DLY_RATES_T rates
5892 , ( SELECT cal_period_id period_id, start_date, end_date FROM pji_time_cal_period_v
5893 UNION ALL
5894 SELECT ent_period_id, start_date, end_date FROM pji_time_ent_period_v
5895 ) dates
5896 , pji_fm_extr_plnver3_t ver
5897 WHERE 1=1
5898 AND fact.project_id = ver.project_id -- new
5899 AND fact.plan_version_id = ver.plan_version_id
5900 AND fact.plan_type_code = ver.plan_type_code -- 4471527
5901 AND ver.wp_flag = 'N'
5902 AND ver.baselined_flag = 'Y'
5903 AND fact.project_id = ppa.project_id
5904 AND fact.time_id = dates.period_id
5905 AND fact.worker_id = -1
5906 AND ( ppa.projfunc_currency_code <> g_global1_currency_code
5907 OR ppa.projfunc_currency_code <> g_global2_currency_code )
5908 AND BITAND ( fact.curr_record_type_id, 4) = 4 -- 00100: Converting from Proj Func Currency.
5909 AND fact.currency_code = ppa.projfunc_currency_code
5910 AND rates.time_id = fact.time_id
5911 AND rates.pf_currency_code = ppa.projfunc_currency_code
5912 AND fact.calendar_type IN (g_gl_cal_str, g_pa_cal_str)
5913 UNION ALL
5914 SELECT -- SQL3: Insert GL1/2 currency record into pjp1 from fact where func curr <> gl1, gl2.
5915 fact.PROJECT_ID
5916 , PROJECT_ORG_ID
5917 , PROJECT_ORGANIZATION_ID
5918 -- , PARTITION_ID
5919 , PROJECT_ELEMENT_ID
5920 , fact.TIME_ID
5921 , PERIOD_TYPE_ID
5922 , CALENDAR_TYPE
5923 , RBS_AGGR_LEVEL
5924 , WBS_ROLLUP_FLAG
5925 , PRG_ROLLUP_FLAG
5926 , DECODE ( curr.curr_code
5927 , g_global1_currency_code, 2 + DECODE ( g_global1_currency_code, g_global2_currency_code, 1, 0)
5928 , g_global2_currency_code, 1 ) CURR_RECORD_TYPE_ID
5929 , curr.curr_code CURRENCY_CODE
5930 , RBS_ELEMENT_ID
5931 , RBS_VERSION_ID
5932 , fact.PLAN_VERSION_ID
5933 , fact.PLAN_TYPE_ID
5934 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) *RAW_COST/curr.mau )*curr.mau RAW_COST -- curr.mau -- rates.mau rates.mau2
5935 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) *BRDN_COST/curr.mau )*curr.mau BRDN_COST
5936 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) *REVENUE/curr.mau )*curr.mau REVENUE
5937 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) *BILL_RAW_COST/curr.mau )*curr.mau BILL_RAW_COST
5938 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) *BILL_BRDN_COST/curr.mau )*curr.mau BILL_BRDN_COST
5939 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) *BILL_LABOR_RAW_COST/curr.mau )*curr.mau BILL_LABOR_RAW_COST
5940 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) *BILL_LABOR_BRDN_COST/curr.mau )*curr.mau BILL_LABOR_BRDN_COST
5941 , BILL_LABOR_HRS
5942 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * EQUIPMENT_RAW_COST/curr.mau )*curr.mau EQUIPMENT_RAW_COST
5943 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * EQUIPMENT_BRDN_COST/curr.mau )*curr.mau EQUIPMENT_BRDN_COST
5944 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * CAPITALIZABLE_RAW_COST/curr.mau )*curr.mau CAPITALIZABLE_RAW_COST
5945 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * CAPITALIZABLE_BRDN_COST/curr.mau )*curr.mau CAPITALIZABLE_BRDN_COST
5946 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * LABOR_RAW_COST/curr.mau )*curr.mau LABOR_RAW_COST
5947 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * LABOR_BRDN_COST/curr.mau )*curr.mau LABOR_BRDN_COST
5948 , LABOR_HRS
5949 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * LABOR_REVENUE/curr.mau )*curr.mau LABOR_REVENUE
5950 , EQUIPMENT_HOURS
5951 , BILLABLE_EQUIPMENT_HOURS
5952 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * SUP_INV_COMMITTED_COST/curr.mau )*curr.mau SUP_INV_COMMITTED_COST
5953 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * PO_COMMITTED_COST/curr.mau )*curr.mau PO_COMMITTED_COST
5954 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * PR_COMMITTED_COST/curr.mau )*curr.mau PR_COMMITTED_COST
5955 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * OTH_COMMITTED_COST/curr.mau )*curr.mau OTH_COMMITTED_COST
5956 , ACT_LABOR_HRS
5957 , ACT_EQUIP_HRS
5958 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ACT_LABOR_BRDN_COST/curr.mau )*curr.mau ACT_LABOR_BRDN_COST
5959 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ACT_EQUIP_BRDN_COST/curr.mau )*curr.mau ACT_EQUIP_BRDN_COST
5960 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ACT_BRDN_COST/curr.mau )*curr.mau ACT_BRDN_COST
5961 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ACT_RAW_COST/curr.mau )*curr.mau ACT_RAW_COST
5962 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ACT_REVENUE/curr.mau )*curr.mau ACT_REVENUE
5963 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ACT_LABOR_RAW_COST/curr.mau )*curr.mau ACT_LABOR_RAW_COST
5964 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ACT_EQUIP_RAW_COST/curr.mau )*curr.mau ACT_EQUIP_RAW_COST
5965 , ETC_LABOR_HRS
5966 , ETC_EQUIP_HRS
5967 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ETC_LABOR_BRDN_COST/curr.mau )*curr.mau ETC_LABOR_BRDN_COST
5968 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ETC_EQUIP_BRDN_COST/curr.mau )*curr.mau ETC_EQUIP_BRDN_COST
5969 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ETC_BRDN_COST/curr.mau )*curr.mau ETC_BRDN_COST
5970 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ETC_RAW_COST/curr.mau )*curr.mau ETC_RAW_COST
5971 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ETC_LABOR_RAW_COST/curr.mau )*curr.mau ETC_LABOR_RAW_COST
5972 , ROUND(decode (curr.curr_code, g_global1_currency_code, rates.rate, g_global2_currency_code, rates.rate2 ) * ETC_EQUIP_RAW_COST/curr.mau )*curr.mau ETC_EQUIP_RAW_COST
5973 , CUSTOM1
5974 , CUSTOM2
5975 , CUSTOM3
5976 , CUSTOM4
5977 , CUSTOM5
5978 , CUSTOM6
5979 , CUSTOM7
5980 , CUSTOM8
5981 , CUSTOM9
5982 , CUSTOM10
5983 , CUSTOM11
5984 , CUSTOM12
5985 , CUSTOM13
5986 , CUSTOM14
5987 , CUSTOM15
5988 -- , 'OG' LINE_TYPE
5989 , DECODE ( DECODE (curr.curr_code
5990 , g_global1_currency_code, rates.rate
5991 , g_global2_currency_code, rates.rate2 )
5992 , NULL, curr.curr_code
5993 , NULL) rate_dangling_flag
5994 , null TIME_DANGLING_FLAG
5995 -- , 0 prg_level
5996 , fact.plan_type_code plan_type_code -- 4471527
5997 FROM pji_fp_xbs_accum_f fact
5998 , pa_projects_all ppa
5999 , ( SELECT g_global1_currency_code curr_code, 0.01 mau FROM DUAL
6000 UNION
6001 SELECT g_global2_currency_code curr_code, 0.01 mau FROM DUAL
6002 ) curr
6003 , PJI_FM_AGGR_DLY_RATES_T rates
6004 , ( SELECT cal_period_id period_id, start_date, end_date FROM pji_time_cal_period_v
6005 UNION ALL
6006 SELECT ent_period_id, start_date, end_date FROM pji_time_ent_period_v
6007 ) dates
6008 , pji_fm_extr_plnver3_t ver
6009 WHERE 1=1
6010 AND fact.project_id = ver.project_id -- new
6011 AND fact.plan_version_id = ver.plan_version_id
6012 ANd fact.plan_type_code = ver.plan_type_code -- 4471527
6013 AND ver.wp_flag = 'N'
6014 AND ver.baselined_flag = 'Y'
6015 AND fact.project_id = ppa.project_id
6016 AND fact.time_id = dates.period_id
6017 AND ( ppa.projfunc_currency_code <> g_global1_currency_code
6018 OR ppa.projfunc_currency_code <> g_global2_currency_code )
6019 AND BITAND ( fact.curr_record_type_id, 4) = 4 -- 00100: Converting from Proj Func Currency.
6020 AND fact.currency_code = ppa.projfunc_currency_code
6021 AND rates.time_id = fact.time_id
6022 AND rates.pf_currency_code = ppa.projfunc_currency_code
6023 AND fact.calendar_type IN (g_gl_cal_str, g_pa_cal_str)
6024 AND fact.rbs_aggr_level = g_lowest_level
6025 AND fact.wbs_rollup_flag = 'N'
6026 AND fact.prg_rollup_flag = 'N'
6027 UNION ALL
6028 SELECT -- SQL 5: Insert pri slice LNN from pjp0 where CRTI can simply be updated.
6029 fact.PROJECT_ID
6030 , PROJECT_ORG_ID
6031 , PROJECT_ORGANIZATION_ID
6032 , PROJECT_ELEMENT_ID
6033 , TIME_ID
6034 , PERIOD_TYPE_ID
6035 , CALENDAR_TYPE
6036 , RBS_AGGR_LEVEL
6037 , WBS_ROLLUP_FLAG
6038 , PRG_ROLLUP_FLAG
6039 , CURR_RECORD_TYPE_ID
6040 + DECODE (currency_code, g_global1_currency_code
6041 , DECODE(BITAND(fact.curr_record_type_id, 2), 0, 2, 0)
6042 , 0) -- 000.000.010 = 2
6043 + DECODE (currency_code, g_global2_currency_code
6044 , DECODE(BITAND(fact.curr_record_type_id, 1), 0, 1, 0)
6045 , 0) -- 000.000.010 = 2
6046 , CURRENCY_CODE
6047 , RBS_ELEMENT_ID
6048 , RBS_VERSION_ID
6049 , fact.PLAN_VERSION_ID
6050 , fact.PLAN_TYPE_ID
6051 , RAW_COST
6052 , BRDN_COST
6053 , REVENUE
6054 , BILL_RAW_COST
6055 , BILL_BRDN_COST
6056 , BILL_LABOR_RAW_COST
6057 , BILL_LABOR_BRDN_COST
6058 , BILL_LABOR_HRS
6059 , EQUIPMENT_RAW_COST
6060 , EQUIPMENT_BRDN_COST
6061 , CAPITALIZABLE_RAW_COST
6062 , CAPITALIZABLE_BRDN_COST
6063 , LABOR_RAW_COST
6064 , LABOR_BRDN_COST
6065 , LABOR_HRS
6066 , LABOR_REVENUE
6067 , EQUIPMENT_HOURS
6068 , BILLABLE_EQUIPMENT_HOURS
6069 , SUP_INV_COMMITTED_COST
6070 , PO_COMMITTED_COST
6071 , PR_COMMITTED_COST
6072 , OTH_COMMITTED_COST
6073 , ACT_LABOR_HRS
6074 , ACT_EQUIP_HRS
6075 , ACT_LABOR_BRDN_COST
6076 , ACT_EQUIP_BRDN_COST
6077 , ACT_BRDN_COST
6078 , ACT_RAW_COST
6079 , ACT_REVENUE
6080 , ACT_LABOR_RAW_COST
6081 , ACT_EQUIP_RAW_COST
6082 , ETC_LABOR_HRS
6083 , ETC_EQUIP_HRS
6084 , ETC_LABOR_BRDN_COST
6085 , ETC_EQUIP_BRDN_COST
6086 , ETC_BRDN_COST
6087 , ETC_RAW_COST
6088 , ETC_LABOR_RAW_COST
6089 , ETC_EQUIP_RAW_COST
6090 , CUSTOM1
6091 , CUSTOM2
6092 , CUSTOM3
6093 , CUSTOM4
6094 , CUSTOM5
6095 , CUSTOM6
6096 , CUSTOM7
6097 , CUSTOM8
6098 , CUSTOM9
6099 , CUSTOM10
6100 , CUSTOM11
6101 , CUSTOM12
6102 , CUSTOM13
6103 , CUSTOM14
6104 , CUSTOM15
6105 -- , LINE_TYPE
6106 , fact.RATE_DANGLING_FLAG
6107 , fact.TIME_DANGLING_FLAG
6108 -- , 0
6109 , fact.plan_type_code plan_type_code -- 4471527
6110 FROM pji_fp_aggr_pjp1_t fact
6111 , pji_fm_extr_plnver3_t ver
6112 WHERE 1=1
6113 AND fact.worker_id = -1
6114 AND fact.project_id = ver.project_id
6115 AND fact.plan_version_id = ver.plan_version_id
6116 ANd fact.plan_type_code = ver.plan_type_code -- 4471527
6117 AND rbs_aggr_level = g_lowest_level
6118 AND wbs_rollup_flag = 'N'
6119 AND prg_rollup_flag = 'N'
6120 AND ver.wp_flag = 'N'
6121 AND ver.baselined_flag = 'Y'
6122 AND BITAND(curr_record_type_id, 7) IN (4, 5, 6)
6123 AND currency_code in ( g_global1_currency_code, g_global2_currency_code )
6124 UNION ALL
6125 SELECT -- SQL 5: Insert pri slice LNN from fact where CRTI can simply be updated.
6126 fact.PROJECT_ID
6127 , PROJECT_ORG_ID
6128 , PROJECT_ORGANIZATION_ID
6129 , PROJECT_ELEMENT_ID
6130 , TIME_ID
6131 , PERIOD_TYPE_ID
6132 , CALENDAR_TYPE
6133 , RBS_AGGR_LEVEL
6134 , WBS_ROLLUP_FLAG
6135 , PRG_ROLLUP_FLAG
6136 , CURR_RECORD_TYPE_ID
6137 + DECODE (currency_code, g_global1_currency_code
6138 , DECODE(BITAND(fact.curr_record_type_id, 2), 0, 2, 0)
6139 , 0) -- 000.000.010 = 2
6140 + DECODE (currency_code, g_global2_currency_code
6141 , DECODE(BITAND(fact.curr_record_type_id, 1), 0, 1, 0)
6142 , 0) -- 000.000.010 = 2
6143 , CURRENCY_CODE
6144 , RBS_ELEMENT_ID
6145 , RBS_VERSION_ID
6146 , fact.PLAN_VERSION_ID
6147 , fact.PLAN_TYPE_ID
6148 , RAW_COST
6149 , BRDN_COST
6150 , REVENUE
6151 , BILL_RAW_COST
6152 , BILL_BRDN_COST
6153 , BILL_LABOR_RAW_COST
6154 , BILL_LABOR_BRDN_COST
6155 , BILL_LABOR_HRS
6156 , EQUIPMENT_RAW_COST
6157 , EQUIPMENT_BRDN_COST
6158 , CAPITALIZABLE_RAW_COST
6159 , CAPITALIZABLE_BRDN_COST
6160 , LABOR_RAW_COST
6161 , LABOR_BRDN_COST
6162 , LABOR_HRS
6163 , LABOR_REVENUE
6164 , EQUIPMENT_HOURS
6165 , BILLABLE_EQUIPMENT_HOURS
6166 , SUP_INV_COMMITTED_COST
6167 , PO_COMMITTED_COST
6168 , PR_COMMITTED_COST
6169 , OTH_COMMITTED_COST
6170 , ACT_LABOR_HRS
6171 , ACT_EQUIP_HRS
6172 , ACT_LABOR_BRDN_COST
6173 , ACT_EQUIP_BRDN_COST
6174 , ACT_BRDN_COST
6175 , ACT_RAW_COST
6176 , ACT_REVENUE
6177 , ACT_LABOR_RAW_COST
6178 , ACT_EQUIP_RAW_COST
6179 , ETC_LABOR_HRS
6180 , ETC_EQUIP_HRS
6181 , ETC_LABOR_BRDN_COST
6182 , ETC_EQUIP_BRDN_COST
6183 , ETC_BRDN_COST
6184 , ETC_RAW_COST
6185 , ETC_LABOR_RAW_COST
6186 , ETC_EQUIP_RAW_COST
6187 , CUSTOM1
6188 , CUSTOM2
6189 , CUSTOM3
6190 , CUSTOM4
6191 , CUSTOM5
6192 , CUSTOM6
6193 , CUSTOM7
6194 , CUSTOM8
6195 , CUSTOM9
6196 , CUSTOM10
6197 , CUSTOM11
6198 , CUSTOM12
6199 , CUSTOM13
6200 , CUSTOM14
6201 , CUSTOM15
6202 -- , 'CF'
6203 , NULL
6204 , NULL
6205 -- , START_DATE
6206 -- , END_DATE
6207 -- , 0
6208 , fact.plan_type_code plan_type_code -- 4471527
6209 FROM pji_fp_xbs_accum_f fact
6210 , pji_fm_extr_plnver3_t ver
6211 WHERE 1=1
6212 AND fact.project_id = ver.project_id
6213 AND fact.plan_version_id = ver.plan_version_id
6214 AND fact.plan_type_code = ver.plan_type_code -- 4471527
6215 AND rbs_aggr_level = g_lowest_level
6216 AND wbs_rollup_flag = 'N'
6217 AND prg_rollup_flag = 'N'
6218 AND ver.wp_flag = 'N'
6219 AND ver.baselined_flag = 'Y'
6220 AND BITAND(curr_record_type_id, 7) IN (4, 5, 6)
6221 AND currency_code in ( g_global1_currency_code, g_global2_currency_code )
6222 ) fact
6223 GROUP BY
6224 PROJECT_ID
6225 , PROJECT_ORG_ID
6226 , PROJECT_ORGANIZATION_ID
6227 , PROJECT_ELEMENT_ID
6228 , TIME_ID
6229 , PERIOD_TYPE_ID
6230 , CALENDAR_TYPE
6231 , RBS_AGGR_LEVEL
6232 , WBS_ROLLUP_FLAG
6233 , PRG_ROLLUP_FLAG
6234 , CURRENCY_CODE
6235 , RBS_ELEMENT_ID
6236 , RBS_VERSION_ID
6237 , PLAN_VERSION_ID
6238 , PLAN_TYPE_ID
6239 , RATE_DANGLING_FLAG
6240 , TIME_DANGLING_FLAG
6241 , PLAN_TYPE_CODE ; --- 4471527
6242
6243
6244 print_time('........CREATE_GL1_GL2_CURR_RCDS: End. ' );
6245
6246 EXCEPTION
6247 WHEN OTHERS THEN
6248 print_time('........CREATE_GL1_GL2_CURR_RCDS: Exception. ' || sqlerrm );
6249 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6250 p_procedure_name => 'CREATE_GL1_GL2_CURR_RCDS');
6251 RAISE;
6252 END;
6253 */
6254
6255
6256 PROCEDURE UPDATE_TPFG1_CURR_RCDS
6257 IS BEGIN
6258
6259 print_time('........UPDATE_TPFG1_CURR_RCDS: Begin. ' );
6260
6261 UPDATE pji_fp_xbs_accum_f
6262 SET CURR_RECORD_TYPE_ID = CURR_RECORD_TYPE_ID +
6263 DECODE (currency_code, g_global1_currency_code, 2, 0) -- 000.000.010 = 2
6264 + DECODE (currency_code, g_global2_currency_code, 1, 0) -- 000.000.001 = 1
6265 WHERE BITAND(curr_record_type_id, 28) >= 4 -- 000.011.110 = 16 + 8 + 4 = 28
6266 AND (currency_code IN (g_global1_currency_code, g_global2_currency_code))
6267 AND plan_version_id IN
6268 (SELECT DISTINCT plan_version_id
6269 FROM PJI_FM_EXTR_PLNVER3_T
6270 WHERE 1=1
6271 AND baselined_flag = 'Y'
6272 AND wp_flag = 'N');
6273
6274 UPDATE pji_fp_aggr_pjp1_t
6275 SET CURR_RECORD_TYPE_ID = CURR_RECORD_TYPE_ID +
6276 DECODE (currency_code, g_global1_currency_code, 2, 0) -- 000.000.010 = 2
6277 + DECODE (currency_code, g_global2_currency_code, 1, 0) -- 000.000.001 = 1
6278 WHERE BITAND(curr_record_type_id, 28) >= 4 -- 000.011.110 = 16 + 8 + 4 = 28
6279 AND (currency_code IN (g_global1_currency_code, g_global2_currency_code))
6280 AND worker_id = g_worker_id
6281 AND plan_version_id IN
6282 (SELECT DISTINCT plan_version_id
6283 FROM PJI_FM_EXTR_PLNVER3_T
6284 WHERE 1=1
6285 AND baselined_flag = 'Y'
6286 AND wp_flag = 'N');
6287
6288 print_time('........UPDATE_TPFG1_CURR_RCDS: End. ' );
6289
6290 EXCEPTION
6291 WHEN OTHERS THEN
6292 print_time('........UPDATE_TPFG1_CURR_RCDS: Exception: ' || sqlerrm );
6293 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6294 p_procedure_name => 'UPDATE_TPFG1_CURR_RCDS');
6295 RAISE;
6296 END;
6297
6298
6299 PROCEDURE DO_CURRENCY_DANGLING_CHECK
6300 IS BEGIN
6301
6302 UPDATE PJI_FM_EXTR_PLNVER3_T
6303 SET rate_dangling_flag = 'Y'
6304 WHERE plan_version_id IN (
6305 SELECT
6306 fact.PLAN_VERSION_ID
6307 FROM pji_fp_aggr_pjp1_t fact
6308 , PJI_FM_AGGR_DLY_RATES_T rates
6309 , ( SELECT cal_period_id period_id, start_date, end_date FROM pji_time_cal_period_v
6310 UNION ALL
6311 SELECT cal_qtr_id, start_date, end_date FROM pji_time_cal_qtr_v
6312 UNION ALL
6313 SELECT cal_year_id, start_date, end_date FROM pji_time_cal_year_v
6314 UNION ALL
6315 SELECT ent_period_id, start_date, end_date FROM pji_time_ent_period_v
6316 UNION ALL
6317 SELECT ent_qtr_id, start_date, end_date FROM pji_time_ent_qtr
6318 UNION ALL
6319 SELECT ent_year_id, start_date, end_date FROM pji_time_ent_year
6320 UNION ALL
6321 SELECT week_id, start_date, end_date FROM pji_time_week
6322 ) dates
6323 WHERE 1=1
6324 AND fact.worker_id = g_worker_id
6325 AND dates.period_id = fact.time_id
6326 AND rates.time_id = DECODE ( g_start_str
6327 , g_start_str, TO_CHAR(dates.start_date, 'J')
6328 , g_end_str, TO_CHAR(dates.end_date, 'J') )
6329 AND ( rates.rate IS NULL or rates.rate2 IS NULL )
6330 );
6331
6332
6333 EXCEPTION
6334 WHEN OTHERS THEN
6335 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6336 p_procedure_name => 'DO_CURRENCY_DANGLING_CHECK');
6337 RAISE;
6338 END;
6339
6340
6341 PROCEDURE GET_PRORATE_FORMAT
6342 IS BEGIN
6343
6344 NULL;
6345
6346 EXCEPTION
6347 WHEN OTHERS THEN
6348 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6349 p_procedure_name => 'GET_PRORATE_FORMAT');
6350 RAISE;
6351 END;
6352
6353
6354 PROCEDURE GET_SPREAD_DATE_RANGE_AMOUNTS
6355 IS BEGIN
6356
6357 NULL;
6358
6359 EXCEPTION
6360 WHEN OTHERS THEN
6361 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6362 p_procedure_name => 'GET_SPREAD_DATE_RANGE_AMOUNTS');
6363 RAISE;
6364 END;
6365
6366
6367 PROCEDURE SPREAD_NON_TIME_PHASE_AMOUNTS
6368 IS BEGIN
6369
6370 NULL;
6371
6372 EXCEPTION
6373 WHEN OTHERS THEN
6374 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6375 p_procedure_name => 'SPREAD_NON_TIME_PHASE_AMOUNTS');
6376 RAISE;
6377 END;
6378
6379
6380 PROCEDURE PRORATE_NON_TIME_PHASED_AMTS(
6381 p_calENDar_type IN VARCHAR2 := NULL -- Values can be GL, PA, ENT, ENTW.
6382 ) IS BEGIN
6383
6384 -- What slices will be prorated to PA.
6385 -- Primary slice entries in GL calendar.
6386 -- How to identify? Programming construct OP.
6387
6388 NULL;
6389
6390 EXCEPTION
6391 WHEN OTHERS THEN
6392 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6393 p_procedure_name => 'PRORATE_NON_TIME_PHASED_AMTS');
6394 RAISE;
6395 END;
6396
6397
6398 PROCEDURE PRORATE_TO_OTHER_CALENDAR(
6399 p_calENDar_type IN VARCHAR2 := NULL -- Values can be GL, PA, ENT, ENTW.
6400 ) IS
6401 BEGIN
6402
6403 --
6404 -- Logic to identify the records that are 'original'/'converted' format
6405 -- etc is similar to that for PJI. This is to make it easy for dev working
6406 -- on one module (PJI/PRP) to understand the other with minimum effort.
6407 --
6408 -- Logic is as follows:
6409 -------------------------------------------------------------------------
6410 -- 1. All 'entered' amounts (from pri slice) will have a line type *tag* 'OF'
6411 -- if calendar type is PA/GL. If no calendar type is mentioned,
6412 -- then, it will be 'F1'. Tag == line type column in tmp table.
6413 -- 2. Non time phased amounts if prorated to ENT cal will be tagged 'OF'.
6414 -- This has not been decided yet.
6415 -- 3. Amounts from PA/GL cal entries that have been converted to global will
6416 -- have a tag 'OG'.
6417 -- 4. Non PA calendar entries of OF/OG when converted to PA calendar will have
6418 -- a tag 'CF/CG' respectively.
6419 -- 5. Non GL calendar entries of OF/OG when converted to GL calendar will have
6420 -- a tag 'CF/CG' respectively.
6421 -- 6. Non ENT calendar entries of OF/OG when converted to ENT calendar will have
6422 -- a tag 'CF/CG' respectively.
6423 -- 7. Non ENTW calendar entries of OF/OG when converted to ENTW calendar will have
6424 -- a tag 'CF/CG' respectively.
6425 --
6426
6427 IF (p_calENDar_type = 'PA') THEN
6428 PRORATE('PA');
6429 ELSIF (p_calENDar_type = 'GL') THEN
6430 PRORATE('GL');
6431 ELSIF (p_calENDar_type = 'ENT') THEN
6432 PRORATE_TO_ENT;
6433 END IF;
6434
6435 EXCEPTION
6436 WHEN OTHERS THEN
6437 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6438 p_procedure_name => 'PRORATE_TO_OTHER_CALENDAR');
6439 RAISE;
6440 END;
6441
6442
6443 --
6444 -- Prorate entries in RL fact and pjp1 table in
6445 -- 1. GL and Non time phased into PA.
6446 -- 2. PA into GL.
6447 -- 3. PA and GL into Ent.
6448 --
6449 PROCEDURE PRORATE_TO_ALL_CALENDARS IS
6450 BEGIN
6451
6452 print_time('PRORATE_TO_ALL_CALENDARS: Begin.. ');
6453
6454 PRORATE_TO_OTHER_CALENDAR('PA'); -- Prorate entries in Non time phased and GL cal entries into PA cal.
6455 PRORATE_TO_OTHER_CALENDAR('GL'); -- Prorate entries in PA cal into GL cal.
6456 PRORATE_TO_OTHER_CALENDAR('ENT'); -- Prorate entries in PA and GL cals into ENT cal.
6457
6458 print_time('PRORATE_TO_ALL_CALENDARS: End.. ');
6459
6460 EXCEPTION
6461 WHEN NO_DATA_FOUND THEN
6462
6463 /* This issue will come only when PJI_PJP_FP_CURR_WRAP.get_ent_dates_info gives a no_data_found error.
6464 updating the plan versions as time dangling so that the plan will be marked as dangling. Not updating
6465 the existing records so that data for the primary calendar is not impacted because of issue in proration to
6466 other calendars */
6467
6468 UPDATE PJI_FM_EXTR_PLNVER3_T
6469 SET time_dangling_flag='Y'
6470 WHERE wp_flag='N'
6471 AND baselined_flag = 'Y' ;
6472 -- Not raising any exception as we want the processing to happen properly.
6473 -- The where condition is added to make sure that workplan versions are not marked as dangling.
6474 WHEN OTHERS THEN
6475 print_time('PRORATE_TO_ALL_CALENDARS: Exception.. ' || sqlerrm);
6476 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6477 p_procedure_name => 'PRORATE_TO_ALL_CALENDARS');
6478 RAISE;
6479 END;
6480
6481
6482 PROCEDURE PRORATE_TO_ENT IS
6483 l_calendar_type VARCHAR2(15) := g_ent_cal_str;
6484 BEGIN
6485
6486 PJI_PJP_FP_CURR_WRAP.get_global_currency_info (
6487 x_currency_conversion_rule => g_currency_conversion_rule
6488 , x_prorating_format => g_prorating_format
6489 , x_global1_currency_code => g_global1_currency_code
6490 , x_global2_currency_code => g_global2_currency_code
6491 , x_global1_currency_mau => g_global1_currency_mau
6492 , x_global2_currency_mau => g_global2_currency_mau ) ;
6493
6494
6495 PJI_PJP_FP_CURR_WRAP.get_ent_dates_info (
6496 x_global_start_date => g_global_start_date
6497 , x_ent_start_period_id => g_ent_start_period_id
6498 , x_ent_start_period_name => g_ent_start_period_name
6499 , x_ent_start_date => g_ent_start_date
6500 , x_ent_END_date => g_ent_END_date
6501 , x_global_start_J => g_global_start_J
6502 , x_ent_start_J => g_ent_start_J
6503 , x_ent_END_J => g_ent_END_J
6504 ) ;
6505
6506 -- Refer to prorating logic in 'PRORATE_TO_OTHER_CALENDAR' proc.
6507 -- PRORATE('ENT');
6508
6509 IF (g_prorating_format = 'D') THEN
6510
6511 PJI_FM_PLAN_CAL_RLPS_T.PRORATE_TO_ENT_PG_PJP1_D;
6512 -- PJI_FM_PLAN_CAL_RLPS_T.PRORATE_TO_ENT_PG_FPRL_D;
6513 PJI_FM_PLAN_CAL_RLPS_T.PRORATE_TO_ENT_N_PJP1_D;
6514
6515 ELSIF (g_prorating_format IN ( g_end_str, g_start_str ) ) THEN
6516
6517 /*Added parameter g_prorating_format for bug 4005006*/
6518 PJI_FM_PLAN_CAL_RLPS_T.PRORATE_TO_ENT_PG_PJP1_SE(g_prorating_format);
6519 -- PJI_FM_PLAN_CAL_RLPS_T.PRORATE_TO_ENT_PG_FPRL_SE;
6520 PJI_FM_PLAN_CAL_RLPS_T.PRORATE_TO_ENT_N_PJP1_SE(g_prorating_format);
6521
6522 ELSE
6523 NULL;
6524 END IF;
6525
6526 EXCEPTION
6527 WHEN OTHERS THEN
6528 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6529 p_procedure_name => 'PRORATE_TO_ENT');
6530 RAISE;
6531 END;
6532
6533
6534 /*
6535 PROCEDURE PRORATE_TO_ENT_NONTIMEPH IS
6536 l_last_update_date date := SYSDATE;
6537 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
6538 l_creation_date date := SYSDATE;
6539 l_created_by NUMBER := FND_GLOBAL.USER_ID;
6540 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
6541
6542 l_calendar_type VARCHAR2(15) := 'ENT';
6543 BEGIN
6544
6545 NULL;
6546
6547 EXCEPTION
6548 WHEN OTHERS THEN
6549 RAISE;
6550 END;
6551 */
6552
6553
6554 PROCEDURE PRORATE(
6555 p_calENDar_type IN VARCHAR2 := NULL -- Values can be GL, PA, ENT, ENTW.
6556 ) IS
6557 l_calendar_type VARCHAR2(15);
6558
6559 BEGIN
6560
6561 IF (p_calENDar_type NOT IN ('PA', 'GL')) THEN RETURN; END IF;
6562
6563 IF (p_calENDar_type = 'PA') THEN l_calENDar_type := g_pa_cal_str;
6564 ELSIF (p_calENDar_type = 'GL') THEN l_calENDar_type := g_gl_cal_str;
6565 ELSE RETURN;
6566 END IF;
6567
6568
6569 PJI_PJP_FP_CURR_WRAP.get_global_currency_info (
6570 x_currency_conversion_rule => g_currency_conversion_rule
6571 , x_prorating_format => g_prorating_format
6572 , x_global1_currency_code => g_global1_currency_code
6573 , x_global2_currency_code => g_global2_currency_code
6574 , x_global1_currency_mau => g_global1_currency_mau
6575 , x_global2_currency_mau => g_global2_currency_mau ) ;
6576
6577
6578 PJI_PJP_FP_CURR_WRAP.get_ent_dates_info (
6579 x_global_start_date => g_global_start_date
6580 , x_ent_start_period_id => g_ent_start_period_id
6581 , x_ent_start_period_name => g_ent_start_period_name
6582 , x_ent_start_date => g_ent_start_date
6583 , x_ent_END_date => g_ent_END_date
6584 , x_global_start_J => g_global_start_J
6585 , x_ent_start_J => g_ent_start_J
6586 , x_ent_END_J => g_ent_END_J
6587 ) ;
6588
6589 print_time ( ' Prorating format is .. ' || g_prorating_format ) ;
6590
6591 IF (g_prorating_format = 'D') THEN
6592
6593 PJI_FM_PLAN_CAL_RLPS_T.PRORATE_TO_PAGL_PGE_PJP1_D( p_calendar_type => l_calendar_type );
6594 PJI_FM_PLAN_CAL_RLPS_T.PRORATE_TO_PAGL_N_PJP1_D( p_calendar_type => l_calendar_type );
6595
6596 ELSIF (g_prorating_format IN ( g_end_str, g_start_str ) ) THEN
6597
6598 -- Changed for bug 4005006
6599 PJI_FM_PLAN_CAL_RLPS_T.PRORATE_TO_PAGL_PGE_PJP1_SE( p_calendar_type => l_calendar_type ,
6600 p_prorating_format => g_prorating_format);
6601
6602 -- Commenting out the following call for 4252205.
6603 -- PJI_FM_PLAN_CAL_RLPS_T.PRORATE_TO_PAGL_PGE_FPRL_SE( p_calendar_type => l_calendar_type );
6604
6605 -- Added for bug 4005006
6606 PJI_FM_PLAN_CAL_RLPS_T.PRORATE_TO_PAGL_N_PJP1_SE( p_calendar_type => l_calendar_type ,
6607 p_prorating_format => g_prorating_format);
6608
6609 ELSE
6610 NULL;
6611 END IF;
6612
6613 EXCEPTION
6614 WHEN OTHERS THEN
6615 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6616 p_procedure_name => 'PRORATE');
6617 RAISE;
6618 END;
6619
6620
6621 PROCEDURE MERGE_INTO_FP_FACT IS
6622
6623 l_per_analysis_flag varchar2(2); /* Added for bug 9048716 */
6624
6625 BEGIN
6626
6627 /* Added for bug 9048716 starts */
6628 l_per_analysis_flag := PJI_UTILS.GET_SETUP_PARAMETER('PER_ANALYSIS_FLAG');
6629
6630 if l_per_analysis_flag = 'N' then
6631
6632 DELETE FROM PJI_FP_AGGR_PJP1_T
6633 WHERE calendar_type <> 'A'
6634 and plan_type_id=10; -- Modified for Bug 14369993
6635
6636 end if;
6637 /* Added for bug 9048716 ends */
6638
6639 print_time ( ' MERGE_INTO_FP_FACT 1 ' ) ;
6640 CLEANUP_FP_RMAP_FPR;
6641 print_time ( ' MERGE_INTO_FP_FACT 2 ' ) ;
6642 GET_FP_ROW_IDS;
6643 print_time ( ' MERGE_INTO_FP_FACT 3 ' ) ;
6644 UPDATE_FP_ROWS;
6645 print_time ( ' MERGE_INTO_FP_FACT 4 ' ) ;
6646 INSERT_FP_ROWS;
6647 print_time ( ' MERGE_INTO_FP_FACT 5 ' ) ;
6648
6649 EXCEPTION
6650 WHEN OTHERS THEN
6651 print_time ( ' MERGE_INTO_FP_FACT 6 ' ) ;
6652 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6653 p_procedure_name => 'MERGE_INTO_FP_FACT');
6654 RAISE;
6655 END;
6656
6657
6658 PROCEDURE CLEANUP_FP_RMAP_FPR IS
6659 BEGIN
6660
6661 print_time ( 'CLEANUP_FP_RMAP_FPR begin..');
6662
6663 DELETE FROM PJI_FP_RMAP_FPR_T
6664 WHERE worker_id = g_worker_id;
6665
6666 print_time ( 'CLEANUP_FP_RMAP_FPR end.' || g_worker_id );
6667
6668 EXCEPTION
6669 WHEN OTHERS THEN
6670 print_time ( 'ccc' || sqlerrm );
6671 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6672 p_procedure_name => 'CLEANUP_FP_RMAP_FPR');
6673 RAISE;
6674 END;
6675
6676
6677 PROCEDURE GET_FP_ROW_IDS IS
6678 BEGIN
6679
6680 -- Bug 10632614
6681 --Changed
6682 --SELECT /*+ full(tmp) index(rl, PJI_FP_XBS_ACCUM_F_N1) use_nl(rl) */
6683 --to
6684 --SELECT /*+ full(tmp) index(rl, PJI_FP_XBS_ACCUM_F_N6) use_nl(rl) */
6685 -- End Bug 10632614
6686
6687 INSERT INTO PJI_FP_RMAP_FPR_T
6688 (
6689 worker_id
6690 , pjp1_rowid
6691 , fpr_rowid
6692 )
6693 SELECT /*+ full(tmp) index(rl, PJI_FP_XBS_ACCUM_F_N6) use_nl(rl) */
6694 g_worker_id WORKER_ID
6695 , tmp.ROWID pjp1_rowid
6696 , rl.ROWID fpr_ROWID
6697 FROM
6698 pji_fp_aggr_pjp1_t tmp
6699 , pji_fp_xbs_accum_f rl
6700 WHERE 1 = 1
6701 AND tmp.WORKER_ID = g_worker_id
6702 AND tmp.PROJECT_ID = rl.PROJECT_ID (+)
6703 AND tmp.PLAN_VERSION_ID = rl.PLAN_VERSION_ID (+)
6704 AND tmp.PLAN_TYPE_ID = rl.PLAN_TYPE_ID (+)
6705 AND tmp.PROJECT_ORG_ID = rl.PROJECT_ORG_ID (+)
6706 AND tmp.PROJECT_ORGANIZATION_ID = rl.PROJECT_ORGANIZATION_ID (+)
6707 AND tmp.PROJECT_ELEMENT_ID = rl.PROJECT_ELEMENT_ID (+)
6708 AND tmp.TIME_ID = rl.TIME_ID (+)
6709 AND tmp.PERIOD_TYPE_ID = rl.PERIOD_TYPE_ID (+)
6710 AND tmp.CALENDAR_TYPE = rl.CALENDAR_TYPE (+)
6711 AND tmp.RBS_AGGR_LEVEL = rl.RBS_AGGR_LEVEL (+)
6712 AND tmp.WBS_ROLLUP_FLAG = rl.WBS_ROLLUP_FLAG (+)
6713 AND tmp.PRG_ROLLUP_FLAG = rl.PRG_ROLLUP_FLAG (+)
6714 AND tmp.CURR_RECORD_TYPE_ID = rl.CURR_RECORD_TYPE_ID (+)
6715 AND tmp.CURRENCY_CODE = rl.CURRENCY_CODE (+)
6716 AND tmp.RBS_ELEMENT_ID = rl.RBS_ELEMENT_ID (+)
6717 AND tmp.RBS_VERSION_ID = rl.RBS_VERSION_ID (+)
6718 AND tmp.PLAN_TYPE_CODE = rl.PLAN_TYPE_CODE (+) /* 4471527 */
6719 AND tmp.RATE_DANGLING_FLAG IS NULL
6720 AND tmp.TIME_DANGLING_FLAG IS NULL;
6721
6722 print_time ( ' MERGE_INTO_FP_FACT 1.1 ' || SQL%ROWCOUNT ) ;
6723
6724 EXCEPTION
6725 WHEN OTHERS THEN
6726 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6727 p_procedure_name => 'GET_FP_ROW_IDS');
6728 RAISE;
6729 END;
6730
6731
6732 PROCEDURE GET_ACTUALS (
6733 p_new_pub_version_id IN NUMBER
6734 , p_prev_pub_version_id IN NUMBER := NULL ) IS
6735
6736 BEGIN
6737
6738 NULL;
6739
6740 EXCEPTION
6741 WHEN OTHERS THEN
6742 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6743 p_procedure_name => 'GET_ACTUALS');
6744 RAISE;
6745 END;
6746
6747
6748 PROCEDURE REVERSE_ETC (
6749 p_new_pub_version_id IN NUMBER
6750 , p_prev_pub_version_id IN NUMBER := NULL ) IS
6751
6752 l_project_id NUMBER;
6753 l_struct_sharing_code pa_projects_all.structure_sharing_code%TYPE;
6754 l_prev_pub_version_id NUMBER;
6755 l_curr_wking_version_id NUMBER;
6756 l_actual_plan_version_id NUMBER;
6757 l_copied_from_version_id NUMBER;
6758 l_new_plan_type_id NUMBER;
6759 /*
6760 l_last_update_date DATE := SYSDATE;
6761 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
6762 l_creation_date DATE := SYSDATE;
6763 l_created_by NUMBER := FND_GLOBAL.USER_ID;
6764 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
6765 */
6766 l_max_plnver_id NUMBER := NULL;
6767
6768 BEGIN
6769
6770 print_time ( ' REVERSE_ETC BEGIN' ) ;
6771 print_time ( ' REVERSE_ETC p_new_pub_version_id = ' ||p_new_pub_version_id || ' p_prev_pub_version_id ' || p_prev_pub_version_id ) ;
6772
6773 INSERT_NTP_CAL_RECORD ( x_max_plnver_id => l_max_plnver_id );
6774
6775 IF (l_max_plnver_id IS NULL) THEN
6776 RETURN;
6777 END IF;
6778
6779 SELECT project_id, fin_plan_type_id
6780 INTO l_project_id, l_new_plan_type_id
6781 FROM pa_budget_versions
6782 WHERE budget_version_id = p_new_pub_version_id ;
6783
6784 SELECT structure_sharing_code
6785 INTO l_struct_sharing_code
6786 FROM pa_projects_all
6787 WHERE project_id = l_project_id;
6788
6789 l_prev_pub_version_id := p_prev_pub_version_id;
6790
6791 -- Fix for bug : 4213245
6792 /*
6793 delete from pji_fm_extr_plan_lines
6794 where
6795 PLAN_VERSION_ID = p_new_pub_version_id and
6796 ETC_QUANTITY is null and
6797 ETC_TXN_BURDENED_COST is null and
6798 ETC_PRJ_BURDENED_COST is null and
6799 ETC_PFC_BURDENED_COST is null and
6800 ETC_TXN_RAW_COST is null and
6801 ETC_PRJ_RAW_COST is null and
6802 ETC_PFC_RAW_COST is null and
6803 RBS_VERSION_ID is null;
6804 */
6805
6806 print_time ( ' REVERSE_ETC l_prev_pub_version_id ' || l_prev_pub_version_id || ' l_actual_plan_version_id ' || l_actual_plan_version_id || ' l_project_id ' || l_project_id ) ;
6807
6808
6809 PJI_FM_PLAN_MAINT_PVT.set_res_class_flag;
6810
6811 INSERT INTO PJI_FP_AGGR_PJP1_T
6812 (
6813 WORKER_ID
6814 , PRG_LEVEL
6815 , PROJECT_ID
6816 , PROJECT_ORG_ID
6817 , PROJECT_ORGANIZATION_ID
6818 , PROJECT_ELEMENT_ID
6819 , TIME_ID
6820 , PERIOD_TYPE_ID
6821 , CALENDAR_TYPE
6822 , RBS_AGGR_LEVEL
6823 , WBS_ROLLUP_FLAG
6824 , PRG_ROLLUP_FLAG
6825 , CURR_RECORD_TYPE_ID
6826 , CURRENCY_CODE
6827 , RBS_ELEMENT_ID
6828 , RBS_VERSION_ID
6829 , PLAN_VERSION_ID
6830 , PLAN_TYPE_ID
6831 , RAW_COST
6832 , BRDN_COST
6833 , REVENUE
6834 , BILL_RAW_COST
6835 , BILL_BRDN_COST
6836 , BILL_LABOR_RAW_COST
6837 , BILL_LABOR_BRDN_COST
6838 , BILL_LABOR_HRS
6839 , EQUIPMENT_RAW_COST
6840 , EQUIPMENT_BRDN_COST
6841 , CAPITALIZABLE_RAW_COST
6842 , CAPITALIZABLE_BRDN_COST
6843 , LABOR_RAW_COST
6844 , LABOR_BRDN_COST
6845 , LABOR_HRS
6846 , LABOR_REVENUE
6847 , EQUIPMENT_HOURS
6848 , BILLABLE_EQUIPMENT_HOURS
6849 , SUP_INV_COMMITTED_COST
6850 , PO_COMMITTED_COST
6851 , PR_COMMITTED_COST
6852 , OTH_COMMITTED_COST
6853 , ACT_LABOR_HRS
6854 , ACT_EQUIP_HRS
6855 , ACT_LABOR_BRDN_COST
6856 , ACT_EQUIP_BRDN_COST
6857 , ACT_BRDN_COST
6858 , ACT_RAW_COST
6859 , ACT_REVENUE
6860 , ACT_LABOR_RAW_COST
6861 , ACT_EQUIP_RAW_COST
6862 , ETC_LABOR_HRS
6863 , ETC_EQUIP_HRS
6864 , ETC_LABOR_BRDN_COST
6865 , ETC_EQUIP_BRDN_COST
6866 , ETC_BRDN_COST
6867 , ETC_RAW_COST
6868 , ETC_LABOR_RAW_COST
6869 , ETC_EQUIP_RAW_COST
6870 , CUSTOM1
6871 , CUSTOM2
6872 , CUSTOM3
6873 , CUSTOM4
6874 , CUSTOM5
6875 , CUSTOM6
6876 , CUSTOM7
6877 , CUSTOM8
6878 , CUSTOM9
6879 , CUSTOM10
6880 , CUSTOM11
6881 , CUSTOM12
6882 , CUSTOM13
6883 , CUSTOM14
6884 , CUSTOM15
6885 , PLAN_TYPE_CODE /* 4471527 */
6886 )
6887 SELECT
6888 g_worker_id WORKER_ID
6889 , g_default_prg_level PRG_LEVEL
6890 , plr.PROJECT_ID
6891 , plr.PROJECT_ORG_ID
6892 , plr.project_ORGANIZATION_ID
6893 , plr.WBS_ELEMENT_ID project_element_id
6894 , DECODE(vers.time_phased_type_code
6895 , 'N', -1
6896 , pji_time.cal_period_id) time_id
6897 , DECODE(vers.time_phased_type_code
6898 , 'P', 32
6899 , 'G', 32
6900 , 'N', 2048) period_type_id -- period type id...
6901 , DECODE(vers.time_phased_type_code
6902 , 'P', 'P'
6903 , 'G', 'G'
6904 , 'N', 'A'
6905 , 'X') CALENDAR_TYPE
6906 , 'L' RBS_AGGR_LEVEL
6907 , 'N' WBS_ROLLUP_FLAG
6908 , 'N' PRG_ROLLUP_FLAG
6909 , plr.CURR_RECORD_TYPE CURR_RECORD_TYPE_ID
6910 , plr.currency_code
6911 , plr.RBS_ELEMENT_ID
6912 , plr.RBS_STRUCT_VERSION_ID rbs_version_id
6913 , plr.BUDGET_VERSION_ID PLAN_VERSION_ID
6914 , plr.plan_type_id
6915 , SUM(plr.RAW_COST) RAW_COST
6916 , SUM(plr.BRDN_COST) BRDN_COST
6917 , SUM(plr.REVENUE) REVENUE
6918 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, TO_NUMBER(NULL) ) ) BILL_RAW_COST
6919 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, TO_NUMBER(NULL) ) ) BILL_BRDN_COST
6920 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || 'PEOPLE', plr.raw_cost, TO_NUMBER(NULL) ) ) BILL_LABOR_RAW_COST
6921 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || 'PEOPLE' , plr.BRDN_COST, TO_NUMBER(NULL) ) ) BILL_LABOR_BRDN_COST
6922 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'Y' || 'PEOPLE', plr.quantity, TO_NUMBER(NULL) ) ) BILL_LABOR_HRS */ -- bug 6039785
6923 , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'Y' || 'PEOPLE',
6924 decode(plr.billable_flag,'Y', plr.quantity, TO_NUMBER(NULL)),
6925 TO_NUMBER(NULL) ) ) BILL_LABOR_HRS -- bug 6039785
6926 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT' , plr.raw_cost, TO_NUMBER(NULL) ) ) EQUIPMENT_RAW_COST
6927 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT' , plr.BRDN_COST, TO_NUMBER(NULL) ) ) EQUIPMENT_BRDN_COST
6928 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, TO_NUMBER(NULL) ) ) CAPITALIZABLE_RAW_COST
6929 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, TO_NUMBER(NULL) ) ) CAPITALIZABLE_BRDN_COST
6930 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.raw_cost, TO_NUMBER(NULL) ) ) LABOR_RAW_COST
6931 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.BRDN_COST, TO_NUMBER(NULL) ) ) LABOR_BRDN_COST
6932 /* , SUM ( DECODE ( plr.resource_class, 'PEOPLE',
6933 DECODE ( vers.wp_flag, 'N',
6934 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
6935 plr.quantity),
6936 TO_NUMBER(NULL) ) ) labor_hrs */ -- bug 6039785
6937 , SUM ( DECODE ( plr.resource_class, 'PEOPLE',
6938 DECODE(plr.billable_flag,'Y',
6939 DECODE ( vers.wp_flag, 'N',
6940 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
6941 plr.quantity)
6942 , TO_NUMBER(NULL) ),
6943 TO_NUMBER(NULL) ) ) labor_hrs -- bug 6039785
6944 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.revenue, TO_NUMBER(NULL) ) ) LABOR_REVENUE
6945 /* , SUM ( -- s
6946 DECODE ( plr.resource_class -- d1
6947 , 'EQUIPMENT'
6948 , DECODE ( vers.wp_flag -- d2
6949 , 'N'
6950 , DECODE ( plr.billable_flag -- d3
6951 , 'Y'
6952 , plr.quantity
6953 , TO_NUMBER(NULL)
6954 ) -- d3
6955 , plr.quantity
6956 ) -- d2
6957 , TO_NUMBER(NULL)
6958 ) -- d1
6959 ) EQUIPMENT_HRS -- s */ -- bug 6039785
6960 , SUM ( -- s
6961 DECODE ( plr.resource_class -- d1
6962 , 'EQUIPMENT' , DECODE(plr.billable_flag,'Y'
6963 , DECODE ( vers.wp_flag -- d2
6964 , 'N'
6965 , DECODE ( plr.billable_flag -- d3
6966 , 'Y'
6967 , plr.quantity
6968 , TO_NUMBER(NULL)
6969 ) -- d3
6970 , plr.quantity
6971 ) -- d2
6972 , TO_NUMBER(NULL) ),
6973 TO_NUMBER(NULL)
6974 ) -- d1
6975 ) EQUIPMENT_HRS -- s -- bug 6039785
6976 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YEQUIPMENT', plr.quantity, 0 ) ) BILLABLE_EQUIPMENT_HOURS */ -- bug 6039785
6977 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YEQUIPMENT',
6978 DECODE(plr.billable_flag,'Y',plr.quantity,0 ) , 0 ) ) BILLABLE_EQUIPMENT_HOURS -- bug 6039785
6979 , TO_NUMBER(NULL) SUP_INV_COMMITTED_COST
6980 , TO_NUMBER(NULL) PO_COMMITTED_COST
6981 , TO_NUMBER(NULL) PR_COMMITTED_COST
6982 , TO_NUMBER(NULL) OTH_COMMITTED_COST
6983 /* , SUM ( DECODE ( plr.resource_class, 'PEOPLE',
6984 DECODE ( vers.wp_flag, 'N',
6985 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
6986 plr.actual_quantity),
6987 TO_NUMBER(NULL) ) ) ACT_LABOR_HRS */ -- bug 6039785
6988 , SUM ( DECODE ( plr.resource_class, 'PEOPLE',
6989 DECODE (plr.billable_flag ,'Y',
6990 DECODE ( vers.wp_flag, 'N',
6991 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
6992 plr.actual_quantity),
6993 TO_NUMBER(NULL) ),
6994 TO_NUMBER(NULL) ) ) ACT_LABOR_HRS -- bug 6039785
6995 /* , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT',
6996 DECODE ( vers.wp_flag, 'N',
6997 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
6998 plr.actual_quantity),
6999 TO_NUMBER(NULL) ) ) ACT_EQUIP_HRS */ -- bug 6039785
7000 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT',
7001 DECODE (plr.billable_flag ,'Y',
7002 DECODE ( vers.wp_flag, 'N',
7003 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
7004 plr.actual_quantity),
7005 TO_NUMBER(NULL) ),
7006 TO_NUMBER(NULL) ) ) ACT_EQUIP_HRS -- bug 6039785
7007 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.actual_BRDN_COST, TO_NUMBER(NULL) ) ) ACT_LABOR_BRDN_COST
7008 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT' , plr.actual_BRDN_COST, TO_NUMBER(NULL) ) ) ACT_EQUIP_BRDN_COST
7009 , SUM ( plr.actual_brdn_cost ) ACT_BRDN_COST
7010 , SUM ( plr.actual_raw_cost ) ACT_RAW_COST
7011 , SUM ( plr.actual_revenue ) ACT_REVENUE
7012 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.actual_RAW_COST, TO_NUMBER(NULL) ) ) ACT_LABOR_RAW_COST
7013 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT' , plr.actual_RAW_COST, TO_NUMBER(NULL) ) ) ACT_EQUIP_RAW_COST
7014 /* , SUM ( DECODE ( plr.resource_class, 'PEOPLE',
7015 DECODE ( vers.wp_flag, 'N',
7016 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,TO_NUMBER(NULL)),
7017 plr.ETC_quantity),
7018 'EQUIPMENT', TO_NUMBER(NULL) ) ) ETC_LABOR_HRS */ -- bug 6039785
7019 , SUM ( DECODE ( plr.resource_class, 'PEOPLE',
7020 DECODE (plr.billable_flag ,'Y',
7021 DECODE ( vers.wp_flag, 'N',
7022 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,TO_NUMBER(NULL)),
7023 plr.ETC_quantity), TO_NUMBER(NULL) ),
7024 'EQUIPMENT', TO_NUMBER(NULL) ) ) ETC_LABOR_HRS -- bug 6039785
7025 /* , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT',
7026 DECODE ( vers.wp_flag, 'N',
7027 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,TO_NUMBER(NULL)),
7028 plr.ETC_quantity),
7029 'PEOPLE', TO_NUMBER(NULL) ) ) ETC_EQUIP_HRS */ -- bug 6039785
7030 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT',
7031 DECODE (plr.billable_flag ,'Y',
7032 DECODE ( vers.wp_flag, 'N',
7033 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,TO_NUMBER(NULL)),
7034 plr.ETC_quantity), TO_NUMBER(NULL) ),
7035 'PEOPLE', TO_NUMBER(NULL) ) ) ETC_EQUIP_HRS -- bug 6039785
7036 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.etc_BRDN_COST, TO_NUMBER(NULL) ) ) ETC_LABOR_BRDN_COST
7037 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT', plr.etc_BRDN_COST, TO_NUMBER(NULL) ) ) ETC_EQUIP_BRDN_COST
7038 , SUM ( plr.etc_brdn_cost ) ETC_BRDN_COST
7039 , SUM ( plr.etc_raw_cost ) ETC_RAW_COST
7040 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.etc_raw_COST, TO_NUMBER(NULL) ) ) ETC_LABOR_raw_COST
7041 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT', plr.etc_raw_COST, TO_NUMBER(NULL) ) ) ETC_EQUIP_raw_COST
7042 , TO_NUMBER(NULL) CUSTOM1
7043 , TO_NUMBER(NULL) CUSTOM2
7044 , TO_NUMBER(NULL) CUSTOM3
7045 , TO_NUMBER(NULL) CUSTOM4
7046 , TO_NUMBER(NULL) CUSTOM5
7047 , TO_NUMBER(NULL) CUSTOM6
7048 , TO_NUMBER(NULL) CUSTOM7
7049 , TO_NUMBER(NULL) CUSTOM8
7050 , TO_NUMBER(NULL) CUSTOM9
7051 , TO_NUMBER(NULL) CUSTOM10
7052 , TO_NUMBER(NULL) CUSTOM11
7053 , TO_NUMBER(NULL) CUSTOM12
7054 , TO_NUMBER(NULL) CUSTOM13
7055 , TO_NUMBER(NULL) CUSTOM14
7056 , TO_NUMBER(NULL) CUSTOM15
7057 , plr.plan_type_code plan_type_code /* 4471527 */
7058 FROM
7059 ( ----- First inline view plr .............
7060 SELECT
7061 collapse_bl.PROJECT_ID
7062 , collapse_bl.WBS_ELEMENT_ID
7063 , SUM(collapse_bl.CURR_RECORD_TYPE_ID) CURR_RECORD_TYPE
7064 , collapse_bl.RBS_ELEMENT_ID
7065 , collapse_bl.RBS_STRUCT_VERSION_ID
7066 , collapse_bl.plan_type_id
7067 , collapse_bl.BUDGET_VERSION_ID
7068 , collapse_bl.PROJECT_ORGANIZATION_ID
7069 , collapse_bl.PROJECT_ORG_ID
7070 , collapse_bl.BILLABLE_FLAG
7071 , collapse_bl.RESOURCE_CLASS
7072 , collapse_bl.CURRENCY_CODE
7073 , MAX(collapse_bl.raw_cost) raw_cost
7074 , MAX(collapse_bl.BRDN_COST) BRDN_COST
7075 , MAX(collapse_bl.revenue) revenue
7076 , MAX(collapse_bl.act_raw_cost) actual_raw_cost
7077 , MAX(collapse_bl.act_BRDN_COST) actual_BRDN_COST
7078 , MAX(collapse_bl.act_revenue) actual_revenue
7079 , MAX(collapse_bl.etc_RAW_COST) etc_raw_COST
7080 , MAX(collapse_bl.etc_BRDN_COST) etc_BRDN_COST
7081 , MAX(collapse_bl.quantity) quantity
7082 , MAX(collapse_bl.act_quantity) actual_quantity
7083 , MAX(collapse_bl.etc_quantity) etc_quantity
7084 , collapse_bl.period_name period_name
7085 , collapse_bl.row_id
7086 , collapse_bl.plan_type_code plan_type_code /* 4471527 */
7087 FROM
7088 ( ----- Second inline view 'collapse_bl' begin .............
7089 SELECT
7090 spread_bl.row_id row_id
7091 , spread_bl.PROJECT_ID
7092 , spread_bl.BUDGET_VERSION_ID
7093 , spread_bl.WBS_ELEMENT_ID
7094 , spread_bl.RBS_ELEMENT_ID
7095 , spread_bl.WBS_STRUCT_VERSION_ID
7096 , spread_bl.RBS_STRUCT_VERSION_ID
7097 , spread_bl.plan_type_id
7098 , spread_bl.BILLABLE_FLAG
7099 , spread_bl.RESOURCE_CLASS
7100 , spread_bl.PROJECT_ORGANIZATION_ID
7101 , spread_bl.PROJECT_ORG_ID
7102 , DECODE( invert.INVERT_ID
7103 , 4, spread_bl.pfc_CURRENCY_CODE
7104 , 8, spread_bl.PRJ_CURRENCY_CODE
7105 , 16, spread_bl.TXN_CURRENCY_CODE ) CURRENCY_CODE
7106 , invert.INVERT_ID CURR_RECORD_TYPE_ID
7107 , DECODE ( invert.INVERT_ID
7108 , 4, spread_bl.pfc_raw_cost
7109 , 8, spread_bl.PRJ_raw_cost
7110 , 16, spread_bl.TXN_raw_cost) raw_cost
7111 , DECODE ( invert.INVERT_ID
7112 , 4, spread_bl.pfc_BRDN_COST
7113 , 8, spread_bl.PRJ_BRDN_COST
7114 , 16, spread_bl.TXN_BRDN_COST ) BRDN_COST
7115 , DECODE ( invert.INVERT_ID
7116 , 4, spread_bl.pfc_revenue
7117 , 8, spread_bl.PRJ_revenue
7118 , 16, spread_bl.TXN_revenue ) revenue
7119 , DECODE ( invert.INVERT_ID
7120 , 4, spread_bl.act_pfc_raw_cost
7121 , 8, spread_bl.act_PRJ_raw_cost
7122 , 16, spread_bl.act_TXN_raw_cost) act_raw_cost
7123 , DECODE ( invert.INVERT_ID
7124 , 4, spread_bl.act_pfc_BRDN_COST
7125 , 8, spread_bl.act_PRJ_BRDN_COST
7126 , 16, spread_bl.act_TXN_BRDN_COST ) act_BRDN_COST
7127 , DECODE ( invert.INVERT_ID
7128 , 4, spread_bl.act_pfc_revenue
7129 , 8, spread_bl.act_PRJ_revenue
7130 , 16, spread_bl.act_TXN_revenue ) act_revenue
7131 , DECODE ( invert.INVERT_ID
7132 , 4, spread_bl.etc_pfc_brdn_cost
7133 , 8, spread_bl.etc_PRJ_brdn_cost
7134 , 16, spread_bl.etc_TXN_brdn_cost ) etc_brdn_cost
7135 , DECODE ( invert.INVERT_ID
7136 , 4, spread_bl.etc_pfc_raw_cost
7137 , 8, spread_bl.etc_PRJ_raw_cost
7138 , 16, spread_bl.etc_TXN_raw_cost) etc_raw_cost
7139 , spread_bl.quantity quantity
7140 , spread_bl.act_quantity act_quantity
7141 , spread_bl.etc_quantity etc_quantity
7142 , spread_bl.period_name period_name
7143 , spread_bl.plan_type_code plan_type_code /* 4471527 */
7144 FROM
7145 (
7146 SELECT
7147 bl.project_id
7148 , bl.ROWID row_id
7149 , bl.plan_version_id budget_version_id
7150 , DECODE(bl.project_element_id, 0, pevs.proj_element_id, bl.project_element_id) wbs_element_id
7151 , NVL( bl.rbs_element_id, -1) rbs_element_id
7152 , bl.struct_ver_id wbs_struct_version_id
7153 , DECODE( bl.rbs_element_id
7154 , NULL
7155 , -1
7156 , NVL(ver.rbs_struct_version_id, -1)
7157 ) rbs_struct_version_id
7158 , bl.plan_type_id plan_type_id -- ver.plan_type_id
7159 , bl.rate_based_flag billable_flag -- ra.rate_based_flag billable_flag
7160 -- cbs change
7161 --, bl.resource_class_code resource_class -- ra.resource_class_code resource_class
7162 , decode(PJI_FM_PLAN_MAINT_PVT.g_res_class_flag,'N',decode(PJI_FM_PLAN_MAINT_PVT.get_res_class_flag(bl.plan_version_id), 'N',
7163 '1'||bl.resource_class_code, bl.resource_class_code),bl.resource_class_code) resource_class
7164 -- End cbs change
7165 , bl.txn_currency_code txn_currency_code
7166 , bl.txn_raw_cost txn_raw_cost
7167 , bl.txn_burdened_cost txn_BRDN_COST
7168 , bl.txn_revenue txn_revenue
7169 , TO_NUMBER(NULL) act_txn_raw_cost
7170 , TO_NUMBER(NULL) act_txn_brdn_cost
7171 , TO_NUMBER(NULL) act_txn_revenue
7172 , NVL(bl.txn_raw_cost, 0)+NVL(bl.etc_txn_raw_cost, 0) etc_txn_raw_cost
7173 , NVL(bl.txn_burdened_cost, 0)+NVL(bl.etc_txn_burdened_cost, 0) etc_txn_brdn_cost
7174 , bl.prj_currency_code prj_currency_code
7175 , bl.prj_raw_cost prj_raw_cost
7176 , bl.prj_burdened_cost prj_BRDN_COST
7177 , bl.prj_revenue prj_revenue
7178 , TO_NUMBER(NULL) act_prj_raw_cost
7179 , TO_NUMBER(NULL) act_prj_brdn_cost
7180 , TO_NUMBER(NULL) act_prj_revenue
7181 , NVL(bl.prj_raw_cost, 0)+NVL(bl.etc_prj_raw_cost, 0) etc_prj_raw_cost
7182 , NVL(bl.prj_burdened_cost, 0)+NVL(bl.etc_prj_burdened_cost, 0) etc_prj_brdn_cost
7183 , bl.pfc_currency_code pfc_currency_code
7184 , bl.pfc_raw_cost pfc_raw_cost
7185 , bl.pfc_burdened_cost pfc_BRDN_COST
7186 , bl.pfc_revenue pfc_revenue
7187 , TO_NUMBER(NULL) act_pfc_raw_cost
7188 , TO_NUMBER(NULL) act_pfc_brdn_cost
7189 , TO_NUMBER(NULL) act_pfc_revenue
7190 , NVL(bl.pfc_raw_cost, 0)+NVL(bl.etc_pfc_raw_cost, 0) etc_pfc_raw_cost
7191 , NVL(bl.pfc_burdened_cost, 0)+NVL(bl.etc_pfc_burdened_cost, 0) etc_pfc_brdn_cost
7192 , bl.quantity quantity
7193 , TO_NUMBER(NULL) act_quantity
7194 , NVL(bl.quantity, 0)+NVL(bl.etc_quantity, 0) etc_quantity
7195 , NVL(bl.period_name, 'XXX') period_name
7196 , bl.project_org_id project_org_id
7197 , ppa.carrying_out_organization_id project_organization_id
7198 , ver.plan_type_code plan_type_code /* 4471527 */
7199 FROM
7200 PJI_FM_EXTR_PLAN_LINES bl
7201 , PJI_FM_EXTR_PLNVER3_T ver
7202 , PA_PROJECTS_ALL ppa
7203 , PA_PROJ_ELEM_VER_STRUCTURE pevs
7204 , pji_fp_rmap_fpr_update_t rwid
7205 WHERE 1=1
7206 AND bl.project_id = ver.project_id
7207 AND bl.plan_version_id = ver.plan_version_id
7208 AND bl.plan_type_id = ver.plan_type_id
7209 AND ppa.project_id = ver.project_id
7210 AND bl.project_id = ppa.project_id -- Added for bug 3828698
7211 AND ppa.project_id = pevs.project_id -- Added for bug 3838698
7212 AND bl.TXN_CURRENCY_CODE IS NOT NULL
7213 AND bl.prj_currency_code IS NOT NULL
7214 AND bl.pfc_currency_code IS NOT NULL
7215 AND pevs.element_version_id = ver.wbs_struct_version_id
7216 AND pevs.project_id = ver.project_id -- Fix for bug : 4149422 in REVERSE_ETC
7217 AND bl.ROWID = rwid.extr_lines_rowid
7218 UNION ALL
7219 SELECT /*+ LEADING(VER) USE_NL(VER,PPA,PEVS,RA,BL)*/
7220 ra.project_id
7221 , bl.ROWID row_id
7222 , ra.budget_version_id
7223 , DECODE(ra.task_id, 0, pevs.proj_element_id, ra.task_id) wbs_element_id
7224 , NVL(ra.rbs_element_id, -1) rbs_element_id
7225 , ver.wbs_struct_version_id wbs_struct_version_id
7226 , NVL(ver.rbs_struct_version_id, -1) rbs_struct_version_id
7227 , ver.plan_type_id plan_type_id
7228 , ra.rate_based_flag billable_flag
7229 -- cbs change
7230 --, ra.resource_class_code resource_class
7231 , decode(PJI_FM_PLAN_MAINT_PVT.g_res_class_flag,'N',decode(PJI_FM_PLAN_MAINT_PVT.get_res_class_flag(ra.budget_version_id), 'N',
7232 '1'||ra.resource_class_code, ra.resource_class_code),ra.resource_class_code) resource_class
7233 -- End cbs change
7234 , bl.txn_currency_code txn_currency_code
7235 , TO_NUMBER(NULL) txn_raw_cost
7236 , TO_NUMBER(NULL) txn_brdn_COST
7237 , TO_NUMBER(NULL) txn_revenue
7238 , bl.txn_init_raw_cost txn_actual_raw_cost -- new
7239 , bl.txn_init_burdened_cost txn_actual_brdn_cost -- new
7240 , bl.txn_init_revenue txn_actual_revenue -- new
7241 , TO_NUMBER(NULL) txn_etc_raw_cost -- new
7242 , TO_NUMBER(NULL) txn_etc_brdn_cost -- new
7243 , bl.project_currency_code prj_currency_code
7244 , TO_NUMBER(NULL) prj_raw_cost
7245 , TO_NUMBER(NULL) prj_BRDN_COST
7246 , TO_NUMBER(NULL) prj_revenue
7247 , bl.project_init_raw_cost prj_actual_raw_cost -- new
7248 , bl.project_init_burdened_cost prj_actual_brdn_cost -- new
7249 , bl.project_init_revenue prj_actual_revenue -- new
7250 , TO_NUMBER(NULL) prj_etc_raw_cost -- new
7251 , TO_NUMBER(NULL) prj_etc_brdn_cost -- new
7252 , bl.projfunc_currency_code func_currency_code
7253 , TO_NUMBER(NULL) func_raw_cost
7254 , TO_NUMBER(NULL) func_BRDN_COST
7255 , TO_NUMBER(NULL) func_revenue
7256 , bl.init_raw_cost func_actual_raw_cost -- new
7257 , bl.init_burdened_cost func_actual_brdn_cost -- new
7258 , bl.init_revenue func_actual_revenue -- new
7259 , TO_NUMBER(NULL) func_etc_raw_cost -- new
7260 , TO_NUMBER(NULL) func_etc_brdn_cost -- new
7261 , TO_NUMBER(NULL) quantity
7262 , bl.init_quantity actual_quantity -- new
7263 , TO_NUMBER(NULL) etc_quantity -- new
7264 , NVL(bl.period_name, 'XXX') period_name
7265 , ppa.org_id project_org_id
7266 , ppa.carrying_out_organization_id project_organization_id
7267 , ver.plan_type_code plan_type_code /* 4471527 */
7268 FROM
7269 PA_BUDGET_LINES bl
7270 , PA_RESOURCE_ASSIGNMENTS ra
7271 , PJI_FM_EXTR_PLNVER3_T ver
7272 , PA_PROJECTS_ALL ppa
7273 , PA_PROJ_ELEM_VER_STRUCTURE pevs
7274 WHERE
7275 ra.resource_asSIGNment_id = bl.resource_asSIGNment_id
7276 AND ra.project_id = ver.PROJECT_ID
7277 AND ra.budget_version_id = ver.plan_version_id
7278 AND ver.project_id = ppa.project_id
7279 AND txn_currency_code IS NOT NULL
7280 AND bl.project_currency_code IS NOT NULL
7281 AND bl.projfunc_currency_code IS NOT NULL
7282 AND pevs.project_id = ver.project_id -- Fix for bug : 4149422 in REVERSE_ETC
7283 AND pevs.element_version_id = ver.wbs_struct_version_id
7284 AND ver.secondary_rbs_flag = 'N'
7285 ) spread_bl
7286 ---- end of third inline view 'spread_bl'...........
7287 ,
7288 (
7289 SELECT 4 INVERT_ID FROM dual UNION ALL
7290 SELECT 8 INVERT_ID FROM dual UNION ALL
7291 SELECT 16 INVERT_ID FROM dual where PJI_UTILS.GET_SETUP_PARAMETER('TXN_CURR_FLAG') = 'Y'
7292 ) invert
7293 ) collapse_bl
7294 ---- End of second inline view 'collapse_bl' ..........
7295 GROUP BY
7296 collapse_bl.PROJECT_ID
7297 , collapse_bl.WBS_ELEMENT_ID
7298 -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
7299 , collapse_bl.RBS_ELEMENT_ID
7300 , collapse_bl.RBS_STRUCT_VERSION_ID
7301 , collapse_bl.plan_type_id
7302 , collapse_bl.BUDGET_VERSION_ID
7303 , collapse_bl.PROJECT_ORGANIZATION_ID
7304 , collapse_bl.PROJECT_ORG_ID
7305 , collapse_bl.BILLABLE_FLAG
7306 , collapse_bl.RESOURCE_CLASS
7307 , collapse_bl.CURRENCY_CODE
7308 , collapse_bl.period_name
7309 , collapse_bl.row_id
7310 , collapse_bl.plan_type_code
7311 ) plr
7312 ---- End of first inline view plr ..........
7313 , PJI_ORG_EXTR_INFO orginfo
7314 , PJI_FM_EXTR_PLNVER3_T vers
7315 , pji_time_cal_period_v pji_time
7316 WHERE 1=1
7317 AND plr.project_org_id = orginfo.org_id
7318 AND plr.project_id = vers.project_id
7319 AND plr.budget_version_id = vers.plan_version_id
7320 AND plr.plan_type_code = vers.plan_type_code /* 4471527 */
7321 AND DECODE(vers.time_phased_type_code
7322 , 'P', orginfo.pa_calendar_id
7323 , 'G', orginfo.gl_calendar_id
7324 , - l_max_plnver_id )
7325 = pji_time.calendar_id
7326 AND plr.period_name = pji_time.name
7327 AND vers.time_phased_type_code IN ('P', 'G', 'N')
7328 GROUP BY
7329 plr.PROJECT_ID
7330 , plr.WBS_ELEMENT_ID
7331 , DECODE(vers.time_phased_type_code
7332 , 'N', -1
7333 , pji_time.cal_period_id)
7334 , DECODE(vers.time_phased_type_code
7335 , 'P', 32
7336 , 'G', 32
7337 , 'N', 2048) -- period type id...
7338 , DECODE(vers.time_phased_type_code
7339 , 'P', 'P'
7340 , 'G', 'G'
7341 , 'N', 'A'
7342 , 'X') -- CALENDAR_TYPE
7343 , plr.CURR_RECORD_TYPE -- curr code missing.
7344 , plr.currency_code
7345 , plr.RBS_ELEMENT_ID
7346 , plr.RBS_STRUCT_VERSION_ID
7347 , plr.plan_type_id
7348 , plr.BUDGET_VERSION_ID
7349 , plr.project_ORGANIZATION_ID
7350 , plr.project_ORG_ID
7351 , plr.plan_type_code ; /* 4471527 */
7352
7353
7354 print_time ( ' REVERSE_ETC END, # Processed rows is ' || SQL%ROWCOUNT ) ;
7355
7356 DELETE_NTP_CAL_RECORD ( p_max_plnver_id => l_max_plnver_id );
7357
7358 EXCEPTION
7359 WHEN OTHERS THEN
7360 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
7361 p_procedure_name => 'REVERSE_ETC');
7362 RAISE;
7363 END;
7364
7365
7366 PROCEDURE UPDATE_FP_ROWS IS
7367
7368 l_last_update_date DATE := SYSDATE;
7369 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
7370 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
7371
7372 BEGIN
7373
7374 IF P_PA_DEBUG_MODE = 'Y' THEN
7375 pa_debug.write('UPDATE_FP_ROWS: ' || g_module_name,'UPDATE_FP_ROWS ',1);
7376 END IF;
7377 UPDATE /*+ ordered use_nl(rl) rowid(rl) */
7378 pji_fp_xbs_accum_f rl
7379 SET (
7380 rl.RAW_COST
7381 , rl.BRDN_COST
7382 , rl.REVENUE
7383 , rl.BILL_RAW_COST
7384 , rl.BILL_BRDN_COST
7385 , rl.BILL_LABOR_RAW_COST
7386 , rl.BILL_LABOR_BRDN_COST
7387 , rl.BILL_LABOR_HRS
7388 , rl.EQUIPMENT_RAW_COST
7389 , rl.EQUIPMENT_BRDN_COST
7390 , rl.CAPITALIZABLE_RAW_COST
7391 , rl.CAPITALIZABLE_BRDN_COST
7392 , rl.LABOR_RAW_COST
7393 , rl.LABOR_BRDN_COST
7394 , rl.LABOR_HRS
7395 , rl.LABOR_REVENUE
7396 , rl.EQUIPMENT_HOURS
7397 , rl.BILLABLE_EQUIPMENT_HOURS
7398 , rl.SUP_INV_COMMITTED_COST
7399 , rl.PO_COMMITTED_COST
7400 , rl.PR_COMMITTED_COST
7401 , rl.OTH_COMMITTED_COST
7402 , rl.ACT_LABOR_HRS
7403 , rl.ACT_EQUIP_HRS
7404 , rl.ACT_LABOR_BRDN_COST
7405 , rl.ACT_EQUIP_BRDN_COST
7406 , rl.ACT_BRDN_COST
7407 , rl.ACT_RAW_COST
7408 , rl.ACT_REVENUE
7409 , rl.ACT_LABOR_RAW_COST
7410 , rl.ACT_EQUIP_RAW_COST
7411 , rl.ETC_LABOR_HRS
7412 , rl.ETC_EQUIP_HRS
7413 , rl.ETC_LABOR_BRDN_COST
7414 , rl.ETC_EQUIP_BRDN_COST
7415 , rl.ETC_BRDN_COST
7416 , rl.ETC_RAW_COST
7417 , rl.ETC_LABOR_RAW_COST
7418 , rl.ETC_EQUIP_RAW_COST
7419 , rl.CUSTOM1
7420 , rl.CUSTOM2
7421 , rl.CUSTOM3
7422 , rl.CUSTOM4
7423 , rl.CUSTOM5
7424 , rl.CUSTOM6
7425 , rl.CUSTOM7
7426 , rl.CUSTOM8
7427 , rl.CUSTOM9
7428 , rl.CUSTOM10
7429 , rl.CUSTOM11
7430 , rl.CUSTOM12
7431 , rl.CUSTOM13
7432 , rl.CUSTOM14
7433 , rl.CUSTOM15
7434 , rl.last_update_date
7435 , rl.last_updated_by
7436 , rl.last_update_login
7437 ) =
7438 (
7439 SELECT /*+ ORDERED ROWID(TMP) index(rwid,PJI_FP_RMAP_FPR_T_N1) */
7440 NVL(rl.RAW_COST, 0) + NVL(tmp.RAW_COST, 0)
7441 , NVL(rl.BRDN_COST, 0) + NVL(tmp.BRDN_COST, 0)
7442 , NVL(rl.REVENUE, 0) + NVL(tmp.REVENUE, 0)
7443 , NVL(rl.BILL_RAW_COST, 0) + NVL(tmp.BILL_RAW_COST, 0)
7444 , NVL(rl.BILL_BRDN_COST, 0) + NVL(tmp.BILL_BRDN_COST, 0)
7445 , NVL(rl.BILL_LABOR_RAW_COST, 0) + NVL(tmp.BILL_LABOR_RAW_COST, 0)
7446 , NVL(rl.BILL_LABOR_BRDN_COST, 0) + NVL(tmp.BILL_LABOR_BRDN_COST, 0)
7447 , NVL(rl.BILL_LABOR_HRS, 0) + NVL(tmp.BILL_LABOR_HRS, 0)
7448 , NVL(rl.EQUIPMENT_RAW_COST, 0) + NVL(tmp.EQUIPMENT_RAW_COST, 0)
7449 , NVL(rl.EQUIPMENT_BRDN_COST, 0) + NVL(tmp.EQUIPMENT_BRDN_COST, 0)
7450 , NVL(rl.CAPITALIZABLE_RAW_COST, 0) + NVL(tmp.CAPITALIZABLE_RAW_COST , 0)
7451 , NVL(rl.CAPITALIZABLE_BRDN_COST, 0) + NVL(tmp.CAPITALIZABLE_BRDN_COST , 0)
7452 , NVL(rl.LABOR_RAW_COST, 0) + NVL(tmp.LABOR_RAW_COST, 0)
7453 , NVL(rl.LABOR_BRDN_COST, 0) + NVL(tmp.LABOR_BRDN_COST, 0)
7454 , NVL(rl.LABOR_HRS, 0) + NVL(tmp.LABOR_HRS, 0)
7455 , NVL(rl.LABOR_REVENUE, 0) + NVL(tmp.LABOR_REVENUE, 0)
7456 , NVL(rl.EQUIPMENT_HOURS, 0) + NVL(tmp.EQUIPMENT_HOURS, 0)
7457 , NVL(rl.BILLABLE_EQUIPMENT_HOURS, 0) + NVL(tmp.BILLABLE_EQUIPMENT_HOURS, 0)
7458 , NVL(rl.SUP_INV_COMMITTED_COST, 0) + NVL(tmp.SUP_INV_COMMITTED_COST, 0)
7459 , NVL(rl.PO_COMMITTED_COST, 0) + NVL(tmp.PO_COMMITTED_COST, 0)
7460 , NVL(rl.PR_COMMITTED_COST, 0) + NVL(tmp.PR_COMMITTED_COST, 0)
7461 , NVL(rl.OTH_COMMITTED_COST, 0) + NVL(tmp.OTH_COMMITTED_COST, 0)
7462 , NVL(rl.ACT_LABOR_HRS, 0) + NVL(tmp.ACT_LABOR_HRS, 0)
7463 , NVL(rl.ACT_EQUIP_HRS, 0) + NVL(tmp.ACT_EQUIP_HRS, 0)
7464 , NVL(rl.ACT_LABOR_BRDN_COST, 0) + NVL(tmp.ACT_LABOR_BRDN_COST, 0)
7465 , NVL(rl.ACT_EQUIP_BRDN_COST, 0) + NVL(tmp.ACT_EQUIP_BRDN_COST, 0)
7466 , NVL(rl.ACT_BRDN_COST, 0) + NVL(tmp.ACT_BRDN_COST, 0)
7467 , NVL(rl.ACT_RAW_COST, 0) + NVL(tmp.ACT_RAW_COST, 0)
7468 , NVL(rl.ACT_REVENUE, 0) + NVL(tmp.ACT_REVENUE, 0)
7469 , NVL(rl.ACT_LABOR_RAW_COST, 0) + NVL(tmp.ACT_LABOR_RAW_COST, 0)
7470 , NVL(rl.ACT_EQUIP_RAW_COST, 0) + NVL(tmp.ACT_EQUIP_RAW_COST, 0)
7471 , DECODE ( ver3.wp_flag
7472 , 'Y'
7473 , DECODE(TO_CHAR(tmp.ETC_LABOR_HRS)
7474 , NULL
7475 , NVL(rl.etc_labor_hrs, 0) + NVL(tmp.labor_hrs, 0)
7476 , NVL(rl.ETC_LABOR_HRS, 0) + tmp.ETC_LABOR_HRS
7477 )
7478 , NVL(rl.ETC_LABOR_HRS, 0) + NVL(tmp.ETC_LABOR_HRS, 0)
7479 ) ETC_LABOR_HRS
7480 , DECODE ( ver3.wp_flag
7481 , 'Y'
7482 , DECODE(TO_CHAR(tmp.ETC_EQUIP_HRS)
7483 , NULL
7484 , NVL(rl.ETC_EQUIP_HRS, 0) + NVL(tmp.EQUIPMENT_hours, 0)
7485 , NVL(rl.ETC_EQUIP_HRS, 0) + tmp.ETC_EQUIP_HRS
7486 )
7487 , NVL(rl.ETC_EQUIP_HRS, 0) + NVL(tmp.ETC_EQUIP_HRS, 0)
7488 ) ETC_EQUIP_HRS
7489 , DECODE ( ver3.wp_flag
7490 , 'Y'
7491 , DECODE(TO_CHAR(tmp.ETC_LABOR_BRDN_COST)
7492 , NULL
7493 , NVL(rl.ETC_LABOR_BRDN_COST, 0) + NVL(tmp.labor_BRDN_COST, 0)
7494 , NVL(rl.ETC_LABOR_BRDN_COST, 0) + tmp.ETC_LABOR_BRDN_COST
7495 )
7496 , NVL(rl.ETC_LABOR_BRDN_COST, 0) + NVL(tmp.ETC_LABOR_BRDN_COST, 0)
7497 ) ETC_LABOR_BRDN_COST
7498 , DECODE ( ver3.wp_flag
7499 , 'Y'
7500 , DECODE(TO_CHAR(tmp.ETC_EQUIP_BRDN_COST)
7501 , NULL
7502 , NVL(rl.ETC_equip_BRDN_COST, 0) + NVL(tmp.EQUIPment_BRDN_COST, 0)
7503 , NVL(rl.ETC_equip_BRDN_COST, 0) + tmp.ETC_equip_BRDN_COST
7504 )
7505 , NVL(rl.ETC_EQUIP_BRDN_COST, 0) + NVL(tmp.ETC_EQUIP_BRDN_COST, 0)
7506 ) ETC_EQUIP_BRDN_COST
7507 , DECODE ( ver3.wp_flag
7508 , 'Y'
7509 , DECODE(TO_CHAR(tmp.ETC_BRDN_COST)
7510 , NULL
7511 , NVL(rl.ETC_BRDN_COST, 0) + NVL(tmp.BRDN_COST, 0)
7512 , NVL(rl.ETC_BRDN_COST, 0) + tmp.ETC_BRDN_COST
7513
7514 )
7515 , NVL(rl.ETC_BRDN_COST, 0) + NVL(tmp.ETC_BRDN_COST, 0)
7516 ) ETC_BRDN_COST
7517 , DECODE ( ver3.wp_flag
7518 , 'Y'
7519 , DECODE(TO_CHAR(tmp.ETC_raw_COST)
7520 , NULL
7521 , NVL(rl.ETC_raw_COST, 0) + NVL(tmp.raw_COST, 0)
7522 , NVL(rl.ETC_raw_COST, 0) + tmp.ETC_raw_COST
7523 )
7524 , NVL(rl.ETC_raw_COST, 0) + NVL(tmp.ETC_raw_COST, 0)
7525 ) ETC_RAW_COST
7526 , DECODE ( ver3.wp_flag
7527 , 'Y'
7528 , DECODE(TO_CHAR(tmp.ETC_labor_raw_COST)
7529 , NULL
7530 , NVL(rl.ETC_labor_raw_COST, 0) + NVL(tmp.labor_raw_COST, 0)
7531 , NVL(rl.ETC_labor_raw_COST, 0) + tmp.ETC_labor_raw_COST
7532 )
7533 , NVL(rl.ETC_labor_raw_COST, 0) + NVL(tmp.ETC_labor_raw_COST, 0)
7534 ) ETC_LABOR_RAW_COST
7535 , DECODE ( ver3.wp_flag
7536 , 'Y'
7537 , DECODE(TO_CHAR(tmp.ETC_equip_raw_COST)
7538 , NULL
7539 , NVL(rl.ETC_equip_raw_COST, 0) + NVL(tmp.equipment_raw_COST, 0)
7540 , NVL(rl.ETC_equip_raw_COST, 0) + tmp.ETC_equip_raw_COST
7541 )
7542 , NVL(rl.ETC_equip_raw_COST, 0) + NVL(tmp.ETC_equip_raw_COST, 0)
7543 ) ETC_EQUIP_RAW_COST
7544 , NVL(rl.CUSTOM1, 0) + NVL(tmp.CUSTOM1, 0)
7545 , NVL(rl.CUSTOM2, 0) + NVL(tmp.CUSTOM2, 0)
7546 , NVL(rl.CUSTOM3, 0) + NVL(tmp.CUSTOM3, 0)
7547 , NVL(rl.CUSTOM4, 0) + NVL(tmp.CUSTOM4, 0)
7548 , NVL(rl.CUSTOM5, 0) + NVL(tmp.CUSTOM5, 0)
7549 , NVL(rl.CUSTOM6, 0) + NVL(tmp.CUSTOM6, 0)
7550 , NVL(rl.CUSTOM7, 0) + NVL(tmp.CUSTOM7, 0)
7551 , NVL(rl.CUSTOM8, 0) + NVL(tmp.CUSTOM8, 0)
7552 , NVL(rl.CUSTOM9, 0) + NVL(tmp.CUSTOM9, 0)
7553 , NVL(rl.CUSTOM10, 0) + NVL(tmp.CUSTOM10, 0)
7554 , NVL(rl.CUSTOM11, 0) + NVL(tmp.CUSTOM11, 0)
7555 , NVL(rl.CUSTOM12, 0) + NVL(tmp.CUSTOM12, 0)
7556 , NVL(rl.CUSTOM13, 0) + NVL(tmp.CUSTOM13, 0)
7557 , NVL(rl.CUSTOM14, 0) + NVL(tmp.CUSTOM14, 0)
7558 , NVL(rl.CUSTOM15, 0) + NVL(tmp.CUSTOM15, 0)
7559 , SYSDATE
7560 , l_last_updated_by
7561 , l_last_update_login
7562 FROM
7563 PJI_FP_RMAP_FPR_T rwid
7564 , pji_fp_aggr_pjp1_t tmp
7565 , pji_pjp_wbs_header ver3
7566 WHERE 1 = 1
7567 AND tmp.rowid = rwid.pjp1_rowid
7568 AND rl.rowid = rwid.fpr_rowid
7569 AND rwid.fpr_rowid IS NOT NULL
7570 AND ver3.plan_version_id = tmp.plan_version_id
7571 AND ver3.plan_type_code = tmp.plan_type_code /* 4471527 */
7572 AND rwid.worker_id = g_worker_id
7573 AND tmp.worker_id = g_worker_id
7574 -- AND ver3.worker_id = g_worker_id
7575 AND tmp.project_id = ver3.project_id
7576 AND tmp.plan_type_id = NVL(ver3.plan_type_id, -1) -- each plan type can have a different -3, -4 slice.
7577 )
7578 WHERE rl.rowid IN
7579 (
7580 SELECT rwid.fpr_rowid
7581 FROM PJI_FP_RMAP_FPR_T rwid
7582 WHERE rwid.fpr_rowid IS NOT NULL
7583 AND rwid.worker_id = g_worker_id
7584 );
7585
7586 IF P_PA_DEBUG_MODE = 'Y' THEN
7587 pa_debug.write('UPDATE_FP_ROWS: ' || g_module_name,'UPDATE_FP_ROWS : '||sql%rowcount,1);
7588 END IF;
7589 print_time ( ' MERGE_INTO_FP_FACT 2.1 ' || sql%rowcount ) ;
7590
7591
7592 EXCEPTION
7593 WHEN OTHERS THEN
7594 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
7595 p_procedure_name => 'UPDATE_FP_ROWS');
7596 RAISE;
7597 END;
7598
7599
7600 PROCEDURE INSERT_FP_ROWS IS
7601
7602 l_last_update_date date := SYSDATE;
7603 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
7604 l_creation_date date := SYSDATE;
7605 l_created_by NUMBER := FND_GLOBAL.USER_ID;
7606 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
7607 l_count NUMBER;
7608
7609 BEGIN
7610
7611 IF P_PA_DEBUG_MODE = 'Y' THEN
7612 pa_debug.write('INSERT_FP_ROWS: ' || g_module_name,'INSERT_FP_ROWS ',1);
7613 END IF;
7614 INSERT INTO pji_fp_xbs_accum_f fact
7615 (
7616 PROJECT_ID
7617 , PROJECT_ORG_ID
7618 , PROJECT_ORGANIZATION_ID
7619 , PROJECT_ELEMENT_ID
7620 , TIME_ID
7621 , PERIOD_TYPE_ID
7622 , CALENDAR_TYPE
7623 , RBS_AGGR_LEVEL
7624 , WBS_ROLLUP_FLAG
7625 , PRG_ROLLUP_FLAG
7626 , CURR_RECORD_TYPE_ID
7627 , CURRENCY_CODE
7628 , RBS_ELEMENT_ID
7629 , RBS_VERSION_ID
7630 , PLAN_VERSION_ID
7631 , PLAN_TYPE_ID
7632 , LAST_UPDATE_DATE
7633 , LAST_UPDATED_BY
7634 , CREATION_DATE
7635 , CREATED_BY
7636 , LAST_UPDATE_LOGIN
7637 , RAW_COST
7638 , BRDN_COST
7639 , REVENUE
7640 , BILL_RAW_COST
7641 , BILL_BRDN_COST
7642 , BILL_LABOR_RAW_COST
7643 , BILL_LABOR_BRDN_COST
7644 , BILL_LABOR_HRS
7645 , EQUIPMENT_RAW_COST
7646 , EQUIPMENT_BRDN_COST
7647 , CAPITALIZABLE_RAW_COST
7648 , CAPITALIZABLE_BRDN_COST
7649 , LABOR_RAW_COST
7650 , LABOR_BRDN_COST
7651 , LABOR_HRS
7652 , LABOR_REVENUE
7653 , EQUIPMENT_HOURS
7654 , BILLABLE_EQUIPMENT_HOURS
7655 , SUP_INV_COMMITTED_COST
7656 , PO_COMMITTED_COST
7657 , PR_COMMITTED_COST
7658 , OTH_COMMITTED_COST
7659 , ACT_LABOR_HRS
7660 , ACT_EQUIP_HRS
7661 , ACT_LABOR_BRDN_COST
7662 , ACT_EQUIP_BRDN_COST
7663 , ACT_BRDN_COST
7664 , ACT_RAW_COST
7665 , ACT_REVENUE
7666 , ACT_LABOR_RAW_COST
7667 , ACT_EQUIP_RAW_COST
7668 , ETC_LABOR_HRS
7669 , ETC_EQUIP_HRS
7670 , ETC_LABOR_BRDN_COST
7671 , ETC_EQUIP_BRDN_COST
7672 , ETC_BRDN_COST
7673 , ETC_RAW_COST
7674 , ETC_LABOR_RAW_COST
7675 , ETC_EQUIP_RAW_COST
7676 , CUSTOM1
7677 , CUSTOM2
7678 , CUSTOM3
7679 , CUSTOM4
7680 , CUSTOM5
7681 , CUSTOM6
7682 , CUSTOM7
7683 , CUSTOM8
7684 , CUSTOM9
7685 , CUSTOM10
7686 , CUSTOM11
7687 , CUSTOM12
7688 , CUSTOM13
7689 , CUSTOM14
7690 , CUSTOM15
7691 , PLAN_TYPE_CODE /* 4471527 */
7692 )
7693 SELECT /*+ ordered full(rwid) rowid(tmp) */
7694 tmp.PROJECT_ID
7695 , tmp.PROJECT_ORG_ID
7696 , tmp.PROJECT_ORGANIZATION_ID
7697 -- , PARTITION_ID
7698 , tmp.PROJECT_ELEMENT_ID
7699 , tmp.TIME_ID
7700 , tmp.PERIOD_TYPE_ID
7701 , tmp.CALENDAR_TYPE
7702 , tmp.RBS_AGGR_LEVEL
7703 , tmp.WBS_ROLLUP_FLAG
7704 , tmp.PRG_ROLLUP_FLAG
7705 , tmp.CURR_RECORD_TYPE_ID
7706 , tmp.CURRENCY_CODE
7707 , tmp.RBS_ELEMENT_ID
7708 , tmp.RBS_VERSION_ID
7709 , ver3.PLAN_VERSION_ID
7710 , tmp.PLAN_TYPE_ID
7711 , l_last_update_date
7712 , l_last_updated_by
7713 , l_creation_date
7714 , l_created_by
7715 , l_last_update_login
7716 , RAW_COST
7717 , BRDN_COST
7718 , REVENUE
7719 , BILL_RAW_COST
7720 , BILL_BRDN_COST
7721 , BILL_LABOR_RAW_COST
7722 , BILL_LABOR_BRDN_COST
7723 , BILL_LABOR_HRS
7724 , EQUIPMENT_RAW_COST
7725 , EQUIPMENT_BRDN_COST
7726 , CAPITALIZABLE_RAW_COST
7727 , CAPITALIZABLE_BRDN_COST
7728 , LABOR_RAW_COST
7729 , LABOR_BRDN_COST
7730 , LABOR_HRS
7731 , LABOR_REVENUE
7732 , EQUIPMENT_HOURS
7733 , BILLABLE_EQUIPMENT_HOURS
7734 , SUP_INV_COMMITTED_COST
7735 , PO_COMMITTED_COST
7736 , PR_COMMITTED_COST
7737 , OTH_COMMITTED_COST
7738 , ACT_LABOR_HRS
7739 , ACT_EQUIP_HRS
7740 , ACT_LABOR_BRDN_COST
7741 , ACT_EQUIP_BRDN_COST
7742 , ACT_BRDN_COST
7743 , ACT_RAW_COST
7744 , ACT_REVENUE
7745 , ACT_LABOR_RAW_COST
7746 , ACT_EQUIP_RAW_COST
7747 , DECODE ( ver3.wp_flag
7748 , 'Y'
7749 , DECODE(TO_CHAR(tmp.ETC_LABOR_HRS) -- For Workplan
7750 , NULL
7751 , NVL(tmp.labor_hrs, 0)
7752 , NVL(tmp.ETC_LABOR_HRS, 0)
7753 )
7754 , NVL(tmp.ETC_LABOR_HRS, 0)
7755 ) ETC_LABOR_HRS
7756 , DECODE ( ver3.wp_flag
7757 , 'Y'
7758 , DECODE(TO_CHAR(tmp.ETC_EQUIP_HRS)
7759 , NULL
7760 , NVL(tmp.EQUIPMENT_hours, 0)
7761 , NVL(tmp.ETC_EQUIP_HRS, 0)
7762 )
7763 , NVL(tmp.ETC_EQUIP_HRS, 0)
7764 ) ETC_EQUIP_HRS
7765 , DECODE ( ver3.wp_flag
7766 , 'Y'
7767 , DECODE(TO_CHAR(tmp.ETC_LABOR_BRDN_COST)
7768 , NULL
7769 , NVL(tmp.labor_BRDN_COST, 0)
7770 , NVL(tmp.ETC_LABOR_BRDN_COST, 0)
7771 )
7772 , NVL(tmp.ETC_LABOR_BRDN_COST, 0)
7773 ) ETC_LABOR_BRDN_COST
7774 , DECODE ( ver3.wp_flag
7775 , 'Y'
7776 , DECODE(TO_CHAR(tmp.ETC_EQUIP_BRDN_COST)
7777 , NULL
7778 , NVL(tmp.EQUIPment_BRDN_COST, 0)
7779 , NVL(tmp.ETC_equip_BRDN_COST, 0)
7780 )
7781 , NVL(tmp.ETC_EQUIP_BRDN_COST, 0)
7782 ) ETC_equip_BRDN_COST
7783 , DECODE ( ver3.wp_flag
7784 , 'Y'
7785 , DECODE(TO_CHAR(tmp.ETC_BRDN_COST)
7786 , NULL
7787 , NVL(tmp.BRDN_COST, 0)
7788 , NVL(tmp.ETC_BRDN_COST, 0)
7789 )
7790 , NVL(tmp.ETC_BRDN_COST, 0)
7791 ) ETC_BRDN_COST
7792 , DECODE ( ver3.wp_flag
7793 , 'Y'
7794 , DECODE(TO_CHAR(tmp.ETC_raw_COST)
7795 , NULL
7796 , NVL(tmp.raw_COST, 0)
7797 , NVL(tmp.ETC_raw_COST, 0)
7798 )
7799 , NVL(tmp.ETC_raw_COST, 0)
7800 ) ETC_raw_COST
7801 , DECODE ( ver3.wp_flag
7802 , 'Y'
7803 , DECODE(TO_CHAR(tmp.ETC_labor_raw_COST)
7804 , NULL
7805 , NVL(tmp.labor_raw_COST, 0)
7806 , NVL(tmp.ETC_labor_raw_COST, 0)
7807 )
7808 , NVL(tmp.ETC_labor_raw_COST, 0)
7809 ) ETC_labor_raw_COST
7810 , DECODE ( ver3.wp_flag
7811 , 'Y'
7812 , DECODE(TO_CHAR(tmp.ETC_equip_raw_COST)
7813 , NULL
7814 , NVL(tmp.equipment_raw_COST, 0)
7815 , NVL(tmp.ETC_equip_raw_COST, 0)
7816 )
7817 , NVL(tmp.ETC_equip_raw_COST, 0)
7818 ) ETC_equip_raw_COST
7819 , CUSTOM1
7820 , CUSTOM2
7821 , CUSTOM3
7822 , CUSTOM4
7823 , CUSTOM5
7824 , CUSTOM6
7825 , CUSTOM7
7826 , CUSTOM8
7827 , CUSTOM9
7828 , CUSTOM10
7829 , CUSTOM11
7830 , CUSTOM12
7831 , CUSTOM13
7832 , CUSTOM14
7833 , CUSTOM15
7834 , tmp.plan_type_code /* 4471527 */
7835 FROM PJI_FP_RMAP_FPR_T rwid
7836 , pji_fp_aggr_pjp1_t tmp
7837 , pji_pjp_wbs_header ver3 -- replaced ver3 with wbs header for project-to-program association event.
7838 WHERE 1 = 1
7839 AND tmp.worker_id = g_worker_id
7840 AND rwid.worker_id = g_worker_id
7841 AND tmp.rowid = rwid.pjp1_rowid
7842 AND rwid.fpr_rowid IS NULL
7843 AND ver3.plan_version_id = tmp.plan_version_id
7844 AND ver3.plan_type_code = tmp.plan_type_code /* 4471527 */
7845 AND tmp.project_id = ver3.project_id -- use index.
7846 AND tmp.plan_type_id = NVL(ver3.plan_type_id, -1); -- each plan type can have a different -3, -4 slice.
7847
7848 IF P_PA_DEBUG_MODE = 'Y' THEN
7849 pa_debug.write('INSERT_FP_ROWS: ' || g_module_name,'INSERT_FP_ROWS : '||SQL%ROWCOUNT ,1);
7850 END IF;
7851 /* -- Bug 10632614
7852 ORDER BY
7853 tmp.PROJECT_ID
7854 , ver3.PLAN_VERSION_ID
7855 , tmp.PROJECT_ELEMENT_ID
7856 , tmp.TIME_ID
7857 , tmp.RBS_VERSION_ID
7858 */
7859 print_time ( ' MERGE_INTO_FP_FACT 3.1 worker id..' || g_worker_id || 'row count ' || SQL%ROWCOUNT) ;
7860
7861
7862 EXCEPTION
7863 WHEN OTHERS THEN
7864 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
7865 p_procedure_name => 'INSERT_FP_ROWS');
7866 RAISE;
7867 END;
7868
7869
7870 PROCEDURE INSERT_INTO_AC_FACT IS
7871 l_last_update_date date := SYSDATE;
7872 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
7873 l_creation_date date := SYSDATE;
7874 l_created_by NUMBER := FND_GLOBAL.USER_ID;
7875 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
7876 BEGIN
7877
7878 INSERT INTO PJI_AC_XBS_ACCUM_F
7879 (
7880 PROJECT_ID
7881 , PROJECT_ORG_ID
7882 , PROJECT_ORGANIZATION_ID
7883 , PROJECT_ELEMENT_ID
7884 , TIME_ID
7885 , PERIOD_TYPE_ID
7886 , CALENDAR_TYPE
7887 , WBS_ROLLUP_FLAG
7888 , PRG_ROLLUP_FLAG
7889 , CURR_RECORD_TYPE_ID
7890 , CURRENCY_CODE
7891 , REVENUE
7892 , INITIAL_FUNDING_AMOUNT
7893 , INITIAL_FUNDING_COUNT
7894 , ADDITIONAL_FUNDING_AMOUNT
7895 , ADDITIONAL_FUNDING_COUNT
7896 , CANCELLED_FUNDING_AMOUNT
7897 , CANCELLED_FUNDING_COUNT
7898 , FUNDING_ADJUSTMENT_AMOUNT
7899 , FUNDING_ADJUSTMENT_COUNT
7900 , REVENUE_WRITEOFF
7901 , AR_INVOICE_AMOUNT
7902 , AR_INVOICE_COUNT
7903 , AR_CASH_APPLIED_AMOUNT
7904 , AR_INVOICE_WRITE_OFF_AMOUNT
7905 , AR_INVOICE_WRITEOFF_COUNT
7906 , AR_CREDIT_MEMO_AMOUNT
7907 , AR_CREDIT_MEMO_COUNT
7908 , UNBILLED_RECEIVABLES
7909 , UNEARNED_REVENUE
7910 , AR_UNAPPR_INVOICE_AMOUNT
7911 , AR_UNAPPR_INVOICE_COUNT
7912 , AR_APPR_INVOICE_AMOUNT
7913 , AR_APPR_INVOICE_COUNT
7914 , AR_AMOUNT_DUE
7915 , AR_COUNT_DUE
7916 , AR_AMOUNT_OVERDUE
7917 , AR_COUNT_OVERDUE
7918 , DORMANT_BACKLOG_INACTIV
7919 , DORMANT_BACKLOG_START
7920 , LOST_BACKLOG
7921 , ACTIVE_BACKLOG
7922 , REVENUE_AT_RISK
7923 , LAST_UPDATE_DATE
7924 , LAST_UPDATED_BY
7925 , CREATION_DATE
7926 , CREATED_BY
7927 , LAST_UPDATE_LOGIN
7928 , CUSTOM1
7929 , CUSTOM2
7930 , CUSTOM3
7931 , CUSTOM4
7932 , CUSTOM5
7933 , CUSTOM6
7934 , CUSTOM7
7935 , CUSTOM8
7936 , CUSTOM9
7937 , CUSTOM10
7938 , CUSTOM11
7939 , CUSTOM12
7940 , CUSTOM13
7941 , CUSTOM14
7942 , CUSTOM15
7943 )
7944 SELECT
7945 PROJECT_ID
7946 , PROJECT_ORG_ID
7947 , PROJECT_ORGANIZATION_ID
7948 , PROJECT_ELEMENT_ID
7949 , TIME_ID
7950 , PERIOD_TYPE_ID
7951 , CALENDAR_TYPE
7952 , WBS_ROLLUP_FLAG
7953 , PRG_ROLLUP_FLAG
7954 , CURR_RECORD_TYPE_ID
7955 , CURRENCY_CODE
7956 , REVENUE
7957 , INITIAL_FUNDING_AMOUNT
7958 , INITIAL_FUNDING_COUNT
7959 , ADDITIONAL_FUNDING_AMOUNT
7960 , ADDITIONAL_FUNDING_COUNT
7961 , CANCELLED_FUNDING_AMOUNT
7962 , CANCELLED_FUNDING_COUNT
7963 , FUNDING_ADJUSTMENT_AMOUNT
7964 , FUNDING_ADJUSTMENT_COUNT
7965 , REVENUE_WRITEOFF
7966 , AR_INVOICE_AMOUNT
7967 , AR_INVOICE_COUNT
7968 , AR_CASH_APPLIED_AMOUNT
7969 , AR_INVOICE_WRITE_OFF_AMOUNT
7970 , AR_INVOICE_WRITEOFF_COUNT
7971 , AR_CREDIT_MEMO_AMOUNT
7972 , AR_CREDIT_MEMO_COUNT
7973 , UNBILLED_RECEIVABLES
7974 , UNEARNED_REVENUE
7975 , AR_UNAPPR_INVOICE_AMOUNT
7976 , AR_UNAPPR_INVOICE_COUNT
7977 , AR_APPR_INVOICE_AMOUNT
7978 , AR_APPR_INVOICE_COUNT
7979 , AR_AMOUNT_DUE
7980 , AR_COUNT_DUE
7981 , AR_AMOUNT_OVERDUE
7982 , AR_COUNT_OVERDUE
7983 , DORMANT_BACKLOG_INACTIV
7984 , DORMANT_BACKLOG_START
7985 , LOST_BACKLOG
7986 , ACTIVE_BACKLOG
7987 , REVENUE_AT_RISK
7988 , l_last_update_date
7989 , l_last_updated_by
7990 , l_creation_date
7991 , l_created_by
7992 , l_last_update_login
7993 , CUSTOM1
7994 , CUSTOM2
7995 , CUSTOM3
7996 , CUSTOM4
7997 , CUSTOM5
7998 , CUSTOM6
7999 , CUSTOM7
8000 , CUSTOM8
8001 , CUSTOM9
8002 , CUSTOM10
8003 , CUSTOM11
8004 , CUSTOM12
8005 , CUSTOM13
8006 , CUSTOM14
8007 , CUSTOM15
8008 FROM PJI_AC_AGGR_PJP1_T
8009 WHERE worker_id = g_worker_id
8010 ORDER BY
8011 PROJECT_ID
8012 , PROJECT_ELEMENT_ID
8013 , TIME_ID
8014 , CURRENCY_CODE;
8015
8016 EXCEPTION
8017 WHEN OTHERS THEN
8018 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8019 p_procedure_name => 'INSERT_INTO_AC_FACT');
8020 RAISE;
8021 END;
8022
8023
8024 PROCEDURE MERGE_INTO_AC_FACT IS
8025 BEGIN
8026
8027 CLEANUP_AC_RMAP_FPR;
8028
8029 GET_AC_ROW_IDS;
8030
8031 UPDATE_AC_ROWS;
8032
8033 INSERT_AC_ROWS;
8034
8035 EXCEPTION
8036 WHEN OTHERS THEN
8037 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8038 p_procedure_name => 'MERGE_INTO_AC_FACT');
8039 RAISE;
8040 END;
8041
8042
8043 PROCEDURE CLEANUP_AC_RMAP_FPR IS
8044 BEGIN
8045
8046 DELETE FROM PJI_ac_RMAP_acR_T
8047 WHERE worker_id = g_worker_id;
8048
8049 EXCEPTION
8050 WHEN OTHERS THEN
8051 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8052 p_procedure_name => 'CLEANUP_AC_RMAP_FPR');
8053 RAISE;
8054 END;
8055
8056
8057 PROCEDURE GET_AC_ROW_IDS IS
8058 BEGIN
8059
8060 INSERT INTO PJI_ac_RMAP_acR_T
8061 (
8062 worker_id
8063 , pjp1_rowid
8064 , fpr_rowid
8065 )
8066 SELECT
8067 g_worker_id WORKER_ID
8068 , tmp.ROWID PJP1_ROWID
8069 , rl.ROWID FPR_ROWID
8070 FROM
8071 PJI_AC_AGGR_PJP1_T tmp
8072 , PJI_AC_XBS_ACCUM_F rl
8073 WHERE 1 = 1
8074 AND tmp.worker_id = g_worker_id
8075 AND tmp.PROJECT_ID = rl.PROJECT_ID (+)
8076 AND tmp.PROJECT_ORG_ID = rl.PROJECT_ORG_ID (+)
8077 AND tmp.PROJECT_ORGANIZATION_ID = rl.PROJECT_ORGANIZATION_ID (+)
8078 AND tmp.PROJECT_ELEMENT_ID = rl.PROJECT_ELEMENT_ID (+)
8079 AND tmp.TIME_ID = rl.TIME_ID (+)
8080 AND tmp.PERIOD_TYPE_ID = rl.PERIOD_TYPE_ID (+)
8081 AND tmp.CALENDAR_TYPE = rl.CALENDAR_TYPE (+)
8082 AND tmp.WBS_ROLLUP_FLAG = rl.WBS_ROLLUP_FLAG (+)
8083 AND tmp.PRG_ROLLUP_FLAG = rl.PRG_ROLLUP_FLAG (+)
8084 AND tmp.CURR_RECORD_TYPE_ID = rl.CURR_RECORD_TYPE_ID (+)
8085 AND tmp.CURRENCY_CODE = rl.CURRENCY_CODE (+) ;
8086
8087 EXCEPTION
8088 WHEN OTHERS THEN
8089 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8090 p_procedure_name => 'GET_AC_ROW_IDS');
8091 RAISE;
8092 END;
8093
8094
8095 PROCEDURE UPDATE_AC_ROWS IS
8096
8097 l_last_update_date DATE := SYSDATE;
8098 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
8099 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
8100
8101 BEGIN
8102
8103 UPDATE /*+ ordered use_nl(rl) rowid(rl) */
8104 PJI_AC_XBS_ACCUM_F rl
8105 SET (
8106 rl.REVENUE
8107 , rl.INITIAL_FUNDING_AMOUNT
8108 , rl.INITIAL_FUNDING_COUNT
8109 , rl.ADDITIONAL_FUNDING_AMOUNT
8110 , rl.ADDITIONAL_FUNDING_COUNT
8111 , rl.CANCELLED_FUNDING_AMOUNT
8112 , rl.CANCELLED_FUNDING_COUNT
8113 , rl.FUNDING_ADJUSTMENT_AMOUNT
8114 , rl.FUNDING_ADJUSTMENT_COUNT
8115 , rl.REVENUE_WRITEOFF
8116 , rl.AR_INVOICE_AMOUNT
8117 , rl.AR_INVOICE_COUNT
8118 , rl.AR_CASH_APPLIED_AMOUNT
8119 , rl.AR_INVOICE_WRITE_OFF_AMOUNT
8120 , rl.AR_INVOICE_WRITEOFF_COUNT
8121 , rl.AR_CREDIT_MEMO_AMOUNT
8122 , rl.AR_CREDIT_MEMO_COUNT
8123 , rl.UNBILLED_RECEIVABLES
8124 , rl.UNEARNED_REVENUE
8125 , rl.AR_UNAPPR_INVOICE_AMOUNT
8126 , rl.AR_UNAPPR_INVOICE_COUNT
8127 , rl.AR_APPR_INVOICE_AMOUNT
8128 , rl.AR_APPR_INVOICE_COUNT
8129 , rl.AR_AMOUNT_DUE
8130 , rl.AR_COUNT_DUE
8131 , rl.AR_AMOUNT_OVERDUE
8132 , rl.AR_COUNT_OVERDUE
8133 , rl.DORMANT_BACKLOG_INACTIV
8134 , rl.DORMANT_BACKLOG_START
8135 , rl.LOST_BACKLOG
8136 , rl.ACTIVE_BACKLOG
8137 , rl.REVENUE_AT_RISK
8138 , rl.CUSTOM1
8139 , rl.CUSTOM2
8140 , rl.CUSTOM3
8141 , rl.CUSTOM4
8142 , rl.CUSTOM5
8143 , rl.CUSTOM6
8144 , rl.CUSTOM7
8145 , rl.CUSTOM8
8146 , rl.CUSTOM9
8147 , rl.CUSTOM10
8148 , rl.CUSTOM11
8149 , rl.CUSTOM12
8150 , rl.CUSTOM13
8151 , rl.CUSTOM14
8152 , rl.CUSTOM15
8153 , rl.LAST_UPDATE_DATE
8154 , rl.LAST_UPDATED_BY
8155 , rl.LAST_UPDATE_LOGIN
8156 ) =
8157 (
8158 SELECT /*+ ORDERED ROWID(TMP) index(rwid,PJI_AC_RMAP_ACR_T_N1) */
8159 NVL(rl.REVENUE, 0) + NVL(tmp.REVENUE, 0)
8160 , NVL(rl.INITIAL_FUNDING_AMOUNT, 0) + NVL(tmp.INITIAL_FUNDING_AMOUNT, 0)
8161 , NVL(rl.INITIAL_FUNDING_COUNT, 0) + NVL(tmp.INITIAL_FUNDING_COUNT, 0)
8162 , NVL(rl.ADDITIONAL_FUNDING_AMOUNT, 0) + NVL(tmp.ADDITIONAL_FUNDING_AMOUNT, 0)
8163 , NVL(rl.ADDITIONAL_FUNDING_COUNT, 0) + NVL(tmp.ADDITIONAL_FUNDING_COUNT, 0)
8164 , NVL(rl.CANCELLED_FUNDING_AMOUNT, 0) + NVL(tmp.CANCELLED_FUNDING_AMOUNT, 0)
8165 , NVL(rl.CANCELLED_FUNDING_COUNT, 0) + NVL(tmp.CANCELLED_FUNDING_COUNT, 0)
8166 , NVL(rl.FUNDING_ADJUSTMENT_AMOUNT, 0) + NVL(tmp.FUNDING_ADJUSTMENT_AMOUNT, 0)
8167 , NVL(rl.FUNDING_ADJUSTMENT_COUNT, 0) + NVL(tmp.FUNDING_ADJUSTMENT_COUNT, 0)
8168 , NVL(rl.REVENUE_WRITEOFF, 0) + NVL(tmp.REVENUE_WRITEOFF, 0)
8169 , NVL(rl.AR_INVOICE_AMOUNT, 0) + NVL(tmp.AR_INVOICE_AMOUNT, 0)
8170 , NVL(rl.AR_INVOICE_COUNT, 0) + NVL(tmp.AR_INVOICE_COUNT, 0)
8171 , NVL(rl.AR_CASH_APPLIED_AMOUNT, 0) + NVL(tmp.AR_CASH_APPLIED_AMOUNT, 0)
8172 , NVL(rl.AR_INVOICE_WRITE_OFF_AMOUNT, 0) + NVL(tmp.AR_INVOICE_WRITE_OFF_AMOUNT, 0)
8173 , NVL(rl.AR_INVOICE_WRITEOFF_COUNT, 0) + NVL(tmp.AR_INVOICE_WRITEOFF_COUNT, 0)
8174 , NVL(rl.AR_CREDIT_MEMO_AMOUNT, 0) + NVL(tmp.AR_CREDIT_MEMO_AMOUNT, 0)
8175 , NVL(rl.AR_CREDIT_MEMO_COUNT, 0) + NVL(tmp.AR_CREDIT_MEMO_COUNT, 0)
8176 , NVL(rl.UNBILLED_RECEIVABLES, 0) + NVL(tmp.UNBILLED_RECEIVABLES, 0)
8177 , NVL(rl.UNEARNED_REVENUE, 0) + NVL(tmp.UNEARNED_REVENUE, 0)
8178 , NVL(rl.AR_UNAPPR_INVOICE_AMOUNT, 0) + NVL(tmp.AR_UNAPPR_INVOICE_AMOUNT, 0)
8179 , NVL(rl.AR_UNAPPR_INVOICE_COUNT, 0) + NVL(tmp.AR_UNAPPR_INVOICE_COUNT, 0)
8180 , NVL(rl.AR_APPR_INVOICE_AMOUNT, 0) + NVL(tmp.AR_APPR_INVOICE_AMOUNT, 0)
8181 , NVL(rl.AR_APPR_INVOICE_COUNT, 0) + NVL(tmp.AR_APPR_INVOICE_COUNT, 0)
8182 , NVL(rl.AR_AMOUNT_DUE, 0) + NVL(tmp.AR_AMOUNT_DUE, 0)
8183 , NVL(rl.AR_COUNT_DUE, 0) + NVL(tmp.AR_COUNT_DUE, 0)
8184 , NVL(rl.AR_AMOUNT_OVERDUE, 0) + NVL(tmp.AR_AMOUNT_OVERDUE, 0)
8185 , NVL(rl.AR_COUNT_OVERDUE, 0) + NVL(tmp.AR_COUNT_OVERDUE, 0)
8186 , NVL(rl.DORMANT_BACKLOG_INACTIV, 0) + NVL(tmp.DORMANT_BACKLOG_INACTIV, 0)
8187 , NVL(rl.DORMANT_BACKLOG_START, 0) + NVL(tmp.DORMANT_BACKLOG_START, 0)
8188 , NVL(rl.LOST_BACKLOG, 0) + NVL(tmp.LOST_BACKLOG, 0)
8189 , NVL(rl.ACTIVE_BACKLOG, 0) + NVL(tmp.ACTIVE_BACKLOG, 0)
8190 , NVL(rl.REVENUE_AT_RISK, 0) + NVL(tmp.REVENUE_AT_RISK, 0)
8191 , NVL(rl.CUSTOM1, 0) + NVL(tmp.CUSTOM1, 0)
8192 , NVL(rl.CUSTOM2, 0) + NVL(tmp.CUSTOM2, 0)
8193 , NVL(rl.CUSTOM3, 0) + NVL(tmp.CUSTOM3, 0)
8194 , NVL(rl.CUSTOM4, 0) + NVL(tmp.CUSTOM4, 0)
8195 , NVL(rl.CUSTOM5, 0) + NVL(tmp.CUSTOM5, 0)
8196 , NVL(rl.CUSTOM6, 0) + NVL(tmp.CUSTOM6, 0)
8197 , NVL(rl.CUSTOM7, 0) + NVL(tmp.CUSTOM7, 0)
8198 , NVL(rl.CUSTOM8, 0) + NVL(tmp.CUSTOM8, 0)
8199 , NVL(rl.CUSTOM9, 0) + NVL(tmp.CUSTOM9, 0)
8200 , NVL(rl.CUSTOM10, 0) + NVL(tmp.CUSTOM10, 0)
8201 , NVL(rl.CUSTOM11, 0) + NVL(tmp.CUSTOM11, 0)
8202 , NVL(rl.CUSTOM12, 0) + NVL(tmp.CUSTOM12, 0)
8203 , NVL(rl.CUSTOM13, 0) + NVL(tmp.CUSTOM13, 0)
8204 , NVL(rl.CUSTOM14, 0) + NVL(tmp.CUSTOM14, 0)
8205 , NVL(rl.CUSTOM15, 0) + NVL(tmp.CUSTOM15, 0)
8206 , l_last_update_date
8207 , l_last_updated_by
8208 , l_last_update_login
8209 FROM
8210 PJI_AC_RMAP_ACR_T rwid
8211 , PJI_AC_AGGR_PJP1_T tmp
8212 WHERE 1 = 1
8213 AND tmp.worker_id = g_worker_id
8214 AND rwid.worker_id = g_worker_id
8215 AND tmp.rowid = rwid.pjp1_rowid
8216 AND rl.rowid = rwid.fpr_rowid
8217 AND rwid.fpr_rowid IS NOT NULL
8218 )
8219 WHERE rl.rowid IN
8220 ( SELECT fpr_rowid
8221 FROM PJI_ac_RMAP_acR_T rwid
8222 WHERE 1=1
8223 AND rwid.fpr_rowid IS NOT NULL
8224 AND rwid.worker_id = g_worker_id);
8225
8226 EXCEPTION
8227 WHEN OTHERS THEN
8228 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8229 p_procedure_name => 'UPDATE_AC_ROWS');
8230 RAISE;
8231 END;
8232
8233
8234 PROCEDURE INSERT_AC_ROWS IS
8235 l_last_update_date date := SYSDATE;
8236 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
8237 l_creation_date date := SYSDATE;
8238 l_created_by NUMBER := FND_GLOBAL.USER_ID;
8239 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
8240 BEGIN
8241
8242 INSERT INTO PJI_AC_XBS_ACCUM_F
8243 (
8244 PROJECT_ID
8245 , PROJECT_ORG_ID
8246 , PROJECT_ORGANIZATION_ID
8247 , PROJECT_ELEMENT_ID
8248 , TIME_ID
8249 , PERIOD_TYPE_ID
8250 , CALENDAR_TYPE
8251 , WBS_ROLLUP_FLAG
8252 , PRG_ROLLUP_FLAG
8253 , CURR_RECORD_TYPE_ID
8254 , CURRENCY_CODE
8255 , REVENUE
8256 , INITIAL_FUNDING_AMOUNT
8257 , INITIAL_FUNDING_COUNT
8258 , ADDITIONAL_FUNDING_AMOUNT
8259 , ADDITIONAL_FUNDING_COUNT
8260 , CANCELLED_FUNDING_AMOUNT
8261 , CANCELLED_FUNDING_COUNT
8262 , FUNDING_ADJUSTMENT_AMOUNT
8263 , FUNDING_ADJUSTMENT_COUNT
8264 , REVENUE_WRITEOFF
8265 , AR_INVOICE_AMOUNT
8266 , AR_INVOICE_COUNT
8267 , AR_CASH_APPLIED_AMOUNT
8268 , AR_INVOICE_WRITE_OFF_AMOUNT
8269 , AR_INVOICE_WRITEOFF_COUNT
8270 , AR_CREDIT_MEMO_AMOUNT
8271 , AR_CREDIT_MEMO_COUNT
8272 , UNBILLED_RECEIVABLES
8273 , UNEARNED_REVENUE
8274 , AR_UNAPPR_INVOICE_AMOUNT
8275 , AR_UNAPPR_INVOICE_COUNT
8276 , AR_APPR_INVOICE_AMOUNT
8277 , AR_APPR_INVOICE_COUNT
8278 , AR_AMOUNT_DUE
8279 , AR_COUNT_DUE
8280 , AR_AMOUNT_OVERDUE
8281 , AR_COUNT_OVERDUE
8282 , DORMANT_BACKLOG_INACTIV
8283 , DORMANT_BACKLOG_START
8284 , LOST_BACKLOG
8285 , ACTIVE_BACKLOG
8286 , REVENUE_AT_RISK
8287 , LAST_UPDATE_DATE
8288 , LAST_UPDATED_BY
8289 , CREATION_DATE
8290 , CREATED_BY
8291 , LAST_UPDATE_LOGIN
8292 , CUSTOM1
8293 , CUSTOM2
8294 , CUSTOM3
8295 , CUSTOM4
8296 , CUSTOM5
8297 , CUSTOM6
8298 , CUSTOM7
8299 , CUSTOM8
8300 , CUSTOM9
8301 , CUSTOM10
8302 , CUSTOM11
8303 , CUSTOM12
8304 , CUSTOM13
8305 , CUSTOM14
8306 , CUSTOM15
8307 )
8308 SELECT
8309 PROJECT_ID
8310 , PROJECT_ORG_ID
8311 , PROJECT_ORGANIZATION_ID
8312 , PROJECT_ELEMENT_ID
8313 , TIME_ID
8314 , PERIOD_TYPE_ID
8315 , CALENDAR_TYPE
8316 , WBS_ROLLUP_FLAG
8317 , PRG_ROLLUP_FLAG
8318 , CURR_RECORD_TYPE_ID
8319 , CURRENCY_CODE
8320 , REVENUE
8321 , INITIAL_FUNDING_AMOUNT
8322 , INITIAL_FUNDING_COUNT
8323 , ADDITIONAL_FUNDING_AMOUNT
8324 , ADDITIONAL_FUNDING_COUNT
8325 , CANCELLED_FUNDING_AMOUNT
8326 , CANCELLED_FUNDING_COUNT
8327 , FUNDING_ADJUSTMENT_AMOUNT
8328 , FUNDING_ADJUSTMENT_COUNT
8329 , REVENUE_WRITEOFF
8330 , AR_INVOICE_AMOUNT
8331 , AR_INVOICE_COUNT
8332 , AR_CASH_APPLIED_AMOUNT
8333 , AR_INVOICE_WRITE_OFF_AMOUNT
8334 , AR_INVOICE_WRITEOFF_COUNT
8335 , AR_CREDIT_MEMO_AMOUNT
8336 , AR_CREDIT_MEMO_COUNT
8337 , UNBILLED_RECEIVABLES
8338 , UNEARNED_REVENUE
8339 , AR_UNAPPR_INVOICE_AMOUNT
8340 , AR_UNAPPR_INVOICE_COUNT
8341 , AR_APPR_INVOICE_AMOUNT
8342 , AR_APPR_INVOICE_COUNT
8343 , AR_AMOUNT_DUE
8344 , AR_COUNT_DUE
8345 , AR_AMOUNT_OVERDUE
8346 , AR_COUNT_OVERDUE
8347 , DORMANT_BACKLOG_INACTIV
8348 , DORMANT_BACKLOG_START
8349 , LOST_BACKLOG
8350 , ACTIVE_BACKLOG
8351 , REVENUE_AT_RISK
8352 , l_last_update_date
8353 , l_last_updated_by
8354 , l_creation_date
8355 , l_created_by
8356 , l_last_update_login
8357 , CUSTOM1
8358 , CUSTOM2
8359 , CUSTOM3
8360 , CUSTOM4
8361 , CUSTOM5
8362 , CUSTOM6
8363 , CUSTOM7
8364 , CUSTOM8
8365 , CUSTOM9
8366 , CUSTOM10
8367 , CUSTOM11
8368 , CUSTOM12
8369 , CUSTOM13
8370 , CUSTOM14
8371 , CUSTOM15
8372 FROM PJI_AC_AGGR_PJP1_T tmp
8373 , PJI_ac_RMAP_acR_T rwid
8374 WHERE 1 = 1
8375 AND tmp.worker_id = g_worker_id
8376 AND rwid.worker_id = g_worker_id
8377 AND tmp.rowid = rwid.pjp1_rowid
8378 AND rwid.fpr_rowid IS NULL
8379 ORDER BY
8380 PROJECT_ID
8381 , PROJECT_ELEMENT_ID
8382 , TIME_ID
8383 , CURRENCY_CODE;
8384
8385 EXCEPTION
8386 WHEN OTHERS THEN
8387 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8388 p_procedure_name => 'INSERT_AC_ROWS');
8389 RAISE;
8390 END;
8391
8392 PROCEDURE MARK_DANGLING_PLAN_VERSIONS IS
8393 BEGIN
8394
8395 -- Added INDEX for bug 3828698
8396 UPDATE /*+ INDEX(bv,PA_BUDGET_VERSIONS_U1)*/ pa_budget_versions bv
8397 SET pji_summarized_flag = 'P',
8398 record_version_number = nvl(record_version_number,0)+1
8399 WHERE budget_version_id IN (
8400 SELECT plan_version_id
8401 FROM
8402 (
8403 SELECT plan_version_id
8404 , ( COUNT(DISTINCT time_dangling_flag)
8405 + COUNT(DISTINCT rate_dangling_flag)
8406 ) dangling
8407 FROM pji_fp_aggr_pjp1_t
8408 WHERE worker_id = g_worker_id
8409 GROUP BY plan_version_id
8410 ) b
8411 WHERE dangling > 2
8412 );
8413
8414 UPDATE /*+ INDEX(bv,PA_BUDGET_VERSIONS_U1)*/ pa_budget_versions bv
8415 SET pji_summarized_flag = 'Y',
8416 record_version_number = nvl(record_version_number,0)+1
8417 WHERE budget_version_id IN (
8418 SELECT plan_version_id
8419 FROM
8420 (
8421 SELECT plan_version_id
8422 , ( COUNT(DISTINCT time_dangling_flag)
8423 + COUNT(DISTINCT rate_dangling_flag)
8424 ) dangling
8425 FROM pji_fp_aggr_pjp1_t
8426 WHERE worker_id = g_worker_id
8427 GROUP BY plan_version_id
8428 ) b
8429 WHERE dangling = 2
8430 );
8431
8432 EXCEPTION
8433 WHEN OTHERS THEN
8434 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8435 p_procedure_name => 'MARK_DANGLING_PLAN_VERSIONS');
8436 RAISE;
8437 END;
8438
8439
8440 --
8441 -- 0. Plans cannot have time / rate dangling records for primary slice.
8442 -- 1. Work plans have primary slice only.
8443 -- 2. Financial plans can have secondary slices only if the plan is baselined.
8444 -- 3. Only baselined financial plans can have time/rate dangling records.
8445 -- 4. Four states of pji_summarized_flag are N, Y, P, NULL.
8446 -- N - Not summarized..
8447 -- P - Have rate/time dangling records..
8448 -- Y - Project performance summaries fully created.
8449 -- NULL - PJI summaries fully created.
8450 --
8451 -- This api processes plans with pji_summarized_flag = N, i.e., secondary slice
8452 -- for dangling baselined financial plans.
8453 --
8454 PROCEDURE PULL_DANGLING_PLANS IS
8455
8456 l_fp_wp_version_ids SYSTEM.pa_num_tbl_type := SYSTEM.pa_num_tbl_type();
8457 l_fp_version_ids SYSTEM.pa_num_tbl_type := SYSTEM.pa_num_tbl_type();
8458
8459 /*
8460 CURSOR c_dangling_vers_cur IS
8461 SELECT budget_version_id
8462 FROM pa_budget_versions bv
8463 WHERE pji_summarized_flag = 'P';
8464 */
8465
8466 BEGIN
8467
8468 CLEANUP_INTERIM_TABLES;
8469
8470 -- FOR c_dangling IN c_dangling_vers_cur LOOP
8471
8472 -- print_time ( ' plan version id is ... ' || c_dangling.budget_version_id ) ;
8473 -- l_fp_wp_version_ids := SYSTEM.pa_num_tbl_type (c_dangling.budget_version_id);
8474
8475 PJI_FM_PLAN_MAINT.CREATE_SECONDARY_T_PVT(
8476 p_fp_version_ids => l_fp_wp_version_ids
8477 , p_process_all => 'T'
8478 , p_commit => 'F');
8479
8480 -- END LOOP;
8481
8482 EXCEPTION
8483 WHEN OTHERS THEN
8484 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8485 p_procedure_name => 'PULL_DANGLING_PLANS');
8486 RAISE;
8487 END;
8488
8489
8490 PROCEDURE RETRIEVE_ENTERED_SLICE (
8491 p_pln_ver_id IN NUMBER := NULL ) IS
8492 BEGIN
8493
8494 INSERT INTO pji_fp_aggr_pjp1_t
8495 (
8496 WORKER_ID
8497 , PROJECT_ID
8498 , PROJECT_ORG_ID
8499 , PROJECT_ORGANIZATION_ID
8500 -- , PARTITION_ID
8501 , PROJECT_ELEMENT_ID
8502 , TIME_ID
8503 , PERIOD_TYPE_ID
8504 , CALENDAR_TYPE
8505 , RBS_AGGR_LEVEL
8506 , WBS_ROLLUP_FLAG
8507 , PRG_ROLLUP_FLAG
8508 , CURR_RECORD_TYPE_ID
8509 , CURRENCY_CODE
8510 , RBS_ELEMENT_ID
8511 , RBS_VERSION_ID
8512 , PLAN_VERSION_ID
8513 , PLAN_TYPE_ID
8514 , RAW_COST
8515 , BRDN_COST
8516 , REVENUE
8517 , BILL_RAW_COST
8518 , BILL_BRDN_COST
8519 , BILL_LABOR_RAW_COST
8520 , BILL_LABOR_BRDN_COST
8521 , BILL_LABOR_HRS
8522 , EQUIPMENT_RAW_COST
8523 , EQUIPMENT_BRDN_COST
8524 , CAPITALIZABLE_RAW_COST
8525 , CAPITALIZABLE_BRDN_COST
8526 , LABOR_RAW_COST
8527 , LABOR_BRDN_COST
8528 , LABOR_HRS
8529 , LABOR_REVENUE
8530 , EQUIPMENT_HOURS
8531 , BILLABLE_EQUIPMENT_HOURS
8532 , SUP_INV_COMMITTED_COST
8533 , PO_COMMITTED_COST
8534 , PR_COMMITTED_COST
8535 , OTH_COMMITTED_COST
8536 , ACT_LABOR_HRS
8537 , ACT_EQUIP_HRS
8538 , ACT_LABOR_BRDN_COST
8539 , ACT_EQUIP_BRDN_COST
8540 , ACT_BRDN_COST
8541 , ACT_RAW_COST
8542 , ACT_REVENUE
8543 , ACT_LABOR_RAW_COST
8544 , ACT_EQUIP_RAW_COST
8545 , ETC_LABOR_HRS
8546 , ETC_EQUIP_HRS
8547 , ETC_LABOR_BRDN_COST
8548 , ETC_EQUIP_BRDN_COST
8549 , ETC_BRDN_COST
8550 , ETC_RAW_COST
8551 , ETC_LABOR_RAW_COST
8552 , ETC_EQUIP_RAW_COST
8553 , CUSTOM1
8554 , CUSTOM2
8555 , CUSTOM3
8556 , CUSTOM4
8557 , CUSTOM5
8558 , CUSTOM6
8559 , CUSTOM7
8560 , CUSTOM8
8561 , CUSTOM9
8562 , CUSTOM10
8563 , CUSTOM11
8564 , CUSTOM12
8565 , CUSTOM13
8566 , CUSTOM14
8567 , CUSTOM15
8568 , PRG_LEVEL
8569 , PLAN_TYPE_CODE
8570 )
8571 (
8572 SELECT
8573 g_worker_id
8574 , PROJECT_ID
8575 , PROJECT_ORG_ID
8576 , PROJECT_ORGANIZATION_ID
8577 -- , PARTITION_ID
8578 , PROJECT_ELEMENT_ID
8579 , TIME_ID
8580 , PERIOD_TYPE_ID
8581 , CALENDAR_TYPE
8582 , RBS_AGGR_LEVEL
8583 , WBS_ROLLUP_FLAG
8584 , PRG_ROLLUP_FLAG
8585 , CURR_RECORD_TYPE_ID
8586 , CURRENCY_CODE
8587 , RBS_ELEMENT_ID
8588 , RBS_VERSION_ID
8589 , PLAN_VERSION_ID
8590 , PLAN_TYPE_ID
8591 , RAW_COST
8592 , BRDN_COST
8593 , REVENUE
8594 , BILL_RAW_COST
8595 , BILL_BRDN_COST
8596 , BILL_LABOR_RAW_COST
8597 , BILL_LABOR_BRDN_COST
8598 , BILL_LABOR_HRS
8599 , EQUIPMENT_RAW_COST
8600 , EQUIPMENT_BRDN_COST
8601 , CAPITALIZABLE_RAW_COST
8602 , CAPITALIZABLE_BRDN_COST
8603 , LABOR_RAW_COST
8604 , LABOR_BRDN_COST
8605 , LABOR_HRS
8606 , LABOR_REVENUE
8607 , EQUIPMENT_HOURS
8608 , BILLABLE_EQUIPMENT_HOURS
8609 , SUP_INV_COMMITTED_COST
8610 , PO_COMMITTED_COST
8611 , PR_COMMITTED_COST
8612 , OTH_COMMITTED_COST
8613 , ACT_LABOR_HRS
8614 , ACT_EQUIP_HRS
8615 , ACT_LABOR_BRDN_COST
8616 , ACT_EQUIP_BRDN_COST
8617 , ACT_BRDN_COST
8618 , ACT_RAW_COST
8619 , ACT_REVENUE
8620 , ACT_LABOR_RAW_COST
8621 , ACT_EQUIP_RAW_COST
8622 , ETC_LABOR_HRS
8623 , ETC_EQUIP_HRS
8624 , ETC_LABOR_BRDN_COST
8625 , ETC_EQUIP_BRDN_COST
8626 , ETC_BRDN_COST
8627 , ETC_RAW_COST
8628 , ETC_LABOR_RAW_COST
8629 , ETC_EQUIP_RAW_COST
8630 , CUSTOM1
8631 , CUSTOM2
8632 , CUSTOM3
8633 , CUSTOM4
8634 , CUSTOM5
8635 , CUSTOM6
8636 , CUSTOM7
8637 , CUSTOM8
8638 , CUSTOM9
8639 , CUSTOM10
8640 , CUSTOM11
8641 , CUSTOM12
8642 , CUSTOM13
8643 , CUSTOM14
8644 , CUSTOM15
8645 , g_default_prg_level
8646 , plan_type_code
8647 FROM pji_fp_xbs_accum_f
8648 WHERE plan_version_id = p_pln_ver_id
8649 );
8650
8651 EXCEPTION
8652 WHEN OTHERS THEN
8653 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8654 p_procedure_name => 'RETRIEVE_ENTERED_SLICE');
8655 RAISE;
8656 END;
8657
8658
8659
8660
8661 PROCEDURE ROLLUP_FPR_RBS IS
8662 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
8663 -- l_worker_id NUMBER := 1;
8664
8665 BEGIN
8666
8667 INSERT INTO pji_fp_aggr_pjp1_t
8668 (
8669 WORKER_ID
8670 , PROJECT_ID
8671 , PROJECT_ORG_ID
8672 , PROJECT_ORGANIZATION_ID
8673 , PROJECT_ELEMENT_ID
8674 , TIME_ID
8675 , PERIOD_TYPE_ID
8676 , CALENDAR_TYPE
8677 , RBS_AGGR_LEVEL
8678 , WBS_ROLLUP_FLAG
8679 , PRG_ROLLUP_FLAG
8680 , CURR_RECORD_TYPE_ID
8681 , CURRENCY_CODE
8682 , RBS_ELEMENT_ID
8683 , RBS_VERSION_ID
8684 , PLAN_VERSION_ID
8685 , PLAN_TYPE_ID
8686 , RAW_COST
8687 , BRDN_COST
8688 , REVENUE
8689 , BILL_RAW_COST
8690 , BILL_BRDN_COST
8691 , BILL_LABOR_RAW_COST
8692 , BILL_LABOR_BRDN_COST
8693 , BILL_LABOR_HRS
8694 , EQUIPMENT_RAW_COST
8695 , EQUIPMENT_BRDN_COST
8696 , CAPITALIZABLE_RAW_COST
8697 , CAPITALIZABLE_BRDN_COST
8698 , LABOR_RAW_COST
8699 , LABOR_BRDN_COST
8700 , LABOR_HRS
8701 , LABOR_REVENUE
8702 , EQUIPMENT_HOURS
8703 , BILLABLE_EQUIPMENT_HOURS
8704 , SUP_INV_COMMITTED_COST
8705 , PO_COMMITTED_COST
8706 , PR_COMMITTED_COST
8707 , OTH_COMMITTED_COST
8708 , ACT_LABOR_HRS
8709 , ACT_EQUIP_HRS
8710 , ACT_LABOR_BRDN_COST
8711 , ACT_EQUIP_BRDN_COST
8712 , ACT_BRDN_COST
8713 , ACT_RAW_COST
8714 , ACT_REVENUE
8715 , ACT_LABOR_RAW_COST
8716 , ACT_EQUIP_RAW_COST
8717 , ETC_LABOR_HRS
8718 , ETC_EQUIP_HRS
8719 , ETC_LABOR_BRDN_COST
8720 , ETC_EQUIP_BRDN_COST
8721 , ETC_BRDN_COST
8722 , ETC_RAW_COST
8723 , ETC_LABOR_RAW_COST
8724 , ETC_EQUIP_RAW_COST
8725 , CUSTOM1
8726 , CUSTOM2
8727 , CUSTOM3
8728 , CUSTOM4
8729 , CUSTOM5
8730 , CUSTOM6
8731 , CUSTOM7
8732 , CUSTOM8
8733 , CUSTOM9
8734 , CUSTOM10
8735 , CUSTOM11
8736 , CUSTOM12
8737 , CUSTOM13
8738 , CUSTOM14
8739 , CUSTOM15
8740 , LINE_TYPE
8741 , PRG_LEVEL
8742 , PLAN_TYPE_CODE
8743 )
8744 SELECT
8745 g_worker_id WORKER_ID
8746 , fact1.PROJECT_ID
8747 , fact1.PROJECT_ORG_ID
8748 , fact1.PROJECT_ORGANIZATION_ID
8749 , fact1.project_element_id
8750 , fact1.TIME_ID
8751 , fact1.PERIOD_TYPE_ID
8752 , fact1.CALENDAR_TYPE
8753 , g_rolled_up
8754 , fact1.WBS_ROLLUP_FLAG
8755 , fact1.PRG_ROLLUP_FLAG
8756 , fact1.CURR_RECORD_TYPE_ID
8757 , fact1.CURRENCY_CODE
8758 , rbs.sup_id
8759 , fact1.RBS_VERSION_ID
8760 , fact1.PLAN_VERSION_ID
8761 , fact1.PLAN_TYPE_ID
8762 , SUM(fact1.RAW_COST)
8763 , SUM(fact1.BRDN_COST)
8764 , SUM(fact1.REVENUE)
8765 , SUM(fact1.BILL_RAW_COST)
8766 , SUM(fact1.BILL_BRDN_COST )
8767 , SUM(fact1.BILL_LABOR_RAW_COST)
8768 , SUM(fact1.BILL_LABOR_BRDN_COST )
8769 , SUM(fact1.BILL_LABOR_HRS )
8770 , SUM(fact1.EQUIPMENT_RAW_COST )
8771 , SUM(fact1.EQUIPMENT_BRDN_COST )
8772 , SUM(fact1.CAPITALIZABLE_RAW_COST )
8773 , SUM(fact1.CAPITALIZABLE_BRDN_COST )
8774 , SUM(fact1.LABOR_RAW_COST )
8775 , SUM(fact1.LABOR_BRDN_COST )
8776 , SUM(fact1.LABOR_HRS)
8777 , SUM(fact1.LABOR_REVENUE)
8778 , SUM(fact1.EQUIPMENT_HOURS)
8779 , SUM(fact1.BILLABLE_EQUIPMENT_HOURS)
8780 , SUM(fact1.SUP_INV_COMMITTED_COST)
8781 , SUM(fact1.PO_COMMITTED_COST )
8782 , SUM(fact1.PR_COMMITTED_COST )
8783 , SUM(fact1.OTH_COMMITTED_COST)
8784 , SUM(fact1.ACT_LABOR_HRS)
8785 , SUM(fact1.ACT_EQUIP_HRS)
8786 , SUM(fact1.ACT_LABOR_BRDN_COST)
8787 , SUM(fact1.ACT_EQUIP_BRDN_COST)
8788 , SUM(fact1.ACT_BRDN_COST)
8789 , SUM(fact1.ACT_RAW_COST)
8790 , SUM(fact1.ACT_REVENUE)
8791 , SUM(fact1.ACT_LABOR_RAW_COST)
8792 , SUM(fact1.ACT_EQUIP_RAW_COST)
8793 , SUM(fact1.ETC_LABOR_HRS)
8794 , SUM(fact1.ETC_EQUIP_HRS)
8795 , SUM(fact1.ETC_LABOR_BRDN_COST)
8796 , SUM(fact1.ETC_EQUIP_BRDN_COST)
8797 , SUM(fact1.ETC_BRDN_COST )
8798 , SUM(fact1.ETC_RAW_COST )
8799 , SUM(fact1.ETC_LABOR_RAW_COST)
8800 , SUM(fact1.ETC_EQUIP_RAW_COST)
8801 , SUM(fact1.CUSTOM1 )
8802 , SUM(fact1.CUSTOM2 )
8803 , SUM(fact1.CUSTOM3 )
8804 , SUM(fact1.CUSTOM4 )
8805 , SUM(fact1.CUSTOM5 )
8806 , SUM(fact1.CUSTOM6 )
8807 , SUM(fact1.CUSTOM7 )
8808 , SUM(fact1.CUSTOM8 )
8809 , SUM(fact1.CUSTOM9 )
8810 , SUM(fact1.CUSTOM10 )
8811 , SUM(fact1.CUSTOM11 )
8812 , SUM(fact1.CUSTOM12 )
8813 , SUM(fact1.CUSTOM13 )
8814 , SUM(fact1.CUSTOM14 )
8815 , SUM(fact1.CUSTOM15 )
8816 , fact1.line_type
8817 , g_default_prg_level
8818 , fact1.plan_type_code /* 4471527 */
8819 FROM pji_fp_aggr_pjp1_t fact1
8820 , Pji_RBS_DENORM rbs
8821 , pji_rollup_level_status smart
8822 , pji_pjp_rbs_header rhdr
8823 WHERE 1 = 1
8824 AND fact1.project_id = rhdr.project_id
8825 AND fact1.plan_version_id = rhdr.plan_version_id
8826 AND fact1.plan_type_code = rhdr.plan_type_code /*4471527 */
8827 AND rbs.struct_version_id = rhdr.rbs_version_id
8828 AND fact1.rbs_ELEMENT_ID = rbs.sub_id
8829 AND rbs.sup_level <> rbs.sub_level
8830 AND rbs.sup_level <> 1
8831 AND fact1.RBS_AGGR_LEVEL = g_lowest_level
8832 AND smart.rbs_version_id = rbs.struct_version_id
8833 AND smart.plan_version_id = fact1.plan_version_id
8834 AND smart.plan_type_code = fact1.plan_type_code /*4471527 */
8835 AND fact1.worker_id = g_worker_id
8836 GROUP BY
8837 fact1.PROJECT_ID
8838 , fact1.PROJECT_ORG_ID
8839 , fact1.PROJECT_ORGANIZATION_ID
8840 , fact1.project_element_id
8841 , fact1.TIME_ID
8842 , fact1.PERIOD_TYPE_ID
8843 , fact1.CALENDAR_TYPE
8844 , fact1.WBS_ROLLUP_FLAG
8845 , fact1.PRG_ROLLUP_FLAG
8846 , fact1.CURR_RECORD_TYPE_ID
8847 , fact1.CURRENCY_CODE
8848 , rbs.sup_id
8849 , fact1.RBS_VERSION_ID
8850 , fact1.PLAN_VERSION_ID
8851 , fact1.PLAN_TYPE_ID
8852 , fact1.line_type
8853 , fact1.plan_type_code ;
8854
8855
8856 EXCEPTION
8857 WHEN OTHERS THEN
8858 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8859 p_procedure_name => 'ROLLUP_FPR_RBS');
8860 RAISE;
8861 END;
8862
8863
8864 PROCEDURE ROLLUP_FPR_RBS_T_SLICE IS
8865 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
8866
8867 BEGIN
8868
8869 print_time(' worker id is ... ' || 1);
8870
8871 INSERT INTO pji_fp_aggr_pjp1_t
8872 (
8873 WORKER_ID
8874 , PROJECT_ID
8875 , PROJECT_ORG_ID
8876 , PROJECT_ORGANIZATION_ID
8877 , PROJECT_ELEMENT_ID
8878 , TIME_ID
8879 , PERIOD_TYPE_ID
8880 , CALENDAR_TYPE
8881 , RBS_AGGR_LEVEL
8882 , WBS_ROLLUP_FLAG
8883 , PRG_ROLLUP_FLAG
8884 , CURR_RECORD_TYPE_ID
8885 , CURRENCY_CODE
8886 , RBS_ELEMENT_ID
8887 , RBS_VERSION_ID
8888 , PLAN_VERSION_ID
8889 , PLAN_TYPE_ID
8890 , RAW_COST
8891 , BRDN_COST
8892 , REVENUE
8893 , BILL_RAW_COST
8894 , BILL_BRDN_COST
8895 , BILL_LABOR_RAW_COST
8896 , BILL_LABOR_BRDN_COST
8897 , BILL_LABOR_HRS
8898 , EQUIPMENT_RAW_COST
8899 , EQUIPMENT_BRDN_COST
8900 , CAPITALIZABLE_RAW_COST
8901 , CAPITALIZABLE_BRDN_COST
8902 , LABOR_RAW_COST
8903 , LABOR_BRDN_COST
8904 , LABOR_HRS
8905 , LABOR_REVENUE
8906 , EQUIPMENT_HOURS
8907 , BILLABLE_EQUIPMENT_HOURS
8908 , SUP_INV_COMMITTED_COST
8909 , PO_COMMITTED_COST
8910 , PR_COMMITTED_COST
8911 , OTH_COMMITTED_COST
8912 , ACT_LABOR_HRS
8913 , ACT_EQUIP_HRS
8914 , ACT_LABOR_BRDN_COST
8915 , ACT_EQUIP_BRDN_COST
8916 , ACT_BRDN_COST
8917 , ACT_RAW_COST
8918 , ACT_REVENUE
8919 , ACT_LABOR_RAW_COST
8920 , ACT_EQUIP_RAW_COST
8921 , ETC_LABOR_HRS
8922 , ETC_EQUIP_HRS
8923 , ETC_LABOR_BRDN_COST
8924 , ETC_EQUIP_BRDN_COST
8925 , ETC_BRDN_COST
8926 , ETC_RAW_COST
8927 , ETC_LABOR_RAW_COST
8928 , ETC_EQUIP_RAW_COST
8929 , CUSTOM1
8930 , CUSTOM2
8931 , CUSTOM3
8932 , CUSTOM4
8933 , CUSTOM5
8934 , CUSTOM6
8935 , CUSTOM7
8936 , CUSTOM8
8937 , CUSTOM9
8938 , CUSTOM10
8939 , CUSTOM11
8940 , CUSTOM12
8941 , CUSTOM13
8942 , CUSTOM14
8943 , CUSTOM15
8944 , LINE_TYPE
8945 , PRG_LEVEL
8946 , PLAN_TYPE_CODE /* 4471527 */
8947 )
8948 SELECT
8949 g_worker_id WORKER_ID
8950 , fact1.PROJECT_ID
8951 , fact1.PROJECT_ORG_ID
8952 , fact1.PROJECT_ORGANIZATION_ID
8953 , fact1.project_element_id
8954 , fact1.TIME_ID
8955 , fact1.PERIOD_TYPE_ID
8956 , fact1.CALENDAR_TYPE
8957 , g_top_level
8958 , fact1.WBS_ROLLUP_FLAG
8959 , fact1.PRG_ROLLUP_FLAG
8960 , fact1.CURR_RECORD_TYPE_ID
8961 , fact1.CURRENCY_CODE
8962 , -1
8963 , -1
8964 , fact1.PLAN_VERSION_ID
8965 , fact1.PLAN_TYPE_ID
8966 , SUM(fact1.RAW_COST)
8967 , SUM(fact1.BRDN_COST)
8968 , SUM(fact1.REVENUE)
8969 , SUM(fact1.BILL_RAW_COST)
8970 , SUM(fact1.BILL_BRDN_COST )
8971 , SUM(fact1.BILL_LABOR_RAW_COST)
8972 , SUM(fact1.BILL_LABOR_BRDN_COST )
8973 , SUM(fact1.BILL_LABOR_HRS )
8974 , SUM(fact1.EQUIPMENT_RAW_COST )
8975 , SUM(fact1.EQUIPMENT_BRDN_COST )
8976 , SUM(fact1.CAPITALIZABLE_RAW_COST )
8977 , SUM(fact1.CAPITALIZABLE_BRDN_COST )
8978 , SUM(fact1.LABOR_RAW_COST )
8979 , SUM(fact1.LABOR_BRDN_COST )
8980 , SUM(fact1.LABOR_HRS)
8981 , SUM(fact1.LABOR_REVENUE)
8982 , SUM(fact1.EQUIPMENT_HOURS)
8983 , SUM(fact1.BILLABLE_EQUIPMENT_HOURS)
8984 , SUM(fact1.SUP_INV_COMMITTED_COST)
8985 , SUM(fact1.PO_COMMITTED_COST )
8986 , SUM(fact1.PR_COMMITTED_COST )
8987 , SUM(fact1.OTH_COMMITTED_COST)
8988 , SUM(fact1.ACT_LABOR_HRS)
8989 , SUM(fact1.ACT_EQUIP_HRS)
8990 , SUM(fact1.ACT_LABOR_BRDN_COST)
8991 , SUM(fact1.ACT_EQUIP_BRDN_COST)
8992 , SUM(fact1.ACT_BRDN_COST)
8993 , SUM(fact1.ACT_RAW_COST)
8994 , SUM(fact1.ACT_REVENUE)
8995 , SUM(fact1.ACT_LABOR_RAW_COST)
8996 , SUM(fact1.ACT_EQUIP_RAW_COST)
8997 , SUM(fact1.ETC_LABOR_HRS)
8998 , SUM(fact1.ETC_EQUIP_HRS)
8999 , SUM(fact1.ETC_LABOR_BRDN_COST)
9000 , SUM(fact1.ETC_EQUIP_BRDN_COST)
9001 , SUM(fact1.ETC_BRDN_COST )
9002 , SUM(fact1.ETC_RAW_COST )
9003 , SUM(fact1.ETC_LABOR_RAW_COST)
9004 , SUM(fact1.ETC_EQUIP_RAW_COST)
9005 , SUM(fact1.CUSTOM1 )
9006 , SUM(fact1.CUSTOM2 )
9007 , SUM(fact1.CUSTOM3 )
9008 , SUM(fact1.CUSTOM4 )
9009 , SUM(fact1.CUSTOM5 )
9010 , SUM(fact1.CUSTOM6 )
9011 , SUM(fact1.CUSTOM7 )
9012 , SUM(fact1.CUSTOM8 )
9013 , SUM(fact1.CUSTOM9 )
9014 , SUM(fact1.CUSTOM10 )
9015 , SUM(fact1.CUSTOM11 )
9016 , SUM(fact1.CUSTOM12 )
9017 , SUM(fact1.CUSTOM13 )
9018 , SUM(fact1.CUSTOM14 )
9019 , SUM(fact1.CUSTOM15 )
9020 , fact1.line_type
9021 , g_default_prg_level
9022 , fact1.PLAN_TYPE_CODE /* 4471527 */
9023 FROM pji_fp_aggr_pjp1_t fact1
9024 , pji_fm_extr_plnver3_t ver3
9025 WHERE
9026 fact1.RBS_AGGR_LEVEL = g_lowest_level
9027 AND fact1.worker_id = g_worker_id
9028 AND fact1.plan_version_id = ver3.plan_version_id
9029 AND fact1.plan_type_code = ver3.plan_type_code /*4471527 */
9030 AND ( fact1.rbs_version_id = ver3.rbs_struct_version_id
9031 OR fact1.rbs_version_id = -1)
9032 AND ver3.secondary_rbs_flag = 'N'
9033 GROUP BY
9034 fact1.PROJECT_ID
9035 , fact1.PROJECT_ORG_ID
9036 , fact1.PROJECT_ORGANIZATION_ID
9037 , fact1.project_element_id
9038 , fact1.TIME_ID
9039 , fact1.PERIOD_TYPE_ID
9040 , fact1.CALENDAR_TYPE
9041 , fact1.WBS_ROLLUP_FLAG
9042 , fact1.PRG_ROLLUP_FLAG
9043 , fact1.CURR_RECORD_TYPE_ID
9044 , fact1.CURRENCY_CODE
9045 -- , fact1.RBS_VERSION_ID
9046 , fact1.PLAN_VERSION_ID
9047 , fact1.PLAN_TYPE_ID
9048 , fact1.line_type
9049 , fact1.plan_type_code ; /* 4471527 */
9050
9051
9052 EXCEPTION
9053 WHEN OTHERS THEN
9054 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
9055 p_procedure_name => 'ROLLUP_FPR_RBS_T_SLICE');
9056 RAISE;
9057 END;
9058
9059
9060 PROCEDURE COMPUTE_XBS_UPDATED_ROLLUPS IS
9061 BEGIN
9062 NULL;
9063 EXCEPTION
9064 WHEN OTHERS THEN
9065 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
9066 p_procedure_name => 'COMPUTE_XBS_UPDATED_ROLLUPS');
9067 RAISE;
9068 END;
9069
9070
9071 PROCEDURE POPULATE_RBS_HDR IS
9072
9073 l_last_update_date date := SYSDATE;
9074 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
9075 l_creation_date date := SYSDATE;
9076 l_created_by NUMBER := FND_GLOBAL.USER_ID;
9077 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
9078
9079 BEGIN
9080
9081 print_time ( ' Before update rbs header ' );
9082
9083 INSERT INTO pji_pjp_rbs_header
9084 (
9085 project_id
9086 , plan_version_id
9087 , rbs_version_id
9088 , reporting_usage_flag
9089 , prog_rep_usage_flag
9090 , plan_usage_flag
9091 , LAST_UPDATE_DATE
9092 , LAST_UPDATED_BY
9093 , CREATION_DATE
9094 , CREATED_BY
9095 , LAST_UPDATE_LOGIN
9096 , PLAN_TYPE_CODE /*4471527 */
9097 )
9098 SELECT rpa.project_id
9099 , bv.plan_version_id
9100 , rpa.rbs_version_id
9101 , rpa.reporting_usage_flag
9102 , rpa.prog_rep_usage_flag
9103 , DECODE(bv.wp_flag, 'Y', rpa.wp_usage_flag, rpa.fp_usage_flag)
9104 , l_last_update_date
9105 , l_last_updated_by
9106 , l_creation_date
9107 , l_created_by
9108 , l_last_update_login
9109 , bv.plan_type_code /*4471527 */
9110 FROM pa_rbs_prj_assignments rpa
9111 , PJI_FM_EXTR_PLNVER3_T bv
9112 , pji_pjp_rbs_header head
9113 WHERE bv.project_id = rpa.project_id
9114 AND bv.RBS_STRUCT_VERSION_ID = rpa.RBS_VERSION_ID
9115 AND bv.PROJECT_ID = head.PROJECT_ID (+)
9116 AND bv.PLAN_VERSION_ID = head.PLAN_VERSION_ID (+)
9117 AND bv.plan_type_code = head.plan_type_code (+) /* 4471527 */
9118 AND bv.RBS_STRUCT_VERSION_ID = head.RBS_VERSION_ID (+)
9119 AND head.PROJECT_ID IS NULL
9120 AND bv.plan_version_id > 0;
9121
9122 print_time ( ' After populate rbs header for WPs/FPs. # rows inserted = ' || SQL%ROWCOUNT );
9123
9124 INSERT INTO pji_pjp_rbs_header
9125 (
9126 project_id
9127 , plan_version_id
9128 , rbs_version_id
9129 , reporting_usage_flag
9130 , prog_rep_usage_flag
9131 , plan_usage_flag
9132 , LAST_UPDATE_DATE
9133 , LAST_UPDATED_BY
9134 , CREATION_DATE
9135 , CREATED_BY
9136 , LAST_UPDATE_LOGIN
9137 ,PLAN_TYPE_CODE /* 4471527 */
9138 )
9139 SELECT distinct bv.project_id
9140 , bv.plan_version_id
9141 , bv.rbs_struct_version_id
9142 , 'Y' -- rpa.reporting_usage_flag
9143 , 'Y' -- rpa.prog_rep_usage_flag
9144 , 'N' -- DECODE(bv.wp_flag, 'Y', rpa.wp_usage_flag, rpa.fp_usage_flag)
9145 , l_last_update_date
9146 , l_last_updated_by
9147 , l_creation_date
9148 , l_created_by
9149 , l_last_update_login
9150 , bv.plan_type_code /* 4471527 */
9151 FROM PJI_FM_EXTR_PLNVER3_T bv
9152 , pji_pjp_rbs_header head
9153 WHERE bv.PROJECT_ID = head.PROJECT_ID (+)
9154 AND bv.PLAN_VERSION_ID = head.PLAN_VERSION_ID (+)
9155 AND bv.plan_type_code = head.plan_type_code (+) /* 4471527 */
9156 AND bv.RBS_STRUCT_VERSION_ID = head.RBS_VERSION_ID (+)
9157 AND head.PROJECT_ID IS NULL
9158 AND bv.plan_version_id in (-3, -4)
9159 AND bv.RBS_STRUCT_VERSION_ID is not null; /*4882640*/
9160
9161 print_time ( ' After populate rbs header for -3/-4s. # rows inserted = ' || SQL%ROWCOUNT );
9162
9163 EXCEPTION
9164 WHEN OTHERS THEN
9165 print_time ( ' update rbs header exception ' || sqlerrm );
9166 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
9167 p_procedure_name => 'POPULATE_RBS_HDR');
9168 RAISE;
9169 END;
9170
9171
9172 PROCEDURE POPULATE_WBS_HDR IS
9173
9174 l_last_update_date date := SYSDATE;
9175 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
9176 l_creation_date date := SYSDATE;
9177 l_created_by NUMBER := FND_GLOBAL.USER_ID;
9178 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
9179
9180 BEGIN
9181
9182 print_time ( ' Before populate wbs header ' );
9183
9184 INSERT INTO PJI_PJP_WBS_HEADER
9185 (
9186 PROJECT_ID
9187 , PLAN_VERSION_ID
9188 , WBS_VERSION_ID
9189 , WP_FLAG
9190 , CB_FLAG
9191 , CO_FLAG
9192 , LOCK_FLAG
9193 , PLAN_TYPE_ID
9194 , MIN_TXN_DATE
9195 , MAX_TXN_DATE
9196 , PLAN_TYPE_CODE /* 4471527 */
9197 , LAST_UPDATE_DATE
9198 , LAST_UPDATED_BY
9199 , CREATION_DATE
9200 , CREATED_BY
9201 , LAST_UPDATE_LOGIN
9202 )
9203 SELECT DISTINCT
9204 ver.project_id
9205 , ver.plan_version_id
9206 , ver.wbs_struct_version_id
9207 , ver.wp_flag
9208 , DECODE( (ver.current_flag || ver.baselined_flag) , 'YY', 'Y', 'N')
9209 , ver.current_original_flag
9210 , null
9211 , ver.plan_type_id
9212 , to_date('3000/01/01', 'YYYY/MM/DD') MIN_TXN_DATE
9213 , to_date('0001/01/01', 'YYYY/MM/DD') MAX_TXN_DATE
9214 , ver.plan_type_code /* 4471527 */
9215 , l_last_update_date
9216 , l_last_updated_by
9217 , l_creation_date
9218 , l_created_by
9219 , l_last_update_login
9220 FROM PJI_FM_EXTR_PLNVER3_T ver
9221 , PJI_PJP_WBS_HEADER whdr
9222 WHERE ver.plan_version_id = whdr.plan_version_id (+)
9223 AND ver.project_id = whdr.project_id (+)
9224 -- AND ver.wbs_struct_version_id = whdr.wbs_version_id (+)
9225 AND ver.plan_type_id = whdr.plan_type_id (+)
9226 AND ver.plan_type_code = whdr.plan_type_code (+) /* 4471527 */
9227 AND whdr.plan_version_id IS NULL
9228 ORDER BY
9229 ver.project_id
9230 , ver.plan_version_id;
9231
9232 print_time ( ' After populate wbs header. # rows inserted = ' || SQL%ROWCOUNT );
9233
9234 EXCEPTION
9235 WHEN OTHERS THEN
9236 print_time ( ' populate wbs header exception ' || sqlerrm );
9237 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
9238 p_procedure_name => 'POPULATE_WBS_HDR');
9239 RAISE;
9240 END;
9241
9242
9243 PROCEDURE UPDATE_WBS_HDR IS
9244
9245 l_last_update_date date := SYSDATE;
9246 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
9247 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
9248
9249 BEGIN
9250
9251 print_time ( ' Before update wbs header ' );
9252
9253 UPDATE /*+ index(whdr,PJI_PJP_WBS_HEADER_N1) */
9254 PJI_PJP_WBS_HEADER whdr
9255 SET ( MIN_TXN_DATE
9256 , MAX_TXN_DATE
9257 , LAST_UPDATE_DATE
9258 , LAST_UPDATED_BY
9259 , LAST_UPDATE_LOGIN
9260 ) = (
9261 SELECT MIN(LEAST(cal.start_date, NVL(whdr.min_txn_date, cal.start_date))) start_date
9262 , MAX(GREATEST(cal.end_date, NVL(whdr.max_txn_date, cal.end_date))) end_date
9263 , l_last_update_date
9264 , l_last_updated_by
9265 , l_last_update_login
9266 FROM PJI_FP_AGGR_PJP1_T pjp1
9267 , pji_time_cal_period_v cal
9268 WHERE
9269 pjp1.worker_id = g_worker_id
9270 AND pjp1.plan_version_id = whdr.plan_version_id
9271 AND pjp1.project_id = whdr.project_id
9272 AND pjp1.plan_type_id = whdr.plan_type_id
9273 AND pjp1.time_id = cal.cal_period_id
9274 AND pjp1.calendar_type IN ('P', 'G') -- Non time ph and ent cals don't need to be considered.
9275 )
9276 /*
9277 WHERE (project_id, plan_version_id) IN
9278 (
9279 SELECT DISTINCT project_id, plan_version_id
9280 FROM pji_fp_aggr_pjp1_t
9281 );
9282 For bug 7192035 */
9283
9284 WHERE exists (select 1 from pji_fp_aggr_pjp1_t ver where worker_id = g_worker_id
9285 and ver.project_id = whdr.project_id
9286 and ver.plan_version_id = whdr.plan_version_id
9287 and ver.plan_type_id = whdr.plan_type_id);
9288
9289 print_time ( ' After update wbs header. # rows updated = ' || SQL%ROWCOUNT );
9290
9291 EXCEPTION
9292 WHEN OTHERS THEN
9293 print_time ( ' update wbs header exception ' || sqlerrm );
9294 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
9295 p_procedure_name => 'POPULATE_WBS_HDR');
9296 RAISE;
9297 END;
9298
9299
9300
9301 PROCEDURE MARK_TIME_DANGLING_VERSIONS IS
9302 BEGIN
9303
9304 UPDATE PJI_FM_EXTR_PLNVER3_T
9305 SET TIME_DANGLING_FLAG = 'Y'
9306 WHERE plan_version_id IN
9307 (SELECT fact.plan_version_id
9308 FROM pji_fp_aggr_pjp1_t fact
9309 , pji_time_cal_period_v time
9310 , pji_org_extr_info orginfo
9311 WHERE fact.period_type_id = 32
9312 AND fact.worker_id = g_worker_id
9313 AND fact.calendar_type = 'P'
9314 AND fact.time_id = time.cal_period_id
9315 AND orginfo.org_id = fact.project_org_id
9316 AND TO_NUMBER(TO_CHAR(time.end_date, 'J')) > gl_calendar_max_date);
9317
9318 UPDATE PJI_FM_EXTR_PLNVER3_T
9319 SET TIME_DANGLING_FLAG = 'Y'
9320 WHERE plan_version_id IN
9321 (SELECT fact.plan_version_id
9322 FROM pji_fp_aggr_pjp1_t fact
9323 , pji_time_cal_period_v time
9324 , pji_org_extr_info orginfo
9325 WHERE fact.period_type_id = 32
9326 AND fact.worker_id = g_worker_id
9327 AND fact.calendar_type = 'G'
9328 AND fact.time_id = time.cal_period_id
9329 AND orginfo.org_id = fact.project_org_id
9330 AND TO_NUMBER(TO_CHAR(time.end_date, 'J')) > pa_calendar_max_date);
9331
9332 EXCEPTION
9333 WHEN OTHERS THEN
9334 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
9335 p_procedure_name => 'MARK_TIME_DANGLING_VERSIONS');
9336 RAISE;
9337 END;
9338
9339
9340 PROCEDURE MARK_EXTRACTED_PLANS(p_slice_type IN VARCHAR2) IS
9341 l_dangling_flag VARCHAR2(1);
9342 l_plan_version_id NUMBER;
9343
9344 CURSOR PLANS_TO_MARK
9345 IS SELECT DISTINCT project_id,plan_version_id
9346 FROM pji_fm_extr_plnver3_t;
9347
9348 l_plans_to_mark PLANS_TO_MARK%ROWTYPE;
9349
9350 BEGIN
9351
9352 --
9353 -- On PA_BUDGET_VERSIONS, the PJI_SUMMARIZED_FLAG can have four values:
9354 -- 'N' the plan version has not been summarized
9355 -- 'P' the plan version has been partially summarized due to dangling currency or calendar records
9356 -- 'Y' the plan version has been fully summarized in Project Performance and
9357 -- NULL the plan version has been fully summarized in both PJI and Project Performance.
9358 --
9359 -- Note that, in PJI data extraction, data that existed before PJI was installed
9360 -- has PJI_SUMMARIZED_FLAG = null and new transactions are inserted with value 'N'.
9361 -- A similar situation does not occur in PA_BUDGET_VERSIONS. During the upgrade process
9362 -- will pull necessary data from PA_BUDGET_VERSIONS and set PJI_SUMMARIZATION_FLAG to 'P', 'N'
9363 -- or 'Y' accordingly. New versions will be inserted with value 'N'.)
9364 --
9365
9366 IF (p_slice_type = 'PRI') THEN
9367 /* Added index for bug 3818232 */
9368 UPDATE /*+ INDEX( pa_budget_versions PA_BUDGET_VERSIONS_U1)*/
9369 pa_budget_versions
9370 SET pji_summarized_flag =
9371 DECODE(wp_version_flag
9372 , 'Y', 'Y'
9373 , DECODE(budget_status_code
9374 , 'B', 'P'
9375 , 'Y')
9376 ),
9377 record_version_number=nvl(record_version_number,0)+1
9378 WHERE budget_version_id IN
9379 ( SELECT DISTINCT plan_version_id
9380 FROM pji_fm_extr_plnver3_t );
9381
9382 ELSE -- Secondary slice.
9383 FOR l_plans_to_mark IN PLANS_TO_MARK LOOP
9384 DECLARE
9385 BEGIN
9386 SELECT 'Y'
9387 INTO l_dangling_flag
9388 FROM DUAL
9389 WHERE EXISTS(
9390 SELECT 1
9391 FROM pji_fp_aggr_pjp1_t
9392 WHERE ( time_dangling_flag IS NOT NULL
9393 OR rate_dangling_flag IS NOT NULL )
9394 AND worker_id=g_worker_id
9395 AND project_id=l_plans_to_mark.project_id
9396 AND plan_version_id=l_plans_to_mark.plan_version_id
9397 UNION ALL
9398 SELECT 1
9399 FROM PJI_FM_EXTR_PLNVER3_T
9400 WHERE time_dangling_flag IS NOT NULL
9401 AND project_id=l_plans_to_mark.project_id
9402 AND plan_version_id=l_plans_to_mark.plan_version_id
9403 );
9404 EXCEPTION
9405 WHEN NO_DATA_FOUND THEN
9406 l_dangling_flag :='N';
9407 END;
9408
9409
9410
9411 UPDATE pa_budget_versions
9412 SET pji_summarized_flag = decode(l_dangling_flag,'Y','P','Y'),
9413 record_version_number=nvl(record_version_number,0)+1
9414 WHERE budget_version_id IN
9415 (
9416 SELECT plan_version_id
9417 FROM PJI_FM_EXTR_PLNVER3_T
9418 );
9419
9420 END LOOP;
9421 -- Added INDEX for bug 3828698
9422
9423 /* UPDATE pa_budget_versions
9424 SET pji_summarized_flag = 'Y',
9425 record_version_number=nvl(record_version_number,0)+1
9426 WHERE budget_version_id IN
9427 (
9428 SELECT DISTINCT plan_version_id
9429 FROM pji_fp_aggr_pjp1_t
9430 WHERE worker_id = g_worker_id
9431 )
9432 AND budget_version_id NOT IN
9433 (
9434 SELECT DISTINCT plan_version_id
9435 FROM pji_fp_aggr_pjp1_t
9436 WHERE worker_id = g_worker_id
9437 AND (time_dangling_flag IS NOT NULL
9438 OR rate_dangling_flag IS NOT NULL )
9439 )
9440 AND budget_version_id NOT IN
9441 ( SELECT distinct plan_version_id
9442 FROM PJI_FM_EXTR_PLNVER3_T
9443 WHERE time_dangling_flag IS NOT NULL
9444 );
9445
9446 UPDATE pa_budget_versions
9447 SET pji_summarized_flag = 'P',
9448 record_version_number=nvl(record_version_number,0)+1
9449 WHERE budget_version_id IN
9450 (
9451 SELECT DISTINCT plan_version_id
9452 FROM pji_fp_aggr_pjp1_t
9453 WHERE worker_id = g_worker_id
9454 AND (time_dangling_flag IS NOT NULL
9455 OR rate_dangling_flag IS NOT NULL )
9456 )
9457 OR budget_version_id in
9458 ( SELECT distinct plan_version_id
9459 FROM PJI_FM_EXTR_PLNVER3_T
9460 WHERE time_dangling_flag IS NOT NULL
9461 ); */
9462
9463 END IF;
9464
9465 EXCEPTION
9466 WHEN OTHERS THEN
9467 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
9468 p_procedure_name => 'MARK_EXTRACTED_PLANS');
9469 RAISE;
9470 END;
9471
9472
9473
9474 ------------------------------------------------------------------------------
9475 ---- WBS rollup api..
9476 ------------------------------------------------------------------------------
9477
9478 PROCEDURE CREATE_WBSRLP IS
9479 BEGIN
9480
9481 print_time('... Begin CREATE_WBSRLP ' );
9482
9483 PRINT_NUM_WBSRLPRCDS_INPJP1;
9484
9485 print_time('... Before call to rollup_fpr_wbs...' );
9486
9487 PJI_PJP_SUM_ROLLUP.ROLLUP_FPR_WBS;
9488
9489 print_time('... after call to rollup_fpr_wbs. ' );
9490
9491 PRINT_NUM_WBSRLPRCDS_INPJP1;
9492
9493 print_time('... End CREATE_WBSRLP ' );
9494
9495 EXCEPTION
9496 WHEN OTHERS THEN
9497 print_time('... Exception CREATE_WBSRLP ' );
9498 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
9499 p_procedure_name => 'CREATE_WBSRLP');
9500 RAISE;
9501 END;
9502
9503
9504
9505 PROCEDURE PRINT_NUM_WBSRLPRCDS_INPJP1 IS
9506 l_count NUMBER;
9507 l_wbs_rollup_flag VARCHAR2(1);
9508 l_prg_rollup_flag VARCHAR2(1);
9509 l_return_status VARCHAR2(1);
9510
9511 BEGIN
9512
9513 l_wbs_rollup_flag := 'N';
9514 l_prg_rollup_flag := 'N';
9515
9516 /*
9517 select count(1)
9518 INTO l_count
9519 FROM pji_fp_aggr_pjp1_t
9520 WHERE wbs_rollup_flag = l_wbs_rollup_flag
9521 AND prg_rollup_flag = l_prg_rollup_flag;
9522
9523 print_time ( ' l_worker_id = '|| g_worker_id || ' wbs rollup flag = ' || l_wbs_rollup_flag || ' prg rollup flag = ' || l_prg_rollup_flag || ' l_count ' || l_count);
9524
9525
9526 l_wbs_rollup_flag := 'N';
9527 l_prg_rollup_flag := 'Y';
9528
9529 select count(1)
9530 INTO l_count
9531 FROM pji_fp_aggr_pjp1_t
9532 WHERE wbs_rollup_flag = l_wbs_rollup_flag
9533 AND prg_rollup_flag = l_prg_rollup_flag;
9534
9535 print_time ( ' l_worker_id = '|| g_worker_id || ' wbs rollup flag = ' || l_wbs_rollup_flag || ' prg rollup flag = ' || l_prg_rollup_flag || ' l_count ' || l_count);
9536
9537
9538 l_wbs_rollup_flag := 'Y';
9539 l_prg_rollup_flag := 'N';
9540
9541 select count(1)
9542 INTO l_count
9543 FROM pji_fp_aggr_pjp1_t
9544 WHERE wbs_rollup_flag = l_wbs_rollup_flag
9545 AND prg_rollup_flag = l_prg_rollup_flag;
9546
9547 print_time ( ' l_worker_id = '|| g_worker_id || ' wbs rollup flag = ' || l_wbs_rollup_flag || ' prg rollup flag = ' || l_prg_rollup_flag || ' l_count ' || l_count);
9548
9549
9550 l_wbs_rollup_flag := 'Y';
9551 l_prg_rollup_flag := 'Y';
9552
9553 select count(1)
9554 INTO l_count
9555 FROM pji_fp_aggr_pjp1_t
9556 WHERE wbs_rollup_flag = l_wbs_rollup_flag
9557 AND prg_rollup_flag = l_prg_rollup_flag;
9558
9559 print_time ( ' l_worker_id = '|| g_worker_id || ' wbs rollup flag = ' || l_wbs_rollup_flag || ' prg rollup flag = ' || l_prg_rollup_flag || ' l_count ' || l_count);
9560 */
9561
9562 EXCEPTION
9563 WHEN OTHERS THEN
9564 PJI_PJP_FP_CURR_WRAP.EXCP_HANDLER
9565 ( p_package_name => g_package_name
9566 , p_procedure_name => 'PRINT_NUM_WBSRLPRCDS_INPJP1'
9567 , x_return_status => l_return_status ) ;
9568
9569 RAISE;
9570 END;
9571
9572
9573 PROCEDURE CLEANUP_INTERIM_TABLES IS
9574 l_count NUMBER;
9575 BEGIN
9576
9577 print_time('.......CLEANUP_INTERIM_TABLES: Begin. ');
9578
9579 DELETE FROM PJI_FM_EXTR_PLNVER3_T ; -- No worker id join needed for online case.
9580
9581 print_time('.......ver3 rows deleted: #= ' || sql%rowcount);
9582
9583 DELETE FROM pji_fp_aggr_pjp1_t ; -- No worker id join needed for online case.
9584
9585 print_time('.......pjp1 rows deleted: #= ' || sql%rowcount);
9586
9587 print_time('.......CLEANUP_INTERIM_TABLES: End. ');
9588
9589 EXCEPTION
9590 WHEN OTHERS THEN
9591 print_time('.......CLEANUP_INTERIM_TABLES: Exception. ' || sqlerrm);
9592 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
9593 p_procedure_name => 'CLEANUP_INTERIM_TABLES');
9594 RAISE;
9595 END CLEANUP_INTERIM_TABLES;
9596
9597
9598 PROCEDURE SET_WORKER_ID(p_worker_id IN NUMBER := NULL) IS
9599 l_return_status VARCHAR2(1);
9600 BEGIN
9601 IF (p_worker_id IS NOT NULL) THEN
9602 g_worker_id := p_worker_id;
9603 ELSE
9604 g_worker_id := 1; -- PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
9605 END IF;
9606 EXCEPTION
9607 WHEN OTHERS THEN
9608 PJI_PJP_FP_CURR_WRAP.EXCP_HANDLER
9609 ( p_package_name => g_package_name
9610 , p_procedure_name => 'SET_WORKER_ID'
9611 , x_return_status => l_return_status ) ;
9612
9613 RAISE;
9614 END;
9615
9616
9617
9618 --
9619 -- Temp fix until time table will have a record for non time phasing.
9620 --
9621 PROCEDURE INSERT_NTP_CAL_RECORD ( x_max_plnver_id OUT NOCOPY NUMBER ) IS
9622 l_last_update_date date := SYSDATE;
9623 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
9624 l_creation_date date := SYSDATE;
9625 l_created_by NUMBER := FND_GLOBAL.USER_ID;
9626 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
9627
9628 l_start_end_date DATE := TRUNC(SYSDATE);
9629
9630 BEGIN
9631
9632 BEGIN
9633
9634 SELECT MAX(plan_version_id)
9635 INTO x_max_plnver_id
9636 FROM pji_fm_extr_plnver3_t;
9637
9638 EXCEPTION
9639 WHEN NO_DATA_FOUND THEN
9640 RETURN;
9641 END;
9642
9643 IF (x_max_plnver_id IS NULL) THEN
9644 RETURN;
9645 END IF;
9646
9647 print_time (' Inside INSERT_NTP_CAL_RECORD, max project_id is: ' || x_max_plnver_id);
9648
9649 INSERT INTO pji_time_cal_period
9650 (
9651 CAL_PERIOD_ID,
9652 CAL_QTR_ID,
9653 CALENDAR_ID,
9654 SEQUENCE,
9655 NAME ,
9656 START_DATE,
9657 END_DATE,
9658 CREATION_DATE,
9659 LAST_UPDATE_DATE,
9660 LAST_UPDATED_BY,
9661 CREATED_BY,
9662 LAST_UPDATE_LOGIN
9663 )
9664 SELECT -x_max_plnver_id cal_period_id
9665 , -x_max_plnver_id cal_qtr_id
9666 , -x_max_plnver_id calendar_id
9667 , -x_max_plnver_id SEQUENCE
9668 , g_ntp_period_name name
9669 , l_start_end_date start_date
9670 , l_start_end_date end_date
9671 , l_creation_date creation_date
9672 , l_last_update_date last_update_date
9673 , l_last_updated_by last_updated_by
9674 , l_created_by created_by
9675 , l_last_update_login last_update_login
9676 FROM DUAL;
9677
9678 print_time (' INSERT_NTP_CAL_RECORD, # rows inserted is: ' || SQL%ROWCOUNT );
9679
9680 EXCEPTION
9681 WHEN OTHERS THEN
9682 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
9683 p_procedure_name => 'INSERT_NTP_CAL_RECORD');
9684 RAISE;
9685 END;
9686
9687
9688 PROCEDURE DELETE_NTP_CAL_RECORD ( p_max_plnver_id IN NUMBER ) IS
9689 BEGIN
9690
9691 print_time (' DELETE_NTP_CAL_RECORD, max project_id is: ' || p_max_plnver_id);
9692
9693 DELETE FROM pji_time_cal_period
9694 WHERE cal_period_id = -p_max_plnver_id;
9695
9696 print_time (' DELETE_NTP_CAL_RECORD, # rows deleted is: ' || SQL%ROWCOUNT );
9697
9698 EXCEPTION
9699 WHEN OTHERS THEN
9700 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
9701 p_procedure_name => 'DELETE_NTP_CAL_RECORD');
9702 RAISE;
9703 END;
9704
9705
9706 --
9707 -- MAP_ORG_CAL_INFO
9708 -- 1. Populates/updates the org extr info table with any calendar and org information
9709 -- that has changed from the last time this table was updated.
9710 -- 2. Populates pa/gl/ent calendar period tables with newly opened periods.
9711 --
9712 PROCEDURE MAP_ORG_CAL_INFO (
9713 p_fpm_upgrade IN VARCHAR2 := 'Y'
9714 ) IS
9715
9716 l_return_status VARCHAR2(1) := NULL;
9717 l_msg_count NUMBER := NULL;
9718 l_msg_data VARCHAR2(300) := NULL;
9719
9720 CURSOR c_cal_attributes_cur IS
9721 SELECT DISTINCT
9722 DECODE(split_cal.cal_type
9723 , 1
9724 , sob.period_set_name -- gl cal period set name.
9725 , 2
9726 , imp.period_set_name -- pa
9727 ) period_set_name
9728 , DECODE(split_cal.cal_type
9729 , 1
9730 , sob.accounted_period_type -- gl
9731 , 2
9732 , imp.pa_period_type -- pa
9733 ) period_type
9734 FROM pa_implementations_all imp
9735 , gl_sets_of_books sob
9736 , pa_projects_all proj
9737 , pji_fm_extr_plnver3_t ver
9738 , ( SELECT 1 cal_type FROM DUAL -- 1 GL, 2 PA.
9739 UNION ALL
9740 SELECT 2 FROM DUAL
9741 ) split_cal
9742 WHERE 1=1
9743 AND proj.org_id=imp.org_id
9744 AND ver.project_id = proj.project_id
9745 AND imp.set_of_books_id = sob.set_of_books_id;
9746
9747 BEGIN
9748
9749 print_time('MAP_ORG_CAL_INFO : begin calendar table updates.. ');
9750
9751 IF (p_fpm_upgrade = 'Y') THEN
9752
9753 NULL;
9754
9755 ELSIF (p_fpm_upgrade = 'N') THEN
9756
9757 FOR i IN c_cal_attributes_cur LOOP
9758
9759 print_time( ' i.period_set_name = ' || i.period_set_name );
9760 print_time( ' i.period_type = ' || i.period_type);
9761
9762 PJI_TIME_C.LOAD(
9763 p_period_set_name => i.period_set_name
9764 , p_period_type => i.period_type
9765 , x_return_status => l_return_status
9766 , x_msg_count => l_msg_count
9767 , x_msg_data => l_msg_data );
9768
9769 print_time( ' l_return_status = ' || l_return_status );
9770
9771 END LOOP;
9772
9773 END IF;
9774
9775 print_time(' Finished calendar table updates.. ');
9776
9777 IF (p_fpm_upgrade = 'Y') THEN
9778 PJI_PJP_EXTRACTION_UTILS.POPULATE_ORG_EXTR_INFO;
9779 ELSIF (p_fpm_upgrade = 'N') THEN
9780 PJI_PJP_EXTRACTION_UTILS.UPDATE_ORG_EXTR_INFO;
9781 END IF;
9782
9783 print_time(' Finished updating org extr info table. ');
9784 print_time(' MAP_ORG_CAL_INFO : end.. ');
9785
9786 EXCEPTION
9787 WHEN OTHERS THEN
9788 print_time('MAP_ORG_CAL_INFO : exception.. ');
9789 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
9790 p_procedure_name => 'MAP_ORG_CAL_INFO');
9791 RAISE;
9792 END;
9793
9794
9795 ----------
9796 -- Print time API to measure time taken by each api. Also useful for debugging.
9797 ----------
9798 PROCEDURE PRINT_TIME(p_tag IN VARCHAR2) IS
9799 BEGIN
9800 PJI_PJP_FP_CURR_WRAP.print_time(p_tag);
9801 EXCEPTION
9802 WHEN OTHERS THEN
9803 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
9804 p_procedure_name => 'PRINT_TIME');
9805 RAISE;
9806 END;
9807
9808
9809 BEGIN -- this portion is executed WHENever the package is initialized
9810
9811 g_worker_id := 1; -- PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
9812
9813
9814 END PJI_FM_PLAN_MAINT_T_PVT;