[Home] [Help]
PACKAGE BODY: APPS.PJI_FM_PLAN_MAINT_PVT
Source
1 PACKAGE BODY PJI_FM_PLAN_MAINT_PVT AS
2 /* $Header: PJIPP02B.pls 120.86.12020000.6 2013/04/18 12:38:04 udshanmu ship $ */
3
4
5 g_package_name VARCHAR2(100) := 'PJI_FM_PLAN_MAINT_PVT';
6
7 g_prorating_format VARCHAR2(30) := 'S';
8 -- S Start date, E End date, D (daily) Period.
9 -- Based on plan version.
10
11 g_currency_conversion_rule VARCHAR2(30) := 'S';
12 -- S Start date, E End date.
13 -- Based on plan version.
14
15 g_global_curr_1_enabled VARCHAR2(30) := 'T';
16 g_global_curr_2_enabled VARCHAR2(30) := 'T';
17
18 g_global1_currency_code VARCHAR2(30) := 'USD';
19 g_global2_currency_code VARCHAR2(30) := 'CAD';
20
21 g_global1_currency_mau NUMBER;
22 g_global2_currency_mau NUMBER;
23
24 g_labor_mau NUMBER := 0.01;
25
26 g_ent_start_period_id NUMBER := NULL;
27 g_ent_start_period_name VARCHAR2(100) := NULL;
28 g_ent_start_date date := NULL;
29 g_ent_END_date date := NULL;
30 g_global_start_date date := NULL;
31
32 g_global_start_J NUMBER := NULL;
33 g_ent_start_J NUMBER := NULL;
34 g_ent_END_J NUMBER := NULL;
35
36 g_worker_id NUMBER := 1; -- NULL;
37 g_default_prg_level NUMBER := 0;
38
39 g_people_resclass_code VARCHAR2(20) := 'PEOPLE';
40 g_equip_resclass_code VARCHAR2(20) := 'EQUIPMENT';
41
42 g_yes VARCHAR2(1) := 'Y';
43 g_no VARCHAR2(1) := 'N'; -- Same as g_nontimeph_str.
44 g_pa_cal_str VARCHAR2(1) := 'P';
45 g_gl_cal_str VARCHAR2(1) := 'G';
46 -- 'N'ntimeph_str VARCHAR2(1) := 'N';
47 g_ent_cal_str VARCHAR2(1) := 'E';
48 g_all VARCHAR2(1) := 'A';
49 g_start_str VARCHAR2(1) := 'S';
50 g_end_str VARCHAR2(1) := 'E';
51 g_lowest_level VARCHAR2(1) := 'L';
52 g_top_level VARCHAR2(1) := 'T';
53 g_rolled_up VARCHAR2(1) := 'R';
54
55 g_ntp_period_name VARCHAR2(10) := 'XXX';
56
57 -- g_full VARCHAR2(4) := 'FULL';
58 -- g_incr VARCHAR2(4) := 'INCREMENTAL';
59 g_cb_plans constant NUMBER := 2;
60 g_co_plans constant NUMBER := 4;
61 g_lp_plans constant NUMBER := 8;
62 g_wk_plans constant NUMBER := 16;
63 g_latest_plans constant NUMBER := 30;
64 g_all_plans constant NUMBER := 62;
65
66
67 -- cbs change
68 type varchar2_tbl is table of varchar2(1) index by binary_integer;
69 g_plan_ver_id_res_class_tbl varchar2_tbl;
70
71 -- End cbs change
72 P_PA_DEBUG_MODE varchar2(1) := NVL(FND_PROFILE.value('PA_DEBUG_MODE'), 'N');
73 g_module_name VARCHAR2(100) := 'pji.plsql.PJI_FM_PLAN_MAINT_PVT';
74
75
76 -- 'P' VARCHAR2(15) := 'P';
77 -- 'G' VARCHAR2(15) := 'G';
78 -- 'N' VARCHAR2(15) := 'N';
79 -- 'R' VARCHAR2(15) := 'R';
80 -- 'X' VARCHAR2(15) := 'X';
81
82
83 ------------------------------------------------------------------
84 ------------------------------------------------------------------
85 -- Helper Apis Specification --
86 ------------------------------------------------------------------
87 ------------------------------------------------------------------
88
89 PROCEDURE PRINT_TIME (p_tag IN VARCHAR2);
90
91 PROCEDURE PRINT_NUM_WBSRLPRCDS_INPJP1;
92
93 PROCEDURE INSERT_NTP_CAL_RECORD ( x_max_project_id OUT NOCOPY NUMBER );
94
95 PROCEDURE DELETE_NTP_CAL_RECORD ( p_max_project_id IN NUMBER );
96
97 PROCEDURE UPDATE_LOCKS (
98 p_context IN VARCHAR2
99 , p_update_mode IN VARCHAR2
100 , x_return_status OUT NOCOPY VARCHAR2
101 , x_msg_code OUT NOCOPY VARCHAR2 );
102
103 --
104 -- Populate ver3 for summarization programs.
105 --
106 --
107 -- cbs change
108 PROCEDURE SET_RES_CLASS_FLAG IS
109
110 CURSOR plan_ver_cur
111 IS
112 select plan_version_id ver_id
113 from PJI_FM_EXTR_PLNVER4
114 where worker_id = g_worker_id
115 UNION
116 select plan_version_id ver_id
117 from PJI_FM_EXTR_PLNVER3_T;
118
119
120 TYPE num_tbl IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
121 l_tmp_plan_version_id num_tbl;
122 l_resource_list_id_tbl num_tbl;
123
124 CURSOR res_list IS
125 SELECT /*+ ordered */ b.plan_version_id
126 FROM PJI_FM_EXTR_PLNVER4 b, pa_proj_fp_options a, pa_resource_lists_all_bg c
127 WHERE b.project_id = a.project_id
128 AND b.PLAN_TYPE_ID = a.FIN_PLAN_TYPE_ID
129 AND b.plan_version_id = a.fin_plan_version_id
130 and decode(b.plan_type_code, 'C', a.cost_resource_list_id, 'R', a.revenue_resource_list_id, 'A', a.all_resource_list_id) = c.resource_list_id
131 and nvl(resource_class_flag,'Y') = 'N'
132 UNION
133 SELECT /*+ ordered */ b.plan_version_id
134 FROM PJI_FM_EXTR_PLNVER3_T b, pa_proj_fp_options a, pa_resource_lists_all_bg c
135 WHERE b.project_id = a.project_id
136 AND b.PLAN_TYPE_ID = a.FIN_PLAN_TYPE_ID
137 AND b.plan_version_id = a.fin_plan_version_id
138 and decode(b.plan_type_code, 'C', a.cost_resource_list_id, 'R', a.revenue_resource_list_id, 'A', a.all_resource_list_id) = c.resource_list_id
139 and nvl(resource_class_flag,'Y') = 'N' ;
140
141 BEGIN
142
143 g_plan_ver_id_res_class_tbl.DELETE;
144
145 l_tmp_plan_version_id.delete;
146
147 FOR plan_rec in plan_ver_cur
148 LOOP
149 g_plan_ver_id_res_class_tbl(plan_rec.ver_id) := 'Y' ;
150
151 END LOOP;
152
153 IF P_PA_DEBUG_MODE = 'Y' THEN
154 pa_debug.write('SET_RES_CLASS_FLAG: ' || g_module_name,'Initialized g_plan_ver_id_res_class_tbl to Y',1);
155 END IF;
156
157 OPEN res_list;
158 FETCH res_list BULK COLLECT INTO l_tmp_plan_version_id;
159 CLOSE res_list;
160
161 IF P_PA_DEBUG_MODE = 'Y' THEN
162 pa_debug.write('SET_RES_CLASS_FLAG: ' || g_module_name,'g_plan_ver_id_res_class_tbl.count '||to_char(g_plan_ver_id_res_class_tbl.count), 1);
163 pa_debug.write('SET_RES_CLASS_FLAG: ' || g_module_name,'l_tmp_plan_version_id.count '||to_char(l_tmp_plan_version_id.count), 1);
164 END IF;
165
166 if ( l_tmp_plan_version_id.count <> 0 ) then
167 FOR i IN l_tmp_plan_version_id.FIRST..l_tmp_plan_version_id.LAST LOOP
168 g_plan_ver_id_res_class_tbl(l_tmp_plan_version_id(i)) := 'N';
169
170 end loop;
171 PJI_FM_PLAN_MAINT_PVT.g_res_class_flag := 'N';
172 else
173 PJI_FM_PLAN_MAINT_PVT.g_res_class_flag := 'Y';
174 end if;
175
176 IF P_PA_DEBUG_MODE = 'Y' THEN
177 pa_debug.write('SET_RES_CLASS_FLAG: ' || g_module_name,'g_res_class_flag '||PJI_FM_PLAN_MAINT_PVT.g_res_class_flag ,1);
178 END IF;
179 END;
180
181 function GET_RES_CLASS_FLAG
182 (
183 p_budget_version_id in NUMBER
184 ) return VARCHAR2 is
185
186 begin
187
188 return g_plan_ver_id_res_class_tbl(p_budget_version_id);
189
190 end;
191
192 -- End cbs change
193
194 PROCEDURE VALIDATE_SET_PR_PARAMS(
195 p_rbs_version_id IN NUMBER
196 , p_plan_type_id IN NUMBER
197 , p_context IN VARCHAR2 -- Valid values are 'RBS' or 'PLANTYPE'.
198 , x_num_rows OUT NOCOPY NUMBER
199 , x_return_status OUT NOCOPY VARCHAR2
200 , x_msg_code OUT NOCOPY VARCHAR2 ) IS
201
202 l_plan_type_id NUMBER := NULL;
203 l_rbs_version_id NUMBER := NULL;
204 l_rbs_header_id NUMBER := NULL; --Added for bug#5728852
205 -- l_count NUMBER;
206 l_return_status VARCHAR2(1) := NULL;
207 l_fp_version_ids SYSTEM.pa_num_tbl_type := pji_empty_num_tbl ;
208 l_msg_code VARCHAR2(10) := NULL;
209 l_refresh_code NUMBER; -- Bug#5099574
210 l_process varchar2(30); -- Bug#5099574
211
212 l_actual_ver NUMBER := -1;
213 l_cb_ver NUMBER := -3;
214 l_co_ver NUMBER := -4;
215 l_num_rows NUMBER :=0;
216 l_workplan_type_id number;
217
218 BEGIN
219
220 print_time('VALIDATE_SET_PR_PARAMS : Begin.. ');
221
222 PJI_PJP_FP_CURR_WRAP.INIT_ERR_STACK
223 ( p_package_name => g_package_name
224 , x_return_status => x_return_status );
225
226 x_num_rows := 0;
227
228 g_worker_id := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
229 print_time ( ' Worker id is.. ' || g_worker_id );
230
231 print_time(' VALIDATE_SET_PR_PARAMS : plan type id is ' || p_plan_type_id );
232 print_time(' p_context is ' || p_context || ' and rbs ver id is ' || p_rbs_version_id );
233
234 IF (p_context NOT IN ('RBS' , 'PLANTYPE', 'INCREMENTAL', 'FULL')) THEN
235 print_time(' Invalid p_context.. exitting. ' );
236 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
237 RETURN;
238 END IF;
239
240 /* Added for bug#5728852 - START */
241 l_process := PJI_PJP_SUM_MAIN.g_process || to_char(g_worker_id);
242 l_rbs_header_id := PJI_PROCESS_UTIL.GET_PROCESS_PARAMETER(l_process,'RBS_HEADER_ID');
243 /* Added for bug#5728852 - END */
244
245 IF (p_context = 'RBS' AND p_rbs_version_id IS NULL) THEN
246 print_time('Context is RBS and rbs version id is NULL. Pl. provide a rbs version id. Exitting.' );
247 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
248 RETURN;
249 END IF;
250
251 IF (p_context = 'RBS') THEN
252
253 l_plan_type_id := NULL;
254 l_rbs_version_id := p_rbs_version_id;
255
256
257 INSERT INTO PJI_FM_EXTR_PLNVER4
258 (
259 WORKER_ID ,
260 PROJECT_ID ,
261 PLAN_VERSION_ID ,
262 WBS_STRUCT_VERSION_ID ,
263 RBS_STRUCT_VERSION_ID ,
264 PLAN_TYPE_CODE ,
265 PLAN_TYPE_ID ,
266 TIME_PHASED_TYPE_CODE ,
267 TIME_DANGLING_FLAG ,
268 RATE_DANGLING_FLAG ,
269 PROJECT_TYPE_CLASS ,
270 WP_FLAG ,
271 CURRENT_FLAG ,
272 ORIGINAL_FLAG ,
273 CURRENT_ORIGINAL_FLAG ,
274 BASELINED_FLAG ,
275 SECONDARY_RBS_FLAG ,
276 LP_FLAG
277 )
278 SELECT
279 DISTINCT
280 g_worker_id worker_id
281 , project_id
282 , plan_version_id
283 , wbs_struct_version_id
284 , rbs_struct_version_id
285 , plan_type_code
286 , plan_type_id
287 , time_phased_type_code
288 , NULL time_dangling_flag
289 , NULL rate_dangling_flag
290 , NULL PROJECT_TYPE_CLASS
291 , is_wp_flag
292 , current_flag
293 , original_flag
294 , current_original_flag
295 , baselined_flag
296 , SECONDARY_RBS_FLAG
297 , lp_flag
298 FROM
299 (
300 SELECT -- RBS Push 1: This select for all primary RBSes that change from rbs version A to B.
301 /*+ ORDERED */
302 bv.project_id project_id
303 , bv.budget_version_id plan_version_id
304 , DECODE ( NVL(bv.wp_version_flag, 'N')
305 , 'Y', bv.project_structure_version_id
306 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
307 ) wbs_struct_version_id
308 , fpo.rbs_version_id rbs_struct_version_id -- extract for this rbs version id
309 -- , to_char(fpo.fin_plan_type_id) plan_type_code
310 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
311 , fpo.fin_plan_type_id plan_type_id
312 , DECODE(bv.version_type
313 , 'ALL', fpo.all_time_phased_code
314 , 'COST', fpo.cost_time_phased_code
315 , 'REVENUE', fpo.revenue_time_phased_code
316 ) time_phased_type_code
317 , NVL(bv.wp_version_flag, 'N') is_wp_flag
318 , bv.current_flag current_flag
319 , bv.original_flag original_flag
320 , bv.current_original_flag current_original_flag
321 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
322 , 'N' SECONDARY_RBS_FLAG
323 , DECODE( NVL(bv.wp_version_flag, 'N')
324 , 'Y'
325 , DECODE(bv.project_structure_version_id
326 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
327 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
328 , 'Y'
329 , 'N')
330 , 'N'
331 ) lp_flag
332 FROM
333 pji_pjp_proj_batch_map map,
334 pji_pjp_rbs_header rhd,
335 pa_budget_versions bv,
336 pa_proj_fp_options fpo,
337 pji_pa_proj_events_log pel,
338 pa_projects_all ppa,
339 pa_rbs_versions_b rvb --Added for bug#5728852
340 WHERE 1=1
341 AND ppa.project_id = map.project_id
342 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
343 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
344 AND fpo.project_id = map.project_id
345 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
346 AND bv.budget_version_id = fpo.fin_plan_version_id
347 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
348 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
349 AND rhd.rbs_version_id = rvb.rbs_version_id --Added for bug#5728852
350 AND rvb.rbs_header_id = l_rbs_header_id --Added for bug#5728852
351 AND rhd.plan_version_id = bv.budget_version_id
352 AND rhd.project_id = map.project_id
353 AND pel.WORKER_ID = g_worker_id
354 AND pel.event_type = 'RBS_PUSH'
355 AND pel.event_object = fpo.rbs_version_id -- event object is the new primary rbs_version.
356 AND to_number(pel.attribute2) = p_rbs_version_id -- attribute2 is the old rbs_version.
357 AND pel.ATTRIBUTE19 = map.PROJECT_ID
358 AND map.project_id = bv.project_id
359 AND map.worker_id = g_worker_id
360 -- AND p_context = 'RBS'
361 UNION ALL
362 SELECT -- RBS Push 2: This select for all secondary (reporting) RBSes that are changing from A to B.
363 /*+ ORDERED */
364 bv.project_id project_id
365 , bv.budget_version_id plan_version_id
366 , DECODE ( NVL(bv.wp_version_flag, 'N')
367 , 'Y', bv.project_structure_version_id
368 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
369 ) wbs_struct_version_id
370 , rpa.rbs_version_id rbs_struct_version_id
371 -- , to_char(fpo.fin_plan_type_id) plan_type_code
372 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
373 , fpo.fin_plan_type_id plan_type_id
374 , DECODE(bv.version_type
375 , 'ALL', fpo.all_time_phased_code
376 , 'COST', fpo.cost_time_phased_code
377 , 'REVENUE', fpo.revenue_time_phased_code
378 ) time_phased_type_code
379 , NVL(bv.wp_version_flag, 'N') is_wp_flag
380 , bv.current_flag current_flag
381 , bv.original_flag original_flag
382 , bv.current_original_flag current_original_flag
383 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
384 , 'Y' SECONDARY_RBS_FLAG
385 , DECODE( NVL(bv.wp_version_flag, 'N')
386 , 'Y'
387 , DECODE(bv.project_structure_version_id
388 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
389 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
390 , 'Y'
391 , 'N')
392 , 'N'
393 ) lp_flag
394 FROM
395 PJI_PJP_PROJ_BATCH_MAP map,
396 PJI_PJP_RBS_HEADER rhd,
397 PA_BUDGET_VERSIONS bv,
398 PA_PROJ_FP_OPTIONS fpo,
399 PJI_PA_PROJ_EVENTS_LOG pel,
400 PA_RBS_PRJ_ASSIGNMENTS rpa,
401 PA_PROJECTS_ALL ppa,
402 PA_RBS_VERSIONS_B rvb --Added for bug#5728852
403 WHERE 1=1
404 AND ppa.project_id = map.project_id
405 AND bv.project_id = map.project_id
406 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
407 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
408 AND fpo.project_id = map.project_id
409 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
410 AND bv.budget_version_id = fpo.fin_plan_version_id
411 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
412 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
413 AND bv.budget_status_code = 'B'
414 AND NVL(bv.wp_version_flag, 'N') = 'N'
415 AND rhd.project_id = map.project_id
416 AND rhd.plan_version_id = bv.budget_version_id
417 AND rhd.rbs_version_id = rvb.rbs_version_id --Added for bug#5728852
418 AND rvb.rbs_header_id = l_rbs_header_id --Added for bug#5728852
419 AND rpa.assignment_status = 'ACTIVE'
420 AND NVL(fpo.rbs_version_id, -1) <> rpa.rbs_version_id
421 AND rpa.project_id = map.project_id
422 AND pel.WORKER_ID = g_worker_id
423 AND to_number(pel.attribute2) = p_rbs_version_id
424 AND pel.event_type = 'RBS_PUSH' -- When RBS version is 'frozen' from RBS definition screen.
425 AND pel.event_object = rpa.rbs_version_id
426 AND pel.ATTRIBUTE19 = map.PROJECT_ID
427 AND map.project_id = bv.project_id
428 -- AND map.PROJECT_ACTIVE_FLAG = 'Y'
429 AND map.worker_id = g_worker_id
430 -- AND p_context = 'RBS'
431 UNION ALL
432 SELECT
433 /*+ ORDERED */
434 bv.project_id project_id
435 , pln_ver.pvi plan_version_id
436 , DECODE ( NVL(bv.wp_version_flag, 'N')
437 , 'Y', bv.project_structure_version_id
438 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
439 ) wbs_struct_version_id
440 , rpa.rbs_version_id rbs_struct_version_id
441 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
442 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
443 , fpo.fin_plan_type_id plan_type_id
444 , DECODE(bv.version_type
445 , 'ALL', fpo.all_time_phased_code
446 , 'COST', fpo.cost_time_phased_code
447 , 'REVENUE', fpo.revenue_time_phased_code
448 ) time_phased_type_code
449 , NVL(bv.wp_version_flag, 'N') is_wp_flag
450 , DECODE(pln_ver.pvi, -3, 'Y', -4, 'N') current_flag
451 , 'X' original_flag
452 , DECODE(pln_ver.pvi, -3, 'N', -4, 'Y') current_original_flag
453 , DECODE(pln_ver.pvi, -3, 'Y', -4, 'N') baselined_flag
454 , 'N' SECONDARY_RBS_FLAG
455 , 'Y' lp_flag
456 FROM
457 PJI_PJP_PROJ_BATCH_MAP map,
458 PJI_PJP_RBS_HEADER rhd,
459 PA_BUDGET_VERSIONS bv,
460 PA_PROJ_FP_OPTIONS fpo,
461 PJI_PA_PROJ_EVENTS_LOG pel,
462 PA_RBS_PRJ_ASSIGNMENTS rpa,
463 PA_PROJECTS_ALL ppa,
464 PA_RBS_VERSIONS_B rvb,
465 (
466 SELECT -3 pvi FROM dual UNION ALL
467 SELECT -4 pvi FROM dual
468 ) pln_ver
469 WHERE 1=1
470 AND ppa.project_id = bv.project_id
471 AND bv.version_type IS NOT NULL -- COST, REVENUE, etc. Should not be null.
472 AND bv.fin_plan_type_id IS NOT NULL -- Old budgets model data is not picked up with this condition.
473 AND fpo.project_id = bv.project_id
474 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
475 AND bv.budget_version_id = fpo.fin_plan_version_id
476 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
477 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
478 AND bv.budget_status_code = 'B'
479 AND NVL(bv.wp_version_flag, 'N') = 'N'
480 AND pel.WORKER_ID = g_worker_id
481 AND rhd.PROJECT_ID = map.PROJECT_ID
482 AND rhd.rbs_version_id = TO_NUMBER(pel.attribute2)
483 AND rhd.plan_version_id = bv.budget_version_id
484 AND rhd.rbs_version_id = rvb.rbs_version_id --Added for bug#5728852
485 AND rvb.rbs_header_id = l_rbs_header_id --Added for bug#5728852
486 AND rpa.assignment_status = 'ACTIVE'
487 -- AND NVL(fpo.rbs_version_id, -1) <> rpa.rbs_version_id
488 AND rpa.project_id = bv.project_id
489 AND pel.event_type = 'RBS_PUSH' -- When RBS version is 'frozen' from RBS definition screen.
490 AND pel.event_object = rpa.rbs_version_id
491 AND pel.ATTRIBUTE19 = map.PROJECT_ID
492 AND map.project_id = bv.project_id
493 AND map.worker_id = g_worker_id
494 -- AND p_context = 'RBS'
495 ) ;
496
497 l_num_rows := SQL%ROWCOUNT;
498
499 print_time ( ' Number of plans with this rbs version id are.. x_num_rows = ' || l_num_rows);
500 ELSIF (p_context = 'PLANTYPE') THEN
501
502 l_plan_type_id := p_plan_type_id;
503 l_rbs_version_id := NULL;
504 l_process := PJI_PJP_SUM_MAIN.g_process || to_char(g_worker_id); -- Bug#5099574
505 l_refresh_code := PJI_PROCESS_UTIL.GET_PROCESS_PARAMETER (l_process, 'REFRESH_CODE'); -- Bug#5099574
506
507 -- Bug# 5208322 : the workplan plan_type_id is stored in l_workplan_type_id
508 begin
509 SELECT fin_plan_type_id into l_workplan_type_id
510 FROM pa_fin_plan_types_b
511 WHERE use_for_workplan_flag = 'Y';
512 exception
513 when no_data_found then
514 l_workplan_type_id := NULL;
515 end;
516
517
518
519 INSERT INTO PJI_FM_EXTR_PLNVER4
520 (
521 WORKER_ID ,
522 PROJECT_ID ,
523 PLAN_VERSION_ID ,
524 WBS_STRUCT_VERSION_ID ,
525 RBS_STRUCT_VERSION_ID ,
526 PLAN_TYPE_CODE ,
527 PLAN_TYPE_ID ,
528 TIME_PHASED_TYPE_CODE ,
529 TIME_DANGLING_FLAG ,
530 RATE_DANGLING_FLAG ,
531 PROJECT_TYPE_CLASS ,
532 WP_FLAG ,
533 CURRENT_FLAG ,
534 ORIGINAL_FLAG ,
535 CURRENT_ORIGINAL_FLAG ,
536 BASELINED_FLAG ,
537 SECONDARY_RBS_FLAG ,
538 LP_FLAG
539 )
540 SELECT
541 DISTINCT
542 g_worker_id worker_id
543 , project_id
544 , plan_version_id
545 , wbs_struct_version_id
546 , rbs_struct_version_id
547 , plan_type_code
548 , plan_type_id
549 , time_phased_type_code
550 , NULL time_dangling_flag
551 , NULL rate_dangling_flag
552 , NULL PROJECT_TYPE_CLASS
553 , is_wp_flag
554 , current_flag
555 , original_flag
556 , current_original_flag
557 , baselined_flag
558 , SECONDARY_RBS_FLAG
559 , lp_flag
560 FROM
561 (
562 SELECT -- Partial refresh 1: This select for all plan versions with primary rbs and plan type id not null.
563 /*+ ORDERED */
564 bv.project_id project_id
565 , bv.budget_version_id plan_version_id
566 , DECODE ( NVL(bv.wp_version_flag, 'N')
567 , 'Y', bv.project_structure_version_id
568 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
569 ) wbs_struct_version_id
570 , fpo.rbs_version_id rbs_struct_version_id -- extract for this rbs version id
571 -- , to_char(fpo.fin_plan_type_id) plan_type_code
572 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
573 , fpo.fin_plan_type_id plan_type_id
574 , DECODE(bv.version_type
575 , 'ALL', fpo.all_time_phased_code
576 , 'COST', fpo.cost_time_phased_code
577 , 'REVENUE', fpo.revenue_time_phased_code
578 ) time_phased_type_code
579 , NVL(bv.wp_version_flag, 'N') is_wp_flag
580 , bv.current_flag current_flag
581 , bv.original_flag original_flag
582 , bv.current_original_flag current_original_flag
583 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
584 , 'N' SECONDARY_RBS_FLAG
585 , DECODE( NVL(bv.wp_version_flag, 'N')
586 , 'Y'
587 , DECODE(bv.project_structure_version_id
588 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
589 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
590 , 'Y'
591 , 'N')
592 , 'N'
593 ) lp_flag
594 FROM
595 pji_pjp_proj_batch_map map
596 , pa_projects_all ppa
597 , pa_budget_versions bv
598 , pa_proj_fp_options fpo
599 WHERE 1=1
600 AND ppa.project_id = bv.project_id
601 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
602 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
603 AND fpo.project_id = bv.project_id
604 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
605 AND bv.budget_version_id = fpo.fin_plan_version_id
606 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
607 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
608 AND map.project_id = bv.project_id
609 AND map.worker_id = g_worker_id
610 AND bv.fin_plan_type_id = nvl(l_plan_type_id,bv.fin_plan_type_id) and
611 (
612 'Y' IN -- Bug#5099574 Pull Reversals for CB / CO if refresh_code < 62 . Else pull for all plans ids >0 if refresh_code>=62
613 (
614 Select decode(
615 bitand(l_refresh_code,g_all_plans),g_all_plans,'Y',
616 decode( bitand(l_refresh_code,g_cb_plans),g_cb_plans,
617 decode(decode(bv.baselined_date, NULL, 'N', 'Y')||bv.current_flag,'YY', 'Y', 'N'),'X')) from dual
618 UNION ALL
619 Select decode(
620 bitand(l_refresh_code,g_all_plans),g_all_plans,'Y',
621 decode( bitand(l_refresh_code,g_co_plans),g_co_plans,bv.current_original_flag,'X')) from dual
622 )
623 OR -- Bug#5099574 Pull Reversals for Fin plan Working Versions when l_refresh_code=16,30. ignore if l_refresh_code>=62
624 (
625 bv.BUDGET_STATUS_CODE in ('W','S') and
626 fpo.FIN_PLAN_TYPE_ID <> l_workplan_type_id and
627 DECODE(BITAND(l_refresh_code,g_all_plans),g_all_plans,'N',DECODE(BITAND(l_refresh_code,g_wk_plans),g_wk_plans,'Y','N'))='Y'
628 )
629 OR --Pull Reversals for Work plan Working Versions / LPub Vers / Baselined Versions when l_refresh_code=2,8,16,30. ignore if l_refresh_code>=62
630 EXISTS ( select 1 from PA_PROJ_ELEM_VER_STRUCTURE ppevs where
631 bv.FIN_PLAN_TYPE_ID =l_workplan_type_id and
632 bv.PROJECT_STRUCTURE_VERSION_ID = ppevs.ELEMENT_VERSION_ID and
633 (
634 decode(BITAND(l_refresh_code,g_all_plans),g_all_plans,'N',
635 decode(BITAND(l_refresh_code,g_lp_plans),g_lp_plans,LATEST_EFF_PUBLISHED_FLAG,'N'))='Y'
636 or
637 decode(BITAND(l_refresh_code,g_all_plans),g_all_plans,'N',
638 decode(BITAND(l_refresh_code,g_wk_plans),g_wk_plans,STATUS_CODE,'N'))='STRUCTURE_WORKING'
639 or
640 decode(BITAND(l_refresh_code,g_all_plans ),g_all_plans ,'N',
641 decode(BITAND(l_refresh_code,g_cb_plans),g_cb_plans,NVL2(CURRENT_BASELINE_DATE,'Y','N'),'N')) ='Y'
642
643 )
644 )
645 )
646 UNION ALL
647 SELECT -- Partial refresh 2: This select for all secondary (reporting) RBSes .
648 /*+ ORDERED */
649 bv.project_id project_id
650 , bv.budget_version_id plan_version_id
651 , DECODE ( NVL(bv.wp_version_flag, 'N')
652 , 'Y', bv.project_structure_version_id
653 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
654 ) wbs_struct_version_id
655 , rpa.rbs_version_id rbs_struct_version_id
656 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
657 , fpo.fin_plan_type_id plan_type_id
658 , DECODE(bv.version_type
659 , 'ALL', fpo.all_time_phased_code
660 , 'COST', fpo.cost_time_phased_code
661 , 'REVENUE', fpo.revenue_time_phased_code
662 ) time_phased_type_code
663 , NVL(bv.wp_version_flag, 'N') is_wp_flag
664 , bv.current_flag current_flag
665 , bv.original_flag original_flag
666 , bv.current_original_flag current_original_flag
667 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
668 , 'Y' SECONDARY_RBS_FLAG
669 , DECODE( NVL(bv.wp_version_flag, 'N')
670 , 'Y'
671 , DECODE(bv.project_structure_version_id
672 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
673 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
674 , 'Y'
675 , 'N')
676 , 'N'
677 ) lp_flag
678 FROM
679 pji_pjp_proj_batch_map map
680 , pa_projects_all ppa -- @pjdev115 ppa
681 , pa_budget_versions bv -- @pjdev115 bv
682 , pa_proj_fp_options fpo -- @pjdev115 fpo
683 , PA_RBS_PRJ_ASSIGNMENTS rpa
684 WHERE 1=1
685 AND ppa.project_id = bv.project_id
686 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
687 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
688 AND fpo.project_id = bv.project_id
689 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
690 AND bv.budget_version_id = fpo.fin_plan_version_id
691 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
692 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
693 AND bv.budget_status_code = 'B'
694 AND NVL(bv.wp_version_flag, 'N') = 'N'
695 AND rpa.assignment_status = 'ACTIVE'
696 AND NVL(fpo.rbs_version_id, -1) <> rpa.rbs_version_id
697 AND rpa.project_id = bv.project_id
698 AND map.project_id = bv.project_id
699 AND map.worker_id = g_worker_id
700 AND bv.fin_plan_type_id = nvl(l_plan_type_id,bv.fin_plan_type_id) and
701 (
702 'Y' IN -- Bug#5099574 Pull Reversals for CB / CO if refresh_code < 62 . Else pull for all plans ids >0 if refresh_code>=62
703 (
704 Select decode(
705 bitand(l_refresh_code,g_all_plans),g_all_plans,'Y',
706 decode( bitand(l_refresh_code,g_cb_plans),g_cb_plans,
707 decode(decode(bv.baselined_date, NULL, 'N', 'Y')||bv.current_flag,'YY', 'Y', 'N'),'X')) from dual
708 UNION ALL
709 Select decode(
710 bitand(l_refresh_code,g_all_plans),g_all_plans,'Y',
711 decode( bitand(l_refresh_code,g_co_plans),g_co_plans,bv.current_original_flag,'X')) from dual
712 )
713 )
714 ) ;
715
716 l_num_rows := SQL%ROWCOUNT;
717
718
719
720
721 ELSIF (p_context IN ( 'INCREMENTAL', 'FULL')) THEN -- Workplans only.
722
723
724 INSERT INTO PJI_FM_EXTR_PLNVER4
725 (
726 WORKER_ID ,
727 PROJECT_ID ,
728 PLAN_VERSION_ID ,
729 WBS_STRUCT_VERSION_ID ,
730 RBS_STRUCT_VERSION_ID ,
731 PLAN_TYPE_CODE ,
732 PLAN_TYPE_ID ,
733 TIME_PHASED_TYPE_CODE ,
734 TIME_DANGLING_FLAG ,
735 RATE_DANGLING_FLAG ,
736 PROJECT_TYPE_CLASS ,
737 WP_FLAG ,
738 CURRENT_FLAG ,
739 ORIGINAL_FLAG ,
740 CURRENT_ORIGINAL_FLAG ,
741 BASELINED_FLAG ,
742 SECONDARY_RBS_FLAG ,
743 LP_FLAG
744 )
745 SELECT
746 DISTINCT
747 g_worker_id worker_id
748 , project_id
749 , plan_version_id
750 , wbs_struct_version_id
751 , rbs_struct_version_id
752 , plan_type_code
753 , plan_type_id
754 , time_phased_type_code
755 , NULL time_dangling_flag
756 , NULL rate_dangling_flag
757 , NULL PROJECT_TYPE_CLASS
758 , is_wp_flag
759 , current_flag
760 , original_flag
761 , current_original_flag
762 , baselined_flag
763 , SECONDARY_RBS_FLAG
764 , lp_flag
765 FROM
766 (
767 SELECT -- Incr 1 , Full 1: This select for all plan versions with primary rbs and plan type id not null.
768 /*+ ORDERED */
769 pbv.project_id project_id
770 , pbv.budget_version_id plan_version_id
771 , head.WBS_VERSION_ID wbs_struct_version_id
772 , fpo.rbs_version_id rbs_struct_version_id -- extract for this rbs version id
773 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
774 , DECODE (pbv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
775 , fpo.fin_plan_type_id plan_type_id
776 , DECODE(pbv.version_type
777 , 'ALL', fpo.all_time_phased_code
778 , 'COST', fpo.cost_time_phased_code
779 , 'REVENUE', fpo.revenue_time_phased_code
780 ) time_phased_type_code
781 , NVL(pbv.wp_version_flag, 'N') is_wp_flag
782 , pbv.current_flag current_flag
783 , pbv.original_flag original_flag
784 , pbv.current_original_flag current_original_flag
785 , DECODE(Pbv.baselined_date, NULL, 'N', 'Y') baselined_flag
786 , 'N' SECONDARY_RBS_FLAG
787 , 'Y' lp_flag
788 FROM
789 pji_pjp_proj_batch_map map,
790 PA_PROJECTS_ALL ppa,
791 PA_BUDGET_VERSIONS pbv,
792 pji_pjp_wbs_header head,
793 PA_PROJ_ELEM_VER_STRUCTURE ppevs,
794 PA_PROJ_FP_OPTIONS fpo
795 WHERE
796 -- map.PROJECT_ACTIVE_FLAG = 'Y' AND
797 map.PROJECT_ID = head.PROJECT_ID AND
798 head.WP_FLAG = 'Y' AND
799 head.WBS_VERSION_ID = ppevs.ELEMENT_VERSION_ID AND
800 ppevs.STATUS_CODE = 'STRUCTURE_PUBLISHED' AND
801 ppevs.LATEST_EFF_PUBLISHED_FLAG = 'Y' AND
802 head.project_id = ppevs.project_id AND
803 map.PROJECT_ID = ppa.PROJECT_ID AND
804 ppa.STRUCTURE_SHARING_CODE = 'SHARE_FULL' AND
805 pbv.BUDGET_VERSION_ID = head.PLAN_VERSION_ID AND
806 head.PLAN_VERSION_ID = fpo.FIN_PLAN_VERSION_ID AND
807 ppa.project_id = pbv.project_id AND
808 pbv.version_type IS NOT NULL AND
809 pbv.fin_plan_type_id IS NOT NULL AND
810 fpo.project_id = pbv.project_id AND
811 pbv.fin_plan_type_id = fpo.fin_plan_type_id AND
812 pbv.budget_version_id = fpo.fin_plan_version_id AND
813 fpo.fin_plan_option_level_code = 'PLAN_VERSION' AND
814 pbv.version_type IN ('ALL','COST','REVENUE') AND
815 map.worker_id = g_worker_id AND
816 p_context IN ('INCREMENTAL', 'FULL')
817 ) ;
818
819 l_num_rows := SQL%ROWCOUNT;
820
821 print_time ( 'Context of summarization p_context is : ' || p_context );
822 print_time ( 'GET_ACTUALS_SUMM : after insert to ver3 , # rows is ' || l_num_rows );
823
824 END IF;
825
826
827
828 IF p_context = 'PLANTYPE' then
829 select decode(l_plan_type_id,NULL,decode(bitand (l_refresh_code,1),1,-1,-999),-999),
830 decode (bitand (l_refresh_code,2),2,-3,-999) ,
831 decode (bitand (l_refresh_code,4),4,-4,-999)
832 into l_actual_ver,l_cb_ver,l_co_ver from dual;
833 ELSE
834 l_actual_ver := -1;
835 l_cb_ver := -3;
836 l_co_ver := -4;
837 END IF;
838
839 INSERT INTO PJI_FM_EXTR_PLNVER4
840 (
841 WORKER_ID ,
842 PROJECT_ID ,
843 PLAN_VERSION_ID ,
844 WBS_STRUCT_VERSION_ID ,
845 RBS_STRUCT_VERSION_ID ,
846 PLAN_TYPE_CODE ,
847 PLAN_TYPE_ID ,
848 TIME_PHASED_TYPE_CODE ,
849 TIME_DANGLING_FLAG ,
850 RATE_DANGLING_FLAG ,
851 PROJECT_TYPE_CLASS ,
852 WP_FLAG ,
853 CURRENT_FLAG ,
854 ORIGINAL_FLAG ,
855 CURRENT_ORIGINAL_FLAG ,
856 BASELINED_FLAG ,
857 SECONDARY_RBS_FLAG ,
858 LP_FLAG
859 )
860 SELECT
861 DISTINCT
862 g_worker_id worker_id
863 , project_id
864 , plan_version_id
865 , wbs_struct_version_id
866 , rbs_struct_version_id
867 , plan_type_code
868 , plan_type_id
869 , time_phased_type_code
870 , NULL time_dangling_flag
871 , NULL rate_dangling_flag
872 , NULL PROJECT_TYPE_CLASS
873 , is_wp_flag
874 , current_flag
875 , original_flag
876 , current_original_flag
877 , baselined_flag
878 , SECONDARY_RBS_FLAG
879 , lp_flag
880 FROM
881 (
882 SELECT -- RBS push and Partial refresh: All RBSes for -3, -4 slices.
883 /*+ ORDERED */
884 map.project_id project_id
885 , whd.plan_version_id plan_version_id
886 , whd.wbs_version_id wbs_struct_version_id
887 , rhd.rbs_version_id rbs_struct_version_id -- extract for this rbs version id
888 , whd.plan_type_code plan_type_code /*4471527 */
889 , DECODE( whd.plan_version_id
890 , -1
891 , TO_NUMBER(NULL)
892 , whd.plan_type_id) plan_type_id
893 , 'G' time_phased_type_code
894 , 'N' is_wp_flag
895 , DECODE(whd.plan_version_id, -3, 'Y', -4, 'N') current_flag
896 , 'X' original_flag
897 , DECODE(whd.plan_version_id, -3, 'N', -4, 'Y') current_original_flag
898 , DECODE(whd.plan_version_id, -3, 'Y', -4, 'N') baselined_flag
899 , 'N' SECONDARY_RBS_FLAG
900 , 'Y' lp_flag
901 FROM
902 pji_pjp_proj_batch_map map
903 , PA_PROJECTS_ALL ppa
904 , pji_pjp_wbs_header whd
905 , pji_pjp_rbs_header rhd
906 WHERE 1=1
907 AND ppa.project_id = map.project_id
908 -- AND map.PROJECT_ACTIVE_FLAG = 'Y'
909 AND map.worker_id = g_worker_id
910 AND p_context IN ( 'RBS', 'PLANTYPE')
911 AND whd.plan_version_id IN (l_cb_ver, l_co_ver)
912 AND rhd.plan_version_id IN (l_cb_ver, l_co_ver)
913 AND whd.plan_version_id = rhd.plan_version_id
914 AND whd.plan_type_code = rhd.plan_type_code /*4471527 */
915 AND whd.project_id = map.project_id
916 AND rhd.project_id = map.project_id
917 UNION ALL
918 SELECT -- Incr 2 , Full 2, RBS push 3, Partial refresh 4: All RBSes for -1, -3, -4 slices.
919 /*+ ORDERED */
920 map.project_id project_id
921 , whd.plan_version_id plan_version_id
922 , whd.wbs_version_id wbs_struct_version_id
923 , rhd.rbs_version_id rbs_struct_version_id -- extract for this rbs version id
924 , whd.plan_type_code plan_type_code
925 , DECODE( whd.plan_version_id
926 , -1
927 , TO_NUMBER(NULL)
928 , whd.plan_type_id) plan_type_id
929 , 'G' time_phased_type_code
930 , 'N' is_wp_flag
931 , NULL current_flag
932 , 'X' original_flag
933 , NULL current_original_flag
934 , NULL baselined_flag
935 , 'N' SECONDARY_RBS_FLAG
936 , 'Y' lp_flag
937 FROM
938 pji_pjp_proj_batch_map map
939 , PA_PROJECTS_ALL ppa
940 , pji_pjp_wbs_header whd
941 , pji_pjp_rbs_header rhd
942 WHERE 1=1
943 AND ppa.project_id = map.project_id
944 -- AND map.PROJECT_ACTIVE_FLAG = 'Y'
945 AND map.worker_id = g_worker_id
946 AND whd.plan_version_id = l_actual_ver
947 AND rhd.plan_version_id = l_actual_ver
948 AND whd.plan_version_id = rhd.plan_version_id
949 AND whd.plan_type_code = rhd.plan_type_code
950 AND whd.project_id = map.project_id
951 AND rhd.project_id = map.project_id
952 )
953 WHERE (project_id, plan_version_id, NVL(plan_type_id, -1), plan_type_code, rbs_struct_version_id)
954 NOT IN
955 (SELECT project_id, plan_version_id, NVL(plan_type_id, -1), plan_type_code, rbs_struct_version_id
956 FROM pji_fm_extr_plnver4
957 WHERE worker_id = g_worker_id
958 AND plan_version_id in (-1, -3, -4));
959
960 l_num_rows := l_num_rows + SQL%ROWCOUNT; -- Bug#5208250
961
962 print_time(' Number of ver4 records inserted for -1/-3/-4 plan versions is.. ' || SQL%ROWCOUNT );
963
964 x_num_rows := l_num_rows;
965
966 print_time (' Number of records inserted in Ver4 Table is : '||l_num_rows);
967
968 if (l_num_rows=0) then
969 return;
970 end if;
971
972
973
974 IF (p_context = 'RBS') THEN
975
976 DELETE FROM pji_pjp_rbs_header -- Old RBS versions are to be replaced with new ones.
977 WHERE 1=1
978 AND rbs_version_id in (select rbs_version_id
979 from pa_rbs_versions_b
980 where rbs_header_id = l_rbs_header_id) --Modified for Bug#5728852 by VVJOSHI
981 AND plan_version_id > 0;
982
983 print_time ( ' Number of records in rbs hdr tbl that were deleted is.. = ' || SQL%ROWCOUNT );
984
985 DELETE FROM pji_rbs_denorm
986 WHERE struct_version_id = p_rbs_version_id; --Modified for Bug#6884573 by VVJOSHI
987
988 print_time ( ' Number of rows in pji rbs denorm tbl that were deleted is.. = ' || SQL%ROWCOUNT );
989
990 DELETE FROM pa_rbs_denorm
991 WHERE struct_version_id = p_rbs_version_id; --Modified for Bug#6884573 by VVJOSHI
992
993 print_time ( ' Number of rows in pa rbs denorm tbl that were deleted is.. = ' || SQL%ROWCOUNT );
994
995 END IF;
996
997 print_time('VALIDATE_SET_PR_PARAMS : end.. ');
998
999 EXCEPTION
1000 WHEN OTHERS THEN
1001 PJI_PJP_FP_CURR_WRAP.EXCP_HANDLER
1002 ( p_package_name => g_package_name
1003 , p_procedure_name => ' VALIDATE_SET_PR_PARAMS '
1004 , x_return_status => l_return_status ) ;
1005
1006 RAISE;
1007 END;
1008
1009
1010 --
1011 -- bug 4863241
1012 -- Lock mode: Lock during sumz='P', Unlock during sumz=NULL
1013 --
1014 PROCEDURE OBTAIN_RELEASE_LOCKS (
1015 p_context IN VARCHAR2
1016 , p_lock_mode IN VARCHAR2 -- NULL or 'P'
1017 , x_return_status OUT NOCOPY VARCHAR2
1018 , x_msg_code OUT NOCOPY VARCHAR2 ) IS
1019
1020 l_pl_exists VARCHAR2(1) := 'N'; -- plan lines count.
1021 l_dangl_exists VARCHAR2(1) := 'N'; -- dangling processing is happening.
1022 l_rbs_assoc_exists NUMBER := 0; -- rbs assoc event exists.
1023 l_rbs_prg_exists NUMBER := 0; -- rbs prg event exists.
1024 l_prg_change_exists NUMBER := 0; -- prg change event exists.
1025
1026 l_context VARCHAR2(1000) := NULL;
1027
1028 BEGIN
1029
1030 print_time (' OBTAIN_RELEASE_LOCKS start: p_context = ' || p_context || ' p_lock_mode ' || p_lock_mode || ' worker id = ' || g_worker_id );
1031
1032 IF (p_context NOT IN ('RBS', 'PARTIAL', 'INCREMENTAL', 'FULL')) THEN -- , 'PULL_DANGLING') THEN
1033 print_time ( ' OBTAIN_RELEASE_LOCKS : Invalid p_context ' || p_context );
1034 RETURN;
1035 END IF;
1036
1037 --
1038 -- RBS
1039 -- No program rollups, TN/TY slices does not change.
1040 -- New LNY data, so program rollup can happen.
1041 -- Only baselined fin plans/cb/co lock.
1042 -- PLANTYPE
1043 -- Actuals may have come in. LNN slice could have changed. Program rollups happen. New LNY data.
1044 -- All plans for this project, lat pub all the way up, one wpwv above, cb/co.
1045 -- INCR/FULL
1046 -- Only actuals change, if yes then do program rollup.
1047 -- lat pub all the way up.
1048 -- PULL_DANGLING
1049 -- Dangling baselined fin plan for this proj/cb/co, all cb/cos above striped by plan type.
1050 -- RBS_ASSOC
1051 -- TN/TY slices don't change. New LNY data for baselined fps.
1052 -- All baselined fin plan for this proj/cb/co.
1053 -- RBS_PRG
1054 -- TN/TY slices don't change. New LNY data for baselined fps.
1055 -- All baselined fin plan for this proj/cb/co *below* and above.
1056 -- PRG_CHANGE
1057 -- Lock all projects in new prg based on event.
1058 --
1059
1060
1061 BEGIN
1062 SELECT 'Y'
1063 INTO l_pl_exists
1064 FROM pji_fm_extr_plan_lines epl
1065 WHERE EXISTS (
1066 SELECT 1
1067 FROM pji_pjp_proj_batch_map map
1068 WHERE map.worker_id = g_worker_id
1069 AND epl.project_id = map.project_id
1070 )
1071 AND ROWNUM <= 1;
1072 EXCEPTION
1073 WHEN NO_DATA_FOUND THEN
1074 NULL;
1075 END;
1076
1077 SELECT NVL(SUM(DECODE(event_type, 'PRG_CHANGE', 1, 0)), 0)
1078 , NVL(SUM(DECODE(event_type, 'RBS_ASSOC', 1, 0)) , 0)
1079 , NVL(SUM(DECODE(event_type, 'RBS_PRG', 1, 0)) , 0)
1080 INTO l_prg_change_exists
1081 , l_rbs_assoc_exists
1082 , l_rbs_prg_exists
1083 FROM pji_pa_proj_events_log
1084 WHERE 1=1
1085 AND worker_id = g_worker_id;
1086
1087 BEGIN
1088 select /*+ ordered index(bv PA_BUDGET_VERSIONS_U2) */
1089 'Y'
1090 into
1091 l_dangl_exists
1092 from
1093 PJI_PJP_PROJ_BATCH_MAP map,
1094 PA_BUDGET_VERSIONS bv
1095 where
1096 map.WORKER_ID = g_worker_id and
1097 bv.PROJECT_ID = map.PROJECT_ID and
1098 nvl(bv.WP_VERSION_FLAG, 'N') = 'N' and
1099 bv.BUDGET_STATUS_CODE = 'B' and
1100 bv.PJI_SUMMARIZED_FLAG = 'P' and
1101 bv.BUDGET_TYPE_CODE is null and --Bug fix 6909152
1102 bv.FIN_PLAN_TYPE_ID is not null and --Bug fix 6909152
1103 rownum = 1;
1104 EXCEPTION
1105 WHEN NO_DATA_FOUND THEN
1106 NULL;
1107 END;
1108
1109 print_time ( ' Do plan lines exist? ' || l_pl_exists );
1110 print_time ( ' Do prg_change events exist? ' || l_prg_change_exists );
1111 print_time ( ' Do rbs assoc events exist? ' || l_rbs_assoc_exists );
1112 print_time ( ' Do rbs prg events exist? ' || l_rbs_prg_exists );
1113 print_time ( ' Do dangling FP versions exist? ' || l_dangl_exists );
1114
1115
1116 IF (p_context = 'INCREMENTAL') THEN -- incr+rbsprg+rbsassoc+prgchange+dangling
1117
1118 IF (l_pl_exists = 'Y') THEN
1119
1120 -- Only actuals change, if yes then do program rollup.
1121 -- lat pub all the way up.
1122
1123 l_context := l_context || 'c_incr_act_etc:';
1124
1125 END IF;
1126
1127 IF (l_rbs_assoc_exists > 0) THEN
1128
1129 -- TN/TY slices don't change. New LNY data for baselined fps.
1130 -- All baselined fin plan for this proj/cb/co.
1131
1132 l_context := l_context || 'c_all_baselined_fps_rbsassoc:' || 'c_all_cb_co_rbsassoc_above:';
1133
1134 END IF;
1135
1136 IF (l_rbs_prg_exists > 0) THEN
1137
1138 -- TN/TY slices don't change. New LNY data for baselined fps.
1139 -- All baselined fin plan for this proj/cb/co *below* and above.
1140
1141 l_context := l_context || 'c_all_bslnd_fps_rbsprg_below:'
1142 || 'c_all_cb_co_rbsprg_above:' || 'c_all_cb_co_rbsprg_below:';
1143
1144 END IF;
1145
1146 IF (l_prg_change_exists > 0) THEN
1147
1148 -- PRG_CHANGE
1149 -- Lock all projects in new prg based on event.
1150
1151 l_context := l_context || 'c_all_plans_prg_chng:';
1152
1153 END IF;
1154
1155 IF (l_dangl_exists = 'Y') THEN
1156
1157 -- PRG_CHANGE
1158 -- Lock all projects in new prg based on event.
1159
1160 l_context := l_context || 'c_dangl_fps_self:' || 'c_dangl_cb_co_above:' ;
1161
1162 END IF;
1163
1164 ELSIF (p_context = 'FULL') THEN
1165
1166 IF (l_pl_exists = 'Y') THEN
1167
1168 -- Only actuals change, if yes then do program rollup.
1169 -- lat pub all the way up.
1170
1171 l_context := l_context || 'c_incr_act_etc:';
1172
1173 END IF;
1174
1175 ELSIF (p_context = 'RBS') THEN
1176
1177 -- No program rollups, TN/TY slices does not change.
1178 -- Act/etc can come in too.
1179 -- New LNY data, so program rollup can happen.
1180 -- Only baselined fin plans/cb/co lock. Also, lpv all the way up.
1181
1182 IF (l_pl_exists = 'Y') THEN
1183
1184 -- Only actuals change, if yes then do program rollup.
1185 -- lat pub all the way up.
1186
1187 l_context := l_context || 'c_incr_act_etc:';
1188
1189 END IF;
1190
1191
1192 l_context := l_context || 'c_all_baselined_fps_generic:' || 'c_all_cb_co_above:';
1193
1194
1195 ELSIF (p_context = 'PARTIAL') THEN
1196
1197 -- Actuals may have come in. LNN slice could have changed. Program rollups happen. New LNY data.
1198 -- Act/etc can come in too.
1199 -- All plans for this project, lat pub all the way up, one wpwv above, cb/co.
1200 -- Only baselined fin plans/cb/co lock. Also, lpv all the way up.
1201
1202 IF (l_pl_exists = 'Y') THEN
1203
1204 -- Only actuals change, if yes then do program rollup.
1205 -- lat pub all the way up.
1206
1207 l_context := l_context || 'c_incr_act_etc:';
1208
1209 END IF;
1210
1211 l_context := l_context || 'c_all_baselined_fps_generic:' || 'c_all_cb_co_above:' ;
1212
1213 END IF;
1214
1215 UPDATE_LOCKS (
1216 p_context => l_context
1217 , p_update_mode => p_lock_mode
1218 , x_return_status => x_return_status
1219 , x_msg_code => x_msg_code );
1220
1221 print_time(' Obtained lock flag in WBS header table. # rows is .. ' || SQL%ROWCOUNT );
1222
1223 EXCEPTION
1224
1225 WHEN OTHERS THEN
1226 PJI_PJP_FP_CURR_WRAP.EXCP_HANDLER
1227 ( p_package_name => g_package_name
1228 , p_procedure_name => ' OBTAIN_RELEASE_LOCKS '
1229 , x_return_status => x_return_status ) ;
1230
1231 RAISE;
1232 END;
1233
1234
1235 --
1236 -- bug 4863241
1237 -- Lock mode: Lock during sumz='P', Unlock during sumz=NULL
1238 --
1239 PROCEDURE UPDATE_LOCKS (
1240 p_context IN VARCHAR2
1241 , p_update_mode IN VARCHAR2 -- P => lock, NULL => unlock
1242 , x_return_status OUT NOCOPY VARCHAR2
1243 , x_msg_code OUT NOCOPY VARCHAR2 ) IS
1244
1245 l_count_already_locked NUMBER := 0;
1246 l_count_just_updated NUMBER := 0;
1247
1248 l_last_update_date date := SYSDATE;
1249 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
1250 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
1251
1252 excp_resource_busy EXCEPTION;
1253 PRAGMA EXCEPTION_INIT(excp_resource_busy, -54);
1254
1255 CURSOR c_get_hdrs_lock_ver3_t_cur IS
1256 SELECT 1
1257 FROM pji_pjp_wbs_header
1258 WHERE (project_id, plan_type_id, plan_version_id) IN
1259 (SELECT DISTINCT project_id, plan_type_id, plan_version_id
1260 FROM pji_fm_extr_plnver3_t)
1261 FOR UPDATE;
1262
1263 CURSOR c_get_hdrs_lock_map_cur IS
1264 SELECT /*+ index(hd, pji_pjp_wbs_header_n1) */ 1
1265 FROM pji_pjp_wbs_header hd
1266 WHERE (project_id, plan_version_id, plan_type_id) IN
1267 ( SELECT hd1.project_id, plan_version_id, plan_type_id
1268 FROM pji_pjp_wbs_header hd1
1269 , pji_pjp_proj_batch_map map
1270 WHERE hd1.project_id = map.project_id
1271 AND map.worker_id = g_worker_id
1272 AND (hd1.plan_version_id > 0 OR hd1.plan_version_id IN (-3, -4))
1273 )
1274 FOR UPDATE;
1275
1276 BEGIN
1277
1278 Pji_Pjp_Fp_Curr_Wrap.INIT_ERR_STACK
1279 ( p_package_name => g_package_name
1280 , x_return_status => x_return_status ) ;
1281
1282 print_time ( ' UPDATE_LOCKS: p_context = ' || p_context || ' p_update_mode = ' || NVL(p_update_mode, 'X'));
1283
1284 IF ( NVL(p_update_mode, 'X') NOT IN ( 'P', 'X') ) THEN
1285 print_time( ' Invalid context, returning: ' || p_update_mode);
1286 RETURN;
1287 END IF;
1288
1289 IF ( p_context NOT LIKE '%c_incr_act_etc%'
1290 AND p_context NOT LIKE '%c_all_cb_co_above%'
1291 AND p_context NOT LIKE '%c_all_baselined_fps_generic%'
1292 AND p_context NOT LIKE '%c_all_plans_prg_chng%'
1293 AND p_context NOT LIKE '%c_all_cb_co_rbsprg_below%'
1294 AND p_context NOT LIKE '%c_all_cb_co_rbsprg_above%'
1295 AND p_context NOT LIKE '%c_all_bslnd_fps_rbsprg_below%'
1296 AND p_context NOT LIKE '%c_all_cb_co_rbsassoc_above%'
1297 AND p_context NOT LIKE '%c_all_baselined_fps_rbsassoc%'
1298 AND p_context NOT LIKE '%c_dangl_fps_self%'
1299 AND p_context NOT LIKE '%c_dangl_cb_co_above%'
1300 ) THEN
1301 print_time( ' Invalid p_context, returning: ' || p_context);
1302 RETURN;
1303 END IF;
1304
1305 DELETE FROM pji_fm_extr_plnver3_t;
1306
1307 /*
1308 IF (p_context LIKE '%c_incr_act_etc%' AND p_update_mode = 'P') THEN
1309
1310 INSERT INTO pji_fm_extr_plnver3_t
1311 (project_id, plan_version_id, plan_type_id)
1312 SELECT / * + ORDERED * / -- INDEX(HD9, PJI_PJP_WBS_HEADER_N1)
1313 DISTINCT hd9.project_id, hd9.plan_version_id, hd9.plan_type_id
1314 FROM pji_pjp_proj_batch_map map
1315 , pji_fm_extr_plan_lines epl
1316 , pji_pjp_wbs_header hd2 -- SUB
1317 , pji_xbs_denorm den
1318 , pji_pjp_wbs_header hd9 -- SUP
1319 , PA_PROJ_ELEM_VER_STRUCTURE ppevs1
1320 , PA_PROJ_ELEM_VER_STRUCTURE ppevs2
1321 WHERE
1322 den.struct_version_id IS NULL
1323 AND hd2.plan_type_id = hd9.plan_type_id
1324 AND hd2.wbs_version_id = den.sub_id -- struct_version_id
1325 AND hd9.wbs_version_id = den.sup_id
1326 and hd9.project_id = den.sup_project_id
1327 -- AND den.sup_level < den.sub_level
1328 AND den.struct_type = 'PRG'
1329 AND NVL(den.relationship_type, 'WF') IN ('LW', 'WF') -- 'LW',
1330 AND hd9.wp_flag = 'Y'
1331 AND ppevs1.project_id = hd9.project_id
1332 AND ppevs1.element_version_id = hd9.wbs_version_id
1333 AND ppevs1.latest_eff_published_flag = 'Y'
1334 AND hd2.wp_flag = 'Y'
1335 AND ppevs2.project_id = hd2.project_id
1336 AND ppevs2.element_version_id = hd2.wbs_version_id
1337 AND ppevs2.latest_eff_published_flag = 'Y'
1338 AND epl.project_id = hd2.project_id
1339 AND map.project_id = hd2.project_id
1340 AND map.worker_id = g_worker_id
1341 -- AND p_context LIKE '%c_incr_act_etc%'
1342 ;
1343
1344 END IF;
1345 */
1346
1347 IF (p_context LIKE '%c_all_cb_co_above%' AND p_update_mode = 'P') THEN
1348
1349 INSERT INTO pji_fm_extr_plnver3_t
1350 (project_id, plan_version_id, plan_type_id)
1351 SELECT /*+ ORDERED */
1352 DISTINCT hd9.project_id, hd9.plan_version_id, hd9.plan_type_id
1353 FROM pji_pjp_proj_batch_map map
1354 , pji_pjp_wbs_header hd1 -- SUB
1355 , pji_xbs_denorm den
1356 , pji_pjp_wbs_header hd9 -- SUP
1357 WHERE
1358 den.struct_version_id IS NULL
1359 AND hd1.wbs_version_id = den.sub_id -- struct_version_id
1360 AND hd9.wbs_version_id = den.sup_id
1361 AND den.struct_type = 'PRG'
1362 AND hd9.project_id = den.sup_project_id
1363 AND NVL(den.relationship_type, 'WF') IN ('LF', 'WF') -- lf- sp.fp.str, wf/null- fsh.str, lw- sp.wp.str
1364 AND hd1.plan_version_id IN (-3, -4)
1365 AND hd9.plan_version_id IN (-3, -4)
1366 AND hd9.plan_type_id = hd1.plan_type_id
1367 AND map.worker_id = g_worker_id
1368 AND hd1.project_id = map.project_id
1369 -- AND p_context LIKE '%c_all_cb_co_above%'
1370 ;
1371
1372 END IF;
1373
1374 IF (p_context LIKE '%c_all_baselined_fps_generic%' AND p_update_mode = 'P') THEN
1375
1376 INSERT INTO pji_fm_extr_plnver3_t
1377 (project_id, plan_version_id, plan_type_id)
1378 SELECT
1379 DISTINCT bv.project_id, bv.budget_version_id, bv.fin_plan_type_id
1380 FROM pji_pjp_proj_batch_map map
1381 , PA_BUDGET_VERSIONS bv
1382 WHERE
1383 map.worker_id = g_worker_id
1384 AND bv.project_id = map.project_id
1385 AND NVL(bv.wp_version_flag, 'N') = 'N'
1386 AND bv.budget_status_code = 'B'
1387 -- AND p_context LIKE '%c_all_baselined_fps_generic%'
1388 ;
1389
1390 END IF;
1391
1392
1393 IF (p_context LIKE '%c_all_plans_prg_chng%') THEN -- !! ONLY FOR PRG_CHANGE
1394
1395 INSERT INTO pji_fm_extr_plnver3_t
1396 (project_id, plan_version_id, plan_type_id)
1397 SELECT DISTINCT hd9.project_id, hd9.plan_version_id, hd9.plan_type_id
1398 FROM -- pji_pjp_wbs_header hd2
1399 -- pa_proj_elem_ver_structure hd2
1400 pji_pa_proj_events_log ev
1401 , Pa_XBS_DENORM den
1402 , pji_pjp_wbs_header hd9 -- SUP
1403 WHERE
1404 den.struct_version_id IS NULL
1405 AND hd9.wbs_version_id = den.sup_id -- struct_version_id
1406 -- AND hd2.element_version_id = den.sub_id
1407 -- AND hd2.project_id > 0
1408 AND hd9.project_id = den.sup_project_id
1409 AND den.struct_type = 'PRG'
1410 AND den.prg_group IN ( TO_NUMBER(ev.event_object), TO_NUMBER(ev.attribute1))
1411 AND ev.worker_id = g_worker_id
1412 AND ev.event_type = 'PRG_CHANGE'
1413 AND ( hd9.plan_version_id > 0
1414 OR hd9.plan_version_id IN (-3, -4) )
1415 -- AND p_context LIKE '%c_all_plans_prg_chng%'
1416 ;
1417
1418 END IF;
1419
1420
1421 IF (p_context LIKE '%c_all_cb_co_rbsprg_below%' AND p_update_mode = 'P') THEN
1422
1423 INSERT INTO pji_fm_extr_plnver3_t
1424 (project_id, plan_version_id, plan_type_id)
1425 SELECT /*+ ordered */
1426 DISTINCT hd2.project_id, hd2.plan_version_id, hd2.plan_type_id
1427 FROM
1428 pji_pjp_proj_batch_map map
1429 , pji_pa_proj_events_log ev
1430 , pji_pjp_wbs_header hd9 -- SUP
1431 , pji_xbs_denorm den
1432 , pji_pjp_wbs_header hd2 -- SUB
1433 WHERE
1434 den.struct_version_id IS NULL
1435 AND hd9.wbs_version_id = den.sub_id -- struct_version_id
1436 AND hd2.wbs_version_id = den.sup_id
1437 AND hd9.project_id = den.sup_project_id
1438 AND den.struct_type = 'PRG'
1439 AND NVL(den.relationship_type, 'WF') IN ('LF', 'WF') -- lf- sp.fp.str, wf/null- fsh.str, lw- sp.wp.str
1440 AND hd9.plan_version_id IN (-3, -4)
1441 AND hd2.plan_version_id IN (-3, -4)
1442 AND map.worker_id = g_worker_id
1443 AND ev.worker_id = g_worker_id
1444 AND ev.event_type = 'RBS_PRG'
1445 AND TO_NUMBER(ev.attribute1) = map.project_id
1446 AND hd9.project_id = map.project_id
1447 AND hd9.plan_type_id = hd2.plan_type_id
1448 -- AND p_context LIKE '%c_all_cb_co_rbsprg_below%'
1449 ;
1450
1451 END IF;
1452
1453
1454 IF (p_context LIKE '%c_all_baselined_fps_rbsassoc%' AND p_update_mode = 'P') THEN
1455
1456 INSERT INTO pji_fm_extr_plnver3_t
1457 (project_id, plan_version_id, plan_type_id)
1458 SELECT /*+ LEADING(MAP) */ /* leading hint added for bug 9337307 */
1459 DISTINCT hd9.project_id, hd9.plan_version_id, hd9.plan_type_id
1460 FROM pji_pjp_proj_batch_map map
1461 , pji_pa_proj_events_log ev
1462 , pji_pjp_wbs_header hd9 -- SUP
1463 WHERE
1464 map.worker_id = g_worker_id
1465 AND ev.worker_id = g_worker_id
1466 AND ev.event_type = 'RBS_ASSOC'
1467 AND TO_NUMBER(ev.attribute1) = map.project_id
1468 AND hd9.wp_flag = 'N'
1469 AND hd9.cb_flag || hd9.co_flag LIKE '%Y%'
1470 AND hd9.project_id = map.project_id
1471 AND not exists(select null
1472 from pji_fp_xbs_accum_f fact
1473 where fact.project_id = hd9.project_id
1474 and fact.plan_version_id = hd9.plan_version_id
1475 and fact.plan_type_id = hd9.plan_type_id
1476 and fact.rbs_version_id = ev.event_object)
1477 -- AND p_context LIKE '%c_all_baselined_fps_rbsassoc%'
1478 ;
1479
1480 END IF;
1481
1482
1483 IF (p_context LIKE '%c_all_cb_co_rbsassoc_above_cur%' AND p_update_mode = 'P') THEN
1484
1485 INSERT INTO pji_fm_extr_plnver3_t
1486 (project_id, plan_version_id, plan_type_id)
1487 SELECT DISTINCT hd9.project_id, hd9.plan_version_id, hd9.plan_type_id
1488 FROM pji_xbs_denorm den
1489 , pji_pjp_wbs_header hd1 -- SUB
1490 , pji_pjp_proj_batch_map map
1491 , pji_pa_proj_events_log ev
1492 , pji_pjp_wbs_header hd9 -- SUP
1493 WHERE
1494 den.struct_version_id IS NULL
1495 AND hd1.wbs_version_id = den.sub_id -- struct_version_id
1496 AND hd9.wbs_version_id = den.sup_id
1497 AND hd9.project_id = den.sup_project_id
1498 AND den.struct_type = 'PRG'
1499 AND NVL(den.relationship_type, 'WF') IN ('LF', 'WF')
1500 -- lf- sp.fp.str, wf/null- fsh.str, lw- sp.wp.str
1501 AND hd1.plan_version_id IN (-3, -4)
1502 AND hd9.plan_version_id IN (-3, -4)
1503 AND map.worker_id = g_worker_id
1504 AND ev.worker_id = g_worker_id
1505 AND ev.event_type = 'RBS_ASSOC'
1506 AND TO_NUMBER(ev.attribute1) = map.project_id
1507 AND hd1.project_id = map.project_id
1508 AND hd9.plan_type_id = hd1.plan_type_id
1509 AND not exists(select null
1510 from pji_fp_xbs_accum_f fact
1511 where fact.project_id = hd9.project_id
1512 and fact.plan_version_id = hd9.plan_version_id
1513 and fact.plan_type_id = hd9.plan_type_id
1514 and fact.rbs_version_id = ev.event_object)
1515 -- AND p_context LIKE '%c_all_cb_co_rbsassoc_above%'
1516 ;
1517
1518 END IF;
1519
1520
1521 IF (p_context LIKE '%c_all_bslnd_fps_rbsprg_below%' AND p_update_mode = 'P') THEN
1522
1523 INSERT INTO pji_fm_extr_plnver3_t
1524 (project_id, plan_version_id, plan_type_id)
1525 SELECT /*+ ordered */
1526 DISTINCT hd9.project_id, hd9.plan_version_id, hd9.plan_type_id
1527 FROM pji_pjp_proj_batch_map map
1528 , pji_pa_proj_events_log ev
1529 -- , PA_BUDGET_VERSIONS bv
1530 , pji_xbs_denorm den
1531 , pji_pjp_wbs_header wh1 -- sup
1532 , pji_pjp_wbs_header hd9 -- SUb!!
1533 WHERE
1534 den.struct_version_id IS NULL
1535 AND hd9.wbs_version_id = den.sub_id -- struct_version_id
1536 AND wh1.wbs_version_id = den.sup_id
1537 AND wh1.project_id = den.sup_project_id
1538 AND den.struct_type = 'PRG'
1539 AND NVL(den.relationship_type, 'WF') IN ('LF', 'WF')
1540 AND map.worker_id = g_worker_id
1541 AND ev.worker_id = g_worker_id
1542 AND ev.event_type = 'RBS_PRG'
1543 AND TO_NUMBER(ev.attribute1) = map.project_id
1544 AND wh1.project_id = map.project_id
1545 AND hd9.wp_flag = 'N'
1546 AND wh1.wp_flag = 'N'
1547 AND hd9.plan_version_id > 0
1548 AND wh1.plan_version_id > 0
1549 AND hd9.plan_type_id = wh1.plan_type_id
1550 AND hd9.cb_flag || hd9.co_flag LIKE '%Y%'
1551 -- AND p_context LIKE '%c_all_bslnd_fps_rbsprg_below%'
1552 ;
1553
1554 END IF;
1555
1556
1557 IF (p_context LIKE '%c_all_cb_co_rbsprg_above%' AND p_update_mode = 'P') THEN
1558
1559 INSERT INTO pji_fm_extr_plnver3_t
1560 (project_id, plan_version_id, plan_type_id)
1561 SELECT DISTINCT hd9.project_id, hd9.plan_version_id, hd9.plan_type_id
1562 FROM pji_xbs_denorm den
1563 , pji_pjp_wbs_header hd2 -- SUB
1564 , pji_pjp_proj_batch_map map
1565 , pji_pa_proj_events_log ev
1566 , pji_pjp_wbs_header hd9 -- SUP
1567 WHERE
1568 den.struct_version_id IS NULL
1569 AND hd9.wbs_version_id = den.sup_id -- struct_version_id
1570 AND hd2.wbs_version_id = den.sub_id
1571 AND hd9.project_id = den.sup_project_id
1572 AND den.struct_type = 'PRG'
1573 AND NVL(den.relationship_type, 'WF') IN ('LF', 'WF') -- lf- sp.fp.str, wf/null- fsh.str, lw- sp.wp.str
1574 AND hd9.plan_version_id IN (-3, -4)
1575 AND hd2.plan_version_id IN (-3, -4)
1576 AND map.worker_id = g_worker_id
1577 AND ev.worker_id = g_worker_id
1578 AND ev.event_type = 'RBS_PRG'
1579 AND TO_NUMBER(ev.attribute1) = map.project_id
1580 AND hd2.project_id = map.project_id
1581 AND hd9.plan_type_id = hd2.plan_type_id
1582 -- AND p_context LIKE '%c_all_cb_co_rbsprg_above%'
1583 ;
1584
1585 END IF;
1586
1587
1588 IF (p_context LIKE '%c_dangl_fps_self%' AND p_update_mode = 'P') THEN
1589
1590 INSERT INTO pji_fm_extr_plnver3_t
1591 (project_id, plan_version_id, plan_type_id)
1592 SELECT DISTINCT hd9.project_id, hd9.plan_version_id, hd9.plan_type_id
1593 FROM pji_pjp_proj_batch_map map
1594 , PA_BUDGET_VERSIONS bv
1595 , pji_pjp_wbs_header hd9 -- SUP
1596 WHERE
1597 map.worker_id = g_worker_id
1598 AND hd9.project_id = map.project_id
1599 AND hd9.project_id = bv.project_id
1600 AND hd9.plan_version_id = bv.budget_version_id
1601 AND hd9.wp_flag = 'N'
1602 AND bv.budget_status_code = 'B'
1603 AND bv.pji_summarized_flag = 'P'
1604 -- AND hd.lock_flag IS NOT NULL
1605 -- AND p_context LIKE '%c_dangl_fps_self%'
1606 ;
1607
1608 END IF;
1609
1610
1611 IF (p_context LIKE '%c_dangl_cb_co_above%' AND p_update_mode = 'P') THEN
1612
1613 INSERT INTO pji_fm_extr_plnver3_t
1614 (project_id, plan_version_id, plan_type_id)
1615 SELECT DISTINCT hd9.project_id, hd9.plan_version_id, hd9.plan_type_id
1616 FROM pji_xbs_denorm den
1617 , pji_pjp_wbs_header hd1 -- SUB
1618 , pji_pjp_proj_batch_map map
1619 , pa_budget_versions bv
1620 , pji_pjp_wbs_header hd9 -- SUP
1621 WHERE
1622 den.struct_version_id IS NULL
1623 AND map.project_id = bv.project_id
1624 AND map.project_id = hd1.project_id
1625 AND hd1.wp_flag = 'N'
1626 AND hd1.plan_type_id = bv.fin_plan_type_id
1627 AND bv.budget_status_code = 'B'
1628 AND bv.pji_summarized_flag = 'P'
1629 AND hd1.wbs_version_id = den.sub_id -- struct_version_id
1630 AND hd9.wbs_version_id = den.sup_id
1631 AND hd9.project_id = den.sup_project_id
1632 AND den.struct_type = 'PRG'
1633 AND NVL(den.relationship_type, 'WF') IN ('LF', 'WF')
1634 -- lf- sp.fp.str, wf/null- fsh.str, lw- sp.wp.str
1635 AND hd1.plan_version_id IN (-3, -4)
1636 AND hd9.plan_version_id IN (-3, -4)
1637 AND map.worker_id = g_worker_id
1638 AND hd1.project_id = map.project_id
1639 AND hd9.plan_type_id = bv.fin_plan_type_id
1640 AND hd9.plan_type_id = hd1.plan_type_id
1641 AND hd1.plan_version_id = hd9.plan_version_id
1642 -- AND p_context LIKE '%c_dangl_cb_co_above%'
1643 ;
1644
1645 END IF;
1646
1647
1648 OPEN c_get_hdrs_lock_ver3_t_cur;
1649 CLOSE c_get_hdrs_lock_ver3_t_cur;
1650
1651 UPDATE pji_pjp_wbs_header hd9 -- SUP
1652 SET lock_flag = p_update_mode
1653 , LAST_UPDATE_DATE = l_last_update_date
1654 , LAST_UPDATED_BY = l_last_updated_by
1655 , LAST_UPDATE_LOGIN = l_last_update_login
1656 WHERE (project_id, plan_type_id, plan_version_id) IN
1657 (SELECT DISTINCT project_id, plan_type_id, plan_version_id
1658 FROM pji_fm_extr_plnver3_t);
1659
1660 print_time ( ' UPDATE_LOCKS # updated hdrs = ' || SQL%ROWCOUNT );
1661
1662 DELETE FROM pji_fm_extr_plnver3_t;
1663 print_time ( ' # of records deleted in plnver3 = ' || SQL%ROWCOUNT );
1664
1665
1666 IF (p_update_mode IS NULL) THEN
1667
1668 OPEN c_get_hdrs_lock_map_cur;
1669 CLOSE c_get_hdrs_lock_map_cur;
1670
1671 update PJI_PJP_WBS_HEADER hd9
1672 set LOCK_FLAG = null,
1673 LAST_UPDATE_DATE = l_last_update_date,
1674 LAST_UPDATED_BY = l_last_updated_by,
1675 LAST_UPDATE_LOGIN = l_last_update_login
1676 where (hd9.PLAN_VERSION_ID > 0 or
1677 hd9.PLAN_VERSION_ID in (-3, -4)) and
1678 exists
1679 (
1680 select
1681 1
1682 from
1683 PJI_PJP_PROJ_BATCH_MAP map
1684 where
1685 map.WORKER_ID = g_worker_id and
1686 hd9.PROJECT_ID = map.PROJECT_ID
1687 );
1688
1689 print_time ( ' UPDATE_LOCKS # additional hdrs updated in unlock hdrs for prg change = ' || SQL%ROWCOUNT );
1690
1691 END IF;
1692
1693
1694 EXCEPTION
1695
1696 WHEN excp_resource_busy THEN
1697
1698 x_return_status := Fnd_Api.G_RET_STS_ERROR;
1699 x_msg_code := Fnd_Message.GET_STRING( APPIN => 'PJI'
1700 , NAMEIN => 'PJI_LOCK_NOT_OBTAINED');
1701
1702 -- PA_UTILS.ADD_MESSAGE( p_app_short_name => 'PJI'
1703 -- , p_msg_name => 'PJI_LOCK_NOT_OBTAINED');
1704 Fnd_Message.SET_NAME('PJI', 'PJI_LOCK_NOT_OBTAINED');
1705 Fnd_Msg_Pub.add_detail(p_message_type=>Fnd_Api.G_RET_STS_ERROR);
1706
1707 print_time ( ' UPDATE_LOCKS exception ' || SQLERRM);
1708
1709 Pji_Pjp_Fp_Curr_Wrap.EXCP_HANDLER
1710 ( p_package_name => g_package_name
1711 , p_procedure_name => ' UPDATE_LOCKS '
1712 , x_return_status => x_return_status ) ;
1713
1714 RAISE;
1715
1716 WHEN OTHERS THEN
1717 PJI_PJP_FP_CURR_WRAP.EXCP_HANDLER
1718 ( p_package_name => g_package_name
1719 , p_procedure_name => ' UPDATE_LOCKS '
1720 , x_return_status => x_return_status ) ;
1721
1722 RAISE;
1723
1724 END;
1725
1726
1727 --
1728 -- Get the budget versions that need to be extracted INTO a temp table.
1729 -- This is to set scope for extraction as well as track time/curr dangling records
1730 -- in the case of secondary slice creation.
1731 --
1732 -- !!!! Add event handler for RBS_PRG.
1733 --
1734 PROCEDURE EXTRACT_FIN_PLAN_VERS_BULK(
1735 p_slice_type IN VARCHAR2 := NULL -- 'PRI' or 'SEC' or 'SECRBS'
1736 ) IS
1737 l_prg_exists varchar2(1) := 'N';
1738 /* Added for bug 8708651 */
1739 l_up_process_flag varchar2(1);
1740 l_profile_check varchar2(30);
1741 l_RBS_ASSOC_exists varchar2(1) := 'Y' ;
1742 l_RBS_PRG_exists varchar2(1) := 'Y' ;
1743 l_PRG_CHANGE_exists varchar2(1) := 'Y';
1744 BEGIN
1745
1746 print_time('EXTRACT_FIN_PLAN_VERS_BULK : Begin ' );
1747
1748 /* Added for bug 8708651 starts */
1749 begin
1750
1751 select 'Y'
1752 into l_RBS_ASSOC_exists
1753 from dual
1754 where exists
1755 ( select 'x'
1756 from pji_pa_proj_events_log
1757 where worker_id = g_worker_id
1758 and event_type = 'RBS_ASSOC'
1759 );
1760
1761 exception
1762
1763 when no_data_found then
1764
1765 l_RBS_ASSOC_exists := 'N';
1766
1767 end;
1768
1769
1770 begin
1771
1772 select 'Y'
1773 into l_RBS_PRG_exists
1774 from dual
1775 where exists
1776 ( select 'x'
1777 from pji_pa_proj_events_log
1778 where worker_id = g_worker_id
1779 and event_type = 'RBS_PRG'
1780 );
1781
1782 exception
1783
1784 when no_data_found then
1785
1786 l_RBS_PRG_exists := 'N';
1787
1788 end;
1789
1790 begin
1791
1792 select 'Y'
1793 into l_PRG_CHANGE_exists
1794 from dual
1795 where exists
1796 ( select 'x'
1797 from pji_pa_proj_events_log
1798 where worker_id = g_worker_id
1799 and event_type = 'PRG_CHANGE'
1800 );
1801
1802 exception
1803
1804 when no_data_found then
1805
1806 l_PRG_CHANGE_exists := 'N';
1807
1808 end;
1809 /* Added for bug 8708651 ends */
1810
1811 IF ( p_slice_type NOT IN ('PRI', 'SEC', 'SECRBS', 'SEC_PROJ', 'SECRBS_PROJ') ) THEN
1812 print_time('EXTRACT_FIN_PLAN_VERSIONS : Invalid slice type. Exitting. ' );
1813 RETURN;
1814 END IF;
1815
1816 /* Added for bug 8708651 starts */
1817 l_profile_check := FND_PROFILE.VALUE('PJI_SUM_CLEANALL');
1818 l_up_process_flag := PJI_UTILS.GET_SETUP_PARAMETER('UP_PROCESS_FLAG');
1819 /* Added for bug 8708651 ends */
1820
1821 --#bug 5356051
1822 begin
1823 select 'Y'
1824 into l_prg_exists
1825 from dual
1826 where exists (
1827 select null
1828 from
1829 pa_proj_element_versions proj
1830 where
1831 proj.prg_group is not null
1832 and rownum <=1
1833 );
1834 exception
1835 when no_data_found then
1836 l_prg_exists := 'N';
1837 end;
1838 --#bug 5356051
1839
1840 IF ( p_slice_type = 'PRI') THEN
1841
1842 if (l_up_process_flag = 'Y') then /* Added for bug 8708651 */
1843
1844 INSERT INTO PJI_FM_EXTR_PLNVER4
1845 (
1846 WORKER_ID ,
1847 PROJECT_ID ,
1848 PLAN_VERSION_ID ,
1849 WBS_STRUCT_VERSION_ID ,
1850 RBS_STRUCT_VERSION_ID ,
1851 PLAN_TYPE_CODE ,
1852 PLAN_TYPE_ID ,
1853 TIME_PHASED_TYPE_CODE ,
1854 TIME_DANGLING_FLAG ,
1855 RATE_DANGLING_FLAG ,
1856 PROJECT_TYPE_CLASS ,
1857 WP_FLAG ,
1858 CURRENT_FLAG ,
1859 ORIGINAL_FLAG ,
1860 CURRENT_ORIGINAL_FLAG ,
1861 BASELINED_FLAG ,
1862 SECONDARY_RBS_FLAG ,
1863 LP_FLAG
1864 )
1865 SELECT
1866 g_worker_id
1867 , bv.project_id project_id
1868 , bv.budget_version_id plan_version_id
1869 , DECODE ( NVL(bv.wp_version_flag, 'N')
1870 , 'Y', bv.project_structure_version_id
1871 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
1872 ) wbs_struct_version_id
1873 , fpo.rbs_version_id rbs_struct_version_id
1874 -- , to_char(fpo.fin_plan_type_id) plan_type_code
1875 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
1876 , fpo.fin_plan_type_id plan_type_id
1877 , DECODE(bv.version_type
1878 , 'ALL', fpo.all_time_phased_code
1879 , 'COST', fpo.cost_time_phased_code
1880 , 'REVENUE', fpo.revenue_time_phased_code
1881 ) time_phased_type_code
1882 , NULL time_dangling_flag -- to be used for dangling check.
1883 , NULL rate_dangling_flag -- to be used for dangling check.
1884 , NULL PROJECT_TYPE_CLASS
1885 , NVL(bv.wp_version_flag, 'N') is_wp_flag
1886 , bv.current_flag current_flag
1887 , bv.original_flag original_flag
1888 , bv.current_original_flag current_original_flag
1889 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
1890 , 'N' SECONDARY_RBS_FLAG
1891 , DECODE( NVL(bv.wp_version_flag, 'N')
1892 , 'Y'
1893 , DECODE(bv.project_structure_version_id
1894 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
1895 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
1896 , 'Y'
1897 , 'N')
1898 , 'N'
1899 ) lp_flag
1900 FROM
1901 pa_budget_versions bv -- @pjdev115 bv
1902 , pa_proj_fp_options fpo -- @pjdev115 fpo
1903 , pa_projects_all ppa -- @pjdev115 ppa
1904 WHERE 1=1
1905 AND ppa.project_id = bv.project_id
1906 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
1907 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
1908 AND fpo.project_id = bv.project_id
1909 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
1910 AND bv.budget_version_id = fpo.fin_plan_version_id
1911 AND bv.fin_plan_type_id = 10 /* Added for bug 8708651*/
1912 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
1913 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
1914 UNION ALL
1915 SELECT
1916 g_worker_id
1917 , bv.project_id project_id
1918 , bv.budget_version_id plan_version_id
1919 , DECODE ( NVL(bv.wp_version_flag, 'N')
1920 , 'Y', bv.project_structure_version_id
1921 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
1922 ) wbs_struct_version_id
1923 , fpo.rbs_version_id rbs_struct_version_id
1924 -- , to_char(fpo.fin_plan_type_id) plan_type_code
1925 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
1926 , fpo.fin_plan_type_id plan_type_id
1927 , DECODE(bv.version_type
1928 , 'ALL', fpo.all_time_phased_code
1929 , 'COST', fpo.cost_time_phased_code
1930 , 'REVENUE', fpo.revenue_time_phased_code
1931 ) time_phased_type_code
1932 , NULL time_dangling_flag -- to be used for dangling check.
1933 , NULL rate_dangling_flag -- to be used for dangling check.
1934 , NULL PROJECT_TYPE_CLASS
1935 , NVL(bv.wp_version_flag, 'N') is_wp_flag
1936 , bv.current_flag current_flag
1937 , bv.original_flag original_flag
1938 , bv.current_original_flag current_original_flag
1939 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
1940 , 'N' SECONDARY_RBS_FLAG
1941 , DECODE( NVL(bv.wp_version_flag, 'N')
1942 , 'Y'
1943 , DECODE(bv.project_structure_version_id
1944 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
1945 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
1946 , 'Y'
1947 , 'N')
1948 , 'N'
1949 ) lp_flag
1950 FROM
1951 pa_budget_versions bv -- @pjdev115 bv
1952 , pa_proj_fp_options fpo -- @pjdev115 fpo
1953 , pa_projects_all ppa -- @pjdev115 ppa
1954 WHERE 1=1
1955 AND ppa.project_id = bv.project_id
1956 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
1957 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
1958 AND fpo.project_id = bv.project_id
1959 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
1960 AND bv.budget_version_id = fpo.fin_plan_version_id
1961 AND bv.fin_plan_type_id <> 10 /* Added for bug 8708651*/
1962 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
1963 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE')
1964 AND (bv.current_flag = 'Y' or bv.current_original_flag = 'Y') /* Added for bug 8708651*/
1965 UNION ALL
1966 SELECT
1967 g_worker_id
1968 , bv.project_id project_id
1969 , bv.budget_version_id plan_version_id
1970 , DECODE ( NVL(bv.wp_version_flag, 'N')
1971 , 'Y', bv.project_structure_version_id
1972 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
1973 ) wbs_struct_version_id
1974 , fpo.rbs_version_id rbs_struct_version_id
1975 -- , to_char(fpo.fin_plan_type_id) plan_type_code
1976 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
1977 , fpo.fin_plan_type_id plan_type_id
1978 , 'N' time_phased_type_code /* Added for bug 8708651*/
1979 , NULL time_dangling_flag -- to be used for dangling check.
1980 , NULL rate_dangling_flag -- to be used for dangling check.
1981 , NULL PROJECT_TYPE_CLASS
1982 , NVL(bv.wp_version_flag, 'N') is_wp_flag
1983 , bv.current_flag current_flag
1984 , bv.original_flag original_flag
1985 , bv.current_original_flag current_original_flag
1986 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
1987 , 'N' SECONDARY_RBS_FLAG
1988 , DECODE( NVL(bv.wp_version_flag, 'N')
1989 , 'Y'
1990 , DECODE(bv.project_structure_version_id
1991 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
1992 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
1993 , 'Y'
1994 , 'N')
1995 , 'N'
1996 ) lp_flag
1997 FROM
1998 pa_budget_versions bv -- @pjdev115 bv
1999 , pa_proj_fp_options fpo -- @pjdev115 fpo
2000 , pa_projects_all ppa -- @pjdev115 ppa
2001 WHERE 1=1
2002 AND ppa.project_id = bv.project_id
2003 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
2004 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
2005 AND fpo.project_id = bv.project_id
2006 AND bv.fin_plan_type_id <> 10 /* Added for bug 8708651*/
2007 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
2008 AND bv.budget_version_id = fpo.fin_plan_version_id
2009 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
2010 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE')
2011 AND (bv.current_flag = 'N' and bv.current_original_flag = 'N') /* Added for bug 8708651*/
2012 ;
2013
2014 else
2015
2016 INSERT INTO PJI_FM_EXTR_PLNVER4
2017 (
2018 WORKER_ID ,
2019 PROJECT_ID ,
2020 PLAN_VERSION_ID ,
2021 WBS_STRUCT_VERSION_ID ,
2022 RBS_STRUCT_VERSION_ID ,
2023 PLAN_TYPE_CODE ,
2024 PLAN_TYPE_ID ,
2025 TIME_PHASED_TYPE_CODE ,
2026 TIME_DANGLING_FLAG ,
2027 RATE_DANGLING_FLAG ,
2028 PROJECT_TYPE_CLASS ,
2029 WP_FLAG ,
2030 CURRENT_FLAG ,
2031 ORIGINAL_FLAG ,
2032 CURRENT_ORIGINAL_FLAG ,
2033 BASELINED_FLAG ,
2034 SECONDARY_RBS_FLAG ,
2035 LP_FLAG
2036 )
2037 SELECT
2038 g_worker_id
2039 , bv.project_id project_id
2040 , bv.budget_version_id plan_version_id
2041 , DECODE ( NVL(bv.wp_version_flag, 'N')
2042 , 'Y', bv.project_structure_version_id
2043 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
2044 ) wbs_struct_version_id
2045 , fpo.rbs_version_id rbs_struct_version_id
2046 -- , to_char(fpo.fin_plan_type_id) plan_type_code
2047 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
2048 , fpo.fin_plan_type_id plan_type_id
2049 , DECODE(bv.version_type
2050 , 'ALL', fpo.all_time_phased_code
2051 , 'COST', fpo.cost_time_phased_code
2052 , 'REVENUE', fpo.revenue_time_phased_code
2053 ) time_phased_type_code
2054 , NULL time_dangling_flag -- to be used for dangling check.
2055 , NULL rate_dangling_flag -- to be used for dangling check.
2056 , NULL PROJECT_TYPE_CLASS
2057 , NVL(bv.wp_version_flag, 'N') is_wp_flag
2058 , bv.current_flag current_flag
2059 , bv.original_flag original_flag
2060 , bv.current_original_flag current_original_flag
2061 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
2062 , 'N' SECONDARY_RBS_FLAG
2063 , DECODE( NVL(bv.wp_version_flag, 'N')
2064 , 'Y'
2065 , DECODE(bv.project_structure_version_id
2066 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
2067 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
2068 , 'Y'
2069 , 'N')
2070 , 'N'
2071 ) lp_flag
2072 FROM
2073 pa_budget_versions bv -- @pjdev115 bv
2074 , pa_proj_fp_options fpo -- @pjdev115 fpo
2075 , pa_projects_all ppa -- @pjdev115 ppa
2076 WHERE 1=1
2077 AND ppa.project_id = bv.project_id
2078 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
2079 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
2080 AND fpo.project_id = bv.project_id
2081 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
2082 AND bv.budget_version_id = fpo.fin_plan_version_id
2083 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
2084 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
2085 ;
2086 end if;
2087
2088 --#bug 5356051
2089 If l_prg_exists = 'Y' then --Programs exist, need to insert -3/-4 for programs as well
2090
2091
2092 INSERT INTO PJI_FM_EXTR_PLNVER4
2093 (
2094 WORKER_ID ,
2095 PROJECT_ID ,
2096 PLAN_VERSION_ID ,
2097 WBS_STRUCT_VERSION_ID ,
2098 RBS_STRUCT_VERSION_ID ,
2099 PLAN_TYPE_CODE ,
2100 PLAN_TYPE_ID ,
2101 TIME_PHASED_TYPE_CODE ,
2102 TIME_DANGLING_FLAG ,
2103 RATE_DANGLING_FLAG ,
2104 PROJECT_TYPE_CLASS ,
2105 WP_FLAG ,
2106 CURRENT_FLAG ,
2107 ORIGINAL_FLAG ,
2108 CURRENT_ORIGINAL_FLAG ,
2109 BASELINED_FLAG ,
2110 SECONDARY_RBS_FLAG ,
2111 LP_FLAG
2112 )
2113 SELECT DISTINCT -- For insertion of -3/-4 header records.
2114 g_worker_id worker_id
2115 , den.sup_project_id project_id
2116 , cbco.plan_version_id plan_version_id
2117 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(den.sup_project_id) wbs_struct_version_id
2118 , hd2.rbs_struct_version_id rbs_version_id
2119 , hd2.plan_type_code plan_type_code /*4471527 */
2120 , hd2.plan_type_id plan_type_id
2121 , hd2.time_phased_type_code time_phased_type_code
2122 , NULL TIME_DANGLING_FLAG
2123 , NULL RATE_DANGLING_FLAG
2124 , NULL PROJECT_TYPE_CLASS
2125 , 'N' is_wp_flag
2126 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') current_flag
2127 , NULL original_flag
2128 , DECODE(cbco.plan_version_id, -4, 'Y', 'N') current_original_flag
2129 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') baselined_flag
2130 , 'Y' SECONDARY_RBS_FLAG
2131 , 'Y' lp_flag
2132 FROM
2133 pji_fm_extr_plnver4 hd2 -- sub
2134 , pji_xbs_denorm den
2135 , ( SELECT -3 plan_version_id FROM dual
2136 UNION ALL
2137 SELECT -4 plan_version_id FROM dual ) cbco
2138 WHERE
2139 hd2.baselined_flag = 'Y'
2140 AND hd2.wp_flag = 'N'
2141 AND hd2.worker_id = g_worker_id
2142 AND den.struct_version_id IS NULL
2143 AND hd2.wbs_struct_version_id = den.sub_id
2144 AND den.struct_type = 'PRG'
2145 AND NVL(den.relationship_type, 'WF') IN ('LF', 'WF');
2146
2147 elsif l_prg_exists = 'N' then
2148
2149 INSERT INTO PJI_FM_EXTR_PLNVER4
2150 (
2151 WORKER_ID ,
2152 PROJECT_ID ,
2153 PLAN_VERSION_ID ,
2154 WBS_STRUCT_VERSION_ID ,
2155 RBS_STRUCT_VERSION_ID ,
2156 PLAN_TYPE_CODE ,
2157 PLAN_TYPE_ID ,
2158 TIME_PHASED_TYPE_CODE ,
2159 TIME_DANGLING_FLAG ,
2160 RATE_DANGLING_FLAG ,
2161 PROJECT_TYPE_CLASS ,
2162 WP_FLAG ,
2163 CURRENT_FLAG ,
2164 ORIGINAL_FLAG ,
2165 CURRENT_ORIGINAL_FLAG ,
2166 BASELINED_FLAG ,
2167 SECONDARY_RBS_FLAG ,
2168 LP_FLAG
2169 )
2170 SELECT DISTINCT -- For insertion of -3/-4 header records.
2171 g_worker_id worker_id
2172 , hd2.project_id project_id
2173 , cbco.plan_version_id plan_version_id
2174 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(hd2.project_id) wbs_struct_version_id
2175 , hd2.rbs_struct_version_id rbs_version_id
2176 , hd2.plan_type_code plan_type_code /*4471527 */
2177 , hd2.plan_type_id plan_type_id
2178 , hd2.time_phased_type_code time_phased_type_code
2179 , NULL TIME_DANGLING_FLAG
2180 , NULL RATE_DANGLING_FLAG
2181 , NULL PROJECT_TYPE_CLASS
2182 , 'N' is_wp_flag
2183 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') current_flag
2184 , NULL original_flag
2185 , DECODE(cbco.plan_version_id, -4, 'Y', 'N') current_original_flag
2186 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') baselined_flag
2187 , 'Y' SECONDARY_RBS_FLAG
2188 , 'Y' lp_flag
2189 FROM
2190 pji_fm_extr_plnver4 hd2 -- sub
2191 , ( SELECT -3 plan_version_id FROM dual
2192 UNION ALL
2193 SELECT -4 plan_version_id FROM dual ) cbco
2194 WHERE
2195 hd2.baselined_flag = 'Y'
2196 AND hd2.wp_flag = 'N'
2197 AND hd2.worker_id = g_worker_id;
2198
2199 end if;
2200 --#bug 5356051
2201
2202
2203 ELSIF ( p_slice_type = 'SEC') THEN
2204
2205 INSERT INTO PJI_FM_EXTR_PLNVER4
2206 (
2207 WORKER_ID ,
2208 PROJECT_ID ,
2209 PLAN_VERSION_ID ,
2210 WBS_STRUCT_VERSION_ID ,
2211 RBS_STRUCT_VERSION_ID ,
2212 PLAN_TYPE_CODE ,
2213 PLAN_TYPE_ID ,
2214 TIME_PHASED_TYPE_CODE ,
2215 TIME_DANGLING_FLAG ,
2216 RATE_DANGLING_FLAG ,
2217 PROJECT_TYPE_CLASS ,
2218 WP_FLAG ,
2219 CURRENT_FLAG ,
2220 ORIGINAL_FLAG ,
2221 CURRENT_ORIGINAL_FLAG ,
2222 BASELINED_FLAG ,
2223 SECONDARY_RBS_FLAG ,
2224 LP_FLAG
2225 )
2226 SELECT
2227 g_worker_id
2228 , bv.project_id project_id
2229 , bv.budget_version_id plan_version_id
2230 , DECODE ( NVL(bv.wp_version_flag, 'N')
2231 , 'Y', bv.project_structure_version_id
2232 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
2233 ) wbs_struct_version_id
2234 , fpo.rbs_version_id rbs_struct_version_id
2235 -- , to_char(fpo.fin_plan_type_id) plan_type_code
2236 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
2237 , fpo.fin_plan_type_id plan_type_id
2238 , DECODE(bv.version_type
2239 , 'ALL', fpo.all_time_phased_code
2240 , 'COST', fpo.cost_time_phased_code
2241 , 'REVENUE', fpo.revenue_time_phased_code
2242 ) time_phased_type_code
2243 , NULL time_dangling_flag -- to be used for dangling check.
2244 , NULL rate_dangling_flag -- to be used for dangling check.
2245 , NULL PROJECT_TYPE_CLASS
2246 , NVL(bv.wp_version_flag, 'N') is_wp_flag
2247 , bv.current_flag current_flag
2248 , bv.original_flag original_flag
2249 , bv.current_original_flag current_original_flag
2250 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
2251 , 'N' SECONDARY_RBS_FLAG
2252 , DECODE( NVL(bv.wp_version_flag, 'N')
2253 , 'Y'
2254 , DECODE(bv.project_structure_version_id
2255 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
2256 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
2257 , 'Y'
2258 , 'N')
2259 , 'N'
2260 ) lp_flag
2261 FROM
2262 pa_budget_versions bv -- @pjdev115 bv
2263 , pa_proj_fp_options fpo -- @pjdev115 fpo
2264 , pa_projects_all ppa -- @pjdev115 ppa
2265 WHERE 1=1
2266 AND ppa.project_id = bv.project_id
2267 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
2268 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
2269 AND fpo.project_id = bv.project_id
2270 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
2271 AND bv.budget_version_id = fpo.fin_plan_version_id
2272 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
2273 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
2274 AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
2275 AND bv.budget_status_code = 'B'
2276 AND NVL(bv.wp_version_flag, 'N') = 'N';
2277
2278
2279 ELSIF ( p_slice_type = 'SECRBS') THEN
2280
2281 INSERT INTO PJI_FM_EXTR_PLNVER4
2282 (
2283 WORKER_ID ,
2284 PROJECT_ID ,
2285 PLAN_VERSION_ID ,
2286 WBS_STRUCT_VERSION_ID ,
2287 RBS_STRUCT_VERSION_ID ,
2288 PLAN_TYPE_CODE ,
2289 PLAN_TYPE_ID ,
2290 TIME_PHASED_TYPE_CODE ,
2291 TIME_DANGLING_FLAG ,
2292 RATE_DANGLING_FLAG ,
2293 PROJECT_TYPE_CLASS ,
2294 WP_FLAG ,
2295 CURRENT_FLAG ,
2296 ORIGINAL_FLAG ,
2297 CURRENT_ORIGINAL_FLAG ,
2298 BASELINED_FLAG ,
2299 SECONDARY_RBS_FLAG ,
2300 LP_FLAG
2301 )
2302 SELECT
2303 g_worker_id
2304 , bv.project_id project_id
2305 , bv.budget_version_id plan_version_id
2306 , DECODE ( NVL(bv.wp_version_flag, 'N')
2307 , 'Y', bv.project_structure_version_id
2308 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
2309 ) wbs_struct_version_id
2310 , rpa.rbs_version_id rbs_struct_version_id
2311 -- , fpo.rbs_version_id rbs_struct_version_id
2312 -- , to_char(fpo.fin_plan_type_id) plan_type_code
2313 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
2314 , fpo.fin_plan_type_id plan_type_id
2315 , DECODE(bv.version_type
2316 , 'ALL', fpo.all_time_phased_code
2317 , 'COST', fpo.cost_time_phased_code
2318 , 'REVENUE', fpo.revenue_time_phased_code
2319 ) time_phased_type_code
2320 , NULL time_dangling_flag -- to be used for dangling check.
2321 , NULL rate_dangling_flag -- to be used for dangling check.
2322 , NULL PROJECT_TYPE_CLASS
2323 , NVL(bv.wp_version_flag, 'N') is_wp_flag
2324 , bv.current_flag current_flag
2325 , bv.original_flag original_flag
2326 , bv.current_original_flag current_original_flag
2327 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
2328 , 'Y' SECONDARY_RBS_FLAG
2329 , DECODE( NVL(bv.wp_version_flag, 'N')
2330 , 'Y'
2331 , DECODE(bv.project_structure_version_id
2332 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
2333 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
2334 , 'Y'
2335 , 'N')
2336 , 'N'
2337 ) lp_flag
2338 FROM
2339 pa_budget_versions bv -- @pjdev115 bv
2340 , pa_proj_fp_options fpo -- @pjdev115 fpo
2341 , pa_projects_all ppa -- @pjdev115 ppa
2342 , PA_RBS_PRJ_ASSIGNMENTS rpa
2343 WHERE 1=1
2344 AND ppa.project_id = bv.project_id
2345 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
2346 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
2347 AND fpo.project_id = bv.project_id
2348 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
2349 AND bv.budget_version_id = fpo.fin_plan_version_id
2350 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
2351 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
2352 AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
2353 AND bv.budget_status_code = 'B'
2354 AND rpa.project_id = bv.project_id
2355 -- AND DECODE ( rpa.wp_usage_flag, 'Y', 'Y', 'X') = NVL(bv.wp_version_flag, 'N')
2356 -- AND DECODE ( rpa.fp_usage_flag, 'Y', 'N', 'X') = NVL(bv.wp_version_flag, 'N')
2357 AND rpa.assignment_status = 'ACTIVE'
2358 AND NVL(fpo.rbs_version_id, -1) <> rpa.rbs_version_id
2359 AND NVL(bv.wp_version_flag, 'N') = 'N'
2360 AND rpa.reporting_usage_flag = 'Y';
2361
2362 /*Plans are restricted by the projects chosen by the user*/
2363
2364 ELSIF ( p_slice_type = 'SEC_PROJ') THEN
2365
2366 if (upper(nvl(l_profile_check, 'N')) = 'Y') then /* Added for bug 8708651 */
2367
2368 INSERT INTO PJI_FM_EXTR_PLNVER4
2369 (
2370 WORKER_ID ,
2371 PROJECT_ID ,
2372 PLAN_VERSION_ID ,
2373 WBS_STRUCT_VERSION_ID ,
2374 RBS_STRUCT_VERSION_ID ,
2375 PLAN_TYPE_CODE ,
2376 PLAN_TYPE_ID ,
2377 TIME_PHASED_TYPE_CODE ,
2378 TIME_DANGLING_FLAG ,
2379 RATE_DANGLING_FLAG ,
2380 PROJECT_TYPE_CLASS ,
2381 WP_FLAG ,
2382 CURRENT_FLAG ,
2383 ORIGINAL_FLAG ,
2384 CURRENT_ORIGINAL_FLAG ,
2385 BASELINED_FLAG ,
2386 SECONDARY_RBS_FLAG ,
2387 LP_FLAG
2388 )
2389 SELECT /*+ ordered use_nl( map bv ppa fpo ) */
2390 g_worker_id
2391 , bv.project_id project_id
2392 , bv.budget_version_id plan_version_id
2393 , DECODE ( NVL(bv.wp_version_flag, 'N')
2394 , 'Y', bv.project_structure_version_id
2395 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
2396 ) wbs_struct_version_id
2397 , fpo.rbs_version_id rbs_struct_version_id
2398 -- , to_char(fpo.fin_plan_type_id) plan_type_code
2399 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
2400 , fpo.fin_plan_type_id plan_type_id
2401 , DECODE(bv.version_type
2402 , 'ALL', fpo.all_time_phased_code
2403 , 'COST', fpo.cost_time_phased_code
2404 , 'REVENUE', fpo.revenue_time_phased_code
2405 ) time_phased_type_code
2406 , NULL time_dangling_flag -- to be used for dangling check.
2407 , NULL rate_dangling_flag -- to be used for dangling check.
2408 , NULL PROJECT_TYPE_CLASS
2409 , NVL(bv.wp_version_flag, 'N') is_wp_flag
2410 , bv.current_flag current_flag
2411 , bv.original_flag original_flag
2412 , bv.current_original_flag current_original_flag
2413 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
2414 , 'N' SECONDARY_RBS_FLAG
2415 , DECODE( NVL(bv.wp_version_flag, 'N')
2416 , 'Y'
2417 , DECODE(bv.project_structure_version_id
2418 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
2419 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
2420 , 'Y'
2421 , 'N')
2422 , 'N'
2423 ) lp_flag
2424 FROM
2425 pji_pjp_proj_batch_map map
2426 , pa_budget_versions bv -- @pjdev115 bv
2427 , pa_projects_all ppa -- @pjdev115 ppa
2428 , pa_proj_fp_options fpo -- @pjdev115 fpo
2429 WHERE 1=1
2430 AND ppa.project_id = bv.project_id
2431 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
2432 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
2433 AND fpo.project_id = bv.project_id
2434 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
2435 AND bv.budget_version_id = fpo.fin_plan_version_id
2436 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
2437 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
2438 AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
2439 AND bv.budget_status_code = 'B'
2440 AND NVL(bv.wp_version_flag, 'N') = 'N'
2441 AND ppa.project_id = map.project_id
2442 AND map.worker_id = g_worker_id
2443 AND (bv.current_flag = 'Y' or bv.current_original_flag = 'Y') /* Added for bug 8708651 */
2444 UNION ALL
2445 SELECT /*+ ordered use_nl( map bv ppa fpo ) */
2446 g_worker_id
2447 , bv.project_id project_id
2448 , bv.budget_version_id plan_version_id
2449 , DECODE ( NVL(bv.wp_version_flag, 'N')
2450 , 'Y', bv.project_structure_version_id
2451 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
2452 ) wbs_struct_version_id
2453 , fpo.rbs_version_id rbs_struct_version_id
2454 -- , to_char(fpo.fin_plan_type_id) plan_type_code
2455 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
2456 , fpo.fin_plan_type_id plan_type_id
2457 , 'N' time_phased_type_code
2458 , NULL time_dangling_flag -- to be used for dangling check.
2459 , NULL rate_dangling_flag -- to be used for dangling check.
2460 , NULL PROJECT_TYPE_CLASS
2461 , NVL(bv.wp_version_flag, 'N') is_wp_flag
2462 , bv.current_flag current_flag
2463 , bv.original_flag original_flag
2464 , bv.current_original_flag current_original_flag
2465 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
2466 , 'N' SECONDARY_RBS_FLAG
2467 , DECODE( NVL(bv.wp_version_flag, 'N')
2468 , 'Y'
2469 , DECODE(bv.project_structure_version_id
2470 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
2471 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
2472 , 'Y'
2473 , 'N')
2474 , 'N'
2475 ) lp_flag
2476 FROM
2477 pji_pjp_proj_batch_map map
2478 , pa_budget_versions bv -- @pjdev115 bv
2479 , pa_projects_all ppa -- @pjdev115 ppa
2480 , pa_proj_fp_options fpo -- @pjdev115 fpo
2481 WHERE 1=1
2482 AND ppa.project_id = bv.project_id
2483 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
2484 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
2485 AND fpo.project_id = bv.project_id
2486 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
2487 AND bv.budget_version_id = fpo.fin_plan_version_id
2488 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
2489 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
2490 AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
2491 AND bv.budget_status_code = 'B'
2492 AND NVL(bv.wp_version_flag, 'N') = 'N'
2493 AND ppa.project_id = map.project_id
2494 AND map.worker_id = g_worker_id
2495 AND (bv.current_flag = 'N' AND bv.current_original_flag = 'N') /* Added for bug 8708651 */
2496 UNION ALL
2497 SELECT /*+ ordered use_nl( map bv fpo ) */
2498 g_worker_id
2499 , bv.project_id project_id
2500 , cbco.plan_version_id plan_version_id
2501 , DECODE ( NVL(bv.wp_version_flag, 'N')
2502 , 'Y', bv.project_structure_version_id
2503 , Pa_Project_Structure_Utils.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
2504 ) wbs_struct_version_id
2505 , fpo.rbs_version_id rbs_struct_version_id
2506 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
2507 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
2508 , fpo.fin_plan_type_id plan_type_id
2509 , DECODE(bv.version_type
2510 , 'ALL', fpo.all_time_phased_code
2511 , 'COST', fpo.cost_time_phased_code
2512 , 'REVENUE', fpo.revenue_time_phased_code
2513 ) time_phased_type_code
2514 , NULL time_dangling_flag -- to be used for dangling check.
2515 , NULL rate_dangling_flag -- to be used for dangling check.
2516 , NULL PROJECT_TYPE_CLASS
2517 , NVL(bv.wp_version_flag, 'N') is_wp_flag
2518 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') current_flag
2519 , bv.original_flag original_flag
2520 , DECODE(cbco.plan_version_id, -4, 'Y', 'N') current_original_flag
2521 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') baselined_flag
2522 , 'N' SECONDARY_RBS_FLAG
2523 , DECODE( NVL(bv.wp_version_flag, 'N')
2524 , 'Y'
2525 , DECODE(bv.project_structure_version_id
2526 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
2527 -- , Pa_Project_Structure_Utils.GET_FIN_STRUC_VER_ID(bv.project_id)
2528 , 'Y'
2529 , 'N')
2530 , 'N'
2531 ) lp_flag
2532 FROM
2533 pji_pjp_proj_batch_map map
2534 , pa_budget_versions bv
2535 , pa_proj_fp_options fpo
2536 , ( SELECT -3 plan_version_id FROM dual
2537 UNION ALL
2538 SELECT -4 plan_version_id FROM dual ) cbco
2539 WHERE 1=1
2540 AND bv.project_id = map.project_id
2541 AND map.worker_id = g_worker_id
2542 AND bv.version_type IS NOT NULL -- COST, REVENUE, etc. Should not be null.
2543 AND bv.fin_plan_type_id IS NOT NULL -- Old budgets model data is not picked up with this condition.
2544 AND fpo.project_id = bv.project_id
2545 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
2546 AND bv.budget_version_id = fpo.fin_plan_version_id
2547 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
2548 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
2549 AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
2550 AND bv.budget_status_code = 'B'
2551 AND NVL(bv.wp_version_flag, 'N') = 'N';
2552
2553 else
2554
2555 INSERT INTO PJI_FM_EXTR_PLNVER4
2556 (
2557 WORKER_ID ,
2558 PROJECT_ID ,
2559 PLAN_VERSION_ID ,
2560 WBS_STRUCT_VERSION_ID ,
2561 RBS_STRUCT_VERSION_ID ,
2562 PLAN_TYPE_CODE ,
2563 PLAN_TYPE_ID ,
2564 TIME_PHASED_TYPE_CODE ,
2565 TIME_DANGLING_FLAG ,
2566 RATE_DANGLING_FLAG ,
2567 PROJECT_TYPE_CLASS ,
2568 WP_FLAG ,
2569 CURRENT_FLAG ,
2570 ORIGINAL_FLAG ,
2571 CURRENT_ORIGINAL_FLAG ,
2572 BASELINED_FLAG ,
2573 SECONDARY_RBS_FLAG ,
2574 LP_FLAG
2575 )
2576 SELECT /*+ ordered use_nl( map bv ppa fpo ) */
2577 g_worker_id
2578 , bv.project_id project_id
2579 , bv.budget_version_id plan_version_id
2580 , DECODE ( NVL(bv.wp_version_flag, 'N')
2581 , 'Y', bv.project_structure_version_id
2582 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
2583 ) wbs_struct_version_id
2584 , fpo.rbs_version_id rbs_struct_version_id
2585 -- , to_char(fpo.fin_plan_type_id) plan_type_code
2586 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
2587 , fpo.fin_plan_type_id plan_type_id
2588 , DECODE(bv.version_type
2589 , 'ALL', fpo.all_time_phased_code
2590 , 'COST', fpo.cost_time_phased_code
2591 , 'REVENUE', fpo.revenue_time_phased_code
2592 ) time_phased_type_code
2593 , NULL time_dangling_flag -- to be used for dangling check.
2594 , NULL rate_dangling_flag -- to be used for dangling check.
2595 , NULL PROJECT_TYPE_CLASS
2596 , NVL(bv.wp_version_flag, 'N') is_wp_flag
2597 , bv.current_flag current_flag
2598 , bv.original_flag original_flag
2599 , bv.current_original_flag current_original_flag
2600 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
2601 , 'N' SECONDARY_RBS_FLAG
2602 , DECODE( NVL(bv.wp_version_flag, 'N')
2603 , 'Y'
2604 , DECODE(bv.project_structure_version_id
2605 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
2606 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
2607 , 'Y'
2608 , 'N')
2609 , 'N'
2610 ) lp_flag
2611 FROM
2612 pji_pjp_proj_batch_map map
2613 , pa_budget_versions bv -- @pjdev115 bv
2614 , pa_projects_all ppa -- @pjdev115 ppa
2615 , pa_proj_fp_options fpo -- @pjdev115 fpo
2616 WHERE 1=1
2617 AND ppa.project_id = bv.project_id
2618 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
2619 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
2620 AND fpo.project_id = bv.project_id
2621 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
2622 AND bv.budget_version_id = fpo.fin_plan_version_id
2623 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
2624 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
2625 AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
2626 AND bv.budget_status_code = 'B'
2627 AND NVL(bv.wp_version_flag, 'N') = 'N'
2628 AND ppa.project_id = map.project_id
2629 AND map.worker_id = g_worker_id
2630 UNION ALL
2631 SELECT /*+ ordered use_nl( map bv fpo ) */
2632 g_worker_id
2633 , bv.project_id project_id
2634 , cbco.plan_version_id plan_version_id
2635 , DECODE ( NVL(bv.wp_version_flag, 'N')
2636 , 'Y', bv.project_structure_version_id
2637 , Pa_Project_Structure_Utils.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
2638 ) wbs_struct_version_id
2639 , fpo.rbs_version_id rbs_struct_version_id
2640 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
2641 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
2642 , fpo.fin_plan_type_id plan_type_id
2643 , DECODE(bv.version_type
2644 , 'ALL', fpo.all_time_phased_code
2645 , 'COST', fpo.cost_time_phased_code
2646 , 'REVENUE', fpo.revenue_time_phased_code
2647 ) time_phased_type_code
2648 , NULL time_dangling_flag -- to be used for dangling check.
2649 , NULL rate_dangling_flag -- to be used for dangling check.
2650 , NULL PROJECT_TYPE_CLASS
2651 , NVL(bv.wp_version_flag, 'N') is_wp_flag
2652 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') current_flag
2653 , bv.original_flag original_flag
2654 , DECODE(cbco.plan_version_id, -4, 'Y', 'N') current_original_flag
2655 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') baselined_flag
2656 , 'N' SECONDARY_RBS_FLAG
2657 , DECODE( NVL(bv.wp_version_flag, 'N')
2658 , 'Y'
2659 , DECODE(bv.project_structure_version_id
2660 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
2661 -- , Pa_Project_Structure_Utils.GET_FIN_STRUC_VER_ID(bv.project_id)
2662 , 'Y'
2663 , 'N')
2664 , 'N'
2665 ) lp_flag
2666 FROM
2667 pji_pjp_proj_batch_map map
2668 , pa_budget_versions bv
2669 , pa_proj_fp_options fpo
2670 , ( SELECT -3 plan_version_id FROM dual
2671 UNION ALL
2672 SELECT -4 plan_version_id FROM dual ) cbco
2673 WHERE 1=1
2674 AND bv.project_id = map.project_id
2675 AND map.worker_id = g_worker_id
2676 AND bv.version_type IS NOT NULL -- COST, REVENUE, etc. Should not be null.
2677 AND bv.fin_plan_type_id IS NOT NULL -- Old budgets model data is not picked up with this condition.
2678 AND fpo.project_id = bv.project_id
2679 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
2680 AND bv.budget_version_id = fpo.fin_plan_version_id
2681 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
2682 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
2683 AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
2684 AND bv.budget_status_code = 'B'
2685 AND NVL(bv.wp_version_flag, 'N') = 'N';
2686
2687 end if;
2688
2689 ELSIF ( p_slice_type = 'SECRBS_PROJ') THEN
2690
2691 if (upper(nvl(l_profile_check, 'N')) = 'Y') then /* Added for bug 8708651 */
2692
2693 INSERT INTO PJI_FM_EXTR_PLNVER4
2694 (
2695 WORKER_ID ,
2696 PROJECT_ID ,
2697 PLAN_VERSION_ID ,
2698 WBS_STRUCT_VERSION_ID ,
2699 RBS_STRUCT_VERSION_ID ,
2700 PLAN_TYPE_CODE ,
2701 PLAN_TYPE_ID ,
2702 TIME_PHASED_TYPE_CODE ,
2703 TIME_DANGLING_FLAG ,
2704 RATE_DANGLING_FLAG ,
2705 PROJECT_TYPE_CLASS ,
2706 WP_FLAG ,
2707 CURRENT_FLAG ,
2708 ORIGINAL_FLAG ,
2709 CURRENT_ORIGINAL_FLAG ,
2710 BASELINED_FLAG ,
2711 SECONDARY_RBS_FLAG ,
2712 LP_FLAG
2713 )
2714 SELECT DISTINCT
2715 g_worker_id ,
2716 PROJECT_ID ,
2717 PLAN_VERSION_ID ,
2718 WBS_STRUCT_VERSION_ID ,
2719 RBS_STRUCT_VERSION_ID ,
2720 PLAN_TYPE_CODE ,
2721 PLAN_TYPE_ID ,
2722 TIME_PHASED_TYPE_CODE ,
2723 NULL TIME_DANGLING_FLAG ,
2724 NULL RATE_DANGLING_FLAG ,
2725 NULL PROJECT_TYPE_CLASS ,
2726 WP_FLAG ,
2727 CURRENT_FLAG ,
2728 ORIGINAL_FLAG ,
2729 CURRENT_ORIGINAL_FLAG ,
2730 BASELINED_FLAG ,
2731 SECONDARY_RBS_FLAG ,
2732 LP_FLAG
2733 FROM
2734 (
2735 SELECT /*+ ordered use_nl( map bv ppa fpo rpa ) */
2736 bv.project_id project_id
2737 , bv.budget_version_id plan_version_id
2738 , DECODE ( NVL(bv.wp_version_flag, 'N')
2739 , 'Y', bv.project_structure_version_id
2740 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
2741 ) wbs_struct_version_id
2742 , rpa.rbs_version_id rbs_struct_version_id
2743 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
2744 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
2745 , fpo.fin_plan_type_id plan_type_id
2746 , DECODE(bv.version_type
2747 , 'ALL', fpo.all_time_phased_code
2748 , 'COST', fpo.cost_time_phased_code
2749 , 'REVENUE', fpo.revenue_time_phased_code
2750 ) time_phased_type_code
2751
2752
2753
2754 , NVL(bv.wp_version_flag, 'N') wp_flag
2755 , bv.current_flag current_flag
2756 , bv.original_flag original_flag
2757 , bv.current_original_flag current_original_flag
2758 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
2759 , 'Y' SECONDARY_RBS_FLAG
2760 , DECODE( NVL(bv.wp_version_flag, 'N')
2761 , 'Y'
2762 , DECODE(bv.project_structure_version_id
2763 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
2764 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
2765 , 'Y'
2766 , 'N')
2767 , 'N'
2768 ) lp_flag
2769 FROM
2770 pji_pjp_proj_batch_map map
2771 , pa_budget_versions bv
2772 /* Commented for bug 13030627 , pa_projects_all ppa -- @pjdev115 ppa */
2773 , pa_proj_fp_options fpo
2774 , PA_RBS_PRJ_ASSIGNMENTS rpa
2775 WHERE map.project_id = bv.project_id /* Added for bug 13030627 */
2776 AND bv.version_type IS NOT NULL
2777 AND bv.fin_plan_type_id IS NOT NULL
2778 AND fpo.project_id = bv.project_id
2779 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
2780 AND bv.budget_version_id = fpo.fin_plan_version_id
2781 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
2782 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
2783 AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
2784 AND bv.budget_status_code = 'B'
2785 AND rpa.project_id = bv.project_id
2786 AND rpa.assignment_status = 'ACTIVE'
2787 AND NVL(fpo.rbs_version_id, -1) <> rpa.rbs_version_id
2788 AND NVL(bv.wp_version_flag, 'N') = 'N'
2789 AND rpa.reporting_usage_flag = 'Y'
2790 /* Commented for bug 13030627 AND ppa.project_id = map.project_id */
2791 AND map.worker_id = g_worker_id
2792 AND (bv.current_flag = 'Y' or bv.current_original_flag = 'Y') /* Added for bug 8708651 */
2793 UNION ALL
2794 SELECT /*+ ordered use_nl( map bv ppa fpo rpa ) */
2795 bv.project_id project_id
2796 , bv.budget_version_id plan_version_id
2797 , DECODE ( NVL(bv.wp_version_flag, 'N')
2798 , 'Y', bv.project_structure_version_id
2799 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
2800 ) wbs_struct_version_id
2801 , rpa.rbs_version_id rbs_struct_version_id
2802 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
2803 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
2804 , fpo.fin_plan_type_id plan_type_id
2805 , 'N' time_phased_type_code
2806
2807
2808
2809 , NVL(bv.wp_version_flag, 'N') wp_flag
2810 , bv.current_flag current_flag
2811 , bv.original_flag original_flag
2812 , bv.current_original_flag current_original_flag
2813 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
2814 , 'Y' SECONDARY_RBS_FLAG
2815 , DECODE( NVL(bv.wp_version_flag, 'N')
2816 , 'Y'
2817 , DECODE(bv.project_structure_version_id
2818 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
2819 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
2820 , 'Y'
2821 , 'N')
2822 , 'N'
2823 ) lp_flag
2824 FROM
2825 pji_pjp_proj_batch_map map
2826 , pa_budget_versions bv -- @pjdev115 bv
2827 , pa_projects_all ppa -- @pjdev115 ppa
2828 , pa_proj_fp_options fpo -- @pjdev115 fpo
2829 , PA_RBS_PRJ_ASSIGNMENTS rpa
2830 WHERE ppa.project_id = bv.project_id
2831 AND bv.version_type IS NOT NULL
2832 AND bv.fin_plan_type_id IS NOT NULL
2833 AND fpo.project_id = bv.project_id
2834 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
2835 AND bv.budget_version_id = fpo.fin_plan_version_id
2836 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
2837 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
2838 AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
2839 AND bv.budget_status_code = 'B'
2840 AND rpa.project_id = bv.project_id
2841 AND rpa.assignment_status = 'ACTIVE'
2842 AND NVL(fpo.rbs_version_id, -1) <> rpa.rbs_version_id
2843 AND NVL(bv.wp_version_flag, 'N') = 'N'
2844 AND rpa.reporting_usage_flag = 'Y'
2845 AND ppa.project_id = map.project_id
2846 AND map.worker_id = g_worker_id
2847 AND (bv.current_flag = 'N' AND bv.current_original_flag = 'N') /* Added for bug 8708651 */
2848 UNION ALL
2849 SELECT /*+ ordered use_nl( map bv fpo rpa ) */
2850 bv.project_id project_id
2851 , cbco.plan_version_id plan_version_id
2852 , DECODE ( NVL(bv.wp_version_flag, 'N')
2853 , 'Y', bv.project_structure_version_id
2854 , Pa_Project_Structure_Utils.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
2855 ) wbs_struct_version_id
2856 , rpa.rbs_version_id rbs_struct_version_id
2857 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
2858 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
2859 , fpo.fin_plan_type_id plan_type_id
2860 , DECODE(bv.version_type
2861 , 'ALL', fpo.all_time_phased_code
2862 , 'COST', fpo.cost_time_phased_code
2863 , 'REVENUE', fpo.revenue_time_phased_code
2864 ) time_phased_type_code
2865 , NVL(bv.wp_version_flag, 'N') wp_flag
2866 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') current_flag
2867 , bv.original_flag original_flag
2868 , DECODE(cbco.plan_version_id, -4, 'Y', 'N') current_original_flag
2869 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') baselined_flag
2870 , 'Y' SECONDARY_RBS_FLAG
2871 , DECODE( NVL(bv.wp_version_flag, 'N')
2872 , 'Y'
2873 , DECODE(bv.project_structure_version_id
2874 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
2875 -- , Pa_Project_Structure_Utils.GET_FIN_STRUC_VER_ID(bv.project_id)
2876 , 'Y'
2877 , 'N')
2878 , 'N'
2879 ) lp_flag
2880 FROM
2881 pji_pjp_proj_batch_map map
2882 , pji_pa_proj_events_log ev
2883 , pa_budget_versions bv -- @pjdev115 bv
2884 , pa_proj_fp_options fpo -- @pjdev115 fpo
2885 -- , pa_projects_all ppa -- @pjdev115 ppa
2886 , PA_RBS_PRJ_ASSIGNMENTS rpa
2887 , ( SELECT -3 plan_version_id FROM dual
2888 UNION ALL
2889 SELECT -4 plan_version_id FROM dual ) cbco
2890 WHERE map.project_id = bv.project_id
2891 AND bv.version_type IS NOT NULL
2892 AND bv.fin_plan_type_id IS NOT NULL
2893 AND fpo.project_id = bv.project_id
2894 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
2895 AND bv.budget_version_id = fpo.fin_plan_version_id
2896 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
2897 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
2898 AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
2899 AND bv.budget_status_code = 'B'
2900 AND rpa.project_id = bv.project_id
2901 AND rpa.assignment_status = 'ACTIVE'
2902 AND NVL(fpo.rbs_version_id, -1) <> rpa.rbs_version_id
2903 AND NVL(bv.wp_version_flag, 'N') = 'N'
2904 AND rpa.reporting_usage_flag = 'Y'
2905 AND map.worker_id = g_worker_id
2906 UNION ALL
2907 SELECT /*+ ordered use_nl( ev rpa bv fpo ppa map ) */ -- 'RBS_ASSOC'
2908 bv.project_id project_id
2909 , bv.budget_version_id plan_version_id
2910 , DECODE ( NVL(bv.wp_version_flag, 'N')
2911 , 'Y', bv.project_structure_version_id
2912 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
2913 ) wbs_struct_version_id
2914 , rpa.rbs_version_id rbs_struct_version_id
2915 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
2916 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
2917 , fpo.fin_plan_type_id plan_type_id
2918 , DECODE(bv.version_type
2919 , 'ALL', fpo.all_time_phased_code
2920 , 'COST', fpo.cost_time_phased_code
2921 , 'REVENUE', fpo.revenue_time_phased_code
2922 ) time_phased_type_code
2923
2924
2925
2926 , NVL(bv.wp_version_flag, 'N') is_wp_flag
2927 , bv.current_flag current_flag
2928 , bv.original_flag original_flag
2929 , bv.current_original_flag current_original_flag
2930 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
2931 , 'Y' SECONDARY_RBS_FLAG
2932 , DECODE( NVL(bv.wp_version_flag, 'N')
2933 , 'Y'
2934 , DECODE(bv.project_structure_version_id
2935 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
2936 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
2937 , 'Y'
2938 , 'N')
2939 , 'N'
2940 ) lp_flag
2941 FROM
2942 pji_pa_proj_events_log ev
2943 , PA_RBS_PRJ_ASSIGNMENTS rpa
2944 , pa_budget_versions bv -- @pjdev115 bv
2945 , pa_proj_fp_options fpo -- @pjdev115 fpo
2946 , pa_projects_all ppa -- @pjdev115 ppa
2947 , pji_pjp_proj_batch_map map
2948 WHERE l_RBS_ASSOC_exists = 'Y' /* Added for bug 8708651 */
2949 AND ppa.project_id = bv.project_id
2950 AND bv.version_type IS NOT NULL
2951 AND bv.fin_plan_type_id IS NOT NULL
2952 AND fpo.project_id = bv.project_id
2953 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
2954 AND bv.budget_version_id = fpo.fin_plan_version_id
2955 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION'
2956 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE')
2957 AND bv.pji_summarized_flag = 'Y'
2958 AND bv.budget_status_code = 'B'
2959 AND rpa.project_id = bv.project_id
2960 AND rpa.assignment_status = 'ACTIVE'
2961 AND NVL(fpo.rbs_version_id, -1) <> rpa.rbs_version_id
2962 AND NVL(bv.wp_version_flag, 'N') = 'N'
2963 AND rpa.reporting_usage_flag = 'Y'
2964 AND ppa.project_id = map.project_id
2965 AND map.worker_id = g_worker_id
2966 AND ev.worker_id = g_worker_id
2967 AND ev.event_type = 'RBS_ASSOC'
2968 AND TO_NUMBER(ev.attribute1) = map.project_id
2969 AND rpa.rbs_version_id = TO_NUMBER(ev.event_object)
2970 UNION ALL
2971 SELECT /*+ ordered use_nl( ev bv fpo ) */ -- 'RBS_ASSOC'
2972 bv.project_id project_id
2973 , cbcov.plan_version_id plan_version_id
2974 , DECODE ( NVL(bv.wp_version_flag, 'N')
2975 , 'Y', bv.project_structure_version_id
2976 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
2977 ) wbs_struct_version_id
2978 , TO_NUMBER(ev.event_object) rbs_struct_version_id
2979 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
2980 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
2981 , fpo.fin_plan_type_id plan_type_id
2982 , DECODE(bv.version_type
2983 , 'ALL', fpo.all_time_phased_code
2984 , 'COST', fpo.cost_time_phased_code
2985 , 'REVENUE', fpo.revenue_time_phased_code
2986 ) time_phased_type_code
2987
2988
2989
2990 , NVL(bv.wp_version_flag, 'N') is_wp_flag
2991 , DECODE(cbcov.plan_version_id, -3, 'Y', 'N') current_flag
2992 , bv.original_flag original_flag
2993 , DECODE(cbcov.plan_version_id, -4, 'Y', 'N') current_original_flag
2994 , DECODE(cbcov.plan_version_id, -3, 'Y', 'N') baselined_flag
2995 , 'Y' SECONDARY_RBS_FLAG
2996 , DECODE( NVL(bv.wp_version_flag, 'N')
2997 , 'Y'
2998 , DECODE(bv.project_structure_version_id
2999 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
3000 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
3001 , 'Y'
3002 , 'N')
3003 , 'N'
3004 ) lp_flag
3005 FROM
3006 PJI_PA_PROJ_EVENTS_LOG ev
3007 , pa_budget_versions bv
3008 , pa_proj_fp_options fpo
3009 , (SELECT -3 plan_version_id FROM DUAL
3010 UNION ALL
3011 SELECT -4 plan_version_id FROM DUAL
3012 ) cbcov
3013 WHERE l_RBS_ASSOC_exists = 'Y' /* Added for bug 8708651 */ /*1=1*/
3014 AND bv.version_type IS NOT NULL
3015 AND bv.fin_plan_type_id IS NOT NULL
3016 AND fpo.project_id = bv.project_id
3017 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
3018 AND bv.budget_version_id = fpo.fin_plan_version_id
3019 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION'
3020 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE')
3021 AND bv.pji_summarized_flag = 'Y'
3022 AND bv.budget_status_code = 'B'
3023 AND NVL(bv.wp_version_flag, 'N') = 'N'
3024 AND ev.worker_id = g_worker_id
3025 AND ev.event_type = 'RBS_ASSOC'
3026 AND bv.project_id = TO_NUMBER(ev.attribute1)
3027 AND NOT EXISTS -- Exclude plan version/RBS version combo for which plan data has already been extracted.
3028 ( SELECT 1
3029 FROM pji_pjp_rbs_header rh
3030 WHERE rh.project_id = bv.project_id
3031 AND rh.plan_version_id = cbcov.plan_version_id
3032 AND rh.rbs_version_id = TO_NUMBER(ev.event_object)
3033 )
3034 UNION ALL
3035 SELECT /*+ ordered use_nl( ev hd1 den hd2 bv fpo ) */ -- 'RBS_PRG' event handling.
3036 bv.project_id project_id
3037 , bv.budget_version_id plan_version_id
3038 , DECODE ( NVL(bv.wp_version_flag, 'N')
3039 , 'Y', bv.project_structure_version_id
3040 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
3041 ) wbs_struct_version_id
3042 , TO_NUMBER(ev.event_object) rbs_version_id
3043 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
3044 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
3045 , fpo.fin_plan_type_id plan_type_id
3046 , DECODE(bv.version_type
3047 , 'ALL', fpo.all_time_phased_code
3048 , 'COST', fpo.cost_time_phased_code
3049 , 'REVENUE', fpo.revenue_time_phased_code
3050 ) time_phased_type_code
3051
3052
3053
3054 , NVL(bv.wp_version_flag, 'N') is_wp_flag
3055 , bv.current_flag current_flag
3056 , bv.original_flag original_flag
3057 , bv.current_original_flag current_original_flag
3058 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
3059 , 'Y' SECONDARY_RBS_FLAG
3060 , DECODE( NVL(bv.wp_version_flag, 'N')
3061 , 'Y'
3062 , DECODE(bv.project_structure_version_id
3063 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
3064 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
3065 , 'Y'
3066 , 'N')
3067 , 'N'
3068 ) lp_flag
3069 FROM
3070 pji_pa_proj_events_log ev
3071 , pji_pjp_wbs_header hd1 -- sup
3072 , pji_xbs_denorm den
3073 , pji_pjp_wbs_header hd2 -- sub
3074 , pa_budget_versions bv
3075 , pa_proj_fp_options fpo
3076 WHERE l_RBS_PRG_exists = 'Y' /* Added for bug 8708651 */
3077 AND bv.version_type IS NOT NULL
3078 AND bv.fin_plan_type_id IS NOT NULL
3079 AND fpo.project_id = bv.project_id
3080 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
3081 AND bv.budget_version_id = fpo.fin_plan_version_id
3082 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION'
3083 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE')
3084 AND bv.pji_summarized_flag = 'Y'
3085 AND bv.budget_status_code = 'B'
3086 AND NVL(bv.wp_version_flag, 'N') = 'N'
3087 AND NVL(fpo.rbs_version_id, -1) <> TO_NUMBER(ev.event_object) -- Non-pri RBSes.
3088 AND ev.worker_id = g_worker_id
3089 AND ev.event_type = 'RBS_PRG'
3090 AND den.struct_version_id IS NULL
3091 AND TO_NUMBER(ev.attribute1) = hd1.project_id
3092 AND hd1.project_id = den.sup_project_id
3093 AND hd2.wbs_version_id = den.sub_id -- struct_version_id
3094 AND hd1.wbs_version_id = den.sup_id
3095 AND den.struct_type = 'PRG'
3096 AND NVL(den.relationship_type, 'WF') IN ('LF', 'WF')
3097 AND hd2.wp_flag = 'N'
3098 AND hd1.wp_flag = 'N'
3099 AND hd2.plan_version_id = bv.budget_version_id
3100 AND hd1.plan_version_id > 0
3101 -- AND hd2.plan_version_id > 0
3102 AND NOT EXISTS -- Exclude plan version/RBS version combo for which plan data has already been extracted.
3103 ( SELECT 1
3104 FROM pji_pjp_rbs_header rh
3105 WHERE rh.project_id = bv.project_id
3106 AND rh.plan_version_id = bv.budget_version_id
3107 AND rh.rbs_version_id = TO_NUMBER(ev.event_object)
3108 )
3109 UNION ALL
3110 SELECT /*+ ordered use_nl( ev hd1 den hd2 bv fpo ) */ -- 'RBS_PRG' event handling.
3111 bv.project_id project_id
3112 , cbcov.plan_version_id plan_version_id
3113 , DECODE ( NVL(bv.wp_version_flag, 'N')
3114 , 'Y', bv.project_structure_version_id
3115 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
3116 ) wbs_struct_version_id
3117 , TO_NUMBER(ev.event_object) rbs_version_id
3118 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
3119 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
3120 , fpo.fin_plan_type_id plan_type_id
3121 , DECODE(bv.version_type
3122 , 'ALL', fpo.all_time_phased_code
3123 , 'COST', fpo.cost_time_phased_code
3124 , 'REVENUE', fpo.revenue_time_phased_code
3125 ) time_phased_type_code
3126 , NVL(bv.wp_version_flag, 'N') is_wp_flag
3127 , DECODE(cbcov.plan_version_id, -3, 'Y', 'N') current_flag
3128 , bv.original_flag original_flag
3129 , DECODE(cbcov.plan_version_id, -4, 'Y', 'N') current_original_flag
3130 , DECODE(cbcov.plan_version_id, -3, 'Y', 'N') baselined_flag
3131 , 'Y' SECONDARY_RBS_FLAG
3132 , DECODE( NVL(bv.wp_version_flag, 'N')
3133 , 'Y'
3134 , DECODE(bv.project_structure_version_id
3135 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
3136 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
3137 , 'Y'
3138 , 'N')
3139 , 'N'
3140 ) lp_flag
3141 FROM
3142 PJI_PA_PROJ_EVENTS_LOG ev
3143 , pji_pjp_wbs_header hd1 -- sup
3144 , pji_xbs_denorm den
3145 , pji_pjp_wbs_header hd2 -- sub
3146 , pa_budget_versions bv
3147 , pa_proj_fp_options fpo
3148 , (SELECT -3 plan_version_id FROM DUAL
3149 UNION ALL
3150 SELECT -4 plan_version_id FROM DUAL
3151 ) cbcov
3152 WHERE l_RBS_PRG_exists = 'Y' /* Added for bug 8708651 */
3153 AND bv.version_type IS NOT NULL
3154 AND bv.fin_plan_type_id IS NOT NULL
3155 AND fpo.project_id = bv.project_id
3156 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
3157 AND bv.budget_version_id = fpo.fin_plan_version_id
3158 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION'
3159 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE')
3160 AND bv.pji_summarized_flag = 'Y'
3161 AND bv.budget_status_code = 'B'
3162 AND NVL(bv.wp_version_flag, 'N') = 'N'
3163 AND NVL(fpo.rbs_version_id, -1) <> TO_NUMBER(ev.event_object) -- rpa.rbs_version_id
3164 AND ev.worker_id = g_worker_id
3165 AND ev.event_type = 'RBS_PRG'
3166 AND den.struct_version_id IS NULL
3167 AND TO_NUMBER(ev.attribute1) = hd1.project_id
3168 AND hd1.project_id = den.sup_project_id
3169 AND hd2.wbs_version_id = den.sub_id -- struct_version_id
3170 AND hd1.wbs_version_id = den.sup_id
3171 AND den.struct_type = 'PRG'
3172 AND NVL(den.relationship_type, 'WF') IN ('LF', 'WF')
3173 AND hd2.wp_flag = 'N'
3174 AND hd1.wp_flag = 'N'
3175 AND hd2.plan_version_id = bv.budget_version_id
3176 AND hd1.plan_version_id > 0
3177 -- AND hd2.plan_version_id > 0
3178 AND NOT EXISTS -- Exclude plan version/RBS version combo for which plan data has already been extracted.
3179 ( SELECT 1
3180 FROM pji_pjp_rbs_header rh
3181 WHERE rh.project_id = bv.project_id
3182 AND rh.plan_version_id = cbcov.plan_version_id
3183 AND rh.rbs_version_id = TO_NUMBER(ev.event_object)
3184 )
3185 UNION ALL
3186 -- Added for Bug# 8838371
3187 SELECT
3188 project_id
3189 , plan_version_id
3190 , Pa_Project_Structure_Utils.GET_FIN_STRUC_VER_ID(project_id) wbs_version_id
3191 , rbs_version_id
3192 , plan_type_code
3193 , plan_type_id
3194 , time_phased_type_code
3195 , wp_flag
3196 , current_flag
3197 , original_flag
3198 , curr_original_flag
3199 , baselined_flag
3200 , SECONDARY_RBS_FLAG
3201 , lp_flag
3202 FROM
3203 (
3204 SELECT DISTINCT /*+ NO_MERGE(fpo) use_nl(fpo map whsub den) index(den pji_xbs_denorm_n6) */ -- 'PRG_CHANGE' event.
3205 den.sup_project_id project_id
3206 , cbco.plan_version_id plan_version_id -- -3/-4
3207 -- , Pa_Project_Structure_Utils.GET_FIN_STRUC_VER_ID(den.sup_project_id) wbs_version_id
3208 , fpo.parvi rbs_version_id
3209 -- , TO_CHAR(whsub.plan_type_id) plan_type_code
3210 , whsub.plan_type_code plan_type_code /*4471527 */
3211 , whsub.plan_type_id plan_type_id
3212 , fpo.tptc time_phased_type_code
3213 , 'N' wp_flag
3214 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') current_flag
3215 , DECODE(cbco.plan_version_id, -4, 'Y', 'N') original_flag
3216 , DECODE(cbco.plan_version_id, -4, 'Y', 'N') curr_original_flag
3217 , 'Y' baselined_flag
3218 , DECODE(fpo.fprvi, NULL, 'Y', 'N') SECONDARY_RBS_FLAG
3219 , 'Y' lp_flag
3220 FROM
3221 (
3222 SELECT rpa.project_id rpi
3223 , fpo.rbs_version_id fprvi
3224 , rpa.rbs_version_id parvi
3225 , fpo.fin_plan_option_level_code fpolc
3226 , NVL( fpo.all_time_phased_code
3227 || fpo.cost_time_phased_code
3228 || fpo.revenue_time_phased_code
3229 , 'G') tptc
3230 FROM pji_pjp_proj_batch_map map
3231 , pa_budget_versions bv
3232 , pa_rbs_prj_assignments rpa
3233 , pa_proj_fp_options fpo
3234 WHERE 1=1
3235 AND fpo.project_id (+)= rpa.project_id
3236 AND fpo.rbs_version_id (+)= rpa.rbs_version_id
3237 AND bv.project_id = rpa.project_id
3238 AND NVL(bv.wp_version_flag, 'N') = 'N'
3239 AND bv.budget_status_code = 'B' -- Don't care if dangling plan.
3240 AND map.worker_id = g_worker_id
3241 AND map.project_id = bv.project_id
3242 ) fpo
3243 , pji_pjp_proj_batch_map map
3244 , pji_pjp_wbs_header whsub
3245 , pa_xbs_denorm den
3246 , ( SELECT -3 plan_version_id FROM dual
3247 UNION ALL
3248 SELECT -4 plan_version_id FROM dual ) cbco
3249 WHERE l_PRG_CHANGE_exists = 'Y' /* Added for bug 8708651 */
3250 AND map.worker_id = g_worker_id
3251 AND fpo.rpi = map.project_id
3252 AND NVL(fpolc, 'PLAN_VERSION') = 'PLAN_VERSION'
3253 AND map.project_id = whsub.project_id
3254 AND whsub.wp_flag = 'N'
3255 AND whsub.plan_version_id <> -1
3256 AND den.sub_id = whsub.wbs_version_id
3257 AND den.struct_version_id IS NULL
3258 AND den.struct_type = 'PRG'
3259 AND den.sup_level < den.sub_level
3260 AND NVL(den.relationship_type, 'WF') IN ('LF', 'WF') -- Excluding 'LW'
3261 AND EXISTS ( SELECT DISTINCT 1
3262 FROM pji_pa_proj_events_log
3263 WHERE event_type = 'PRG_CHANGE'
3264 AND worker_id = g_worker_id )
3265 )
3266 -- Added for Bug# 8838371 ends
3267 );
3268
3269 else
3270
3271 INSERT INTO PJI_FM_EXTR_PLNVER4
3272 (
3273 WORKER_ID ,
3274 PROJECT_ID ,
3275 PLAN_VERSION_ID ,
3276 WBS_STRUCT_VERSION_ID ,
3277 RBS_STRUCT_VERSION_ID ,
3278 PLAN_TYPE_CODE ,
3279 PLAN_TYPE_ID ,
3280 TIME_PHASED_TYPE_CODE ,
3281 TIME_DANGLING_FLAG ,
3282 RATE_DANGLING_FLAG ,
3283 PROJECT_TYPE_CLASS ,
3284 WP_FLAG ,
3285 CURRENT_FLAG ,
3286 ORIGINAL_FLAG ,
3287 CURRENT_ORIGINAL_FLAG ,
3288 BASELINED_FLAG ,
3289 SECONDARY_RBS_FLAG ,
3290 LP_FLAG
3291 )
3292 SELECT DISTINCT
3293 g_worker_id ,
3294 PROJECT_ID ,
3295 PLAN_VERSION_ID ,
3296 WBS_STRUCT_VERSION_ID ,
3297 RBS_STRUCT_VERSION_ID ,
3298 PLAN_TYPE_CODE ,
3299 PLAN_TYPE_ID ,
3300 TIME_PHASED_TYPE_CODE ,
3301 NULL TIME_DANGLING_FLAG ,
3302 NULL RATE_DANGLING_FLAG ,
3303 NULL PROJECT_TYPE_CLASS ,
3304 WP_FLAG ,
3305 CURRENT_FLAG ,
3306 ORIGINAL_FLAG ,
3307 CURRENT_ORIGINAL_FLAG ,
3308 BASELINED_FLAG ,
3309 SECONDARY_RBS_FLAG ,
3310 LP_FLAG
3311 FROM
3312 (
3313 SELECT /*+ ordered use_nl( map bv ppa fpo rpa ) */
3314 bv.project_id project_id
3315 , bv.budget_version_id plan_version_id
3316 , DECODE ( NVL(bv.wp_version_flag, 'N')
3317 , 'Y', bv.project_structure_version_id
3318 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
3319 ) wbs_struct_version_id
3320 , rpa.rbs_version_id rbs_struct_version_id
3321 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
3322 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
3323 , fpo.fin_plan_type_id plan_type_id
3324 , DECODE(bv.version_type
3325 , 'ALL', fpo.all_time_phased_code
3326 , 'COST', fpo.cost_time_phased_code
3327 , 'REVENUE', fpo.revenue_time_phased_code
3328 ) time_phased_type_code
3329
3330
3331
3332 , NVL(bv.wp_version_flag, 'N') wp_flag
3333 , bv.current_flag current_flag
3334 , bv.original_flag original_flag
3335 , bv.current_original_flag current_original_flag
3336 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
3337 , 'Y' SECONDARY_RBS_FLAG
3338 , DECODE( NVL(bv.wp_version_flag, 'N')
3339 , 'Y'
3340 , DECODE(bv.project_structure_version_id
3341 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
3342 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
3343 , 'Y'
3344 , 'N')
3345 , 'N'
3346 ) lp_flag
3347 FROM
3348 pji_pjp_proj_batch_map map -- CHANGE_01 Sridhar Carlson 6919766 changed order of the tables
3349 , pa_budget_versions bv -- @pjdev115 bv
3350 , pa_projects_all ppa -- @pjdev115 ppa
3351 , pa_proj_fp_options fpo -- @pjdev115 fpo
3352 , PA_RBS_PRJ_ASSIGNMENTS rpa
3353 WHERE ppa.project_id = bv.project_id
3354 AND bv.version_type IS NOT NULL
3355 AND bv.fin_plan_type_id IS NOT NULL
3356 AND fpo.project_id = bv.project_id
3357 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
3358 AND bv.budget_version_id = fpo.fin_plan_version_id
3359 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
3360 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
3361 AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
3362 AND bv.budget_status_code = 'B'
3363 AND rpa.project_id = bv.project_id
3364 -- AND DECODE ( rpa.wp_usage_flag, 'Y', 'Y', 'X') = NVL(bv.wp_version_flag, 'N')
3365 -- AND DECODE ( rpa.fp_usage_flag, 'Y', 'N', 'X') = NVL(bv.wp_version_flag, 'N')
3366 AND rpa.assignment_status = 'ACTIVE'
3367 AND NVL(fpo.rbs_version_id, -1) <> rpa.rbs_version_id
3368 AND NVL(bv.wp_version_flag, 'N') = 'N'
3369 AND rpa.reporting_usage_flag = 'Y'
3370 AND ppa.project_id = map.project_id
3371 AND map.worker_id = g_worker_id
3372 UNION ALL
3373 SELECT /*+ ordered use_nl( map bv fpo rpa ) */
3374 bv.project_id project_id
3375 , cbco.plan_version_id plan_version_id
3376 , DECODE ( NVL(bv.wp_version_flag, 'N')
3377 , 'Y', bv.project_structure_version_id
3378 , Pa_Project_Structure_Utils.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
3379 ) wbs_struct_version_id
3380 , rpa.rbs_version_id rbs_struct_version_id
3381 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
3382 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
3383 , fpo.fin_plan_type_id plan_type_id
3384 , DECODE(bv.version_type
3385 , 'ALL', fpo.all_time_phased_code
3386 , 'COST', fpo.cost_time_phased_code
3387 , 'REVENUE', fpo.revenue_time_phased_code
3388 ) time_phased_type_code
3389 , NVL(bv.wp_version_flag, 'N') wp_flag
3390 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') current_flag
3391 , bv.original_flag original_flag
3392 , DECODE(cbco.plan_version_id, -4, 'Y', 'N') current_original_flag
3393 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') baselined_flag
3394 , 'Y' SECONDARY_RBS_FLAG
3395 , DECODE( NVL(bv.wp_version_flag, 'N')
3396 , 'Y'
3397 , DECODE(bv.project_structure_version_id
3398 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
3399 -- , Pa_Project_Structure_Utils.GET_FIN_STRUC_VER_ID(bv.project_id)
3400 , 'Y'
3401 , 'N')
3402 , 'N'
3403 ) lp_flag
3404 FROM
3405 pji_pjp_proj_batch_map map
3406 , pa_budget_versions bv -- @pjdev115 bv
3407 , pa_proj_fp_options fpo -- @pjdev115 fpo
3408 -- , pa_projects_all ppa -- @pjdev115 ppa
3409 , PA_RBS_PRJ_ASSIGNMENTS rpa
3410 , ( SELECT -3 plan_version_id FROM dual
3411 UNION ALL
3412 SELECT -4 plan_version_id FROM dual ) cbco
3413 WHERE map.project_id = bv.project_id
3414 AND bv.version_type IS NOT NULL
3415 AND bv.fin_plan_type_id IS NOT NULL
3416 AND fpo.project_id = bv.project_id
3417 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
3418 AND bv.budget_version_id = fpo.fin_plan_version_id
3419 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
3420 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
3421 AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
3422 AND bv.budget_status_code = 'B'
3423 AND rpa.project_id = bv.project_id
3424 AND rpa.assignment_status = 'ACTIVE'
3425 AND NVL(fpo.rbs_version_id, -1) <> rpa.rbs_version_id
3426 AND NVL(bv.wp_version_flag, 'N') = 'N'
3427 AND rpa.reporting_usage_flag = 'Y'
3428 AND map.worker_id = g_worker_id
3429 UNION ALL
3430 SELECT /*+ ordered use_nl( ev rpa bv fpo ppa map ) */ -- 'RBS_ASSOC'
3431 bv.project_id project_id
3432 , bv.budget_version_id plan_version_id
3433 , DECODE ( NVL(bv.wp_version_flag, 'N')
3434 , 'Y', bv.project_structure_version_id
3435 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
3436 ) wbs_struct_version_id
3437 , rpa.rbs_version_id rbs_struct_version_id
3438 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
3439 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
3440 , fpo.fin_plan_type_id plan_type_id
3441 , DECODE(bv.version_type
3442 , 'ALL', fpo.all_time_phased_code
3443 , 'COST', fpo.cost_time_phased_code
3444 , 'REVENUE', fpo.revenue_time_phased_code
3445 ) time_phased_type_code
3446
3447
3448
3449 , NVL(bv.wp_version_flag, 'N') is_wp_flag
3450 , bv.current_flag current_flag
3451 , bv.original_flag original_flag
3452 , bv.current_original_flag current_original_flag
3453 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
3454 , 'Y' SECONDARY_RBS_FLAG
3455 , DECODE( NVL(bv.wp_version_flag, 'N')
3456 , 'Y'
3457 , DECODE(bv.project_structure_version_id
3458 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
3459 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
3460 , 'Y'
3461 , 'N')
3462 , 'N'
3463 ) lp_flag
3464 FROM
3465 pji_pa_proj_events_log ev
3466 , PA_RBS_PRJ_ASSIGNMENTS rpa
3467 , pa_budget_versions bv -- @pjdev115 bv
3468 , pa_proj_fp_options fpo -- @pjdev115 fpo
3469 , pa_projects_all ppa -- @pjdev115 ppa
3470 , pji_pjp_proj_batch_map map
3471 WHERE l_RBS_ASSOC_exists = 'Y' /* Added for bug 8708651 */
3472 AND ppa.project_id = bv.project_id
3473 AND bv.version_type IS NOT NULL
3474 AND bv.fin_plan_type_id IS NOT NULL
3475 AND fpo.project_id = bv.project_id
3476 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
3477 AND bv.budget_version_id = fpo.fin_plan_version_id
3478 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION'
3479 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE')
3480 AND bv.pji_summarized_flag = 'Y'
3481 AND bv.budget_status_code = 'B'
3482 AND rpa.project_id = bv.project_id
3483 AND rpa.assignment_status = 'ACTIVE'
3484 AND NVL(fpo.rbs_version_id, -1) <> rpa.rbs_version_id
3485 AND NVL(bv.wp_version_flag, 'N') = 'N'
3486 AND rpa.reporting_usage_flag = 'Y'
3487 AND ppa.project_id = map.project_id
3488 AND map.worker_id = g_worker_id
3489 AND ev.worker_id = g_worker_id
3490 AND ev.event_type = 'RBS_ASSOC'
3491 AND TO_NUMBER(ev.attribute1) = map.project_id
3492 AND rpa.rbs_version_id = TO_NUMBER(ev.event_object)
3493 UNION ALL
3494 SELECT /*+ ordered use_nl( ev bv fpo ) */ -- 'RBS_ASSOC'
3495 bv.project_id project_id
3496 , cbcov.plan_version_id plan_version_id
3497 , DECODE ( NVL(bv.wp_version_flag, 'N')
3498 , 'Y', bv.project_structure_version_id
3499 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
3500 ) wbs_struct_version_id
3501 , TO_NUMBER(ev.event_object) rbs_struct_version_id
3502 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
3503 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
3504 , fpo.fin_plan_type_id plan_type_id
3505 , DECODE(bv.version_type
3506 , 'ALL', fpo.all_time_phased_code
3507 , 'COST', fpo.cost_time_phased_code
3508 , 'REVENUE', fpo.revenue_time_phased_code
3509 ) time_phased_type_code
3510
3511
3512
3513 , NVL(bv.wp_version_flag, 'N') is_wp_flag
3514 , DECODE(cbcov.plan_version_id, -3, 'Y', 'N') current_flag
3515 , bv.original_flag original_flag
3516 , DECODE(cbcov.plan_version_id, -4, 'Y', 'N') current_original_flag
3517 , DECODE(cbcov.plan_version_id, -3, 'Y', 'N') baselined_flag
3518 , 'Y' SECONDARY_RBS_FLAG
3519 , DECODE( NVL(bv.wp_version_flag, 'N')
3520 , 'Y'
3521 , DECODE(bv.project_structure_version_id
3522 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
3523 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
3524 , 'Y'
3525 , 'N')
3526 , 'N'
3527 ) lp_flag
3528 FROM
3529 PJI_PA_PROJ_EVENTS_LOG ev
3530 , pa_budget_versions bv
3531 , pa_proj_fp_options fpo
3532 , (SELECT -3 plan_version_id FROM DUAL
3533 UNION ALL
3534 SELECT -4 plan_version_id FROM DUAL
3535 ) cbcov
3536 WHERE l_RBS_ASSOC_exists = 'Y' /* Added for bug 8708651 */ /*1=1*/
3537 AND bv.version_type IS NOT NULL
3538 AND bv.fin_plan_type_id IS NOT NULL
3539 AND fpo.project_id = bv.project_id
3540 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
3541 AND bv.budget_version_id = fpo.fin_plan_version_id
3542 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION'
3543 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE')
3544 AND bv.pji_summarized_flag = 'Y'
3545 AND bv.budget_status_code = 'B'
3546 AND NVL(bv.wp_version_flag, 'N') = 'N'
3547 AND ev.worker_id = g_worker_id
3548 AND ev.event_type = 'RBS_ASSOC'
3549 AND bv.project_id = TO_NUMBER(ev.attribute1)
3550 AND NOT EXISTS -- Exclude plan version/RBS version combo for which plan data has already been extracted.
3551 ( SELECT 1
3552 FROM pji_pjp_rbs_header rh
3553 WHERE rh.project_id = bv.project_id
3554 AND rh.plan_version_id = cbcov.plan_version_id
3555 AND rh.rbs_version_id = TO_NUMBER(ev.event_object)
3556 )
3557 UNION ALL
3558 SELECT /*+ ordered use_nl( ev hd1 den hd2 bv fpo ) */ -- 'RBS_PRG' event handling.
3559 bv.project_id project_id
3560 , bv.budget_version_id plan_version_id
3561 , DECODE ( NVL(bv.wp_version_flag, 'N')
3562 , 'Y', bv.project_structure_version_id
3563 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
3564 ) wbs_struct_version_id
3565 , TO_NUMBER(ev.event_object) rbs_version_id
3566 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
3567 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
3568 , fpo.fin_plan_type_id plan_type_id
3569 , DECODE(bv.version_type
3570 , 'ALL', fpo.all_time_phased_code
3571 , 'COST', fpo.cost_time_phased_code
3572 , 'REVENUE', fpo.revenue_time_phased_code
3573 ) time_phased_type_code
3574
3575
3576
3577 , NVL(bv.wp_version_flag, 'N') is_wp_flag
3578 , bv.current_flag current_flag
3579 , bv.original_flag original_flag
3580 , bv.current_original_flag current_original_flag
3581 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
3582 , 'Y' SECONDARY_RBS_FLAG
3583 , DECODE( NVL(bv.wp_version_flag, 'N')
3584 , 'Y'
3585 , DECODE(bv.project_structure_version_id
3586 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
3587 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
3588 , 'Y'
3589 , 'N')
3590 , 'N'
3591 ) lp_flag
3592 FROM
3593 pji_pa_proj_events_log ev
3594 , pji_pjp_wbs_header hd1 -- sup
3595 , pji_xbs_denorm den
3596 , pji_pjp_wbs_header hd2 -- sub
3597 , pa_budget_versions bv
3598 , pa_proj_fp_options fpo
3599 WHERE l_RBS_PRG_exists = 'Y' /* Added for bug 8708651 */
3600 AND bv.version_type IS NOT NULL
3601 AND bv.fin_plan_type_id IS NOT NULL
3602 AND fpo.project_id = bv.project_id
3603 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
3604 AND bv.budget_version_id = fpo.fin_plan_version_id
3605 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION'
3606 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE')
3607 AND bv.pji_summarized_flag = 'Y'
3608 AND bv.budget_status_code = 'B'
3609 AND NVL(bv.wp_version_flag, 'N') = 'N'
3610 AND NVL(fpo.rbs_version_id, -1) <> TO_NUMBER(ev.event_object) -- Non-pri RBSes.
3611 AND ev.worker_id = g_worker_id
3612 AND ev.event_type = 'RBS_PRG'
3613 AND den.struct_version_id IS NULL
3614 AND TO_NUMBER(ev.attribute1) = hd1.project_id
3615 AND hd1.project_id = den.sup_project_id
3616 AND hd2.wbs_version_id = den.sub_id -- struct_version_id
3617 AND hd1.wbs_version_id = den.sup_id
3618 AND den.struct_type = 'PRG'
3619 AND NVL(den.relationship_type, 'WF') IN ('LF', 'WF')
3620 AND hd2.wp_flag = 'N'
3621 AND hd1.wp_flag = 'N'
3622 AND hd2.plan_version_id = bv.budget_version_id
3623 AND hd1.plan_version_id > 0
3624 -- AND hd2.plan_version_id > 0
3625 AND NOT EXISTS -- Exclude plan version/RBS version combo for which plan data has already been extracted.
3626 ( SELECT 1
3627 FROM pji_pjp_rbs_header rh
3628 WHERE rh.project_id = bv.project_id
3629 AND rh.plan_version_id = bv.budget_version_id
3630 AND rh.rbs_version_id = TO_NUMBER(ev.event_object)
3631 )
3632 UNION ALL
3633 SELECT /*+ ordered use_nl( ev hd1 den hd2 bv fpo ) */ -- 'RBS_PRG' event handling.
3634 bv.project_id project_id
3635 , cbcov.plan_version_id plan_version_id
3636 , DECODE ( NVL(bv.wp_version_flag, 'N')
3637 , 'Y', bv.project_structure_version_id
3638 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
3639 ) wbs_struct_version_id
3640 , TO_NUMBER(ev.event_object) rbs_version_id
3641 -- , TO_CHAR(fpo.fin_plan_type_id) plan_type_code
3642 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
3643 , fpo.fin_plan_type_id plan_type_id
3644 , DECODE(bv.version_type
3645 , 'ALL', fpo.all_time_phased_code
3646 , 'COST', fpo.cost_time_phased_code
3647 , 'REVENUE', fpo.revenue_time_phased_code
3648 ) time_phased_type_code
3649 , NVL(bv.wp_version_flag, 'N') is_wp_flag
3650 , DECODE(cbcov.plan_version_id, -3, 'Y', 'N') current_flag
3651 , bv.original_flag original_flag
3652 , DECODE(cbcov.plan_version_id, -4, 'Y', 'N') current_original_flag
3653 , DECODE(cbcov.plan_version_id, -3, 'Y', 'N') baselined_flag
3654 , 'Y' SECONDARY_RBS_FLAG
3655 , DECODE( NVL(bv.wp_version_flag, 'N')
3656 , 'Y'
3657 , DECODE(bv.project_structure_version_id
3658 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
3659 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
3660 , 'Y'
3661 , 'N')
3662 , 'N'
3663 ) lp_flag
3664 FROM
3665 PJI_PA_PROJ_EVENTS_LOG ev
3666 , pji_pjp_wbs_header hd1 -- sup
3667 , pji_xbs_denorm den
3668 , pji_pjp_wbs_header hd2 -- sub
3669 , pa_budget_versions bv
3670 , pa_proj_fp_options fpo
3671 , (SELECT -3 plan_version_id FROM DUAL
3672 UNION ALL
3673 SELECT -4 plan_version_id FROM DUAL
3674 ) cbcov
3675 WHERE l_RBS_PRG_exists = 'Y' /* Added for bug 8708651 */
3676 AND bv.version_type IS NOT NULL
3677 AND bv.fin_plan_type_id IS NOT NULL
3678 AND fpo.project_id = bv.project_id
3679 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
3680 AND bv.budget_version_id = fpo.fin_plan_version_id
3681 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION'
3682 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE')
3683 AND bv.pji_summarized_flag = 'Y'
3684 AND bv.budget_status_code = 'B'
3685 AND NVL(bv.wp_version_flag, 'N') = 'N'
3686 AND NVL(fpo.rbs_version_id, -1) <> TO_NUMBER(ev.event_object) -- rpa.rbs_version_id
3687 AND ev.worker_id = g_worker_id
3688 AND ev.event_type = 'RBS_PRG'
3689 AND den.struct_version_id IS NULL
3690 AND TO_NUMBER(ev.attribute1) = hd1.project_id
3691 AND hd1.project_id = den.sup_project_id
3692 AND hd2.wbs_version_id = den.sub_id -- struct_version_id
3693 AND hd1.wbs_version_id = den.sup_id
3694 AND den.struct_type = 'PRG'
3695 AND NVL(den.relationship_type, 'WF') IN ('LF', 'WF')
3696 AND hd2.wp_flag = 'N'
3697 AND hd1.wp_flag = 'N'
3698 AND hd2.plan_version_id = bv.budget_version_id
3699 AND hd1.plan_version_id > 0
3700 -- AND hd2.plan_version_id > 0
3701 AND NOT EXISTS -- Exclude plan version/RBS version combo for which plan data has already been extracted.
3702 ( SELECT 1
3703 FROM pji_pjp_rbs_header rh
3704 WHERE rh.project_id = bv.project_id
3705 AND rh.plan_version_id = cbcov.plan_version_id
3706 AND rh.rbs_version_id = TO_NUMBER(ev.event_object)
3707 )
3708 UNION ALL
3709 -- Added for Bug# 8838371
3710 SELECT
3711 project_id
3712 , plan_version_id
3713 , Pa_Project_Structure_Utils.GET_FIN_STRUC_VER_ID(project_id) wbs_struct_version_id
3714 , rbs_struct_version_id
3715 , plan_type_code
3716 , plan_type_id
3717 , time_phased_type_code
3718 , wp_flag
3719 , current_flag
3720 , original_flag
3721 , curr_original_flag
3722 , baselined_flag
3723 , SECONDARY_RBS_FLAG
3724 , lp_flag
3725 FROM
3726 (
3727 SELECT DISTINCT /*+ NO_MERGE(fpo) use_nl(fpo map whsub den) index(den pji_xbs_denorm_n6) */ -- 'PRG_CHANGE' event.
3728 den.sup_project_id project_id
3729 , cbco.plan_version_id plan_version_id -- -3/-4
3730 -- , Pa_Project_Structure_Utils.GET_FIN_STRUC_VER_ID(den.sup_project_id) wbs_struct_version_id
3731 , fpo.parvi rbs_struct_version_id
3732 -- , TO_CHAR(whsub.plan_type_id) plan_type_code
3733 , whsub.plan_type_code plan_type_code /*4471527 */
3734 , whsub.plan_type_id plan_type_id
3735 , fpo.tptc time_phased_type_code
3736 , 'N' wp_flag
3737 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') current_flag
3738 , DECODE(cbco.plan_version_id, -4, 'Y', 'N') original_flag
3739 , DECODE(cbco.plan_version_id, -4, 'Y', 'N') curr_original_flag
3740 , 'Y' baselined_flag
3741 , DECODE(fpo.fprvi, NULL, 'Y', 'N') SECONDARY_RBS_FLAG
3742 , 'Y' lp_flag
3743 FROM
3744 (
3745 SELECT rpa.project_id rpi
3746 , fpo.rbs_version_id fprvi
3747 , rpa.rbs_version_id parvi
3748 , fpo.fin_plan_option_level_code fpolc
3749 , NVL( fpo.all_time_phased_code
3750 || fpo.cost_time_phased_code
3751 || fpo.revenue_time_phased_code
3752 , 'G') tptc
3753 FROM pji_pjp_proj_batch_map map
3754 , pa_budget_versions bv
3755 , pa_rbs_prj_assignments rpa
3756 , pa_proj_fp_options fpo
3757 WHERE 1=1
3758 AND fpo.project_id (+)= rpa.project_id
3759 AND fpo.rbs_version_id (+)= rpa.rbs_version_id
3760 AND bv.project_id = rpa.project_id
3761 AND NVL(bv.wp_version_flag, 'N') = 'N'
3762 AND bv.budget_status_code = 'B' -- Don't care if dangling plan.
3763 AND map.worker_id = g_worker_id
3764 AND map.project_id = bv.project_id
3765 ) fpo
3766 , pji_pjp_proj_batch_map map
3767 , pji_pjp_wbs_header whsub
3768 , pa_xbs_denorm den
3769 , ( SELECT -3 plan_version_id FROM dual
3770 UNION ALL
3771 SELECT -4 plan_version_id FROM dual ) cbco
3772 WHERE l_PRG_CHANGE_exists = 'Y' /* Added for bug 8708651 */
3773 AND map.worker_id = g_worker_id
3774 AND fpo.rpi = map.project_id
3775 AND NVL(fpolc, 'PLAN_VERSION') = 'PLAN_VERSION'
3776 AND map.project_id = whsub.project_id
3777 AND whsub.wp_flag = 'N'
3778 AND whsub.plan_version_id <> -1
3779 AND den.sub_id = whsub.wbs_version_id
3780 AND den.struct_version_id IS NULL
3781 AND den.struct_type = 'PRG'
3782 AND den.sup_level < den.sub_level
3783 AND NVL(den.relationship_type, 'WF') IN ('LF', 'WF') -- Excluding 'LW'
3784 AND EXISTS ( SELECT DISTINCT 1
3785 FROM pji_pa_proj_events_log
3786 WHERE event_type = 'PRG_CHANGE'
3787 AND worker_id = g_worker_id )
3788 )
3789 -- Added for Bug# 8838371 ends
3790 );
3791
3792 end if;
3793
3794
3795 --#bug 5356051
3796 If l_prg_exists = 'Y' then --Programs exist, need to insert -3/-4 for programs as well
3797
3798 INSERT INTO PJI_FM_EXTR_PLNVER4
3799 (
3800 WORKER_ID ,
3801 PROJECT_ID ,
3802 PLAN_VERSION_ID ,
3803 WBS_STRUCT_VERSION_ID ,
3804 RBS_STRUCT_VERSION_ID ,
3805 PLAN_TYPE_CODE ,
3806 PLAN_TYPE_ID ,
3807 TIME_PHASED_TYPE_CODE ,
3808 TIME_DANGLING_FLAG ,
3809 RATE_DANGLING_FLAG ,
3810 PROJECT_TYPE_CLASS ,
3811 WP_FLAG ,
3812 CURRENT_FLAG ,
3813 ORIGINAL_FLAG ,
3814 CURRENT_ORIGINAL_FLAG ,
3815 BASELINED_FLAG ,
3816 SECONDARY_RBS_FLAG ,
3817 LP_FLAG
3818 )
3819 SELECT DISTINCT -- For insertion of -3/-4 header records.
3820 g_worker_id worker_id
3821 , den.sup_project_id project_id
3822 , cbco.plan_version_id plan_version_id
3823 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(den.sup_project_id) wbs_struct_version_id
3824 , hd2.rbs_struct_version_id rbs_version_id
3825 ,hd2.plan_type_code plan_type_code /*4471527 */
3826 , hd2.plan_type_id plan_type_id
3827 , hd2.time_phased_type_code time_phased_type_code
3828 , NULL TIME_DANGLING_FLAG
3829 , NULL RATE_DANGLING_FLAG
3830 , NULL PROJECT_TYPE_CLASS
3831 , 'N' is_wp_flag
3832 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') current_flag
3833 , NULL original_flag
3834 , DECODE(cbco.plan_version_id, -4, 'Y', 'N') current_original_flag
3835 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') baselined_flag
3836 , 'Y' SECONDARY_RBS_FLAG
3837 , 'Y' lp_flag
3838 FROM
3839 pji_fm_extr_plnver4 hd2 -- sub
3840 , pji_xbs_denorm den
3841 , ( SELECT -3 plan_version_id FROM dual
3842 UNION ALL
3843 SELECT -4 plan_version_id FROM dual ) cbco
3844 WHERE hd2.baselined_flag = 'Y'
3845 AND hd2.wp_flag = 'N'
3846 AND hd2.plan_version_id > 0
3847 AND hd2.worker_id = g_worker_id
3848 AND den.struct_version_id IS NULL
3849 AND hd2.wbs_struct_version_id = den.sub_id -- struct_version_id
3850 AND den.struct_type = 'PRG'
3851 AND NVL(den.relationship_type, 'WF') IN ('LF', 'WF')
3852 /* Added for bug 13030627 */
3853 AND NOT EXISTS (
3854 SELECT 1
3855 FROM pji_fm_extr_plnver4 ver3
3856 WHERE den.sup_project_id = ver3.project_id
3857 AND cbco.plan_version_id = ver3.plan_version_id
3858 AND hd2.plan_type_id = ver3.plan_type_id
3859 AND hd2.plan_type_code = ver3.plan_type_code
3860 AND hd2.rbs_struct_version_id = ver3.rbs_struct_version_id
3861 AND worker_id = g_worker_id);
3862 /* AND (den.sup_project_id, cbco.plan_version_id, hd2.plan_type_id,hd2.plan_type_code, hd2.rbs_struct_version_id) NOT IN
3863 ( SELECT project_id, plan_version_id, plan_type_id, plan_type_code,rbs_struct_version_id
3864 FROM pji_fm_extr_plnver4 ver3
3865 WHERE worker_id = g_worker_id ); Commented for bug 13030627 */
3866
3867 elsif l_prg_exists = 'N' then
3868
3869 INSERT INTO PJI_FM_EXTR_PLNVER4
3870 (
3871 WORKER_ID ,
3872 PROJECT_ID ,
3873 PLAN_VERSION_ID ,
3874 WBS_STRUCT_VERSION_ID ,
3875 RBS_STRUCT_VERSION_ID ,
3876 PLAN_TYPE_CODE ,
3877 PLAN_TYPE_ID ,
3878 TIME_PHASED_TYPE_CODE ,
3879 TIME_DANGLING_FLAG ,
3880 RATE_DANGLING_FLAG ,
3881 PROJECT_TYPE_CLASS ,
3882 WP_FLAG ,
3883 CURRENT_FLAG ,
3884 ORIGINAL_FLAG ,
3885 CURRENT_ORIGINAL_FLAG ,
3886 BASELINED_FLAG ,
3887 SECONDARY_RBS_FLAG ,
3888 LP_FLAG
3889 )
3890 SELECT DISTINCT -- For insertion of -3/-4 header records.
3891 g_worker_id worker_id
3892 , hd2.project_id project_id
3893 , cbco.plan_version_id plan_version_id
3894 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(hd2.project_id) wbs_struct_version_id
3895 , hd2.rbs_struct_version_id rbs_version_id
3896 , hd2.plan_type_code plan_type_code /*4471527 */
3897 , hd2.plan_type_id plan_type_id
3898 , hd2.time_phased_type_code time_phased_type_code
3899 , NULL TIME_DANGLING_FLAG
3900 , NULL RATE_DANGLING_FLAG
3901 , NULL PROJECT_TYPE_CLASS
3902 , 'N' is_wp_flag
3903 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') current_flag
3904 , NULL original_flag
3905 , DECODE(cbco.plan_version_id, -4, 'Y', 'N') current_original_flag
3906 , DECODE(cbco.plan_version_id, -3, 'Y', 'N') baselined_flag
3907 , 'Y' SECONDARY_RBS_FLAG
3908 , 'Y' lp_flag
3909 FROM
3910 pji_fm_extr_plnver4 hd2 -- sub
3911 , ( SELECT -3 plan_version_id FROM dual
3912 UNION ALL
3913 SELECT -4 plan_version_id FROM dual ) cbco
3914 WHERE hd2.baselined_flag = 'Y'
3915 AND hd2.wp_flag = 'N'
3916 AND hd2.plan_version_id > 0
3917 AND hd2.worker_id = g_worker_id
3918 /* Added for bug 13030627 */
3919 AND NOT EXISTS (
3920 SELECT 1
3921 FROM pji_fm_extr_plnver4 ver3
3922 WHERE hd2.project_id = ver3.project_id
3923 AND cbco.plan_version_id = ver3.plan_version_id
3924 AND hd2.plan_type_id = ver3.plan_type_id
3925 AND hd2.plan_type_code = ver3.plan_type_code
3926 AND hd2.rbs_struct_version_id = ver3.rbs_struct_version_id
3927 AND worker_id = g_worker_id);
3928 /* Commented for bug 13030627
3929 AND (hd2.project_id, cbco.plan_version_id, hd2.plan_type_id,hd2.plan_type_code, hd2.rbs_struct_version_id) NOT IN
3930 ( SELECT project_id, plan_version_id, plan_type_id, plan_type_code,rbs_struct_version_id
3931 FROM pji_fm_extr_plnver4 ver3
3932 WHERE worker_id = g_worker_id );
3933 */
3934 end if;
3935 --#bug 5356051
3936
3937
3938 END IF;
3939
3940
3941 print_time('EXTRACT_FIN_PLAN_VERS_BULK : End .. rows processed ' || SQL%ROWCOUNT );
3942
3943 EXCEPTION
3944 WHEN OTHERS THEN
3945
3946 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
3947 p_procedure_name => 'EXTRACT_FIN_PLAN_VERS_BULK');
3948 print_time('EXTRACT_FIN_PLAN_VERS_BULK : Exception: ' || sqlerrm );
3949 RAISE;
3950 END;
3951
3952
3953 --
3954 -- Get the budget versions that need to be extracted INTO a temp table.
3955 -- This is to set scope for extraction as well as track time/curr dangling records
3956 -- in the case of secondary slice creation.
3957 --
3958 PROCEDURE EXTRACT_FIN_PLAN_VERSIONS(
3959 p_fp_version_ids IN SYSTEM.pa_num_tbl_type := pji_empty_num_tbl
3960 , p_slice_type IN VARCHAR2 := NULL -- 'PRI' or 'SEC' or 'SECRBS'
3961 ) IS
3962 l_count NUMBER;
3963 BEGIN
3964
3965 print_time('EXTRACT_FIN_PLAN_VERSIONS : Begin ' );
3966
3967 IF (p_slice_type NOT IN ( 'PRI', 'SEC', 'SECRBS' )) THEN
3968 print_time('EXTRACT_FIN_PLAN_VERSIONS : Invalid slice type. Exitting. ' );
3969 RETURN;
3970 END IF;
3971
3972 print_time('EXTRACT_FIN_PLAN_VERSIONS : l_count is ... ' || p_fp_version_ids.COUNT );
3973
3974 IF (p_slice_type = 'PRI') THEN
3975
3976 FOR I IN 1..p_fp_version_ids.COUNT LOOP
3977
3978 INSERT INTO PJI_FM_EXTR_PLNVER4 ver3
3979 (
3980 WORKER_ID ,
3981 PROJECT_ID ,
3982 PLAN_VERSION_ID ,
3983 WBS_STRUCT_VERSION_ID ,
3984 RBS_STRUCT_VERSION_ID ,
3985 PLAN_TYPE_CODE ,
3986 PLAN_TYPE_ID ,
3987 TIME_PHASED_TYPE_CODE ,
3988 TIME_DANGLING_FLAG ,
3989 RATE_DANGLING_FLAG ,
3990 PROJECT_TYPE_CLASS ,
3991 WP_FLAG ,
3992 CURRENT_FLAG ,
3993 ORIGINAL_FLAG ,
3994 CURRENT_ORIGINAL_FLAG ,
3995 BASELINED_FLAG ,
3996 SECONDARY_RBS_FLAG ,
3997 LP_FLAG
3998 )
3999 SELECT
4000 g_worker_id
4001 , bv.project_id project_id
4002 , bv.budget_version_id plan_version_id
4003 , DECODE ( NVL(bv.wp_version_flag, 'N')
4004 , 'Y', bv.project_structure_version_id
4005 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
4006 ) wbs_struct_version_id
4007 , fpo.rbs_version_id rbs_struct_version_id
4008 -- , to_char(fpo.fin_plan_type_id) plan_type_code
4009 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
4010 , fpo.fin_plan_type_id plan_type_id
4011 , DECODE(bv.version_type
4012 , 'ALL', fpo.all_time_phased_code
4013 , 'COST', fpo.cost_time_phased_code
4014 , 'REVENUE', fpo.revenue_time_phased_code
4015 ) time_phased_type_code
4016 , NULL time_dangling_flag -- to be used for dangling check.
4017 , NULL rate_dangling_flag -- to be used for dangling check.
4018 , NULL PROJECT_TYPE_CLASS
4019 , NVL(bv.wp_version_flag, 'N') is_wp_flag
4020 , bv.current_flag current_flag
4021 , bv.original_flag original_flag
4022 , bv.current_original_flag current_original_flag
4023 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
4024 , 'N' SECONDARY_RBS_FLAG
4025 , DECODE( NVL(bv.wp_version_flag, 'N')
4026 , 'Y'
4027 , DECODE(bv.project_structure_version_id
4028 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
4029 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
4030 , 'Y'
4031 , 'N')
4032 , 'N'
4033 ) lp_flag
4034 FROM
4035 pa_budget_versions bv -- @pjdev115 bv
4036 , pa_proj_fp_options fpo -- @pjdev115 fpo
4037 , pa_projects_all ppa -- @pjdev115 ppa
4038 WHERE 1=1
4039 AND ppa.project_id = bv.project_id
4040 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
4041 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
4042 -- Ask VR: How about WP version.. are they picked up with this condition??
4043 AND fpo.project_id = bv.project_id
4044 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
4045 AND bv.budget_version_id = fpo.fin_plan_version_id
4046 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
4047 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
4048 -- AND bv.pji_summarized_flag = 'N'
4049 AND bv.budget_version_id = p_fp_version_ids(i) ;
4050
4051 END LOOP;
4052
4053 ELSIF (p_slice_type = 'SEC') THEN
4054
4055 FOR I IN 1..p_fp_version_ids.COUNT LOOP
4056
4057 INSERT INTO PJI_FM_EXTR_PLNVER4 ver3
4058 (
4059 WORKER_ID ,
4060 PROJECT_ID ,
4061 PLAN_VERSION_ID ,
4062 WBS_STRUCT_VERSION_ID ,
4063 RBS_STRUCT_VERSION_ID ,
4064 PLAN_TYPE_CODE ,
4065 PLAN_TYPE_ID ,
4066 TIME_PHASED_TYPE_CODE ,
4067 TIME_DANGLING_FLAG ,
4068 RATE_DANGLING_FLAG ,
4069 PROJECT_TYPE_CLASS ,
4070 WP_FLAG ,
4071 CURRENT_FLAG ,
4072 ORIGINAL_FLAG ,
4073 CURRENT_ORIGINAL_FLAG ,
4074 BASELINED_FLAG ,
4075 SECONDARY_RBS_FLAG ,
4076 LP_FLAG
4077 )
4078 SELECT
4079 g_worker_id
4080 , bv.project_id project_id
4081 , bv.budget_version_id plan_version_id
4082 , DECODE ( NVL(bv.wp_version_flag, 'N')
4083 , 'Y', bv.project_structure_version_id
4084 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
4085 ) wbs_struct_version_id
4086 , fpo.rbs_version_id rbs_struct_version_id
4087 -- , to_char(fpo.fin_plan_type_id) plan_type_code
4088 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
4089 , fpo.fin_plan_type_id plan_type_id
4090 , DECODE(bv.version_type
4091 , 'ALL', fpo.all_time_phased_code
4092 , 'COST', fpo.cost_time_phased_code
4093 , 'REVENUE', fpo.revenue_time_phased_code
4094 ) time_phased_type_code
4095 , NULL time_dangling_flag -- to be used for dangling check.
4096 , NULL rate_dangling_flag -- to be used for dangling check.
4097 , NULL PROJECT_TYPE_CLASS
4098 , NVL(bv.wp_version_flag, 'N') is_wp_flag
4099 , bv.current_flag current_flag
4100 , bv.original_flag original_flag
4101 , bv.current_original_flag current_original_flag
4102 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
4103 , 'N' SECONDARY_RBS_FLAG
4104 , DECODE( NVL(bv.wp_version_flag, 'N')
4105 , 'Y'
4106 , DECODE(bv.project_structure_version_id
4107 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
4108 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
4109 , 'Y'
4110 , 'N')
4111 , 'N'
4112 ) lp_flag
4113 FROM
4114 pa_budget_versions bv -- @pjdev115 bv
4115 , pa_proj_fp_options fpo -- @pjdev115 fpo
4116 , pa_projects_all ppa -- @pjdev115 ppa
4117 WHERE 1=1
4118 AND ppa.project_id = bv.project_id
4119 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
4120 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
4121 AND fpo.project_id = bv.project_id
4122 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
4123 AND bv.budget_version_id = fpo.fin_plan_version_id
4124 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
4125 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
4126 AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
4127 AND bv.budget_status_code = 'B'
4128 AND NVL(bv.wp_version_flag, 'N') = 'N'
4129 AND bv.budget_version_id = p_fp_version_ids(i) ;
4130
4131 END LOOP;
4132
4133
4134 ELSIF (p_slice_type = 'SECRBS') THEN
4135
4136 FOR I IN 1..p_fp_version_ids.COUNT LOOP
4137
4138 INSERT INTO PJI_FM_EXTR_PLNVER4 ver3
4139 (
4140 WORKER_ID ,
4141 PROJECT_ID ,
4142 PLAN_VERSION_ID ,
4143 WBS_STRUCT_VERSION_ID ,
4144 RBS_STRUCT_VERSION_ID ,
4145 PLAN_TYPE_CODE ,
4146 PLAN_TYPE_ID ,
4147 TIME_PHASED_TYPE_CODE ,
4148 TIME_DANGLING_FLAG ,
4149 RATE_DANGLING_FLAG ,
4150 PROJECT_TYPE_CLASS ,
4151 WP_FLAG ,
4152 CURRENT_FLAG ,
4153 ORIGINAL_FLAG ,
4154 CURRENT_ORIGINAL_FLAG ,
4155 BASELINED_FLAG ,
4156 SECONDARY_RBS_FLAG ,
4157 LP_FLAG
4158 )
4159 SELECT
4160 g_worker_id
4161 , bv.project_id project_id
4162 , bv.budget_version_id plan_version_id
4163 , DECODE ( NVL(bv.wp_version_flag, 'N')
4164 , 'Y', bv.project_structure_version_id
4165 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
4166 ) wbs_struct_version_id
4167 , rpa.rbs_version_id rbs_struct_version_id
4168 -- , to_char(fpo.fin_plan_type_id) plan_type_code
4169 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
4170 , fpo.fin_plan_type_id plan_type_id
4171 , DECODE(bv.version_type
4172 , 'ALL', fpo.all_time_phased_code
4173 , 'COST', fpo.cost_time_phased_code
4174 , 'REVENUE', fpo.revenue_time_phased_code
4175 ) time_phased_type_code
4176 , NULL time_dangling_flag -- to be used for dangling check.
4177 , NULL rate_dangling_flag -- to be used for dangling check.
4178 , NULL PROJECT_TYPE_CLASS
4179 , NVL(bv.wp_version_flag, 'N') is_wp_flag
4180 , bv.current_flag current_flag
4181 , bv.original_flag original_flag
4182 , bv.current_original_flag current_original_flag
4183 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
4184 , 'Y' SECONDARY_RBS_FLAG
4185 , DECODE( NVL(bv.wp_version_flag, 'N')
4186 , 'Y'
4187 , DECODE(bv.project_structure_version_id
4188 , PA_PROJECT_STRUCTURE_UTILS.GET_LATEST_WP_VERSION( bv.project_id) -- 4682341
4189 -- , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id)
4190 , 'Y'
4191 , 'N')
4192 , 'N'
4193 ) lp_flag
4194 FROM
4195 pa_budget_versions bv -- @pjdev115 bv
4196 , pa_proj_fp_options fpo -- @pjdev115 fpo
4197 , pa_projects_all ppa -- @pjdev115 ppa
4198 , PA_RBS_PRJ_ASSIGNMENTS rpa
4199 WHERE 1=1
4200 AND ppa.project_id = bv.project_id
4201 AND bv.version_type is not NULL -- COST, REVENUE, etc. Should not be null.
4202 AND bv.fin_plan_type_id is not NULL -- Old budgets model data is not picked up with this condition.
4203 AND fpo.project_id = bv.project_id
4204 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
4205 AND bv.budget_version_id = fpo.fin_plan_version_id
4206 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION' -- Other values are: plan type and project.
4207 AND bv.version_type IN ( 'ALL' , 'COST' , 'REVENUE') -- Eg of other version type is ORG_FORECAST.
4208 AND bv.pji_summarized_flag = 'P' -- Pri slice created or dangling records exist.
4209 AND bv.budget_status_code = 'B'
4210 AND rpa.project_id = bv.project_id
4211 AND rpa.assignment_status = 'ACTIVE'
4212 AND NVL(fpo.rbs_version_id, -1) <> rpa.rbs_version_id
4213 AND rpa.reporting_usage_flag = 'Y'
4214 AND NVL(bv.wp_version_flag, 'N') = 'N'
4215 AND bv.budget_version_id = p_fp_version_ids(i)
4216 AND bv.project_id = rpa.project_id;
4217
4218 END LOOP;
4219
4220 END IF;
4221
4222 l_count := SQL%ROWCOUNT;
4223
4224 print_time('EXTRACT_FIN_PLAN_VERSIONS : l_count is ... ' || l_count );
4225
4226 print_time('EXTRACT_FIN_PLAN_VERSIONS : End' );
4227
4228 EXCEPTION
4229 WHEN OTHERS THEN
4230 print_time('EXTRACT_FIN_PLAN_VERSIONS : Exception: ' || sqlerrm );
4231 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
4232 p_procedure_name => 'EXTRACT_FIN_PLAN_VERSIONS');
4233 RAISE;
4234 END;
4235
4236 --
4237 -- Extract the period level plan amounts for PA/GL/non time phased entries from budget lines
4238 -- for the primary RBS for this plan version into pji_fp_aggr_pjp1.
4239 -- EXTRACT_PLAN_AMOUNTS_PRIRBS
4240 PROCEDURE EXTRACT_PLAN_AMOUNTS_PRIRBS IS
4241 l_count NUMBER;
4242 l_max_project_id NUMBER := NULL;
4243
4244 BEGIN
4245
4246 print_time('EXTRACT_PLAN_AMOUNTS_PRIRBS : Begin' );
4247 print_time('EXTRACT_PLAN_AMOUNTS_PRIRBS : Begin worker id is ... ' || 1);
4248
4249
4250 INSERT_NTP_CAL_RECORD ( x_max_project_id => l_max_project_id );
4251
4252 IF (l_max_project_id IS NULL) THEN
4253 RETURN;
4254 END IF;
4255
4256 -- cbs change
4257 IF P_PA_DEBUG_MODE = 'Y' THEN
4258 pa_debug.write('EXTRACT_PLAN_AMOUNTS_PRIRBS: ' || g_module_name,'Before calling SET_RES_CLASS_FLAG' ,1);
4259 END IF;
4260
4261 SET_RES_CLASS_FLAG;
4262
4263 IF P_PA_DEBUG_MODE = 'Y' THEN
4264 pa_debug.write('EXTRACT_PLAN_AMOUNTS_PRIRBS: ' || g_module_name,'After calling SET_RES_CLASS_FLAG' ,1);
4265 END IF;
4266 -- End cbs change
4267
4268 INSERT INTO PJI_FP_AGGR_PJP1
4269 (
4270 WORKER_ID
4271 , PROJECT_ID
4272 , PROJECT_ORG_ID
4273 , PROJECT_ORGANIZATION_ID
4274 , PROJECT_ELEMENT_ID
4275 , TIME_ID
4276 , PERIOD_TYPE_ID
4277 , CALENDAR_TYPE
4278 , RBS_AGGR_LEVEL
4279 , WBS_ROLLUP_FLAG
4280 , PRG_ROLLUP_FLAG
4281 , CURR_RECORD_TYPE_ID
4282 , CURRENCY_CODE
4283 , RBS_ELEMENT_ID
4284 , RBS_VERSION_ID
4285 , PLAN_VERSION_ID
4286 , PLAN_TYPE_ID
4287 , RAW_COST
4288 , BRDN_COST
4289 , REVENUE
4290 , BILL_RAW_COST
4291 , BILL_BRDN_COST
4292 , BILL_LABOR_RAW_COST
4293 , BILL_LABOR_BRDN_COST
4294 , BILL_LABOR_HRS
4295 , EQUIPMENT_RAW_COST
4296 , EQUIPMENT_BRDN_COST
4297 , CAPITALIZABLE_RAW_COST
4298 , CAPITALIZABLE_BRDN_COST
4299 , LABOR_RAW_COST
4300 , LABOR_BRDN_COST
4301 , LABOR_HRS
4302 , LABOR_REVENUE
4303 , EQUIPMENT_HOURS
4304 , BILLABLE_EQUIPMENT_HOURS
4305 , SUP_INV_COMMITTED_COST
4306 , PO_COMMITTED_COST
4307 , PR_COMMITTED_COST
4308 , OTH_COMMITTED_COST
4309 , ACT_LABOR_HRS
4310 , ACT_EQUIP_HRS
4311 , ACT_LABOR_BRDN_COST
4312 , ACT_EQUIP_BRDN_COST
4313 , ACT_BRDN_COST
4314 , ACT_RAW_COST
4315 , ACT_REVENUE
4316 , ACT_LABOR_RAW_COST
4317 , ACT_EQUIP_RAW_COST
4318 , ETC_LABOR_HRS
4319 , ETC_EQUIP_HRS
4320 , ETC_LABOR_BRDN_COST
4321 , ETC_EQUIP_BRDN_COST
4322 , ETC_BRDN_COST
4323 , ETC_RAW_COST
4324 , ETC_LABOR_RAW_COST
4325 , ETC_EQUIP_RAW_COST
4326 , CUSTOM1
4327 , CUSTOM2
4328 , CUSTOM3
4329 , CUSTOM4
4330 , CUSTOM5
4331 , CUSTOM6
4332 , CUSTOM7
4333 , CUSTOM8
4334 , CUSTOM9
4335 , CUSTOM10
4336 , CUSTOM11
4337 , CUSTOM12
4338 , CUSTOM13
4339 , CUSTOM14
4340 , CUSTOM15
4341 , LINE_TYPE
4342 , RATE_DANGLING_FLAG
4343 , TIME_DANGLING_FLAG
4344 -- , START_DATE
4345 -- , END_DATE
4346 , PRG_LEVEL
4347 ,PLAN_TYPE_CODE
4348 )
4349 SELECT /*+ ordered no_merge(plr) */
4350 g_worker_id WORKER_ID
4351 , plr.PROJECT_ID
4352 , plr.PROJECT_ORG_ID
4353 , plr.project_ORGANIZATION_ID
4354 , plr.WBS_ELEMENT_ID
4355 , DECODE(plr.time_phased_type_code
4356 , 'N', -1
4357 , pji_time.cal_period_id) time_id
4358
4359 , DECODE(plr.time_phased_type_code
4360 , 'P', 32
4361 , 'G', 32
4362 , 'N', 2048
4363 , -1) period_type_id -- period type id...
4364 , DECODE(plr.time_phased_type_code
4365 , 'P', 'P'
4366 , 'G', 'G'
4367 , 'N', 'A'
4368 , 'X') -- CALENDAR_TYPE
4369 , 'L' RBS_AGGR_LEVEL
4370 , 'N' WBS_ROLLUP_FLAG
4371 , 'N' PRG_ROLLUP_FLAG
4372 , plr.CURR_RECORD_TYPE -- curr code missing.
4373 , plr.currency_code
4374 , plr.RBS_ELEMENT_ID
4375 , plr.RBS_STRUCT_VERSION_ID
4376 , plr.BUDGET_VERSION_ID
4377 , plr.plan_type_id
4378 , SUM(plr.RAW_COST)
4379 , SUM(plr.BRDN_COST)
4380 , SUM(plr.REVENUE)
4381 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) BILL_RAW_COST
4382 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) BILL_BRDN_COST
4383 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YPEOPLE', plr.raw_cost, 0 ) ) BILL_LABOR_RAW_COST
4384 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YPEOPLE' , plr.BRDN_COST, 0 ) ) BILL_LABOR_BRDN_COST
4385 --, SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'YPEOPLE', plr.quantity, 0 ) ) BILL_LABOR_HRS -- bug 6039785
4386 , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'YPEOPLE',
4387 DECODE ( plr.billable_flag , 'Y' , plr.quantity, 0 ) , 0 ) ) BILL_LABOR_HRS -- bug 6039785
4388 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code , plr.raw_cost, 0 ) ) EQUIPMENT_RAW_COST
4389 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code , plr.BRDN_COST, 0 ) ) EQUIPMENT_BRDN_COST
4390 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) CAPITALIZABLE_RAW_COST
4391 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) CAPITALIZABLE_BRDN_COST
4392 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.raw_cost, 0 ) ) LABOR_RAW_COST
4393 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.BRDN_COST, 0 ) ) LABOR_BRDN_COST
4394 /* , SUM ( DECODE ( plr.resource_class, g_people_resclass_code,
4395 DECODE ( plr.wp_flag, 'N',
4396 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
4397 plr.quantity),
4398 0 ) ) labor_hrs */ -- bug 6039785
4399 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code,
4400 DECODE( plr.billable_flag , 'Y' ,
4401 DECODE ( plr.wp_flag, 'N',
4402 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
4403 plr.quantity),
4404 0 ),
4405 0 ) ) labor_hrs -- bug 6039785
4406 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.revenue, 0 ) ) LABOR_REVENUE
4407 /* , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code,
4408 DECODE ( plr.wp_flag, 'N',
4409 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
4410 plr.quantity),
4411
4412 0 ) ) EQUIPMENT_HOURS */ -- bug 6039785
4413 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code,
4414 DECODE( plr.billable_flag , 'Y' ,
4415 DECODE ( plr.wp_flag, 'N',
4416 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
4417 plr.quantity),
4418 0 ),
4419 0 ) ) EQUIPMENT_HOURS -- bug 6039785
4420 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YEQUIPMENT', plr.quantity, 0 ) ) BILLABLE_EQUIPMENT_HOURS */ -- bug 6039785
4421 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YEQUIPMENT',
4422 DECODE ( plr.billable_flag , 'Y' , plr.quantity, 0 ) , 0 ) ) BILLABLE_EQUIPMENT_HOURS -- bug 6039785
4423 , NULL SUP_INV_COMMITTED_COST
4424 , NULL PO_COMMITTED_COST
4425 , NULL PR_COMMITTED_COST
4426 , NULL OTH_COMMITTED_COST
4427 /* , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
4428 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
4429 0 ) ) ) ACT_LABOR_HRS */ -- bug 6039785
4430 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
4431 DECODE ( plr.billable_flag , 'Y',
4432 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
4433 0 ),
4434 0 ) ) ) ACT_LABOR_HRS -- bug 6039785
4435 /* , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
4436 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
4437 0 ) ) ) ACT_EQUIP_HOURS */ -- bug 6039785
4438 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
4439 DECODE ( plr.billable_flag , 'Y',
4440 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
4441 0 ),
4442 0 ) ) ) ACT_EQUIP_HOURS -- bug 6039785
4443 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.actual_BRDN_COST, 0 ) ) ) ACT_LABOR_BRDN_COST
4444 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.actual_BRDN_COST, 0 ) ) ) ACT_EQUIPMENT_BRDN_COST
4445 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, plr.actual_brdn_cost ) ) ACT_BRDN_COST
4446 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, plr.actual_raw_cost ) ) ACT_RAW_COST
4447 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, plr.actual_revenue ) ) ACT_REVENUE
4448 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.actual_RAW_COST, 0 ) ) ) ACT_LABOR_RAW_COST
4449 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.actual_RAW_COST, 0 ) ) ) ACT_EQUIPMENT_RAW_COST
4450 /* , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
4451 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
4452 0 ) ) ) ETC_LABOR_HRS */ -- bug 6039785
4453 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
4454 DECODE ( plr.billable_flag , 'Y',
4455 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
4456 0 ),
4457 0 ) ) ) ETC_LABOR_HRS -- bug 6039785
4458 /* , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
4459 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
4460 0 ) ) ) ETC_EQUIP_HOURS */ -- bug 6039785
4461 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
4462 DECODE ( plr.billable_flag , 'Y',
4463 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
4464 0 ),
4465 0 ) ) ) ETC_EQUIP_HOURS -- bug 6039785
4466 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.etc_BRDN_COST, 0 ) ) ) ETC_LABOR_BRDN_COST
4467 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.etc_BRDN_COST, 0 ) ) ) ETC_EQUIP_BRDN_COST
4468 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, plr.etc_brdn_cost ) ) ETC_BRDN_COST
4469 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, plr.etc_raw_cost ) ) ETC_RAW_COST
4470 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.etc_raw_COST, 0 ) ) ) ETC_LABOR_raw_COST
4471 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.etc_raw_COST, 0 ) ) ) ETC_EQUIP_raw_COST
4472 , NULL CUSTOM1
4473 , NULL CUSTOM2
4474 , NULL CUSTOM3
4475 , NULL CUSTOM4
4476 , NULL CUSTOM5
4477 , NULL CUSTOM6
4478 , NULL CUSTOM7
4479 , NULL CUSTOM8
4480 , NULL CUSTOM9
4481 , NULL CUSTOM10
4482 , NULL CUSTOM11
4483 , NULL CUSTOM12
4484 , NULL CUSTOM13
4485 , NULL CUSTOM14
4486 , NULL CUSTOM15
4487 , DECODE(plr.time_phased_type_code, 'P', 'OF', 'G', 'OF', 'N', 'NTR', 'X') -- LINE_TYPE
4488 , NULL time_dangling_flag
4489 , NULL rate_dangling_flag
4490 -- , plr.start_date
4491 -- , plr.end_date
4492 , g_default_prg_level prg_level
4493 ,plr.PLAN_TYPE_CODE PLAN_TYPE_CODE /*4471527 */
4494 FROM
4495 ( ----- First inline view plr .............
4496 select /*+ no_merge(collapse_bl) */
4497 collapse_bl.PROJECT_ID -- , 1 partition_id
4498 , collapse_bl.WBS_ELEMENT_ID -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
4499 , SUM(collapse_bl.CURR_RECORD_TYPE_ID) CURR_RECORD_TYPE
4500 , collapse_bl.RBS_ELEMENT_ID
4501 , collapse_bl.RBS_STRUCT_VERSION_ID
4502 , collapse_bl.plan_type_id
4503 , collapse_bl.BUDGET_VERSION_ID
4504 , collapse_bl.PROJECT_ORGANIZATION_ID
4505 , collapse_bl.PROJECT_ORG_ID
4506 , collapse_bl.RESOURCE_ASSIGNMENT_ID
4507 , collapse_bl.BILLABLE_FLAG
4508 , collapse_bl.RESOURCE_CLASS -- , CALENDAR_TYPE -- , CALENDAR_ID
4509 , collapse_bl.TIME_PHASED_TYPE_CODE
4510 , collapse_bl.CURRENCY_CODE
4511 , max(collapse_bl.raw_cost) raw_cost
4512 , max(collapse_bl.BRDN_COST) BRDN_COST
4513 , max(collapse_bl.revenue) revenue
4514 , max(collapse_bl.actual_raw_cost) actual_raw_cost
4515 , max(collapse_bl.actual_BRDN_COST) actual_BRDN_COST
4516 , max(collapse_bl.actual_revenue) actual_revenue
4517 , max(collapse_bl.etc_raw_cost) etc_raw_cost
4518 , max(collapse_bl.etc_BRDN_COST) etc_BRDN_COST
4519 , max(collapse_bl.etc_revenue) etc_revenue
4520 , max(collapse_bl.quantity) quantity
4521 , max(collapse_bl.actual_quantity) actual_quantity
4522 , max(collapse_bl.etc_quantity) etc_quantity
4523 , collapse_bl.start_date start_date
4524 , collapse_bl.end_date end_date
4525 , collapse_bl.period_name period_name -- , TRACK_AS_LABOR_FLAG track_as_labor_flag
4526 , collapse_bl.row_id
4527 , collapse_bl.plan_type_code
4528 , collapse_bl.WP_FLAG
4529 from
4530 ( ----- Second inline view 'collapse_bl' begin .............
4531 select /*+ no_merge(spread_bl) */
4532 spread_bl.row_id row_id
4533 , spread_bl.PROJECT_ID
4534 , spread_bl.BUDGET_VERSION_ID
4535 , spread_bl.RESOURCE_ASSIGNMENT_ID
4536 , spread_bl.WBS_ELEMENT_ID
4537 , spread_bl.RBS_ELEMENT_ID
4538 , spread_bl.WBS_STRUCT_VERSION_ID
4539 , spread_bl.RBS_STRUCT_VERSION_ID
4540 , spread_bl.plan_type_id
4541 , spread_bl.BILLABLE_FLAG
4542 , spread_bl.RESOURCE_CLASS -- , spread_bl.CALENDAR_TYPE -- , pji_time.CALENDAR_ID
4543 , spread_bl.PROJECT_ORGANIZATION_ID
4544 , spread_bl.PROJECT_ORG_ID
4545 , spread_bl.TIME_PHASED_TYPE_CODE
4546 , DECODE( invert.INVERT_ID
4547 , 4, spread_bl.func_CURRENCY_CODE
4548 , 8, spread_bl.PRJ_CURRENCY_CODE
4549 , 16, spread_bl.TXN_CURRENCY_CODE ) CURRENCY_CODE
4550 , invert.INVERT_ID CURR_RECORD_TYPE_ID
4551 , DECODE ( invert.INVERT_ID
4552 , 4, spread_bl.func_raw_cost
4553 , 8, spread_bl.PRJ_raw_cost
4554 , 16, spread_bl.TXN_raw_cost) raw_cost
4555 , DECODE ( invert.INVERT_ID
4556 , 4, spread_bl.func_BRDN_COST
4557 , 8, spread_bl.PRJ_BRDN_COST
4558 , 16, spread_bl.TXN_BRDN_COST ) BRDN_COST
4559 , DECODE ( invert.INVERT_ID
4560 , 4, spread_bl.func_revenue
4561 , 8, spread_bl.PRJ_revenue
4562 , 16, spread_bl.TXN_revenue ) revenue
4563 , DECODE ( invert.INVERT_ID
4564 , 4, spread_bl.func_actual_raw_cost
4565 , 8, spread_bl.prj_actual_raw_cost
4566 , 16, spread_bl.txn_actual_raw_cost ) actual_raw_cost
4567 , DECODE ( invert.INVERT_ID
4568 , 4, spread_bl.func_actual_brdn_cost
4569 , 8, spread_bl.prj_actual_brdn_cost
4570 , 16, spread_bl.txn_actual_brdn_cost ) actual_brdn_cost
4571 , DECODE ( invert.INVERT_ID
4572 , 4, spread_bl.func_actual_revenue
4573 , 8, spread_bl.prj_actual_revenue
4574 , 16, spread_bl.txn_actual_revenue ) actual_revenue
4575 , DECODE ( invert.INVERT_ID
4576 , 4, spread_bl.func_etc_raw_cost
4577 , 8, spread_bl.prj_etc_raw_cost
4578 , 16, spread_bl.txn_etc_raw_cost ) etc_raw_cost
4579 , DECODE ( invert.INVERT_ID
4580 , 4, spread_bl.func_etc_brdn_cost
4581 , 8, spread_bl.prj_etc_brdn_cost
4582 , 16, spread_bl.txn_etc_brdn_cost ) etc_brdn_cost
4583 , DECODE ( invert.INVERT_ID
4584 , 4, spread_bl.func_etc_revenue
4585 , 8, spread_bl.prj_etc_revenue
4586 , 16, spread_bl.txn_etc_revenue ) etc_revenue
4587 , spread_bl.quantity quantity
4588 , spread_bl.actual_quantity actual_quantity
4589 , spread_bl.etc_quantity etc_quantity
4590 , spread_bl.start_date start_date
4591 , spread_bl.end_date end_date
4592 , spread_bl.period_name period_name
4593 -- , spread_bl.TRACK_AS_LABOR_FLAG track_as_labor_flag
4594 , spread_bl.plan_type_code
4595 , spread_bl.WP_FLAG
4596 from
4597 ( ----- Third inline view 'spread_bl' .............
4598 SELECT /*+ ordered */
4599 ra.project_id
4600 , bl.rowid row_id
4601 , ra.budget_version_id
4602 , bl.resource_asSIGNment_id
4603 , DECODE(ra.task_id, 0, pevs.proj_element_id, ra.task_id) wbs_element_id
4604 , NVL(ra.rbs_element_id, -1) rbs_element_id
4605 , ver.wbs_struct_version_id wbs_struct_version_id
4606 , NVL(ver.rbs_struct_version_id, -1) rbs_struct_version_id
4607 , ver.plan_type_id plan_type_id
4608 , ra.rate_based_flag billable_flag
4609 -- cbs change
4610 , 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',
4611 '1'||ra.resource_class_code, ra.resource_class_code),ra.resource_class_code) resource_class
4612 -- End cbs change
4613 , bl.txn_currency_code txn_currency_code
4614 , bl.txn_raw_cost txn_raw_cost
4615 , bl.txn_burdened_COST txn_brdn_COST
4616 , bl.txn_revenue txn_revenue
4617 , DECODE(ver.wp_flag, 'N', bl.txn_init_raw_cost, NULL) txn_actual_raw_cost -- new
4618 , DECODE(ver.wp_flag, 'N', bl.txn_init_burdened_cost, NULL) txn_actual_brdn_cost -- new
4619 , DECODE(ver.wp_flag, 'N', bl.txn_init_revenue, NULL) txn_actual_revenue -- new
4620 , DECODE(ver.wp_flag, 'N', (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0)), NULL) txn_etc_raw_cost -- new
4621 , DECODE(ver.wp_flag, 'N', (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0)), NULL) txn_etc_brdn_cost -- new
4622 , DECODE(ver.wp_flag, 'N', (bl.txn_revenue - NVL(bl.txn_init_revenue, 0)), NULL) txn_etc_revenue -- new
4623 , bl.project_currency_code prj_currency_code
4624 , bl.project_raw_cost prj_raw_cost
4625 , bl.project_burdened_COST prj_BRDN_COST
4626 , bl.project_revenue prj_revenue
4627 , DECODE(ver.wp_flag, 'N', bl.project_init_raw_cost, NULL) prj_actual_raw_cost -- new
4628 , DECODE(ver.wp_flag, 'N', bl.project_init_burdened_cost, NULL) prj_actual_brdn_cost -- new
4629 , DECODE(ver.wp_flag, 'N', bl.project_init_revenue, NULL) prj_actual_revenue -- new
4630 , DECODE(ver.wp_flag, 'N', (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0)), NULL) prj_etc_raw_cost -- new
4631 , DECODE(ver.wp_flag, 'N', (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0)), NULL) prj_etc_brdn_cost -- new
4632 , DECODE(ver.wp_flag, 'N', (bl.project_revenue - NVL(bl.project_init_revenue, 0)), NULL) prj_etc_revenue -- new
4633 , bl.projfunc_currency_code func_currency_code
4634 , bl.raw_cost func_raw_cost
4635 , bl.burdened_COST func_BRDN_COST
4636 , bl.revenue func_revenue
4637 , DECODE(ver.wp_flag, 'N', bl.init_raw_cost , NULL) func_actual_raw_cost -- new
4638 , DECODE(ver.wp_flag, 'N', bl.init_burdened_cost , NULL) func_actual_brdn_cost -- new
4639 , DECODE(ver.wp_flag, 'N', bl.init_revenue , NULL) func_actual_revenue -- new
4640 , DECODE(ver.wp_flag, 'N', (bl.raw_cost - NVL(bl.init_raw_cost, 0)), NULL) func_etc_raw_cost -- new
4641 , DECODE(ver.wp_flag, 'N', (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)), NULL) func_etc_brdn_cost -- new
4642 , DECODE(ver.wp_flag, 'N', (bl.revenue - NVL(bl.init_revenue, 0)), NULL) func_etc_revenue -- new
4643 , g_global1_currency_code glb1_currency_code
4644 , NULL glb1_raw_cost
4645 , NULL glb1_BRDN_COST
4646 , NULL glb1_revenue
4647 , g_global2_currency_code glb2_currency_code
4648 , NULL glb2_raw_cost
4649 , NULL glb1_BRDN_COST
4650 , NULL glb1_revenue
4651 , bl.quantity quantity
4652 , DECODE(ver.wp_flag, 'N', bl.init_quantity, NULL) actual_quantity -- new
4653 , DECODE(ver.wp_flag, 'N', (bl.quantity - NVL(bl.init_quantity, 0)), NULL) etc_quantity -- new
4654 , bl.start_date
4655 , bl.END_date
4656 , NVL(bl.period_name, g_ntp_period_name) period_name
4657 , ver.time_phased_type_code time_phased_type_code
4658 , ppa.org_id project_org_id
4659 , ppa.carrying_out_organization_id project_organization_id
4660 , ver.plan_type_code /*4471527 */
4661 , ver.WP_FLAG
4662 FROM
4663 PJI_FM_EXTR_PLNVER4 ver
4664 , pa_resource_asSIGNments ra
4665 , PA_BUDGET_LINES bl
4666 , pa_projects_all ppa
4667 , PA_PROJ_ELEM_VER_STRUCTURE pevs
4668 WHERE
4669 ra.resource_asSIGNment_id = bl.resource_asSIGNment_id
4670 AND ra.project_id = ver.PROJECT_ID
4671 AND ra.budget_version_id = ver.plan_version_id
4672 AND ver.project_id = ppa.project_id
4673 AND txn_currency_code IS NOT NULL
4674 AND bl.project_currency_code IS NOT NULL
4675 AND bl.projfunc_currency_code IS NOT NULL
4676 AND pevs.element_version_id = ver.wbs_struct_version_id
4677 AND pevs.project_id = ver.project_id
4678 AND ver.worker_id = g_worker_id
4679 AND ver.time_phased_type_code IN ('P', 'G', 'N')
4680 ) spread_bl
4681 ---- end of third inline view 'spread_bl'...........
4682 ,
4683 (
4684 select 4 INVERT_ID from dual union all
4685 select 8 INVERT_ID from dual union all
4686 select 16 INVERT_ID from dual where PJI_UTILS.GET_SETUP_PARAMETER('TXN_CURR_FLAG') = 'Y'
4687 ) invert
4688 ) collapse_bl
4689 ---- End of second inline view 'collapse_bl' ..........
4690 GROUP BY
4691 collapse_bl.PROJECT_ID
4692 , collapse_bl.WBS_ELEMENT_ID
4693 -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
4694 , collapse_bl.RBS_ELEMENT_ID
4695 , collapse_bl.RBS_STRUCT_VERSION_ID
4696 , collapse_bl.plan_type_id
4697 , collapse_bl.BUDGET_VERSION_ID
4698 , collapse_bl.PROJECT_ORGANIZATION_ID
4699 , collapse_bl.PROJECT_ORG_ID
4700 , collapse_bl.RESOURCE_ASSIGNMENT_ID
4701 , collapse_bl.BILLABLE_FLAG
4702 , collapse_bl.RESOURCE_CLASS
4703 , collapse_bl.TIME_PHASED_TYPE_CODE
4704 , collapse_bl.CURRENCY_CODE
4705 , collapse_bl.start_date
4706 , collapse_bl.end_date
4707 , collapse_bl.period_name
4708 , collapse_bl.row_id
4709 , collapse_bl.plan_type_code
4710 , collapse_bl.WP_FLAG
4711 ) plr
4712 ---- End of first inline view plr ..........
4713 , PJI_ORG_EXTR_INFO orginfo
4714 , pji_time_cal_period_v pji_time
4715 WHERE 1=1
4716 -- AND orginfo.projfunc_currency_mau is not NULL
4717 AND plr.project_org_id = orginfo.org_id
4718 AND DECODE(plr.time_phased_type_code
4719 , 'P', orginfo.pa_calendar_id
4720 , 'G', orginfo.gl_calendar_id
4721 , -l_max_project_id ) = pji_time.calendar_id
4722 AND plr.period_name = pji_time.name
4723 GROUP BY
4724 plr.PROJECT_ID
4725 , plr.PROJECT_ORG_ID
4726 , plr.project_ORGANIZATION_ID
4727 , plr.WBS_ELEMENT_ID
4728 , DECODE(plr.time_phased_type_code
4729 , 'N', -1
4730 , pji_time.cal_period_id)
4731 , DECODE(plr.time_phased_type_code
4732 , 'P', 32
4733 , 'G', 32
4734 , 'N', 2048
4735 , -1) -- period type id...
4736 , DECODE(plr.time_phased_type_code
4737 , 'P', 'P'
4738 , 'G', 'G'
4739 , 'N', 'A'
4740 , 'X') -- CALENDAR_TYPE
4741 , plr.CURR_RECORD_TYPE -- curr code missing.
4742 , plr.currency_code
4743 , plr.RBS_ELEMENT_ID
4744 , plr.RBS_STRUCT_VERSION_ID
4745 , plr.BUDGET_VERSION_ID
4746 , plr.plan_type_id
4747 -- , plr.start_date
4748 -- , plr.end_date
4749 , DECODE(plr.time_phased_type_code, 'P', 'OF', 'G', 'OF', 'N', 'NTR', 'X')
4750 ,plr.plan_type_code ;
4751
4752
4753 print_time('EXTRACT_PLAN_AMOUNTS_PRIRBS : l_count ' || SQL%ROWCOUNT );
4754
4755 DELETE_NTP_CAL_RECORD ( p_max_project_id => l_max_project_id );
4756
4757
4758 print_time('EXTRACT_PLAN_AMOUNTS_PRIRBS : End' );
4759
4760 EXCEPTION
4761 WHEN OTHERS THEN
4762 print_time('EXTRACT_PLAN_AMOUNTS_PRIRBS : Exception ' || SQLERRM );
4763 print_time('EXTRACT_PLAN_AMOUNTS_PRIRBS : Begin worker id is ... ' || 1);
4764 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
4765 p_procedure_name => 'EXTRACT_PLAN_AMOUNTS_PRIRBS');
4766 RAISE;
4767 END;
4768
4769
4770
4771
4772 ----------------------------------------------
4773 --- Overridden ETC Pull apis.
4774 ----------------------------------------------
4775
4776 PROCEDURE RETRIEVE_OVERRIDDEN_WP_ETC IS
4777
4778 l_return_status varchar2(1);
4779 l_msg_data varchar2(500);
4780 l_msg_count NUMBER;
4781
4782 l_project_id NUMBER := 6842; -- 6976; -- 7185
4783 l_latest_pub_str_ver NUMBER := 34269; -- 34951; -- 34982
4784 l_count NUMBER := NULL;
4785
4786 CURSOR c_lp_struct_ver IS
4787 SELECT ver.project_id, ver.wbs_struct_version_id
4788 FROM pji_fm_extr_plnver4 ver
4789 WHERE ver.wp_flag = 'Y'
4790 AND ver.lp_flag = 'Y'
4791 AND ver.worker_id = g_worker_id;
4792
4793 BEGIN
4794
4795 -- dbms_output.put_line ( ' Begin.. ');
4796
4797 Pji_Pjp_Fp_Curr_Wrap.INIT_ERR_STACK
4798 ( p_package_name => g_package_name
4799 , x_return_status => l_return_status ) ;
4800
4801 --
4802 -- Why the following code:
4803 -- When RETRIEVE_OVERRIDDEN_WP_ETC is called, we intend to process only overridden ETC values.
4804 -- Currently there is no locking mechanism for either wbs header or the plan lines in this flow.
4805 -- One of the following alternative solutions are considered.
4806 -- a. Implement locking.
4807 -- b.
4808 DELETE FROM pji_fm_extr_plan_lines;
4809 -- c. call PJI_FM_XBS_ACCUM_MAINT.plan_update_pvt; and then call delete plan lines.
4810 -- Going with b for now, for simplicity.
4811 --
4812
4813
4814 FOR i IN c_lp_struct_ver LOOP
4815
4816 BEGIN
4817
4818 print_time ( ' i.project_id = ' || i.project_id || ' i.wbs_struct_version_id ' || i.wbs_struct_version_id );
4819
4820 pa_progress_pub.COPY_PROGRESS_ACT_ETC(
4821 p_project_id => i.project_id
4822 , p_src_str_ver_id => i.wbs_struct_version_id
4823 , p_dst_str_ver_id => i.wbs_struct_version_id
4824 , p_pji_conc_prog_context => 'Y'
4825 , p_calling_context => 'PJI' -- IN VARCHAR2 := 'PUBLISH'
4826 -- ,p_copy_actuals_flag IN VARCHAR2 := 'Y' -- We want the default value.
4827 -- ,p_copy_ETC_flag IN VARCHAR2 := 'Y' -- We want the default value.
4828 , x_return_status => l_return_status
4829 , x_msg_count => l_msg_count
4830 , x_msg_data => l_msg_data
4831 );
4832
4833 EXCEPTION
4834 WHEN OTHERS THEN
4835 print_time ( ' RETRIEVE_OVERRIDDEN_WP_ETC ' || SQLERRM );
4836 END;
4837
4838 END LOOP;
4839
4840 --
4841 -- Delete plan lines that have no relevant overridden ETC info to avoid unnecessary processing overhead.
4842 --
4843 DELETE FROM pji_fm_extr_plan_lines
4844 WHERE
4845 (PROJECT_ID, PLAN_VERSION_ID) IN
4846 (SELECT DISTINCT project_id, plan_version_id
4847 FROM pji_fm_extr_plnver4) AND
4848 ETC_QUANTITY IS NULL AND
4849 ETC_TXN_BURDENED_COST IS NULL AND
4850 ETC_PRJ_BURDENED_COST IS NULL AND
4851 ETC_PFC_BURDENED_COST IS NULL AND
4852 ETC_TXN_RAW_COST IS NULL AND
4853 ETC_PRJ_RAW_COST IS NULL AND
4854 ETC_PFC_RAW_COST IS NULL;
4855
4856
4857 /*
4858 dbms_output.put_line ( ' After call.. l_msg_code ' || l_msg_data || ' l_return_status ' || l_return_status );
4859
4860 SELECT COUNT(1)
4861 INTO l_count
4862 FROM pji_fm_extr_plan_lines
4863 WHERE project_id = l_project_id;
4864
4865 dbms_output.put_line ( ' Count in plan lines is.. ' || l_count );
4866 */
4867
4868 EXCEPTION
4869 WHEN OTHERS THEN
4870 PJI_PJP_FP_CURR_WRAP.EXCP_HANDLER
4871 ( p_package_name => g_package_name
4872 , p_procedure_name => 'RETRIEVE_OVERRIDDEN_WP_ETC'
4873 , x_return_status => l_return_status ) ;
4874
4875 RAISE;
4876 END;
4877
4878
4879 PROCEDURE EXTRACT_PLAN_ETC_PRIRBS (
4880 p_slice_type IN VARCHAR2 := 'PRI'
4881 -- Valid values are 'PRI' and 'SEC'.
4882 -- 'PRI' for RBS push and Partial refresh
4883 -- 'SEC' for Truncate
4884 ) IS
4885
4886 l_max_project_id NUMBER := NULL;
4887 l_sysdate DATE := SYSDATE;
4888 l_return_status varchar2(1);
4889 l_msg_data varchar2(500);
4890 l_msg_count NUMBER;
4891
4892 BEGIN
4893
4894 Pji_Pjp_Fp_Curr_Wrap.INIT_ERR_STACK
4895 ( p_package_name => g_package_name
4896 , x_return_status => l_return_status ) ;
4897
4898 print_time('EXTRACT_PLAN_ETC_PRIRBS : Begin' );
4899 print_time('EXTRACT_PLAN_ETC_PRIRBS : Begin worker id is ... ' || g_worker_id);
4900
4901 IF (p_slice_type NOT IN ('PRI','SEC')) THEN
4902 print_time('EXTRACT_PLAN_ETC_PRIRBS : invalid p_slice_type ' || p_slice_type );
4903 RETURN;
4904 END IF;
4905
4906
4907 INSERT_NTP_CAL_RECORD ( x_max_project_id => l_max_project_id );
4908
4909 IF (l_max_project_id IS NULL) THEN
4910 RETURN;
4911 END IF;
4912
4913 /* Added for bug 11843459 */
4914 if PJI_PJP_GEN_PERF_ALL.GET_PARAMETER('PJI_PJP_PERF_PRL') = 'Y' then
4915 PJI_PJP_GEN_PERF_ALL.EXTRACT_PLAN_ETC_PRIRBS(l_max_project_id,p_slice_type);
4916 else
4917 -- cbs change
4918 IF P_PA_DEBUG_MODE = 'Y' THEN
4919 pa_debug.write('EXTRACT_PLAN_ETC_PRIRBS: ' || g_module_name,'Before calling SET_RES_CLASS_FLAG' ,1);
4920 END IF;
4921
4922 SET_RES_CLASS_FLAG;
4923
4924 IF P_PA_DEBUG_MODE = 'Y' THEN
4925 pa_debug.write('EXTRACT_PLAN_ETC_PRIRBS: ' || g_module_name,'After calling SET_RES_CLASS_FLAG' ,1);
4926 END IF;
4927 -- End cbs change
4928
4929 INSERT /*+ parallel(PJI_FP_AGGR_PJP1) */ /* Added for bug 13030627 */
4930 INTO PJI_FP_AGGR_PJP1
4931 (
4932 WORKER_ID
4933 , PROJECT_ID
4934 , PROJECT_ORG_ID
4935 , PROJECT_ORGANIZATION_ID
4936 , PROJECT_ELEMENT_ID
4937 , TIME_ID
4938 , PERIOD_TYPE_ID
4939 , CALENDAR_TYPE
4940 , RBS_AGGR_LEVEL
4941 , WBS_ROLLUP_FLAG
4942 , PRG_ROLLUP_FLAG
4943 , CURR_RECORD_TYPE_ID
4944 , CURRENCY_CODE
4945 , RBS_ELEMENT_ID
4946 , RBS_VERSION_ID
4947 , PLAN_VERSION_ID
4948 , PLAN_TYPE_ID
4949 , RAW_COST
4950 , BRDN_COST
4951 , REVENUE
4952 , BILL_RAW_COST
4953 , BILL_BRDN_COST
4954 , BILL_LABOR_RAW_COST
4955 , BILL_LABOR_BRDN_COST
4956 , BILL_LABOR_HRS
4957 , EQUIPMENT_RAW_COST
4958 , EQUIPMENT_BRDN_COST
4959 , CAPITALIZABLE_RAW_COST
4960 , CAPITALIZABLE_BRDN_COST
4961 , LABOR_RAW_COST
4962 , LABOR_BRDN_COST
4963 , LABOR_HRS
4964 , LABOR_REVENUE
4965 , EQUIPMENT_HOURS
4966 , BILLABLE_EQUIPMENT_HOURS
4967 , SUP_INV_COMMITTED_COST
4968 , PO_COMMITTED_COST
4969 , PR_COMMITTED_COST
4970 , OTH_COMMITTED_COST
4971 , ACT_LABOR_HRS
4972 , ACT_EQUIP_HRS
4973 , ACT_LABOR_BRDN_COST
4974 , ACT_EQUIP_BRDN_COST
4975 , ACT_BRDN_COST
4976 , ACT_RAW_COST
4977 , ACT_REVENUE
4978 , ACT_LABOR_RAW_COST
4979 , ACT_EQUIP_RAW_COST
4980 , ETC_LABOR_HRS
4981 , ETC_EQUIP_HRS
4982 , ETC_LABOR_BRDN_COST
4983 , ETC_EQUIP_BRDN_COST
4984 , ETC_BRDN_COST
4985 , ETC_RAW_COST
4986 , ETC_LABOR_RAW_COST
4987 , ETC_EQUIP_RAW_COST
4988 , CUSTOM1
4989 , CUSTOM2
4990 , CUSTOM3
4991 , CUSTOM4
4992 , CUSTOM5
4993 , CUSTOM6
4994 , CUSTOM7
4995 , CUSTOM8
4996 , CUSTOM9
4997 , CUSTOM10
4998 , CUSTOM11
4999 , CUSTOM12
5000 , CUSTOM13
5001 , CUSTOM14
5002 , CUSTOM15
5003 , LINE_TYPE
5004 , RATE_DANGLING_FLAG
5005 , TIME_DANGLING_FLAG
5006 , PRG_LEVEL
5007 , PLAN_TYPE_CODE
5008 )
5009 SELECT /*+ ordered no_merge(plr) */
5010 g_worker_id WORKER_ID
5011 , plr.PROJECT_ID
5012 , plr.PROJECT_ORG_ID
5013 , plr.project_ORGANIZATION_ID
5014 , plr.WBS_ELEMENT_ID project_element_id
5015 , DECODE(plr.time_phased_type_code
5016 , 'N', -1
5017 , pji_time.cal_period_id) time_id
5018 , DECODE(plr.time_phased_type_code
5019 , 'P', 32
5020 , 'G', 32
5021 , 'N', 2048
5022 , -1) period_type_id -- period type id...
5023 , DECODE(plr.time_phased_type_code
5024 , 'P', 'P'
5025 , 'G', 'G'
5026 , 'N', 'A'
5027 , 'X') CALENDAR_TYPE
5028 , 'L' RBS_AGGR_LEVEL
5029 , 'N' WBS_ROLLUP_FLAG
5030 , 'N' PRG_ROLLUP_FLAG
5031 , plr.CURR_RECORD_TYPE CURR_RECORD_TYPE_id
5032 , plr.currency_code
5033 , plr.RBS_ELEMENT_ID
5034 , plr.RBS_STRUCT_VERSION_ID RBS_VERSION_ID
5035 , plr.BUDGET_VERSION_ID plan_version_id
5036 , plr.plan_type_id
5037 , SUM(plr.RAW_COST) RAW_COST
5038 , SUM(plr.BRDN_COST) BRDN_COST
5039 , SUM(plr.REVENUE) REVENUE
5040 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) BILL_RAW_COST
5041 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) BILL_BRDN_COST
5042 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YPEOPLE', plr.raw_cost, 0 ) ) BILL_LABOR_RAW_COST
5043 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YPEOPLE' , plr.BRDN_COST, 0 ) ) BILL_LABOR_BRDN_COST
5044 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'YPEOPLE', plr.quantity, 0 ) ) BILL_LABOR_HRS */ -- bug 6039785
5045 , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'YPEOPLE',
5046 DECODE ( plr.billable_flag , 'Y' , plr.quantity , 0 ) , 0 ) ) BILL_LABOR_HRS -- bug 6039785
5047 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT' , plr.raw_cost, 0 ) ) EQUIPMENT_RAW_COST
5048 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT' , plr.BRDN_COST, 0 ) ) EQUIPMENT_BRDN_COST
5049 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) CAPITALIZABLE_RAW_COST
5050 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) CAPITALIZABLE_BRDN_COST
5051 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.raw_cost, 0 ) ) LABOR_RAW_COST
5052 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.BRDN_COST, 0 ) ) LABOR_BRDN_COST
5053 /* , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.quantity, 0 ) ) labor_hrs */ -- bug 6039785
5054 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', DECODE(plr.billable_flag , 'Y', plr.quantity,0),
5055 0 ) ) labor_hrs -- bug 6039785
5056 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.revenue, 0 ) ) LABOR_REVENUE
5057 /* , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT', plr.quantity, 0 ) ) EQUIPMENT_HOURS */ -- bug 6039785
5058 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT', DECODE(plr.billable_flag , 'Y', plr.quantity, 0),
5059 0 ) ) EQUIPMENT_HOURS -- bug 6039785
5060 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YEQUIPMENT', plr.quantity, 0 ) ) BILLABLE_EQUIPMENT_HOURS */ -- bug 6039785
5061 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YEQUIPMENT', DECODE(plr.billable_flag , 'Y', plr.quantity, 0),
5062 0 ) ) BILLABLE_EQUIPMENT_HOURS -- bug 6039785
5063 , TO_NUMBER(NULL) SUP_INV_COMMITTED_COST
5064 , TO_NUMBER(NULL) PO_COMMITTED_COST
5065 , TO_NUMBER(NULL) PR_COMMITTED_COST
5066 , TO_NUMBER(NULL) OTH_COMMITTED_COST
5067 /* , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.actual_quantity, 0 ) ) ACT_LABOR_HRS */ -- bug 6039785
5068 , SUM ( DECODE ( plr.resource_class, 'PEOPLE' , DECODE (plr.billable_flag ,'Y', plr.actual_quantity,0),
5069 0 ) ) ACT_LABOR_HRS -- bug 6039785
5070 /* , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT', plr.actual_quantity, 0 ) ) ACT_EQUIP_HRS */ -- bug 6039785
5071 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT', DECODE (plr.billable_flag ,'Y', plr.actual_quantity, 0),
5072 0 ) ) ACT_EQUIP_HRS -- bug 6039785
5073 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.actual_BRDN_COST, 0 ) ) ACT_LABOR_BRDN_COST
5074 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT' , plr.actual_BRDN_COST, 0 ) ) ACT_EQUIP_BRDN_COST
5075 , SUM ( plr.actual_brdn_cost ) ACT_BRDN_COST
5076 , SUM ( plr.actual_raw_cost ) ACT_RAW_COST
5077 , SUM ( plr.actual_revenue ) ACT_REVENUE
5078 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.actual_RAW_COST, 0 ) ) ACT_LABOR_RAW_COST
5079 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT' , plr.actual_RAW_COST, 0 ) ) ACT_EQUIP_RAW_COST
5080 /* , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.etc_quantity, 0 ) ) ETC_LABOR_HRS */ -- bug 6039785
5081 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', DECODE (plr.billable_flag , 'Y' , plr.ETC_quantity,0),
5082 0 ) ) ETC_LABOR_HRS -- bug 6039785
5083 /* , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT', plr.etc_quantity, 0 ) ) ETC_EQUIP_HRS */ -- bug 6039785
5084 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT', DECODE (plr.billable_flag , 'Y' , plr.etc_quantity, 0) ,
5085 0 ) ) ETC_EQUIP_HRS -- bug 6039785
5086 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.etc_BRDN_COST, 0 ) ) ETC_LABOR_BRDN_COST
5087 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT' , plr.etc_BRDN_COST, 0 ) ) ETC_EQUIP_BRDN_COST
5088 , SUM(plr.etc_BRDN_COST) ETC_BRDN_COST
5089 , SUM(plr.etc_RAW_COST) ETC_RAW_COST
5090 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.etc_raw_cost, 0 ) ) ETC_LABOR_raw_COST
5091 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT', plr.etc_raw_cost, 0 ) ) ETC_EQUIP_raw_COST
5092 , NULL CUSTOM1
5093 , NULL CUSTOM2
5094 , NULL CUSTOM3
5095 , NULL CUSTOM4
5096 , NULL CUSTOM5
5097 , NULL CUSTOM6
5098 , NULL CUSTOM7
5099 , NULL CUSTOM8
5100 , NULL CUSTOM9
5101 , NULL CUSTOM10
5102 , NULL CUSTOM11
5103 , NULL CUSTOM12
5104 , NULL CUSTOM13
5105 , NULL CUSTOM14
5106 , NULL CUSTOM15
5107 , DECODE(plr.time_phased_type_code, 'P', 'OF', 'G', 'OF', 'N', 'NTR', 'X') LINE_TYPE
5108 , NULL time_dangling_flag
5109 , NULL rate_dangling_flag
5110 , g_default_prg_level prg_level
5111 , plr.PLAN_TYPE_CODE
5112 FROM
5113 ( ----- First inline view plr .............
5114 SELECT /*+ no_merge(collapse_bl) */
5115 collapse_bl.PROJECT_ID -- , 1 partition_id
5116 , collapse_bl.WBS_ELEMENT_ID -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
5117 , SUM(collapse_bl.CURR_RECORD_TYPE_ID) CURR_RECORD_TYPE
5118 , collapse_bl.RBS_ELEMENT_ID
5119 , collapse_bl.RBS_STRUCT_VERSION_ID
5120 , collapse_bl.plan_type_id
5121 , collapse_bl.BUDGET_VERSION_ID
5122 , collapse_bl.PROJECT_ORGANIZATION_ID
5123 , collapse_bl.PROJECT_ORG_ID
5124 , collapse_bl.BILLABLE_FLAG
5125 , collapse_bl.RESOURCE_CLASS -- , CALENDAR_TYPE -- , CALENDAR_ID
5126 , collapse_bl.CURRENCY_CODE
5127 , MAX(collapse_bl.raw_cost) raw_cost
5128 , MAX(collapse_bl.BRDN_COST) BRDN_COST
5129 , MAX(collapse_bl.revenue) revenue
5130 , MAX(collapse_bl.actual_raw_cost) actual_raw_cost
5131 , MAX(collapse_bl.actual_BRDN_COST) actual_BRDN_COST
5132 , MAX(collapse_bl.actual_revenue) actual_revenue
5133 , MAX(collapse_bl.etc_raw_cost) etc_raw_cost
5134 , MAX(collapse_bl.etc_BRDN_COST) etc_BRDN_COST
5135 , MAX(collapse_bl.quantity) quantity
5136 , MAX(collapse_bl.actual_quantity) actual_quantity
5137 , MAX(collapse_bl.etc_quantity) etc_quantity
5138 , collapse_bl.period_name period_name -- , TRACK_AS_LABOR_FLAG track_as_labor_flag
5139 , collapse_bl.row_id
5140 , collapse_bl.plan_type_code
5141 , collapse_bl.time_phased_type_code
5142 FROM
5143 ( ----- Second inline view 'collapse_bl' begin .............
5144 SELECT /*+ no_merge(spread_bl) */
5145 spread_bl.row_id row_id
5146 , spread_bl.PROJECT_ID
5147 , spread_bl.BUDGET_VERSION_ID
5148 , spread_bl.WBS_ELEMENT_ID
5149 , spread_bl.RBS_ELEMENT_ID
5150 , spread_bl.WBS_STRUCT_VERSION_ID
5151 , spread_bl.RBS_STRUCT_VERSION_ID
5152 , spread_bl.plan_type_id
5153 , spread_bl.BILLABLE_FLAG
5154 , spread_bl.RESOURCE_CLASS -- , spread_bl.CALENDAR_TYPE -- , pji_time.CALENDAR_ID
5155 , spread_bl.PROJECT_ORGANIZATION_ID
5156 , spread_bl.PROJECT_ORG_ID
5157 , DECODE( invert.INVERT_ID
5158 , 4, spread_bl.func_CURRENCY_CODE
5159 , 8, spread_bl.PRJ_CURRENCY_CODE
5160 , 16, spread_bl.TXN_CURRENCY_CODE ) CURRENCY_CODE
5161 , invert.INVERT_ID CURR_RECORD_TYPE_ID
5162 , DECODE ( invert.INVERT_ID
5163 , 4, spread_bl.func_raw_cost
5164 , 8, spread_bl.PRJ_raw_cost
5165 , 16, spread_bl.TXN_raw_cost) raw_cost
5166 , DECODE ( invert.INVERT_ID
5167 , 4, spread_bl.func_BRDN_COST
5168 , 8, spread_bl.PRJ_BRDN_COST
5169 , 16, spread_bl.TXN_BRDN_COST ) BRDN_COST
5170 , DECODE ( invert.INVERT_ID
5171 , 4, spread_bl.func_revenue
5172 , 8, spread_bl.PRJ_revenue
5173 , 16, spread_bl.TXN_revenue ) revenue
5174 , DECODE ( invert.INVERT_ID
5175 , 4, spread_bl.func_actual_raw_cost
5176 , 8, spread_bl.prj_actual_raw_cost
5177 , 16, spread_bl.txn_actual_raw_cost ) actual_raw_cost
5178 , DECODE ( invert.INVERT_ID
5179 , 4, spread_bl.func_actual_brdn_cost
5180 , 8, spread_bl.prj_actual_brdn_cost
5181 , 16, spread_bl.txn_actual_brdn_cost ) actual_brdn_cost
5182 , DECODE ( invert.INVERT_ID
5183 , 4, spread_bl.func_actual_revenue
5184 , 8, spread_bl.prj_actual_revenue
5185 , 16, spread_bl.txn_actual_revenue ) actual_revenue
5186 , DECODE ( invert.INVERT_ID
5187 , 4, spread_bl.func_etc_raw_cost
5188 , 8, spread_bl.prj_etc_raw_cost
5189 , 16, spread_bl.txn_etc_raw_cost ) etc_raw_cost
5190 , DECODE ( invert.INVERT_ID
5191 , 4, spread_bl.func_etc_brdn_cost
5192 , 8, spread_bl.prj_etc_brdn_cost
5193 , 16, spread_bl.txn_etc_brdn_cost ) etc_brdn_cost
5194 , spread_bl.quantity quantity
5195 , spread_bl.actual_quantity actual_quantity
5196 , spread_bl.etc_quantity etc_quantity
5197 , spread_bl.period_name period_name
5198 ,spread_bl.plan_type_code
5199 , spread_bl.time_phased_type_code
5200 FROM
5201 ( ----- Third inline view 'spread_bl' .............
5202 SELECT /*+ ordered parallel(ver) */ /* Added for bug 13030627 */
5203 ra.project_id
5204 , bl.ROWID row_id
5205 , ra.budget_version_id
5206 , DECODE(ra.task_id, 0, pevs.proj_element_id, ra.task_id) wbs_element_id
5207 , NVL(ra.rbs_element_id, -1) rbs_element_id
5208 , ver.wbs_struct_version_id wbs_struct_version_id
5209 , NVL(ver.rbs_struct_version_id, -1) rbs_struct_version_id
5210 , ver.plan_type_id plan_type_id
5211 , ra.rate_based_flag billable_flag
5212 -- cbs change
5213 , 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',
5214 '1'||ra.resource_class_code, ra.resource_class_code),ra.resource_class_code) resource_class
5215 -- End cbs change
5216 , bl.txn_currency_code txn_currency_code
5217 , bl.txn_raw_cost txn_raw_cost
5218 , bl.txn_burdened_COST txn_brdn_COST
5219 , bl.txn_revenue txn_revenue
5220 , DECODE(p_slice_type||ver.wp_flag, 'SECY',
5221 decode(ppa.structure_sharing_code, 'SHARE_FULL',TO_NUMBER(NULL),bl.txn_init_raw_cost),
5222 bl.txn_init_raw_cost) txn_actual_raw_cost
5223 , DECODE(p_slice_type||ver.wp_flag, 'SECY',
5224 decode(ppa.structure_sharing_code, 'SHARE_FULL',TO_NUMBER(NULL),bl.txn_init_burdened_cost),
5225 bl.txn_init_burdened_cost) txn_actual_brdn_cost
5226 , DECODE(p_slice_type||ver.wp_flag, 'SECY', TO_NUMBER(NULL), bl.txn_init_revenue) txn_actual_revenue
5227 , DECODE(ver.wp_flag, 'N', bl.txn_raw_cost - bl.txn_init_raw_cost, bl.txn_raw_cost) txn_etc_raw_cost
5228 , DECODE(ver.wp_flag, 'N', bl.txn_burdened_cost - bl.txn_init_burdened_cost, bl.txn_burdened_cost) txn_etc_brdn_cost
5229 , bl.project_currency_code prj_currency_code
5230 , bl.project_raw_cost prj_raw_cost
5231 , bl.project_burdened_COST prj_BRDN_COST
5232 , bl.project_revenue prj_revenue
5233 , DECODE(p_slice_type||ver.wp_flag, 'SECY',
5234 decode(ppa.structure_sharing_code, 'SHARE_FULL',TO_NUMBER(NULL),bl.project_init_raw_cost),
5235 bl.project_init_raw_cost) prj_actual_raw_cost
5236 , DECODE(p_slice_type||ver.wp_flag, 'SECY',
5237 decode(ppa.structure_sharing_code, 'SHARE_FULL',TO_NUMBER(NULL),bl.project_init_burdened_cost),
5238 bl.project_init_burdened_cost) prj_actual_brdn_cost
5239 , DECODE(p_slice_type||ver.wp_flag, 'SECY', TO_NUMBER(NULL), bl.project_init_revenue) prj_actual_revenue
5240 , DECODE(ver.wp_flag, 'N', bl.project_raw_cost - bl.project_init_raw_cost, bl.project_raw_cost) prj_etc_raw_cost
5241 , DECODE(ver.wp_flag, 'N', bl.project_burdened_cost - bl.project_init_burdened_cost, bl.project_burdened_cost) prj_etc_brdn_cost
5242 , bl.projfunc_currency_code func_currency_code
5243 , bl.raw_cost func_raw_cost
5244 , bl.burdened_COST func_BRDN_COST
5245 , bl.revenue func_revenue
5246 , DECODE(p_slice_type||ver.wp_flag, 'SECY',
5247 decode(ppa.structure_sharing_code, 'SHARE_FULL',TO_NUMBER(NULL),bl.init_raw_cost),
5248 bl.init_raw_cost) func_actual_raw_cost
5249 , DECODE(p_slice_type||ver.wp_flag, 'SECY',
5250 decode(ppa.structure_sharing_code, 'SHARE_FULL',TO_NUMBER(NULL),bl.init_burdened_cost),
5251 bl.init_burdened_cost) func_actual_brdn_cost
5252 , DECODE(p_slice_type||ver.wp_flag, 'SECY', TO_NUMBER(NULL), bl.init_revenue) func_actual_revenue
5253 , DECODE(ver.wp_flag, 'N', bl.raw_cost - bl.init_raw_cost, bl.raw_cost) func_etc_raw_cost
5254 , DECODE(ver.wp_flag, 'N', bl.burdened_cost - bl.init_burdened_cost, bl.burdened_cost) func_etc_brdn_cost
5255 , bl.quantity quantity
5256 , DECODE(p_slice_type||ver.wp_flag, 'SECY',
5257 decode(ppa.structure_sharing_code, 'SHARE_FULL',TO_NUMBER(NULL),bl.init_quantity),
5258 bl.init_quantity) actual_quantity
5259 , DECODE(ver.wp_flag, 'N', bl.quantity - bl.init_quantity, bl.quantity) etc_quantity
5260 , Decode(ver.time_phased_type_code,'N','XXX',NVL(bl.period_name, 'XXX')) period_name /* Added for bug 8708651 */
5261 , ppa.org_id project_org_id
5262 , ppa.carrying_out_organization_id project_organization_id
5263 , ver.plan_type_code
5264 , ver.time_phased_type_code
5265 FROM
5266 PJI_FM_EXTR_PLNVER4 ver
5267 , PA_RESOURCE_ASSIGNMENTS ra
5268 , PA_BUDGET_LINES bl
5269 , PA_PROJECTS_ALL ppa
5270 , PA_PROJ_ELEM_VER_STRUCTURE pevs
5271 WHERE
5272 ra.resource_asSIGNment_id = bl.resource_asSIGNment_id
5273 AND (
5274 (
5275 ( p_slice_type = 'PRI' )
5276 AND ( ( ver.wp_flag = 'Y' ) OR ( ver.wp_flag = 'N' AND ver.baselined_flag = 'N' ) )
5277 )
5278 OR
5279 ( p_slice_type = 'SEC' )
5280 )
5281 AND ra.project_id = ver.PROJECT_ID
5282 AND ra.budget_version_id = ver.plan_version_id
5283 AND ver.project_id = ppa.project_id
5284 AND bl.txn_currency_code IS NOT NULL
5285 AND bl.project_currency_code IS NOT NULL
5286 AND bl.projfunc_currency_code IS NOT NULL
5287 AND pevs.element_version_id = ver.wbs_struct_version_id
5288 AND pevs.project_id = ver.project_id
5289 AND ver.worker_id = g_worker_id
5290 AND ver.time_phased_type_code IN ('P', 'G', 'N')
5291 UNION ALL
5292 SELECT /*+ ordered parallel(ver) */ /* Added for bug 13030627 */
5293 bl.project_id
5294 , bl.ROWID row_id
5295 , bl.plan_version_id budget_version_id
5296 , DECODE(bl.project_element_id, 0, pevs.proj_element_id, bl.project_element_id) wbs_element_id
5297 , NVL(bl.rbs_element_id, -1) rbs_element_id
5298 , bl.struct_ver_id wbs_struct_version_id
5299 , NVL(ver.rbs_struct_version_id, -1) rbs_struct_version_id
5300 , bl.plan_type_id plan_type_id -- ver.plan_type_id
5301 , bl.rate_based_flag billable_flag -- ra.rate_based_flag billable_flag
5302 , bl.resource_class_code resource_class -- ra.resource_class_code resource_class
5303 , bl.txn_currency_code txn_currency_code
5304 , bl.txn_raw_cost txn_raw_cost
5305 , bl.txn_burdened_cost txn_BRDN_COST
5306 , bl.txn_revenue txn_revenue
5307 , bl.act_txn_raw_cost act_txn_raw_cost
5308 , bl.act_txn_burdened_cost act_txn_brdn_cost
5309 , bl.act_txn_revenue act_txn_revenue
5310 , bl.etc_txn_raw_cost etc_txn_raw_cost
5311 , bl.etc_txn_burdened_cost etc_txn_brdn_cost
5312 , bl.prj_currency_code prj_currency_code
5313 , bl.prj_raw_cost prj_raw_cost
5314 , bl.prj_burdened_cost prj_BRDN_COST
5315 , bl.prj_revenue prj_revenue
5316 , bl.act_prj_raw_cost act_prj_raw_cost
5317 , bl.act_prj_burdened_cost act_prj_brdn_cost
5318 , bl.act_prj_revenue act_prj_revenue
5319 , bl.etc_prj_raw_cost etc_prj_raw_cost
5320 , bl.etc_prj_burdened_cost act_prj_brdn_cost
5321 , bl.pfc_currency_code pfc_currency_code
5322 , bl.pfc_raw_cost prj_raw_cost
5323 , bl.pfc_burdened_cost prj_BRDN_COST
5324 , bl.pfc_revenue prj_revenue
5325 , bl.act_pfc_raw_cost act_prj_raw_cost
5326 , bl.act_pfc_burdened_cost act_prj_brdn_cost
5327 , bl.act_pfc_revenue act_prj_revenue
5328 , bl.etc_pfc_raw_cost etc_prj_raw_cost
5329 , bl.etc_pfc_burdened_cost act_prj_brdn_cost
5330 , bl.quantity quantity
5331 , bl.act_quantity act_quantity
5332 , bl.etc_quantity etc_quantity
5333 , NVL(bl.period_name, 'XXX') period_name
5334 , bl.project_org_id project_org_id
5335 , ppa.carrying_out_organization_id project_organization_id
5336 , ver.plan_type_code
5337 , ver.time_phased_type_code
5338 FROM
5339 PJI_FM_EXTR_PLNVER4 ver
5340 , PJI_FM_EXTR_PLAN_LINES bl
5341 , PA_PROJECTS_ALL ppa
5342 , PA_PROJ_ELEM_VER_STRUCTURE pevs
5343 WHERE 1=1
5344 AND ver.wp_flag = 'Y'
5345 AND bl.project_id = ver.project_id
5346 AND bl.plan_version_id = ver.plan_version_id
5347 AND bl.plan_type_id = ver.plan_type_id
5348 AND ppa.project_id = ver.project_id
5349 AND bl.project_id = ppa.project_id
5350 AND bl.TXN_CURRENCY_CODE IS NOT NULL
5351 AND bl.prj_currency_code IS NOT NULL
5352 AND bl.pfc_currency_code IS NOT NULL
5353 AND pevs.element_version_id = ver.wbs_struct_version_id
5354 AND pevs.project_id = ver.project_id
5355 AND ver.worker_id = g_worker_id
5356 AND ver.time_phased_type_code IN ('P', 'G', 'N')
5357 AND p_slice_type = 'SEC' -- 4682341
5358 ) spread_bl
5359 ---- end of third inline view 'spread_bl'...........
5360 ,
5361 (
5362 SELECT 4 INVERT_ID FROM dual UNION ALL
5363 SELECT 8 INVERT_ID FROM dual UNION ALL
5364 SELECT 16 INVERT_ID FROM dual where PJI_UTILS.GET_SETUP_PARAMETER('TXN_CURR_FLAG') = 'Y'
5365 ) invert
5366 ) collapse_bl
5367 ---- End of second inline view 'collapse_bl' ..........
5368 GROUP BY
5369 collapse_bl.PROJECT_ID
5370 , collapse_bl.WBS_ELEMENT_ID
5371 , collapse_bl.RBS_ELEMENT_ID
5372 , collapse_bl.RBS_STRUCT_VERSION_ID
5373 , collapse_bl.plan_type_id
5374 , collapse_bl.BUDGET_VERSION_ID
5375 , collapse_bl.PROJECT_ORGANIZATION_ID
5376 , collapse_bl.PROJECT_ORG_ID
5377 , collapse_bl.BILLABLE_FLAG
5378 , collapse_bl.RESOURCE_CLASS
5379 , collapse_bl.CURRENCY_CODE
5380 , collapse_bl.period_name
5381 , collapse_bl.row_id
5382 , collapse_bl.plan_type_code
5383 , collapse_bl.time_phased_type_code
5384 ) plr
5385 ---- End of first inline view plr ..........
5386 , PJI_ORG_EXTR_INFO orginfo
5387 , pji_time_cal_period_v pji_time
5388 WHERE 1=1
5389 -- AND orginfo.projfunc_currency_mau is not NULL
5390 AND plr.project_org_id = orginfo.org_id
5391 AND DECODE(plr.time_phased_type_code
5392 , 'P', orginfo.pa_calendar_id
5393 , 'G', orginfo.gl_calendar_id
5394 , - l_max_project_id ) = pji_time.calendar_id
5395 AND plr.period_name = pji_time.name
5396 GROUP BY
5397 plr.PROJECT_ID
5398 , plr.PROJECT_ORG_ID
5399 , plr.project_ORGANIZATION_ID
5400 , plr.WBS_ELEMENT_ID
5401 , DECODE(plr.time_phased_type_code
5402 , 'N', -1
5403 , pji_time.cal_period_id)
5404 , DECODE(plr.time_phased_type_code
5405 , 'P', 32
5406 , 'G', 32
5407 , 'N', 2048
5408 , -1) -- period type id...
5409 , DECODE(plr.time_phased_type_code
5410 , 'P', 'P'
5411 , 'G', 'G'
5412 , 'N', 'A'
5413 , 'X') -- CALENDAR_TYPE
5414 , plr.CURR_RECORD_TYPE -- curr code missing.
5415 , plr.currency_code
5416 , plr.RBS_ELEMENT_ID
5417 , plr.RBS_STRUCT_VERSION_ID
5418 , plr.BUDGET_VERSION_ID
5419 , plr.plan_type_id
5420 , DECODE(plr.time_phased_type_code, 'P', 'OF', 'G', 'OF', 'N', 'NTR', 'X')
5421 , plr.PLAN_TYPE_CODE;
5422
5423 COMMIT; --Added for Bug# 9746330
5424
5425 end if; /* Added for bug 11843459 */
5426
5427 print_time('EXTRACT_PLAN_ETC_PRIRBS : Finished. # rows extracted is ' || SQL%ROWCOUNT);
5428
5429 DELETE_NTP_CAL_RECORD ( p_max_project_id => l_max_project_id );
5430
5431
5432 EXCEPTION
5433 WHEN OTHERS THEN
5434 PJI_PJP_FP_CURR_WRAP.EXCP_HANDLER
5435 ( p_package_name => g_package_name
5436 , p_procedure_name => 'EXTRACT_PLAN_ETC_PRIRBS'
5437 , x_return_status => l_return_status ) ;
5438
5439 RAISE;
5440 END;
5441
5442
5443 PROCEDURE DELETE_PLAN_LINES
5444 ( x_return_status OUT NOCOPY VARCHAR2 ) IS
5445
5446 --Bug 6047966
5447 l_process varchar2(30);
5448 l_plan_ver_type_code varchar2(30);
5449
5450 BEGIN
5451
5452 print_time ( 'DELETE_PLAN_LINES : begin ' );
5453
5454 Pji_Pjp_Fp_Curr_Wrap.INIT_ERR_STACK
5455 ( p_package_name => g_package_name
5456 , x_return_status => x_return_status ) ;
5457
5458 --Bug 6047966.
5459 l_process := PJI_PJP_SUM_MAIN.g_process || to_char(g_worker_id);
5460 l_plan_ver_type_code := PJI_PROCESS_UTIL.GET_PROCESS_PARAMETER(l_process, 'PLAN_VERSION');
5461
5462 DELETE FROM pji_fm_extr_plan_lines
5463 WHERE (project_id, plan_version_id) IN
5464 (SELECT ver.project_id, ver.plan_version_id
5465 FROM pji_fm_extr_plnver4 ver
5466 WHERE ver.worker_id = g_worker_id)
5467 AND txn_currency_code IS NOT NULL
5468 AND prj_currency_code IS NOT NULL
5469 AND pfc_currency_code IS NOT NULL;
5470
5471 --Bug 6047966. In case actuals alone are summarized, pji_fm_extr_plnver4
5472 --contains only -1 record. Hence that case should be handled.
5473 IF l_plan_ver_type_code ='ACTUAL' THEN
5474
5475 DELETE FROM pji_fm_extr_plan_lines
5476 WHERE (project_id) IN
5477 (SELECT ver.project_id
5478 FROM pji_fm_extr_plnver4 ver
5479 WHERE ver.worker_id = g_worker_id
5480 AND ver.plan_version_id=-1)
5481 AND txn_currency_code IS NOT NULL
5482 AND prj_currency_code IS NOT NULL
5483 AND pfc_currency_code IS NOT NULL;
5484
5485 END IF;
5486
5487 print_time ( 'DELETE_PLAN_LINES : after deletion of plan lines , # rows deleted is ' || SQL%ROWCOUNT );
5488
5489 EXCEPTION
5490 WHEN OTHERS THEN
5491 PJI_PJP_FP_CURR_WRAP.EXCP_HANDLER
5492 ( p_package_name => g_package_name
5493 , p_procedure_name => 'DELETE_PLAN_LINES'
5494 , x_return_status => x_return_status ) ;
5495
5496 RAISE;
5497 END;
5498
5499
5500 --
5501 -- Inserts into FP reporting lines fact the data in the interim pjp1 table.
5502 --
5503 PROCEDURE INSERT_INTO_FP_FACT ( p_slice_type IN VARCHAR2 := NULL) IS
5504 l_last_update_date date := SYSDATE;
5505 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
5506 l_creation_date date := SYSDATE;
5507 l_created_by NUMBER := FND_GLOBAL.USER_ID;
5508 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
5509
5510 /*commenting for bug 7497672
5511 -- Bug 7010864
5512 TYPE row_id_tab_type IS TABLE OF rowid index by binary_integer;
5513 x_row_id row_id_tab_type;
5514
5515 cursor c1 is
5516 select rowid from pji_fp_aggr_pjp1
5517 where worker_id = g_worker_id;
5518 -- Bug 7010864
5519 */
5520 BEGIN
5521
5522 IF ( p_slice_type IS NULL ) THEN
5523
5524 if PJI_UTILS.GET_PARAMETER('PJP_SIN_PRG') = 'Y' then
5525
5526 PJI_PJP_PRG_PERF_ALL.INSERT_INTO_FP_FACT;
5527
5528 else
5529
5530 /* commenting for bug 7497672
5531 -- Bug 7010864
5532 open c1;
5533 loop
5534
5535 fetch c1 bulk collect into x_row_id limit 500000;
5536
5537 If x_row_id.count > 0 then
5538 -- gather statistics for PJI metadata tables
5539 FND_STATS.GATHER_TABLE_STATS(ownname => PJI_UTILS.GET_PJI_SCHEMA_NAME,
5540 tabname => 'PJI_FP_AGGR_PJP1',
5541 percent => 5,
5542 degree => PJI_UTILS.GET_DEGREE_OF_PARALLELISM());
5543
5544 -- gather statistics for PJI metadata tables
5545 FND_STATS.GATHER_TABLE_STATS(ownname => PJI_UTILS.GET_PJI_SCHEMA_NAME,
5546 tabname => 'PJI_FP_XBS_ACCUM_F',
5547 percent => 5,
5548 degree => PJI_UTILS.GET_DEGREE_OF_PARALLELISM());
5549
5550
5551 Forall i in x_row_id.first..x_row_id.last
5552 */
5553 INSERT /*+ append parallel(rl) */ INTO pji_fp_xbs_accum_f rl
5554 (
5555 PROJECT_ID
5556 , PROJECT_ORG_ID
5557 , PROJECT_ORGANIZATION_ID
5558 , PROJECT_ELEMENT_ID
5559 , TIME_ID
5560 , PERIOD_TYPE_ID
5561 , CALENDAR_TYPE
5562 , RBS_AGGR_LEVEL
5563 , WBS_ROLLUP_FLAG
5564 , PRG_ROLLUP_FLAG
5565 , CURR_RECORD_TYPE_ID
5566 , CURRENCY_CODE
5567 , RBS_ELEMENT_ID
5568 , RBS_VERSION_ID
5569 , PLAN_VERSION_ID
5570 , PLAN_TYPE_ID
5571 , LAST_UPDATE_DATE
5572 , LAST_UPDATED_BY
5573 , CREATION_DATE
5574 , CREATED_BY
5575 , LAST_UPDATE_LOGIN
5576 , RAW_COST
5577 , BRDN_COST
5578 , REVENUE
5579 , BILL_RAW_COST
5580 , BILL_BRDN_COST
5581 , BILL_LABOR_RAW_COST
5582 , BILL_LABOR_BRDN_COST
5583 , BILL_LABOR_HRS
5584 , EQUIPMENT_RAW_COST
5585 , EQUIPMENT_BRDN_COST
5586 , CAPITALIZABLE_RAW_COST
5587 , CAPITALIZABLE_BRDN_COST
5588 , LABOR_RAW_COST
5589 , LABOR_BRDN_COST
5590 , LABOR_HRS
5591 , LABOR_REVENUE
5592 , EQUIPMENT_HOURS
5593 , BILLABLE_EQUIPMENT_HOURS
5594 , SUP_INV_COMMITTED_COST
5595 , PO_COMMITTED_COST
5596 , PR_COMMITTED_COST
5597 , OTH_COMMITTED_COST
5598 , ACT_LABOR_HRS
5599 , ACT_EQUIP_HRS
5600 , ACT_LABOR_BRDN_COST
5601 , ACT_EQUIP_BRDN_COST
5602 , ACT_BRDN_COST
5603 , ACT_RAW_COST
5604 , ACT_REVENUE
5605 , ACT_LABOR_RAW_COST
5606 , ACT_EQUIP_RAW_COST
5607 , ETC_LABOR_HRS
5608 , ETC_EQUIP_HRS
5609 , ETC_LABOR_BRDN_COST
5610 , ETC_EQUIP_BRDN_COST
5611 , ETC_BRDN_COST
5612 , ETC_RAW_COST
5613 , ETC_LABOR_RAW_COST
5614 , ETC_EQUIP_RAW_COST
5615 , CUSTOM1
5616 , CUSTOM2
5617 , CUSTOM3
5618 , CUSTOM4
5619 , CUSTOM5
5620 , CUSTOM6
5621 , CUSTOM7
5622 , CUSTOM8
5623 , CUSTOM9
5624 , CUSTOM10
5625 , CUSTOM11
5626 , CUSTOM12
5627 , CUSTOM13
5628 , CUSTOM14
5629 , CUSTOM15
5630 , PLAN_TYPE_CODE
5631 )
5632 SELECT /*+ parallel(pjp1) */ /* Added for bug 11843459 */
5633 pjp1.PROJECT_ID
5634 , pjp1.PROJECT_ORG_ID
5635 , pjp1.PROJECT_ORGANIZATION_ID
5636 , pjp1.PROJECT_ELEMENT_ID
5637 , pjp1.TIME_ID
5638 , pjp1.PERIOD_TYPE_ID
5639 , pjp1.CALENDAR_TYPE
5640 , pjp1.RBS_AGGR_LEVEL
5641 , pjp1.WBS_ROLLUP_FLAG
5642 , pjp1.PRG_ROLLUP_FLAG
5643 , pjp1.CURR_RECORD_TYPE_ID
5644 , pjp1.CURRENCY_CODE
5645 , pjp1.RBS_ELEMENT_ID
5646 , pjp1.RBS_VERSION_ID
5647 , pjp1.PLAN_VERSION_ID
5648 , pjp1.PLAN_TYPE_ID
5649 , l_last_update_date -- sysdate --
5650 , l_last_updated_by -- 1 --
5651 , l_creation_date -- sysdate --
5652 , l_created_by -- 1 --
5653 , l_last_update_login -- 1 --
5654 , pjp1.RAW_COST
5655 , pjp1.BRDN_COST
5656 , pjp1.REVENUE
5657 , pjp1.BILL_RAW_COST
5658 , pjp1.BILL_BRDN_COST
5659 , pjp1.BILL_LABOR_RAW_COST
5660 , pjp1.BILL_LABOR_BRDN_COST
5661 , pjp1.BILL_LABOR_HRS
5662 , pjp1.EQUIPMENT_RAW_COST
5663 , pjp1.EQUIPMENT_BRDN_COST
5664 , pjp1.CAPITALIZABLE_RAW_COST
5665 , pjp1.CAPITALIZABLE_BRDN_COST
5666 , pjp1.LABOR_RAW_COST
5667 , pjp1.LABOR_BRDN_COST
5668 , pjp1.LABOR_HRS
5669 , pjp1.LABOR_REVENUE
5670 , pjp1.EQUIPMENT_HOURS
5671 , pjp1.BILLABLE_EQUIPMENT_HOURS
5672 , pjp1.SUP_INV_COMMITTED_COST
5673 , pjp1.PO_COMMITTED_COST
5674 , pjp1.PR_COMMITTED_COST
5675 , pjp1.OTH_COMMITTED_COST
5676 , pjp1.ACT_LABOR_HRS
5677 , pjp1.ACT_EQUIP_HRS
5678 , pjp1.ACT_LABOR_BRDN_COST
5679 , pjp1.ACT_EQUIP_BRDN_COST
5680 , pjp1.ACT_BRDN_COST
5681 , pjp1.ACT_RAW_COST
5682 , pjp1.ACT_REVENUE
5683 , pjp1.ACT_LABOR_RAW_COST
5684 , pjp1.ACT_EQUIP_RAW_COST
5685 , DECODE(SIGN(pjp1.ETC_LABOR_HRS), -1, 0, pjp1.ETC_LABOR_HRS) ETC_LABOR_HRS
5686 , DECODE(SIGN(pjp1.ETC_EQUIP_HRS), -1, 0, pjp1.ETC_EQUIP_HRS) ETC_EQUIP_HRS
5687 , DECODE(SIGN(pjp1.ETC_LABOR_BRDN_COST), -1, 0, pjp1.ETC_LABOR_BRDN_COST) ETC_LABOR_BRDN_COST
5688 , DECODE(SIGN(pjp1.ETC_EQUIP_BRDN_COST), -1, 0, pjp1.ETC_EQUIP_BRDN_COST) ETC_EQUIP_BRDN_COST
5689 , DECODE(SIGN(pjp1.ETC_BRDN_COST), -1, 0, pjp1.ETC_BRDN_COST) ETC_BRDN_COST
5690 , DECODE(SIGN(pjp1.ETC_RAW_COST), -1, 0, pjp1.ETC_RAW_COST) ETC_RAW_COST
5691 , DECODE(SIGN(pjp1.ETC_LABOR_RAW_COST), -1, 0, pjp1.ETC_LABOR_RAW_COST) ETC_LABOR_RAW_COST
5692 , DECODE(SIGN(pjp1.ETC_EQUIP_RAW_COST), -1, 0, pjp1.ETC_EQUIP_RAW_COST) ETC_EQUIP_RAW_COST
5693 , pjp1.CUSTOM1
5694 , pjp1.CUSTOM2
5695 , pjp1.CUSTOM3
5696 , pjp1.CUSTOM4
5697 , pjp1.CUSTOM5
5698 , pjp1.CUSTOM6
5699 , pjp1.CUSTOM7
5700 , pjp1.CUSTOM8
5701 , pjp1.CUSTOM9
5702 , pjp1.CUSTOM10
5703 , pjp1.CUSTOM11
5704 , pjp1.CUSTOM12
5705 , pjp1.CUSTOM13
5706 , pjp1.CUSTOM14
5707 , pjp1.CUSTOM15
5708 , pjp1.PLAN_TYPE_CODE
5709 FROM
5710 pji_fp_aggr_pjp1 pjp1
5711 WHERE 1=1
5712 AND worker_id = g_worker_id
5713 --AND pjp1.rowid = x_row_id(i) commented for bug 7497672
5714 ORDER BY
5715 pjp1.PROJECT_ID
5716 , pjp1.PLAN_VERSION_ID
5717 , pjp1.PROJECT_ELEMENT_ID
5718 , pjp1.TIME_ID
5719 , pjp1.RBS_VERSION_ID;
5720 /*commenting for bug 7497672
5721 -- Bug 7010864
5722 Forall j in x_row_id.first..x_row_id.last
5723 delete from pji_fp_aggr_pjp1
5724 where worker_id = g_worker_id
5725 and rowid = x_row_id(j);
5726
5727 commit;
5728
5729 x_row_id.delete;
5730
5731 exit when c1%notfound;
5732 Else
5733 Exit;
5734 End if;
5735 end loop;
5736
5737 close c1;
5738 -- Bug 7010864
5739 */
5740
5741 end if;
5742
5743 ELSIF (p_slice_type = 'PRI') THEN
5744
5745 MERGE_INTO_FP_FACT;
5746
5747 ELSIF (p_slice_type = 'SEC') THEN
5748
5749 DELETE FROM pji_fp_aggr_pjp1
5750 WHERE line_type = 'OF'
5751 AND worker_id = g_worker_id; -- Data in entered calendar should not be rolled up.
5752
5753 MERGE_INTO_FP_FACT;
5754
5755 END IF;
5756
5757 EXCEPTION
5758 WHEN OTHERS THEN
5759 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
5760 p_procedure_name => 'INSERT_INTO_FP_FACT');
5761 RAISE;
5762 END;
5763
5764
5765 PROCEDURE GET_PRI_SLICE_DATA(
5766 p_fp_version_ids IN SYSTEM.pa_num_tbl_type := pji_empty_num_tbl
5767 , p_commit IN VARCHAR2 := 'F') IS
5768 BEGIN
5769
5770 FORALL I IN p_fp_version_ids.FIRST..p_fp_version_ids.LAST
5771 INSERT INTO pji_fp_aggr_pjp1
5772 (
5773 WORKER_ID
5774 , PROJECT_ID
5775 , PROJECT_ORG_ID
5776 , PROJECT_ORGANIZATION_ID
5777 -- , PARTITION_ID
5778 , PROJECT_ELEMENT_ID
5779 , TIME_ID
5780 , PERIOD_TYPE_ID
5781 , CALENDAR_TYPE
5782 , RBS_AGGR_LEVEL
5783 , WBS_ROLLUP_FLAG
5784 , PRG_ROLLUP_FLAG
5785 , CURR_RECORD_TYPE_ID
5786 , CURRENCY_CODE
5787 , RBS_ELEMENT_ID
5788 , RBS_VERSION_ID
5789 , PLAN_VERSION_ID
5790 , PLAN_TYPE_ID
5791 , RAW_COST
5792 , BRDN_COST
5793 , REVENUE
5794 , BILL_RAW_COST
5795 , BILL_BRDN_COST
5796 , BILL_LABOR_RAW_COST
5797 , BILL_LABOR_BRDN_COST
5798 , BILL_LABOR_HRS
5799 , EQUIPMENT_RAW_COST
5800 , EQUIPMENT_BRDN_COST
5801 , CAPITALIZABLE_RAW_COST
5802 , CAPITALIZABLE_BRDN_COST
5803 , LABOR_RAW_COST
5804 , LABOR_BRDN_COST
5805 , LABOR_HRS
5806 , LABOR_REVENUE
5807 , EQUIPMENT_HOURS
5808 , BILLABLE_EQUIPMENT_HOURS
5809 , SUP_INV_COMMITTED_COST
5810 , PO_COMMITTED_COST
5811 , PR_COMMITTED_COST
5812 , OTH_COMMITTED_COST
5813 , ACT_LABOR_HRS
5814 , ACT_EQUIP_HRS
5815 , ACT_LABOR_BRDN_COST
5816 , ACT_EQUIP_BRDN_COST
5817 , ACT_BRDN_COST
5818 , ACT_RAW_COST
5819 , ACT_REVENUE
5820 , ACT_LABOR_RAW_COST
5821 , ACT_EQUIP_RAW_COST
5822 , ETC_LABOR_HRS
5823 , ETC_EQUIP_HRS
5824 , ETC_LABOR_BRDN_COST
5825 , ETC_EQUIP_BRDN_COST
5826 , ETC_BRDN_COST
5827 , ETC_RAW_COST
5828 , ETC_LABOR_RAW_COST
5829 , ETC_EQUIP_RAW_COST
5830 , CUSTOM1
5831 , CUSTOM2
5832 , CUSTOM3
5833 , CUSTOM4
5834 , CUSTOM5
5835 , CUSTOM6
5836 , CUSTOM7
5837 , CUSTOM8
5838 , CUSTOM9
5839 , CUSTOM10
5840 , CUSTOM11
5841 , CUSTOM12
5842 , CUSTOM13
5843 , CUSTOM14
5844 , CUSTOM15
5845 , PRG_LEVEL
5846 , PLAN_TYPE_CODE
5847 )
5848 (
5849 SELECT
5850 g_worker_id
5851 , rl.PROJECT_ID
5852 , rl.PROJECT_ORG_ID
5853 , rl.PROJECT_ORGANIZATION_ID
5854 -- , rl.PARTITION_ID
5855 , rl.PROJECT_ELEMENT_ID
5856 , rl.TIME_ID
5857 , rl.PERIOD_TYPE_ID
5858 , rl.CALENDAR_TYPE
5859 , rl.RBS_AGGR_LEVEL
5860 , rl.WBS_ROLLUP_FLAG
5861 , rl.PRG_ROLLUP_FLAG
5862 , rl.CURR_RECORD_TYPE_ID
5863 , rl.CURRENCY_CODE
5864 , rl.RBS_ELEMENT_ID
5865 , rl.RBS_VERSION_ID
5866 , rl.PLAN_VERSION_ID
5867 , rl.PLAN_TYPE_ID
5868 , rl.RAW_COST
5869 , rl.BRDN_COST
5870 , rl.REVENUE
5871 , rl.BILL_RAW_COST
5872 , rl.BILL_BRDN_COST
5873 , rl.BILL_LABOR_RAW_COST
5874 , rl.BILL_LABOR_BRDN_COST
5875 , rl.BILL_LABOR_HRS
5876 , rl.EQUIPMENT_RAW_COST
5877 , rl.EQUIPMENT_BRDN_COST
5878 , rl.CAPITALIZABLE_RAW_COST
5879 , rl.CAPITALIZABLE_BRDN_COST
5880 , rl.LABOR_RAW_COST
5881 , rl.LABOR_BRDN_COST
5882 , rl.LABOR_HRS
5883 , rl.LABOR_REVENUE
5884 , rl.EQUIPMENT_HOURS
5885 , rl.BILLABLE_EQUIPMENT_HOURS
5886 , rl.SUP_INV_COMMITTED_COST
5887 , rl.PO_COMMITTED_COST
5888 , rl.PR_COMMITTED_COST
5889 , rl.OTH_COMMITTED_COST
5890 , rl.ACT_LABOR_HRS
5891 , rl.ACT_EQUIP_HRS
5892 , rl.ACT_LABOR_BRDN_COST
5893 , rl.ACT_EQUIP_BRDN_COST
5894 , rl.ACT_BRDN_COST
5895 , rl.ACT_RAW_COST
5896 , rl.ACT_REVENUE
5897 , rl.ACT_LABOR_RAW_COST
5898 , rl.ACT_EQUIP_RAW_COST
5899 , rl.ETC_LABOR_HRS
5900 , rl.ETC_EQUIP_HRS
5901 , rl.ETC_LABOR_BRDN_COST
5902 , rl.ETC_EQUIP_BRDN_COST
5903 , rl.ETC_BRDN_COST
5904 , rl.ETC_RAW_COST
5905 , rl.ETC_LABOR_RAW_COST
5906 , rl.ETC_EQUIP_RAW_COST
5907 , rl.CUSTOM1
5908 , rl.CUSTOM2
5909 , rl.CUSTOM3
5910 , rl.CUSTOM4
5911 , rl.CUSTOM5
5912 , rl.CUSTOM6
5913 , rl.CUSTOM7
5914 , rl.CUSTOM8
5915 , rl.CUSTOM9
5916 , rl.CUSTOM10
5917 , rl.CUSTOM11
5918 , rl.CUSTOM12
5919 , rl.CUSTOM13
5920 , rl.CUSTOM14
5921 , rl.CUSTOM15
5922 , g_default_prg_level
5923 , rl.PLAN_TYPE_CODE
5924 FROM
5925 pji_fp_xbs_accum_f rl
5926 , pa_budget_versions bv -- @pjdev115 bv
5927 , pa_proj_fp_options fpo -- @pjdev115 fpo
5928 WHERE
5929 rl.project_id = bv.project_id
5930 AND bv.version_type IS NOT NULL
5931 AND bv.fin_plan_type_id IS NOT NULL
5932 AND fpo.project_id = bv.project_id
5933 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
5934 AND bv.budget_version_id = fpo.fin_plan_version_id
5935 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION'
5936 AND rl.calendar_type =
5937 DECODE( bv.version_type
5938 , 'ALL', fpo.all_time_phased_code
5939 , 'COST', fpo.cost_time_phased_code
5940 , 'REVENUE', fpo.revenue_time_phased_code
5941 )
5942 AND rl.plan_version_id = p_fp_version_ids(i));
5943
5944
5945 EXCEPTION
5946 WHEN OTHERS THEN
5947 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
5948 p_procedure_name => 'GET_PRI_SLICE_DATA');
5949 RAISE;
5950 END;
5951
5952
5953
5954 PROCEDURE POPULATE_PLN_VER_TABLE IS
5955 l_count NUMBER := 0;
5956 BEGIN
5957
5958 print_time('........POPULATE_PLN_VER_TABLE : Begin.' );
5959
5960 INSERT INTO PJI_FM_EXTR_PLNVER4
5961 (
5962 WORKER_ID ,
5963 PROJECT_ID ,
5964 PLAN_VERSION_ID ,
5965 WBS_STRUCT_VERSION_ID ,
5966 RBS_STRUCT_VERSION_ID ,
5967 PLAN_TYPE_CODE ,
5968 PLAN_TYPE_ID ,
5969 TIME_PHASED_TYPE_CODE ,
5970 TIME_DANGLING_FLAG ,
5971 RATE_DANGLING_FLAG ,
5972 PROJECT_TYPE_CLASS ,
5973 WP_FLAG ,
5974 CURRENT_FLAG ,
5975 ORIGINAL_FLAG ,
5976 CURRENT_ORIGINAL_FLAG ,
5977 BASELINED_FLAG
5978 )
5979 SELECT DISTINCT
5980 g_worker_id
5981 , epl.project_id
5982 , epl.plan_version_id
5983 , DECODE ( NVL(bv.wp_version_flag, 'N')
5984 , 'Y', bv.project_structure_version_id
5985 , PA_PROJECT_STRUCTURE_UTILS.GET_FIN_STRUC_VER_ID(bv.project_id) -- -9999 --
5986 ) wbs_struct_version_id
5987 -- , epl.struct_ver_id
5988 , fpo.rbs_version_id -- epl.rbs_version_id
5989 -- , to_char(epl.plan_type_id) -- pln type code
5990 , DECODE (bv.version_type, 'COST' ,'C' , 'REVENUE', 'R', 'A') plan_type_code /* 4471527 */
5991 , epl.plan_type_id
5992 , DECODE(bv.version_type
5993 , 'ALL', fpo.all_time_phased_code
5994 , 'COST', fpo.cost_time_phased_code
5995 , 'REVENUE', fpo.revenue_time_phased_code
5996 ) time_phased_type_code
5997 , null -- time dangling..
5998 , null -- time dangling..
5999 , null -- project type class is not used currently..
6000 , DECODE(bv.wp_version_flag, 'Y', 'Y', 'N') is_wp_flag
6001 , bv.current_flag current_flag
6002 , bv.original_flag original_flag
6003 , bv.current_original_flag current_original_flag
6004 , DECODE(bv.baselined_date, NULL, 'N', 'Y') baselined_flag
6005 FROM PJI_FM_EXTR_PLAN_LINES epl
6006 , pa_budget_versions bv
6007 , pa_proj_fp_options fpo
6008 WHERE
6009 epl.plan_version_id = bv.budget_version_id
6010 AND fpo.project_id = bv.project_id
6011 AND bv.fin_plan_type_id = fpo.fin_plan_type_id
6012 AND bv.budget_version_id = fpo.fin_plan_version_id
6013 AND fpo.fin_plan_option_level_code = 'PLAN_VERSION'
6014 AND epl.rowid IN ( SELECT extr_lines_rowid FROM pji_fp_rmap_fpr_update_t);
6015
6016 /*
6017 SELECT COUNT(1)
6018 INTO l_count
6019 FROM PJI_FM_EXTR_PLNVER4;
6020 */
6021
6022 print_time('count is ... ' || SQL%ROWCOUNT );
6023
6024 print_time('........POPULATE_PLN_VER_TABLE : End.' );
6025
6026 EXCEPTION
6027 WHEN OTHERS THEN
6028 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6029 p_procedure_name => 'POPULATE_PLN_VER_TABLE');
6030 print_time('........POPULATE_PLN_VER_TABLE : Exception: ' || sqlerrm );
6031 RAISE;
6032 END;
6033
6034
6035 PROCEDURE GET_GLOBAL_EXCHANGE_RATES IS
6036
6037 l_gl1_cur_code VARCHAR2(15) := g_global1_currency_code;
6038 l_gl2_cur_code VARCHAR2(15) := g_global2_currency_code;
6039 l_gl1_mau NUMBER := g_global1_currency_mau;
6040 l_gl2_mau NUMBER := g_global2_currency_mau;
6041
6042 BEGIN
6043
6044 /* Added for bug 13030627 */
6045 if PJI_UTILS.GET_PARAMETER('PJP_SIN_PRG') = 'Y' then
6046
6047 PJI_PJP_PRG_PERF_ALL.GET_GLOBAL_EXCHANGE_RATES;
6048
6049 else
6050
6051 print_time('........GET_GLOBAL_EXCHANGE_RATES: Begin. ' );
6052
6053 PJI_PJP_FP_CURR_WRAP.get_global_currency_info (
6054 x_currency_conversion_rule => g_currency_conversion_rule
6055 , x_prorating_format => g_prorating_format
6056 , x_global1_currency_code => g_global1_currency_code
6057 , x_global2_currency_code => g_global2_currency_code
6058 , x_global1_currency_mau => g_global1_currency_mau
6059 , x_global2_currency_mau => g_global2_currency_mau ) ;
6060
6061 --
6062 -- Todo: Remove hardcoded currency codes after making code work if one of the global currencies is null.
6063 --
6064
6065 l_gl1_cur_code := g_global1_currency_code;
6066 l_gl2_cur_code := g_global2_currency_code;
6067 l_gl1_mau := g_global1_currency_mau;
6068 l_gl2_mau := g_global2_currency_mau;
6069
6070 print_time(' Got global currency settings. ');
6071 print_time(' g_currency_conversion_rule ' || g_currency_conversion_rule || ' g_prorating_format ' || g_prorating_format );
6072 print_time(' g_global1_currency_code ' || g_global1_currency_code || ' g_global2_currency_code ' || g_global2_currency_code );
6073 print_time(' g_global1_currency_mau ' || g_global1_currency_mau || ' g_global2_currency_mau ' || g_global2_currency_mau ) ;
6074
6075
6076 DELETE FROM PJI_FM_AGGR_DLY_RATES
6077 WHERE worker_id = g_worker_id;
6078
6079 print_time('........GET_GLOBAL_EXCHANGE_RATES: # rows deleted is: ' || SQL%ROWCOUNT );
6080
6081 PJI_UTILS.g_max_roll_days := 1500; /*5155692 */
6082 -- Removed pa_resource_assignments join and Added joins with pji_org_extr_info
6083 -- for bug 4149422
6084 -- SQL for getting rates for time phased budgets.
6085 INSERT INTO PJI_FM_AGGR_DLY_RATES (
6086 WORKER_ID ,
6087 PF_CURRENCY_CODE ,
6088 TIME_ID ,
6089 RATE ,
6090 MAU ,
6091 RATE2 ,
6092 MAU2)
6093 select worker_id,
6094 projfunc_currency_code,
6095 time_id,
6096 PJI_UTILS.GET_GLOBAL_RATE_PRIMARY (temp.projfunc_currency_code
6097 , DECODE ( g_currency_conversion_rule
6098 , 'S'
6099 , temp.start_date
6100 , 'E'
6101 , temp.end_date ))
6102 rate1,
6103 l_gl1_mau mau1,
6104 DECODE ( PJI_UTILS.GET_SETUP_PARAMETER('GLOBAL_CURR2_FLAG'),
6105 'Y',
6106 PJI_UTILS.GET_GLOBAL_RATE_SECONDARY(
6107 temp.projfunc_currency_code,
6108 DECODE ( g_currency_conversion_rule
6109 , 'S'
6110 , temp.start_date
6111 , 'E'
6112 , temp.end_date
6113 )
6114 ) ,
6115 NULL
6116 ) rate2,
6117 l_gl2_mau mau2
6118 FROM (
6119 SELECT DISTINCT
6120 g_worker_id worker_id
6121 , ppa.projfunc_currency_code
6122 , cal_period_id time_id
6123 , DECODE( g_currency_conversion_rule
6124 , 'S'
6125 , prd.start_date
6126 , TO_DATE(NULL)
6127 ) start_date
6128 , DECODE( g_currency_conversion_rule
6129 , 'E'
6130 , prd.end_date
6131 , TO_DATE(NULL)
6132 ) end_date
6133 FROM pa_budget_lines bl
6134 , pji_time_cal_period_v prd
6135 , PJI_FM_EXTR_PLNVER4 ver
6136 , pa_projects_all ppa
6137 ,PJI_ORG_EXTR_INFO inf
6138 WHERE 1=1
6139 AND bl.budget_version_id = ver.plan_version_id
6140 AND ver.time_phased_type_code IN ('P', 'G')
6141 AND bl.period_name = prd.name
6142 AND ver.wp_flag = 'N'
6143 AND ver.baselined_flag = 'Y'
6144 AND ver.project_id = ppa.project_id
6145 -- Fix for bug : 4149422
6146 AND ppa.org_id = inf.org_id
6147 AND DECODE ( ver.time_phased_type_code
6148 , 'P'
6149 , inf.pa_calendar_id
6150 , 'G'
6151 , inf.gl_calendar_id
6152 ) = prd.calendar_id
6153 AND ver.worker_id = g_worker_id
6154 UNION ALL
6155 SELECT DISTINCT
6156 g_worker_id worker_id
6157 , ppa.projfunc_currency_code
6158 , DECODE ( g_currency_conversion_rule
6159 , 'S'
6160 , TO_NUMBER(to_CHAR(ra.planning_start_date, 'J'))
6161 , 'E'
6162 , TO_NUMBER(to_CHAR(ra.planning_end_date, 'J')) ) time_id
6163 , DECODE( g_currency_conversion_rule
6164 , 'S'
6165 , ra.planning_start_date
6166 , TO_DATE(NULL)
6167 ) start_date
6168 , DECODE( g_currency_conversion_rule
6169 , 'E'
6170 , ra.planning_end_date
6171 , TO_DATE(NULL)
6172 ) end_date
6173 FROM pa_resource_assignments ra
6174 , PJI_FM_EXTR_PLNVER4 ver
6175 , pa_projects_all ppa
6176 WHERE 1=1
6177 AND ra.budget_version_id = ver.plan_version_id
6178 AND ver.wp_flag = 'N'
6179 AND ver.baselined_flag = 'Y'
6180 AND ver.time_phased_type_code = 'N'
6181 AND ver.project_id = ppa.project_id
6182 AND ver.worker_id = g_worker_id
6183 ) temp;
6184
6185 PJI_UTILS.g_max_roll_days := NULL; /*5155692 */
6186
6187 UPDATE /*+ INDEX(prd,pji_time_cal_period_u1) index(rates, PJI_FM_AGGR_DLY_RATES_N1) */
6188 PJI_FM_EXTR_PLNVER4 ver
6189 SET rate_dangling_flag = 'Y'
6190 WHERE (project_id,plan_version_id) IN
6191 ( SELECT project_id,budget_version_id
6192 FROM PA_BUDGET_LINES bl,
6193 pji_time_cal_period_v prd,
6194 PJI_FM_AGGR_DLY_RATES rates
6195 WHERE rates.time_id=prd.cal_period_id
6196 AND bl.period_name = prd.name
6197 AND (sign(rates.rate)=-1 OR sign(rates.rate2) = -1)
6198 AND ver.time_phased_type_code IN ('P', 'G')
6199 AND rates.worker_id=g_worker_id /* Added for bug 4083581 */
6200 UNION ALL
6201 SELECT project_id,budget_version_id
6202 FROM pa_resource_assignments ra,
6203 PJI_FM_AGGR_DLY_RATES rates
6204 WHERE rates.time_id= DECODE ( g_currency_conversion_rule
6205 , 'S'
6206 , TO_NUMBER(to_CHAR(ra.planning_start_date, 'J'))
6207 , 'E'
6208 , TO_NUMBER(to_CHAR(ra.planning_end_date, 'J')) )
6209 AND (sign(rates.rate)=-1 OR sign(rates.rate2) = -1)
6210 AND ver.time_phased_type_code = 'N'
6211 AND rates.worker_id=g_worker_id /* Added for bug 4083581 */
6212 )
6213 AND ver.wp_flag = 'N'
6214 AND ver.baselined_flag = 'Y'
6215 AND ver.worker_id = g_worker_id;
6216
6217 print_time('........GET_GLOBAL_EXCHANGE_RATES: End. # rows inserted is: ' || SQL%ROWCOUNT );
6218
6219 end if;
6220
6221 commit; -- Added for bug 9108728
6222
6223 EXCEPTION
6224 WHEN OTHERS THEN
6225 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6226 p_procedure_name => 'GET_GLOBAL_EXCHANGE_RATES');
6227 print_time('........GET_GLOBAL_EXCHANGE_RATES: Exception: ' || sqlerrm );
6228 RAISE;
6229 END;
6230
6231
6232 PROCEDURE DELETE_GLOBAL_EXCHANGE_RATES IS
6233 BEGIN
6234
6235 print_time('........DELETE_GLOBAL_EXCHANGE_RATES: Begin. ' );
6236
6237 DELETE FROM PJI_FM_AGGR_DLY_RATES
6238 WHERE worker_id = g_worker_id;
6239
6240 print_time('........DELETE_GLOBAL_EXCHANGE_RATES: End. # rows is.. ' || SQL%ROWCOUNT );
6241
6242 EXCEPTION
6243 WHEN OTHERS THEN
6244 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6245 p_procedure_name => 'DELETE_GLOBAL_EXCHANGE_RATES');
6246 print_time('........DELETE_GLOBAL_EXCHANGE_RATES: Exception: ' || sqlerrm );
6247 RAISE;
6248 END;
6249
6250
6251
6252
6253 PROCEDURE CONV_TO_GLOBAL_CURRENCIES
6254 IS BEGIN
6255
6256 print_time('........CONV_TO_GLOBAL_CURRENCIES: Begin. ' );
6257
6258 NULL; -- Pull dangling implemented is changed.
6259
6260
6261 print_time('........CONV_TO_GLOBAL_CURRENCIES: End. ' );
6262
6263 EXCEPTION
6264 WHEN OTHERS THEN
6265 print_time('........CONV_TO_GLOBAL_CURRENCIES: Exception ' || sqlerrm );
6266 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6267 p_procedure_name => 'CONV_TO_GLOBAL_CURRENCIES');
6268 RAISE;
6269 END;
6270
6271
6272 PROCEDURE DELETE_DNGLRATE_PLNVER_DATA IS
6273 BEGIN
6274
6275 DELETE FROM pji_fp_aggr_pjp1
6276 WHERE plan_version_id IN
6277 (
6278 SELECT DISTINCT plan_version_id
6279 FROM pji_fp_aggr_pjp1
6280 WHERE worker_id = g_worker_id
6281 AND rate_dangling_flag IS NOT NULL )
6282 AND worker_id = g_worker_id;
6283
6284 EXCEPTION
6285 WHEN OTHERS THEN
6286 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6287 p_procedure_name => 'DELETE_DNGLRATE_PLNVER_DATA');
6288 RAISE;
6289 END;
6290
6291
6292
6293 PROCEDURE DO_CURRENCY_DANGLING_CHECK
6294 IS BEGIN
6295
6296 NULL; -- Rate dangling check already done in get global exchange rates.
6297
6298 EXCEPTION
6299 WHEN OTHERS THEN
6300 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6301 p_procedure_name => 'DO_CURRENCY_DANGLING_CHECK');
6302 RAISE;
6303 END;
6304
6305
6306 PROCEDURE GET_PRORATE_FORMAT
6307 IS BEGIN
6308
6309 NULL;
6310
6311 EXCEPTION
6312 WHEN OTHERS THEN
6313 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6314 p_procedure_name => 'GET_PRORATE_FORMAT');
6315 RAISE;
6316 END;
6317
6318
6319 PROCEDURE GET_SPREAD_DATE_RANGE_AMOUNTS
6320 IS BEGIN
6321
6322 NULL;
6323
6324 EXCEPTION
6325 WHEN OTHERS THEN
6326 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6327 p_procedure_name => 'GET_SPREAD_DATE_RANGE_AMOUNTS');
6328 RAISE;
6329 END;
6330
6331
6332 PROCEDURE SPREAD_NON_TIME_PHASE_AMOUNTS
6333 IS BEGIN
6334
6335 NULL;
6336
6337 EXCEPTION
6338 WHEN OTHERS THEN
6339 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6340 p_procedure_name => 'SPREAD_NON_TIME_PHASE_AMOUNTS');
6341 RAISE;
6342 END;
6343
6344
6345
6346
6347 PROCEDURE PRORATE_TO_OTHER_CALENDAR(
6348 p_calENDar_type IN VARCHAR2 := NULL -- Values can be GL, PA, ENT, ENTW.
6349 ) IS
6350 BEGIN
6351
6352 --
6353 -- Logic to identify the records that are 'original'/'converted' format
6354 -- etc is similar to that for PJI. This is to make it easy for dev working
6355 -- on one module (PJI/PRP) to understand the other with minimum effort.
6356 --
6357 -- Logic is as follows:
6358 -------------------------------------------------------------------------
6359 -- 1. All 'entered' amounts (from pri slice) will have a line type *tag* 'OF'
6360 -- if calendar type is PA/GL. If no calendar type is mentioned,
6361 -- then, it will be 'F1'. Tag == line type column in tmp table.
6362 -- 2. Non time phased amounts if prorated to ENT cal will be tagged 'OF'.
6363 -- This has not been decided yet.
6364 -- 3. Amounts from PA/GL cal entries that have been converted to global will
6365 -- have a tag 'OG'.
6366 -- 4. Non PA calendar entries of OF/OG when converted to PA calendar will have
6367 -- a tag 'CF/CG' respectively.
6368 -- 5. Non GL calendar entries of OF/OG when converted to GL calendar will have
6369 -- a tag 'CF/CG' respectively.
6370 -- 6. Non ENT calendar entries of OF/OG when converted to ENT calendar will have
6371 -- a tag 'CF/CG' respectively.
6372 -- 7. Non ENTW calendar entries of OF/OG when converted to ENTW calendar will have
6373 -- a tag 'CF/CG' respectively.
6374 --
6375
6376 IF (p_calENDar_type = 'PA') THEN
6377 PRORATE_TO_PA;
6378 ELSIF (p_calENDar_type = 'GL') THEN
6379 PRORATE_TO_GL;
6380 ELSIF (p_calENDar_type = 'ENT') THEN
6381 PRORATE_TO_ENT;
6382 END IF;
6383
6384 EXCEPTION
6385 WHEN OTHERS THEN
6386 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6387 p_procedure_name => 'PRORATE_TO_OTHER_CALENDAR');
6388 RAISE;
6389 END;
6390
6391
6392 PROCEDURE PRORATE_TO_PA IS
6393 BEGIN
6394
6395 -- Refer to prorating logic in 'PRORATE_TO_OTHER_CALENDAR' proc.
6396 PRORATE('PA');
6397
6398 EXCEPTION
6399 WHEN OTHERS THEN
6400 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6401 p_procedure_name => 'PRORATE_TO_PA');
6402 RAISE;
6403 END;
6404
6405
6406 PROCEDURE PRORATE_TO_GL IS
6407 BEGIN
6408
6409 -- Refer to prorating logic in 'PRORATE_TO_OTHER_CALENDAR' proc.
6410 PRORATE('GL');
6411
6412 EXCEPTION
6413 WHEN OTHERS THEN
6414 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6415 p_procedure_name => 'PRORATE_TO_GL');
6416 RAISE;
6417 END;
6418
6419
6420 --
6421 -- Prorate entries in RL fact and pjp1 table in
6422 -- 1. GL cal and Non time phased entries into PA cal.
6423 -- 2. PA cal and Non time phased entries into GL cal.
6424 -- 3. PA, GL cals and Non time phased entries into Ent cal.
6425 --
6426 PROCEDURE PRORATE_TO_ALL_CALENDARS IS
6427 BEGIN
6428
6429 print_time('PRORATE_TO_ALL_CALENDARS: Begin.. ');
6430
6431 PRORATE('PA'); -- Prorate entries in RL fact and pjp1 table
6432 -- in GL cal and Non time phased entries into PA cal.
6433 PRORATE('GL'); -- Prorate entries in RL fact and pjp1 table
6434 -- in PA cal and Non time phased entries into GL cal.
6435 PRORATE_TO_ENT; -- Prorate entries in PA and GL cals into ENT cal. /*for bug 3852901 */
6436
6437 print_time('PRORATE_TO_ALL_CALENDARS: End.. ');
6438
6439 EXCEPTION
6440 WHEN NO_DATA_FOUND THEN
6441
6442 /* This issue will come only when PJI_PJP_FP_CURR_WRAP.get_ent_dates_info gives a no_data_found error.
6443 updating the plan versions as time dangling so that the plan will be marked as dangling. Not updating
6444 the existing records so that data for the primary calendar is not impacted because of issue in proration to
6445 other calendars */
6446
6447 UPDATE PJI_FM_EXTR_PLNVER4
6448 SET time_dangling_flag='Y'
6449 WHERE wp_flag='N'
6450 AND baselined_flag = 'Y'
6451 AND worker_id = g_worker_id; -- Not raising any exception as we want the processing to happen properly.
6452 WHEN OTHERS THEN
6453 print_time('PRORATE_TO_ALL_CALENDARS: Exception.. ' || sqlerrm);
6454 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6455 p_procedure_name => 'PRORATE_TO_ALL_CALENDARS');
6456 RAISE;
6457 END;
6458
6459
6460 PROCEDURE PRORATE_TO_ENT IS
6461 l_calendar_type VARCHAR2(15) := 'E';
6462 BEGIN
6463
6464 /* Added for bug 13030627 */
6465 if PJI_UTILS.GET_PARAMETER('PJP_SIN_PRG') = 'Y' then
6466
6467 PJI_PJP_PRG_PERF_ALL.PRORATE_TO_ENT;
6468
6469 else
6470
6471 PJI_PJP_FP_CURR_WRAP.get_global_currency_info (
6472 x_currency_conversion_rule => g_currency_conversion_rule
6473 , x_prorating_format => g_prorating_format
6474 , x_global1_currency_code => g_global1_currency_code
6475 , x_global2_currency_code => g_global2_currency_code
6476 , x_global1_currency_mau => g_global1_currency_mau
6477 , x_global2_currency_mau => g_global2_currency_mau ) ;
6478
6479
6480 PJI_PJP_FP_CURR_WRAP.get_ent_dates_info (
6481 x_global_start_date => g_global_start_date
6482 , x_ent_start_period_id => g_ent_start_period_id
6483 , x_ent_start_period_name => g_ent_start_period_name
6484 , x_ent_start_date => g_ent_start_date
6485 , x_ent_END_date => g_ent_END_date
6486 , x_global_start_J => g_global_start_J
6487 , x_ent_start_J => g_ent_start_J
6488 , x_ent_END_J => g_ent_END_J
6489 ) ;
6490
6491 IF (g_prorating_format = 'D') THEN
6492
6493 PJI_FM_PLAN_CAL_RLPS.PRORATE_TO_ENT_PG_PJP1_D;
6494 PJI_FM_PLAN_CAL_RLPS.PRORATE_TO_ENT_N_PJP1_D;
6495
6496 ELSIF (g_prorating_format IN ( g_end_str, g_start_str ) ) THEN
6497
6498 PJI_FM_PLAN_CAL_RLPS.PRORATE_TO_ENT_PG_PJP1_SE(g_prorating_format);
6499 PJI_FM_PLAN_CAL_RLPS.PRORATE_TO_ENT_N_PJP1_SE(g_prorating_format);
6500
6501 ELSE
6502 NULL;
6503 END IF;
6504
6505 end if;
6506
6507 EXCEPTION
6508 WHEN OTHERS THEN
6509 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6510 p_procedure_name => 'PRORATE_TO_ENT');
6511 RAISE;
6512 END;
6513
6514
6515 PROCEDURE PRORATE(
6516 p_calENDar_type IN VARCHAR2 := NULL -- Values can be GL, PA, ENT, ENTW.
6517 ) IS
6518 l_calendar_type VARCHAR2(15);
6519
6520 BEGIN
6521
6522 IF (p_calENDar_type NOT IN ('PA', 'GL')) THEN RETURN; END IF;
6523
6524 IF (p_calENDar_type = 'PA') THEN l_calENDar_type := 'P';
6525 ELSIF (p_calENDar_type = 'GL') THEN l_calENDar_type := 'G';
6526 ELSE RETURN;
6527 END IF;
6528
6529
6530 PJI_PJP_FP_CURR_WRAP.get_global_currency_info (
6531 x_currency_conversion_rule => g_currency_conversion_rule
6532 , x_prorating_format => g_prorating_format
6533 , x_global1_currency_code => g_global1_currency_code
6534 , x_global2_currency_code => g_global2_currency_code
6535 , x_global1_currency_mau => g_global1_currency_mau
6536 , x_global2_currency_mau => g_global2_currency_mau ) ;
6537
6538
6539 PJI_PJP_FP_CURR_WRAP.get_ent_dates_info (
6540 x_global_start_date => g_global_start_date
6541 , x_ent_start_period_id => g_ent_start_period_id
6542 , x_ent_start_period_name => g_ent_start_period_name
6543 , x_ent_start_date => g_ent_start_date
6544 , x_ent_END_date => g_ent_END_date
6545 , x_global_start_J => g_global_start_J
6546 , x_ent_start_J => g_ent_start_J
6547 , x_ent_END_J => g_ent_END_J
6548 ) ;
6549
6550 print_time ( ' Prorating format is .. ' || g_prorating_format ) ;
6551
6552 IF (g_prorating_format = 'D') THEN
6553
6554 PJI_FM_PLAN_CAL_RLPS.PRORATE_TO_PAGL_PGE_PJP1_D( p_calendar_type => l_calendar_type );
6555 PJI_FM_PLAN_CAL_RLPS.PRORATE_TO_PAGL_N_PJP1_D( p_calendar_type => l_calendar_type );
6556
6557 ELSIF (g_prorating_format IN ( 'E', 'S' ) ) THEN
6558
6559 PJI_FM_PLAN_CAL_RLPS.PRORATE_TO_PAGL_PGE_PJP1_SE( p_calendar_type => l_calendar_type ,
6560 p_prorating_format => g_prorating_format);
6561 PJI_FM_PLAN_CAL_RLPS.PRORATE_TO_PAGL_N_PJP1_SE( p_calendar_type => l_calendar_type ,
6562 p_prorating_format => g_prorating_format);
6563
6564 ELSE
6565 NULL;
6566 END IF;
6567
6568 EXCEPTION
6569 WHEN OTHERS THEN
6570 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6571 p_procedure_name => 'PRORATE');
6572 RAISE;
6573 END;
6574
6575
6576 PROCEDURE MERGE_INTO_FP_FACT IS
6577 BEGIN
6578
6579 print_time ( ' MERGE_INTO_FP_FACT 2 ' ) ;
6580 GET_FP_ROW_IDS;
6581 print_time ( ' MERGE_INTO_FP_FACT 3 ' ) ;
6582 UPDATE_FP_ROWS;
6583 print_time ( ' MERGE_INTO_FP_FACT 4 ' ) ;
6584 INSERT_FP_ROWS;
6585 print_time ( ' MERGE_INTO_FP_FACT 5 ' ) ;
6586 CLEANUP_FP_RMAP_FPR;
6587 print_time ( ' MERGE_INTO_FP_FACT 6 ' ) ;
6588
6589 EXCEPTION
6590 WHEN OTHERS THEN
6591 print_time ( ' MERGE_INTO_FP_FACT 6 ' ) ;
6592 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6593 p_procedure_name => 'MERGE_INTO_FP_FACT');
6594 RAISE;
6595 END;
6596
6597
6598 PROCEDURE CLEANUP_FP_RMAP_FPR IS
6599 BEGIN
6600
6601 print_time ( 'CLEANUP_FP_RMAP_FPR begin..');
6602
6603 DELETE FROM PJI_FP_RMAP_FPR
6604 WHERE worker_id = g_worker_id;
6605
6606 print_time ( 'CLEANUP_FP_RMAP_FPR end.' || g_worker_id );
6607
6608 EXCEPTION
6609 WHEN OTHERS THEN
6610 print_time ( 'ccc' || sqlerrm );
6611 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6612 p_procedure_name => 'CLEANUP_FP_RMAP_FPR');
6613 RAISE;
6614 END;
6615
6616
6617 PROCEDURE GET_FP_ROW_IDS IS
6618 BEGIN
6619
6620 INSERT INTO PJI_FP_RMAP_FPR
6621 (
6622 worker_id
6623 , rl_rowid
6624 , tmp_rowid
6625 )
6626 SELECT /*+ ORDERED full(tmp) index(rl,PJI_FP_XBS_ACCUM_F_N1) */
6627 g_worker_id WORKER_ID
6628 , rl.ROWID rl_rowid
6629 , tmp.ROWID TMP_ROWID
6630 FROM
6631 pji_fp_aggr_pjp1 tmp
6632 , pji_fp_xbs_accum_f rl
6633 WHERE 1 = 1
6634 -- Removed outer join for bug 5927368
6635 -- AND tmp.WORKER_ID = g_worker_id
6636 -- AND tmp.PROJECT_ID = rl.PROJECT_ID (+)
6637 -- AND tmp.PLAN_VERSION_ID = rl.PLAN_VERSION_ID (+)
6638 -- AND tmp.PLAN_TYPE_ID = rl.PLAN_TYPE_ID (+)
6639 -- AND tmp.PLAN_TYPE_CODE = rl.PLAN_TYPE_CODE(+) /*4471527 */
6640 -- AND tmp.PROJECT_ORG_ID = rl.PROJECT_ORG_ID (+)
6641 -- AND tmp.PROJECT_ORGANIZATION_ID = rl.PROJECT_ORGANIZATION_ID (+)
6642 -- AND tmp.PROJECT_ELEMENT_ID = rl.PROJECT_ELEMENT_ID (+)
6643 -- AND tmp.TIME_ID = rl.TIME_ID (+)
6644 -- AND tmp.PERIOD_TYPE_ID = rl.PERIOD_TYPE_ID (+)
6645 -- AND tmp.CALENDAR_TYPE = rl.CALENDAR_TYPE (+)
6646 -- AND tmp.RBS_AGGR_LEVEL = rl.RBS_AGGR_LEVEL (+)
6647 -- AND tmp.WBS_ROLLUP_FLAG = rl.WBS_ROLLUP_FLAG (+)
6648 -- AND tmp.PRG_ROLLUP_FLAG = rl.PRG_ROLLUP_FLAG (+)
6649 -- AND tmp.CURR_RECORD_TYPE_ID = rl.CURR_RECORD_TYPE_ID (+)
6650 -- AND tmp.CURRENCY_CODE = rl.CURRENCY_CODE (+)
6651 -- AND tmp.RBS_ELEMENT_ID = rl.RBS_ELEMENT_ID (+)
6652 -- AND tmp.RBS_VERSION_ID = rl.RBS_VERSION_ID (+)
6653 -- AND tmp.RATE_DANGLING_FLAG IS NULL
6654 -- AND tmp.TIME_DANGLING_FLAG IS NULL;
6655 AND tmp.WORKER_ID = g_worker_id
6656 AND tmp.PROJECT_ID = rl.PROJECT_ID
6657 AND tmp.PLAN_VERSION_ID = rl.PLAN_VERSION_ID
6658 AND tmp.PLAN_TYPE_ID = rl.PLAN_TYPE_ID
6659 AND tmp.PLAN_TYPE_CODE = rl.PLAN_TYPE_CODE
6660 AND tmp.PROJECT_ORG_ID = rl.PROJECT_ORG_ID
6661 AND tmp.PROJECT_ORGANIZATION_ID = rl.PROJECT_ORGANIZATION_ID
6662 AND tmp.PROJECT_ELEMENT_ID = rl.PROJECT_ELEMENT_ID
6663 AND tmp.TIME_ID = rl.TIME_ID
6664 AND tmp.PERIOD_TYPE_ID = rl.PERIOD_TYPE_ID
6665 AND tmp.CALENDAR_TYPE = rl.CALENDAR_TYPE
6666 AND tmp.RBS_AGGR_LEVEL = rl.RBS_AGGR_LEVEL
6667 AND tmp.WBS_ROLLUP_FLAG = rl.WBS_ROLLUP_FLAG
6668 AND tmp.PRG_ROLLUP_FLAG = rl.PRG_ROLLUP_FLAG
6669 AND tmp.CURR_RECORD_TYPE_ID = rl.CURR_RECORD_TYPE_ID
6670 AND tmp.CURRENCY_CODE = rl.CURRENCY_CODE
6671 AND tmp.RBS_ELEMENT_ID = rl.RBS_ELEMENT_ID
6672 AND tmp.RBS_VERSION_ID = rl.RBS_VERSION_ID
6673 AND tmp.RATE_DANGLING_FLAG IS NULL
6674 AND tmp.TIME_DANGLING_FLAG IS NULL;
6675
6676 print_time ( ' MERGE_INTO_FP_FACT 1.1 ' || SQL%ROWCOUNT ) ;
6677
6678 EXCEPTION
6679 WHEN OTHERS THEN
6680 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6681 p_procedure_name => 'GET_FP_ROW_IDS');
6682 RAISE;
6683 END;
6684
6685
6686
6687 PROCEDURE UPDATE_FP_ROWS IS
6688
6689 l_last_update_date DATE := SYSDATE;
6690 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
6691 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
6692
6693 BEGIN
6694
6695
6696
6697 UPDATE /*+ ordered use_nl(rl) rowid(rl) */
6698 pji_fp_xbs_accum_f rl
6699 SET (
6700 rl.RAW_COST
6701 , rl.BRDN_COST
6702 , rl.REVENUE
6703 , rl.BILL_RAW_COST
6704 , rl.BILL_BRDN_COST
6705 , rl.BILL_LABOR_RAW_COST
6706 , rl.BILL_LABOR_BRDN_COST
6707 , rl.BILL_LABOR_HRS
6708 , rl.EQUIPMENT_RAW_COST
6709 , rl.EQUIPMENT_BRDN_COST
6710 , rl.CAPITALIZABLE_RAW_COST
6711 , rl.CAPITALIZABLE_BRDN_COST
6712 , rl.LABOR_RAW_COST
6713 , rl.LABOR_BRDN_COST
6714 , rl.LABOR_HRS
6715 , rl.LABOR_REVENUE
6716 , rl.EQUIPMENT_HOURS
6717 , rl.BILLABLE_EQUIPMENT_HOURS
6718 , rl.SUP_INV_COMMITTED_COST
6719 , rl.PO_COMMITTED_COST
6720 , rl.PR_COMMITTED_COST
6721 , rl.OTH_COMMITTED_COST
6722 , rl.ACT_LABOR_HRS
6723 , rl.ACT_EQUIP_HRS
6724 , rl.ACT_LABOR_BRDN_COST
6725 , rl.ACT_EQUIP_BRDN_COST
6726 , rl.ACT_BRDN_COST
6727 , rl.ACT_RAW_COST
6728 , rl.ACT_REVENUE
6729 , rl.ACT_LABOR_RAW_COST
6730 , rl.ACT_EQUIP_RAW_COST
6731 , rl.ETC_LABOR_HRS
6732 , rl.ETC_EQUIP_HRS
6733 , rl.ETC_LABOR_BRDN_COST
6734 , rl.ETC_EQUIP_BRDN_COST
6735 , rl.ETC_BRDN_COST
6736 , rl.ETC_RAW_COST
6737 , rl.ETC_LABOR_RAW_COST
6738 , rl.ETC_EQUIP_RAW_COST
6739 , rl.CUSTOM1
6740 , rl.CUSTOM2
6741 , rl.CUSTOM3
6742 , rl.CUSTOM4
6743 , rl.CUSTOM5
6744 , rl.CUSTOM6
6745 , rl.CUSTOM7
6746 , rl.CUSTOM8
6747 , rl.CUSTOM9
6748 , rl.CUSTOM10
6749 , rl.CUSTOM11
6750 , rl.CUSTOM12
6751 , rl.CUSTOM13
6752 , rl.CUSTOM14
6753 , rl.CUSTOM15
6754 , rl.last_update_date
6755 , rl.last_updated_by
6756 , rl.last_update_login
6757 ) =
6758 (
6759 SELECT /*+ ORDERED ROWID(TMP) index(rwid,PJI_FP_RMAP_FPR_N1) */
6760 NVL(rl.RAW_COST, 0) + NVL(tmp.RAW_COST, 0)
6761 , NVL(rl.BRDN_COST, 0) + NVL(tmp.BRDN_COST, 0)
6762 , NVL(rl.REVENUE, 0) + NVL(tmp.REVENUE, 0)
6763 , NVL(rl.BILL_RAW_COST, 0) + NVL(tmp.BILL_RAW_COST, 0)
6764 , NVL(rl.BILL_BRDN_COST, 0) + NVL(tmp.BILL_BRDN_COST, 0)
6765 , NVL(rl.BILL_LABOR_RAW_COST, 0) + NVL(tmp.BILL_LABOR_RAW_COST, 0)
6766 , NVL(rl.BILL_LABOR_BRDN_COST, 0) + NVL(tmp.BILL_LABOR_BRDN_COST, 0)
6767 , NVL(rl.BILL_LABOR_HRS, 0) + NVL(tmp.BILL_LABOR_HRS, 0)
6768 , NVL(rl.EQUIPMENT_RAW_COST, 0) + NVL(tmp.EQUIPMENT_RAW_COST, 0)
6769 , NVL(rl.EQUIPMENT_BRDN_COST, 0) + NVL(tmp.EQUIPMENT_BRDN_COST, 0)
6770 , NVL(rl.CAPITALIZABLE_RAW_COST, 0) + NVL(tmp.CAPITALIZABLE_RAW_COST , 0)
6771 , NVL(rl.CAPITALIZABLE_BRDN_COST, 0) + NVL(tmp.CAPITALIZABLE_BRDN_COST , 0)
6772 , NVL(rl.LABOR_RAW_COST, 0) + NVL(tmp.LABOR_RAW_COST, 0)
6773 , NVL(rl.LABOR_BRDN_COST, 0) + NVL(tmp.LABOR_BRDN_COST, 0)
6774 , NVL(rl.LABOR_HRS, 0) + NVL(tmp.LABOR_HRS, 0)
6775 , NVL(rl.LABOR_REVENUE, 0) + NVL(tmp.LABOR_REVENUE, 0)
6776 , NVL(rl.EQUIPMENT_HOURS, 0) + NVL(tmp.EQUIPMENT_HOURS, 0)
6777 , NVL(rl.BILLABLE_EQUIPMENT_HOURS, 0) + NVL(tmp.BILLABLE_EQUIPMENT_HOURS, 0)
6778 , NVL(rl.SUP_INV_COMMITTED_COST, 0) + NVL(tmp.SUP_INV_COMMITTED_COST, 0)
6779 , NVL(rl.PO_COMMITTED_COST, 0) + NVL(tmp.PO_COMMITTED_COST, 0)
6780 , NVL(rl.PR_COMMITTED_COST, 0) + NVL(tmp.PR_COMMITTED_COST, 0)
6781 , NVL(rl.OTH_COMMITTED_COST, 0) + NVL(tmp.OTH_COMMITTED_COST, 0)
6782 , NVL(rl.ACT_LABOR_HRS, 0) + NVL(tmp.ACT_LABOR_HRS, 0)
6783 , NVL(rl.ACT_EQUIP_HRS, 0) + NVL(tmp.ACT_EQUIP_HRS, 0)
6784 , NVL(rl.ACT_LABOR_BRDN_COST, 0) + NVL(tmp.ACT_LABOR_BRDN_COST, 0)
6785 , NVL(rl.ACT_EQUIP_BRDN_COST, 0) + NVL(tmp.ACT_EQUIP_BRDN_COST, 0)
6786 , NVL(rl.ACT_BRDN_COST, 0) + NVL(tmp.ACT_BRDN_COST, 0)
6787 , NVL(rl.ACT_RAW_COST, 0) + NVL(tmp.ACT_RAW_COST, 0)
6788 , NVL(rl.ACT_REVENUE, 0) + NVL(tmp.ACT_REVENUE, 0)
6789 , NVL(rl.ACT_LABOR_RAW_COST, 0) + NVL(tmp.ACT_LABOR_RAW_COST, 0)
6790 , NVL(rl.ACT_EQUIP_RAW_COST, 0) + NVL(tmp.ACT_EQUIP_RAW_COST, 0)
6791 , DECODE ( ver3.wp_flag
6792 , 'Y'
6793 , DECODE(TO_CHAR(tmp.ETC_LABOR_HRS)
6794 , NULL
6795 , NVL(rl.ETC_LABOR_HRS, 0) + NVL(tmp.labor_hrs, 0)
6796 , NVL(rl.ETC_LABOR_HRS, 0) + tmp.ETC_LABOR_HRS
6797 )
6798 , NVL(rl.ETC_LABOR_HRS, 0) + NVL(tmp.ETC_LABOR_HRS, 0)
6799 ) ETC_LABOR_HRS
6800 , DECODE ( ver3.wp_flag
6801 , 'Y'
6802 , DECODE(TO_CHAR(tmp.ETC_EQUIP_HRS)
6803 , NULL
6804 , NVL(rl.ETC_EQUIP_HRS, 0) + NVL(tmp.EQUIPMENT_hours, 0)
6805 , NVL(rl.ETC_EQUIP_HRS, 0) + tmp.ETC_EQUIP_HRS
6806 )
6807 , NVL(rl.ETC_EQUIP_HRS, 0) + NVL(tmp.ETC_EQUIP_HRS, 0)
6808 ) ETC_EQUIP_HRS
6809 , DECODE ( ver3.wp_flag
6810 , 'Y'
6811 , DECODE(TO_CHAR(tmp.ETC_LABOR_BRDN_COST)
6812 , NULL
6813 , NVL(rl.ETC_LABOR_BRDN_COST, 0) + NVL(tmp.labor_BRDN_COST, 0)
6814 , NVL(rl.ETC_LABOR_BRDN_COST, 0) + tmp.ETC_LABOR_BRDN_COST
6815 )
6816 , NVL(rl.ETC_LABOR_BRDN_COST, 0) + NVL(tmp.ETC_LABOR_BRDN_COST, 0)
6817 ) ETC_LABOR_BRDN_COST
6818 , DECODE ( ver3.wp_flag
6819 , 'Y'
6820 , DECODE(TO_CHAR(tmp.ETC_EQUIP_BRDN_COST)
6821 , NULL
6822 , NVL(rl.ETC_equip_BRDN_COST, 0) + NVL(tmp.EQUIPment_BRDN_COST, 0)
6823 , NVL(rl.ETC_equip_BRDN_COST, 0) + tmp.ETC_equip_BRDN_COST
6824 )
6825 , NVL(rl.ETC_EQUIP_BRDN_COST, 0) + NVL(tmp.ETC_EQUIP_BRDN_COST, 0)
6826 ) ETC_EQUIP_BRDN_COST
6827 , DECODE ( ver3.wp_flag
6828 , 'Y'
6829 , DECODE(TO_CHAR(tmp.ETC_BRDN_COST)
6830 , NULL
6831 , NVL(rl.ETC_BRDN_COST, 0) + NVL(tmp.BRDN_COST, 0)
6832 , NVL(rl.ETC_BRDN_COST, 0) + tmp.ETC_BRDN_COST
6833
6834 )
6835 , NVL(rl.ETC_BRDN_COST, 0) + NVL(tmp.ETC_BRDN_COST, 0)
6836 ) ETC_BRDN_COST
6837 , DECODE ( ver3.wp_flag
6838 , 'Y'
6839 , DECODE(TO_CHAR(tmp.ETC_raw_COST)
6840 , NULL
6841 , NVL(rl.ETC_raw_COST, 0) + NVL(tmp.raw_COST, 0)
6842 , NVL(rl.ETC_raw_COST, 0) + tmp.ETC_raw_COST
6843 )
6844 , NVL(rl.ETC_raw_COST, 0) + NVL(tmp.ETC_raw_COST, 0)
6845 ) ETC_RAW_COST
6846 , DECODE ( ver3.wp_flag
6847 , 'Y'
6848 , DECODE(TO_CHAR(tmp.ETC_labor_raw_COST)
6849 , NULL
6850 , NVL(rl.ETC_labor_raw_COST, 0) + NVL(tmp.labor_raw_COST, 0)
6851 , NVL(rl.ETC_labor_raw_COST, 0) + tmp.ETC_labor_raw_COST
6852 )
6853 , NVL(rl.ETC_labor_raw_COST, 0) + NVL(tmp.ETC_labor_raw_COST, 0)
6854 ) ETC_LABOR_RAW_COST
6855 , DECODE ( ver3.wp_flag
6856 , 'Y'
6857 , DECODE(TO_CHAR(tmp.ETC_equip_raw_COST)
6858 , NULL
6859 , NVL(rl.ETC_equip_raw_COST, 0) + NVL(tmp.equipment_raw_COST, 0)
6860 , NVL(rl.ETC_equip_raw_COST, 0) + tmp.ETC_equip_raw_COST
6861 )
6862 , NVL(rl.ETC_equip_raw_COST, 0) + NVL(tmp.ETC_equip_raw_COST, 0)
6863 ) ETC_EQUIP_RAW_COST
6864 , NVL(rl.CUSTOM1, 0) + NVL(tmp.CUSTOM1, 0)
6865 , NVL(rl.CUSTOM2, 0) + NVL(tmp.CUSTOM2, 0)
6866 , NVL(rl.CUSTOM3, 0) + NVL(tmp.CUSTOM3, 0)
6867 , NVL(rl.CUSTOM4, 0) + NVL(tmp.CUSTOM4, 0)
6868 , NVL(rl.CUSTOM5, 0) + NVL(tmp.CUSTOM5, 0)
6869 , NVL(rl.CUSTOM6, 0) + NVL(tmp.CUSTOM6, 0)
6870 , NVL(rl.CUSTOM7, 0) + NVL(tmp.CUSTOM7, 0)
6871 , NVL(rl.CUSTOM8, 0) + NVL(tmp.CUSTOM8, 0)
6872 , NVL(rl.CUSTOM9, 0) + NVL(tmp.CUSTOM9, 0)
6873 , NVL(rl.CUSTOM10, 0) + NVL(tmp.CUSTOM10, 0)
6874 , NVL(rl.CUSTOM11, 0) + NVL(tmp.CUSTOM11, 0)
6875 , NVL(rl.CUSTOM12, 0) + NVL(tmp.CUSTOM12, 0)
6876 , NVL(rl.CUSTOM13, 0) + NVL(tmp.CUSTOM13, 0)
6877 , NVL(rl.CUSTOM14, 0) + NVL(tmp.CUSTOM14, 0)
6878 , NVL(rl.CUSTOM15, 0) + NVL(tmp.CUSTOM15, 0)
6879 , SYSDATE -- l_last_update_date
6880 , l_last_updated_by
6881 , l_last_update_login
6882 FROM
6883 PJI_FP_RMAP_FPR rwid
6884 , pji_fp_aggr_pjp1 tmp
6885 , pji_pjp_wbs_header ver3 -- replaced ver3 with wbs header for project-to-program association event.
6886 WHERE 1 = 1
6887 AND tmp.rowid = rwid.tmp_rowid
6888 AND rl.rowid = rwid.rl_rowid
6889 --Commented for bug 5927368
6890 -- AND rwid.rl_rowid IS NOT NULL
6891 AND ver3.plan_version_id = tmp.plan_version_id
6892 AND rwid.worker_id = g_worker_id
6893 AND tmp.worker_id = g_worker_id
6894 AND tmp.project_id = ver3.project_id
6895 AND NVL(tmp.plan_type_id,-1) = NVL(ver3.plan_type_id, -1) -- each plan type can have a different -3, -4 slice.
6896 AND ver3.plan_type_code = tmp.plan_type_code /*4471527 */
6897 )
6898 WHERE rl.rowid IN
6899 (
6900 SELECT rwid.rl_rowid
6901 FROM PJI_FP_RMAP_FPR rwid
6902 --commented for bug 5927368
6903 -- WHERE rwid.rl_rowid IS NOT NULL
6904 -- AND rwid.worker_id = g_worker_id
6905 WHERE rwid.worker_id = g_worker_id
6906 );
6907
6908 print_time ( ' MERGE_INTO_FP_FACT 2.1 ' || sql%rowcount ) ;
6909
6910
6911 EXCEPTION
6912 WHEN OTHERS THEN
6913 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
6914 p_procedure_name => 'UPDATE_FP_ROWS');
6915 RAISE;
6916 END;
6917
6918
6919 PROCEDURE INSERT_FP_ROWS IS
6920
6921 l_last_update_date date := SYSDATE;
6922 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
6923 l_creation_date date := SYSDATE;
6924 l_created_by NUMBER := FND_GLOBAL.USER_ID;
6925 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
6926
6927 BEGIN
6928
6929 --Start of addition for bug 5927368
6930 update /*+ use_nl(pjp1_u) rowid(pjp1_u) */
6931 PJI_FP_AGGR_PJP1 pjp1_u
6932 set RECORD_TYPE = 'U'
6933 where ROWID in (select rwid.TMP_ROWID
6934 from PJI_FP_RMAP_FPR rwid
6935 where rwid.WORKER_ID = g_worker_id) and
6936 nvl(RECORD_TYPE, 'X') <> 'U';
6937 commit;
6938 --End of addition for bug 5927368
6939
6940 INSERT INTO pji_fp_xbs_accum_f fact
6941 (
6942 PROJECT_ID
6943 , PROJECT_ORG_ID
6944 , PROJECT_ORGANIZATION_ID
6945 , PROJECT_ELEMENT_ID
6946 , TIME_ID
6947 , PERIOD_TYPE_ID
6948 , CALENDAR_TYPE
6949 , RBS_AGGR_LEVEL
6950 , WBS_ROLLUP_FLAG
6951 , PRG_ROLLUP_FLAG
6952 , CURR_RECORD_TYPE_ID
6953 , CURRENCY_CODE
6954 , RBS_ELEMENT_ID
6955 , RBS_VERSION_ID
6956 , PLAN_VERSION_ID
6957 , PLAN_TYPE_ID
6958 , LAST_UPDATE_DATE
6959 , LAST_UPDATED_BY
6960 , CREATION_DATE
6961 , CREATED_BY
6962 , LAST_UPDATE_LOGIN
6963 , RAW_COST
6964 , BRDN_COST
6965 , REVENUE
6966 , BILL_RAW_COST
6967 , BILL_BRDN_COST
6968 , BILL_LABOR_RAW_COST
6969 , BILL_LABOR_BRDN_COST
6970 , BILL_LABOR_HRS
6971 , EQUIPMENT_RAW_COST
6972 , EQUIPMENT_BRDN_COST
6973 , CAPITALIZABLE_RAW_COST
6974 , CAPITALIZABLE_BRDN_COST
6975 , LABOR_RAW_COST
6976 , LABOR_BRDN_COST
6977 , LABOR_HRS
6978 , LABOR_REVENUE
6979 , EQUIPMENT_HOURS
6980 , BILLABLE_EQUIPMENT_HOURS
6981 , SUP_INV_COMMITTED_COST
6982 , PO_COMMITTED_COST
6983 , PR_COMMITTED_COST
6984 , OTH_COMMITTED_COST
6985 , ACT_LABOR_HRS
6986 , ACT_EQUIP_HRS
6987 , ACT_LABOR_BRDN_COST
6988 , ACT_EQUIP_BRDN_COST
6989 , ACT_BRDN_COST
6990 , ACT_RAW_COST
6991 , ACT_REVENUE
6992 , ACT_LABOR_RAW_COST
6993 , ACT_EQUIP_RAW_COST
6994 , ETC_LABOR_HRS
6995 , ETC_EQUIP_HRS
6996 , ETC_LABOR_BRDN_COST
6997 , ETC_EQUIP_BRDN_COST
6998 , ETC_BRDN_COST
6999 , ETC_RAW_COST
7000 , ETC_LABOR_RAW_COST
7001 , ETC_EQUIP_RAW_COST
7002 , CUSTOM1
7003 , CUSTOM2
7004 , CUSTOM3
7005 , CUSTOM4
7006 , CUSTOM5
7007 , CUSTOM6
7008 , CUSTOM7
7009 , CUSTOM8
7010 , CUSTOM9
7011 , CUSTOM10
7012 , CUSTOM11
7013 , CUSTOM12
7014 , CUSTOM13
7015 , CUSTOM14
7016 , CUSTOM15
7017 , PLAN_TYPE_CODE /*4471527 */
7018 )
7019 --Commented hint for bug 5927368
7020 SELECT /*+ ordered index(ver3 PJI_PJP_WBS_HEADER_N1) */
7021 -- SELECT / *+ ordered full(rwid) rowid(tmp) * /
7022 tmp.PROJECT_ID
7023 , tmp.PROJECT_ORG_ID
7024 , tmp.PROJECT_ORGANIZATION_ID
7025 -- , PARTITION_ID
7026 , tmp.PROJECT_ELEMENT_ID
7027 , tmp.TIME_ID
7028 , tmp.PERIOD_TYPE_ID
7029 , tmp.CALENDAR_TYPE
7030 , tmp.RBS_AGGR_LEVEL
7031 , tmp.WBS_ROLLUP_FLAG
7032 , tmp.PRG_ROLLUP_FLAG
7033 , tmp.CURR_RECORD_TYPE_ID
7034 , tmp.CURRENCY_CODE
7035 , tmp.RBS_ELEMENT_ID
7036 , tmp.RBS_VERSION_ID
7037 , ver3.PLAN_VERSION_ID
7038 , tmp.PLAN_TYPE_ID
7039 , l_last_update_date
7040 , l_last_updated_by
7041 , l_creation_date
7042 , l_created_by
7043 , l_last_update_login
7044 , RAW_COST
7045 , BRDN_COST
7046 , REVENUE
7047 , BILL_RAW_COST
7048 , BILL_BRDN_COST
7049 , BILL_LABOR_RAW_COST
7050 , BILL_LABOR_BRDN_COST
7051 , BILL_LABOR_HRS
7052 , EQUIPMENT_RAW_COST
7053 , EQUIPMENT_BRDN_COST
7054 , CAPITALIZABLE_RAW_COST
7055 , CAPITALIZABLE_BRDN_COST
7056 , LABOR_RAW_COST
7057 , LABOR_BRDN_COST
7058 , LABOR_HRS
7059 , LABOR_REVENUE
7060 , EQUIPMENT_HOURS
7061 , BILLABLE_EQUIPMENT_HOURS
7062 , SUP_INV_COMMITTED_COST
7063 , PO_COMMITTED_COST
7064 , PR_COMMITTED_COST
7065 , OTH_COMMITTED_COST
7066 , ACT_LABOR_HRS
7067 , ACT_EQUIP_HRS
7068 , ACT_LABOR_BRDN_COST
7069 , ACT_EQUIP_BRDN_COST
7070 , ACT_BRDN_COST
7071 , ACT_RAW_COST
7072 , ACT_REVENUE
7073 , ACT_LABOR_RAW_COST
7074 , ACT_EQUIP_RAW_COST
7075 , DECODE ( ver3.wp_flag
7076 , 'Y'
7077 , DECODE(TO_CHAR(tmp.ETC_LABOR_HRS) -- For Workplan
7078 , NULL
7079 , NVL(tmp.labor_hrs, 0)
7080 , NVL(tmp.ETC_LABOR_HRS, 0)
7081 )
7082 , NVL(tmp.ETC_LABOR_HRS, 0)
7083 ) ETC_LABOR_HRS
7084 , DECODE ( ver3.wp_flag
7085 , 'Y'
7086 , DECODE(TO_CHAR(tmp.ETC_EQUIP_HRS)
7087 , NULL
7088 , NVL(tmp.EQUIPMENT_hours, 0)
7089 , NVL(tmp.ETC_EQUIP_HRS, 0)
7090 )
7091 , NVL(tmp.ETC_EQUIP_HRS, 0)
7092 ) ETC_EQUIP_HRS
7093 , DECODE ( ver3.wp_flag
7094 , 'Y'
7095 , DECODE(TO_CHAR(tmp.ETC_LABOR_BRDN_COST)
7096 , NULL
7097 , NVL(tmp.labor_BRDN_COST, 0)
7098 , NVL(tmp.ETC_LABOR_BRDN_COST, 0)
7099 )
7100 , NVL(tmp.ETC_LABOR_BRDN_COST, 0)
7101 ) ETC_LABOR_BRDN_COST
7102 , DECODE ( ver3.wp_flag
7103 , 'Y'
7104 , DECODE(TO_CHAR(tmp.ETC_EQUIP_BRDN_COST)
7105 , NULL
7106 , NVL(tmp.EQUIPment_BRDN_COST, 0)
7107 , NVL(tmp.ETC_equip_BRDN_COST, 0)
7108 )
7109 , NVL(tmp.ETC_EQUIP_BRDN_COST, 0)
7110 ) ETC_equip_BRDN_COST
7111 , DECODE ( ver3.wp_flag
7112 , 'Y'
7113 , DECODE(TO_CHAR(tmp.ETC_BRDN_COST)
7114 , NULL
7115 , NVL(tmp.BRDN_COST, 0)
7116 , NVL(tmp.ETC_BRDN_COST, 0)
7117 )
7118 , NVL(tmp.ETC_BRDN_COST, 0)
7119 ) ETC_BRDN_COST
7120 , DECODE ( ver3.wp_flag
7121 , 'Y'
7122 , DECODE(TO_CHAR(tmp.ETC_raw_COST)
7123 , NULL
7124 , NVL(tmp.raw_COST, 0)
7125 , NVL(tmp.ETC_raw_COST, 0)
7126 )
7127 , NVL(tmp.ETC_raw_COST, 0)
7128 ) ETC_raw_COST
7129 , DECODE ( ver3.wp_flag
7130 , 'Y'
7131 , DECODE(TO_CHAR(tmp.ETC_labor_raw_COST)
7132 , NULL
7133 , NVL(tmp.labor_raw_COST, 0)
7134 , NVL(tmp.ETC_labor_raw_COST, 0)
7135 )
7136 , NVL(tmp.ETC_labor_raw_COST, 0)
7137 ) ETC_labor_raw_COST
7138 , DECODE ( ver3.wp_flag
7139 , 'Y'
7140 , DECODE(TO_CHAR(tmp.ETC_equip_raw_COST)
7141 , NULL
7142 , NVL(tmp.equipment_raw_COST, 0)
7143 , NVL(tmp.ETC_equip_raw_COST, 0)
7144 )
7145 , NVL(tmp.ETC_equip_raw_COST, 0)
7146 ) ETC_equip_raw_COST
7147 , CUSTOM1
7148 , CUSTOM2
7149 , CUSTOM3
7150 , CUSTOM4
7151 , CUSTOM5
7152 , CUSTOM6
7153 , CUSTOM7
7154 , CUSTOM8
7155 , CUSTOM9
7156 , CUSTOM10
7157 , CUSTOM11
7158 , CUSTOM12
7159 , CUSTOM13
7160 , CUSTOM14
7161 , CUSTOM15
7162 ,tmp.PLAN_TYPE_CODE PLAN_TYPE_CODE /*4471527 */
7163 FROM
7164 --Commented for 5927368
7165 -- PJI_FP_RMAP_FPR rwid
7166 pji_fp_aggr_pjp1 tmp
7167 , pji_pjp_wbs_header ver3 -- replaced ver3 with wbs header for project-to-program association event.
7168 WHERE 1 = 1
7169 AND tmp.worker_id = g_worker_id
7170 --commented for 5927368 and added tmp.RECORD_TYPE <> 'U' condition
7171 -- AND rwid.worker_id = g_worker_id
7172 -- AND tmp.rowid = rwid.tmp_rowid
7173 -- AND rwid.rl_rowid IS NULL
7174 AND nvl(tmp.RECORD_TYPE, 'X') <> 'U'
7175 --
7176 AND ver3.plan_version_id = tmp.plan_version_id
7177 AND ver3.plan_type_code = tmp.plan_type_code /*4471527 */
7178 AND tmp.project_id = ver3.project_id -- use index.
7179 AND NVL(tmp.plan_type_id,-1) = NVL(ver3.plan_type_id, -1) -- each plan type can have a different -3, -4 slice.
7180 ORDER BY
7181 tmp.PROJECT_ID
7182 , ver3.PLAN_VERSION_ID
7183 , tmp.PROJECT_ELEMENT_ID
7184 , tmp.TIME_ID
7185 , tmp.RBS_VERSION_ID;
7186
7187 print_time ( ' MERGE_INTO_FP_FACT 3.1 worker id..' || g_worker_id || 'row count ' || SQL%ROWCOUNT) ;
7188
7189
7190 EXCEPTION
7191 WHEN OTHERS THEN
7192 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
7193 p_procedure_name => 'INSERT_FP_ROWS');
7194 RAISE;
7195 END;
7196
7197
7198 PROCEDURE INSERT_INTO_AC_FACT IS
7199 l_last_update_date date := SYSDATE;
7200 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
7201 l_creation_date date := SYSDATE;
7202 l_created_by NUMBER := FND_GLOBAL.USER_ID;
7203 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
7204 BEGIN
7205
7206 INSERT INTO PJI_AC_XBS_ACCUM_F
7207 (
7208 PROJECT_ID
7209 , PROJECT_ORG_ID
7210 , PROJECT_ORGANIZATION_ID
7211 , PROJECT_ELEMENT_ID
7212 , TIME_ID
7213 , PERIOD_TYPE_ID
7214 , CALENDAR_TYPE
7215 , WBS_ROLLUP_FLAG
7216 , PRG_ROLLUP_FLAG
7217 , CURR_RECORD_TYPE_ID
7218 , CURRENCY_CODE
7219 , REVENUE
7220 , INITIAL_FUNDING_AMOUNT
7221 , INITIAL_FUNDING_COUNT
7222 , ADDITIONAL_FUNDING_AMOUNT
7223 , ADDITIONAL_FUNDING_COUNT
7224 , CANCELLED_FUNDING_AMOUNT
7225 , CANCELLED_FUNDING_COUNT
7226 , FUNDING_ADJUSTMENT_AMOUNT
7227 , FUNDING_ADJUSTMENT_COUNT
7228 , REVENUE_WRITEOFF
7229 , AR_INVOICE_AMOUNT
7230 , AR_INVOICE_COUNT
7231 , AR_CASH_APPLIED_AMOUNT
7232 , AR_INVOICE_WRITE_OFF_AMOUNT
7233 , AR_INVOICE_WRITEOFF_COUNT
7234 , AR_CREDIT_MEMO_AMOUNT
7235 , AR_CREDIT_MEMO_COUNT
7236 , UNBILLED_RECEIVABLES
7237 , UNEARNED_REVENUE
7238 , AR_UNAPPR_INVOICE_AMOUNT
7239 , AR_UNAPPR_INVOICE_COUNT
7240 , AR_APPR_INVOICE_AMOUNT
7241 , AR_APPR_INVOICE_COUNT
7242 , AR_AMOUNT_DUE
7243 , AR_COUNT_DUE
7244 , AR_AMOUNT_OVERDUE
7245 , AR_COUNT_OVERDUE
7246 , DORMANT_BACKLOG_INACTIV
7247 , DORMANT_BACKLOG_START
7248 , LOST_BACKLOG
7249 , ACTIVE_BACKLOG
7250 , REVENUE_AT_RISK
7251 , LAST_UPDATE_DATE
7252 , LAST_UPDATED_BY
7253 , CREATION_DATE
7254 , CREATED_BY
7255 , LAST_UPDATE_LOGIN
7256 , CUSTOM1
7257 , CUSTOM2
7258 , CUSTOM3
7259 , CUSTOM4
7260 , CUSTOM5
7261 , CUSTOM6
7262 , CUSTOM7
7263 , CUSTOM8
7264 , CUSTOM9
7265 , CUSTOM10
7266 , CUSTOM11
7267 , CUSTOM12
7268 , CUSTOM13
7269 , CUSTOM14
7270 , CUSTOM15
7271 )
7272 SELECT
7273 PROJECT_ID
7274 , PROJECT_ORG_ID
7275 , PROJECT_ORGANIZATION_ID
7276 , PROJECT_ELEMENT_ID
7277 , TIME_ID
7278 , PERIOD_TYPE_ID
7279 , CALENDAR_TYPE
7280 , WBS_ROLLUP_FLAG
7281 , PRG_ROLLUP_FLAG
7282 , CURR_RECORD_TYPE_ID
7283 , CURRENCY_CODE
7284 , REVENUE
7285 , INITIAL_FUNDING_AMOUNT
7286 , INITIAL_FUNDING_COUNT
7287 , ADDITIONAL_FUNDING_AMOUNT
7288 , ADDITIONAL_FUNDING_COUNT
7289 , CANCELLED_FUNDING_AMOUNT
7290 , CANCELLED_FUNDING_COUNT
7291 , FUNDING_ADJUSTMENT_AMOUNT
7292 , FUNDING_ADJUSTMENT_COUNT
7293 , REVENUE_WRITEOFF
7294 , AR_INVOICE_AMOUNT
7295 , AR_INVOICE_COUNT
7296 , AR_CASH_APPLIED_AMOUNT
7297 , AR_INVOICE_WRITE_OFF_AMOUNT
7298 , AR_INVOICE_WRITEOFF_COUNT
7299 , AR_CREDIT_MEMO_AMOUNT
7300 , AR_CREDIT_MEMO_COUNT
7301 , UNBILLED_RECEIVABLES
7302 , UNEARNED_REVENUE
7303 , AR_UNAPPR_INVOICE_AMOUNT
7304 , AR_UNAPPR_INVOICE_COUNT
7305 , AR_APPR_INVOICE_AMOUNT
7306 , AR_APPR_INVOICE_COUNT
7307 , AR_AMOUNT_DUE
7308 , AR_COUNT_DUE
7309 , AR_AMOUNT_OVERDUE
7310 , AR_COUNT_OVERDUE
7311 , DORMANT_BACKLOG_INACTIV
7312 , DORMANT_BACKLOG_START
7313 , LOST_BACKLOG
7314 , ACTIVE_BACKLOG
7315 , REVENUE_AT_RISK
7316 , l_last_update_date
7317 , l_last_updated_by
7318 , l_creation_date
7319 , l_created_by
7320 , l_last_update_login
7321 , CUSTOM1
7322 , CUSTOM2
7323 , CUSTOM3
7324 , CUSTOM4
7325 , CUSTOM5
7326 , CUSTOM6
7327 , CUSTOM7
7328 , CUSTOM8
7329 , CUSTOM9
7330 , CUSTOM10
7331 , CUSTOM11
7332 , CUSTOM12
7333 , CUSTOM13
7334 , CUSTOM14
7335 , CUSTOM15
7336 FROM PJI_AC_AGGR_PJP1
7337 WHERE worker_id = g_worker_id
7338 ORDER BY
7339 PROJECT_ID
7340 , PROJECT_ELEMENT_ID
7341 , TIME_ID
7342 , CURRENCY_CODE;
7343
7344 EXCEPTION
7345 WHEN OTHERS THEN
7346 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
7347 p_procedure_name => 'INSERT_INTO_AC_FACT');
7348 RAISE;
7349 END;
7350
7351
7352 PROCEDURE MERGE_INTO_AC_FACT IS
7353 BEGIN
7354
7355 GET_AC_ROW_IDS;
7356
7357 UPDATE_AC_ROWS;
7358
7359 INSERT_AC_ROWS;
7360
7361 CLEANUP_AC_RMAP_FPR;
7362
7363 EXCEPTION
7364 WHEN OTHERS THEN
7365 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
7366 p_procedure_name => 'MERGE_INTO_AC_FACT');
7367 RAISE;
7368 END;
7369
7370
7371 PROCEDURE CLEANUP_AC_RMAP_FPR IS
7372 BEGIN
7373
7374 DELETE FROM PJI_AC_RMAP_ACR
7375 WHERE worker_id = g_worker_id;
7376
7377 EXCEPTION
7378 WHEN OTHERS THEN
7379 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
7380 p_procedure_name => 'CLEANUP_AC_RMAP_FPR');
7381 RAISE;
7382 END;
7383
7384
7385 PROCEDURE GET_AC_ROW_IDS IS
7386 BEGIN
7387
7388 INSERT INTO PJI_AC_RMAP_ACR /*Not decided to keep this hint yet. + APPEND PARALLEL */
7389 (
7390 worker_id
7391 , rl_rowid
7392 , tmp_rowid
7393 )
7394 SELECT
7395 g_worker_id WORKER_ID
7396 , rl.ROWID pjp1_rowid
7397 , tmp.ROWID TMP1_ROWID
7398 FROM
7399 pji_ac_aggr_pjp1 tmp
7400 , PJI_AC_XBS_ACCUM_F rl
7401 WHERE 1 = 1
7402 AND tmp.worker_id = g_worker_id
7403 AND tmp.PROJECT_ID = rl.PROJECT_ID (+)
7404 AND tmp.PROJECT_ORG_ID = rl.PROJECT_ORG_ID (+)
7405 AND tmp.PROJECT_ORGANIZATION_ID = rl.PROJECT_ORGANIZATION_ID (+)
7406 AND tmp.PROJECT_ELEMENT_ID = rl.PROJECT_ELEMENT_ID (+)
7407 AND tmp.TIME_ID = rl.TIME_ID (+)
7408 AND tmp.PERIOD_TYPE_ID = rl.PERIOD_TYPE_ID (+)
7409 AND tmp.CALENDAR_TYPE = rl.CALENDAR_TYPE (+)
7410 AND tmp.WBS_ROLLUP_FLAG = rl.WBS_ROLLUP_FLAG (+)
7411 AND tmp.PRG_ROLLUP_FLAG = rl.PRG_ROLLUP_FLAG (+)
7412 AND tmp.CURR_RECORD_TYPE_ID = rl.CURR_RECORD_TYPE_ID (+)
7413 AND tmp.CURRENCY_CODE = rl.CURRENCY_CODE (+) ;
7414
7415 EXCEPTION
7416 WHEN OTHERS THEN
7417 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
7418 p_procedure_name => 'GET_AC_ROW_IDS');
7419 RAISE;
7420 END;
7421
7422
7423 PROCEDURE UPDATE_AC_ROWS IS
7424
7425 l_last_update_date DATE := SYSDATE;
7426 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
7427 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
7428
7429 BEGIN
7430
7431 UPDATE /*+ ordered use_nl(rl) rowid(rl) */
7432 PJI_AC_XBS_ACCUM_F rl
7433 SET (
7434 rl.REVENUE
7435 , rl.INITIAL_FUNDING_AMOUNT
7436 , rl.INITIAL_FUNDING_COUNT
7437 , rl.ADDITIONAL_FUNDING_AMOUNT
7438 , rl.ADDITIONAL_FUNDING_COUNT
7439 , rl.CANCELLED_FUNDING_AMOUNT
7440 , rl.CANCELLED_FUNDING_COUNT
7441 , rl.FUNDING_ADJUSTMENT_AMOUNT
7442 , rl.FUNDING_ADJUSTMENT_COUNT
7443 , rl.REVENUE_WRITEOFF
7444 , rl.AR_INVOICE_AMOUNT
7445 , rl.AR_INVOICE_COUNT
7446 , rl.AR_CASH_APPLIED_AMOUNT
7447 , rl.AR_INVOICE_WRITE_OFF_AMOUNT
7448 , rl.AR_INVOICE_WRITEOFF_COUNT
7449 , rl.AR_CREDIT_MEMO_AMOUNT
7450 , rl.AR_CREDIT_MEMO_COUNT
7451 , rl.UNBILLED_RECEIVABLES
7452 , rl.UNEARNED_REVENUE
7453 , rl.AR_UNAPPR_INVOICE_AMOUNT
7454 , rl.AR_UNAPPR_INVOICE_COUNT
7455 , rl.AR_APPR_INVOICE_AMOUNT
7456 , rl.AR_APPR_INVOICE_COUNT
7457 , rl.AR_AMOUNT_DUE
7458 , rl.AR_COUNT_DUE
7459 , rl.AR_AMOUNT_OVERDUE
7460 , rl.AR_COUNT_OVERDUE
7461 , rl.DORMANT_BACKLOG_INACTIV
7462 , rl.DORMANT_BACKLOG_START
7463 , rl.LOST_BACKLOG
7464 , rl.ACTIVE_BACKLOG
7465 , rl.REVENUE_AT_RISK
7466 , rl.CUSTOM1
7467 , rl.CUSTOM2
7468 , rl.CUSTOM3
7469 , rl.CUSTOM4
7470 , rl.CUSTOM5
7471 , rl.CUSTOM6
7472 , rl.CUSTOM7
7473 , rl.CUSTOM8
7474 , rl.CUSTOM9
7475 , rl.CUSTOM10
7476 , rl.CUSTOM11
7477 , rl.CUSTOM12
7478 , rl.CUSTOM13
7479 , rl.CUSTOM14
7480 , rl.CUSTOM15
7481 , rl.LAST_UPDATE_DATE
7482 , rl.LAST_UPDATED_BY
7483 , rl.LAST_UPDATE_LOGIN
7484 ) =
7485 (
7486 SELECT /*+ ORDERED ROWID(TMP) index(rwid,PJI_AC_RMAP_ACR_N1) */
7487 NVL(rl.REVENUE, 0) + NVL(tmp.REVENUE, 0)
7488 , NVL(rl.INITIAL_FUNDING_AMOUNT, 0) + NVL(tmp.INITIAL_FUNDING_AMOUNT, 0)
7489 , NVL(rl.INITIAL_FUNDING_COUNT, 0) + NVL(tmp.INITIAL_FUNDING_COUNT, 0)
7490 , NVL(rl.ADDITIONAL_FUNDING_AMOUNT, 0) + NVL(tmp.ADDITIONAL_FUNDING_AMOUNT, 0)
7491 , NVL(rl.ADDITIONAL_FUNDING_COUNT, 0) + NVL(tmp.ADDITIONAL_FUNDING_COUNT, 0)
7492 , NVL(rl.CANCELLED_FUNDING_AMOUNT, 0) + NVL(tmp.CANCELLED_FUNDING_AMOUNT, 0)
7493 , NVL(rl.CANCELLED_FUNDING_COUNT, 0) + NVL(tmp.CANCELLED_FUNDING_COUNT, 0)
7494 , NVL(rl.FUNDING_ADJUSTMENT_AMOUNT, 0) + NVL(tmp.FUNDING_ADJUSTMENT_AMOUNT, 0)
7495 , NVL(rl.FUNDING_ADJUSTMENT_COUNT, 0) + NVL(tmp.FUNDING_ADJUSTMENT_COUNT, 0)
7496 , NVL(rl.REVENUE_WRITEOFF, 0) + NVL(tmp.REVENUE_WRITEOFF, 0)
7497 , NVL(rl.AR_INVOICE_AMOUNT, 0) + NVL(tmp.AR_INVOICE_AMOUNT, 0)
7498 , NVL(rl.AR_INVOICE_COUNT, 0) + NVL(tmp.AR_INVOICE_COUNT, 0)
7499 , NVL(rl.AR_CASH_APPLIED_AMOUNT, 0) + NVL(tmp.AR_CASH_APPLIED_AMOUNT, 0)
7500 , NVL(rl.AR_INVOICE_WRITE_OFF_AMOUNT, 0) + NVL(tmp.AR_INVOICE_WRITE_OFF_AMOUNT, 0)
7501 , NVL(rl.AR_INVOICE_WRITEOFF_COUNT, 0) + NVL(tmp.AR_INVOICE_WRITEOFF_COUNT, 0)
7502 , NVL(rl.AR_CREDIT_MEMO_AMOUNT, 0) + NVL(tmp.AR_CREDIT_MEMO_AMOUNT, 0)
7503 , NVL(rl.AR_CREDIT_MEMO_COUNT, 0) + NVL(tmp.AR_CREDIT_MEMO_COUNT, 0)
7504 , NVL(rl.UNBILLED_RECEIVABLES, 0) + NVL(tmp.UNBILLED_RECEIVABLES, 0)
7505 , NVL(rl.UNEARNED_REVENUE, 0) + NVL(tmp.UNEARNED_REVENUE, 0)
7506 , NVL(rl.AR_UNAPPR_INVOICE_AMOUNT, 0) + NVL(tmp.AR_UNAPPR_INVOICE_AMOUNT, 0)
7507 , NVL(rl.AR_UNAPPR_INVOICE_COUNT, 0) + NVL(tmp.AR_UNAPPR_INVOICE_COUNT, 0)
7508 , NVL(rl.AR_APPR_INVOICE_AMOUNT, 0) + NVL(tmp.AR_APPR_INVOICE_AMOUNT, 0)
7509 , NVL(rl.AR_APPR_INVOICE_COUNT, 0) + NVL(tmp.AR_APPR_INVOICE_COUNT, 0)
7510 , NVL(rl.AR_AMOUNT_DUE, 0) + NVL(tmp.AR_AMOUNT_DUE, 0)
7511 , NVL(rl.AR_COUNT_DUE, 0) + NVL(tmp.AR_COUNT_DUE, 0)
7512 , NVL(rl.AR_AMOUNT_OVERDUE, 0) + NVL(tmp.AR_AMOUNT_OVERDUE, 0)
7513 , NVL(rl.AR_COUNT_OVERDUE, 0) + NVL(tmp.AR_COUNT_OVERDUE, 0)
7514 , NVL(rl.DORMANT_BACKLOG_INACTIV, 0) + NVL(tmp.DORMANT_BACKLOG_INACTIV, 0)
7515 , NVL(rl.DORMANT_BACKLOG_START, 0) + NVL(tmp.DORMANT_BACKLOG_START, 0)
7516 , NVL(rl.LOST_BACKLOG, 0) + NVL(tmp.LOST_BACKLOG, 0)
7517 , NVL(rl.ACTIVE_BACKLOG, 0) + NVL(tmp.ACTIVE_BACKLOG, 0)
7518 , NVL(rl.REVENUE_AT_RISK, 0) + NVL(tmp.REVENUE_AT_RISK, 0)
7519 , NVL(rl.CUSTOM1, 0) + NVL(tmp.CUSTOM1, 0)
7520 , NVL(rl.CUSTOM2, 0) + NVL(tmp.CUSTOM2, 0)
7521 , NVL(rl.CUSTOM3, 0) + NVL(tmp.CUSTOM3, 0)
7522 , NVL(rl.CUSTOM4, 0) + NVL(tmp.CUSTOM4, 0)
7523 , NVL(rl.CUSTOM5, 0) + NVL(tmp.CUSTOM5, 0)
7524 , NVL(rl.CUSTOM6, 0) + NVL(tmp.CUSTOM6, 0)
7525 , NVL(rl.CUSTOM7, 0) + NVL(tmp.CUSTOM7, 0)
7526 , NVL(rl.CUSTOM8, 0) + NVL(tmp.CUSTOM8, 0)
7527 , NVL(rl.CUSTOM9, 0) + NVL(tmp.CUSTOM9, 0)
7528 , NVL(rl.CUSTOM10, 0) + NVL(tmp.CUSTOM10, 0)
7529 , NVL(rl.CUSTOM11, 0) + NVL(tmp.CUSTOM11, 0)
7530 , NVL(rl.CUSTOM12, 0) + NVL(tmp.CUSTOM12, 0)
7531 , NVL(rl.CUSTOM13, 0) + NVL(tmp.CUSTOM13, 0)
7532 , NVL(rl.CUSTOM14, 0) + NVL(tmp.CUSTOM14, 0)
7533 , NVL(rl.CUSTOM15, 0) + NVL(tmp.CUSTOM15, 0)
7534 , l_last_update_date
7535 , l_last_updated_by
7536 , l_last_update_login
7537 FROM
7538 PJI_AC_RMAP_ACR rwid
7539 , pji_ac_aggr_pjp1 tmp
7540 WHERE 1 = 1
7541 AND tmp.worker_id = g_worker_id
7542 AND rwid.worker_id = g_worker_id
7543 AND tmp.rowid = rwid.tmp_rowid
7544 AND rl.rowid = rwid.rl_rowid
7545 AND rwid.rl_rowid IS NOT NULL
7546 )
7547 WHERE rl.rowid IN
7548 ( SELECT rl_rowid
7549 FROM PJI_AC_RMAP_ACR rwid
7550 WHERE 1=1
7551 AND rwid.rl_rowid IS NOT NULL
7552 AND rwid.worker_id = g_worker_id);
7553
7554 EXCEPTION
7555 WHEN OTHERS THEN
7556 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
7557 p_procedure_name => 'UPDATE_AC_ROWS');
7558 RAISE;
7559 END;
7560
7561
7562 PROCEDURE INSERT_AC_ROWS IS
7563 l_last_update_date date := SYSDATE;
7564 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
7565 l_creation_date date := SYSDATE;
7566 l_created_by NUMBER := FND_GLOBAL.USER_ID;
7567 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
7568 BEGIN
7569
7570 INSERT INTO PJI_AC_XBS_ACCUM_F
7571 (
7572 PROJECT_ID
7573 , PROJECT_ORG_ID
7574 , PROJECT_ORGANIZATION_ID
7575 , PROJECT_ELEMENT_ID
7576 , TIME_ID
7577 , PERIOD_TYPE_ID
7578 , CALENDAR_TYPE
7579 , WBS_ROLLUP_FLAG
7580 , PRG_ROLLUP_FLAG
7581 , CURR_RECORD_TYPE_ID
7582 , CURRENCY_CODE
7583 , REVENUE
7584 , INITIAL_FUNDING_AMOUNT
7585 , INITIAL_FUNDING_COUNT
7586 , ADDITIONAL_FUNDING_AMOUNT
7587 , ADDITIONAL_FUNDING_COUNT
7588 , CANCELLED_FUNDING_AMOUNT
7589 , CANCELLED_FUNDING_COUNT
7590 , FUNDING_ADJUSTMENT_AMOUNT
7591 , FUNDING_ADJUSTMENT_COUNT
7592 , REVENUE_WRITEOFF
7593 , AR_INVOICE_AMOUNT
7594 , AR_INVOICE_COUNT
7595 , AR_CASH_APPLIED_AMOUNT
7596 , AR_INVOICE_WRITE_OFF_AMOUNT
7597 , AR_INVOICE_WRITEOFF_COUNT
7598 , AR_CREDIT_MEMO_AMOUNT
7599 , AR_CREDIT_MEMO_COUNT
7600 , UNBILLED_RECEIVABLES
7601 , UNEARNED_REVENUE
7602 , AR_UNAPPR_INVOICE_AMOUNT
7603 , AR_UNAPPR_INVOICE_COUNT
7604 , AR_APPR_INVOICE_AMOUNT
7605 , AR_APPR_INVOICE_COUNT
7606 , AR_AMOUNT_DUE
7607 , AR_COUNT_DUE
7608 , AR_AMOUNT_OVERDUE
7609 , AR_COUNT_OVERDUE
7610 , DORMANT_BACKLOG_INACTIV
7611 , DORMANT_BACKLOG_START
7612 , LOST_BACKLOG
7613 , ACTIVE_BACKLOG
7614 , REVENUE_AT_RISK
7615 , LAST_UPDATE_DATE
7616 , LAST_UPDATED_BY
7617 , CREATION_DATE
7618 , CREATED_BY
7619 , LAST_UPDATE_LOGIN
7620 , CUSTOM1
7621 , CUSTOM2
7622 , CUSTOM3
7623 , CUSTOM4
7624 , CUSTOM5
7625 , CUSTOM6
7626 , CUSTOM7
7627 , CUSTOM8
7628 , CUSTOM9
7629 , CUSTOM10
7630 , CUSTOM11
7631 , CUSTOM12
7632 , CUSTOM13
7633 , CUSTOM14
7634 , CUSTOM15
7635 )
7636 SELECT
7637 PROJECT_ID
7638 , PROJECT_ORG_ID
7639 , PROJECT_ORGANIZATION_ID
7640 , PROJECT_ELEMENT_ID
7641 , TIME_ID
7642 , PERIOD_TYPE_ID
7643 , CALENDAR_TYPE
7644 , WBS_ROLLUP_FLAG
7645 , PRG_ROLLUP_FLAG
7646 , CURR_RECORD_TYPE_ID
7647 , CURRENCY_CODE
7648 , REVENUE
7649 , INITIAL_FUNDING_AMOUNT
7650 , INITIAL_FUNDING_COUNT
7651 , ADDITIONAL_FUNDING_AMOUNT
7652 , ADDITIONAL_FUNDING_COUNT
7653 , CANCELLED_FUNDING_AMOUNT
7654 , CANCELLED_FUNDING_COUNT
7655 , FUNDING_ADJUSTMENT_AMOUNT
7656 , FUNDING_ADJUSTMENT_COUNT
7657 , REVENUE_WRITEOFF
7658 , AR_INVOICE_AMOUNT
7659 , AR_INVOICE_COUNT
7660 , AR_CASH_APPLIED_AMOUNT
7661 , AR_INVOICE_WRITE_OFF_AMOUNT
7662 , AR_INVOICE_WRITEOFF_COUNT
7663 , AR_CREDIT_MEMO_AMOUNT
7664 , AR_CREDIT_MEMO_COUNT
7665 , UNBILLED_RECEIVABLES
7666 , UNEARNED_REVENUE
7667 , AR_UNAPPR_INVOICE_AMOUNT
7668 , AR_UNAPPR_INVOICE_COUNT
7669 , AR_APPR_INVOICE_AMOUNT
7670 , AR_APPR_INVOICE_COUNT
7671 , AR_AMOUNT_DUE
7672 , AR_COUNT_DUE
7673 , AR_AMOUNT_OVERDUE
7674 , AR_COUNT_OVERDUE
7675 , DORMANT_BACKLOG_INACTIV
7676 , DORMANT_BACKLOG_START
7677 , LOST_BACKLOG
7678 , ACTIVE_BACKLOG
7679 , REVENUE_AT_RISK
7680 , l_last_update_date
7681 , l_last_updated_by
7682 , l_creation_date
7683 , l_created_by
7684 , l_last_update_login
7685 , CUSTOM1
7686 , CUSTOM2
7687 , CUSTOM3
7688 , CUSTOM4
7689 , CUSTOM5
7690 , CUSTOM6
7691 , CUSTOM7
7692 , CUSTOM8
7693 , CUSTOM9
7694 , CUSTOM10
7695 , CUSTOM11
7696 , CUSTOM12
7697 , CUSTOM13
7698 , CUSTOM14
7699 , CUSTOM15
7700 FROM pji_ac_aggr_pjp1 tmp
7701 , PJI_AC_RMAP_ACR rwid
7702 WHERE 1 = 1
7703 AND tmp.worker_id = g_worker_id
7704 AND rwid.worker_id = g_worker_id
7705 AND tmp.rowid = rwid.tmp_rowid
7706 AND rwid.rl_rowid IS NULL
7707 ORDER BY
7708 PROJECT_ID
7709 , PROJECT_ELEMENT_ID
7710 , TIME_ID
7711 , CURRENCY_CODE;
7712
7713 EXCEPTION
7714 WHEN OTHERS THEN
7715 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
7716 p_procedure_name => 'INSERT_AC_ROWS');
7717 RAISE;
7718 END;
7719
7720 PROCEDURE MARK_DANGLING_PLAN_VERSIONS IS
7721 BEGIN
7722
7723 UPDATE pa_budget_versions bv
7724 SET pji_summarized_flag = 'P',
7725 record_version_number = nvl(record_version_number,0)+1
7726 WHERE budget_version_id IN (
7727 SELECT plan_version_id
7728 FROM
7729 (
7730 SELECT plan_version_id
7731 , ( COUNT(DISTINCT time_dangling_flag)
7732 + COUNT(DISTINCT rate_dangling_flag)
7733 ) dangling
7734 FROM pji_fp_aggr_pjp1
7735 WHERE worker_id = g_worker_id
7736 GROUP BY plan_version_id
7737 ) b
7738 WHERE dangling > 2
7739 );
7740
7741 UPDATE pa_budget_versions bv
7742 SET pji_summarized_flag = 'Y',
7743 record_version_number = nvl(record_version_number,0)+1
7744 WHERE budget_version_id IN (
7745 SELECT plan_version_id
7746 FROM
7747 (
7748 SELECT plan_version_id
7749 , ( COUNT(DISTINCT time_dangling_flag)
7750 + COUNT(DISTINCT rate_dangling_flag)
7751 ) dangling
7752 FROM pji_fp_aggr_pjp1
7753 WHERE worker_id = g_worker_id
7754 GROUP BY plan_version_id
7755 ) b
7756 WHERE dangling = 2
7757 );
7758
7759 EXCEPTION
7760 WHEN OTHERS THEN
7761 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
7762 p_procedure_name => 'MARK_DANGLING_PLAN_VERSIONS');
7763 RAISE;
7764 END;
7765
7766
7767 --
7768 -- 0. Plans cannot have time / rate dangling records for primary slice.
7769 -- 1. Work plans have primary slice only.
7770 -- 2. Financial plans can have secondary slices only if the plan is baselined.
7771 -- 3. Only baselined financial plans can have time/rate dangling records.
7772 -- 4. Four states of pji_summarized_flag are N, Y, P, NULL.
7773 -- N - Not summarized..
7774 -- P - Have rate/time dangling records..
7775 -- Y - Project performance summaries fully created.
7776 -- NULL - PJI summaries fully created.
7777 --
7778 -- This api processes plans with pji_summarized_flag = N, i.e., secondary slice
7779 -- for dangling baselined financial plans.
7780 --
7781 PROCEDURE PULL_DANGLING_PLANS IS
7782
7783 l_fp_wp_version_ids SYSTEM.pa_num_tbl_type := SYSTEM.pa_num_tbl_type();
7784 l_fp_version_ids SYSTEM.pa_num_tbl_type := SYSTEM.pa_num_tbl_type();
7785
7786 BEGIN
7787
7788 NULL; -- Pull dangling calls bulk "create secondary private" directly.
7789
7790 EXCEPTION
7791 WHEN OTHERS THEN
7792 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
7793 p_procedure_name => 'PULL_DANGLING_PLANS');
7794 RAISE;
7795 END;
7796
7797
7798 PROCEDURE RETRIEVE_ENTERED_SLICE (
7799 p_pln_ver_id IN NUMBER := NULL ) IS
7800 BEGIN
7801
7802 INSERT INTO pji_fp_aggr_pjp1
7803 (
7804 WORKER_ID
7805 , PROJECT_ID
7806 , PROJECT_ORG_ID
7807 , PROJECT_ORGANIZATION_ID
7808 -- , PARTITION_ID
7809 , PROJECT_ELEMENT_ID
7810 , TIME_ID
7811 , PERIOD_TYPE_ID
7812 , CALENDAR_TYPE
7813 , RBS_AGGR_LEVEL
7814 , WBS_ROLLUP_FLAG
7815 , PRG_ROLLUP_FLAG
7816 , CURR_RECORD_TYPE_ID
7817 , CURRENCY_CODE
7818 , RBS_ELEMENT_ID
7819 , RBS_VERSION_ID
7820 , PLAN_VERSION_ID
7821 , PLAN_TYPE_ID
7822 , RAW_COST
7823 , BRDN_COST
7824 , REVENUE
7825 , BILL_RAW_COST
7826 , BILL_BRDN_COST
7827 , BILL_LABOR_RAW_COST
7828 , BILL_LABOR_BRDN_COST
7829 , BILL_LABOR_HRS
7830 , EQUIPMENT_RAW_COST
7831 , EQUIPMENT_BRDN_COST
7832 , CAPITALIZABLE_RAW_COST
7833 , CAPITALIZABLE_BRDN_COST
7834 , LABOR_RAW_COST
7835 , LABOR_BRDN_COST
7836 , LABOR_HRS
7837 , LABOR_REVENUE
7838 , EQUIPMENT_HOURS
7839 , BILLABLE_EQUIPMENT_HOURS
7840 , SUP_INV_COMMITTED_COST
7841 , PO_COMMITTED_COST
7842 , PR_COMMITTED_COST
7843 , OTH_COMMITTED_COST
7844 , ACT_LABOR_HRS
7845 , ACT_EQUIP_HRS
7846 , ACT_LABOR_BRDN_COST
7847 , ACT_EQUIP_BRDN_COST
7848 , ACT_BRDN_COST
7849 , ACT_RAW_COST
7850 , ACT_REVENUE
7851 , ACT_LABOR_RAW_COST
7852 , ACT_EQUIP_RAW_COST
7853 , ETC_LABOR_HRS
7854 , ETC_EQUIP_HRS
7855 , ETC_LABOR_BRDN_COST
7856 , ETC_EQUIP_BRDN_COST
7857 , ETC_BRDN_COST
7858 , ETC_RAW_COST
7859 , ETC_LABOR_RAW_COST
7860 , ETC_EQUIP_RAW_COST
7861 , CUSTOM1
7862 , CUSTOM2
7863 , CUSTOM3
7864 , CUSTOM4
7865 , CUSTOM5
7866 , CUSTOM6
7867 , CUSTOM7
7868 , CUSTOM8
7869 , CUSTOM9
7870 , CUSTOM10
7871 , CUSTOM11
7872 , CUSTOM12
7873 , CUSTOM13
7874 , CUSTOM14
7875 , CUSTOM15
7876 , PRG_LEVEL
7877 ,PLAN_TYPE_CODE /*4471527 */
7878 )
7879 (
7880 SELECT
7881 g_worker_id
7882 , PROJECT_ID
7883 , PROJECT_ORG_ID
7884 , PROJECT_ORGANIZATION_ID
7885 -- , PARTITION_ID
7886 , PROJECT_ELEMENT_ID
7887 , TIME_ID
7888 , PERIOD_TYPE_ID
7889 , CALENDAR_TYPE
7890 , RBS_AGGR_LEVEL
7891 , WBS_ROLLUP_FLAG
7892 , PRG_ROLLUP_FLAG
7893 , CURR_RECORD_TYPE_ID
7894 , CURRENCY_CODE
7895 , RBS_ELEMENT_ID
7896 , RBS_VERSION_ID
7897 , PLAN_VERSION_ID
7898 , PLAN_TYPE_ID
7899 , RAW_COST
7900 , BRDN_COST
7901 , REVENUE
7902 , BILL_RAW_COST
7903 , BILL_BRDN_COST
7904 , BILL_LABOR_RAW_COST
7905 , BILL_LABOR_BRDN_COST
7906 , BILL_LABOR_HRS
7907 , EQUIPMENT_RAW_COST
7908 , EQUIPMENT_BRDN_COST
7909 , CAPITALIZABLE_RAW_COST
7910 , CAPITALIZABLE_BRDN_COST
7911 , LABOR_RAW_COST
7912 , LABOR_BRDN_COST
7913 , LABOR_HRS
7914 , LABOR_REVENUE
7915 , EQUIPMENT_HOURS
7916 , BILLABLE_EQUIPMENT_HOURS
7917 , SUP_INV_COMMITTED_COST
7918 , PO_COMMITTED_COST
7919 , PR_COMMITTED_COST
7920 , OTH_COMMITTED_COST
7921 , ACT_LABOR_HRS
7922 , ACT_EQUIP_HRS
7923 , ACT_LABOR_BRDN_COST
7924 , ACT_EQUIP_BRDN_COST
7925 , ACT_BRDN_COST
7926 , ACT_RAW_COST
7927 , ACT_REVENUE
7928 , ACT_LABOR_RAW_COST
7929 , ACT_EQUIP_RAW_COST
7930 , ETC_LABOR_HRS
7931 , ETC_EQUIP_HRS
7932 , ETC_LABOR_BRDN_COST
7933 , ETC_EQUIP_BRDN_COST
7934 , ETC_BRDN_COST
7935 , ETC_RAW_COST
7936 , ETC_LABOR_RAW_COST
7937 , ETC_EQUIP_RAW_COST
7938 , CUSTOM1
7939 , CUSTOM2
7940 , CUSTOM3
7941 , CUSTOM4
7942 , CUSTOM5
7943 , CUSTOM6
7944 , CUSTOM7
7945 , CUSTOM8
7946 , CUSTOM9
7947 , CUSTOM10
7948 , CUSTOM11
7949 , CUSTOM12
7950 , CUSTOM13
7951 , CUSTOM14
7952 , CUSTOM15
7953 , g_default_prg_level
7954 ,PLAN_TYPE_CODE
7955 FROM pji_fp_xbs_accum_f
7956 WHERE plan_version_id = p_pln_ver_id
7957 );
7958
7959 EXCEPTION
7960 WHEN OTHERS THEN
7961 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
7962 p_procedure_name => 'RETRIEVE_ENTERED_SLICE');
7963 RAISE;
7964 END;
7965
7966
7967
7968
7969 PROCEDURE ROLLUP_FPR_RBS IS
7970 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
7971 -- l_worker_id NUMBER := 1;
7972
7973 BEGIN
7974
7975 INSERT INTO pji_fp_aggr_pjp1
7976 (
7977 WORKER_ID
7978 , PROJECT_ID
7979 , PROJECT_ORG_ID
7980 , PROJECT_ORGANIZATION_ID
7981 , PROJECT_ELEMENT_ID
7982 , TIME_ID
7983 , PERIOD_TYPE_ID
7984 , CALENDAR_TYPE
7985 , RBS_AGGR_LEVEL
7986 , WBS_ROLLUP_FLAG
7987 , PRG_ROLLUP_FLAG
7988 , CURR_RECORD_TYPE_ID
7989 , CURRENCY_CODE
7990 , RBS_ELEMENT_ID
7991 , RBS_VERSION_ID
7992 , PLAN_VERSION_ID
7993 , PLAN_TYPE_ID
7994 , RAW_COST
7995 , BRDN_COST
7996 , REVENUE
7997 , BILL_RAW_COST
7998 , BILL_BRDN_COST
7999 , BILL_LABOR_RAW_COST
8000 , BILL_LABOR_BRDN_COST
8001 , BILL_LABOR_HRS
8002 , EQUIPMENT_RAW_COST
8003 , EQUIPMENT_BRDN_COST
8004 , CAPITALIZABLE_RAW_COST
8005 , CAPITALIZABLE_BRDN_COST
8006 , LABOR_RAW_COST
8007 , LABOR_BRDN_COST
8008 , LABOR_HRS
8009 , LABOR_REVENUE
8010 , EQUIPMENT_HOURS
8011 , BILLABLE_EQUIPMENT_HOURS
8012 , SUP_INV_COMMITTED_COST
8013 , PO_COMMITTED_COST
8014 , PR_COMMITTED_COST
8015 , OTH_COMMITTED_COST
8016 , ACT_LABOR_HRS
8017 , ACT_EQUIP_HRS
8018 , ACT_LABOR_BRDN_COST
8019 , ACT_EQUIP_BRDN_COST
8020 , ACT_BRDN_COST
8021 , ACT_RAW_COST
8022 , ACT_REVENUE
8023 , ACT_LABOR_RAW_COST
8024 , ACT_EQUIP_RAW_COST
8025 , ETC_LABOR_HRS
8026 , ETC_EQUIP_HRS
8027 , ETC_LABOR_BRDN_COST
8028 , ETC_EQUIP_BRDN_COST
8029 , ETC_BRDN_COST
8030 , ETC_RAW_COST
8031 , ETC_LABOR_RAW_COST
8032 , ETC_EQUIP_RAW_COST
8033 , CUSTOM1
8034 , CUSTOM2
8035 , CUSTOM3
8036 , CUSTOM4
8037 , CUSTOM5
8038 , CUSTOM6
8039 , CUSTOM7
8040 , CUSTOM8
8041 , CUSTOM9
8042 , CUSTOM10
8043 , CUSTOM11
8044 , CUSTOM12
8045 , CUSTOM13
8046 , CUSTOM14
8047 , CUSTOM15
8048 , LINE_TYPE
8049 , PRG_LEVEL
8050 , PLAN_TYPE_CODE /*4471527 */
8051 )
8052 SELECT
8053 g_worker_id WORKER_ID
8054 , fact1.PROJECT_ID
8055 , fact1.PROJECT_ORG_ID
8056 , fact1.PROJECT_ORGANIZATION_ID
8057 , fact1.project_element_id
8058 , fact1.TIME_ID
8059 , fact1.PERIOD_TYPE_ID
8060 , fact1.CALENDAR_TYPE
8061 , 'R'
8062 , fact1.WBS_ROLLUP_FLAG
8063 , fact1.PRG_ROLLUP_FLAG
8064 , fact1.CURR_RECORD_TYPE_ID
8065 , fact1.CURRENCY_CODE
8066 , rbs.sup_id
8067 , fact1.RBS_VERSION_ID
8068 , fact1.PLAN_VERSION_ID
8069 , fact1.PLAN_TYPE_ID
8070 , SUM(fact1.RAW_COST)
8071 , SUM(fact1.BRDN_COST)
8072 , SUM(fact1.REVENUE)
8073 , SUM(fact1.BILL_RAW_COST)
8074 , SUM(fact1.BILL_BRDN_COST )
8075 , SUM(fact1.BILL_LABOR_RAW_COST)
8076 , SUM(fact1.BILL_LABOR_BRDN_COST )
8077 , SUM(fact1.BILL_LABOR_HRS )
8078 , SUM(fact1.EQUIPMENT_RAW_COST )
8079 , SUM(fact1.EQUIPMENT_BRDN_COST )
8080 , SUM(fact1.CAPITALIZABLE_RAW_COST )
8081 , SUM(fact1.CAPITALIZABLE_BRDN_COST )
8082 , SUM(fact1.LABOR_RAW_COST )
8083 , SUM(fact1.LABOR_BRDN_COST )
8084 , SUM(fact1.LABOR_HRS)
8085 , SUM(fact1.LABOR_REVENUE)
8086 , SUM(fact1.EQUIPMENT_HOURS)
8087 , SUM(fact1.BILLABLE_EQUIPMENT_HOURS)
8088 , SUM(fact1.SUP_INV_COMMITTED_COST)
8089 , SUM(fact1.PO_COMMITTED_COST )
8090 , SUM(fact1.PR_COMMITTED_COST )
8091 , SUM(fact1.OTH_COMMITTED_COST)
8092 , SUM(fact1.ACT_LABOR_HRS)
8093 , SUM(fact1.ACT_EQUIP_HRS)
8094 , SUM(fact1.ACT_LABOR_BRDN_COST)
8095 , SUM(fact1.ACT_EQUIP_BRDN_COST)
8096 , SUM(fact1.ACT_BRDN_COST)
8097 , SUM(fact1.ACT_RAW_COST)
8098 , SUM(fact1.ACT_REVENUE)
8099 , SUM(fact1.ACT_LABOR_RAW_COST)
8100 , SUM(fact1.ACT_EQUIP_RAW_COST)
8101 , SUM(fact1.ETC_LABOR_HRS)
8102 , SUM(fact1.ETC_EQUIP_HRS)
8103 , SUM(fact1.ETC_LABOR_BRDN_COST)
8104 , SUM(fact1.ETC_EQUIP_BRDN_COST)
8105 , SUM(fact1.ETC_BRDN_COST )
8106 , SUM(fact1.ETC_RAW_COST )
8107 , SUM(fact1.ETC_LABOR_RAW_COST)
8108 , SUM(fact1.ETC_EQUIP_RAW_COST)
8109 , SUM(fact1.CUSTOM1 )
8110 , SUM(fact1.CUSTOM2 )
8111 , SUM(fact1.CUSTOM3 )
8112 , SUM(fact1.CUSTOM4 )
8113 , SUM(fact1.CUSTOM5 )
8114 , SUM(fact1.CUSTOM6 )
8115 , SUM(fact1.CUSTOM7 )
8116 , SUM(fact1.CUSTOM8 )
8117 , SUM(fact1.CUSTOM9 )
8118 , SUM(fact1.CUSTOM10 )
8119 , SUM(fact1.CUSTOM11 )
8120 , SUM(fact1.CUSTOM12 )
8121 , SUM(fact1.CUSTOM13 )
8122 , SUM(fact1.CUSTOM14 )
8123 , SUM(fact1.CUSTOM15 )
8124 , fact1.line_type
8125 , g_default_prg_level
8126 ,fact1.PLAN_TYPE_CODE /*4471527 */
8127 FROM pji_fp_aggr_pjp1 fact1
8128 , Pji_RBS_DENORM rbs
8129 , pji_rollup_level_status smart
8130 , pji_pjp_rbs_header rhdr
8131 WHERE 1 = 1
8132 AND fact1.project_id = rhdr.project_id
8133 AND fact1.plan_version_id = rhdr.plan_version_id
8134 AND fact1.plan_type_code = rhdr.plan_type_code /*4471527 */
8135 AND rbs.struct_version_id = rhdr.rbs_version_id
8136 AND fact1.rbs_ELEMENT_ID = rbs.sub_id
8137 AND rbs.sup_level <> rbs.sub_level
8138 AND rbs.sup_level <> 1
8139 AND fact1.RBS_AGGR_LEVEL = 'L'
8140 AND smart.rbs_version_id = rbs.struct_version_id
8141 AND smart.plan_version_id = fact1.plan_version_id
8142 AND smart.plan_type_code = fact1.plan_type_code /*4471527 */
8143 AND fact1.worker_id = g_worker_id
8144 GROUP BY
8145 fact1.PROJECT_ID
8146 , fact1.PROJECT_ORG_ID
8147 , fact1.PROJECT_ORGANIZATION_ID
8148 , fact1.project_element_id
8149 , fact1.TIME_ID
8150 , fact1.PERIOD_TYPE_ID
8151 , fact1.CALENDAR_TYPE
8152 , fact1.WBS_ROLLUP_FLAG
8153 , fact1.PRG_ROLLUP_FLAG
8154 , fact1.CURR_RECORD_TYPE_ID
8155 , fact1.CURRENCY_CODE
8156 , rbs.sup_id
8157 , fact1.RBS_VERSION_ID
8158 , fact1.PLAN_VERSION_ID
8159 , fact1.PLAN_TYPE_ID
8160 , fact1.line_type
8161 , fact1.plan_type_code ; /*4471527*/
8162
8163
8164 EXCEPTION
8165 WHEN OTHERS THEN
8166 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8167 p_procedure_name => 'ROLLUP_FPR_RBS');
8168 RAISE;
8169 END;
8170
8171
8172 PROCEDURE ROLLUP_FPR_RBS_T_SLICE IS
8173 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
8174
8175 BEGIN
8176
8177 print_time(' worker id is ... ' || 1);
8178
8179 /* Added for bug 11843459 */
8180 if PJI_PJP_GEN_PERF_ALL.GET_PARAMETER('PJI_PJP_PERF_PRL') = 'Y' then
8181 PJI_PJP_GEN_PERF_ALL.ROLLUP_FPR_RBS_T_SLICE;
8182 else
8183 INSERT /*+ parallel(pji_fp_aggr_pjp1) */ /* Added for bug 13030627 */
8184 INTO pji_fp_aggr_pjp1
8185 (
8186 WORKER_ID
8187 , PROJECT_ID
8188 , PROJECT_ORG_ID
8189 , PROJECT_ORGANIZATION_ID
8190 , PROJECT_ELEMENT_ID
8191 , TIME_ID
8192 , PERIOD_TYPE_ID
8193 , CALENDAR_TYPE
8194 , RBS_AGGR_LEVEL
8195 , WBS_ROLLUP_FLAG
8196 , PRG_ROLLUP_FLAG
8197 , CURR_RECORD_TYPE_ID
8198 , CURRENCY_CODE
8199 , RBS_ELEMENT_ID
8200 , RBS_VERSION_ID
8201 , PLAN_VERSION_ID
8202 , PLAN_TYPE_ID
8203 , RAW_COST
8204 , BRDN_COST
8205 , REVENUE
8206 , BILL_RAW_COST
8207 , BILL_BRDN_COST
8208 , BILL_LABOR_RAW_COST
8209 , BILL_LABOR_BRDN_COST
8210 , BILL_LABOR_HRS
8211 , EQUIPMENT_RAW_COST
8212 , EQUIPMENT_BRDN_COST
8213 , CAPITALIZABLE_RAW_COST
8214 , CAPITALIZABLE_BRDN_COST
8215 , LABOR_RAW_COST
8216 , LABOR_BRDN_COST
8217 , LABOR_HRS
8218 , LABOR_REVENUE
8219 , EQUIPMENT_HOURS
8220 , BILLABLE_EQUIPMENT_HOURS
8221 , SUP_INV_COMMITTED_COST
8222 , PO_COMMITTED_COST
8223 , PR_COMMITTED_COST
8224 , OTH_COMMITTED_COST
8225 , ACT_LABOR_HRS
8226 , ACT_EQUIP_HRS
8227 , ACT_LABOR_BRDN_COST
8228 , ACT_EQUIP_BRDN_COST
8229 , ACT_BRDN_COST
8230 , ACT_RAW_COST
8231 , ACT_REVENUE
8232 , ACT_LABOR_RAW_COST
8233 , ACT_EQUIP_RAW_COST
8234 , ETC_LABOR_HRS
8235 , ETC_EQUIP_HRS
8236 , ETC_LABOR_BRDN_COST
8237 , ETC_EQUIP_BRDN_COST
8238 , ETC_BRDN_COST
8239 , ETC_RAW_COST
8240 , ETC_LABOR_RAW_COST
8241 , ETC_EQUIP_RAW_COST
8242 , CUSTOM1
8243 , CUSTOM2
8244 , CUSTOM3
8245 , CUSTOM4
8246 , CUSTOM5
8247 , CUSTOM6
8248 , CUSTOM7
8249 , CUSTOM8
8250 , CUSTOM9
8251 , CUSTOM10
8252 , CUSTOM11
8253 , CUSTOM12
8254 , CUSTOM13
8255 , CUSTOM14
8256 , CUSTOM15
8257 , LINE_TYPE
8258 , PRG_LEVEL
8259 , PLAN_TYPE_CODE /*4471527 */
8260 )
8261 SELECT /*+ parallel(fact1) */ /* Added for bug 13030627 */
8262 g_worker_id WORKER_ID
8263 , fact1.PROJECT_ID
8264 , fact1.PROJECT_ORG_ID
8265 , fact1.PROJECT_ORGANIZATION_ID
8266 , fact1.project_element_id
8267 , fact1.TIME_ID
8268 , fact1.PERIOD_TYPE_ID
8269 , fact1.CALENDAR_TYPE
8270 , g_top_level
8271 , fact1.WBS_ROLLUP_FLAG
8272 , fact1.PRG_ROLLUP_FLAG
8273 , fact1.CURR_RECORD_TYPE_ID
8274 , fact1.CURRENCY_CODE
8275 , -1
8276 , -1
8277 , fact1.PLAN_VERSION_ID
8278 , fact1.PLAN_TYPE_ID
8279 , SUM(fact1.RAW_COST)
8280 , SUM(fact1.BRDN_COST)
8281 , SUM(fact1.REVENUE)
8282 , SUM(fact1.BILL_RAW_COST)
8283 , SUM(fact1.BILL_BRDN_COST )
8284 , SUM(fact1.BILL_LABOR_RAW_COST)
8285 , SUM(fact1.BILL_LABOR_BRDN_COST )
8286 , SUM(fact1.BILL_LABOR_HRS )
8287 , SUM(fact1.EQUIPMENT_RAW_COST )
8288 , SUM(fact1.EQUIPMENT_BRDN_COST )
8289 , SUM(fact1.CAPITALIZABLE_RAW_COST )
8290 , SUM(fact1.CAPITALIZABLE_BRDN_COST )
8291 , SUM(fact1.LABOR_RAW_COST )
8292 , SUM(fact1.LABOR_BRDN_COST )
8293 , SUM(fact1.LABOR_HRS)
8294 , SUM(fact1.LABOR_REVENUE)
8295 , SUM(fact1.EQUIPMENT_HOURS)
8296 , SUM(fact1.BILLABLE_EQUIPMENT_HOURS)
8297 , SUM(fact1.SUP_INV_COMMITTED_COST)
8298 , SUM(fact1.PO_COMMITTED_COST )
8299 , SUM(fact1.PR_COMMITTED_COST )
8300 , SUM(fact1.OTH_COMMITTED_COST)
8301 , SUM(fact1.ACT_LABOR_HRS)
8302 , SUM(fact1.ACT_EQUIP_HRS)
8303 , SUM(fact1.ACT_LABOR_BRDN_COST)
8304 , SUM(fact1.ACT_EQUIP_BRDN_COST)
8305 , SUM(fact1.ACT_BRDN_COST)
8306 , SUM(fact1.ACT_RAW_COST)
8307 , SUM(fact1.ACT_REVENUE)
8308 , SUM(fact1.ACT_LABOR_RAW_COST)
8309 , SUM(fact1.ACT_EQUIP_RAW_COST)
8310 , SUM(fact1.ETC_LABOR_HRS)
8311 , SUM(fact1.ETC_EQUIP_HRS)
8312 , SUM(fact1.ETC_LABOR_BRDN_COST)
8313 , SUM(fact1.ETC_EQUIP_BRDN_COST)
8314 , SUM(fact1.ETC_BRDN_COST )
8315 , SUM(fact1.ETC_RAW_COST )
8316 , SUM(fact1.ETC_LABOR_RAW_COST)
8317 , SUM(fact1.ETC_EQUIP_RAW_COST)
8318 , SUM(fact1.CUSTOM1 )
8319 , SUM(fact1.CUSTOM2 )
8320 , SUM(fact1.CUSTOM3 )
8321 , SUM(fact1.CUSTOM4 )
8322 , SUM(fact1.CUSTOM5 )
8323 , SUM(fact1.CUSTOM6 )
8324 , SUM(fact1.CUSTOM7 )
8325 , SUM(fact1.CUSTOM8 )
8326 , SUM(fact1.CUSTOM9 )
8327 , SUM(fact1.CUSTOM10 )
8328 , SUM(fact1.CUSTOM11 )
8329 , SUM(fact1.CUSTOM12 )
8330 , SUM(fact1.CUSTOM13 )
8331 , SUM(fact1.CUSTOM14 )
8332 , SUM(fact1.CUSTOM15 )
8333 , fact1.line_type
8334 , g_default_prg_level
8335 , fact1.plan_type_code
8336 FROM pji_fp_aggr_pjp1 fact1
8337 , pji_fm_extr_plnver4 ver3
8338 WHERE
8339 fact1.RBS_AGGR_LEVEL = g_lowest_level
8340 AND fact1.worker_id = g_worker_id
8341 AND ver3.worker_id = g_worker_id
8342 AND fact1.plan_version_id = ver3.plan_version_id
8343 AND fact1.plan_type_code = ver3.plan_type_code /*4471527 */
8344 AND ( fact1.rbs_version_id = ver3.rbs_struct_version_id
8345 OR fact1.rbs_version_id = -1)
8346 AND ver3.secondary_rbs_flag = 'N'
8347 GROUP BY
8348 fact1.PROJECT_ID
8349 , fact1.PROJECT_ORG_ID
8350 , fact1.PROJECT_ORGANIZATION_ID
8351 , fact1.project_element_id
8352 , fact1.TIME_ID
8353 , fact1.PERIOD_TYPE_ID
8354 , fact1.CALENDAR_TYPE
8355 , fact1.WBS_ROLLUP_FLAG
8356 , fact1.PRG_ROLLUP_FLAG
8357 , fact1.CURR_RECORD_TYPE_ID
8358 , fact1.CURRENCY_CODE
8359 , fact1.RBS_VERSION_ID
8360 , fact1.PLAN_VERSION_ID
8361 , fact1.PLAN_TYPE_ID
8362 , fact1.line_type
8363 , fact1.plan_type_code; /*4471527 */
8364
8365 end if; /* Added for bug 11843459 */
8366
8367 EXCEPTION
8368 WHEN OTHERS THEN
8369 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8370 p_procedure_name => 'ROLLUP_FPR_RBS_T_SLICE');
8371 RAISE;
8372 END;
8373
8374
8375 PROCEDURE COMPUTE_XBS_UPDATED_ROLLUPS IS
8376 BEGIN
8377 NULL;
8378 EXCEPTION
8379 WHEN OTHERS THEN
8380 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8381 p_procedure_name => 'COMPUTE_XBS_UPDATED_ROLLUPS');
8382 RAISE;
8383 END;
8384
8385
8386 PROCEDURE POPULATE_RBS_HDR IS
8387
8388 l_last_update_date date := SYSDATE;
8389 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
8390 l_creation_date date := SYSDATE;
8391 l_created_by NUMBER := FND_GLOBAL.USER_ID;
8392 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
8393
8394 BEGIN
8395
8396 /* Added for bug 13030627 */
8397 if PJI_UTILS.GET_PARAMETER('PJP_SIN_PRG') = 'Y' then
8398
8399 PJI_PJP_PRG_PERF_ALL.POPULATE_RBS_HDR;
8400
8401 else
8402
8403
8404 print_time ( ' Before update rbs header ' );
8405
8406 INSERT INTO pji_pjp_rbs_header
8407 (
8408 project_id
8409 , plan_version_id
8410 , rbs_version_id
8411 , reporting_usage_flag
8412 , prog_rep_usage_flag
8413 , plan_usage_flag
8414 , LAST_UPDATE_DATE
8415 , LAST_UPDATED_BY
8416 , CREATION_DATE
8417 , CREATED_BY
8418 , LAST_UPDATE_LOGIN
8419 ,PLAN_TYPE_CODE /*4471527 */
8420 )
8421 SELECT /*+ ordered */ DISTINCT
8422 rpa.project_id
8423 , bv.plan_version_id
8424 , rpa.rbs_version_id
8425 , rpa.reporting_usage_flag
8426 , rpa.prog_rep_usage_flag
8427 , DECODE(bv.wp_flag, 'Y', rpa.wp_usage_flag, rpa.fp_usage_flag)
8428 , l_last_update_date
8429 , l_last_updated_by
8430 , l_creation_date
8431 , l_created_by
8432 , l_last_update_login
8433 , bv.plan_type_code
8434 FROM
8435 PJI_FM_EXTR_PLNVER4 bv,
8436 PA_RBS_PRJ_ASSIGNMENTS rpa,
8437 PJI_PJP_RBS_HEADER head
8438 WHERE bv.project_id = rpa.project_id
8439 AND bv.worker_id = g_worker_id
8440 AND bv.RBS_STRUCT_VERSION_ID = rpa.RBS_VERSION_ID
8441 AND bv.PROJECT_ID = head.PROJECT_ID (+)
8442 AND bv.PLAN_VERSION_ID = head.PLAN_VERSION_ID (+)
8443 AND bv.PLAN_TYPE_CODE = head.PLAN_TYPE_CODE (+) /*4471527 */
8444 AND bv.RBS_STRUCT_VERSION_ID = head.RBS_VERSION_ID (+)
8445 AND head.PROJECT_ID IS NULL;
8446
8447 print_time ( ' After update rbs header, # rows inserted is.. '|| SQL%ROWCOUNT );
8448
8449 end if;
8450
8451 EXCEPTION
8452 WHEN OTHERS THEN
8453 print_time ( ' update rbs header exception ' || sqlerrm );
8454 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8455 p_procedure_name => 'POPULATE_RBS_HDR');
8456 RAISE;
8457 END;
8458
8459
8460 PROCEDURE POPULATE_WBS_HDR IS
8461
8462 l_last_update_date date := SYSDATE;
8463 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
8464 l_creation_date date := SYSDATE;
8465 l_created_by NUMBER := FND_GLOBAL.USER_ID;
8466 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
8467
8468 BEGIN
8469
8470 print_time ( ' Before populate wbs header ' );
8471
8472 INSERT INTO PJI_PJP_WBS_HEADER
8473 (
8474 PROJECT_ID
8475 , PLAN_VERSION_ID
8476 , WBS_VERSION_ID
8477 , WP_FLAG
8478 , CB_FLAG
8479 , CO_FLAG
8480 , LOCK_FLAG
8481 , PLAN_TYPE_ID
8482 , MIN_TXN_DATE
8483 , MAX_TXN_DATE
8484 , LAST_UPDATE_DATE
8485 , LAST_UPDATED_BY
8486 , CREATION_DATE
8487 , CREATED_BY
8488 , LAST_UPDATE_LOGIN
8489 , PLAN_TYPE_CODE /* 4471527 */
8490 )
8491 SELECT /*+ ordered */ DISTINCT -- Added for bug 13897252
8492 ver.project_id
8493 , ver.plan_version_id
8494 , ver.wbs_struct_version_id
8495 , ver.wp_flag
8496 , DECODE( (ver.current_flag || ver.baselined_flag) , 'YY', 'Y', 'N')
8497 , ver.current_original_flag
8498 , null
8499 , ver.plan_type_id
8500 , to_date('3000/01/01', 'YYYY/MM/DD') MIN_TXN_DATE
8501 , to_date('0001/01/01', 'YYYY/MM/DD') MAX_TXN_DATE
8502 , l_last_update_date
8503 , l_last_updated_by
8504 , l_creation_date
8505 , l_created_by
8506 , l_last_update_login
8507 , ver.plan_type_code
8508 FROM PJI_FM_EXTR_PLNVER4 ver
8509 , PJI_PJP_WBS_HEADER whdr
8510 WHERE ver.worker_id = g_worker_id
8511 AND ver.plan_version_id = whdr.plan_version_id (+)
8512 AND ver.plan_type_code = whdr.plan_type_code(+) /*4471527 */
8513 AND ver.project_id = whdr.project_id (+)
8514 AND ver.plan_type_id = whdr.plan_type_id (+)
8515 -- AND ver.wbs_struct_version_id = whdr.wbs_version_id (+)
8516 AND whdr.plan_version_id IS NULL
8517 AND ver.plan_version_id <> -1
8518 ORDER BY
8519 ver.project_id
8520 , ver.plan_version_id;
8521
8522 print_time ( ' After populate wbs header ' );
8523
8524 EXCEPTION
8525 WHEN OTHERS THEN
8526 print_time ( ' Populate wbs header exception ' || sqlerrm );
8527 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8528 p_procedure_name => 'POPULATE_WBS_HDR');
8529 RAISE;
8530 END;
8531
8532
8533
8534 PROCEDURE UPDATE_WBS_HDR IS
8535 -- pragma autonomous_transaction; /* Commented for Bug 14735308 */
8536 l_last_update_date date := SYSDATE;
8537 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
8538 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
8539
8540 BEGIN
8541
8542 /* Added for bug 13030627 */
8543 if PJI_UTILS.GET_PARAMETER('PJP_SIN_PRG') = 'Y' then
8544
8545 PJI_PJP_PRG_PERF_ALL.UPDATE_WBS_HDR;
8546
8547 else
8548
8549 print_time ( ' Before update wbs header ' );
8550
8551 delete from pji_fp_aggr_pjp1_t; -- 5309891
8552 -- commit; /* Commented for Bug 14735308 */
8553 INSERT INTO pji_fp_aggr_pjp1_t
8554 ( WORKER_ID
8555 , PROJECT_ID, PROJECT_ORG_ID, PROJECT_ORGANIZATION_ID, PROJECT_ELEMENT_ID
8556 , TIME_ID, PERIOD_TYPE_ID, CALENDAR_TYPE, RBS_AGGR_LEVEL
8557 , WBS_ROLLUP_FLAG, PRG_ROLLUP_FLAG , CURR_RECORD_TYPE_ID ,CURRENCY_CODE
8558 , PLAN_VERSION_ID, PLAN_TYPE_ID, PLAN_TYPE_CODE
8559 , start_date, end_date)
8560 SELECT g_worker_id
8561 , whdr.project_id, 0, 0, 0
8562 , 0, 0, 'X', 'X'
8563 , 'X', 'X', 0, 'X'
8564 , whdr.plan_version_id, NVL(whdr.plan_type_id, -1)
8565 , whdr.PLAN_TYPE_CODE
8566 , MIN(LEAST(cal.start_date, NVL(whdr.min_txn_date, cal.start_date))) start_date
8567 , MAX(GREATEST(cal.end_date, NVL(whdr.max_txn_date, cal.end_date))) end_date
8568 FROM PJI_FP_AGGR_PJP1 pjp1
8569 , pji_time_cal_period_v cal
8570 , pji_pjp_wbs_header whdr
8571 WHERE
8572 pjp1.worker_id = g_worker_id
8573 AND pjp1.project_id = whdr.project_id
8574 AND pjp1.plan_type_id = NVL(whdr.plan_type_id, -1)
8575 AND pjp1.plan_version_id = whdr.plan_version_id
8576 AND pjp1.time_id = cal.cal_period_id
8577 AND pjp1.calendar_type IN ('P', 'G') -- Non time ph and ent cals don't need to be considered.
8578 AND pjp1.plan_type_code = whdr.plan_type_code
8579 GROUP BY whdr.project_id, whdr.plan_type_id
8580 , whdr.plan_version_id, whdr.plan_type_code;
8581 -- commit; /* Commented for Bug 14735308 */
8582 UPDATE /*+ index(whdr,PJI_PJP_WBS_HEADER_N1) */
8583 PJI_PJP_WBS_HEADER whdr
8584 SET ( MIN_TXN_DATE
8585 , MAX_TXN_DATE
8586 , LAST_UPDATE_DATE
8587 , LAST_UPDATED_BY
8588 , LAST_UPDATE_LOGIN ) = (
8589 SELECT start_date
8590 , end_date
8591 , l_last_update_date
8592 , l_last_updated_by
8593 , l_last_update_login
8594 FROM pji_fp_aggr_pjp1_t dates
8595 WHERE
8596 dates.plan_version_id = whdr.plan_version_id
8597 AND dates.project_id = whdr.project_id
8598 AND dates.plan_type_id = NVL(whdr.plan_type_id, -1)
8599 AND dates.plan_type_code = whdr.plan_type_code
8600 )
8601 WHERE (project_id, NVL(plan_type_id, -1), plan_version_id, plan_type_code) IN (
8602 SELECT project_id, plan_type_id, plan_version_id , plan_type_code
8603 FROM PJI_FP_AGGR_PJP1_T ver
8604 );
8605 -- commit; /* Commented for Bug 14735308 */
8606 delete from pji_fp_aggr_pjp1_t;
8607 -- commit; /* Commented for Bug 14735308 */
8608
8609 print_time ( ' After update wbs header ' );
8610
8611 end if;
8612
8613 EXCEPTION
8614 WHEN OTHERS THEN
8615 print_time ( ' update wbs header exception ' || sqlerrm );
8616 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8617 p_procedure_name => 'POPULATE_WBS_HDR');
8618 RAISE;
8619 END;
8620
8621
8622
8623
8624 PROCEDURE MARK_EXTRACTED_PLANS(p_slice_type IN VARCHAR2) IS
8625 -- Added for bug 9108728
8626 l_up_process_flag varchar2(1);
8627
8628 BEGIN
8629
8630 -- Added for bug 9108728
8631 l_up_process_flag := PJI_UTILS.GET_SETUP_PARAMETER('UP_PROCESS_FLAG');
8632 --
8633 -- On PA_BUDGET_VERSIONS, the PJI_SUMMARIZED_FLAG can have four values:
8634 -- 'N' the plan version has not been summarized
8635 -- 'P' the plan version has been partially summarized due to dangling currency or calendar records
8636 -- 'Y' the plan version has been fully summarized in Project Performance and
8637 -- NULL the plan version has been fully summarized in both PJI and Project Performance.
8638 --
8639 -- Note that, in PJI data extraction, data that existed before PJI was installed
8640 -- has PJI_SUMMARIZED_FLAG = null and new transactions are inserted with value 'N'.
8641 -- A similar situation does not occur in PA_BUDGET_VERSIONS. During the upgrade process
8642 -- will pull necessary data from PA_BUDGET_VERSIONS and set PJI_SUMMARIZATION_FLAG to 'P', 'N'
8643 -- or 'Y' accordingly. New versions will be inserted with value 'N'.)
8644 --
8645
8646 IF (p_slice_type = 'PRI') THEN
8647 -- Added for bug 9108728
8648 if l_up_process_flag = 'Y' then
8649
8650 UPDATE /*+ index(bv,pa_budget_versions_u1) */
8651 pa_budget_versions bv
8652 SET pji_summarized_flag = 'P',
8653 record_version_number=nvl(record_version_number,0)+1
8654 WHERE budget_version_id IN
8655 ( SELECT DISTINCT plan_version_id
8656 FROM pji_fm_extr_plnver4
8657 WHERE worker_id = g_worker_id )
8658 AND (bv.current_flag = 'Y' or bv.current_original_flag = 'Y')
8659 AND nvl(bv.wp_version_flag,'Y') = 'N';
8660
8661 UPDATE /*+ index(bv,pa_budget_versions_u1) */
8662 pa_budget_versions bv
8663 SET pji_summarized_flag = 'Y',
8664 record_version_number=nvl(record_version_number,0)+1
8665 WHERE budget_version_id IN
8666 ( SELECT DISTINCT plan_version_id
8667 FROM pji_fm_extr_plnver4
8668 WHERE worker_id = g_worker_id )
8669 AND bv.current_flag = 'N'
8670 AND bv.current_original_flag = 'N';
8671
8672 else
8673 -- Added for bug 9108728 ends
8674
8675 UPDATE /*+ index(bv,pa_budget_versions_u1) */
8676 pa_budget_versions bv
8677 SET pji_summarized_flag =
8678 DECODE(wp_version_flag
8679 , 'Y', 'Y'
8680 , DECODE(budget_status_code
8681 , 'B', 'P'
8682 , 'Y')
8683 ),
8684 record_version_number=nvl(record_version_number,0)+1
8685 WHERE budget_version_id IN
8686 ( SELECT DISTINCT plan_version_id
8687 FROM pji_fm_extr_plnver4
8688 WHERE worker_id = g_worker_id );
8689
8690 end if; -- Added for bug 9108728
8691 ELSE -- Secondary slice.
8692
8693 /* Added for bug 13897252 starts */
8694 UPDATE PJI_FM_EXTR_PLNVER4 ver3
8695 SET time_dangling_flag = 'Y'
8696 WHERE ver3.worker_id = g_worker_id
8697 AND EXISTS (SELECT /*+ index (pjp1, PJI_FP_AGGR_PJP1_N5) */ NULL
8698 FROM pji_fp_aggr_pjp1 pjp1
8699 WHERE pjp1.worker_id = g_worker_id
8700 AND ver3.project_id = pjp1.project_id
8701 AND ver3.plan_version_id = pjp1.plan_version_id
8702 AND ver3.plan_type_code = pjp1.plan_type_code
8703 AND ( pjp1.time_dangling_flag IS NOT NULL
8704 OR pjp1.rate_dangling_flag IS NOT NULL )
8705 );
8706 /* Added for bug 13897252 ends */
8707
8708 UPDATE /*+ index( bv , pa_budget_versions_u1 ) */
8709 pa_budget_versions bv
8710 SET pji_summarized_flag = 'Y',
8711 record_version_number=nvl(record_version_number,0)+1
8712 WHERE budget_version_id IN (SELECT plan_version_id
8713 FROM PJI_FM_EXTR_PLNVER4 ver3
8714 WHERE ver3.worker_id=g_worker_id
8715 AND ver3.time_dangling_flag IS NULL);
8716
8717 UPDATE /*+ index( bv , pa_budget_versions_u1 ) */
8718 pa_budget_versions bv
8719 SET pji_summarized_flag = 'P',
8720 record_version_number=nvl(record_version_number,0)+1
8721 WHERE budget_version_id IN (SELECT plan_version_id
8722 FROM PJI_FM_EXTR_PLNVER4 ver3
8723 WHERE ver3.worker_id=g_worker_id
8724 AND ver3.time_dangling_flag IS NOT NULL);
8725
8726 END IF;
8727
8728 EXCEPTION
8729 WHEN OTHERS THEN
8730 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8731 p_procedure_name => 'MARK_EXTRACTED_PLANS');
8732 RAISE;
8733 END;
8734
8735
8736 ------------------------------------------------------------------------------
8737 ---- WBS rollup api..
8738 ------------------------------------------------------------------------------
8739
8740 PROCEDURE CREATE_WBSRLP IS
8741 BEGIN
8742
8743 print_time('... Begin CREATE_WBSRLP ' );
8744
8745 PRINT_NUM_WBSRLPRCDS_INPJP1;
8746
8747 print_time('... Before call to rollup_fpr_wbs...' );
8748
8749 PJI_PJP_SUM_ROLLUP.ROLLUP_FPR_WBS(g_worker_id); /*Added for 3852901*/
8750
8751 print_time('... after call to rollup_fpr_wbs. ' );
8752
8753 PRINT_NUM_WBSRLPRCDS_INPJP1;
8754
8755 print_time('... End CREATE_WBSRLP ' );
8756
8757 EXCEPTION
8758 WHEN OTHERS THEN
8759 print_time('... Exception CREATE_WBSRLP ' );
8760 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8761 p_procedure_name => 'CREATE_WBSRLP');
8762 RAISE;
8763 END;
8764
8765
8766
8767 PROCEDURE PRINT_NUM_WBSRLPRCDS_INPJP1 IS
8768 l_count NUMBER;
8769 l_wbs_rollup_flag VARCHAR2(1);
8770 l_prg_rollup_flag VARCHAR2(1);
8771 l_return_status VARCHAR2(1);
8772
8773 BEGIN
8774
8775 l_wbs_rollup_flag := 'N';
8776 l_prg_rollup_flag := 'N';
8777
8778 /*
8779 select count(1)
8780 INTO l_count
8781 FROM pji_fp_aggr_pjp1
8782 WHERE wbs_rollup_flag = l_wbs_rollup_flag
8783 AND prg_rollup_flag = l_prg_rollup_flag;
8784
8785 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);
8786
8787
8788 l_wbs_rollup_flag := 'N';
8789 l_prg_rollup_flag := 'Y';
8790
8791 select count(1)
8792 INTO l_count
8793 FROM pji_fp_aggr_pjp1
8794 WHERE wbs_rollup_flag = l_wbs_rollup_flag
8795 AND prg_rollup_flag = l_prg_rollup_flag;
8796
8797 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);
8798
8799
8800 l_wbs_rollup_flag := 'Y';
8801 l_prg_rollup_flag := 'N';
8802
8803 select count(1)
8804 INTO l_count
8805 FROM pji_fp_aggr_pjp1
8806 WHERE wbs_rollup_flag = l_wbs_rollup_flag
8807 AND prg_rollup_flag = l_prg_rollup_flag;
8808
8809 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);
8810
8811
8812 l_wbs_rollup_flag := 'Y';
8813 l_prg_rollup_flag := 'Y';
8814
8815 select count(1)
8816 INTO l_count
8817 FROM pji_fp_aggr_pjp1
8818 WHERE wbs_rollup_flag = l_wbs_rollup_flag
8819 AND prg_rollup_flag = l_prg_rollup_flag;
8820
8821 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);
8822 */
8823
8824 EXCEPTION
8825 WHEN OTHERS THEN
8826 PJI_PJP_FP_CURR_WRAP.EXCP_HANDLER
8827 ( p_package_name => g_package_name
8828 , p_procedure_name => 'PRINT_NUM_WBSRLPRCDS_INPJP1'
8829 , x_return_status => l_return_status ) ;
8830
8831 RAISE;
8832 END;
8833
8834
8835 PROCEDURE CLEANUP_INTERIM_TABLES IS
8836 l_count NUMBER;
8837 BEGIN
8838
8839 print_time('.......CLEANUP_INTERIM_TABLES: Begin. ');
8840
8841 DELETE FROM PJI_FM_EXTR_PLNVER4
8842 WHERE worker_id = g_worker_id ;
8843
8844 print_time('.......ver3 rows deleted: #= ' || sql%rowcount);
8845
8846 DELETE FROM pji_fp_aggr_pjp1
8847 WHERE worker_id = g_worker_id;
8848
8849 print_time('.......pjp1 rows deleted: #= ' || sql%rowcount);
8850
8851 print_time('.......CLEANUP_INTERIM_TABLES: End. ');
8852
8853 EXCEPTION
8854 WHEN OTHERS THEN
8855 print_time('.......CLEANUP_INTERIM_TABLES: Exception. ' || sqlerrm);
8856 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8857 p_procedure_name => 'CLEANUP_INTERIM_TABLES');
8858 RAISE;
8859 END CLEANUP_INTERIM_TABLES;
8860
8861
8862 ----------
8863 -- Print time API to measure time taken by each api. Also useful for debugging.
8864 ----------
8865 PROCEDURE PRINT_TIME(p_tag IN VARCHAR2) IS
8866 BEGIN
8867 PJI_PJP_FP_CURR_WRAP.print_time(p_tag);
8868 EXCEPTION
8869 WHEN OTHERS THEN
8870 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
8871 p_procedure_name => 'PRINT_TIME');
8872 RAISE;
8873 END;
8874
8875 PROCEDURE EXTRACT_PLAN_AMTS_SECRBS_GLC12 (
8876 p_pull_dangling_flag IN VARCHAR2 := 'Y') -- Reversals to be computed only if pull_dangling flag is 'Y'
8877 IS
8878 BEGIN
8879
8880 print_time ( ' EXTRACT_PLAN_AMTS_SECRBS_GLC12 begin. ' );
8881
8882 PJI_PJP_FP_CURR_WRAP.get_global_currency_info (
8883 x_currency_conversion_rule => g_currency_conversion_rule
8884 , x_prorating_format => g_prorating_format
8885 , x_global1_currency_code => g_global1_currency_code
8886 , x_global2_currency_code => g_global2_currency_code
8887 , x_global1_currency_mau => g_global1_currency_mau
8888 , x_global2_currency_mau => g_global2_currency_mau ) ;
8889
8890
8891 print_time(' Got global currency settings. ');
8892 print_time(' g_currency_conversion_rule ' || g_currency_conversion_rule || ' g_prorating_format ' || g_prorating_format );
8893 print_time(' g_global1_currency_code ' || g_global1_currency_code || ' g_global2_currency_code ' || g_global2_currency_code );
8894 print_time(' g_global1_currency_mau ' || g_global1_currency_mau || ' g_global2_currency_mau ' || g_global2_currency_mau ) ;
8895
8896 -- cbs change
8897 IF P_PA_DEBUG_MODE = 'Y' THEN
8898 pa_debug.write('EXTRACT_PLAN_AMTS_SECRBS_GLC12: ' || g_module_name,'Before calling SET_RES_CLASS_FLAG' ,1);
8899 END IF;
8900
8901 SET_RES_CLASS_FLAG;
8902
8903 IF P_PA_DEBUG_MODE = 'Y' THEN
8904 pa_debug.write('EXTRACT_PLAN_AMTS_SECRBS_GLC12: ' || g_module_name,'After calling SET_RES_CLASS_FLAG' ,1);
8905 END IF;
8906
8907 -- End cbs change
8908
8909 INSERT INTO PJI_FP_AGGR_PJP1
8910 (
8911 WORKER_ID
8912 , PROJECT_ID
8913 , PROJECT_ORG_ID
8914 , PROJECT_ORGANIZATION_ID
8915 , PROJECT_ELEMENT_ID
8916 , TIME_ID
8917 , PERIOD_TYPE_ID
8918 , CALENDAR_TYPE
8919 , RBS_AGGR_LEVEL
8920 , WBS_ROLLUP_FLAG
8921 , PRG_ROLLUP_FLAG
8922 , CURR_RECORD_TYPE_ID
8923 , CURRENCY_CODE
8924 , RBS_ELEMENT_ID
8925 , RBS_VERSION_ID
8926 , PLAN_VERSION_ID
8927 , PLAN_TYPE_ID
8928 , RAW_COST
8929 , BRDN_COST
8930 , REVENUE
8931 , BILL_RAW_COST
8932 , BILL_BRDN_COST
8933 , BILL_LABOR_RAW_COST
8934 , BILL_LABOR_BRDN_COST
8935 , BILL_LABOR_HRS
8936 , EQUIPMENT_RAW_COST
8937 , EQUIPMENT_BRDN_COST
8938 , CAPITALIZABLE_RAW_COST
8939 , CAPITALIZABLE_BRDN_COST
8940 , LABOR_RAW_COST
8941 , LABOR_BRDN_COST
8942 , LABOR_HRS
8943 , LABOR_REVENUE
8944 , EQUIPMENT_HOURS
8945 , BILLABLE_EQUIPMENT_HOURS
8946 , SUP_INV_COMMITTED_COST
8947 , PO_COMMITTED_COST
8948 , PR_COMMITTED_COST
8949 , OTH_COMMITTED_COST
8950 , ACT_LABOR_HRS
8951 , ACT_EQUIP_HRS
8952 , ACT_LABOR_BRDN_COST
8953 , ACT_EQUIP_BRDN_COST
8954 , ACT_BRDN_COST
8955 , ACT_RAW_COST
8956 , ACT_REVENUE
8957 , ACT_LABOR_RAW_COST
8958 , ACT_EQUIP_RAW_COST
8959 , ETC_LABOR_HRS
8960 , ETC_EQUIP_HRS
8961 , ETC_LABOR_BRDN_COST
8962 , ETC_EQUIP_BRDN_COST
8963 , ETC_BRDN_COST
8964 , ETC_RAW_COST
8965 , ETC_LABOR_RAW_COST
8966 , ETC_EQUIP_RAW_COST
8967 , CUSTOM1
8968 , CUSTOM2
8969 , CUSTOM3
8970 , CUSTOM4
8971 , CUSTOM5
8972 , CUSTOM6
8973 , CUSTOM7
8974 , CUSTOM8
8975 , CUSTOM9
8976 , CUSTOM10
8977 , CUSTOM11
8978 , CUSTOM12
8979 , CUSTOM13
8980 , CUSTOM14
8981 , CUSTOM15
8982 , LINE_TYPE
8983 , RATE_DANGLING_FLAG
8984 , TIME_DANGLING_FLAG
8985 , START_DATE
8986 , END_DATE
8987 , PRG_LEVEL
8988 ,PLAN_TYPE_CODE /*4471527 */
8989 )
8990 SELECT
8991 WORKER_ID
8992 , PROJECT_ID
8993 , PROJECT_ORG_ID
8994 , project_ORGANIZATION_ID
8995 , WBS_ELEMENT_ID
8996 , time_id
8997 , period_type_id
8998 , CALENDAR_TYPE
8999 , g_lowest_level RBS_AGGR_LEVEL
9000 , 'N' WBS_ROLLUP_FLAG
9001 , 'N' PRG_ROLLUP_FLAG
9002 , CURR_RECORD_TYPE
9003 , currency_code
9004 , RBS_ELEMENT_ID
9005 , RBS_STRUCT_VERSION_ID
9006 , plan_version_id
9007 , plan_type_id
9008 , decode(rate_dangling_flag,null,SUM(RAW_COST),0)
9009 , decode(rate_dangling_flag,null,SUM(BRDN_COST),0)
9010 , decode(rate_dangling_flag,null,SUM(REVENUE),0)
9011 , decode(rate_dangling_flag,null,SUM ( BILL_RAW_COST ),0) BILL_RAW_COST
9012 , decode(rate_dangling_flag,null,SUM (BILL_BRDN_COST ),0) BILL_BRDN_COST
9013 , decode(rate_dangling_flag,null,SUM ( BILL_LABOR_RAW_COST),0) BILL_LABOR_RAW_COST
9014 , decode(rate_dangling_flag,null,SUM ( BILL_LABOR_BRDN_COST),0) BILL_LABOR_BRDN_COST
9015 , decode(rate_dangling_flag,null,SUM ( BILL_LABOR_HRS),0) BILL_LABOR_HRS
9016 , decode(rate_dangling_flag,null,SUM ( EQUIPMENT_RAW_COST),0) EQUIPMENT_RAW_COST
9017 , decode(rate_dangling_flag,null,SUM ( EQUIPMENT_BRDN_COST),0) EQUIPMENT_BRDN_COST
9018 , decode(rate_dangling_flag,null,SUM (CAPITALIZABLE_RAW_COST),0) CAPITALIZABLE_RAW_COST
9019 , decode(rate_dangling_flag,null,SUM ( CAPITALIZABLE_BRDN_COST),0)
9020 , decode(rate_dangling_flag,null,SUM ( LABOR_RAW_COST),0) LABOR_RAW_COST
9021 , decode(rate_dangling_flag,null,SUM ( LABOR_BRDN_COST),0) LABOR_BRDN_COST
9022 , decode(rate_dangling_flag,null,SUM ( labor_hrs),0) labor_hrs
9023 , decode(rate_dangling_flag,null,SUM (LABOR_REVENUE),0) LABOR_REVENUE
9024 , decode(rate_dangling_flag,null,SUM (EQUIPMENT_HOURS),0) EQUIPMENT_HOURS
9025 , decode(rate_dangling_flag,null,SUM ( BILLABLE_EQUIPMENT_HOURS),0) BILLABLE_EQUIPMENT_HOURS
9026 , decode(rate_dangling_flag,null,SUM(SUP_INV_COMMITTED_COST),0) SUP_INV_COMMITTED_COST
9027 , decode(rate_dangling_flag,null,SUM(PO_COMMITTED_COST),0) PO_COMMITTED_COST
9028 , decode(rate_dangling_flag,null,SUM(PR_COMMITTED_COST),0) PR_COMMITTED_COST
9029 , decode(rate_dangling_flag,null,SUM(OTH_COMMITTED_COST),0) PR_COMMITTED_COST
9030 , decode(rate_dangling_flag,null,SUM ( ACT_LABOR_HRS),0) ACT_LABOR_HRS
9031 , decode(rate_dangling_flag,null,SUM (ACT_EQUIP_HOURS),0) ACT_EQUIP_HOURS
9032 , decode(rate_dangling_flag,null,SUM ( ACT_LABOR_BRDN_COST),0) ACT_LABOR_BRDN_COST
9033 , decode(rate_dangling_flag,null,SUM ( ACT_EQUIPMENT_BRDN_COST),0) ACT_EQUIPMENT_BRDN_COST
9034 , decode(rate_dangling_flag,null,SUM ( ACT_BRDN_COST),0) ACT_BRDN_COST
9035 , decode(rate_dangling_flag,null,SUM ( ACT_RAW_COST),0) ACT_RAW_COST
9036 , decode(rate_dangling_flag,null,SUM ( ACT_REVENUE),0) ACT_REVENUE
9037 , decode(rate_dangling_flag,null,SUM ( ACT_LABOR_RAW_COST),0) ACT_LABOR_RAW_COST
9038 , decode(rate_dangling_flag,null,SUM ( ACT_EQUIPMENT_RAW_COST),0) ACT_EQUIPMENT_RAW_COST
9039 , decode(rate_dangling_flag,null,SUM ( ETC_LABOR_HRS),0) ETC_LABOR_HRS
9040 , decode(rate_dangling_flag,null,SUM ( ETC_EQUIP_HOURS),0) ETC_EQUIP_HOURS
9041 , decode(rate_dangling_flag,null,SUM ( ETC_LABOR_BRDN_COST),0) ETC_LABOR_BRDN_COST
9042 , decode(rate_dangling_flag,null,SUM ( ETC_EQUIP_BRDN_COST),0) ETC_EQUIP_BRDN_COST
9043 , decode(rate_dangling_flag,null,SUM ( ETC_BRDN_COST),0) ETC_BRDN_COST
9044 , decode(rate_dangling_flag,null,SUM ( ETC_RAW_COST),0) ETC_RAW_COST
9045 , decode(rate_dangling_flag,null,SUM ( ETC_LABOR_raw_COST),0) ETC_LABOR_raw_COST
9046 , decode(rate_dangling_flag,null,SUM ( ETC_EQUIP_raw_COST),0) ETC_EQUIP_raw_COST
9047 , decode(rate_dangling_flag,null,SUM(CUSTOM1),0) CUSTOM1
9048 , decode(rate_dangling_flag,null,SUM(CUSTOM2),0) CUSTOM2
9049 , decode(rate_dangling_flag,null,SUM(CUSTOM3),0) CUSTOM3
9050 , decode(rate_dangling_flag,null,SUM(CUSTOM4),0) CUSTOM4
9051 , decode(rate_dangling_flag,null,SUM(CUSTOM5),0) CUSTOM5
9052 , decode(rate_dangling_flag,null,SUM(CUSTOM6),0) CUSTOM6
9053 , decode(rate_dangling_flag,null,SUM(CUSTOM7),0) CUSTOM7
9054 , decode(rate_dangling_flag,null,SUM(CUSTOM8),0) CUSTOM8
9055 , decode(rate_dangling_flag,null,SUM(CUSTOM9),0) CUSTOM9
9056 , decode(rate_dangling_flag,null,SUM(CUSTOM10),0) CUSTOM10
9057 , decode(rate_dangling_flag,null,SUM(CUSTOM11),0) CUSTOM11
9058 , decode(rate_dangling_flag,null,SUM(CUSTOM12),0) CUSTOM12
9059 , decode(rate_dangling_flag,null,SUM(CUSTOM13),0) CUSTOM13
9060 , decode(rate_dangling_flag,null,SUM(CUSTOM14),0) CUSTOM14
9061 , decode(rate_dangling_flag,null,SUM(CUSTOM15),0) CUSTOM15
9062 , LINE_TYPE
9063 , rate_dangling_flag
9064 , time_dangling_flag
9065 , start_date
9066 , end_date
9067 , g_default_prg_level prg_level
9068 ,plan_type_code
9069 FROM
9070 ( SELECT
9071 g_worker_id WORKER_ID
9072 , plr.PROJECT_ID
9073 , plr.PROJECT_ORG_ID
9074 , plr.project_ORGANIZATION_ID
9075 , plr.WBS_ELEMENT_ID
9076 , plr.time_id
9077 , plr.period_type_id -- period type id...
9078 , plr.CALENDAR_TYPE
9079 , g_lowest_level RBS_AGGR_LEVEL
9080 , 'N' WBS_ROLLUP_FLAG
9081 , 'N' PRG_ROLLUP_FLAG
9082 , plr.CURR_RECORD_TYPE
9083 , plr.currency_code
9084 , plr.RBS_ELEMENT_ID
9085 , plr.RBS_STRUCT_VERSION_ID
9086 , plr.plan_version_id
9087 , plr.plan_type_id
9088 , SUM(plr.RAW_COST) RAW_COST
9089 , SUM(plr.BRDN_COST) BRDN_COST
9090 , SUM(plr.REVENUE) REVENUE
9091 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) BILL_RAW_COST
9092 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) BILL_BRDN_COST
9093 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_people_resclass_code, plr.raw_cost, 0 ) ) BILL_LABOR_RAW_COST
9094 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_people_resclass_code , plr.BRDN_COST, 0 ) ) BILL_LABOR_BRDN_COST
9095 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'Y' || g_people_resclass_code, plr.quantity, 0 ) ) BILL_LABOR_HRS */ -- bug 6039785
9096 , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'Y' || g_people_resclass_code,
9097 DECODE ( plr.billable_flag , 'Y' , plr.quantity, 0 ) , 0 ) ) BILL_LABOR_HRS -- bug 6039785
9098 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code , plr.raw_cost, 0 ) ) EQUIPMENT_RAW_COST
9099 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code , plr.BRDN_COST, 0 ) ) EQUIPMENT_BRDN_COST
9100 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) CAPITALIZABLE_RAW_COST
9101 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) CAPITALIZABLE_BRDN_COST
9102 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.raw_cost, 0 ) ) LABOR_RAW_COST
9103 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.BRDN_COST, 0 ) ) LABOR_BRDN_COST
9104 /* , SUM ( DECODE ( plr.resource_class, g_people_resclass_code,
9105 DECODE ( plr.wp_flag, 'N',
9106 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
9107 plr.quantity),
9108 0 ) ) labor_hrs */ -- bug 6039785
9109 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code,
9110 DECODE(plr.billable_flag, 'Y' ,
9111 DECODE ( plr.wp_flag, 'N',
9112 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
9113 plr.quantity),
9114 0 ),
9115 0 ) ) labor_hrs -- bug 6039785
9116 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.revenue, 0 ) ) LABOR_REVENUE
9117 /* , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code,
9118 DECODE ( plr.wp_flag, 'N',
9119 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
9120 plr.quantity),
9121
9122 0 ) ) EQUIPMENT_HOURS */ -- bug 6039785
9123 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code,
9124 DECODE(plr.billable_flag, 'Y' ,
9125 DECODE ( plr.wp_flag, 'N',
9126 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
9127 plr.quantity),
9128 0 ),
9129 0 ) ) EQUIPMENT_HOURS -- bug 6039785
9130 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_equip_resclass_code, plr.quantity, 0 ) ) BILLABLE_EQUIPMENT_HOURS */ -- bug 6039785
9131 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_equip_resclass_code,
9132 DECODE ( plr.billable_flag , 'Y' , plr.quantity, 0 ) , 0 ) ) BILLABLE_EQUIPMENT_HOURS -- bug 6039785
9133 , TO_NUMBER(NULL) SUP_INV_COMMITTED_COST
9134 , TO_NUMBER(NULL) PO_COMMITTED_COST
9135 , TO_NUMBER(NULL) PR_COMMITTED_COST
9136 , TO_NUMBER(NULL) OTH_COMMITTED_COST
9137 /* , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
9138 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
9139 0 ) ) ) ACT_LABOR_HRS */ -- bug 6039785
9140 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
9141 DECODE (plr.billable_flag ,'Y',
9142 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
9143 0 ),
9144 0 ) ) ) ACT_LABOR_HRS -- bug 6039785
9145 /* , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
9146 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
9147 0 ) ) ) ACT_EQUIP_HOURS */ -- bug 6039785
9148 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
9149 DECODE (plr.billable_flag ,'Y',
9150 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
9151 0 ),
9152 0 ) ) ) ACT_EQUIP_HOURS -- bug 6039785
9153 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.actual_BRDN_COST, 0 ) ) ) ACT_LABOR_BRDN_COST
9154 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.actual_BRDN_COST, 0 ) ) ) ACT_EQUIPMENT_BRDN_COST
9155 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, plr.actual_brdn_cost ) ) ACT_BRDN_COST
9156 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, plr.actual_raw_cost ) ) ACT_RAW_COST
9157 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, plr.actual_revenue ) ) ACT_REVENUE
9158 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.actual_RAW_COST, 0 ) ) ) ACT_LABOR_RAW_COST
9159 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.actual_RAW_COST, 0 ) ) ) ACT_EQUIPMENT_RAW_COST
9160 /* , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
9161 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
9162 0 ) ) ) ETC_LABOR_HRS */ -- bug 6039785
9163 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
9164 DECODE (plr.billable_flag ,'Y',
9165 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
9166 0 ),
9167 0 ) ) ) ETC_LABOR_HRS -- bug 6039785
9168 /* , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
9169 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
9170 0 ) ) ) ETC_EQUIP_HOURS */ -- bug 6039785
9171 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
9172 DECODE (plr.billable_flag ,'Y',
9173 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
9174 0 ),
9175 0 ) ) ) ETC_EQUIP_HOURS -- bug 6039785
9176 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.etc_BRDN_COST, 0 ) ) ) ETC_LABOR_BRDN_COST
9177 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.etc_BRDN_COST, 0 ) ) ) ETC_EQUIP_BRDN_COST
9178 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, plr.etc_brdn_cost ) ) ETC_BRDN_COST
9179 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, plr.etc_raw_cost ) ) ETC_RAW_COST
9180 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.etc_raw_COST, 0 ) ) ) ETC_LABOR_raw_COST
9181 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.etc_raw_COST, 0 ) ) ) ETC_EQUIP_raw_COST
9182 , TO_NUMBER(NULL) CUSTOM1
9183 , TO_NUMBER(NULL) CUSTOM2
9184 , TO_NUMBER(NULL) CUSTOM3
9185 , TO_NUMBER(NULL) CUSTOM4
9186 , TO_NUMBER(NULL) CUSTOM5
9187 , TO_NUMBER(NULL) CUSTOM6
9188 , TO_NUMBER(NULL) CUSTOM7
9189 , TO_NUMBER(NULL) CUSTOM8
9190 , TO_NUMBER(NULL) CUSTOM9
9191 , TO_NUMBER(NULL) CUSTOM10
9192 , TO_NUMBER(NULL) CUSTOM11
9193 , TO_NUMBER(NULL) CUSTOM12
9194 , TO_NUMBER(NULL) CUSTOM13
9195 , TO_NUMBER(NULL) CUSTOM14
9196 , TO_NUMBER(NULL) CUSTOM15
9197 , plr.LINE_TYPE
9198 , decode(sign(plr.rate),-1,'Y',NULL) ||decode(sign(plr.rate2),-1,'Y',NULL) rate_dangling_flag
9199 , NULL time_dangling_flag
9200 , plr.start_date
9201 , plr.end_date
9202 , g_default_prg_level prg_level
9203 , plr.plan_type_code PLAN_TYPE_CODE /*4471527 */
9204 FROM
9205 ( ----- First inline view plr .............
9206 select
9207 collapse_bl.PROJECT_ID -- , 1 partition_id
9208 , collapse_bl.WBS_ELEMENT_ID -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
9209 , SUM(collapse_bl.CURR_RECORD_TYPE_ID) CURR_RECORD_TYPE
9210 , collapse_bl.RBS_ELEMENT_ID
9211 , collapse_bl.RBS_STRUCT_VERSION_ID
9212 , collapse_bl.plan_type_id
9213 , collapse_bl.plan_version_id
9214 , collapse_bl.time_id
9215 , collapse_bl.PROJECT_ORGANIZATION_ID
9216 , collapse_bl.PROJECT_ORG_ID
9217 , collapse_bl.RESOURCE_ASSIGNMENT_ID
9218 , collapse_bl.BILLABLE_FLAG
9219 , collapse_bl.RESOURCE_CLASS -- , CALENDAR_TYPE -- , CALENDAR_ID
9220 , collapse_bl.TIME_PHASED_TYPE_CODE
9221 , collapse_bl.CURRENCY_CODE
9222 , max(collapse_bl.raw_cost) raw_cost
9223 , max(collapse_bl.BRDN_COST) BRDN_COST
9224 , max(collapse_bl.revenue) revenue
9225 , max(collapse_bl.actual_raw_cost) actual_raw_cost
9226 , max(collapse_bl.actual_BRDN_COST) actual_BRDN_COST
9227 , max(collapse_bl.actual_revenue) actual_revenue
9228 , max(collapse_bl.etc_raw_cost) etc_raw_cost
9229 , max(collapse_bl.etc_BRDN_COST) etc_BRDN_COST
9230 , max(collapse_bl.etc_revenue) etc_revenue
9231 , max(collapse_bl.quantity) quantity
9232 , max(collapse_bl.actual_quantity) actual_quantity
9233 , max(collapse_bl.etc_quantity) etc_quantity
9234 , collapse_bl.start_date start_date
9235 , collapse_bl.end_date end_date
9236 -- , collapse_bl.period_name period_name -- , TRACK_AS_LABOR_FLAG track_as_labor_flag
9237 , collapse_bl.line_type
9238 , collapse_bl.calendar_type
9239 , collapse_bl.period_type_id
9240 , collapse_bl.row_id
9241 ,collapse_bl.rate rate
9242 ,collapse_bl.rate2 rate2
9243 , collapse_bl.plan_type_code
9244 , collapse_bl.WP_FLAG
9245 from
9246 ( ----- Second inline view 'collapse_bl' begin .............
9247 select
9248 spread_bl.row_id row_id
9249 , spread_bl.PROJECT_ID
9250 , spread_bl.BUDGET_VERSION_ID plan_version_id
9251 , spread_bl.time_id
9252 , spread_bl.RESOURCE_ASSIGNMENT_ID
9253 , spread_bl.WBS_ELEMENT_ID
9254 , spread_bl.RBS_ELEMENT_ID
9255 , spread_bl.WBS_STRUCT_VERSION_ID
9256 , spread_bl.RBS_STRUCT_VERSION_ID
9257 , spread_bl.plan_type_id
9258 , spread_bl.BILLABLE_FLAG
9259 , spread_bl.RESOURCE_CLASS
9260 , spread_bl.PROJECT_ORGANIZATION_ID
9261 , spread_bl.PROJECT_ORG_ID
9262 , spread_bl.TIME_PHASED_TYPE_CODE
9263 , DECODE( invert.INVERT_ID
9264 , 1, spread_bl.glb1_CURRENCY_CODE
9265 , 2, spread_bl.glb2_CURRENCY_CODE
9266 , 4, spread_bl.func_CURRENCY_CODE
9267 , 8, spread_bl.PRJ_CURRENCY_CODE
9268 , 16, spread_bl.TXN_CURRENCY_CODE ) CURRENCY_CODE
9269 , invert.INVERT_ID CURR_RECORD_TYPE_ID
9270 , DECODE ( invert.INVERT_ID
9271 , 1, spread_bl.glb1_raw_cost
9272 , 2, spread_bl.glb2_raw_cost
9273 , 4, spread_bl.func_raw_cost
9274 , 8, spread_bl.PRJ_raw_cost
9275 , 16, spread_bl.TXN_raw_cost) raw_cost
9276 , DECODE ( invert.INVERT_ID
9277 , 1, spread_bl.glb1_brdn_cost
9278 , 2, spread_bl.glb2_brdn_cost
9279 , 4, spread_bl.func_BRDN_COST
9280 , 8, spread_bl.PRJ_BRDN_COST
9281 , 16, spread_bl.TXN_BRDN_COST ) BRDN_COST
9282 , DECODE ( invert.INVERT_ID
9283 , 1, spread_bl.glb1_revenue
9284 , 2, spread_bl.glb2_revenue
9285 , 4, spread_bl.func_revenue
9286 , 8, spread_bl.PRJ_revenue
9287 , 16, spread_bl.TXN_revenue ) revenue
9288 , DECODE ( invert.INVERT_ID
9289 , 1, spread_bl.glb1_actual_raw_cost
9290 , 2, spread_bl.glb2_actual_raw_cost
9291 , 4, spread_bl.func_actual_raw_cost
9292 , 8, spread_bl.prj_actual_raw_cost
9293 , 16, spread_bl.txn_actual_raw_cost ) actual_raw_cost
9294 , DECODE ( invert.INVERT_ID
9295 , 1, spread_bl.glb1_actual_brdn_cost
9296 , 2, spread_bl.glb2_actual_brdn_cost
9297 , 4, spread_bl.func_actual_brdn_cost
9298 , 8, spread_bl.prj_actual_brdn_cost
9299 , 16, spread_bl.txn_actual_brdn_cost ) actual_brdn_cost
9300 , DECODE ( invert.INVERT_ID
9301 , 1, spread_bl.glb1_actual_revenue
9302 , 2, spread_bl.glb2_actual_revenue
9303 , 4, spread_bl.func_actual_revenue
9304 , 8, spread_bl.prj_actual_revenue
9305 , 16, spread_bl.txn_actual_revenue ) actual_revenue
9306 , DECODE ( invert.INVERT_ID
9307 , 1, spread_bl.glb1_etc_raw_cost
9308 , 2, spread_bl.glb2_etc_raw_cost
9309 , 4, spread_bl.func_etc_raw_cost
9310 , 8, spread_bl.prj_etc_raw_cost
9311 , 16, spread_bl.txn_etc_raw_cost ) etc_raw_cost
9312 , DECODE ( invert.INVERT_ID
9313 , 1, spread_bl.glb1_etc_brdn_cost
9314 , 2, spread_bl.glb2_etc_brdn_cost
9315 , 4, spread_bl.func_etc_brdn_cost
9316 , 8, spread_bl.prj_etc_brdn_cost
9317 , 16, spread_bl.txn_etc_brdn_cost ) etc_brdn_cost
9318 , DECODE ( invert.INVERT_ID
9319 , 1, spread_bl.glb1_etc_revenue
9320 , 2, spread_bl.glb2_etc_revenue
9321 , 4, spread_bl.func_etc_revenue
9322 , 8, spread_bl.prj_etc_revenue
9323 , 16, spread_bl.txn_etc_revenue ) etc_revenue
9324 , spread_bl.quantity quantity
9325 , spread_bl.actual_quantity actual_quantity
9326 , spread_bl.etc_quantity etc_quantity
9327 , spread_bl.start_date start_date
9328 , spread_bl.end_date end_date
9329 , spread_bl.line_type line_type
9330 , spread_bl.period_type_id
9331 , spread_bl.calendar_type
9332 ,decode(invert.invert_id,1,spread_bl.rate,1) rate
9333 ,decode(invert.invert_id,2,spread_bl.rate2,1) rate2
9334 , spread_bl.plan_type_code
9335 , spread_bl.WP_FLAG
9336 from
9337 ( ----- Third inline view 'spread_bl' .............
9338 SELECT /*+ leading(VER PPA PEVS RA BL PRD RATES) use_hash(RA) */ -- Modified hints for bug 13897252
9339 ra.project_id
9340 , bl.rowid row_id
9341 , ra.budget_version_id
9342 , prd.cal_period_id time_id
9343 , bl.resource_asSIGNment_id
9344 , DECODE(ra.task_id, 0, pevs.proj_element_id, ra.task_id) wbs_element_id
9345 , NVL(map.element_id, -1) rbs_element_id -- !! changed.
9346 , ver.wbs_struct_version_id wbs_struct_version_id
9347 , NVL(ver.rbs_struct_version_id, -1) rbs_struct_version_id -- !! changed.
9348 , ver.plan_type_id plan_type_id
9349 , ra.rate_based_flag billable_flag
9350 -- cbs change
9351 , 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',
9352 '1'||ra.resource_class_code, ra.resource_class_code),ra.resource_class_code) resource_class
9353 -- End cbs change
9354 , DECODE(ver.time_phased_type_code
9355 , g_pa_cal_str, 32
9356 , g_gl_cal_str, 32
9357 , 'N', 2048
9358 , -1) period_type_id
9359 , DECODE(ver.time_phased_type_code
9360 , g_pa_cal_str, g_pa_cal_str
9361 , g_gl_cal_str, g_gl_cal_str
9362 , 'N', g_all
9363 , 'X') CALENDAR_TYPE
9364 , bl.txn_currency_code txn_currency_code
9365 , bl.txn_raw_cost txn_raw_cost
9366 , bl.txn_burdened_COST txn_brdn_COST
9367 , bl.txn_revenue txn_revenue
9368 , DECODE(ver.wp_flag, 'N', bl.txn_init_raw_cost, TO_NUMBER(NULL)) txn_actual_raw_cost -- new
9369 , DECODE(ver.wp_flag, 'N', bl.txn_init_burdened_cost, TO_NUMBER(NULL)) txn_actual_brdn_cost -- new
9370 , DECODE(ver.wp_flag, 'N', bl.txn_init_revenue, TO_NUMBER(NULL)) txn_actual_revenue -- new
9371 , DECODE(ver.wp_flag, 'N', (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0)), TO_NUMBER(NULL)) txn_etc_raw_cost -- new
9372 , DECODE(ver.wp_flag, 'N', (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0)), TO_NUMBER(NULL)) txn_etc_brdn_cost -- new
9373 , DECODE(ver.wp_flag, 'N', (bl.txn_revenue - NVL(bl.txn_init_revenue, 0)), TO_NUMBER(NULL)) txn_etc_revenue -- new
9374 , bl.project_currency_code prj_currency_code
9375 , bl.project_raw_cost prj_raw_cost
9376 , bl.project_burdened_COST prj_BRDN_COST
9377 , bl.project_revenue prj_revenue
9378 , DECODE(ver.wp_flag, 'N', bl.project_init_raw_cost, TO_NUMBER(NULL)) prj_actual_raw_cost -- new
9379 , DECODE(ver.wp_flag, 'N', bl.project_init_burdened_cost, TO_NUMBER(NULL)) prj_actual_brdn_cost -- new
9380 , DECODE(ver.wp_flag, 'N', bl.project_init_revenue, TO_NUMBER(NULL)) prj_actual_revenue -- new
9381 , DECODE(ver.wp_flag, 'N', (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0)), TO_NUMBER(NULL)) prj_etc_raw_cost -- new
9382 , DECODE(ver.wp_flag, 'N', (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0)), TO_NUMBER(NULL)) prj_etc_brdn_cost -- new
9383 , DECODE(ver.wp_flag, 'N', (bl.project_revenue - NVL(bl.project_init_revenue, 0)), TO_NUMBER(NULL)) prj_etc_revenue -- new
9384 , bl.projfunc_currency_code func_currency_code
9385 , bl.raw_cost func_raw_cost
9386 , bl.burdened_COST func_BRDN_COST
9387 , bl.revenue func_revenue
9388 , DECODE(ver.wp_flag, 'N', bl.init_raw_cost , TO_NUMBER(NULL)) func_actual_raw_cost -- new
9389 , DECODE(ver.wp_flag, 'N', bl.init_burdened_cost , TO_NUMBER(NULL)) func_actual_brdn_cost -- new
9390 , DECODE(ver.wp_flag, 'N', bl.init_revenue , TO_NUMBER(NULL)) func_actual_revenue -- new
9391 , DECODE(ver.wp_flag, 'N', (bl.raw_cost - NVL(bl.init_raw_cost, 0)), TO_NUMBER(NULL)) func_etc_raw_cost -- new
9392 , DECODE(ver.wp_flag, 'N', (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)), TO_NUMBER(NULL)) func_etc_brdn_cost -- new
9393 , DECODE(ver.wp_flag, 'N', (bl.revenue - NVL(bl.init_revenue, 0)), TO_NUMBER(NULL)) func_etc_revenue -- new
9394 , g_global1_currency_code glb1_currency_code -- g_global1_currency_code glb1_currency_code
9395 , DECODE (g_global1_currency_code
9396 , bl.txn_currency_code
9397 , bl.txn_raw_cost
9398 , bl.project_currency_code
9399 , bl.project_raw_cost
9400 , bl.projfunc_currency_code
9401 , bl.raw_cost
9402 , ROUND((rates.rate * raw_cost )/rates.mau)*rates.mau
9403 ) glb1_raw_cost
9404 , DECODE (g_global1_currency_code
9405 , bl.txn_currency_code
9406 , bl.txn_burdened_cost
9407 , bl.project_currency_code
9408 , bl.project_burdened_cost
9409 , bl.projfunc_currency_code
9410 , bl.burdened_cost
9411 , ROUND((rates.rate * burdened_cost )/rates.mau)*rates.mau
9412 ) glb1_BRDN_COST
9413 , DECODE (g_global1_currency_code
9414 , bl.txn_currency_code
9415 , bl.txn_revenue
9416 , bl.project_currency_code
9417 , bl.project_revenue
9418 , bl.projfunc_currency_code
9419 , bl.revenue
9420 , ROUND((rates.rate * revenue )/rates.mau)*rates.mau
9421 ) glb1_revenue
9422 , DECODE(ver.wp_flag
9423 , 'N'
9424 , DECODE (g_global1_currency_code
9425 , bl.txn_currency_code
9426 , bl.txn_init_raw_cost
9427 , bl.project_currency_code
9428 , bl.project_init_raw_cost
9429 , bl.projfunc_currency_code
9430 , bl.init_raw_cost
9431 , ROUND((rates.rate * bl.init_raw_cost )/rates.mau)*rates.mau
9432 )
9433 , TO_NUMBER(NULL)) glb1_actual_raw_cost
9434 , DECODE(ver.wp_flag
9435 , 'N'
9436 , DECODE (g_global1_currency_code
9437 , bl.txn_currency_code
9438 , bl.txn_init_burdened_cost
9439 , bl.project_currency_code
9440 , bl.project_init_burdened_cost
9441 , bl.projfunc_currency_code
9442 , bl.init_burdened_cost
9443 , ROUND((rates.rate * bl.init_burdened_cost )/rates.mau)*rates.mau
9444 )
9445 , TO_NUMBER(NULL)) glb1_actual_brdn_cost
9446 , DECODE(ver.wp_flag
9447 , 'N'
9448 , DECODE (g_global1_currency_code
9449 , bl.txn_currency_code
9450 , bl.txn_init_revenue
9451 , bl.project_currency_code
9452 , bl.project_init_revenue
9453 , bl.projfunc_currency_code
9454 , bl.init_revenue
9455 , ROUND((rates.rate * bl.init_revenue )/rates.mau)*rates.mau
9456 )
9457 , TO_NUMBER(NULL)) glb1_actual_revenue
9458 , DECODE(ver.wp_flag
9459 , 'N'
9460 , DECODE (g_global1_currency_code
9461 , bl.txn_currency_code
9462 , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0))
9463 , bl.project_currency_code
9464 , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0))
9465 , bl.projfunc_currency_code
9466 , (bl.raw_cost - NVL(bl.init_raw_cost, 0))
9467 , ROUND((rates.rate * (bl.raw_cost - NVL(bl.init_raw_cost, 0)) )/rates.mau)*rates.mau
9468 )
9469 , TO_NUMBER(NULL)) glb1_etc_raw_cost
9470 , DECODE(ver.wp_flag
9471 , 'N'
9472 , DECODE (g_global1_currency_code
9473 , bl.txn_currency_code
9474 , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0))
9475 , bl.project_currency_code
9476 , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0))
9477 , bl.projfunc_currency_code
9478 , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0))
9479 , ROUND((rates.rate * (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)) )/rates.mau)*rates.mau
9480 )
9481 , TO_NUMBER(NULL)) glb1_etc_brdn_cost
9482 , DECODE(ver.wp_flag
9483 , 'N'
9484 , DECODE (g_global1_currency_code
9485 , bl.txn_currency_code
9486 , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0))
9487 , bl.project_currency_code
9488 , (bl.project_revenue - NVL(bl.project_init_revenue, 0))
9489 , bl.projfunc_currency_code
9490 , (bl.revenue - NVL(bl.init_revenue, 0))
9491 , ROUND((rates.rate * (bl.revenue - NVL(bl.init_revenue, 0)) )/rates.mau)*rates.mau
9492 )
9493 , TO_NUMBER(NULL)) glb1_etc_revenue
9494 , g_global2_currency_code glb2_currency_code -- g_global2_currency_code glb2_currency_code
9495 , DECODE (g_global2_currency_code
9496 , bl.txn_currency_code
9497 , bl.txn_raw_cost
9498 , bl.project_currency_code
9499 , bl.project_raw_cost
9500 , bl.projfunc_currency_code
9501 , bl.raw_cost
9502 , ROUND((rates.rate2 * raw_cost )/rates.mau2)*rates.mau2
9503 ) glb2_raw_cost
9504 , DECODE (g_global2_currency_code
9505 , bl.txn_currency_code
9506 , bl.txn_burdened_cost
9507 , bl.project_currency_code
9508 , bl.project_burdened_cost
9509 , bl.projfunc_currency_code
9510 , bl.burdened_cost
9511 , ROUND((rates.rate2 * burdened_cost )/rates.mau2)*rates.mau2
9512 ) glb2_BRDN_COST
9513 , DECODE (g_global2_currency_code
9514 , bl.txn_currency_code
9515 , bl.txn_revenue
9516 , bl.project_currency_code
9517 , bl.project_revenue
9518 , bl.projfunc_currency_code
9519 , bl.revenue
9520 , ROUND((rates.rate2 * revenue )/rates.mau2)*rates.mau2
9521 ) glb2_revenue
9522 , DECODE(ver.wp_flag
9523 , 'N'
9524 , DECODE (g_global2_currency_code
9525 , bl.txn_currency_code
9526 , bl.txn_init_raw_cost
9527 , bl.project_currency_code
9528 , bl.project_init_raw_cost
9529 , bl.projfunc_currency_code
9530 , bl.init_raw_cost
9531 , ROUND((rates.rate2 * bl.init_raw_cost )/rates.mau2)*rates.mau2
9532 )
9533 , TO_NUMBER(NULL)) glb2_actual_raw_cost
9534 , DECODE(ver.wp_flag
9535 , 'N'
9536 , DECODE (g_global2_currency_code
9537 , bl.txn_currency_code
9538 , bl.txn_init_burdened_cost
9539 , bl.project_currency_code
9540 , bl.project_init_burdened_cost
9541 , bl.projfunc_currency_code
9542 , bl.init_burdened_cost
9543 , ROUND((rates.rate2 * bl.init_burdened_cost )/rates.mau2)*rates.mau2
9544 )
9545 , TO_NUMBER(NULL)) glb2_actual_brdn_cost
9546 , DECODE(ver.wp_flag
9547 , 'N'
9548 , DECODE (g_global2_currency_code
9549 , bl.txn_currency_code
9550 , bl.txn_init_revenue
9551 , bl.project_currency_code
9552 , bl.project_init_revenue
9553 , bl.projfunc_currency_code
9554 , bl.init_revenue
9555 , ROUND((rates.rate2 * bl.init_revenue )/rates.mau2)*rates.mau2
9556 )
9557 , TO_NUMBER(NULL)) glb2_actual_revenue
9558 , DECODE(ver.wp_flag
9559 , 'N'
9560 , DECODE (g_global2_currency_code
9561 , bl.txn_currency_code
9562 , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0))
9563 , bl.project_currency_code
9564 , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0))
9565 , bl.projfunc_currency_code
9566 , (bl.raw_cost - NVL(bl.init_raw_cost, 0))
9567 , ROUND((rates.rate2 * (bl.raw_cost - NVL(bl.init_raw_cost, 0)) )/rates.mau2)*rates.mau2
9568 )
9569 , TO_NUMBER(NULL)) glb2_etc_raw_cost
9570 , DECODE(ver.wp_flag
9571 , 'N'
9572 , DECODE (g_global2_currency_code
9573 , bl.txn_currency_code
9574 , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0))
9575 , bl.project_currency_code
9576 , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0))
9577 , bl.projfunc_currency_code
9578 , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0))
9579 , ROUND((rates.rate2 * (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)) )/rates.mau2)*rates.mau2
9580 )
9581 , TO_NUMBER(NULL)) glb2_etc_brdn_cost
9582 , DECODE(ver.wp_flag
9583 , 'N'
9584 , DECODE (g_global2_currency_code
9585 , bl.txn_currency_code
9586 , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0))
9587 , bl.project_currency_code
9588 , (bl.project_revenue - NVL(bl.project_init_revenue, 0))
9589 , bl.projfunc_currency_code
9590 , (bl.revenue - NVL(bl.init_revenue, 0))
9591 , ROUND((rates.rate2 * (bl.revenue - NVL(bl.init_revenue, 0)) )/rates.mau2)*rates.mau2
9592 )
9593 , TO_NUMBER(NULL)) glb2_etc_revenue
9594 , bl.quantity quantity
9595 , DECODE(ver.wp_flag, 'N', bl.init_quantity, TO_NUMBER(NULL)) actual_quantity -- new
9596 , DECODE(ver.wp_flag, 'N', (bl.quantity - NVL(bl.init_quantity, 0)), TO_NUMBER(NULL)) etc_quantity -- new
9597 , TO_DATE(NULL) START_DATE
9598 , TO_DATE(NULL) END_date
9599 , ver.time_phased_type_code time_phased_type_code
9600 , ppa.org_id project_org_id
9601 , ppa.carrying_out_organization_id project_organization_id
9602 , DECODE(ver.time_phased_type_code, g_pa_cal_str, 'OF', g_gl_cal_str, 'OF', 'N', 'NTP', 'X') line_type
9603 ,decode(ver.rate_dangling_flag,'Y',-1,1) rate
9604 ,decode(ver.rate_dangling_flag,'Y',-1,1) rate2
9605 ,ver.plan_type_code plan_type_code /*4471527 */
9606 , ver.WP_FLAG
9607 FROM
9608 PJI_FM_EXTR_PLNVER4 ver
9609 , pa_resource_asSIGNments ra
9610 , PA_BUDGET_LINES bl
9611 , pa_projects_all ppa
9612 , PJI_ORG_EXTR_INFO oei
9613 , pji_pjp_rbs_header rhdr
9614 , pji_time_cal_period_v prd
9615 , PJI_FM_AGGR_DLY_RATES rates
9616 , pji_fp_txn_accum_header hdr
9617 , pa_rbs_txn_accum_map map
9618 , PA_PROJ_ELEM_VER_STRUCTURE pevs
9619 WHERE 1=1
9620 AND ra.resource_asSIGNment_id = bl.resource_asSIGNment_id
9621 AND ra.project_id = ver.PROJECT_ID
9622 AND ra.budget_version_id = ver.plan_version_id
9623 AND ver.project_id = ppa.project_id
9624 AND txn_currency_code IS NOT NULL
9625 AND bl.project_currency_code IS NOT NULL
9626 AND bl.projfunc_currency_code IS NOT NULL
9627 AND pevs.element_version_id = ver.wbs_struct_version_id
9628 AND ver.project_id = pevs.project_id
9629 AND ver.secondary_rbs_flag = 'Y'
9630 AND ver.wp_flag = 'N'
9631 AND ver.baselined_flag = 'Y'
9632 AND oei.org_id = ppa.org_id
9633 AND ver.time_phased_type_code IN (g_pa_cal_str, g_gl_cal_str)
9634 AND DECODE ( ver.time_phased_type_code
9635 , g_pa_cal_str, oei.pa_calendar_id
9636 , g_gl_cal_str, oei.gl_calendar_id) = prd.calendar_id
9637 AND bl.period_name = prd.name
9638 AND rates.time_id = prd.cal_period_id
9639 AND rates.worker_id = g_worker_id
9640 AND rates.pf_currency_code = bl.projfunc_currency_code -- 4764334
9641 AND ra.txn_accum_header_id = hdr.txn_accum_header_id
9642 AND ra.txn_accum_header_id = map.txn_accum_header_id
9643 AND map.struct_version_id = rhdr.rbs_version_id
9644 AND ra.budget_version_id = rhdr.plan_version_id
9645 AND rhdr.project_id = ver.project_id
9646 AND ppa.project_id = ra.project_id
9647 AND ver.rbs_struct_version_id = rhdr.rbs_version_id
9648 AND ver.worker_id = g_worker_id
9649 UNION ALL
9650 SELECT /*+ parallel(ver) */ -- Modified hints for bug 13897252
9651 ra.project_id
9652 , bl.rowid row_id
9653 , ra.budget_version_id
9654 , -1 time_id
9655 , bl.resource_asSIGNment_id
9656 , DECODE(ra.task_id, 0, pevs.proj_element_id, ra.task_id) wbs_element_id
9657 , NVL(map.element_id, -1) rbs_element_id -- !! changed.
9658 , ver.wbs_struct_version_id wbs_struct_version_id
9659 , NVL(ver.rbs_struct_version_id, -1) rbs_struct_version_id -- !! changed.
9660 , ver.plan_type_id plan_type_id
9661 , ra.rate_based_flag billable_flag
9662 -- cbs change
9663 , 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',
9664 '1'||ra.resource_class_code, ra.resource_class_code),ra.resource_class_code) resource_class
9665 -- End cbs change
9666 , DECODE(ver.time_phased_type_code
9667 , g_pa_cal_str, 32
9668 , g_gl_cal_str, 32
9669 , 'N', 2048
9670 , -1) period_type_id
9671 , DECODE(ver.time_phased_type_code
9672 , g_pa_cal_str, g_pa_cal_str
9673 , g_gl_cal_str, g_gl_cal_str
9674 , 'N', g_all
9675 , 'X') CALENDAR_TYPE
9676 , bl.txn_currency_code txn_currency_code
9677 , bl.txn_raw_cost txn_raw_cost
9678 , bl.txn_burdened_COST txn_brdn_COST
9679 , bl.txn_revenue txn_revenue
9680 , DECODE(ver.wp_flag, 'N', bl.txn_init_raw_cost, TO_NUMBER(NULL)) txn_actual_raw_cost -- new
9681 , DECODE(ver.wp_flag, 'N', bl.txn_init_burdened_cost, TO_NUMBER(NULL)) txn_actual_brdn_cost -- new
9682 , DECODE(ver.wp_flag, 'N', bl.txn_init_revenue, TO_NUMBER(NULL)) txn_actual_revenue -- new
9683 , DECODE(ver.wp_flag, 'N', (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0)), TO_NUMBER(NULL)) txn_etc_raw_cost -- new
9684 , DECODE(ver.wp_flag, 'N', (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0)), TO_NUMBER(NULL)) txn_etc_brdn_cost -- new
9685 , DECODE(ver.wp_flag, 'N', (bl.txn_revenue - NVL(bl.txn_init_revenue, 0)), TO_NUMBER(NULL)) txn_etc_revenue -- new
9686 , bl.project_currency_code prj_currency_code
9687 , bl.project_raw_cost prj_raw_cost
9688 , bl.project_burdened_COST prj_BRDN_COST
9689 , bl.project_revenue prj_revenue
9690 , DECODE(ver.wp_flag, 'N', bl.project_init_raw_cost, TO_NUMBER(NULL)) prj_actual_raw_cost -- new
9691 , DECODE(ver.wp_flag, 'N', bl.project_init_burdened_cost, TO_NUMBER(NULL)) prj_actual_brdn_cost -- new
9692 , DECODE(ver.wp_flag, 'N', bl.project_init_revenue, TO_NUMBER(NULL)) prj_actual_revenue -- new
9693 , DECODE(ver.wp_flag, 'N', (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0)), TO_NUMBER(NULL)) prj_etc_raw_cost -- new
9694 , DECODE(ver.wp_flag, 'N', (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0)), TO_NUMBER(NULL)) prj_etc_brdn_cost -- new
9695 , DECODE(ver.wp_flag, 'N', (bl.project_revenue - NVL(bl.project_init_revenue, 0)), TO_NUMBER(NULL)) prj_etc_revenue -- new
9696 , bl.projfunc_currency_code func_currency_code
9697 , bl.raw_cost func_raw_cost
9698 , bl.burdened_COST func_BRDN_COST
9699 , bl.revenue func_revenue
9700 , DECODE(ver.wp_flag, 'N', bl.init_raw_cost , TO_NUMBER(NULL)) func_actual_raw_cost -- new
9701 , DECODE(ver.wp_flag, 'N', bl.init_burdened_cost , TO_NUMBER(NULL)) func_actual_brdn_cost -- new
9702 , DECODE(ver.wp_flag, 'N', bl.init_revenue , TO_NUMBER(NULL)) func_actual_revenue -- new
9703 , DECODE(ver.wp_flag, 'N', (bl.raw_cost - NVL(bl.init_raw_cost, 0)), TO_NUMBER(NULL)) func_etc_raw_cost -- new
9704 , DECODE(ver.wp_flag, 'N', (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)), TO_NUMBER(NULL)) func_etc_brdn_cost -- new
9705 , DECODE(ver.wp_flag, 'N', (bl.revenue - NVL(bl.init_revenue, 0)), TO_NUMBER(NULL)) func_etc_revenue -- new
9706 , g_global1_currency_code glb1_currency_code -- g_global1_currency_code glb1_currency_code
9707 , DECODE (g_global1_currency_code
9708 , bl.txn_currency_code
9709 , bl.txn_raw_cost
9710 , bl.project_currency_code
9711 , bl.project_raw_cost
9712 , bl.projfunc_currency_code
9713 , bl.raw_cost
9714 , ROUND((rates.rate * raw_cost )/rates.mau)*rates.mau
9715 ) glb1_raw_cost
9716 , DECODE (g_global1_currency_code
9717 , bl.txn_currency_code
9718 , bl.txn_burdened_cost
9719 , bl.project_currency_code
9720 , bl.project_burdened_cost
9721 , bl.projfunc_currency_code
9722 , bl.burdened_cost
9723 , ROUND((rates.rate * burdened_cost )/rates.mau)*rates.mau
9724 ) glb1_BRDN_COST
9725 , DECODE (g_global1_currency_code
9726 , bl.txn_currency_code
9727 , bl.txn_revenue
9728 , bl.project_currency_code
9729 , bl.project_revenue
9730 , bl.projfunc_currency_code
9731 , bl.revenue
9732 , ROUND((rates.rate * revenue )/rates.mau)*rates.mau
9733 ) glb1_revenue
9734 , DECODE(ver.wp_flag
9735 , 'N'
9736 , DECODE (g_global1_currency_code
9737 , bl.txn_currency_code
9738 , bl.txn_init_raw_cost
9739 , bl.project_currency_code
9740 , bl.project_init_raw_cost
9741 , bl.projfunc_currency_code
9742 , bl.init_raw_cost
9743 , ROUND((rates.rate * bl.init_raw_cost )/rates.mau)*rates.mau
9744 )
9745 , TO_NUMBER(NULL)) glb1_actual_raw_cost
9746 , DECODE(ver.wp_flag
9747 , 'N'
9748 , DECODE (g_global1_currency_code
9749 , bl.txn_currency_code
9750 , bl.txn_init_burdened_cost
9751 , bl.project_currency_code
9752 , bl.project_init_burdened_cost
9753 , bl.projfunc_currency_code
9754 , bl.init_burdened_cost
9755 , ROUND((rates.rate * bl.init_burdened_cost )/rates.mau)*rates.mau
9756 )
9757 , TO_NUMBER(NULL)) glb1_actual_brdn_cost
9758 , DECODE(ver.wp_flag
9759 , 'N'
9760 , DECODE (g_global1_currency_code
9761 , bl.txn_currency_code
9762 , bl.txn_init_revenue
9763 , bl.project_currency_code
9764 , bl.project_init_revenue
9765 , bl.projfunc_currency_code
9766 , bl.init_revenue
9767 , ROUND((rates.rate * bl.init_revenue )/rates.mau)*rates.mau
9768 )
9769 , TO_NUMBER(NULL)) glb1_actual_revenue
9770 , DECODE(ver.wp_flag
9771 , 'N'
9772 , DECODE (g_global1_currency_code
9773 , bl.txn_currency_code
9774 , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0))
9775 , bl.project_currency_code
9776 , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0))
9777 , bl.projfunc_currency_code
9778 , (bl.raw_cost - NVL(bl.init_raw_cost, 0))
9779 , ROUND((rates.rate * (bl.raw_cost - NVL(bl.init_raw_cost, 0)) )/rates.mau)*rates.mau
9780 )
9781 , TO_NUMBER(NULL)) glb1_etc_raw_cost
9782 , DECODE(ver.wp_flag
9783 , 'N'
9784 , DECODE (g_global1_currency_code
9785 , bl.txn_currency_code
9786 , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0))
9787 , bl.project_currency_code
9788 , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0))
9789 , bl.projfunc_currency_code
9790 , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0))
9791 , ROUND((rates.rate * (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)) )/rates.mau)*rates.mau
9792 )
9793 , TO_NUMBER(NULL)) glb1_etc_brdn_cost
9794 , DECODE(ver.wp_flag
9795 , 'N'
9796 , DECODE (g_global1_currency_code
9797 , bl.txn_currency_code
9798 , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0))
9799 , bl.project_currency_code
9800 , (bl.project_revenue - NVL(bl.project_init_revenue, 0))
9801 , bl.projfunc_currency_code
9802 , (bl.revenue - NVL(bl.init_revenue, 0))
9803 , ROUND((rates.rate * (bl.revenue - NVL(bl.init_revenue, 0)) )/rates.mau)*rates.mau
9804 )
9805 , TO_NUMBER(NULL)) glb1_etc_revenue
9806 , g_global2_currency_code glb2_currency_code -- g_global2_currency_code glb2_currency_code
9807 , DECODE (g_global2_currency_code
9808 , bl.txn_currency_code
9809 , bl.txn_raw_cost
9810 , bl.project_currency_code
9811 , bl.project_raw_cost
9812 , bl.projfunc_currency_code
9813 , bl.raw_cost
9814 , ROUND((rates.rate2 * raw_cost )/rates.mau2)*rates.mau2
9815 ) glb2_raw_cost
9816 , DECODE (g_global2_currency_code
9817 , bl.txn_currency_code
9818 , bl.txn_burdened_cost
9819 , bl.project_currency_code
9820 , bl.project_burdened_cost
9821 , bl.projfunc_currency_code
9822 , bl.burdened_cost
9823 , ROUND((rates.rate2 * burdened_cost )/rates.mau2)*rates.mau2
9824 ) glb2_BRDN_COST
9825 , DECODE (g_global2_currency_code
9826 , bl.txn_currency_code
9827 , bl.txn_revenue
9828 , bl.project_currency_code
9829 , bl.project_revenue
9830 , bl.projfunc_currency_code
9831 , bl.revenue
9832 , ROUND((rates.rate2 * revenue )/rates.mau2)*rates.mau2
9833 ) glb2_revenue
9834 , DECODE(ver.wp_flag
9835 , 'N'
9836 , DECODE (g_global2_currency_code
9837 , bl.txn_currency_code
9838 , bl.txn_init_raw_cost
9839 , bl.project_currency_code
9840 , bl.project_init_raw_cost
9841 , bl.projfunc_currency_code
9842 , bl.init_raw_cost
9843 , ROUND((rates.rate2 * bl.init_raw_cost )/rates.mau2)*rates.mau2
9844 )
9845 , TO_NUMBER(NULL)) glb2_actual_raw_cost
9846 , DECODE(ver.wp_flag
9847 , 'N'
9848 , DECODE (g_global2_currency_code
9849 , bl.txn_currency_code
9850 , bl.txn_init_burdened_cost
9851 , bl.project_currency_code
9852 , bl.project_init_burdened_cost
9853 , bl.projfunc_currency_code
9854 , bl.init_burdened_cost
9855 , ROUND((rates.rate2 * bl.init_burdened_cost )/rates.mau2)*rates.mau2
9856 )
9857 , TO_NUMBER(NULL)) glb2_actual_brdn_cost
9858 , DECODE(ver.wp_flag
9859 , 'N'
9860 , DECODE (g_global2_currency_code
9861 , bl.txn_currency_code
9862 , bl.txn_init_revenue
9863 , bl.project_currency_code
9864 , bl.project_init_revenue
9865 , bl.projfunc_currency_code
9866 , bl.init_revenue
9867 , ROUND((rates.rate2 * bl.init_revenue )/rates.mau2)*rates.mau2
9868 )
9869 , TO_NUMBER(NULL)) glb2_actual_revenue
9870 , DECODE(ver.wp_flag
9871 , 'N'
9872 , DECODE (g_global2_currency_code
9873 , bl.txn_currency_code
9874 , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0))
9875 , bl.project_currency_code
9876 , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0))
9877 , bl.projfunc_currency_code
9878 , (bl.raw_cost - NVL(bl.init_raw_cost, 0))
9879 , ROUND((rates.rate2 * (bl.raw_cost - NVL(bl.init_raw_cost, 0)) )/rates.mau2)*rates.mau2
9880 )
9881 , TO_NUMBER(NULL)) glb2_etc_raw_cost
9882 , DECODE(ver.wp_flag
9883 , 'N'
9884 , DECODE (g_global2_currency_code
9885 , bl.txn_currency_code
9886 , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0))
9887 , bl.project_currency_code
9888 , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0))
9889 , bl.projfunc_currency_code
9890 , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0))
9891 , ROUND((rates.rate2 * (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)) )/rates.mau2)*rates.mau2
9892 )
9893 , TO_NUMBER(NULL)) glb2_etc_brdn_cost
9894 , DECODE(ver.wp_flag
9895 , 'N'
9896 , DECODE (g_global2_currency_code
9897 , bl.txn_currency_code
9898 , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0))
9899 , bl.project_currency_code
9900 , (bl.project_revenue - NVL(bl.project_init_revenue, 0))
9901 , bl.projfunc_currency_code
9902 , (bl.revenue - NVL(bl.init_revenue, 0))
9903 , ROUND((rates.rate2 * (bl.revenue - NVL(bl.init_revenue, 0)) )/rates.mau2)*rates.mau2
9904 )
9905 , TO_NUMBER(NULL)) glb2_etc_revenue
9906 , bl.quantity quantity
9907 , DECODE(ver.wp_flag, 'N', bl.init_quantity, TO_NUMBER(NULL)) actual_quantity -- new
9908 , DECODE(ver.wp_flag, 'N', (bl.quantity - NVL(bl.init_quantity, 0)), TO_NUMBER(NULL)) etc_quantity -- new
9909 , ra.planning_start_date start_date
9910 , ra.planning_END_date end_date
9911 , ver.time_phased_type_code time_phased_type_code
9912 , ppa.org_id project_org_id
9913 , ppa.carrying_out_organization_id project_organization_id
9914 , 'NTP' line_type
9915 ,decode(ver.rate_dangling_flag,'Y',-1,1) rate
9916 ,decode(ver.rate_dangling_flag,'Y',-1,1) rate2
9917 , ver.plan_type_code plan_type_code /*4471527 */
9918 , ver.WP_FLAG
9919 FROM
9920 PJI_FM_EXTR_PLNVER4 ver
9921 , pa_resource_asSIGNments ra
9922 , PA_BUDGET_LINES bl
9923 , pa_projects_all ppa
9924 , pji_pjp_rbs_header rhdr
9925 , PJI_FM_AGGR_DLY_RATES rates
9926 , pji_fp_txn_accum_header hdr
9927 , pa_rbs_txn_accum_map map
9928 , PA_PROJ_ELEM_VER_STRUCTURE pevs
9929 WHERE 1=1
9930 AND ra.resource_asSIGNment_id = bl.resource_asSIGNment_id
9931 AND ra.project_id = ver.PROJECT_ID
9932 AND ra.budget_version_id = ver.plan_version_id
9933 AND ver.project_id = ppa.project_id
9934 AND txn_currency_code IS NOT NULL
9935 AND bl.project_currency_code IS NOT NULL
9936 AND bl.projfunc_currency_code IS NOT NULL
9937 AND pevs.element_version_id = ver.wbs_struct_version_id
9938 AND ver.project_id = pevs.project_id
9939 AND ver.secondary_rbs_flag = 'Y'
9940 AND ver.wp_flag = 'N'
9941 AND ver.baselined_flag = 'Y'
9942 -- AND oei.org_id = ppa.org_id
9943 AND ver.time_phased_type_code = 'N' -- IN (g_pa_cal_str, g_gl_cal_str)
9944 AND rates.time_id = DECODE ( g_currency_conversion_rule
9945 , g_start_str
9946 , TO_NUMBER(to_CHAR(ra.planning_start_date, 'J'))
9947 , g_end_str
9948 , TO_NUMBER(to_CHAR(ra.planning_end_date, 'J')) )
9949 AND rates.pf_currency_code = bl.projfunc_currency_code -- 4764334
9950 AND rates.worker_id = g_worker_id
9951 AND ra.txn_accum_header_id = hdr.txn_accum_header_id
9952 AND ra.txn_accum_header_id = map.txn_accum_header_id
9953 AND map.struct_version_id = rhdr.rbs_version_id
9954 AND ra.budget_version_id = rhdr.plan_version_id
9955 AND rhdr.project_id = ver.project_id
9956 AND ppa.project_id = ra.project_id
9957 AND ver.rbs_struct_version_id = rhdr.rbs_version_id
9958 AND ver.worker_id = g_worker_id
9959 ) spread_bl
9960 ---- end of third inline view 'spread_bl'...........
9961 ,
9962 (
9963 select 1 INVERT_ID from dual where PJI_UTILS.GET_SETUP_PARAMETER('GLOBAL_CURR1_FLAG') = 'Y' union all /* Added for bug 8708651 */
9964 select 2 INVERT_ID from dual where PJI_UTILS.GET_SETUP_PARAMETER('GLOBAL_CURR2_FLAG') = 'Y' union all
9965 select 4 INVERT_ID from dual union all
9966 select 8 INVERT_ID from dual union all
9967 select 16 INVERT_ID from dual where PJI_UTILS.GET_SETUP_PARAMETER('TXN_CURR_FLAG') = 'Y'
9968 ) invert
9969 ) collapse_bl
9970 ---- End of second inline view 'collapse_bl' ..........
9971 GROUP BY
9972 collapse_bl.PROJECT_ID
9973 , collapse_bl.time_id
9974 , collapse_bl.WBS_ELEMENT_ID
9975 -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
9976 , collapse_bl.RBS_ELEMENT_ID
9977 , collapse_bl.RBS_STRUCT_VERSION_ID
9978 , collapse_bl.plan_type_id
9979 , collapse_bl.plan_version_id
9980 , collapse_bl.PROJECT_ORGANIZATION_ID
9981 , collapse_bl.PROJECT_ORG_ID
9982 , collapse_bl.RESOURCE_ASSIGNMENT_ID
9983 , collapse_bl.BILLABLE_FLAG
9984 , collapse_bl.RESOURCE_CLASS
9985 , collapse_bl.TIME_PHASED_TYPE_CODE
9986 , collapse_bl.CURRENCY_CODE
9987 , collapse_bl.start_date
9988 , collapse_bl.end_date
9989 , collapse_bl.row_id
9990 , collapse_bl.line_type
9991 , collapse_bl.calendar_type
9992 , collapse_bl.period_type_id
9993 ,collapse_bl.rate
9994 ,collapse_bl.rate2
9995 , collapse_bl.plan_type_code
9996 , collapse_bl.WP_FLAG
9997 ) plr
9998 ---- End of first inline view plr ..........
9999 WHERE 1=1
10000 -- AND plr.CURR_RECORD_TYPE IS NOT NULL
10001 AND plr.currency_code IS NOT NULL
10002 GROUP BY
10003 plr.PROJECT_ID
10004 , plr.PROJECT_ORG_ID
10005 , plr.project_ORGANIZATION_ID
10006 , plr.WBS_ELEMENT_ID
10007 , plr.time_id
10008 , plr.period_type_id
10009 , plr.CALENDAR_TYPE
10010 , plr.CURR_RECORD_TYPE -- curr code missing.
10011 , plr.currency_code
10012 , plr.RBS_ELEMENT_ID
10013 , plr.RBS_STRUCT_VERSION_ID
10014 , plr.plan_version_id
10015 , plr.plan_type_id
10016 , plr.start_date
10017 , plr.end_date
10018 , plr.line_type
10019 ,decode(sign(plr.rate),-1,'Y',NULL) ||decode(sign(plr.rate2),-1,'Y',NULL)
10020 ,plr.plan_type_code /*4471527 */
10021 )
10022 GROUP BY
10023 WORKER_ID
10024 ,PROJECT_ID
10025 ,PROJECT_ORG_ID
10026 ,project_ORGANIZATION_ID
10027 ,WBS_ELEMENT_ID
10028 ,time_id
10029 ,period_type_id
10030 ,CALENDAR_TYPE
10031 ,RBS_AGGR_LEVEL
10032 ,WBS_ROLLUP_FLAG
10033 ,PRG_ROLLUP_FLAG
10034 ,CURR_RECORD_TYPE
10035 ,currency_code
10036 ,RBS_ELEMENT_ID
10037 ,RBS_STRUCT_VERSION_ID
10038 ,plan_version_id
10039 ,plan_type_id
10040 ,LINE_TYPE
10041 ,rate_dangling_flag
10042 ,time_dangling_flag
10043 ,start_date
10044 ,end_date
10045 ,prg_level
10046 , plan_type_code ; /*4471527 */
10047
10048 print_time ( ' EXTRACT_PLAN_AMTS_SECRBS_GLC12 end. Inserted rows # is: ' || SQL%ROWCOUNT );
10049
10050 EXCEPTION
10051 WHEN OTHERS THEN
10052 print_time('EXTRACT_PLAN_AMOUNTS_SECRBS : Exception ' || SQLERRM );
10053 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
10054 p_procedure_name => 'EXTRACT_PLAN_AMTS_SECRBS_GLC12');
10055 RAISE;
10056 END;
10057
10058
10059 PROCEDURE EXTRACT_PLAN_AMTS_PRIRBS_GLC12 (
10060 p_pull_dangling_flag IN VARCHAR2 := 'Y') -- Reversals to be computed only if pull_dangling flag is 'Y'
10061 IS
10062 BEGIN
10063
10064 /* Added for bug 13030627 */
10065 if PJI_UTILS.GET_PARAMETER('PJP_SIN_PRG') = 'Y' then
10066
10067 PJI_PJP_PRG_PERF_ALL.EXTRACT_PLAN_AMTS_PRIRBS_GLC12;
10068
10069 else
10070
10071 print_time ( ' EXTRACT_PLAN_AMTS_PRIRBS_GLC12 begin. ' );
10072
10073 PJI_PJP_FP_CURR_WRAP.get_global_currency_info (
10074 x_currency_conversion_rule => g_currency_conversion_rule
10075 , x_prorating_format => g_prorating_format
10076 , x_global1_currency_code => g_global1_currency_code
10077 , x_global2_currency_code => g_global2_currency_code
10078 , x_global1_currency_mau => g_global1_currency_mau
10079 , x_global2_currency_mau => g_global2_currency_mau ) ;
10080
10081
10082 print_time(' Got global currency settings. ');
10083 print_time(' g_currency_conversion_rule ' || g_currency_conversion_rule || ' g_prorating_format ' || g_prorating_format );
10084 print_time(' g_global1_currency_code ' || g_global1_currency_code || ' g_global2_currency_code ' || g_global2_currency_code );
10085 print_time(' g_global1_currency_mau ' || g_global1_currency_mau || ' g_global2_currency_mau ' || g_global2_currency_mau ) ;
10086
10087 -- cbs change
10088 IF P_PA_DEBUG_MODE = 'Y' THEN
10089 pa_debug.write('EXTRACT_PLAN_AMTS_PRIRBS_GLC12: ' || g_module_name,'Before calling SET_RES_CLASS_FLAG' ,1);
10090 END IF;
10091
10092 SET_RES_CLASS_FLAG;
10093
10094 IF P_PA_DEBUG_MODE = 'Y' THEN
10095 pa_debug.write('EXTRACT_PLAN_AMTS_PRIRBS_GLC12: ' || g_module_name,'After calling SET_RES_CLASS_FLAG' ,1);
10096 END IF;
10097
10098 -- End cbs change
10099 INSERT INTO PJI_FP_AGGR_PJP1
10100 (
10101 WORKER_ID
10102 , PROJECT_ID
10103 , PROJECT_ORG_ID
10104 , PROJECT_ORGANIZATION_ID
10105 , PROJECT_ELEMENT_ID
10106 , TIME_ID
10107 , PERIOD_TYPE_ID
10108 , CALENDAR_TYPE
10109 , RBS_AGGR_LEVEL
10110 , WBS_ROLLUP_FLAG
10111 , PRG_ROLLUP_FLAG
10112 , CURR_RECORD_TYPE_ID
10113 , CURRENCY_CODE
10114 , RBS_ELEMENT_ID
10115 , RBS_VERSION_ID
10116 , PLAN_VERSION_ID
10117 , PLAN_TYPE_ID
10118 , RAW_COST
10119 , BRDN_COST
10120 , REVENUE
10121 , BILL_RAW_COST
10122 , BILL_BRDN_COST
10123 , BILL_LABOR_RAW_COST
10124 , BILL_LABOR_BRDN_COST
10125 , BILL_LABOR_HRS
10126 , EQUIPMENT_RAW_COST
10127 , EQUIPMENT_BRDN_COST
10128 , CAPITALIZABLE_RAW_COST
10129 , CAPITALIZABLE_BRDN_COST
10130 , LABOR_RAW_COST
10131 , LABOR_BRDN_COST
10132 , LABOR_HRS
10133 , LABOR_REVENUE
10134 , EQUIPMENT_HOURS
10135 , BILLABLE_EQUIPMENT_HOURS
10136 , SUP_INV_COMMITTED_COST
10137 , PO_COMMITTED_COST
10138 , PR_COMMITTED_COST
10139 , OTH_COMMITTED_COST
10140 , ACT_LABOR_HRS
10141 , ACT_EQUIP_HRS
10142 , ACT_LABOR_BRDN_COST
10143 , ACT_EQUIP_BRDN_COST
10144 , ACT_BRDN_COST
10145 , ACT_RAW_COST
10146 , ACT_REVENUE
10147 , ACT_LABOR_RAW_COST
10148 , ACT_EQUIP_RAW_COST
10149 , ETC_LABOR_HRS
10150 , ETC_EQUIP_HRS
10151 , ETC_LABOR_BRDN_COST
10152 , ETC_EQUIP_BRDN_COST
10153 , ETC_BRDN_COST
10154 , ETC_RAW_COST
10155 , ETC_LABOR_RAW_COST
10156 , ETC_EQUIP_RAW_COST
10157 , CUSTOM1
10158 , CUSTOM2
10159 , CUSTOM3
10160 , CUSTOM4
10161 , CUSTOM5
10162 , CUSTOM6
10163 , CUSTOM7
10164 , CUSTOM8
10165 , CUSTOM9
10166 , CUSTOM10
10167 , CUSTOM11
10168 , CUSTOM12
10169 , CUSTOM13
10170 , CUSTOM14
10171 , CUSTOM15
10172 , LINE_TYPE
10173 , RATE_DANGLING_FLAG
10174 , TIME_DANGLING_FLAG
10175 , START_DATE
10176 , END_DATE
10177 , PRG_LEVEL
10178 , PLAN_TYPE_CODE /*4471527 */
10179 )
10180 SELECT /* This select is no more required. Not removing it to minimize impact for nov-11 dhi one off.
10181 We can remove it later, to improve performance */
10182 WORKER_ID
10183 , PROJECT_ID
10184 , PROJECT_ORG_ID
10185 , project_ORGANIZATION_ID
10186 , WBS_ELEMENT_ID
10187 , time_id
10188 , period_type_id
10189 , CALENDAR_TYPE
10190 , g_lowest_level RBS_AGGR_LEVEL
10191 , 'N' WBS_ROLLUP_FLAG
10192 , 'N' PRG_ROLLUP_FLAG
10193 , CURR_RECORD_TYPE
10194 , currency_code
10195 , RBS_ELEMENT_ID
10196 , RBS_STRUCT_VERSION_ID
10197 , plan_version_id
10198 , plan_type_id
10199 , decode(rate_dangling_flag,null,SUM(RAW_COST),0)
10200 , decode(rate_dangling_flag,null,SUM(BRDN_COST),0)
10201 , decode(rate_dangling_flag,null,SUM(REVENUE),0)
10202 , decode(rate_dangling_flag,null,SUM ( BILL_RAW_COST ),0) BILL_RAW_COST
10203 , decode(rate_dangling_flag,null,SUM (BILL_BRDN_COST ),0) BILL_BRDN_COST
10204 , decode(rate_dangling_flag,null,SUM ( BILL_LABOR_RAW_COST),0) BILL_LABOR_RAW_COST
10205 , decode(rate_dangling_flag,null,SUM ( BILL_LABOR_BRDN_COST),0) BILL_LABOR_BRDN_COST
10206 , decode(rate_dangling_flag,null,SUM ( BILL_LABOR_HRS),0) BILL_LABOR_HRS
10207 , decode(rate_dangling_flag,null,SUM ( EQUIPMENT_RAW_COST),0) EQUIPMENT_RAW_COST
10208 , decode(rate_dangling_flag,null,SUM ( EQUIPMENT_BRDN_COST),0) EQUIPMENT_BRDN_COST
10209 , decode(rate_dangling_flag,null,SUM (CAPITALIZABLE_RAW_COST),0) CAPITALIZABLE_RAW_COST
10210 , decode(rate_dangling_flag,null,SUM ( CAPITALIZABLE_BRDN_COST),0)
10211 , decode(rate_dangling_flag,null,SUM ( LABOR_RAW_COST),0) LABOR_RAW_COST
10212 , decode(rate_dangling_flag,null,SUM ( LABOR_BRDN_COST),0) LABOR_BRDN_COST
10213 , decode(rate_dangling_flag,null,SUM ( labor_hrs),0) labor_hrs
10214 , decode(rate_dangling_flag,null,SUM (LABOR_REVENUE),0) LABOR_REVENUE
10215 , decode(rate_dangling_flag,null,SUM (EQUIPMENT_HOURS),0) EQUIPMENT_HOURS
10216 , decode(rate_dangling_flag,null,SUM ( BILLABLE_EQUIPMENT_HOURS),0) BILLABLE_EQUIPMENT_HOURS
10217 , decode(rate_dangling_flag,null,SUM(SUP_INV_COMMITTED_COST),0) SUP_INV_COMMITTED_COST
10218 , decode(rate_dangling_flag,null,SUM(PO_COMMITTED_COST),0) PO_COMMITTED_COST
10219 , decode(rate_dangling_flag,null,SUM(PR_COMMITTED_COST),0) PR_COMMITTED_COST
10220 , decode(rate_dangling_flag,null,SUM(OTH_COMMITTED_COST),0) PR_COMMITTED_COST
10221 , decode(rate_dangling_flag,null,SUM ( ACT_LABOR_HRS),0) ACT_LABOR_HRS
10222 , decode(rate_dangling_flag,null,SUM (ACT_EQUIP_HOURS),0) ACT_EQUIP_HOURS
10223 , decode(rate_dangling_flag,null,SUM ( ACT_LABOR_BRDN_COST),0) ACT_LABOR_BRDN_COST
10224 , decode(rate_dangling_flag,null,SUM ( ACT_EQUIPMENT_BRDN_COST),0) ACT_EQUIPMENT_BRDN_COST
10225 , decode(rate_dangling_flag,null,SUM ( ACT_BRDN_COST),0) ACT_BRDN_COST
10226 , decode(rate_dangling_flag,null,SUM ( ACT_RAW_COST),0) ACT_RAW_COST
10227 , decode(rate_dangling_flag,null,SUM ( ACT_REVENUE),0) ACT_REVENUE
10228 , decode(rate_dangling_flag,null,SUM ( ACT_LABOR_RAW_COST),0) ACT_LABOR_RAW_COST
10229 , decode(rate_dangling_flag,null,SUM ( ACT_EQUIPMENT_RAW_COST),0) ACT_EQUIPMENT_RAW_COST
10230 , decode(rate_dangling_flag,null,SUM ( ETC_LABOR_HRS),0) ETC_LABOR_HRS
10231 , decode(rate_dangling_flag,null,SUM ( ETC_EQUIP_HOURS),0) ETC_EQUIP_HOURS
10232 , decode(rate_dangling_flag,null,SUM ( ETC_LABOR_BRDN_COST),0) ETC_LABOR_BRDN_COST
10233 , decode(rate_dangling_flag,null,SUM ( ETC_EQUIP_BRDN_COST),0) ETC_EQUIP_BRDN_COST
10234 , decode(rate_dangling_flag,null,SUM ( ETC_BRDN_COST),0) ETC_BRDN_COST
10235 , decode(rate_dangling_flag,null,SUM ( ETC_RAW_COST),0) ETC_RAW_COST
10236 , decode(rate_dangling_flag,null,SUM ( ETC_LABOR_raw_COST),0) ETC_LABOR_raw_COST
10237 , decode(rate_dangling_flag,null,SUM ( ETC_EQUIP_raw_COST),0) ETC_EQUIP_raw_COST
10238 , decode(rate_dangling_flag,null,SUM(CUSTOM1),0) CUSTOM1
10239 , decode(rate_dangling_flag,null,SUM(CUSTOM2),0) CUSTOM2
10240 , decode(rate_dangling_flag,null,SUM(CUSTOM3),0) CUSTOM3
10241 , decode(rate_dangling_flag,null,SUM(CUSTOM4),0) CUSTOM4
10242 , decode(rate_dangling_flag,null,SUM(CUSTOM5),0) CUSTOM5
10243 , decode(rate_dangling_flag,null,SUM(CUSTOM6),0) CUSTOM6
10244 , decode(rate_dangling_flag,null,SUM(CUSTOM7),0) CUSTOM7
10245 , decode(rate_dangling_flag,null,SUM(CUSTOM8),0) CUSTOM8
10246 , decode(rate_dangling_flag,null,SUM(CUSTOM9),0) CUSTOM9
10247 , decode(rate_dangling_flag,null,SUM(CUSTOM10),0) CUSTOM10
10248 , decode(rate_dangling_flag,null,SUM(CUSTOM11),0) CUSTOM11
10249 , decode(rate_dangling_flag,null,SUM(CUSTOM12),0) CUSTOM12
10250 , decode(rate_dangling_flag,null,SUM(CUSTOM13),0) CUSTOM13
10251 , decode(rate_dangling_flag,null,SUM(CUSTOM14),0) CUSTOM14
10252 , decode(rate_dangling_flag,null,SUM(CUSTOM15),0) CUSTOM15
10253 , LINE_TYPE
10254 , rate_dangling_flag
10255 , time_dangling_flag
10256 , start_date
10257 , end_date
10258 , g_default_prg_level prg_level
10259 , plan_type_code
10260 FROM
10261 ( SELECT
10262 g_worker_id WORKER_ID
10263 , plr.PROJECT_ID
10264 , plr.PROJECT_ORG_ID
10265 , plr.project_ORGANIZATION_ID
10266 , plr.WBS_ELEMENT_ID
10267 , plr.time_id
10268 , plr.period_type_id -- period type id...
10269 , plr.CALENDAR_TYPE
10270 , g_lowest_level RBS_AGGR_LEVEL
10271 , 'N' WBS_ROLLUP_FLAG
10272 , 'N' PRG_ROLLUP_FLAG
10273 , plr.CURR_RECORD_TYPE
10274 , plr.currency_code
10275 , plr.RBS_ELEMENT_ID
10276 , plr.RBS_STRUCT_VERSION_ID
10277 , plr.plan_version_id
10278 , plr.plan_type_id
10279 , SUM(plr.RAW_COST) RAW_COST
10280 , SUM(plr.BRDN_COST) BRDN_COST
10281 , SUM(plr.REVENUE) REVENUE
10282 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) BILL_RAW_COST
10283 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) BILL_BRDN_COST
10284 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_people_resclass_code, plr.raw_cost, 0 ) ) BILL_LABOR_RAW_COST
10285 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_people_resclass_code , plr.BRDN_COST, 0 ) ) BILL_LABOR_BRDN_COST
10286 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'Y' || g_people_resclass_code, plr.quantity, 0 ) ) BILL_LABOR_HRS */ -- bug 6039785
10287 , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'Y' || g_people_resclass_code,
10288 DECODE ( plr.billable_flag , 'Y' , plr.quantity, 0 ) , 0 ) ) BILL_LABOR_HRS -- bug 6039785
10289 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code , plr.raw_cost, 0 ) ) EQUIPMENT_RAW_COST
10290 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code , plr.BRDN_COST, 0 ) ) EQUIPMENT_BRDN_COST
10291 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) CAPITALIZABLE_RAW_COST
10292 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) CAPITALIZABLE_BRDN_COST
10293 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.raw_cost, 0 ) ) LABOR_RAW_COST
10294 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.BRDN_COST, 0 ) ) LABOR_BRDN_COST
10295 /* , SUM ( DECODE ( plr.resource_class, g_people_resclass_code,
10296 DECODE ( plr.wp_flag, 'N',
10297 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
10298 plr.quantity),
10299 0 ) ) labor_hrs */ -- bug 6039785
10300 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, DECODE( plr.billable_flag , 'Y',
10301 DECODE ( plr.wp_flag, 'N',
10302 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
10303 plr.quantity),
10304 0 ),
10305 0 ) ) labor_hrs -- bug 6039785
10306 , SUM ( DECODE ( plr.resource_class, g_people_resclass_code, plr.revenue, 0 ) ) LABOR_REVENUE
10307 /* , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code,
10308 DECODE ( plr.wp_flag, 'N',
10309 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
10310 plr.quantity),
10311
10312 0 ) ) EQUIPMENT_HOURS */ -- bug 6039785
10313 , SUM ( DECODE ( plr.resource_class, g_equip_resclass_code, DECODE( plr.billable_flag , 'Y',
10314 DECODE ( plr.wp_flag, 'N',
10315 DECODE ( plr.billable_flag, 'Y',plr.quantity,0),
10316 plr.quantity),
10317 0 ),
10318 0 ) ) EQUIPMENT_HOURS -- bug 6039785
10319 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_equip_resclass_code, plr.quantity, 0 ) ) BILLABLE_EQUIPMENT_HOURS */ -- bug 6039785
10320 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'Y' || g_equip_resclass_code,
10321 DECODE ( plr.billable_flag , 'Y' , plr.quantity, 0 ) , 0 ) ) BILLABLE_EQUIPMENT_HOURS -- bug 6039785
10322 , TO_NUMBER(NULL) SUP_INV_COMMITTED_COST
10323 , TO_NUMBER(NULL) PO_COMMITTED_COST
10324 , TO_NUMBER(NULL) PR_COMMITTED_COST
10325 , TO_NUMBER(NULL) OTH_COMMITTED_COST
10326 /* , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
10327 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
10328 0 ) ) ) ACT_LABOR_HRS */ -- bug 6039785
10329 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
10330 DECODE (plr.billable_flag ,'Y',
10331 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
10332 0 ),
10333 0 ) ) ) ACT_LABOR_HRS -- bug 6039785
10334 /* , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
10335 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
10336 0 ) ) ) ACT_EQUIP_HOURS */ -- bug 6039785
10337 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
10338 DECODE (plr.billable_flag ,'Y',
10339 DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,0),
10340 0 ),
10341 0 ) ) ) ACT_EQUIP_HOURS -- bug 6039785
10342 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.actual_BRDN_COST, 0 ) ) ) ACT_LABOR_BRDN_COST
10343 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.actual_BRDN_COST, 0 ) ) ) ACT_EQUIPMENT_BRDN_COST
10344 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, plr.actual_brdn_cost ) ) ACT_BRDN_COST
10345 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, plr.actual_raw_cost ) ) ACT_RAW_COST
10346 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, plr.actual_revenue ) ) ACT_REVENUE
10347 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.actual_RAW_COST, 0 ) ) ) ACT_LABOR_RAW_COST
10348 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.actual_RAW_COST, 0 ) ) ) ACT_EQUIPMENT_RAW_COST
10349 /* , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
10350 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
10351 0 ) ) ) ETC_LABOR_HRS */ -- bug 6039785
10352 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code,
10353 DECODE (plr.billable_flag ,'Y',
10354 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
10355 0 ),
10356 0 ) ) ) ETC_LABOR_HRS -- bug 6039785
10357 /* , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
10358 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
10359 0 ) ) ) ETC_EQUIP_HOURS */ -- bug 6039785
10360 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code,
10361 DECODE (plr.billable_flag ,'Y',
10362 DECODE ( plr.billable_flag, 'Y',plr.ETC_quantity,0),
10363 0 ),
10364 0 ) ) ) ETC_EQUIP_HOURS -- bug 6039785
10365 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.etc_BRDN_COST, 0 ) ) ) ETC_LABOR_BRDN_COST
10366 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.etc_BRDN_COST, 0 ) ) ) ETC_EQUIP_BRDN_COST
10367 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, plr.etc_brdn_cost ) ) ETC_BRDN_COST
10368 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, plr.etc_raw_cost ) ) ETC_RAW_COST
10369 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_people_resclass_code, plr.etc_raw_COST, 0 ) ) ) ETC_LABOR_raw_COST
10370 , SUM ( DECODE ( plr.wp_flag, 'Y', NULL, DECODE ( plr.resource_class, g_equip_resclass_code , plr.etc_raw_COST, 0 ) ) ) ETC_EQUIP_raw_COST
10371 , TO_NUMBER(NULL) CUSTOM1
10372 , TO_NUMBER(NULL) CUSTOM2
10373 , TO_NUMBER(NULL) CUSTOM3
10374 , TO_NUMBER(NULL) CUSTOM4
10375 , TO_NUMBER(NULL) CUSTOM5
10376 , TO_NUMBER(NULL) CUSTOM6
10377 , TO_NUMBER(NULL) CUSTOM7
10378 , TO_NUMBER(NULL) CUSTOM8
10379 , TO_NUMBER(NULL) CUSTOM9
10380 , TO_NUMBER(NULL) CUSTOM10
10381 , TO_NUMBER(NULL) CUSTOM11
10382 , TO_NUMBER(NULL) CUSTOM12
10383 , TO_NUMBER(NULL) CUSTOM13
10384 , TO_NUMBER(NULL) CUSTOM14
10385 , TO_NUMBER(NULL) CUSTOM15
10386 , plr.LINE_TYPE
10387 , decode(sign(plr.rate),-1,'Y',NULL) ||decode(sign(plr.rate2),-1,'Y',NULL) rate_dangling_flag
10388 , NULL time_dangling_flag
10389 , plr.start_date
10390 , plr.end_date
10391 , g_default_prg_level prg_level
10392 ,plr.plan_type_code plan_type_code /*4471527 */
10393 FROM
10394 ( ----- First inline view plr .............
10395 select
10396 collapse_bl.PROJECT_ID -- , 1 partition_id
10397 , collapse_bl.WBS_ELEMENT_ID -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
10398 , SUM(collapse_bl.CURR_RECORD_TYPE_ID) CURR_RECORD_TYPE
10399 , collapse_bl.RBS_ELEMENT_ID
10400 , collapse_bl.RBS_STRUCT_VERSION_ID
10401 , collapse_bl.plan_type_id
10402 , collapse_bl.plan_version_id
10403 , collapse_bl.time_id
10404 , collapse_bl.PROJECT_ORGANIZATION_ID
10405 , collapse_bl.PROJECT_ORG_ID
10406 , collapse_bl.RESOURCE_ASSIGNMENT_ID
10407 , collapse_bl.BILLABLE_FLAG
10408 , collapse_bl.RESOURCE_CLASS -- , CALENDAR_TYPE -- , CALENDAR_ID
10409 , collapse_bl.TIME_PHASED_TYPE_CODE
10410 , collapse_bl.CURRENCY_CODE
10411 , max(collapse_bl.raw_cost) raw_cost
10412 , max(collapse_bl.BRDN_COST) BRDN_COST
10413 , max(collapse_bl.revenue) revenue
10414 , max(collapse_bl.actual_raw_cost) actual_raw_cost
10415 , max(collapse_bl.actual_BRDN_COST) actual_BRDN_COST
10416 , max(collapse_bl.actual_revenue) actual_revenue
10417 , max(collapse_bl.etc_raw_cost) etc_raw_cost
10418 , max(collapse_bl.etc_BRDN_COST) etc_BRDN_COST
10419 , max(collapse_bl.etc_revenue) etc_revenue
10420 , max(collapse_bl.quantity) quantity
10421 , max(collapse_bl.actual_quantity) actual_quantity
10422 , max(collapse_bl.etc_quantity) etc_quantity
10423 , collapse_bl.start_date start_date
10424 , collapse_bl.end_date end_date
10425 -- , collapse_bl.period_name period_name -- , TRACK_AS_LABOR_FLAG track_as_labor_flag
10426 , collapse_bl.line_type
10427 , collapse_bl.calendar_type
10428 , collapse_bl.period_type_id
10429 , collapse_bl.row_id
10430 ,collapse_bl.rate rate
10431 ,collapse_bl.rate2 rate2
10432 , collapse_bl.plan_type_code plan_type_code
10433 , collapse_bl.WP_FLAG
10434 from
10435 ( ----- Second inline view 'collapse_bl' begin .............
10436 select
10437 spread_bl.row_id row_id
10438 , spread_bl.PROJECT_ID
10439 , spread_bl.BUDGET_VERSION_ID plan_version_id
10440 , spread_bl.time_id
10441 , spread_bl.RESOURCE_ASSIGNMENT_ID
10442 , spread_bl.WBS_ELEMENT_ID
10443 , spread_bl.RBS_ELEMENT_ID
10444 , spread_bl.WBS_STRUCT_VERSION_ID
10445 , spread_bl.RBS_STRUCT_VERSION_ID
10446 , spread_bl.plan_type_id
10447 , spread_bl.BILLABLE_FLAG
10448 , spread_bl.RESOURCE_CLASS
10449 , spread_bl.PROJECT_ORGANIZATION_ID
10450 , spread_bl.PROJECT_ORG_ID
10451 , spread_bl.TIME_PHASED_TYPE_CODE
10452 , DECODE( invert.INVERT_ID
10453 , 1, spread_bl.glb1_CURRENCY_CODE
10454 , 2, spread_bl.glb2_CURRENCY_CODE
10455 , 4, spread_bl.func_CURRENCY_CODE
10456 , 8, spread_bl.PRJ_CURRENCY_CODE
10457 , 16, spread_bl.TXN_CURRENCY_CODE ) CURRENCY_CODE
10458 , invert.INVERT_ID CURR_RECORD_TYPE_ID
10459 , DECODE ( invert.INVERT_ID
10460 , 1, spread_bl.glb1_raw_cost
10461 , 2, spread_bl.glb2_raw_cost
10462 , 4, spread_bl.func_raw_cost
10463 , 8, spread_bl.PRJ_raw_cost
10464 , 16, spread_bl.TXN_raw_cost) raw_cost
10465 , DECODE ( invert.INVERT_ID
10466 , 1, spread_bl.glb1_brdn_cost
10467 , 2, spread_bl.glb2_brdn_cost
10468 , 4, spread_bl.func_BRDN_COST
10469 , 8, spread_bl.PRJ_BRDN_COST
10470 , 16, spread_bl.TXN_BRDN_COST ) BRDN_COST
10471 , DECODE ( invert.INVERT_ID
10472 , 1, spread_bl.glb1_revenue
10473 , 2, spread_bl.glb2_revenue
10474 , 4, spread_bl.func_revenue
10475 , 8, spread_bl.PRJ_revenue
10476 , 16, spread_bl.TXN_revenue ) revenue
10477 , DECODE ( invert.INVERT_ID
10478 , 1, spread_bl.glb1_actual_raw_cost
10479 , 2, spread_bl.glb2_actual_raw_cost
10480 , 4, spread_bl.func_actual_raw_cost
10481 , 8, spread_bl.prj_actual_raw_cost
10482 , 16, spread_bl.txn_actual_raw_cost ) actual_raw_cost
10483 , DECODE ( invert.INVERT_ID
10484 , 1, spread_bl.glb1_actual_brdn_cost
10485 , 2, spread_bl.glb2_actual_brdn_cost
10486 , 4, spread_bl.func_actual_brdn_cost
10487 , 8, spread_bl.prj_actual_brdn_cost
10488 , 16, spread_bl.txn_actual_brdn_cost ) actual_brdn_cost
10489 , DECODE ( invert.INVERT_ID
10490 , 1, spread_bl.glb1_actual_revenue
10491 , 2, spread_bl.glb2_actual_revenue
10492 , 4, spread_bl.func_actual_revenue
10493 , 8, spread_bl.prj_actual_revenue
10494 , 16, spread_bl.txn_actual_revenue ) actual_revenue
10495 , DECODE ( invert.INVERT_ID
10496 , 1, spread_bl.glb1_etc_raw_cost
10497 , 2, spread_bl.glb2_etc_raw_cost
10498 , 4, spread_bl.func_etc_raw_cost
10499 , 8, spread_bl.prj_etc_raw_cost
10500 , 16, spread_bl.txn_etc_raw_cost ) etc_raw_cost
10501 , DECODE ( invert.INVERT_ID
10502 , 1, spread_bl.glb1_etc_brdn_cost
10503 , 2, spread_bl.glb2_etc_brdn_cost
10504 , 4, spread_bl.func_etc_brdn_cost
10505 , 8, spread_bl.prj_etc_brdn_cost
10506 , 16, spread_bl.txn_etc_brdn_cost ) etc_brdn_cost
10507 , DECODE ( invert.INVERT_ID
10508 , 1, spread_bl.glb1_etc_revenue
10509 , 2, spread_bl.glb2_etc_revenue
10510 , 4, spread_bl.func_etc_revenue
10511 , 8, spread_bl.prj_etc_revenue
10512 , 16, spread_bl.txn_etc_revenue ) etc_revenue
10513 , spread_bl.quantity quantity
10514 , spread_bl.actual_quantity actual_quantity
10515 , spread_bl.etc_quantity etc_quantity
10516 , spread_bl.start_date start_date
10517 , spread_bl.end_date end_date
10518 , spread_bl.line_type line_type
10519 , spread_bl.period_type_id
10520 , spread_bl.calendar_type
10521 ,decode(invert.invert_id,1,spread_bl.rate,1) rate
10522 ,decode(invert.invert_id,2,spread_bl.rate2,1) rate2
10523 , spread_bl.plan_type_code plan_type_code /*4471527 */
10524 , spread_bl.WP_FLAG
10525 from
10526 ( ----- Third inline view 'spread_bl' .............
10527 SELECT /*+ ordered */
10528 ra.project_id
10529 , bl.rowid row_id
10530 , ra.budget_version_id
10531 , prd.cal_period_id time_id
10532 , bl.resource_asSIGNment_id
10533 , DECODE(ra.task_id, 0, pevs.proj_element_id, ra.task_id) wbs_element_id
10534 , NVL(ra.rbs_element_id, -1) rbs_element_id
10535 , ver.wbs_struct_version_id wbs_struct_version_id
10536 , NVL(ver.rbs_struct_version_id, -1) rbs_struct_version_id
10537 , ver.plan_type_id plan_type_id
10538 , ra.rate_based_flag billable_flag
10539 -- cbs change
10540 , 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',
10541 '1'||ra.resource_class_code, ra.resource_class_code),ra.resource_class_code) resource_class
10542 -- End cbs change
10543 , DECODE(ver.time_phased_type_code
10544 , g_pa_cal_str, 32
10545 , g_gl_cal_str, 32
10546 , 'N', 2048
10547 , -1) period_type_id
10548 , DECODE(ver.time_phased_type_code
10549 , g_pa_cal_str, g_pa_cal_str
10550 , g_gl_cal_str, g_gl_cal_str
10551 , 'N', g_all
10552 , 'X') CALENDAR_TYPE
10553 , bl.txn_currency_code txn_currency_code
10554 , bl.txn_raw_cost txn_raw_cost
10555 , bl.txn_burdened_COST txn_brdn_COST
10556 , bl.txn_revenue txn_revenue
10557 , DECODE(ver.wp_flag, 'N', bl.txn_init_raw_cost, TO_NUMBER(NULL)) txn_actual_raw_cost -- new
10558 , DECODE(ver.wp_flag, 'N', bl.txn_init_burdened_cost, TO_NUMBER(NULL)) txn_actual_brdn_cost -- new
10559 , DECODE(ver.wp_flag, 'N', bl.txn_init_revenue, TO_NUMBER(NULL)) txn_actual_revenue -- new
10560 , DECODE(ver.wp_flag, 'N', (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0)), TO_NUMBER(NULL)) txn_etc_raw_cost -- new
10561 , DECODE(ver.wp_flag, 'N', (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0)), TO_NUMBER(NULL)) txn_etc_brdn_cost -- new
10562 , DECODE(ver.wp_flag, 'N', (bl.txn_revenue - NVL(bl.txn_init_revenue, 0)), TO_NUMBER(NULL)) txn_etc_revenue -- new
10563 , bl.project_currency_code prj_currency_code
10564 , bl.project_raw_cost prj_raw_cost
10565 , bl.project_burdened_COST prj_BRDN_COST
10566 , bl.project_revenue prj_revenue
10567 , DECODE(ver.wp_flag, 'N', bl.project_init_raw_cost, TO_NUMBER(NULL)) prj_actual_raw_cost -- new
10568 , DECODE(ver.wp_flag, 'N', bl.project_init_burdened_cost, TO_NUMBER(NULL)) prj_actual_brdn_cost -- new
10569 , DECODE(ver.wp_flag, 'N', bl.project_init_revenue, TO_NUMBER(NULL)) prj_actual_revenue -- new
10570 , DECODE(ver.wp_flag, 'N', (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0)), TO_NUMBER(NULL)) prj_etc_raw_cost -- new
10571 , DECODE(ver.wp_flag, 'N', (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0)), TO_NUMBER(NULL)) prj_etc_brdn_cost -- new
10572 , DECODE(ver.wp_flag, 'N', (bl.project_revenue - NVL(bl.project_init_revenue, 0)), TO_NUMBER(NULL)) prj_etc_revenue -- new
10573 , bl.projfunc_currency_code func_currency_code
10574 , bl.raw_cost func_raw_cost
10575 , bl.burdened_COST func_BRDN_COST
10576 , bl.revenue func_revenue
10577 , DECODE(ver.wp_flag, 'N', bl.init_raw_cost , TO_NUMBER(NULL)) func_actual_raw_cost -- new
10578 , DECODE(ver.wp_flag, 'N', bl.init_burdened_cost , TO_NUMBER(NULL)) func_actual_brdn_cost -- new
10579 , DECODE(ver.wp_flag, 'N', bl.init_revenue , TO_NUMBER(NULL)) func_actual_revenue -- new
10580 , DECODE(ver.wp_flag, 'N', (bl.raw_cost - NVL(bl.init_raw_cost, 0)), TO_NUMBER(NULL)) func_etc_raw_cost -- new
10581 , DECODE(ver.wp_flag, 'N', (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)), TO_NUMBER(NULL)) func_etc_brdn_cost -- new
10582 , DECODE(ver.wp_flag, 'N', (bl.revenue - NVL(bl.init_revenue, 0)), TO_NUMBER(NULL)) func_etc_revenue -- new
10583 , g_global1_currency_code glb1_currency_code -- g_global1_currency_code glb1_currency_code
10584 , DECODE (g_global1_currency_code
10585 , bl.txn_currency_code
10586 , bl.txn_raw_cost
10587 , bl.project_currency_code
10588 , bl.project_raw_cost
10589 , bl.projfunc_currency_code
10590 , bl.raw_cost
10591 , ROUND((rates.rate * raw_cost )/rates.mau)*rates.mau
10592 ) glb1_raw_cost
10593 , DECODE (g_global1_currency_code
10594 , bl.txn_currency_code
10595 , bl.txn_burdened_cost
10596 , bl.project_currency_code
10597 , bl.project_burdened_cost
10598 , bl.projfunc_currency_code
10599 , bl.burdened_cost
10600 , ROUND((rates.rate * burdened_cost )/rates.mau)*rates.mau
10601 ) glb1_BRDN_COST
10602 , DECODE (g_global1_currency_code
10603 , bl.txn_currency_code
10604 , bl.txn_revenue
10605 , bl.project_currency_code
10606 , bl.project_revenue
10607 , bl.projfunc_currency_code
10608 , bl.revenue
10609 , ROUND((rates.rate * revenue )/rates.mau)*rates.mau
10610 ) glb1_revenue
10611 , DECODE(ver.wp_flag
10612 , 'N'
10613 , DECODE (g_global1_currency_code
10614 , bl.txn_currency_code
10615 , bl.txn_init_raw_cost
10616 , bl.project_currency_code
10617 , bl.project_init_raw_cost
10618 , bl.projfunc_currency_code
10619 , bl.init_raw_cost
10620 , ROUND((rates.rate * bl.init_raw_cost )/rates.mau)*rates.mau
10621 )
10622 , NULL) glb1_actual_raw_cost
10623 , DECODE(ver.wp_flag
10624 , 'N'
10625 , DECODE (g_global1_currency_code
10626 , bl.txn_currency_code
10627 , bl.txn_init_burdened_cost
10628 , bl.project_currency_code
10629 , bl.project_init_burdened_cost
10630 , bl.projfunc_currency_code
10631 , bl.init_burdened_cost
10632 , ROUND((rates.rate * bl.init_burdened_cost )/rates.mau)*rates.mau
10633 )
10634 , NULL) glb1_actual_brdn_cost
10635 , DECODE(ver.wp_flag
10636 , 'N'
10637 , DECODE (g_global1_currency_code
10638 , bl.txn_currency_code
10639 , bl.txn_init_revenue
10640 , bl.project_currency_code
10641 , bl.project_init_revenue
10642 , bl.projfunc_currency_code
10643 , bl.init_revenue
10644 , ROUND((rates.rate * bl.init_revenue )/rates.mau)*rates.mau
10645 )
10646 , NULL) glb1_actual_revenue
10647 , DECODE(ver.wp_flag
10648 , 'N'
10649 , DECODE (g_global1_currency_code
10650 , bl.txn_currency_code
10651 , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0))
10652 , bl.project_currency_code
10653 , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0))
10654 , bl.projfunc_currency_code
10655 , (bl.raw_cost - NVL(bl.init_raw_cost, 0))
10656 , ROUND((rates.rate * (bl.raw_cost - NVL(bl.init_raw_cost, 0)) )/rates.mau)*rates.mau
10657 )
10658 , NULL) glb1_etc_raw_cost
10659 , DECODE(ver.wp_flag
10660 , 'N'
10661 , DECODE (g_global1_currency_code
10662 , bl.txn_currency_code
10663 , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0))
10664 , bl.project_currency_code
10665 , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0))
10666 , bl.projfunc_currency_code
10667 , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0))
10668 , ROUND((rates.rate * (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)) )/rates.mau)*rates.mau
10669 )
10670 , NULL) glb1_etc_brdn_cost
10671 , DECODE(ver.wp_flag
10672 , 'N'
10673 , DECODE (g_global1_currency_code
10674 , bl.txn_currency_code
10675 , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0))
10676 , bl.project_currency_code
10677 , (bl.project_revenue - NVL(bl.project_init_revenue, 0))
10678 , bl.projfunc_currency_code
10679 , (bl.revenue - NVL(bl.init_revenue, 0))
10680 , ROUND((rates.rate * (bl.revenue - NVL(bl.init_revenue, 0)) )/rates.mau)*rates.mau
10681 )
10682 , NULL) glb1_etc_revenue
10683 , g_global2_currency_code glb2_currency_code -- g_global2_currency_code glb2_currency_code
10684 , DECODE (g_global2_currency_code
10685 , bl.txn_currency_code
10686 , bl.txn_raw_cost
10687 , bl.project_currency_code
10688 , bl.project_raw_cost
10689 , bl.projfunc_currency_code
10690 , bl.raw_cost
10691 , ROUND((rates.rate2 * raw_cost )/rates.mau2)*rates.mau2
10692 ) glb2_raw_cost
10693 , DECODE (g_global2_currency_code
10694 , bl.txn_currency_code
10695 , bl.txn_burdened_cost
10696 , bl.project_currency_code
10697 , bl.project_burdened_cost
10698 , bl.projfunc_currency_code
10699 , bl.burdened_cost
10700 , ROUND((rates.rate2 * burdened_cost )/rates.mau2)*rates.mau2
10701 ) glb2_BRDN_COST
10702 , DECODE (g_global2_currency_code
10703 , bl.txn_currency_code
10704 , bl.txn_revenue
10705 , bl.project_currency_code
10706 , bl.project_revenue
10707 , bl.projfunc_currency_code
10708 , bl.revenue
10709 , ROUND((rates.rate2 * revenue )/rates.mau2)*rates.mau2
10710 ) glb2_revenue
10711 , DECODE(ver.wp_flag
10712 , 'N'
10713 , DECODE (g_global2_currency_code
10714 , bl.txn_currency_code
10715 , bl.txn_init_raw_cost
10716 , bl.project_currency_code
10717 , bl.project_init_raw_cost
10718 , bl.projfunc_currency_code
10719 , bl.init_raw_cost
10720 , ROUND((rates.rate2 * bl.init_raw_cost )/rates.mau2)*rates.mau2
10721 )
10722 , TO_NUMBER(NULL)) glb2_actual_raw_cost
10723 , DECODE(ver.wp_flag
10724 , 'N'
10725 , DECODE (g_global2_currency_code
10726 , bl.txn_currency_code
10727 , bl.txn_init_burdened_cost
10728 , bl.project_currency_code
10729 , bl.project_init_burdened_cost
10730 , bl.projfunc_currency_code
10731 , bl.init_burdened_cost
10732 , ROUND((rates.rate2 * bl.init_burdened_cost )/rates.mau2)*rates.mau2
10733 )
10734 , TO_NUMBER(NULL)) glb2_actual_brdn_cost
10735 , DECODE(ver.wp_flag
10736 , 'N'
10737 , DECODE (g_global2_currency_code
10738 , bl.txn_currency_code
10739 , bl.txn_init_revenue
10740 , bl.project_currency_code
10741 , bl.project_init_revenue
10742 , bl.projfunc_currency_code
10743 , bl.init_revenue
10744 , ROUND((rates.rate2 * bl.init_revenue )/rates.mau2)*rates.mau2
10745 )
10746 , TO_NUMBER(NULL)) glb2_actual_revenue
10747 , DECODE(ver.wp_flag
10748 , 'N'
10749 , DECODE (g_global2_currency_code
10750 , bl.txn_currency_code
10751 , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0))
10752 , bl.project_currency_code
10753 , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0))
10754 , bl.projfunc_currency_code
10755 , (bl.raw_cost - NVL(bl.init_raw_cost, 0))
10756 , ROUND((rates.rate2 * (bl.raw_cost - NVL(bl.init_raw_cost, 0)) )/rates.mau2)*rates.mau2
10757 )
10758 , TO_NUMBER(NULL)) glb2_etc_raw_cost
10759 , DECODE(ver.wp_flag
10760 , 'N'
10761 , DECODE (g_global2_currency_code
10762 , bl.txn_currency_code
10763 , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0))
10764 , bl.project_currency_code
10765 , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0))
10766 , bl.projfunc_currency_code
10767 , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0))
10768 , ROUND((rates.rate2 * (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)) )/rates.mau2)*rates.mau2
10769 )
10770 , TO_NUMBER(NULL)) glb2_etc_brdn_cost
10771 , DECODE(ver.wp_flag
10772 , 'N'
10773 , DECODE (g_global2_currency_code
10774 , bl.txn_currency_code
10775 , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0))
10776 , bl.project_currency_code
10777 , (bl.project_revenue - NVL(bl.project_init_revenue, 0))
10778 , bl.projfunc_currency_code
10779 , (bl.revenue - NVL(bl.init_revenue, 0))
10780 , ROUND((rates.rate2 * (bl.revenue - NVL(bl.init_revenue, 0)) )/rates.mau2)*rates.mau2
10781 )
10782 , TO_NUMBER(NULL)) glb2_etc_revenue
10783 , bl.quantity quantity
10784 , DECODE(ver.wp_flag, 'N', bl.init_quantity, TO_NUMBER(NULL)) actual_quantity -- new
10785 , DECODE(ver.wp_flag, 'N', (bl.quantity - NVL(bl.init_quantity, 0)), TO_NUMBER(NULL)) etc_quantity -- new
10786 , TO_DATE(NULL) start_date -- bl.start_date
10787 , TO_DATE(NULL) end_date -- bl.END_date
10788 , ver.time_phased_type_code time_phased_type_code
10789 , ppa.org_id project_org_id
10790 , ppa.carrying_out_organization_id project_organization_id
10791 , DECODE(ver.time_phased_type_code, g_pa_cal_str, 'OF', g_gl_cal_str, 'OF', 'N', 'NTP', 'X') line_type
10792 ,decode(ver.rate_dangling_flag,'Y',-1,1) rate
10793 ,decode(ver.rate_dangling_flag,'Y',-1,1) rate2
10794 , ver.plan_type_code plan_type_code /*4471527 */
10795 , ver.WP_FLAG
10796 FROM
10797 PJI_FM_EXTR_PLNVER4 ver
10798 , pa_resource_asSIGNments ra
10799 , PA_BUDGET_LINES bl
10800 , pa_projects_all ppa
10801 , PJI_ORG_EXTR_INFO oei
10802 , pji_time_cal_period_v prd
10803 , PJI_FM_AGGR_DLY_RATES rates
10804 , PA_PROJ_ELEM_VER_STRUCTURE pevs
10805 WHERE 1=1
10806 AND ra.resource_asSIGNment_id = bl.resource_asSIGNment_id
10807 AND ra.project_id = ver.PROJECT_ID
10808 AND ra.budget_version_id = ver.plan_version_id
10809 AND ver.project_id = ppa.project_id
10810 AND txn_currency_code IS NOT NULL
10811 AND bl.project_currency_code IS NOT NULL
10812 AND bl.projfunc_currency_code IS NOT NULL
10813 AND pevs.element_version_id = ver.wbs_struct_version_id
10814 AND ver.project_id = pevs.project_id
10815 AND ver.secondary_rbs_flag = 'N'
10816 AND ver.wp_flag = 'N'
10817 AND ver.baselined_flag = 'Y'
10818 AND oei.org_id = ppa.org_id
10819 AND ver.time_phased_type_code IN (g_pa_cal_str, g_gl_cal_str)
10820 AND DECODE ( ver.time_phased_type_code
10821 , g_pa_cal_str, oei.pa_calendar_id
10822 , g_gl_cal_str, oei.gl_calendar_id) = prd.calendar_id
10823 AND bl.period_name = prd.name
10824 AND rates.time_id = prd.cal_period_id
10825 AND rates.worker_id = g_worker_id
10826 AND rates.pf_currency_code = bl.projfunc_currency_code -- 4764334
10827 AND ver.worker_id = g_worker_id
10828 UNION ALL
10829 SELECT /*+ ordered */
10830 ra.project_id
10831 , bl.rowid row_id
10832 , ra.budget_version_id
10833 , -1 time_id
10834 , bl.resource_asSIGNment_id
10835 , DECODE(ra.task_id, 0, pevs.proj_element_id, ra.task_id) wbs_element_id
10836 , NVL(ra.rbs_element_id, -1) rbs_element_id
10837 , ver.wbs_struct_version_id wbs_struct_version_id
10838 , NVL(ver.rbs_struct_version_id, -1) rbs_struct_version_id
10839 , ver.plan_type_id plan_type_id
10840 , ra.rate_based_flag billable_flag
10841 -- cbs change
10842 , 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',
10843 '1'||ra.resource_class_code, ra.resource_class_code),ra.resource_class_code) resource_class
10844 -- End cbs change
10845 , 2048 period_type_id
10846 , g_all CALENDAR_TYPE
10847 , bl.txn_currency_code txn_currency_code
10848 , bl.txn_raw_cost txn_raw_cost
10849 , bl.txn_burdened_COST txn_brdn_COST
10850 , bl.txn_revenue txn_revenue
10851 , DECODE(ver.wp_flag, 'N' , bl.txn_init_raw_cost, TO_NUMBER(NULL)) txn_actual_raw_cost -- new
10852 , DECODE(ver.wp_flag, 'N' , bl.txn_init_burdened_cost, TO_NUMBER(NULL)) txn_actual_brdn_cost -- new
10853 , DECODE(ver.wp_flag, 'N' , bl.txn_init_revenue, TO_NUMBER(NULL)) txn_actual_revenue -- new
10854 , DECODE(ver.wp_flag, 'N' , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0)), TO_NUMBER(NULL)) txn_etc_raw_cost -- new
10855 , DECODE(ver.wp_flag, 'N' , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0)), TO_NUMBER(NULL)) txn_etc_brdn_cost -- new
10856 , DECODE(ver.wp_flag, 'N' , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0)), TO_NUMBER(NULL)) txn_etc_revenue -- new
10857 , bl.project_currency_code prj_currency_code
10858 , bl.project_raw_cost prj_raw_cost
10859 , bl.project_burdened_COST prj_BRDN_COST
10860 , bl.project_revenue prj_revenue
10861 , DECODE(ver.wp_flag, 'N' , bl.project_init_raw_cost, TO_NUMBER(NULL)) prj_actual_raw_cost -- new
10862 , DECODE(ver.wp_flag, 'N' , bl.project_init_burdened_cost, TO_NUMBER(NULL)) prj_actual_brdn_cost -- new
10863 , DECODE(ver.wp_flag, 'N' , bl.project_init_revenue, TO_NUMBER(NULL)) prj_actual_revenue -- new
10864 , DECODE(ver.wp_flag, 'N' , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0)), TO_NUMBER(NULL)) prj_etc_raw_cost -- new
10865 , DECODE(ver.wp_flag, 'N' , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0)), TO_NUMBER(NULL)) prj_etc_brdn_cost -- new
10866 , DECODE(ver.wp_flag, 'N' , (bl.project_revenue - NVL(bl.project_init_revenue, 0)), TO_NUMBER(NULL)) prj_etc_revenue -- new
10867 , bl.projfunc_currency_code func_currency_code
10868 , bl.raw_cost func_raw_cost
10869 , bl.burdened_COST func_BRDN_COST
10870 , bl.revenue func_revenue
10871 , DECODE(ver.wp_flag, 'N' , bl.init_raw_cost , TO_NUMBER(NULL)) func_actual_raw_cost -- new
10872 , DECODE(ver.wp_flag, 'N' , bl.init_burdened_cost , TO_NUMBER(NULL)) func_actual_brdn_cost -- new
10873 , DECODE(ver.wp_flag, 'N' , bl.init_revenue , TO_NUMBER(NULL)) func_actual_revenue -- new
10874 , DECODE(ver.wp_flag, 'N' , (bl.raw_cost - NVL(bl.init_raw_cost, 0)), TO_NUMBER(NULL)) func_etc_raw_cost -- new
10875 , DECODE(ver.wp_flag, 'N' , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)), TO_NUMBER(NULL)) func_etc_brdn_cost -- new
10876 , DECODE(ver.wp_flag, 'N' , (bl.revenue - NVL(bl.init_revenue, 0)), TO_NUMBER(NULL)) func_etc_revenue -- new
10877 , g_global1_currency_code glb1_currency_code -- g_global1_currency_code glb1_currency_code
10878 , DECODE (g_global1_currency_code
10879 , bl.txn_currency_code
10880 , bl.txn_raw_cost
10881 , bl.project_currency_code
10882 , bl.project_raw_cost
10883 , bl.projfunc_currency_code
10884 , bl.raw_cost
10885 , ROUND((rates.rate * raw_cost )/rates.mau)*rates.mau
10886 ) glb1_raw_cost
10887 , DECODE (g_global1_currency_code
10888 , bl.txn_currency_code
10889 , bl.txn_burdened_cost
10890 , bl.project_currency_code
10891 , bl.project_burdened_cost
10892 , bl.projfunc_currency_code
10893 , bl.burdened_cost
10894 , ROUND((rates.rate * burdened_cost )/rates.mau)*rates.mau
10895 ) glb1_BRDN_COST
10896 , DECODE (g_global1_currency_code
10897 , bl.txn_currency_code
10898 , bl.txn_revenue
10899 , bl.project_currency_code
10900 , bl.project_revenue
10901 , bl.projfunc_currency_code
10902 , bl.revenue
10903 , ROUND((rates.rate * revenue )/rates.mau)*rates.mau
10904 ) glb1_revenue
10905 , DECODE(ver.wp_flag
10906 , 'N'
10907 , DECODE (g_global1_currency_code
10908 , bl.txn_currency_code
10909 , bl.txn_init_raw_cost
10910 , bl.project_currency_code
10911 , bl.project_init_raw_cost
10912 , bl.projfunc_currency_code
10913 , bl.init_raw_cost
10914 , ROUND((rates.rate * bl.init_raw_cost )/rates.mau)*rates.mau
10915 )
10916 , NULL) glb1_actual_raw_cost
10917 , DECODE(ver.wp_flag
10918 , 'N'
10919 , DECODE (g_global1_currency_code
10920 , bl.txn_currency_code
10921 , bl.txn_init_burdened_cost
10922 , bl.project_currency_code
10923 , bl.project_init_burdened_cost
10924 , bl.projfunc_currency_code
10925 , bl.init_burdened_cost
10926 , ROUND((rates.rate * bl.init_burdened_cost )/rates.mau)*rates.mau
10927 )
10928 , NULL) glb1_actual_brdn_cost
10929 , DECODE(ver.wp_flag
10930 , 'N'
10931 , DECODE (g_global1_currency_code
10932 , bl.txn_currency_code
10933 , bl.txn_init_revenue
10934 , bl.project_currency_code
10935 , bl.project_init_revenue
10936 , bl.projfunc_currency_code
10937 , bl.init_revenue
10938 , ROUND((rates.rate * bl.init_revenue )/rates.mau)*rates.mau
10939 )
10940 , NULL) glb1_actual_revenue
10941 , DECODE(ver.wp_flag
10942 , 'N'
10943 , DECODE (g_global1_currency_code
10944 , bl.txn_currency_code
10945 , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0))
10946 , bl.project_currency_code
10947 , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0))
10948 , bl.projfunc_currency_code
10949 , (bl.raw_cost - NVL(bl.init_raw_cost, 0))
10950 , ROUND((rates.rate * (bl.raw_cost - NVL(bl.init_raw_cost, 0)) )/rates.mau)*rates.mau
10951 )
10952 , NULL) glb1_etc_raw_cost
10953 , DECODE(ver.wp_flag
10954 , 'N'
10955 , DECODE (g_global1_currency_code
10956 , bl.txn_currency_code
10957 , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0))
10958 , bl.project_currency_code
10959 , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0))
10960 , bl.projfunc_currency_code
10961 , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0))
10962 , ROUND((rates.rate * (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)) )/rates.mau)*rates.mau
10963 )
10964 , NULL) glb1_etc_brdn_cost
10965 , DECODE(ver.wp_flag
10966 , 'N'
10967 , DECODE (g_global1_currency_code
10968 , bl.txn_currency_code
10969 , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0))
10970 , bl.project_currency_code
10971 , (bl.project_revenue - NVL(bl.project_init_revenue, 0))
10972 , bl.projfunc_currency_code
10973 , (bl.revenue - NVL(bl.init_revenue, 0))
10974 , ROUND((rates.rate * (bl.revenue - NVL(bl.init_revenue, 0)) )/rates.mau)*rates.mau
10975 )
10976 , NULL) glb1_etc_revenue
10977 , g_global2_currency_code glb2_currency_code -- g_global2_currency_code glb2_currency_code
10978 , DECODE (g_global2_currency_code
10979 , bl.txn_currency_code
10980 , bl.txn_raw_cost
10981 , bl.project_currency_code
10982 , bl.project_raw_cost
10983 , bl.projfunc_currency_code
10984 , bl.raw_cost
10985 , ROUND((rates.rate2 * raw_cost )/rates.mau2)*rates.mau2
10986 ) glb2_raw_cost
10987 , DECODE (g_global2_currency_code
10988 , bl.txn_currency_code
10989 , bl.txn_burdened_cost
10990 , bl.project_currency_code
10991 , bl.project_burdened_cost
10992 , bl.projfunc_currency_code
10993 , bl.burdened_cost
10994 , ROUND((rates.rate2 * burdened_cost )/rates.mau2)*rates.mau2
10995 ) glb2_BRDN_COST
10996 , DECODE (g_global2_currency_code
10997 , bl.txn_currency_code
10998 , bl.txn_revenue
10999 , bl.project_currency_code
11000 , bl.project_revenue
11001 , bl.projfunc_currency_code
11002 , bl.revenue
11003 , ROUND((rates.rate2 * revenue )/rates.mau2)*rates.mau2
11004 ) glb2_revenue
11005 , DECODE(ver.wp_flag
11006 , 'N'
11007 , DECODE (g_global2_currency_code
11008 , bl.txn_currency_code
11009 , bl.txn_init_raw_cost
11010 , bl.project_currency_code
11011 , bl.project_init_raw_cost
11012 , bl.projfunc_currency_code
11013 , bl.init_raw_cost
11014 , ROUND((rates.rate2 * bl.init_raw_cost )/rates.mau2)*rates.mau2
11015 )
11016 , TO_NUMBER(NULL)) glb2_actual_raw_cost
11017 , DECODE(ver.wp_flag
11018 , 'N'
11019 , DECODE (g_global2_currency_code
11020 , bl.txn_currency_code
11021 , bl.txn_init_burdened_cost
11022 , bl.project_currency_code
11023 , bl.project_init_burdened_cost
11024 , bl.projfunc_currency_code
11025 , bl.init_burdened_cost
11026 , ROUND((rates.rate2 * bl.init_burdened_cost )/rates.mau2)*rates.mau2
11027 )
11028 , TO_NUMBER(NULL)) glb2_actual_brdn_cost
11029 , DECODE(ver.wp_flag
11030 , 'N'
11031 , DECODE (g_global2_currency_code
11032 , bl.txn_currency_code
11033 , bl.txn_init_revenue
11034 , bl.project_currency_code
11035 , bl.project_init_revenue
11036 , bl.projfunc_currency_code
11037 , bl.init_revenue
11038 , ROUND((rates.rate2 * bl.init_revenue )/rates.mau2)*rates.mau2
11039 )
11040 , TO_NUMBER(NULL)) glb2_actual_revenue
11041 , DECODE(ver.wp_flag
11042 , 'N'
11043 , DECODE (g_global2_currency_code
11044 , bl.txn_currency_code
11045 , (bl.txn_raw_cost - NVL(bl.txn_init_raw_cost, 0))
11046 , bl.project_currency_code
11047 , (bl.project_raw_cost - NVL(bl.project_init_raw_cost, 0))
11048 , bl.projfunc_currency_code
11049 , (bl.raw_cost - NVL(bl.init_raw_cost, 0))
11050 , ROUND((rates.rate2 * (bl.raw_cost - NVL(bl.init_raw_cost, 0)) )/rates.mau2)*rates.mau2
11051 )
11052 , TO_NUMBER(NULL)) glb2_etc_raw_cost
11053 , DECODE(ver.wp_flag
11054 , 'N'
11055 , DECODE (g_global2_currency_code
11056 , bl.txn_currency_code
11057 , (bl.txn_burdened_cost - NVL(bl.txn_init_burdened_cost, 0))
11058 , bl.project_currency_code
11059 , (bl.project_burdened_cost - NVL(bl.project_init_burdened_cost, 0))
11060 , bl.projfunc_currency_code
11061 , (bl.burdened_cost - NVL(bl.init_burdened_cost, 0))
11062 , ROUND((rates.rate2 * (bl.burdened_cost - NVL(bl.init_burdened_cost, 0)) )/rates.mau2)*rates.mau2
11063 )
11064 , TO_NUMBER(NULL)) glb2_etc_brdn_cost
11065 , DECODE(ver.wp_flag
11066 , 'N'
11067 , DECODE (g_global2_currency_code
11068 , bl.txn_currency_code
11069 , (bl.txn_revenue - NVL(bl.txn_init_revenue, 0))
11070 , bl.project_currency_code
11071 , (bl.project_revenue - NVL(bl.project_init_revenue, 0))
11072 , bl.projfunc_currency_code
11073 , (bl.revenue - NVL(bl.init_revenue, 0))
11074 , ROUND((rates.rate2 * (bl.revenue - NVL(bl.init_revenue, 0)) )/rates.mau2)*rates.mau2
11075 )
11076 , TO_NUMBER(NULL)) glb2_etc_revenue
11077 , bl.quantity quantity
11078 , DECODE(ver.wp_flag, 'N' , bl.init_quantity, TO_NUMBER(NULL)) actual_quantity -- new
11079 , DECODE(ver.wp_flag, 'N' , (bl.quantity - NVL(bl.init_quantity, 0)), TO_NUMBER(NULL)) etc_quantity -- new
11080 , ra.planning_start_date
11081 , ra.planning_END_date
11082 , ver.time_phased_type_code time_phased_type_code
11083 , ppa.org_id project_org_id
11084 , ppa.carrying_out_organization_id project_organization_id
11085 , 'NTP' line_type
11086 ,decode(ver.rate_dangling_flag,'Y',-1,1) rate
11087 ,decode(ver.rate_dangling_flag,'Y',-1,1) rate2
11088 , ver.plan_type_code plan_type_code /*4471527 */
11089 , ver.WP_FLAG
11090 FROM
11091 PJI_FM_EXTR_PLNVER4 ver
11092 , pa_resource_asSIGNments ra
11093 , PA_BUDGET_LINES bl
11094 , pa_projects_all ppa
11095 , PJI_FM_AGGR_DLY_RATES rates
11096 , PA_PROJ_ELEM_VER_STRUCTURE pevs
11097 WHERE 1=1
11098 AND ra.resource_asSIGNment_id = bl.resource_asSIGNment_id
11099 AND ra.project_id = ver.PROJECT_ID
11100 AND ra.budget_version_id = ver.plan_version_id
11101 AND ver.project_id = ppa.project_id
11102 AND txn_currency_code IS NOT NULL
11103 AND bl.project_currency_code IS NOT NULL
11104 AND bl.projfunc_currency_code IS NOT NULL
11105 AND pevs.element_version_id = ver.wbs_struct_version_id
11106 AND ver.project_id = pevs.project_id
11107 AND ver.secondary_rbs_flag = 'N'
11108 AND ver.wp_flag = 'N'
11109 AND ver.baselined_flag = 'Y'
11110 AND ver.time_phased_type_code = 'N'
11111 AND rates.time_id = DECODE ( g_currency_conversion_rule
11112 , 'S'
11113 , TO_NUMBER(to_CHAR(ra.planning_start_date, 'J'))
11114 , 'E'
11115 , TO_NUMBER(to_CHAR(ra.planning_end_date, 'J')) )
11116 AND rates.worker_id = g_worker_id
11117 AND rates.pf_currency_code = bl.projfunc_currency_code -- 4764334
11118 AND ver.worker_id = g_worker_id
11119 ) spread_bl
11120 ---- end of third inline view 'spread_bl'...........
11121 ,
11122 (
11123 select 1 INVERT_ID from dual where PJI_UTILS.GET_SETUP_PARAMETER('GLOBAL_CURR1_FLAG') = 'Y' union all /* Added for bug 8708651 */
11124 select 2 INVERT_ID from dual where PJI_UTILS.GET_SETUP_PARAMETER('GLOBAL_CURR2_FLAG') = 'Y' union all
11125 select 4 INVERT_ID from dual union all
11126 select 8 INVERT_ID from dual union all
11127 select 16 INVERT_ID from dual where PJI_UTILS.GET_SETUP_PARAMETER('TXN_CURR_FLAG') = 'Y'
11128 ) invert
11129 ) collapse_bl -- WHERE wbs_element_id = 7474 -- and rbs_element_id = 10266 -- and budget_version_id = 2909
11130 ---- End of second inline view 'collapse_bl' ..........
11131 GROUP BY
11132 collapse_bl.PROJECT_ID
11133 , collapse_bl.time_id
11134 , collapse_bl.WBS_ELEMENT_ID
11135 -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
11136 , collapse_bl.RBS_ELEMENT_ID
11137 , collapse_bl.RBS_STRUCT_VERSION_ID
11138 , collapse_bl.plan_type_id
11139 , collapse_bl.plan_version_id
11140 , collapse_bl.PROJECT_ORGANIZATION_ID
11141 , collapse_bl.PROJECT_ORG_ID
11142 , collapse_bl.RESOURCE_ASSIGNMENT_ID
11143 , collapse_bl.BILLABLE_FLAG
11144 , collapse_bl.RESOURCE_CLASS
11145 , collapse_bl.TIME_PHASED_TYPE_CODE
11146 , collapse_bl.CURRENCY_CODE
11147 , collapse_bl.start_date
11148 , collapse_bl.end_date
11149 , collapse_bl.row_id
11150 , collapse_bl.line_type
11151 , collapse_bl.calendar_type
11152 , collapse_bl.period_type_id
11153 ,collapse_bl.rate
11154 ,collapse_bl.rate2
11155 , collapse_bl.plan_type_code /*4471527 */
11156 , collapse_bl.WP_FLAG
11157 ) plr
11158 ---- End of first inline view plr ..........
11159 WHERE 1=1
11160 -- AND plr.CURR_RECORD_TYPE IS NOT NULL
11161 AND plr.currency_code IS NOT NULL
11162 GROUP BY
11163 plr.PROJECT_ID
11164 , plr.PROJECT_ORG_ID
11165 , plr.project_ORGANIZATION_ID
11166 , plr.WBS_ELEMENT_ID
11167 , plr.time_id
11168 , plr.period_type_id
11169 , plr.CALENDAR_TYPE
11170 , plr.CURR_RECORD_TYPE -- curr code missing.
11171 , plr.currency_code
11172 , plr.RBS_ELEMENT_ID
11173 , plr.RBS_STRUCT_VERSION_ID
11174 , plr.plan_version_id
11175 , plr.plan_type_id
11176 , plr.start_date
11177 , plr.end_date
11178 , plr.line_type
11179 ,decode(sign(plr.rate),-1,'Y',NULL) ||decode(sign(plr.rate2),-1,'Y',NULL)
11180 ,plr.plan_type_code /*4471527 */
11181 )
11182 GROUP BY
11183 WORKER_ID
11184 ,PROJECT_ID
11185 ,PROJECT_ORG_ID
11186 ,project_ORGANIZATION_ID
11187 ,WBS_ELEMENT_ID
11188 ,time_id
11189 ,period_type_id
11190 ,CALENDAR_TYPE
11191 ,RBS_AGGR_LEVEL
11192 ,WBS_ROLLUP_FLAG
11193 ,PRG_ROLLUP_FLAG
11194 ,CURR_RECORD_TYPE
11195 ,currency_code
11196 ,RBS_ELEMENT_ID
11197 ,RBS_STRUCT_VERSION_ID
11198 ,plan_version_id
11199 ,plan_type_id
11200 ,LINE_TYPE
11201 ,rate_dangling_flag
11202 ,time_dangling_flag
11203 ,start_date
11204 ,end_date
11205 ,prg_level
11206 ,plan_type_code ; /*4471527 */
11207
11208 print_time ( ' EXTRACT_PLAN_AMTS_PRIRBS_GLC12 end. Inserted rows # is: ' || SQL%ROWCOUNT );
11209
11210 end if;
11211
11212 EXCEPTION
11213 WHEN OTHERS THEN
11214 print_time('EXTRACT_PLAN_AMTS_PRIRBS_GLC12 : Exception ' || SQLERRM );
11215 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
11216 p_procedure_name => 'EXTRACT_PLAN_AMTS_PRIRBS_GLC12');
11217 RAISE;
11218 END;
11219
11220
11221 PROCEDURE EXTRACT_DANGL_REVERSAL IS
11222 BEGIN
11223
11224 /* Added for bug 13030627 */
11225 if PJI_UTILS.GET_PARAMETER('PJP_SIN_PRG') = 'Y' then
11226
11227 PJI_PJP_PRG_PERF_ALL.EXTRACT_DANGL_REVERSAL;
11228
11229 else -- Else Added for bug 13790186 (checkin 13107651) -- Missed in bug 13030627
11230 print_time ( ' EXTRACT_DANGL_REVERSAL begin. ' );
11231
11232 INSERT INTO PJI_FP_AGGR_PJP1
11233 (
11234 WORKER_ID
11235 , PROJECT_ID
11236 , PROJECT_ORG_ID
11237 , PROJECT_ORGANIZATION_ID
11238 , PROJECT_ELEMENT_ID
11239 , TIME_ID
11240 , PERIOD_TYPE_ID
11241 , CALENDAR_TYPE
11242 , RBS_AGGR_LEVEL
11243 , WBS_ROLLUP_FLAG
11244 , PRG_ROLLUP_FLAG
11245 , CURR_RECORD_TYPE_ID
11246 , CURRENCY_CODE
11247 , RBS_ELEMENT_ID
11248 , RBS_VERSION_ID
11249 , PLAN_VERSION_ID
11250 , PLAN_TYPE_ID
11251 , RAW_COST
11252 , BRDN_COST
11253 , REVENUE
11254 , BILL_RAW_COST
11255 , BILL_BRDN_COST
11256 , BILL_LABOR_RAW_COST
11257 , BILL_LABOR_BRDN_COST
11258 , BILL_LABOR_HRS
11259 , EQUIPMENT_RAW_COST
11260 , EQUIPMENT_BRDN_COST
11261 , CAPITALIZABLE_RAW_COST
11262 , CAPITALIZABLE_BRDN_COST
11263 , LABOR_RAW_COST
11264 , LABOR_BRDN_COST
11265 , LABOR_HRS
11266 , LABOR_REVENUE
11267 , EQUIPMENT_HOURS
11268 , BILLABLE_EQUIPMENT_HOURS
11269 , SUP_INV_COMMITTED_COST
11270 , PO_COMMITTED_COST
11271 , PR_COMMITTED_COST
11272 , OTH_COMMITTED_COST
11273 , ACT_LABOR_HRS
11274 , ACT_EQUIP_HRS
11275 , ACT_LABOR_BRDN_COST
11276 , ACT_EQUIP_BRDN_COST
11277 , ACT_BRDN_COST
11278 , ACT_RAW_COST
11279 , ACT_REVENUE
11280 , ACT_LABOR_RAW_COST
11281 , ACT_EQUIP_RAW_COST
11282 , ETC_LABOR_HRS
11283 , ETC_EQUIP_HRS
11284 , ETC_LABOR_BRDN_COST
11285 , ETC_EQUIP_BRDN_COST
11286 , ETC_BRDN_COST
11287 , ETC_RAW_COST
11288 , ETC_LABOR_RAW_COST
11289 , ETC_EQUIP_RAW_COST
11290 , CUSTOM1
11291 , CUSTOM2
11292 , CUSTOM3
11293 , CUSTOM4
11294 , CUSTOM5
11295 , CUSTOM6
11296 , CUSTOM7
11297 , CUSTOM8
11298 , CUSTOM9
11299 , CUSTOM10
11300 , CUSTOM11
11301 , CUSTOM12
11302 , CUSTOM13
11303 , CUSTOM14
11304 , CUSTOM15
11305 , LINE_TYPE
11306 , RATE_DANGLING_FLAG
11307 , TIME_DANGLING_FLAG
11308 , START_DATE
11309 , END_DATE
11310 , PRG_LEVEL
11311 , PLAN_TYPE_CODE /*4471527 */
11312 )
11313 SELECT
11314 g_worker_id WORKER_ID
11315 ,fact.PROJECT_ID
11316 ,fact.PROJECT_ORG_ID
11317 ,fact.PROJECT_ORGANIZATION_ID
11318 ,fact.PROJECT_ELEMENT_ID
11319 ,fact.TIME_ID
11320 ,fact.PERIOD_TYPE_ID
11321 ,fact.CALENDAR_TYPE
11322 ,fact.RBS_AGGR_LEVEL
11323 ,fact.WBS_ROLLUP_FLAG
11324 ,fact.PRG_ROLLUP_FLAG
11325 ,fact.CURR_RECORD_TYPE_ID
11326 ,fact.CURRENCY_CODE
11327 ,fact.RBS_ELEMENT_ID
11328 ,fact.RBS_VERSION_ID
11329 ,fact.PLAN_VERSION_ID
11330 ,fact.PLAN_TYPE_ID
11331 ,-fact.RAW_COST
11332 ,-fact.BRDN_COST
11333 ,-fact.REVENUE
11334 ,-fact.BILL_RAW_COST
11335 ,-fact.BILL_BRDN_COST
11336 ,-fact.BILL_LABOR_RAW_COST
11337 ,-fact.BILL_LABOR_BRDN_COST
11338 ,-fact.BILL_LABOR_HRS
11339 ,-fact.EQUIPMENT_RAW_COST
11340 ,-fact.EQUIPMENT_BRDN_COST
11341 ,-fact.CAPITALIZABLE_RAW_COST
11342 ,-fact.CAPITALIZABLE_BRDN_COST
11343 ,-fact.LABOR_RAW_COST
11344 ,-fact.LABOR_BRDN_COST
11345 ,-fact.LABOR_HRS
11346 ,-fact.LABOR_REVENUE
11347 ,-fact.EQUIPMENT_HOURS
11348 ,-fact.BILLABLE_EQUIPMENT_HOURS
11349 ,-fact.SUP_INV_COMMITTED_COST
11350 ,-fact.PO_COMMITTED_COST
11351 ,-fact.PR_COMMITTED_COST
11352 ,-fact.OTH_COMMITTED_COST
11353 ,-fact.ACT_LABOR_HRS
11354 ,-fact.ACT_EQUIP_HRS
11355 ,-fact.ACT_LABOR_BRDN_COST
11356 ,-fact.ACT_EQUIP_BRDN_COST
11357 ,-fact.ACT_BRDN_COST
11358 ,-fact.ACT_RAW_COST
11359 ,-fact.ACT_REVENUE
11360 ,-fact.ACT_LABOR_RAW_COST
11361 ,-fact.ACT_EQUIP_RAW_COST
11362 ,-fact.ETC_LABOR_HRS
11363 ,-fact.ETC_EQUIP_HRS
11364 ,-fact.ETC_LABOR_BRDN_COST
11365 ,-fact.ETC_EQUIP_BRDN_COST
11366 ,-fact.ETC_BRDN_COST
11367 ,-fact.ETC_RAW_COST
11368 ,-fact.ETC_LABOR_RAW_COST
11369 ,-fact.ETC_EQUIP_RAW_COST
11370 ,-fact.CUSTOM1
11371 ,-fact.CUSTOM2
11372 ,-fact.CUSTOM3
11373 ,-fact.CUSTOM4
11374 ,-fact.CUSTOM5
11375 ,-fact.CUSTOM6
11376 ,-fact.CUSTOM7
11377 ,-fact.CUSTOM8
11378 ,-fact.CUSTOM9
11379 ,-fact.CUSTOM10
11380 ,-fact.CUSTOM11
11381 ,-fact.CUSTOM12
11382 ,-fact.CUSTOM13
11383 ,-fact.CUSTOM14
11384 ,-fact.CUSTOM15
11385 ,DECODE(ver.time_phased_type_code,'N',
11386 DECODE(fact.calendar_type,'A','NTP','CF'),
11387 fact.calendar_type,'OF','CF') LINE_TYPE
11388 ,NULL RATE_DANGLING_FLAG
11389 ,NULL TIME_DANGLING_FLAG
11390 ,TO_DATE(NULL) START_DATE
11391 ,TO_DATE(NULL) END_DATE
11392 ,g_default_prg_level PRG_LEVEL
11393 , fact.plan_type_code plan_type_code
11394 -- Bug 13107651 Reverted fix for bug 8510978
11395 FROM
11396 pji_fp_xbs_accum_f fact,
11397 pji_fm_extr_plnver4 ver
11398 WHERE fact.plan_version_id=ver.plan_version_id
11399 AND fact.plan_type_code = ver.plan_type_code /*4471527 */
11400 AND fact.project_id = ver.project_id
11401 AND NVL(ver.rbs_struct_version_id,-1) = fact.rbs_version_id
11402 AND ver.worker_id = g_worker_id
11403 AND ver.wp_flag = 'N'
11404 AND ver.baselined_flag = 'Y'
11405 AND fact.rbs_aggr_level='L'
11406 AND fact.wbs_rollup_flag='N'
11407 AND fact.PRG_ROLLUP_FLAG ='N'
11408 AND ( (ver.time_phased_type_code='N' AND fact.calendar_type='A')
11409 OR (fact.calendar_type IN ('P','G','E') AND period_type_id=32));
11410 --End Bug 13107651
11411
11412 print_time ( ' EXTRACT_DANGL_REVERSAL end. Inserted rows # is: ' || SQL%ROWCOUNT );
11413
11414 end if;
11415
11416 EXCEPTION
11417 WHEN OTHERS THEN
11418 print_time(' EXTRACT_DANGL_REVERSAL : Exception ' || SQLERRM );
11419 Fnd_Msg_Pub.add_exc_msg( p_pkg_name => g_package_name ,
11420 p_procedure_name => 'EXTRACT_DANGL_REVERSAL');
11421 RAISE;
11422
11423 END;
11424
11425
11426 PROCEDURE EXTRACT_ACTUALS(
11427 p_extrn_type IN VARCHAR2 := NULL -- 'FULL' or 'INCREMENTAL'
11428 ) IS
11429
11430 l_max_project_id NUMBER;
11431
11432 BEGIN
11433
11434 print_time ( ' EXTRACT_ACTUALS BEGIN' ) ;
11435
11436 IF (p_extrn_type NOT IN ('FULL', 'INCREMENTAL')) THEN
11437 RETURN;
11438 END IF;
11439
11440 INSERT_NTP_CAL_RECORD ( x_max_project_id => l_max_project_id );
11441
11442 IF (l_max_project_id IS NULL) THEN
11443 RETURN;
11444 END IF;
11445
11446
11447 /* Added for bug 11843459 */
11448 if PJI_PJP_GEN_PERF_ALL.GET_PARAMETER('PJI_PJP_PERF_PRL') = 'Y' then
11449 PJI_PJP_GEN_PERF_ALL.EXTRACT_ACTUALS(l_max_project_id,p_extrn_type);
11450 else
11451 INSERT /* parallel(pjp1) */ INTO PJI_FP_AGGR_PJP1 pjp1 /* Added for bug 13030627 */
11452 (
11453 WORKER_ID
11454 , PRG_LEVEL
11455 , PROJECT_ID
11456 , PROJECT_ORG_ID
11457 , PROJECT_ORGANIZATION_ID
11458 , PROJECT_ELEMENT_ID
11459 , TIME_ID
11460 , PERIOD_TYPE_ID
11461 , CALENDAR_TYPE
11462 , RBS_AGGR_LEVEL
11463 , WBS_ROLLUP_FLAG
11464 , PRG_ROLLUP_FLAG
11465 , CURR_RECORD_TYPE_ID
11466 , CURRENCY_CODE
11467 , RBS_ELEMENT_ID
11468 , RBS_VERSION_ID
11469 , PLAN_VERSION_ID
11470 , PLAN_TYPE_ID
11471 , RAW_COST
11472 , BRDN_COST
11473 , REVENUE
11474 , BILL_RAW_COST
11475 , BILL_BRDN_COST
11476 , BILL_LABOR_RAW_COST
11477 , BILL_LABOR_BRDN_COST
11478 , BILL_LABOR_HRS
11479 , EQUIPMENT_RAW_COST
11480 , EQUIPMENT_BRDN_COST
11481 , CAPITALIZABLE_RAW_COST
11482 , CAPITALIZABLE_BRDN_COST
11483 , LABOR_RAW_COST
11484 , LABOR_BRDN_COST
11485 , LABOR_HRS
11486 , LABOR_REVENUE
11487 , EQUIPMENT_HOURS
11488 , BILLABLE_EQUIPMENT_HOURS
11489 , SUP_INV_COMMITTED_COST
11490 , PO_COMMITTED_COST
11491 , PR_COMMITTED_COST
11492 , OTH_COMMITTED_COST
11493 , ACT_LABOR_HRS
11494 , ACT_EQUIP_HRS
11495 , ACT_LABOR_BRDN_COST
11496 , ACT_EQUIP_BRDN_COST
11497 , ACT_BRDN_COST
11498 , ACT_RAW_COST
11499 , ACT_REVENUE
11500 , ACT_LABOR_RAW_COST
11501 , ACT_EQUIP_RAW_COST
11502 , ETC_LABOR_HRS
11503 , ETC_EQUIP_HRS
11504 , ETC_LABOR_BRDN_COST
11505 , ETC_EQUIP_BRDN_COST
11506 , ETC_BRDN_COST
11507 , ETC_RAW_COST
11508 , ETC_LABOR_RAW_COST
11509 , ETC_EQUIP_RAW_COST
11510 , CUSTOM1
11511 , CUSTOM2
11512 , CUSTOM3
11513 , CUSTOM4
11514 , CUSTOM5
11515 , CUSTOM6
11516 , CUSTOM7
11517 , CUSTOM8
11518 , CUSTOM9
11519 , CUSTOM10
11520 , CUSTOM11
11521 , CUSTOM12
11522 , CUSTOM13
11523 , CUSTOM14
11524 , CUSTOM15
11525 ,PLAN_TYPE_CODE /*4471527 */
11526 )
11527 -- Get actuals from budget lines for extraction type is full.
11528 SELECT /*+ ordered no_merge(plr) */
11529 g_worker_id worker_id
11530 , g_default_prg_level prg_level
11531 , plr.PROJECT_ID
11532 , plr.PROJECT_ORG_ID
11533 , plr.project_ORGANIZATION_ID
11534 , plr.WBS_ELEMENT_ID
11535 , DECODE(plr.time_phased_type_code
11536 , 'N', -1
11537 , pji_time.cal_period_id) time_id
11538 , DECODE(plr.time_phased_type_code
11539 , 'P', 32
11540 , 'G', 32
11541 , 'N', 2048
11542 , -1) period_type_id -- period type id...
11543 , DECODE(plr.time_phased_type_code
11544 , 'P', 'P'
11545 , 'G', 'G'
11546 , 'N', 'A'
11547 , 'X') -- CALENDAR_TYPE
11548 , 'L' RBS_AGGR_LEVEL
11549 , 'N' WBS_ROLLUP_FLAG
11550 , 'N' PRG_ROLLUP_FLAG
11551 , plr.CURR_RECORD_TYPE -- curr code missing.
11552 , plr.currency_code
11553 , plr.RBS_ELEMENT_ID
11554 , plr.RBS_STRUCT_VERSION_ID
11555 , plr.BUDGET_VERSION_ID
11556 , plr.plan_type_id plan_type_id
11557 , TO_NUMBER(NULL) RAW_COST
11558 , TO_NUMBER(NULL) BRDN_COST
11559 , TO_NUMBER(NULL) REVENUE
11560 , TO_NUMBER(NULL) BILL_RAW_COST
11561 , TO_NUMBER(NULL) BILL_BRDN_COST
11562 , TO_NUMBER(NULL) BILL_LABOR_RAW_COST
11563 , TO_NUMBER(NULL) BILL_LABOR_BRDN_COST
11564 , TO_NUMBER(NULL) BILL_LABOR_HRS
11565 , TO_NUMBER(NULL) EQUIPMENT_RAW_COST
11566 , TO_NUMBER(NULL) EQUIPMENT_BRDN_COST
11567 , TO_NUMBER(NULL) CAPITALIZABLE_RAW_COST
11568 , TO_NUMBER(NULL) CAPITALIZABLE_BRDN_COST
11569 , TO_NUMBER(NULL) LABOR_RAW_COST
11570 , TO_NUMBER(NULL) LABOR_BRDN_COST
11571 , TO_NUMBER(NULL) labor_hrs
11572 , TO_NUMBER(NULL) LABOR_REVENUE
11573 , TO_NUMBER(NULL) EQUIPMENT_HOURS
11574 , TO_NUMBER(NULL) BILLABLE_EQUIPMENT_HOURS
11575 , TO_NUMBER(NULL) -- TO_NUMBER(NULL) SUP_INV_COMMITTED_COST
11576 , TO_NUMBER(NULL) -- TO_NUMBER(NULL) PO_COMMITTED_COST
11577 , TO_NUMBER(NULL) -- TO_NUMBER(NULL) PR_COMMITTED_COST
11578 , TO_NUMBER(NULL) -- TO_NUMBER(NULL) OTH_COMMITTED_COST
11579 , SUM ( DECODE ( plr.resource_class
11580 , 'PEOPLE'
11581 , DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,TO_NUMBER(NULL))
11582 , TO_NUMBER(NULL) ) ) ACT_LABOR_HRS
11583 , SUM ( DECODE ( plr.resource_class
11584 , 'EQUIPMENT'
11585 , DECODE ( plr.billable_flag, 'Y',plr.actual_quantity,TO_NUMBER(NULL))
11586 , TO_NUMBER(NULL) ) ) ACT_EQUIP_HOURS
11587 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.actual_BRDN_COST, TO_NUMBER(NULL) ) ) ACT_LABOR_BRDN_COST
11588 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT' , plr.actual_BRDN_COST, TO_NUMBER(NULL) ) ) ACT_EQUIPMENT_BRDN_COST
11589 , SUM ( plr.actual_brdn_cost ) ACT_BRDN_COST
11590 , SUM ( plr.actual_raw_cost ) ACT_RAW_COST
11591 , SUM ( plr.actual_revenue ) ACT_REVENUE
11592 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.actual_RAW_COST, TO_NUMBER(NULL) ) ) ACT_LABOR_RAW_COST
11593 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT' , plr.actual_RAW_COST, TO_NUMBER(NULL) ) ) ACT_EQUIPMENT_RAW_COST
11594 , TO_NUMBER(NULL) ETC_LABOR_HRS
11595 , TO_NUMBER(NULL) ETC_EQUIP_HOURS
11596 , TO_NUMBER(NULL) ETC_LABOR_BRDN_COST
11597 , TO_NUMBER(NULL) ETC_EQUIP_BRDN_COST
11598 , TO_NUMBER(NULL) ETC_BRDN_COST
11599 , TO_NUMBER(NULL) ETC_RAW_COST
11600 , TO_NUMBER(NULL) ETC_LABOR_raw_COST
11601 , TO_NUMBER(NULL) ETC_EQUIP_raw_COST
11602 , TO_NUMBER(NULL) CUSTOM1
11603 , TO_NUMBER(NULL) CUSTOM2
11604 , TO_NUMBER(NULL) CUSTOM3
11605 , TO_NUMBER(NULL) CUSTOM4
11606 , TO_NUMBER(NULL) CUSTOM5
11607 , TO_NUMBER(NULL) CUSTOM6
11608 , TO_NUMBER(NULL) CUSTOM7
11609 , TO_NUMBER(NULL) CUSTOM8
11610 , TO_NUMBER(NULL) CUSTOM9
11611 , TO_NUMBER(NULL) CUSTOM10
11612 , TO_NUMBER(NULL) CUSTOM11
11613 , TO_NUMBER(NULL) CUSTOM12
11614 , TO_NUMBER(NULL) CUSTOM13
11615 , TO_NUMBER(NULL) CUSTOM14
11616 , TO_NUMBER(NULL) CUSTOM15
11617 , plr.plan_type_code PLAN_TYPE_CODE /*4471527 */
11618 FROM
11619 ( ----- First inline view plr .............
11620 SELECT /*+ no_merge(collapse_bl) */
11621 collapse_bl.PROJECT_ID
11622 , collapse_bl.WBS_ELEMENT_ID
11623 , SUM(collapse_bl.CURR_RECORD_TYPE_ID) CURR_RECORD_TYPE
11624 , collapse_bl.RBS_ELEMENT_ID
11625 , collapse_bl.RBS_STRUCT_VERSION_ID
11626 , collapse_bl.plan_type_id
11627 , collapse_bl.BUDGET_VERSION_ID
11628 , collapse_bl.PROJECT_ORGANIZATION_ID
11629 , collapse_bl.PROJECT_ORG_ID
11630 , collapse_bl.RESOURCE_ASSIGNMENT_ID
11631 , collapse_bl.BILLABLE_FLAG
11632 , collapse_bl.RESOURCE_CLASS -- , CALENDAR_TYPE -- , CALENDAR_ID
11633 , collapse_bl.TIME_PHASED_TYPE_CODE
11634 , collapse_bl.CURRENCY_CODE
11635 , MAX(collapse_bl.raw_cost) raw_cost
11636 , MAX(collapse_bl.BRDN_COST) BRDN_COST
11637 , MAX(collapse_bl.revenue) revenue
11638 , MAX(collapse_bl.actual_raw_cost) actual_raw_cost
11639 , MAX(collapse_bl.actual_BRDN_COST) actual_BRDN_COST
11640 , MAX(collapse_bl.actual_revenue) actual_revenue
11641 , MAX(collapse_bl.etc_raw_cost) etc_raw_cost
11642 , MAX(collapse_bl.etc_BRDN_COST) etc_BRDN_COST
11643 , MAX(collapse_bl.etc_revenue) etc_revenue
11644 , MAX(collapse_bl.quantity) quantity
11645 , MAX(collapse_bl.actual_quantity) actual_quantity
11646 , MAX(collapse_bl.etc_quantity) etc_quantity
11647 , collapse_bl.start_date start_date
11648 , collapse_bl.end_date end_date
11649 , collapse_bl.period_name period_name
11650 , collapse_bl.row_id
11651 , collapse_bl.plan_type_code
11652 FROM
11653 ( ----- Second inline view 'collapse_bl' begin .............
11654 SELECT /*+ no_merge(spread_bl) */
11655 spread_bl.row_id row_id
11656 , spread_bl.PROJECT_ID
11657 , spread_bl.BUDGET_VERSION_ID
11658 , spread_bl.RESOURCE_ASSIGNMENT_ID
11659 , spread_bl.WBS_ELEMENT_ID
11660 , spread_bl.RBS_ELEMENT_ID
11661 , spread_bl.WBS_STRUCT_VERSION_ID
11662 , spread_bl.RBS_STRUCT_VERSION_ID
11663 , spread_bl.plan_type_id
11664 , spread_bl.BILLABLE_FLAG
11665 , spread_bl.RESOURCE_CLASS -- , spread_bl.CALENDAR_TYPE -- , pji_time.CALENDAR_ID
11666 , spread_bl.PROJECT_ORGANIZATION_ID
11667 , spread_bl.PROJECT_ORG_ID
11668 , spread_bl.TIME_PHASED_TYPE_CODE
11669 , DECODE( invert.INVERT_ID
11670 , 4, spread_bl.func_CURRENCY_CODE
11671 , 8, spread_bl.PRJ_CURRENCY_CODE
11672 , 16, spread_bl.TXN_CURRENCY_CODE ) CURRENCY_CODE
11673 , invert.INVERT_ID CURR_RECORD_TYPE_ID
11674 , DECODE ( invert.INVERT_ID
11675 , 4, spread_bl.func_raw_cost
11676 , 8, spread_bl.PRJ_raw_cost
11677 , 16, spread_bl.TXN_raw_cost) raw_cost
11678 , DECODE ( invert.INVERT_ID
11679 , 4, spread_bl.func_BRDN_COST
11680 , 8, spread_bl.PRJ_BRDN_COST
11681 , 16, spread_bl.TXN_BRDN_COST ) BRDN_COST
11682 , DECODE ( invert.INVERT_ID
11683 , 4, spread_bl.func_revenue
11684 , 8, spread_bl.PRJ_revenue
11685 , 16, spread_bl.TXN_revenue ) revenue
11686 , DECODE ( invert.INVERT_ID
11687 , 4, spread_bl.func_actual_raw_cost
11688 , 8, spread_bl.prj_actual_raw_cost
11689 , 16, spread_bl.txn_actual_raw_cost ) actual_raw_cost
11690 , DECODE ( invert.INVERT_ID
11691 , 4, spread_bl.func_actual_brdn_cost
11692 , 8, spread_bl.prj_actual_brdn_cost
11693 , 16, spread_bl.txn_actual_brdn_cost ) actual_brdn_cost
11694 , DECODE ( invert.INVERT_ID
11695 , 4, spread_bl.func_actual_revenue
11696 , 8, spread_bl.prj_actual_revenue
11697 , 16, spread_bl.txn_actual_revenue ) actual_revenue
11698 , DECODE ( invert.INVERT_ID
11699 , 4, spread_bl.func_etc_raw_cost
11700 , 8, spread_bl.prj_etc_raw_cost
11701 , 16, spread_bl.txn_etc_raw_cost ) etc_raw_cost
11702 , DECODE ( invert.INVERT_ID
11703 , 4, spread_bl.func_etc_brdn_cost
11704 , 8, spread_bl.prj_etc_brdn_cost
11705 , 16, spread_bl.txn_etc_brdn_cost ) etc_brdn_cost
11706 , DECODE ( invert.INVERT_ID
11707 , 4, spread_bl.func_etc_revenue
11708 , 8, spread_bl.prj_etc_revenue
11709 , 16, spread_bl.txn_etc_revenue ) etc_revenue
11710 , spread_bl.quantity quantity
11711 , spread_bl.actual_quantity actual_quantity
11712 , spread_bl.etc_quantity etc_quantity
11713 , spread_bl.start_date start_date
11714 , spread_bl.end_date end_date
11715 , spread_bl.period_name period_name
11716 -- , spread_bl.TRACK_AS_LABOR_FLAG track_as_labor_flag
11717 , spread_bl.plan_type_code plan_type_code /*4471527 */
11718 FROM
11719 ( ----- Third inline view 'spread_bl' .............
11720 SELECT /*+ ordered */
11721 ra.project_id
11722 , bl.ROWID row_id
11723 , ra.budget_version_id
11724 , bl.resource_asSIGNment_id
11725 , DECODE(ra.task_id, 0, pevs.proj_element_id, ra.task_id) wbs_element_id
11726 , NVL(ra.rbs_element_id, -1) rbs_element_id
11727 , ver.wbs_struct_version_id wbs_struct_version_id
11728 , NVL(ver.rbs_struct_version_id, -1) rbs_struct_version_id
11729 , ver.plan_type_id plan_type_id
11730 , ra.rate_based_flag billable_flag
11731 -- cbs change
11732 , 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',
11733 '1'||ra.resource_class_code, ra.resource_class_code),ra.resource_class_code) resource_class
11734 -- End cbs change
11735 , bl.txn_currency_code txn_currency_code
11736 , TO_NUMBER(NULL) txn_raw_cost
11737 , TO_NUMBER(NULL) txn_brdn_COST
11738 , TO_NUMBER(NULL) txn_revenue
11739 , bl.txn_init_raw_cost txn_actual_raw_cost
11740 , bl.txn_init_burdened_cost txn_actual_brdn_cost
11741 , bl.txn_init_revenue txn_actual_revenue
11742 , TO_NUMBER(NULL) txn_etc_raw_cost
11743 , TO_NUMBER(NULL) txn_etc_brdn_cost
11744 , TO_NUMBER(NULL) txn_etc_revenue
11745 , bl.project_currency_code prj_currency_code
11746 , TO_NUMBER(NULL) prj_raw_cost
11747 , TO_NUMBER(NULL) prj_BRDN_COST
11748 , TO_NUMBER(NULL) prj_revenue
11749 , bl.project_init_raw_cost prj_actual_raw_cost
11750 , bl.project_init_burdened_cost prj_actual_brdn_cost
11751 , bl.project_init_revenue prj_actual_revenue
11752 , TO_NUMBER(NULL) prj_etc_raw_cost
11753 , TO_NUMBER(NULL) prj_etc_brdn_cost
11754 , TO_NUMBER(NULL) prj_etc_revenue
11755 , bl.projfunc_currency_code func_currency_code
11756 , TO_NUMBER(NULL) func_raw_cost
11757 , TO_NUMBER(NULL) func_BRDN_COST
11758 , TO_NUMBER(NULL) func_revenue
11759 , bl.init_raw_cost func_actual_raw_cost
11760 , bl.init_burdened_cost func_actual_brdn_cost
11761 , bl.init_revenue func_actual_revenue
11762 , TO_NUMBER(NULL) func_etc_raw_cost
11763 , TO_NUMBER(NULL) func_etc_brdn_cost
11764 , TO_NUMBER(NULL) func_etc_revenue
11765 , 'CAD' glb1_currency_code
11766 , TO_NUMBER(NULL) glb1_raw_cost
11767 , TO_NUMBER(NULL) glb1_BRDN_COST
11768 , TO_NUMBER(NULL) glb1_revenue
11769 , 'USD' glb2_currency_code
11770 , TO_NUMBER(NULL) glb2_raw_cost
11771 , TO_NUMBER(NULL) glb1_BRDN_COST
11772 , TO_NUMBER(NULL) glb1_revenue
11773 , TO_NUMBER(NULL) quantity
11774 , bl.init_quantity actual_quantity
11775 , TO_NUMBER(NULL) etc_quantity
11776 , TO_DATE(NULL) start_date
11777 , TO_DATE(NULL) end_date
11778 , NVL(bl.period_name, 'XXX') period_name
11779 , ver.time_phased_type_code time_phased_type_code
11780 , ppa.org_id project_org_id
11781 , ppa.carrying_out_organization_id project_organization_id
11782 , ver.plan_type_code plan_type_code /* 4471527*/
11783 FROM
11784 PJI_FM_EXTR_PLNVER4 ver
11785 , PA_RESOURCE_ASSIGNMENTS ra
11786 , PA_BUDGET_LINES bl
11787 , PA_PROJECTS_ALL ppa
11788 , PA_PROJ_ELEM_VER_STRUCTURE pevs
11789 WHERE
11790 ra.resource_asSIGNment_id = bl.resource_asSIGNment_id
11791 AND ra.project_id = ver.PROJECT_ID
11792 AND ra.budget_version_id = ver.plan_version_id
11793 AND ver.project_id = ppa.project_id
11794 AND txn_currency_code IS NOT NULL
11795 AND bl.project_currency_code IS NOT NULL
11796 AND bl.projfunc_currency_code IS NOT NULL
11797 AND pevs.element_version_id = ver.wbs_struct_version_id
11798 AND pevs.project_id = ver.project_id
11799 AND ver.secondary_rbs_flag = 'N'
11800 AND p_extrn_type = 'FULL'
11801 AND ver.worker_id = g_worker_id
11802 AND ver.time_phased_type_code IN ('P', 'G', 'N')
11803 ) spread_bl
11804 ---- end of third inline view 'spread_bl'...........
11805 ,
11806 (
11807 SELECT 4 INVERT_ID FROM dual UNION ALL
11808 SELECT 8 INVERT_ID FROM dual UNION ALL
11809 SELECT 16 INVERT_ID FROM dual where PJI_UTILS.GET_SETUP_PARAMETER('TXN_CURR_FLAG') = 'Y'
11810 ) invert
11811 ) collapse_bl
11812 ---- End of second inline view 'collapse_bl' ..........
11813 GROUP BY
11814 collapse_bl.PROJECT_ID
11815 , collapse_bl.WBS_ELEMENT_ID
11816 -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
11817 , collapse_bl.RBS_ELEMENT_ID
11818 , collapse_bl.RBS_STRUCT_VERSION_ID
11819 , collapse_bl.plan_type_id
11820 , collapse_bl.BUDGET_VERSION_ID
11821 , collapse_bl.PROJECT_ORGANIZATION_ID
11822 , collapse_bl.PROJECT_ORG_ID
11823 , collapse_bl.RESOURCE_ASSIGNMENT_ID
11824 , collapse_bl.BILLABLE_FLAG
11825 , collapse_bl.RESOURCE_CLASS
11826 , collapse_bl.TIME_PHASED_TYPE_CODE
11827 , collapse_bl.CURRENCY_CODE
11828 , collapse_bl.start_date
11829 , collapse_bl.end_date
11830 , collapse_bl.period_name
11831 , collapse_bl.row_id
11832 ,collapse_bl.plan_type_code
11833 ) plr
11834 ---- End of first inline view plr ..........
11835 , PJI_ORG_EXTR_INFO orginfo
11836 , pji_time_cal_period_v pji_time
11837 WHERE 1=1
11838 -- AND orginfo.projfunc_currency_mau is not TO_NUMBER(NULL
11839 AND plr.project_org_id = orginfo.org_id
11840 AND DECODE(plr.time_phased_type_code
11841 , 'P', orginfo.pa_calendar_id
11842 , 'G', orginfo.gl_calendar_id
11843 , -l_max_project_id ) = pji_time.calendar_id
11844 AND plr.period_name = pji_time.name
11845 GROUP BY
11846 plr.PROJECT_ID
11847 , plr.PROJECT_ORG_ID
11848 , plr.project_ORGANIZATION_ID
11849 , plr.WBS_ELEMENT_ID
11850 , DECODE(plr.time_phased_type_code
11851 , 'N', -1
11852 , pji_time.cal_period_id)
11853 , DECODE(plr.time_phased_type_code
11854 , 'P', 32
11855 , 'G', 32
11856 , 'N', 2048
11857 , -1) -- period type id...
11858 , DECODE(plr.time_phased_type_code
11859 , 'P', 'P'
11860 , 'G', 'G'
11861 , 'N', 'A'
11862 , 'X') -- CALENDAR_TYPE
11863 , plr.CURR_RECORD_TYPE -- curr code missing.
11864 , plr.currency_code
11865 , plr.RBS_ELEMENT_ID
11866 , plr.RBS_STRUCT_VERSION_ID
11867 , plr.BUDGET_VERSION_ID
11868 , plr.plan_type_id
11869 , plr.PLAN_TYPE_CODE;
11870
11871 end if; /* Added for bug 11843459 */
11872
11873 print_time ( ' EXTRACT_ACTUALS # records is ' || SQL%ROWCOUNT ) ;
11874
11875 DELETE_NTP_CAL_RECORD ( p_max_project_id => l_max_project_id );
11876
11877 EXCEPTION
11878 WHEN OTHERS THEN
11879 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
11880 p_procedure_name => 'EXTRACT_ACTUALS');
11881 RAISE;
11882 END;
11883
11884
11885 --
11886 -- Temp fix until time table will have a record for non time phasing.
11887 --
11888 PROCEDURE INSERT_NTP_CAL_RECORD ( x_max_project_id OUT NOCOPY NUMBER ) IS
11889 l_last_update_date date := SYSDATE;
11890 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
11891 l_creation_date date := SYSDATE;
11892 l_created_by NUMBER := FND_GLOBAL.USER_ID;
11893 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
11894
11895 l_start_end_date DATE := TRUNC(SYSDATE);
11896 BEGIN
11897
11898 BEGIN
11899
11900 SELECT MAX(project_id)
11901 INTO x_max_project_id
11902 FROM pji_pjp_proj_batch_map
11903 WHERE worker_id = g_worker_id;
11904
11905 EXCEPTION
11906 WHEN NO_DATA_FOUND THEN
11907 RETURN;
11908 END;
11909
11910 IF (x_max_project_id IS NULL) THEN
11911 RETURN;
11912 END IF;
11913
11914 print_time (' Inside INSERT_NTP_CAL_RECORD, max project_id is: ' || x_max_project_id);
11915
11916
11917 INSERT INTO pji_time_cal_period
11918 (
11919 CAL_PERIOD_ID,
11920 CAL_QTR_ID,
11921 CALENDAR_ID,
11922 SEQUENCE,
11923 NAME ,
11924 START_DATE,
11925 END_DATE,
11926 CREATION_DATE,
11927 LAST_UPDATE_DATE,
11928 LAST_UPDATED_BY,
11929 CREATED_BY,
11930 LAST_UPDATE_LOGIN
11931 )
11932 SELECT -x_max_project_id cal_period_id
11933 , -x_max_project_id cal_qtr_id
11934 , -x_max_project_id calendar_id
11935 , -x_max_project_id SEQUENCE
11936 , g_ntp_period_name name
11937 , l_start_end_date start_date
11938 , l_start_end_date end_date
11939 , l_creation_date creation_date
11940 , l_last_update_date last_update_date
11941 , l_last_updated_by last_updated_by
11942 , l_created_by created_by
11943 , l_last_update_login last_update_login
11944 FROM DUAL;
11945
11946 print_time (' INSERT_NTP_CAL_RECORD, # rows inserted is: ' || SQL%ROWCOUNT );
11947
11948 EXCEPTION
11949 WHEN OTHERS THEN
11950 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
11951 p_procedure_name => 'INSERT_NTP_CAL_RECORD');
11952 RAISE;
11953 END;
11954
11955
11956 PROCEDURE DELETE_NTP_CAL_RECORD ( p_max_project_id IN NUMBER ) IS
11957 BEGIN
11958
11959 print_time (' DELETE_NTP_CAL_RECORD, max project_id is: ' || p_max_project_id);
11960
11961 DELETE FROM pji_time_cal_period
11962 WHERE cal_period_id = -p_max_project_id;
11963
11964 print_time (' DELETE_NTP_CAL_RECORD, # rows deleted is: ' || SQL%ROWCOUNT );
11965
11966 EXCEPTION
11967 WHEN OTHERS THEN
11968 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
11969 p_procedure_name => 'DELETE_NTP_CAL_RECORD');
11970 RAISE;
11971 END;
11972
11973
11974 --
11975 -- Processes the plan lines that have not yet been processed through bulk summarization.
11976 --
11977 PROCEDURE PROCESS_PENDING_PLAN_UPDATES(
11978 p_extrn_type IN VARCHAR2,
11979 x_return_status OUT NOCOPY VARCHAR2,
11980 x_msg_data OUT NOCOPY VARCHAR2) IS
11981
11982 l_max_project_id NUMBER := NULL;
11983 l_extract_etc VARCHAR2(1) := NULL; -- 4682341
11984
11985 BEGIN
11986
11987 PJI_PJP_FP_CURR_WRAP.INIT_ERR_STACK
11988 ( p_package_name => g_package_name
11989 , x_return_status => x_return_status );
11990
11991 IF (p_extrn_type NOT IN ('FULL', 'INCREMENTAL', 'RBS', 'PARTIAL')) THEN
11992 RETURN;
11993 END IF;
11994
11995 -- 4682341
11996 -- No data found error should not be thrown.
11997 --
11998 BEGIN
11999 SELECT value
12000 INTO l_extract_etc
12001 FROM pji_system_parameters
12002 WHERE name = 'EXTRACT_ETC_FULLLOAD';
12003 EXCEPTION
12004 WHEN OTHERS THEN
12005 l_extract_etc := 'Y';
12006 END;
12007
12008 IF (l_extract_etc = 'N') THEN
12009 UPDATE pji_system_parameters
12010 SET value = 'Y'
12011 WHERE name = 'EXTRACT_ETC_FULLLOAD';
12012 END IF;
12013
12014 INSERT_NTP_CAL_RECORD ( x_max_project_id => l_max_project_id );
12015
12016 IF (l_max_project_id IS NULL) THEN
12017 RETURN;
12018 END IF;
12019
12020 /* Added for bug 11843459 */
12021 if PJI_PJP_GEN_PERF_ALL.GET_PARAMETER('PJI_PJP_PERF_PRL') = 'Y' then
12022 PJI_PJP_GEN_PERF_ALL.PROCESS_PENDING_PLAN_UPDATES(l_max_project_id,
12023 p_extrn_type,
12024 l_extract_etc);
12025 else
12026 -- cbs change
12027 IF P_PA_DEBUG_MODE = 'Y' THEN
12028 pa_debug.write('PROCESS_PENDING_PLAN_UPDATES: ' || g_module_name,'Before calling SET_RES_CLASS_FLAG' ,1);
12029 END IF;
12030
12031 SET_RES_CLASS_FLAG;
12032
12033 IF P_PA_DEBUG_MODE = 'Y' THEN
12034 pa_debug.write('PROCESS_PENDING_PLAN_UPDATES: ' || g_module_name,'After calling SET_RES_CLASS_FLAG' ,1);
12035 END IF;
12036
12037 -- End cbs change
12038 -- INSERT /*+ parallel(pjp1) */ INTO PJI_FP_AGGR_PJP1 pjp1 /* Added for bug 13030627 */
12039 INSERT INTO PJI_FP_AGGR_PJP1 pjp1 -- Commented above and added for Bug 14735308
12040 (
12041 WORKER_ID
12042 , PROJECT_ID
12043 , PROJECT_ORG_ID
12044 , PROJECT_ORGANIZATION_ID
12045 , PROJECT_ELEMENT_ID
12046 , TIME_ID
12047 , PERIOD_TYPE_ID
12048 , CALENDAR_TYPE
12049 , RBS_AGGR_LEVEL
12050 , WBS_ROLLUP_FLAG
12051 , PRG_ROLLUP_FLAG
12052 , CURR_RECORD_TYPE_ID
12053 , CURRENCY_CODE
12054 , RBS_ELEMENT_ID
12055 , RBS_VERSION_ID
12056 , PLAN_VERSION_ID
12057 , PLAN_TYPE_ID
12058 , RAW_COST
12059 , BRDN_COST
12060 , REVENUE
12061 , BILL_RAW_COST
12062 , BILL_BRDN_COST
12063 , BILL_LABOR_RAW_COST
12064 , BILL_LABOR_BRDN_COST
12065 , BILL_LABOR_HRS
12066 , EQUIPMENT_RAW_COST
12067 , EQUIPMENT_BRDN_COST
12068 , CAPITALIZABLE_RAW_COST
12069 , CAPITALIZABLE_BRDN_COST
12070 , LABOR_RAW_COST
12071 , LABOR_BRDN_COST
12072 , LABOR_HRS
12073 , LABOR_REVENUE
12074 , EQUIPMENT_HOURS
12075 , BILLABLE_EQUIPMENT_HOURS
12076 , SUP_INV_COMMITTED_COST
12077 , PO_COMMITTED_COST
12078 , PR_COMMITTED_COST
12079 , OTH_COMMITTED_COST
12080 , ACT_LABOR_HRS
12081 , ACT_EQUIP_HRS
12082 , ACT_LABOR_BRDN_COST
12083 , ACT_EQUIP_BRDN_COST
12084 , ACT_BRDN_COST
12085 , ACT_RAW_COST
12086 , ACT_REVENUE
12087 , ACT_LABOR_RAW_COST
12088 , ACT_EQUIP_RAW_COST
12089 , ETC_LABOR_HRS
12090 , ETC_EQUIP_HRS
12091 , ETC_LABOR_BRDN_COST
12092 , ETC_EQUIP_BRDN_COST
12093 , ETC_BRDN_COST
12094 , ETC_RAW_COST
12095 , ETC_LABOR_RAW_COST
12096 , ETC_EQUIP_RAW_COST
12097 , CUSTOM1
12098 , CUSTOM2
12099 , CUSTOM3
12100 , CUSTOM4
12101 , CUSTOM5
12102 , CUSTOM6
12103 , CUSTOM7
12104 , CUSTOM8
12105 , CUSTOM9
12106 , CUSTOM10
12107 , CUSTOM11
12108 , CUSTOM12
12109 , CUSTOM13
12110 , CUSTOM14
12111 , CUSTOM15
12112 , LINE_TYPE
12113 , RATE_DANGLING_FLAG
12114 , TIME_DANGLING_FLAG
12115 , PRG_LEVEL
12116 , PLAN_TYPE_CODE /*4471527 */
12117 )
12118 SELECT /*+ ordered no_merge(plr) */
12119 g_worker_id WORKER_ID
12120 , plr.PROJECT_ID
12121 , plr.PROJECT_ORG_ID
12122 , plr.project_ORGANIZATION_ID
12123 , plr.WBS_ELEMENT_ID project_element_id
12124 , DECODE(plr.time_phased_type_code
12125 , 'N', -1
12126 , pji_time.cal_period_id) time_id
12127 , DECODE(plr.time_phased_type_code
12128 , 'P', 32
12129 , 'G', 32
12130 , 'N', 2048
12131 , -1) period_type_id -- period type id...
12132 , DECODE(plr.time_phased_type_code
12133 , 'P', 'P'
12134 , 'G', 'G'
12135 , 'N', 'A'
12136 , 'X') CALENDAR_TYPE
12137 , 'L' RBS_AGGR_LEVEL
12138 , 'N' WBS_ROLLUP_FLAG
12139 , 'N' PRG_ROLLUP_FLAG
12140 , plr.CURR_RECORD_TYPE CURR_RECORD_TYPE_id
12141 , plr.currency_code
12142 , plr.RBS_ELEMENT_ID
12143 , plr.RBS_STRUCT_VERSION_ID RBS_VERSION_ID
12144 , plr.BUDGET_VERSION_ID plan_version_id
12145 , plr.plan_type_id
12146 , SUM(plr.RAW_COST) RAW_COST
12147 , SUM(plr.BRDN_COST) BRDN_COST
12148 , SUM(plr.REVENUE) REVENUE
12149 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) BILL_RAW_COST
12150 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) BILL_BRDN_COST
12151 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YPEOPLE', plr.raw_cost, 0 ) ) BILL_LABOR_RAW_COST
12152 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YPEOPLE' , plr.BRDN_COST, 0 ) ) BILL_LABOR_BRDN_COST
12153 -- , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'YPEOPLE', plr.quantity, 0 ) ) BILL_LABOR_HRS -- bug 6039785
12154 , SUM ( DECODE ( plr.billable_flag || plr.resource_class , 'YPEOPLE',
12155 DECODE ( plr.billable_flag ,'Y', plr.quantity, 0 ), 0 ) ) BILL_LABOR_HRS -- bug 6039785
12156 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT' , plr.raw_cost, 0 ) ) EQUIPMENT_RAW_COST
12157 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT' , plr.BRDN_COST, 0 ) ) EQUIPMENT_BRDN_COST
12158 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.raw_cost, 0 ) ) CAPITALIZABLE_RAW_COST
12159 , SUM ( DECODE ( plr.billable_flag, 'Y', plr.BRDN_COST, 0 ) ) CAPITALIZABLE_BRDN_COST
12160 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.raw_cost, 0 ) ) LABOR_RAW_COST
12161 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.BRDN_COST, 0 ) ) LABOR_BRDN_COST
12162 -- , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.quantity, 0 ) ) labor_hrs -- bug 6039785
12163 , SUM ( DECODE ( plr.resource_class, 'PEOPLE',
12164 DECODE(plr.billable_flag , 'Y' , plr.quantity, 0 ),
12165 0 ) ) labor_hrs -- bug 6039785
12166 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.revenue, 0 ) ) LABOR_REVENUE
12167 /* , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT', plr.quantity, 0 ) ) EQUIPMENT_HOURS */ -- bug 6039785
12168 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT',
12169 DECODE(plr.billable_flag , 'Y' , plr.quantity, 0 ),
12170 0 ) ) EQUIPMENT_HOURS -- bug 6039785
12171 /* , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YEQUIPMENT', plr.quantity, 0 ) ) BILLABLE_EQUIPMENT_HOURS */ -- bug 6039785
12172 , SUM ( DECODE ( plr.billable_flag || plr.resource_class, 'YEQUIPMENT',
12173 DECODE ( plr.billable_flag ,'Y', plr.quantity, 0 ), 0 ) ) BILLABLE_EQUIPMENT_HOURS -- bug 6039785
12174 , TO_NUMBER(NULL) SUP_INV_COMMITTED_COST
12175 , TO_NUMBER(NULL) PO_COMMITTED_COST
12176 , TO_NUMBER(NULL) PR_COMMITTED_COST
12177 , TO_NUMBER(NULL) OTH_COMMITTED_COST
12178 --, SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.actual_quantity, 0 ) ) ACT_LABOR_HRS -- bug 6039785
12179 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', DECODE ( plr.billable_flag, 'Y', plr.actual_quantity , 0 ),
12180 0 ) ) ACT_LABOR_HRS -- bug 6039785
12181 /* , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT', plr.actual_quantity, 0 ) ) ACT_EQUIP_HRS */ -- bug 6039785
12182 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT', DECODE ( plr.billable_flag, 'Y', plr.actual_quantity, 0 ),
12183 0 ) ) ACT_EQUIP_HRS -- bug 6039785
12184 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.actual_BRDN_COST, 0 ) ) ACT_LABOR_BRDN_COST
12185 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT' , plr.actual_BRDN_COST, 0 ) ) ACT_EQUIP_BRDN_COST
12186 , SUM ( plr.actual_brdn_cost ) ACT_BRDN_COST
12187 , SUM ( plr.actual_raw_cost ) ACT_RAW_COST
12188 , SUM ( plr.actual_revenue ) ACT_REVENUE
12189 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.actual_RAW_COST, 0 ) ) ACT_LABOR_RAW_COST
12190 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT' , plr.actual_RAW_COST, 0 ) ) ACT_EQUIP_RAW_COST
12191 --, SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.etc_quantity, 0 ) ) ETC_LABOR_HRS -- bug 6039785
12192 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', DECODE ( plr.billable_flag, 'Y', plr.etc_quantity, 0 ),
12193 0 ) ) ETC_LABOR_HRS -- bug 6039785
12194 /* , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT', plr.etc_quantity, 0 ) ) ETC_EQUIP_HRS */ -- bug 6039785
12195 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT', DECODE ( plr.billable_flag, 'Y', plr.etc_quantity, 0 ),
12196 0 ) ) ETC_EQUIP_HRS -- bug 6039785
12197 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.etc_BRDN_COST, 0 ) ) ETC_LABOR_BRDN_COST
12198 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT' , plr.etc_BRDN_COST, 0 ) ) ETC_EQUIP_BRDN_COST
12199 , SUM(plr.etc_BRDN_COST) ETC_BRDN_COST
12200 , SUM(plr.etc_RAW_COST) ETC_RAW_COST
12201 , SUM ( DECODE ( plr.resource_class, 'PEOPLE', plr.etc_raw_cost, 0 ) ) ETC_LABOR_raw_COST
12202 , SUM ( DECODE ( plr.resource_class, 'EQUIPMENT', plr.etc_raw_cost, 0 ) ) ETC_EQUIP_raw_COST
12203 , NULL CUSTOM1
12204 , NULL CUSTOM2
12205 , NULL CUSTOM3
12206 , NULL CUSTOM4
12207 , NULL CUSTOM5
12208 , NULL CUSTOM6
12209 , NULL CUSTOM7
12210 , NULL CUSTOM8
12211 , NULL CUSTOM9
12212 , NULL CUSTOM10
12213 , NULL CUSTOM11
12214 , NULL CUSTOM12
12215 , NULL CUSTOM13
12216 , NULL CUSTOM14
12217 , NULL CUSTOM15
12218 , DECODE(plr.time_phased_type_code, 'P', 'OF', 'G', 'OF', 'N', 'NTR', 'X') LINE_TYPE
12219 , NULL time_dangling_flag
12220 , NULL rate_dangling_flag
12221 , g_default_prg_level prg_level
12222 , plr.plan_type_code plan_type_code /*4471527 */
12223 FROM
12224 ( ----- First inline view plr .............
12225 SELECT /*+ no_merge(collapse_bl) */
12226 collapse_bl.PROJECT_ID -- , 1 partition_id
12227 , collapse_bl.WBS_ELEMENT_ID -- , time_id, period_type_id, calendar type.., slice type, rollpu flag...
12228 , SUM(collapse_bl.CURR_RECORD_TYPE_ID) CURR_RECORD_TYPE
12229 , collapse_bl.RBS_ELEMENT_ID
12230 , collapse_bl.RBS_STRUCT_VERSION_ID
12231 , collapse_bl.plan_type_id
12232 , collapse_bl.BUDGET_VERSION_ID
12233 , collapse_bl.PROJECT_ORGANIZATION_ID
12234 , collapse_bl.PROJECT_ORG_ID
12235 , collapse_bl.BILLABLE_FLAG
12236 , collapse_bl.RESOURCE_CLASS -- , CALENDAR_TYPE -- , CALENDAR_ID
12237 , collapse_bl.CURRENCY_CODE
12238 , MAX(collapse_bl.raw_cost) raw_cost
12239 , MAX(collapse_bl.BRDN_COST) BRDN_COST
12240 , MAX(collapse_bl.revenue) revenue
12241 , MAX(collapse_bl.actual_raw_cost) actual_raw_cost
12242 , MAX(collapse_bl.actual_BRDN_COST) actual_BRDN_COST
12243 , MAX(collapse_bl.actual_revenue) actual_revenue
12244 , MAX(collapse_bl.etc_raw_cost) etc_raw_cost
12245 , MAX(collapse_bl.etc_BRDN_COST) etc_BRDN_COST
12246 , MAX(collapse_bl.quantity) quantity
12247 , MAX(collapse_bl.actual_quantity) actual_quantity
12248 , MAX(collapse_bl.etc_quantity) etc_quantity
12249 , collapse_bl.period_name period_name -- , TRACK_AS_LABOR_FLAG track_as_labor_flag
12250 , collapse_bl.row_id
12251 , collapse_bl.plan_type_code /*4471527 */
12252 , collapse_bl.time_phased_type_code
12253 FROM
12254 ( ----- Second inline view 'collapse_bl' begin .............
12255 SELECT /*+ no_merge(spread_bl) */
12256 spread_bl.row_id row_id
12257 , spread_bl.PROJECT_ID
12258 , spread_bl.BUDGET_VERSION_ID
12259 , spread_bl.WBS_ELEMENT_ID
12260 , spread_bl.RBS_ELEMENT_ID
12261 , spread_bl.WBS_STRUCT_VERSION_ID
12262 , spread_bl.RBS_STRUCT_VERSION_ID
12263 , spread_bl.plan_type_id
12264 , spread_bl.BILLABLE_FLAG
12265 , spread_bl.RESOURCE_CLASS -- , spread_bl.CALENDAR_TYPE -- , pji_time.CALENDAR_ID
12266 , spread_bl.PROJECT_ORGANIZATION_ID
12267 , spread_bl.PROJECT_ORG_ID
12268 , DECODE( invert.INVERT_ID
12269 , 4, spread_bl.func_CURRENCY_CODE
12270 , 8, spread_bl.PRJ_CURRENCY_CODE
12271 , 16, spread_bl.TXN_CURRENCY_CODE ) CURRENCY_CODE
12272 , invert.INVERT_ID CURR_RECORD_TYPE_ID
12273 , DECODE ( invert.INVERT_ID
12274 , 4, spread_bl.func_raw_cost
12275 , 8, spread_bl.PRJ_raw_cost
12276 , 16, spread_bl.TXN_raw_cost) raw_cost
12277 , DECODE ( invert.INVERT_ID
12278 , 4, spread_bl.func_BRDN_COST
12279 , 8, spread_bl.PRJ_BRDN_COST
12280 , 16, spread_bl.TXN_BRDN_COST ) BRDN_COST
12281 , DECODE ( invert.INVERT_ID
12282 , 4, spread_bl.func_revenue
12283 , 8, spread_bl.PRJ_revenue
12284 , 16, spread_bl.TXN_revenue ) revenue
12285 , DECODE ( invert.INVERT_ID
12286 , 4, spread_bl.func_actual_raw_cost
12287 , 8, spread_bl.prj_actual_raw_cost
12288 , 16, spread_bl.txn_actual_raw_cost ) actual_raw_cost
12289 , DECODE ( invert.INVERT_ID
12290 , 4, spread_bl.func_actual_brdn_cost
12291 , 8, spread_bl.prj_actual_brdn_cost
12292 , 16, spread_bl.txn_actual_brdn_cost ) actual_brdn_cost
12293 , DECODE ( invert.INVERT_ID
12294 , 4, spread_bl.func_actual_revenue
12295 , 8, spread_bl.prj_actual_revenue
12296 , 16, spread_bl.txn_actual_revenue ) actual_revenue
12297 , DECODE ( invert.INVERT_ID
12298 , 4, spread_bl.func_etc_raw_cost
12299 , 8, spread_bl.prj_etc_raw_cost
12300 , 16, spread_bl.txn_etc_raw_cost ) etc_raw_cost
12301 , DECODE ( invert.INVERT_ID
12302 , 4, spread_bl.func_etc_brdn_cost
12303 , 8, spread_bl.prj_etc_brdn_cost
12304 , 16, spread_bl.txn_etc_brdn_cost ) etc_brdn_cost
12305 , spread_bl.quantity quantity
12306 , spread_bl.actual_quantity actual_quantity
12307 , spread_bl.etc_quantity etc_quantity
12308 , spread_bl.period_name period_name
12309 , spread_bl.plan_type_code plan_type_code /*4471527 */
12310 , spread_bl.time_phased_type_code
12311 FROM
12312 ( ----- Third inline view 'spread_bl' .............
12313 SELECT /*+ parallel(ver) */ -- Modified hints for bug 13897252
12314 bl.project_id
12315 , bl.ROWID row_id
12316 , bl.plan_version_id budget_version_id
12317 , DECODE(bl.project_element_id, 0, pevs.proj_element_id, bl.project_element_id) wbs_element_id
12318 , NVL(bl.rbs_element_id, -1) rbs_element_id
12319 , bl.struct_ver_id wbs_struct_version_id
12320 , NVL(ver.rbs_struct_version_id, -1) rbs_struct_version_id
12321 , bl.plan_type_id plan_type_id -- ver.plan_type_id
12322 , bl.rate_based_flag billable_flag -- ra.rate_based_flag billable_flag
12323 -- cbs change
12324 , 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',
12325 '1'||bl.resource_class_code, bl.resource_class_code),bl.resource_class_code) resource_class
12326 -- End cbs change
12327 , bl.txn_currency_code txn_currency_code
12328 , TO_NUMBER(NULL) txn_raw_cost -- bl.txn_raw_cost
12329 , TO_NUMBER(NULL) txn_BRDN_COST -- bl.txn_burdened_cost
12330 , TO_NUMBER(NULL) txn_revenue -- bl.txn_revenue
12331 , DECODE(p_extrn_type, 'FULL', TO_NUMBER(NULL), bl.act_txn_raw_cost) txn_actual_raw_cost
12332 , DECODE(p_extrn_type, 'FULL', TO_NUMBER(NULL), bl.act_txn_burdened_cost) txn_actual_brdn_cost
12333 , DECODE(p_extrn_type, 'FULL', TO_NUMBER(NULL), bl.act_txn_revenue) txn_actual_revenue
12334 , DECODE(p_extrn_type||l_extract_etc
12335 , 'FULLN'
12336 , TO_NUMBER(NULL)
12337 , bl.etc_txn_raw_cost) txn_etc_raw_cost
12338 , DECODE(p_extrn_type||l_extract_etc
12339 , 'FULLN'
12340 , TO_NUMBER(NULL)
12341 , bl.etc_txn_burdened_cost) txn_etc_brdn_cost
12342 , bl.prj_currency_code prj_currency_code
12343 , TO_NUMBER(NULL) prj_raw_cost -- bl.prj_raw_cost
12344 , TO_NUMBER(NULL) prj_BRDN_COST -- bl.prj_burdened_cost
12345 , TO_NUMBER(NULL) prj_revenue -- bl.prj_revenue
12346 , DECODE(p_extrn_type, 'FULL', TO_NUMBER(NULL), bl.act_prj_raw_cost) prj_actual_raw_cost
12347 , DECODE(p_extrn_type, 'FULL', TO_NUMBER(NULL), bl.act_prj_burdened_cost) prj_actual_brdn_cost
12348 , DECODE(p_extrn_type, 'FULL', TO_NUMBER(NULL), bl.act_prj_revenue) prj_actual_revenue
12349 , DECODE(p_extrn_type||l_extract_etc
12350 , 'FULLN'
12351 , TO_NUMBER(NULL)
12352 , bl.etc_prj_raw_cost) prj_etc_raw_cost
12353 , DECODE(p_extrn_type||l_extract_etc
12354 , 'FULLN'
12355 , TO_NUMBER(NULL)
12356 , bl.etc_prj_burdened_cost) prj_etc_brdn_cost
12357 , bl.pfc_currency_code func_currency_code
12358 , TO_NUMBER(NULL) func_raw_cost -- bl.pfc_raw_cost
12359 , TO_NUMBER(NULL) func_BRDN_COST -- bl.pfc_burdened_cost
12360 , TO_NUMBER(NULL) func_revenue -- bl.pfc_revenue
12361 , DECODE(p_extrn_type, 'FULL', TO_NUMBER(NULL), bl.act_pfc_raw_cost) func_actual_raw_cost
12362 , DECODE(p_extrn_type, 'FULL', TO_NUMBER(NULL), bl.act_pfc_burdened_cost) func_actual_brdn_cost
12363 , DECODE(p_extrn_type, 'FULL', TO_NUMBER(NULL), bl.act_pfc_revenue) func_actual_revenue
12364 , DECODE(p_extrn_type||l_extract_etc
12365 , 'FULLN'
12366 , TO_NUMBER(NULL)
12367 , bl.etc_pfc_raw_cost) func_etc_raw_cost
12368 , DECODE(p_extrn_type||l_extract_etc
12369 , 'FULLN'
12370 , TO_NUMBER(NULL)
12371 , bl.etc_pfc_burdened_cost) func_etc_brdn_cost
12372 , TO_NUMBER(NULL) quantity -- bl.quantity
12373 , DECODE(p_extrn_type, 'FULL', TO_NUMBER(NULL), bl.act_quantity) actual_quantity
12374 , DECODE(p_extrn_type||l_extract_etc
12375 , 'FULLN'
12376 , TO_NUMBER(NULL)
12377 , bl.etc_quantity) etc_quantity
12378 , NVL(bl.period_name, 'XXX') period_name
12379 , bl.project_org_id project_org_id
12380 , ppa.carrying_out_organization_id project_organization_id
12381 , ver.plan_type_code plan_type_code /*4471527 */
12382 , ver.time_phased_type_code
12383 FROM
12384 PJI_FM_EXTR_PLNVER4 ver
12385 , PJI_FM_EXTR_PLAN_LINES bl
12386 , PA_PROJECTS_ALL ppa
12387 , PA_PROJ_ELEM_VER_STRUCTURE pevs
12388 WHERE 1=1
12389 AND ver.wp_flag = 'Y'
12390 AND bl.project_id = ver.project_id
12391 AND bl.plan_version_id = ver.plan_version_id
12392 AND bl.plan_type_id = ver.plan_type_id
12393 AND ppa.project_id = ver.project_id
12394 AND bl.project_id = ppa.project_id
12395 AND bl.TXN_CURRENCY_CODE IS NOT NULL
12396 AND bl.prj_currency_code IS NOT NULL
12397 AND bl.pfc_currency_code IS NOT NULL
12398 AND pevs.element_version_id = ver.wbs_struct_version_id
12399 AND pevs.project_id = ver.project_id
12400 AND ver.worker_id = g_worker_id
12401 AND ver.time_phased_type_code IN ('P', 'G', 'N')
12402 ) spread_bl
12403 ---- end of third inline view 'spread_bl'...........
12404 ,
12405 (
12406 SELECT 4 INVERT_ID FROM dual UNION ALL
12407 SELECT 8 INVERT_ID FROM dual UNION ALL
12408 SELECT 16 INVERT_ID FROM dual where PJI_UTILS.GET_SETUP_PARAMETER('TXN_CURR_FLAG') = 'Y'
12409 ) invert
12410 ) collapse_bl
12411 ---- End of second inline view 'collapse_bl' ..........
12412 GROUP BY
12413 collapse_bl.PROJECT_ID
12414 , collapse_bl.WBS_ELEMENT_ID
12415 , collapse_bl.RBS_ELEMENT_ID
12416 , collapse_bl.RBS_STRUCT_VERSION_ID
12417 , collapse_bl.plan_type_id
12418 , collapse_bl.BUDGET_VERSION_ID
12419 , collapse_bl.PROJECT_ORGANIZATION_ID
12420 , collapse_bl.PROJECT_ORG_ID
12421 , collapse_bl.BILLABLE_FLAG
12422 , collapse_bl.RESOURCE_CLASS
12423 , collapse_bl.CURRENCY_CODE
12424 , collapse_bl.period_name
12425 , collapse_bl.row_id
12426 , collapse_bl.plan_type_code
12427 , collapse_bl.time_phased_type_code
12428 ) plr
12429 ---- End of first inline view plr ..........
12430 , PJI_ORG_EXTR_INFO orginfo
12431 , pji_time_cal_period_v pji_time
12432 WHERE 1=1
12433 -- AND orginfo.projfunc_currency_mau is not NULL
12434 AND plr.project_org_id = orginfo.org_id
12435 AND DECODE(plr.time_phased_type_code
12436 , 'P', orginfo.pa_calendar_id
12437 , 'G', orginfo.gl_calendar_id
12438 , - l_max_project_id ) = pji_time.calendar_id
12439 AND plr.period_name = pji_time.name
12440 GROUP BY
12441 plr.PROJECT_ID
12442 , plr.PROJECT_ORG_ID
12443 , plr.project_ORGANIZATION_ID
12444 , plr.WBS_ELEMENT_ID
12445 , DECODE(plr.time_phased_type_code
12446 , 'N', -1
12447 , pji_time.cal_period_id)
12448 , DECODE(plr.time_phased_type_code
12449 , 'P', 32
12450 , 'G', 32
12451 , 'N', 2048
12452 , -1) -- period type id...
12453 , DECODE(plr.time_phased_type_code
12454 , 'P', 'P'
12455 , 'G', 'G'
12456 , 'N', 'A'
12457 , 'X') -- CALENDAR_TYPE
12458 , plr.CURR_RECORD_TYPE -- curr code missing.
12459 , plr.currency_code
12460 , plr.RBS_ELEMENT_ID
12461 , plr.RBS_STRUCT_VERSION_ID
12462 , plr.BUDGET_VERSION_ID
12463 , plr.plan_type_id
12464 , DECODE(plr.time_phased_type_code, 'P', 'OF', 'G', 'OF', 'N', 'NTR', 'X')
12465 , plr.plan_type_code ; /*4471527 */
12466
12467 end if; /* Added for bug 11843459 */
12468
12469 print_time(' # of records from plan lines is : ' || SQL%ROWCOUNT );
12470
12471
12472 DELETE_NTP_CAL_RECORD ( p_max_project_id => l_max_project_id );
12473
12474 POPULATE_RBS_HDR;
12475 print_time(' RBS Header Populated.');
12476
12477 POPULATE_WBS_HDR;
12478 print_time('Populated new records into WBS Header Table.');
12479
12480 COMMIT; -- Added for bug 13897252
12481
12482 UPDATE_WBS_HDR; -- To be moved to separate step.
12483 print_time('Updated the WBS header table with min max txn dates.');
12484
12485 -- DELETE PLAN LINES.
12486
12487 EXCEPTION
12488 WHEN OTHERS THEN
12489 PJI_PJP_FP_CURR_WRAP.EXCP_HANDLER
12490 ( p_package_name => g_package_name
12491 , p_procedure_name => ' PROCESS_PENDING_PLAN_UPDATES '
12492 , x_return_status => x_return_status ) ;
12493
12494 RAISE;
12495 END PROCESS_PENDING_PLAN_UPDATES;
12496
12497 -- bug 6063826
12498 PROCEDURE UPDATE_WBS_HDR (p_worker_id in number) is
12499 pragma autonomous_transaction;
12500
12501 CURSOR wbs_cur IS
12502 SELECT pjp1.project_id
12503 , pjp1.plan_version_id, NVL(pjp1.plan_type_id, -1) plan_type_id
12504 , pjp1.PLAN_TYPE_CODE
12505 , cal.start_date min_txn_date
12506 , cal.end_date max_txn_date
12507 FROM PJI_FP_AGGR_PJP1 pjp1
12508 , pji_time_cal_period_v cal
12509 WHERE
12510 pjp1.worker_id = p_worker_id
12511 AND pjp1.time_id = cal.cal_period_id
12512 AND pjp1.calendar_type IN ('P', 'G') ; -- Non time ph and ent cals don't need to be considered.
12513
12514 TYPE proj_id_tab_type IS TABLE OF pji_pjp_wbs_header.project_id%TYPE;
12515 TYPE plan_ver_id_tab_type IS TABLE OF pji_pjp_wbs_header.plan_version_id%TYPE;
12516 TYPE plan_type_id_tab_type IS TABLE OF pji_pjp_wbs_header.plan_type_id%TYPE;
12517 TYPE plan_type_code_tab_type IS TABLE OF pji_pjp_wbs_header.plan_type_code%TYPE;
12518 TYPE min_txn_date_tab_type IS TABLE OF pji_pjp_wbs_header.min_txn_date%TYPE;
12519 TYPE max_txn_date_tab_type IS TABLE OF pji_pjp_wbs_header.max_txn_date%TYPE;
12520
12521 proj_id_tab proj_id_tab_TYPE;
12522 plan_ver_id_tab plan_ver_id_tab_TYPE;
12523 plan_type_id_tab plan_type_id_tab_TYPE;
12524 plan_type_code_tab plan_type_code_tab_TYPE;
12525 min_txn_date_tab min_txn_date_tab_type;
12526 max_txn_date_tab max_txn_date_tab_type;
12527
12528 BEGIN
12529
12530 /* Added for bug 13030627 */
12531 if PJI_UTILS.GET_PARAMETER('PJP_SIN_PRG') = 'Y' then
12532
12533 PJI_PJP_PRG_PERF_ALL.UPDATE_WBS_HDR_1;
12534
12535 else
12536
12537 OPEN wbs_cur;
12538
12539 LOOP
12540 FETCH wbs_cur BULK COLLECT
12541 INTO proj_id_tab,plan_ver_id_tab,plan_type_id_tab,
12542 plan_type_code_tab,min_txn_date_tab,max_txn_date_tab LIMIT 50000;
12543
12544 -- EXIT WHEN wbs_cur%NOTFOUND; -- bug 6316433
12545 If proj_id_tab.count > 0 then
12546 FORALL i IN proj_id_tab.FIRST .. proj_id_tab.LAST
12547 UPDATE /*+ index(whdr,PJI_PJP_WBS_HEADER_N1) */
12548 PJI_PJP_WBS_HEADER whdr
12549 SET MIN_TXN_DATE = LEAST(min_txn_date_tab(i), NVL(whdr.min_txn_date, min_txn_date_tab(i)))
12550 , MAX_TXN_DATE = GREATEST(max_txn_date_tab(i), NVL(whdr.max_txn_date, max_txn_date_tab(i)))
12551 , LAST_UPDATE_DATE = sysdate
12552 , LAST_UPDATED_BY = -9999
12553 , LAST_UPDATE_LOGIN = -9999
12554 WHERE whdr.plan_version_id = plan_ver_id_tab(i)
12555 AND whdr.project_id = proj_id_tab(i)
12556 AND NVL(whdr.plan_type_id, -1) = plan_type_id_tab(i)
12557 AND whdr.plan_type_code = plan_type_code_tab(i);
12558
12559 commit;
12560 proj_id_tab.delete;
12561 plan_ver_id_tab.delete;
12562 plan_type_id_tab.delete;
12563 plan_type_code_tab.delete;
12564 min_txn_date_tab.delete;
12565 max_txn_date_tab.delete;
12566 EXIT WHEN wbs_cur%NOTFOUND; -- bug 6316433
12567 Else
12568 Exit;
12569 End if;
12570 END LOOP;
12571 CLOSE wbs_cur;
12572
12573 end if;
12574
12575 END UPDATE_WBS_HDR;
12576
12577
12578 -- Bug 6316433 : Added batch processing logic
12579 PROCEDURE MERGE_INTO_FP_FACTS IS
12580
12581 l_last_update_date date := SYSDATE;
12582 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
12583 l_creation_date date := SYSDATE;
12584 l_created_by NUMBER := FND_GLOBAL.USER_ID;
12585 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
12586 l_process varchar2(30); /* Added for bug 7551819 */
12587 l_from_launch varchar2(5) := 'N'; /* Added for bug 7551819 */
12588 l_rec_exist number; --Added for bug 14636607
12589 /* Bug Fix 9212516*/
12590 l_num_workers NUMBER := 8;
12591 l_worker_id NUMBER := 8;
12592 l_table_owner VARCHAR2(30) := 'PJI';
12593 l_batch_size VARCHAR2(30) := 50000;
12594 l_any_rows_to_process BOOLEAN;
12595 l_table_name VARCHAR2(30) := 'PJI_FP_AGGR_PJP1';
12596 l_update_name VARCHAR2(30) := 'pjimerge.sql.1';
12597 l_start_rowid ROWID;
12598 l_end_rowid ROWID;
12599 l_rows_processed NUMBER;
12600 l_cur_fetch NUMBER := 0;
12601 l_update_id NUMBER;
12602
12603
12604 /*TYPE row_id_tab_type IS TABLE OF rowid index by binary_integer;
12605
12606
12607 x_row_id row_id_tab_type;
12608
12609 cursor c1 is
12610 select rowid from pji_fp_aggr_pjp1
12611 where worker_id = g_worker_id;*/
12612
12613 cursor c_update_id is
12614 select update_id
12615 from ad_parallel_updates
12616 where owner = upper(l_table_owner)
12617 and table_name = upper(l_table_name)
12618 and script_name = l_update_name;
12619
12620 /*Bug Fix 9212516*/
12621 BEGIN
12622
12623 /*Bug Fix 9212516*/
12624 open c_update_id;
12625 fetch c_update_id into l_update_id;
12626 close c_update_id;
12627
12628 delete
12629 from ad_parallel_workers
12630 where update_id = l_update_id;
12631
12632 delete
12633 from ad_parallel_update_units
12634 where update_id = l_update_id;
12635
12636 delete
12637 from ad_parallel_updates
12638 where update_id = l_update_id;
12639
12640 commit;
12641 /*Bug Fix 9212516*/
12642
12643 /* Added for bug 13030627 */
12644 if PJI_UTILS.GET_PARAMETER('PJP_SIN_PRG') = 'Y' then
12645
12646 PJI_PJP_PRG_PERF_ALL.MERGE_INTO_FP_FACTS;
12647
12648 else
12649
12650 print_time ( 'SAM MERGE_INTO_FP_FACTS worker id..' || g_worker_id || ' sysdate ' || sysdate) ;
12651
12652 l_process := PJI_PJP_SUM_MAIN.g_process || g_worker_id; /* Added for bug 7551819 */
12653
12654 select count(*) into l_rec_exist -- Start for bug 14636607
12655 from pji_fp_xbs_accum_f
12656 where rownum=1;
12657
12658 If l_rec_exist > 0 then -- End for bug 14636607
12659
12660 /* Added for bug 7551819 */
12661 begin
12662 select 'Y' into l_from_launch
12663 from dual
12664 where PJI_PROCESS_UTIL.GET_PROCESS_PARAMETER(l_process, 'FROM_PROJECT')
12665 like 'UPP-BATCH-%';
12666 exception
12667 when others then
12668 l_from_launch := 'N';
12669 end;
12670 /* Added for bug 7551819 */
12671
12672
12673 open c_update_id; /*Bug Fix 9212516*/
12674 /*open c1;
12675 loop
12676
12677 fetch c1 bulk collect into x_row_id limit 500000;
12678
12679 If x_row_id.count > 0 then*/
12680 /*Bug Fix 9212516*/
12681
12682 -- gather statistics for PJI metadata tables
12683 /* Gather stats by partition added for bug 7551819 */
12684 FND_STATS.GATHER_TABLE_STATS(ownname => PJI_UTILS.GET_PJI_SCHEMA_NAME,
12685 tabname => 'PJI_FP_AGGR_PJP1',
12686 partname=>'P'|| g_worker_id,
12687 granularity=>'PARTITION',
12688 percent => 5,
12689 degree => PJI_UTILS.GET_DEGREE_OF_PARALLELISM());
12690
12691 /* Added for bug 7551819
12692 If UPPD is submitted standalone, then gather stats is required.
12693 If UPPD is submitted from Launch process, gather stats is not required */
12694
12695 if l_from_launch = 'N' then
12696 IF nvl(FND_PROFILE.VALUE('PJI_GATHERSTATS_FACT'),'N') = 'Y' THEN -- Added for bug 11789673 Base bug 9824355
12697 -- gather statistics for PJI metadata tables
12698 FND_STATS.GATHER_TABLE_STATS(ownname => PJI_UTILS.GET_PJI_SCHEMA_NAME,
12699 tabname => 'PJI_FP_XBS_ACCUM_F',
12700 percent => 5,
12701 degree => PJI_UTILS.GET_DEGREE_OF_PARALLELISM());
12702 END IF;
12703 end if;
12704
12705 /*Bug Fix 9212516*/
12706 /*Forall i in x_row_id.first..x_row_id.last*/
12707 ad_parallel_updates_pkg.initialize_rowid_range(
12708 ad_parallel_updates_pkg.ROWID_RANGE,
12709 l_table_owner,
12710 l_table_name,
12711 l_update_name,
12712 l_worker_id,
12713 l_num_workers,
12714 l_batch_size, 0);
12715
12716 ad_parallel_updates_pkg.get_rowid_range(
12717 l_start_rowid,
12718 l_end_rowid,
12719 l_any_rows_to_process,
12720 l_batch_size,
12721 TRUE);
12722 /*Bug Fix 9212516*/
12723
12724 WHILE (l_any_rows_to_process) LOOP
12725
12726 MERGE INTO PJI_FP_XBS_ACCUM_F fact
12727 USING ( SELECT /*+ leading(tmp) rowid(tmp)*/
12728 tmp.worker_id
12729 , tmp.PROJECT_ID
12730 , tmp.PROJECT_ORG_ID
12731 , tmp.PROJECT_ORGANIZATION_ID
12732 , tmp.PROJECT_ELEMENT_ID
12733 , tmp.TIME_ID
12734 , tmp.PERIOD_TYPE_ID
12735 , tmp.CALENDAR_TYPE
12736 , tmp.RBS_AGGR_LEVEL
12737 , tmp.WBS_ROLLUP_FLAG
12738 , tmp.PRG_ROLLUP_FLAG
12739 , tmp.CURR_RECORD_TYPE_ID
12740 , tmp.CURRENCY_CODE
12741 , tmp.RBS_ELEMENT_ID
12742 , tmp.RBS_VERSION_ID
12743 , ver3.PLAN_VERSION_ID
12744 , tmp.PLAN_TYPE_ID
12745 , tmp.RAW_COST
12746 , tmp.BRDN_COST
12747 , tmp.REVENUE
12748 , tmp.BILL_RAW_COST
12749 , tmp.BILL_BRDN_COST
12750 , tmp.BILL_LABOR_RAW_COST
12751 , tmp.BILL_LABOR_BRDN_COST
12752 , tmp.BILL_LABOR_HRS
12753 , tmp.EQUIPMENT_RAW_COST
12754 , tmp.EQUIPMENT_BRDN_COST
12755 , tmp.CAPITALIZABLE_RAW_COST
12756 , tmp.CAPITALIZABLE_BRDN_COST
12757 , tmp.LABOR_RAW_COST
12758 , tmp.LABOR_BRDN_COST
12759 , tmp.LABOR_HRS
12760 , tmp.LABOR_REVENUE
12761 , tmp.EQUIPMENT_HOURS
12762 , tmp.BILLABLE_EQUIPMENT_HOURS
12763 , tmp.SUP_INV_COMMITTED_COST
12764 , tmp.PO_COMMITTED_COST
12765 , tmp.PR_COMMITTED_COST
12766 , tmp.OTH_COMMITTED_COST
12767 , tmp.ACT_LABOR_HRS
12768 , tmp.ACT_EQUIP_HRS
12769 , tmp.ACT_LABOR_BRDN_COST
12770 , tmp.ACT_EQUIP_BRDN_COST
12771 , tmp.ACT_BRDN_COST
12772 , tmp.ACT_RAW_COST
12773 , tmp.ACT_REVENUE
12774 , tmp.ACT_LABOR_RAW_COST
12775 , tmp.ACT_EQUIP_RAW_COST
12776 , DECODE ( ver3.wp_flag
12777 , 'Y'
12778 , DECODE(TO_CHAR(tmp.ETC_LABOR_HRS) -- For Workplan
12779 , NULL
12780 , NVL(tmp.labor_hrs, 0)
12781 , NVL(tmp.ETC_LABOR_HRS, 0)
12782 )
12783 , NVL(tmp.ETC_LABOR_HRS, 0)
12784 ) ETC_LABOR_HRS
12785 , DECODE ( ver3.wp_flag
12786 , 'Y'
12787 , DECODE(TO_CHAR(tmp.ETC_EQUIP_HRS)
12788 , NULL
12789 , NVL(tmp.EQUIPMENT_hours, 0)
12790 , NVL(tmp.ETC_EQUIP_HRS, 0)
12791 )
12792 , NVL(tmp.ETC_EQUIP_HRS, 0)
12793 ) ETC_EQUIP_HRS
12794 , DECODE ( ver3.wp_flag
12795 , 'Y'
12796 , DECODE(TO_CHAR(tmp.ETC_LABOR_BRDN_COST)
12797 , NULL
12798 , NVL(tmp.labor_BRDN_COST, 0)
12799 , NVL(tmp.ETC_LABOR_BRDN_COST, 0)
12800 )
12801 , NVL(tmp.ETC_LABOR_BRDN_COST, 0)
12802 ) ETC_LABOR_BRDN_COST
12803 , DECODE ( ver3.wp_flag
12804 , 'Y'
12805 , DECODE(TO_CHAR(tmp.ETC_EQUIP_BRDN_COST)
12806 , NULL
12807 , NVL(tmp.EQUIPment_BRDN_COST, 0)
12808 , NVL(tmp.ETC_equip_BRDN_COST, 0)
12809 )
12810 , NVL(tmp.ETC_EQUIP_BRDN_COST, 0)
12811 ) ETC_equip_BRDN_COST
12812 , DECODE ( ver3.wp_flag
12813 , 'Y'
12814 , DECODE(TO_CHAR(tmp.ETC_BRDN_COST)
12815 , NULL
12816 , NVL(tmp.BRDN_COST, 0)
12817 , NVL(tmp.ETC_BRDN_COST, 0)
12818 )
12819 , NVL(tmp.ETC_BRDN_COST, 0)
12820 ) ETC_BRDN_COST
12821 , DECODE ( ver3.wp_flag
12822 , 'Y'
12823 , DECODE(TO_CHAR(tmp.ETC_raw_COST)
12824 , NULL
12825 , NVL(tmp.raw_COST, 0)
12826 , NVL(tmp.ETC_raw_COST, 0)
12827 )
12828 , NVL(tmp.ETC_raw_COST, 0)
12829 ) ETC_raw_COST
12830 , DECODE ( ver3.wp_flag
12831 , 'Y'
12832 , DECODE(TO_CHAR(tmp.ETC_labor_raw_COST)
12833 , NULL
12834 , NVL(tmp.labor_raw_COST, 0)
12835 , NVL(tmp.ETC_labor_raw_COST, 0)
12836 )
12837 , NVL(tmp.ETC_labor_raw_COST, 0)
12838 ) ETC_labor_raw_COST
12839 , DECODE ( ver3.wp_flag
12840 , 'Y'
12841 , DECODE(TO_CHAR(tmp.ETC_equip_raw_COST)
12842 , NULL
12843 , NVL(tmp.equipment_raw_COST, 0)
12844 , NVL(tmp.ETC_equip_raw_COST, 0)
12845 )
12846 , NVL(tmp.ETC_equip_raw_COST, 0)
12847 ) ETC_equip_raw_COST
12848 , tmp.CUSTOM1
12849 , tmp.CUSTOM2
12850 , tmp.CUSTOM3
12851 , tmp.CUSTOM4
12852 , tmp.CUSTOM5
12853 , tmp.CUSTOM6
12854 , tmp.CUSTOM7
12855 , tmp.CUSTOM8
12856 , tmp.CUSTOM9
12857 , tmp.CUSTOM10
12858 , tmp.CUSTOM11
12859 , tmp.CUSTOM12
12860 , tmp.CUSTOM13
12861 , tmp.CUSTOM14
12862 , tmp.CUSTOM15
12863 , tmp.PLAN_TYPE_CODE
12864 FROM pji_fp_aggr_pjp1 tmp
12865 , pji_pjp_wbs_header ver3 -- replaced ver3 with wbs header for project-to-program association event.
12866 WHERE 1 = 1
12867 AND tmp.worker_id = g_worker_id
12868 AND tmp.project_id = ver3.project_id
12869 AND ver3.plan_version_id = tmp.plan_version_id
12870 AND NVL(tmp.plan_type_id,-1) = NVL(ver3.plan_type_id, -1) -- each plan type can have a different -3, -4 slice.
12871 AND ver3.plan_type_code = tmp.plan_type_code
12872 -- AND tmp.rowid = x_row_id(i) --Bug Fix 9212516
12873 AND tmp.rowid BETWEEN l_start_rowid AND l_end_rowid
12874 AND tmp.RATE_DANGLING_FLAG IS NULL
12875 AND tmp.TIME_DANGLING_FLAG IS NULL
12876 ) pjp1
12877 ON (pjp1.WORKER_ID = g_worker_id
12878 AND pjp1.PROJECT_ID = fact.PROJECT_ID
12879 AND pjp1.PLAN_VERSION_ID = fact.PLAN_VERSION_ID
12880 AND pjp1.PLAN_TYPE_ID = fact.PLAN_TYPE_ID
12881 AND pjp1.PLAN_TYPE_CODE = fact.PLAN_TYPE_CODE
12882 AND pjp1.PROJECT_ORG_ID = fact.PROJECT_ORG_ID
12883 AND pjp1.PROJECT_ORGANIZATION_ID = fact.PROJECT_ORGANIZATION_ID
12884 AND pjp1.PROJECT_ELEMENT_ID = fact.PROJECT_ELEMENT_ID
12885 AND pjp1.TIME_ID = fact.TIME_ID
12886 AND pjp1.PERIOD_TYPE_ID = fact.PERIOD_TYPE_ID
12887 AND pjp1.CALENDAR_TYPE = fact.CALENDAR_TYPE
12888 AND pjp1.RBS_AGGR_LEVEL = fact.RBS_AGGR_LEVEL
12889 AND pjp1.WBS_ROLLUP_FLAG = fact.WBS_ROLLUP_FLAG
12890 AND pjp1.PRG_ROLLUP_FLAG = fact.PRG_ROLLUP_FLAG
12891 AND pjp1.CURR_RECORD_TYPE_ID = fact.CURR_RECORD_TYPE_ID
12892 AND pjp1.CURRENCY_CODE = fact.CURRENCY_CODE
12893 AND pjp1.RBS_ELEMENT_ID = fact.RBS_ELEMENT_ID
12894 AND pjp1.RBS_VERSION_ID = fact.RBS_VERSION_ID)
12895 WHEN MATCHED THEN
12896 UPDATE
12897 SET fact.RAW_COST = NVL(fact.RAW_COST, 0) + NVL(pjp1.RAW_COST, 0)
12898 , fact.BRDN_COST = NVL(fact.BRDN_COST, 0) + NVL(pjp1.BRDN_COST, 0)
12899 , fact.REVENUE = NVL(fact.REVENUE, 0) + NVL(pjp1.REVENUE, 0)
12900 , fact.BILL_RAW_COST = NVL(fact.BILL_RAW_COST, 0) + NVL(pjp1.BILL_RAW_COST, 0)
12901 , fact.BILL_BRDN_COST = NVL(fact.BILL_BRDN_COST, 0) + NVL(pjp1.BILL_BRDN_COST, 0)
12902 , fact.BILL_LABOR_RAW_COST = NVL(fact.BILL_LABOR_RAW_COST, 0) + NVL(pjp1.BILL_LABOR_RAW_COST, 0)
12903 , fact.BILL_LABOR_BRDN_COST = NVL(fact.BILL_LABOR_BRDN_COST, 0) + NVL(pjp1.BILL_LABOR_BRDN_COST, 0)
12904 , fact.BILL_LABOR_HRS = NVL(fact.BILL_LABOR_HRS, 0) + NVL(pjp1.BILL_LABOR_HRS, 0)
12905 , fact.EQUIPMENT_RAW_COST = NVL(fact.EQUIPMENT_RAW_COST, 0) + NVL(pjp1.EQUIPMENT_RAW_COST, 0)
12906 , fact.EQUIPMENT_BRDN_COST = NVL(fact.EQUIPMENT_BRDN_COST, 0) + NVL(pjp1.EQUIPMENT_BRDN_COST, 0)
12907 , fact.CAPITALIZABLE_RAW_COST = NVL(fact.CAPITALIZABLE_RAW_COST, 0) + NVL(pjp1.CAPITALIZABLE_RAW_COST, 0)
12908 , fact.CAPITALIZABLE_BRDN_COST = NVL(fact.CAPITALIZABLE_BRDN_COST, 0) + NVL(pjp1.CAPITALIZABLE_BRDN_COST, 0)
12909 , fact.LABOR_RAW_COST = NVL(fact.LABOR_RAW_COST, 0) + NVL(pjp1.LABOR_RAW_COST, 0)
12910 , fact.LABOR_BRDN_COST = NVL(fact.LABOR_BRDN_COST, 0) + NVL(pjp1.LABOR_BRDN_COST, 0)
12911 , fact.LABOR_HRS = NVL(fact.LABOR_HRS, 0) + NVL(pjp1.LABOR_HRS, 0)
12912 , fact.LABOR_REVENUE = NVL(fact.LABOR_REVENUE, 0) + NVL(pjp1.LABOR_REVENUE, 0)
12913 , fact.EQUIPMENT_HOURS = NVL(fact.EQUIPMENT_HOURS, 0) + NVL(pjp1.EQUIPMENT_HOURS, 0)
12914 , fact.BILLABLE_EQUIPMENT_HOURS = NVL(fact.BILLABLE_EQUIPMENT_HOURS, 0) + NVL(pjp1.BILLABLE_EQUIPMENT_HOURS, 0)
12915 , fact.SUP_INV_COMMITTED_COST = NVL(fact.SUP_INV_COMMITTED_COST, 0) + NVL(pjp1.SUP_INV_COMMITTED_COST, 0)
12916 , fact.PO_COMMITTED_COST = NVL(fact.PO_COMMITTED_COST, 0) + NVL(pjp1.PO_COMMITTED_COST, 0)
12917 , fact.PR_COMMITTED_COST = NVL(fact.PR_COMMITTED_COST, 0) + NVL(pjp1.PR_COMMITTED_COST, 0)
12918 , fact.OTH_COMMITTED_COST = NVL(fact.OTH_COMMITTED_COST, 0) + NVL(pjp1.OTH_COMMITTED_COST, 0)
12919 , fact.ACT_LABOR_HRS = NVL(fact.ACT_LABOR_HRS, 0) + NVL(pjp1.ACT_LABOR_HRS, 0)
12920 , fact.ACT_EQUIP_HRS = NVL(fact.ACT_EQUIP_HRS, 0) + NVL(pjp1.ACT_EQUIP_HRS, 0)
12921 , fact.ACT_LABOR_BRDN_COST = NVL(fact.ACT_LABOR_BRDN_COST, 0) + NVL(pjp1.ACT_LABOR_BRDN_COST, 0)
12922 , fact.ACT_EQUIP_BRDN_COST = NVL(fact.ACT_EQUIP_BRDN_COST, 0) + NVL(pjp1.ACT_EQUIP_BRDN_COST, 0)
12923 , fact.ACT_BRDN_COST = NVL(fact.ACT_BRDN_COST, 0) + NVL(pjp1.ACT_BRDN_COST, 0)
12924 , fact.ACT_RAW_COST = NVL(fact.ACT_RAW_COST, 0) + NVL(pjp1.ACT_RAW_COST, 0)
12925 , fact.ACT_REVENUE = NVL(fact.ACT_REVENUE, 0) + NVL(pjp1.ACT_REVENUE, 0)
12926 , fact.ACT_LABOR_RAW_COST = NVL(fact.ACT_LABOR_RAW_COST, 0) + NVL(pjp1.ACT_LABOR_RAW_COST, 0)
12927 , fact.ACT_EQUIP_RAW_COST = NVL(fact.ACT_EQUIP_RAW_COST, 0) + NVL(pjp1.ACT_EQUIP_RAW_COST, 0)
12928 , fact.ETC_LABOR_HRS = NVL(fact.ETC_LABOR_HRS, 0) + NVL(pjp1.ETC_LABOR_HRS, 0)
12929 , fact.ETC_EQUIP_HRS = NVL(fact.ETC_EQUIP_HRS, 0) + NVL(pjp1.ETC_EQUIP_HRS, 0)
12930 , fact.ETC_LABOR_BRDN_COST = NVL(fact.ETC_LABOR_BRDN_COST, 0) + NVL(pjp1.ETC_LABOR_BRDN_COST, 0)
12931 , fact.ETC_EQUIP_BRDN_COST = NVL(fact.ETC_EQUIP_BRDN_COST, 0) + NVL(pjp1.ETC_EQUIP_BRDN_COST, 0)
12932 , fact.ETC_BRDN_COST = NVL(fact.ETC_BRDN_COST, 0) + NVL(pjp1.ETC_BRDN_COST, 0)
12933 , fact.ETC_RAW_COST = NVL(fact.ETC_RAW_COST, 0) + NVL(pjp1.ETC_RAW_COST, 0)
12934 , fact.ETC_LABOR_RAW_COST = NVL(fact.ETC_LABOR_RAW_COST, 0) + NVL(pjp1.ETC_LABOR_RAW_COST, 0)
12935 , fact.ETC_EQUIP_RAW_COST = NVL(fact.ETC_EQUIP_RAW_COST, 0) + NVL(pjp1.ETC_EQUIP_RAW_COST, 0)
12936 , fact.CUSTOM1 = NVL(fact.CUSTOM1, 0) + NVL(pjp1.CUSTOM1, 0)
12937 , fact.CUSTOM2 = NVL(fact.CUSTOM2, 0) + NVL(pjp1.CUSTOM2, 0)
12938 , fact.CUSTOM3 = NVL(fact.CUSTOM3, 0) + NVL(pjp1.CUSTOM3, 0)
12939 , fact.CUSTOM4 = NVL(fact.CUSTOM4, 0) + NVL(pjp1.CUSTOM4, 0)
12940 , fact.CUSTOM5 = NVL(fact.CUSTOM5, 0) + NVL(pjp1.CUSTOM5, 0)
12941 , fact.CUSTOM6 = NVL(fact.CUSTOM6, 0) + NVL(pjp1.CUSTOM6, 0)
12942 , fact.CUSTOM7 = NVL(fact.CUSTOM7, 0) + NVL(pjp1.CUSTOM7, 0)
12943 , fact.CUSTOM8 = NVL(fact.CUSTOM8, 0) + NVL(pjp1.CUSTOM8, 0)
12944 , fact.CUSTOM9 = NVL(fact.CUSTOM9, 0) + NVL(pjp1.CUSTOM9, 0)
12945 , fact.CUSTOM10 = NVL(fact.CUSTOM10, 0) + NVL(pjp1.CUSTOM10, 0)
12946 , fact.CUSTOM11 = NVL(fact.CUSTOM11, 0) + NVL(pjp1.CUSTOM11, 0)
12947 , fact.CUSTOM12 = NVL(fact.CUSTOM12, 0) + NVL(pjp1.CUSTOM12, 0)
12948 , fact.CUSTOM13 = NVL(fact.CUSTOM13, 0) + NVL(pjp1.CUSTOM13, 0)
12949 , fact.CUSTOM14 = NVL(fact.CUSTOM14, 0) + NVL(pjp1.CUSTOM14, 0)
12950 , fact.CUSTOM15 = NVL(fact.CUSTOM15, 0) + NVL(pjp1.CUSTOM15, 0)
12951 , fact.last_update_date = SYSDATE
12952 , fact.last_updated_by = l_last_updated_by
12953 , fact.last_update_login = l_last_update_login
12954 WHEN NOT MATCHED THEN
12955 INSERT (
12956 fact.PROJECT_ID
12957 , fact.PROJECT_ORG_ID
12958 , fact.PROJECT_ORGANIZATION_ID
12959 , fact.PROJECT_ELEMENT_ID
12960 , fact.TIME_ID
12961 , fact.PERIOD_TYPE_ID
12962 , fact.CALENDAR_TYPE
12963 , fact.RBS_AGGR_LEVEL
12964 , fact.WBS_ROLLUP_FLAG
12965 , fact.PRG_ROLLUP_FLAG
12966 , fact.CURR_RECORD_TYPE_ID
12967 , fact.CURRENCY_CODE
12968 , fact.RBS_ELEMENT_ID
12969 , fact.RBS_VERSION_ID
12970 , fact.PLAN_VERSION_ID
12971 , fact.PLAN_TYPE_ID
12972 , fact.LAST_UPDATE_DATE
12973 , fact.LAST_UPDATED_BY
12974 , fact.CREATION_DATE
12975 , fact.CREATED_BY
12976 , fact.LAST_UPDATE_LOGIN
12977 , fact.RAW_COST
12978 , fact.BRDN_COST
12979 , fact.REVENUE
12980 , fact.BILL_RAW_COST
12981 , fact.BILL_BRDN_COST
12982 , fact.BILL_LABOR_RAW_COST
12983 , fact.BILL_LABOR_BRDN_COST
12984 , fact.BILL_LABOR_HRS
12985 , fact.EQUIPMENT_RAW_COST
12986 , fact.EQUIPMENT_BRDN_COST
12987 , fact.CAPITALIZABLE_RAW_COST
12988 , fact.CAPITALIZABLE_BRDN_COST
12989 , fact.LABOR_RAW_COST
12990 , fact.LABOR_BRDN_COST
12991 , fact.LABOR_HRS
12992 , fact.LABOR_REVENUE
12993 , fact.EQUIPMENT_HOURS
12994 , fact.BILLABLE_EQUIPMENT_HOURS
12995 , fact.SUP_INV_COMMITTED_COST
12996 , fact.PO_COMMITTED_COST
12997 , fact.PR_COMMITTED_COST
12998 , fact.OTH_COMMITTED_COST
12999 , fact.ACT_LABOR_HRS
13000 , fact.ACT_EQUIP_HRS
13001 , fact.ACT_LABOR_BRDN_COST
13002 , fact.ACT_EQUIP_BRDN_COST
13003 , fact.ACT_BRDN_COST
13004 , fact.ACT_RAW_COST
13005 , fact.ACT_REVENUE
13006 , fact.ACT_LABOR_RAW_COST
13007 , fact.ACT_EQUIP_RAW_COST
13008 , fact.ETC_LABOR_HRS
13009 , fact.ETC_EQUIP_HRS
13010 , fact.ETC_LABOR_BRDN_COST
13011 , fact.ETC_EQUIP_BRDN_COST
13012 , fact.ETC_BRDN_COST
13013 , fact.ETC_RAW_COST
13014 , fact.ETC_LABOR_RAW_COST
13015 , fact.ETC_EQUIP_RAW_COST
13016 , fact.CUSTOM1
13017 , fact.CUSTOM2
13018 , fact.CUSTOM3
13019 , fact.CUSTOM4
13020 , fact.CUSTOM5
13021 , fact.CUSTOM6
13022 , fact.CUSTOM7
13023 , fact.CUSTOM8
13024 , fact.CUSTOM9
13025 , fact.CUSTOM10
13026 , fact.CUSTOM11
13027 , fact.CUSTOM12
13028 , fact.CUSTOM13
13029 , fact.CUSTOM14
13030 , fact.CUSTOM15
13031 , fact.PLAN_TYPE_CODE
13032 )
13033 VALUES (
13034 pjp1.PROJECT_ID
13035 , pjp1.PROJECT_ORG_ID
13036 , pjp1.PROJECT_ORGANIZATION_ID
13037 , pjp1.PROJECT_ELEMENT_ID
13038 , pjp1.TIME_ID
13039 , pjp1.PERIOD_TYPE_ID
13040 , pjp1.CALENDAR_TYPE
13041 , pjp1.RBS_AGGR_LEVEL
13042 , pjp1.WBS_ROLLUP_FLAG
13043 , pjp1.PRG_ROLLUP_FLAG
13044 , pjp1.CURR_RECORD_TYPE_ID
13045 , pjp1.CURRENCY_CODE
13046 , pjp1.RBS_ELEMENT_ID
13047 , pjp1.RBS_VERSION_ID
13048 , pjp1.PLAN_VERSION_ID
13049 , pjp1.PLAN_TYPE_ID
13050 , sysdate
13051 , l_last_updated_by
13052 , sysdate
13053 , l_created_by
13054 , l_last_update_login
13055 , pjp1.RAW_COST
13056 , pjp1.BRDN_COST
13057 , pjp1.REVENUE
13058 , pjp1.BILL_RAW_COST
13059 , pjp1.BILL_BRDN_COST
13060 , pjp1.BILL_LABOR_RAW_COST
13061 , pjp1.BILL_LABOR_BRDN_COST
13062 , pjp1.BILL_LABOR_HRS
13063 , pjp1.EQUIPMENT_RAW_COST
13064 , pjp1.EQUIPMENT_BRDN_COST
13065 , pjp1.CAPITALIZABLE_RAW_COST
13066 , pjp1.CAPITALIZABLE_BRDN_COST
13067 , pjp1.LABOR_RAW_COST
13068 , pjp1.LABOR_BRDN_COST
13069 , pjp1.LABOR_HRS
13070 , pjp1.LABOR_REVENUE
13071 , pjp1.EQUIPMENT_HOURS
13072 , pjp1.BILLABLE_EQUIPMENT_HOURS
13073 , pjp1.SUP_INV_COMMITTED_COST
13074 , pjp1.PO_COMMITTED_COST
13075 , pjp1.PR_COMMITTED_COST
13076 , pjp1.OTH_COMMITTED_COST
13077 , pjp1.ACT_LABOR_HRS
13078 , pjp1.ACT_EQUIP_HRS
13079 , pjp1.ACT_LABOR_BRDN_COST
13080 , pjp1.ACT_EQUIP_BRDN_COST
13081 , pjp1.ACT_BRDN_COST
13082 , pjp1.ACT_RAW_COST
13083 , pjp1.ACT_REVENUE
13084 , pjp1.ACT_LABOR_RAW_COST
13085 , pjp1.ACT_EQUIP_RAW_COST
13086 , pjp1.ETC_LABOR_HRS
13087 , pjp1.ETC_EQUIP_HRS
13088 , pjp1.ETC_LABOR_BRDN_COST
13089 , pjp1.ETC_equip_BRDN_COST
13090 , pjp1.ETC_BRDN_COST
13091 , pjp1.ETC_RAW_COST
13092 , pjp1.ETC_LABOR_RAW_COST
13093 , pjp1.ETC_EQUIP_RAW_COST
13094 , pjp1.CUSTOM1
13095 , pjp1.CUSTOM2
13096 , pjp1.CUSTOM3
13097 , pjp1.CUSTOM4
13098 , pjp1.CUSTOM5
13099 , pjp1.CUSTOM6
13100 , pjp1.CUSTOM7
13101 , pjp1.CUSTOM8
13102 , pjp1.CUSTOM9
13103 , pjp1.CUSTOM10
13104 , pjp1.CUSTOM11
13105 , pjp1.CUSTOM12
13106 , pjp1.CUSTOM13
13107 , pjp1.CUSTOM14
13108 , pjp1.CUSTOM15
13109 , pjp1.PLAN_TYPE_CODE
13110 );
13111
13112 print_time ( 'SAM MERGE_INTO_FP_FACTS worker id..' || g_worker_id || 'row count ' || SQL%ROWCOUNT) ;
13113
13114 /*Bug Fix 9212516*/
13115 l_rows_processed := SQL%ROWCOUNT;
13116
13117 ad_parallel_updates_pkg.processed_rowid_range(
13118 l_rows_processed,
13119 l_end_rowid);
13120
13121 /*Forall j in x_row_id.first..x_row_id.last
13122 delete from pji_fp_aggr_pjp1
13123 where worker_id = g_worker_id
13124 and rowid = x_row_id(j);
13125
13126 commit;
13127
13128 x_row_id.delete;
13129
13130 exit when c1%notfound;
13131 Else
13132 Exit;
13133 End if;
13134 end loop;
13135
13136 close c1;*/
13137
13138 ad_parallel_updates_pkg.get_rowid_range(
13139 l_start_rowid,
13140 l_end_rowid,
13141 l_any_rows_to_process,
13142 l_batch_size,
13143 FALSE);
13144
13145 END LOOP;
13146
13147 /*Bug Fix 9212516*/
13148
13149 /* Added for bug 14636607 Starts */
13150 else
13151
13152 FND_STATS.GATHER_TABLE_STATS(ownname => PJI_UTILS.GET_PJI_SCHEMA_NAME,
13153 tabname => 'PJI_FP_AGGR_PJP1',
13154 partname => 'P'|| g_worker_id,
13155 granularity => 'PARTITION',
13156 percent => 5,
13157 degree => PJI_UTILS.GET_DEGREE_OF_PARALLELISM());
13158
13159
13160 -- Disable indexes on fact table
13161 FOR ind_lp IN (SELECT table_owner||'.'||index_name ind_name
13162 , partitioned
13163 FROM dba_indexes
13164 WHERE table_name = 'PJI_FP_XBS_ACCUM_F'
13165 AND table_owner = PJI_UTILS.GET_PJI_SCHEMA_NAME
13166 AND status <> 'UNUSABLE') LOOP
13167
13168 IF ind_lp.partitioned = 'YES' THEN
13169 EXECUTE IMMEDIATE 'ALTER INDEX '||ind_lp.ind_name||' MODIFY PARTITION P'||g_worker_id||' UNUSABLE';
13170 ELSE
13171 EXECUTE IMMEDIATE 'ALTER INDEX '||ind_lp.ind_name||' UNUSABLE';
13172 END IF;
13173
13174 END LOOP;
13175
13176 PJI_FM_PLAN_MAINT_PVT.INSERT_INTO_FP_FACTS;
13177
13178 -- Put the indexes back
13179 FOR ind_lp IN (SELECT table_owner||'.'||index_name ind_name
13180 , partitioned
13181 FROM dba_indexes
13182 WHERE table_name = 'PJI_FP_XBS_ACCUM_F'
13183 AND table_owner = PJI_UTILS.GET_PJI_SCHEMA_NAME) LOOP
13184
13185 IF ind_lp.partitioned = 'YES' THEN
13186 EXECUTE IMMEDIATE 'ALTER INDEX '||ind_lp.ind_name||' REBUILD PARTITION P'||g_worker_id||' PARALLEL';
13187
13188 ELSE
13189 EXECUTE IMMEDIATE 'ALTER INDEX '||ind_lp.ind_name||' REBUILD PARALLEL';
13190 END IF;
13191
13192 END LOOP;
13193
13194 end if; /* Added for bug 14636607 Ends */
13195
13196 end if;
13197
13198 EXCEPTION
13199 WHEN OTHERS THEN
13200 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
13201 p_procedure_name => 'MERGE_INTO_FP_FACTS');
13202 /* Added for bug 14636607 Starts */
13203 -- Put the indexes back
13204 FOR ind_lp IN (SELECT table_owner||'.'||index_name ind_name
13205 , partitioned
13206 FROM dba_indexes
13207 WHERE table_name = 'PJI_FP_XBS_ACCUM_F'
13208 AND table_owner = PJI_UTILS.GET_PJI_SCHEMA_NAME) LOOP
13209
13210 IF ind_lp.partitioned = 'YES' THEN
13211 EXECUTE IMMEDIATE 'ALTER INDEX '||ind_lp.ind_name||' REBUILD PARTITION P'||g_worker_id||' PARALLEL';
13212 ELSE
13213 EXECUTE IMMEDIATE 'ALTER INDEX '||ind_lp.ind_name||' REBUILD PARALLEL';
13214 END IF;
13215
13216 END LOOP;
13217 /* Added for bug 14636607 Ends */
13218 RAISE;
13219 END MERGE_INTO_FP_FACTS;
13220
13221 /* Added below new procedure for bug 14517209 */
13222 PROCEDURE INSERT_INTO_FP_FACTS IS
13223
13224 l_last_update_date date := SYSDATE;
13225 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
13226 l_creation_date date := SYSDATE;
13227 l_created_by NUMBER := FND_GLOBAL.USER_ID;
13228 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
13229 l_from_launch varchar2(5) := 'N'; /* Added for bug 7551819 */
13230 l_process varchar2(30); /* Added for bug 7551819 */
13231 TYPE row_id_tab_type IS TABLE OF rowid index by binary_integer;
13232 x_row_id row_id_tab_type;
13233
13234 cursor c1 is
13235 select rowid from pji_fp_aggr_pjp1
13236 where worker_id = g_worker_id;
13237 BEGIN
13238
13239 print_time ( 'SAM INSERT_INTO_FP_FACTS worker id..' || g_worker_id || ' sysdate ' || sysdate) ;
13240 l_process := PJI_PJP_SUM_MAIN.g_process || g_worker_id; /* Added for bug 7551819 */
13241
13242 open c1;
13243 loop
13244
13245 fetch c1 bulk collect into x_row_id limit 500000;
13246
13247 If x_row_id.count > 0 then
13248
13249 Forall i in x_row_id.first..x_row_id.last
13250 INSERT into pji_fp_xbs_accum_f fact
13251 (
13252 fact.PROJECT_ID
13253 , fact.PROJECT_ORG_ID
13254 , fact.PROJECT_ORGANIZATION_ID
13255 , fact.PROJECT_ELEMENT_ID
13256 , fact.TIME_ID
13257 , fact.PERIOD_TYPE_ID
13258 , fact.CALENDAR_TYPE
13259 , fact.RBS_AGGR_LEVEL
13260 , fact.WBS_ROLLUP_FLAG
13261 , fact.PRG_ROLLUP_FLAG
13262 , fact.CURR_RECORD_TYPE_ID
13263 , fact.CURRENCY_CODE
13264 , fact.RBS_ELEMENT_ID
13265 , fact.RBS_VERSION_ID
13266 , fact.PLAN_VERSION_ID
13267 , fact.PLAN_TYPE_ID
13268 , fact.LAST_UPDATE_DATE
13269 , fact.LAST_UPDATED_BY
13270 , fact.CREATION_DATE
13271 , fact.CREATED_BY
13272 , fact.LAST_UPDATE_LOGIN
13273 , fact.RAW_COST
13274 , fact.BRDN_COST
13275 , fact.REVENUE
13276 , fact.BILL_RAW_COST
13277 , fact.BILL_BRDN_COST
13278 , fact.BILL_LABOR_RAW_COST
13279 , fact.BILL_LABOR_BRDN_COST
13280 , fact.BILL_LABOR_HRS
13281 , fact.EQUIPMENT_RAW_COST
13282 , fact.EQUIPMENT_BRDN_COST
13283 , fact.CAPITALIZABLE_RAW_COST
13284 , fact.CAPITALIZABLE_BRDN_COST
13285 , fact.LABOR_RAW_COST
13286 , fact.LABOR_BRDN_COST
13287 , fact.LABOR_HRS
13288 , fact.LABOR_REVENUE
13289 , fact.EQUIPMENT_HOURS
13290 , fact.BILLABLE_EQUIPMENT_HOURS
13291 , fact.SUP_INV_COMMITTED_COST
13292 , fact.PO_COMMITTED_COST
13293 , fact.PR_COMMITTED_COST
13294 , fact.OTH_COMMITTED_COST
13295 , fact.ACT_LABOR_HRS
13296 , fact.ACT_EQUIP_HRS
13297 , fact.ACT_LABOR_BRDN_COST
13298 , fact.ACT_EQUIP_BRDN_COST
13299 , fact.ACT_BRDN_COST
13300 , fact.ACT_RAW_COST
13301 , fact.ACT_REVENUE
13302 , fact.ACT_LABOR_RAW_COST
13303 , fact.ACT_EQUIP_RAW_COST
13304 , fact.ETC_LABOR_HRS
13305 , fact.ETC_EQUIP_HRS
13306 , fact.ETC_LABOR_BRDN_COST
13307 , fact.ETC_EQUIP_BRDN_COST
13308 , fact.ETC_BRDN_COST
13309 , fact.ETC_RAW_COST
13310 , fact.ETC_LABOR_RAW_COST
13311 , fact.ETC_EQUIP_RAW_COST
13312 , fact.CUSTOM1
13313 , fact.CUSTOM2
13314 , fact.CUSTOM3
13315 , fact.CUSTOM4
13316 , fact.CUSTOM5
13317 , fact.CUSTOM6
13318 , fact.CUSTOM7
13319 , fact.CUSTOM8
13320 , fact.CUSTOM9
13321 , fact.CUSTOM10
13322 , fact.CUSTOM11
13323 , fact.CUSTOM12
13324 , fact.CUSTOM13
13325 , fact.CUSTOM14
13326 , fact.CUSTOM15
13327 , fact.PLAN_TYPE_CODE
13328 )
13329 select
13330 pjp1.PROJECT_ID
13331 , pjp1.PROJECT_ORG_ID
13332 , pjp1.PROJECT_ORGANIZATION_ID
13333 , pjp1.PROJECT_ELEMENT_ID
13334 , pjp1.TIME_ID
13335 , pjp1.PERIOD_TYPE_ID
13336 , pjp1.CALENDAR_TYPE
13337 , pjp1.RBS_AGGR_LEVEL
13338 , pjp1.WBS_ROLLUP_FLAG
13339 , pjp1.PRG_ROLLUP_FLAG
13340 , pjp1.CURR_RECORD_TYPE_ID
13341 , pjp1.CURRENCY_CODE
13342 , pjp1.RBS_ELEMENT_ID
13343 , pjp1.RBS_VERSION_ID
13344 , pjp1.PLAN_VERSION_ID
13345 , pjp1.PLAN_TYPE_ID
13346 , sysdate
13347 , l_last_updated_by
13348 , sysdate
13349 , l_created_by
13350 , l_last_update_login
13351 , pjp1.RAW_COST
13352 , pjp1.BRDN_COST
13353 , pjp1.REVENUE
13354 , pjp1.BILL_RAW_COST
13355 , pjp1.BILL_BRDN_COST
13356 , pjp1.BILL_LABOR_RAW_COST
13357 , pjp1.BILL_LABOR_BRDN_COST
13358 , pjp1.BILL_LABOR_HRS
13359 , pjp1.EQUIPMENT_RAW_COST
13360 , pjp1.EQUIPMENT_BRDN_COST
13361 , pjp1.CAPITALIZABLE_RAW_COST
13362 , pjp1.CAPITALIZABLE_BRDN_COST
13363 , pjp1.LABOR_RAW_COST
13364 , pjp1.LABOR_BRDN_COST
13365 , pjp1.LABOR_HRS
13366 , pjp1.LABOR_REVENUE
13367 , pjp1.EQUIPMENT_HOURS
13368 , pjp1.BILLABLE_EQUIPMENT_HOURS
13369 , pjp1.SUP_INV_COMMITTED_COST
13370 , pjp1.PO_COMMITTED_COST
13371 , pjp1.PR_COMMITTED_COST
13372 , pjp1.OTH_COMMITTED_COST
13373 , pjp1.ACT_LABOR_HRS
13374 , pjp1.ACT_EQUIP_HRS
13375 , pjp1.ACT_LABOR_BRDN_COST
13376 , pjp1.ACT_EQUIP_BRDN_COST
13377 , pjp1.ACT_BRDN_COST
13378 , pjp1.ACT_RAW_COST
13379 , pjp1.ACT_REVENUE
13380 , pjp1.ACT_LABOR_RAW_COST
13381 , pjp1.ACT_EQUIP_RAW_COST
13382 , pjp1.ETC_LABOR_HRS
13383 , pjp1.ETC_EQUIP_HRS
13384 , pjp1.ETC_LABOR_BRDN_COST
13385 , pjp1.ETC_equip_BRDN_COST
13386 , pjp1.ETC_BRDN_COST
13387 , pjp1.ETC_RAW_COST
13388 , pjp1.ETC_LABOR_RAW_COST
13389 , pjp1.ETC_EQUIP_RAW_COST
13390 , pjp1.CUSTOM1
13391 , pjp1.CUSTOM2
13392 , pjp1.CUSTOM3
13393 , pjp1.CUSTOM4
13394 , pjp1.CUSTOM5
13395 , pjp1.CUSTOM6
13396 , pjp1.CUSTOM7
13397 , pjp1.CUSTOM8
13398 , pjp1.CUSTOM9
13399 , pjp1.CUSTOM10
13400 , pjp1.CUSTOM11
13401 , pjp1.CUSTOM12
13402 , pjp1.CUSTOM13
13403 , pjp1.CUSTOM14
13404 , pjp1.CUSTOM15
13405 , pjp1.PLAN_TYPE_CODE
13406 from
13407 (SELECT
13408 tmp.worker_id
13409 , tmp.PROJECT_ID
13410 , tmp.PROJECT_ORG_ID
13411 , tmp.PROJECT_ORGANIZATION_ID
13412 , tmp.PROJECT_ELEMENT_ID
13413 , tmp.TIME_ID
13414 , tmp.PERIOD_TYPE_ID
13415 , tmp.CALENDAR_TYPE
13416 , tmp.RBS_AGGR_LEVEL
13417 , tmp.WBS_ROLLUP_FLAG
13418 , tmp.PRG_ROLLUP_FLAG
13419 , tmp.CURR_RECORD_TYPE_ID
13420 , tmp.CURRENCY_CODE
13421 , tmp.RBS_ELEMENT_ID
13422 , tmp.RBS_VERSION_ID
13423 , ver3.PLAN_VERSION_ID
13424 , tmp.PLAN_TYPE_ID
13425 , tmp.RAW_COST
13426 , tmp.BRDN_COST
13427 , tmp.REVENUE
13428 , tmp.BILL_RAW_COST
13429 , tmp.BILL_BRDN_COST
13430 , tmp.BILL_LABOR_RAW_COST
13431 , tmp.BILL_LABOR_BRDN_COST
13432 , tmp.BILL_LABOR_HRS
13433 , tmp.EQUIPMENT_RAW_COST
13434 , tmp.EQUIPMENT_BRDN_COST
13435 , tmp.CAPITALIZABLE_RAW_COST
13436 , tmp.CAPITALIZABLE_BRDN_COST
13437 , tmp.LABOR_RAW_COST
13438 , tmp.LABOR_BRDN_COST
13439 , tmp.LABOR_HRS
13440 , tmp.LABOR_REVENUE
13441 , tmp.EQUIPMENT_HOURS
13442 , tmp.BILLABLE_EQUIPMENT_HOURS
13443 , tmp.SUP_INV_COMMITTED_COST
13444 , tmp.PO_COMMITTED_COST
13445 , tmp.PR_COMMITTED_COST
13446 , tmp.OTH_COMMITTED_COST
13447 , tmp.ACT_LABOR_HRS
13448 , tmp.ACT_EQUIP_HRS
13449 , tmp.ACT_LABOR_BRDN_COST
13450 , tmp.ACT_EQUIP_BRDN_COST
13451 , tmp.ACT_BRDN_COST
13452 , tmp.ACT_RAW_COST
13453 , tmp.ACT_REVENUE
13454 , tmp.ACT_LABOR_RAW_COST
13455 , tmp.ACT_EQUIP_RAW_COST
13456 , DECODE ( ver3.wp_flag
13457 , 'Y'
13458 , DECODE(TO_CHAR(tmp.ETC_LABOR_HRS) -- For Workplan
13459 , NULL
13460 , NVL(tmp.labor_hrs, 0)
13461 , NVL(tmp.ETC_LABOR_HRS, 0)
13462 )
13463 , NVL(tmp.ETC_LABOR_HRS, 0)
13464 ) ETC_LABOR_HRS
13465 , DECODE ( ver3.wp_flag
13466 , 'Y'
13467 , DECODE(TO_CHAR(tmp.ETC_EQUIP_HRS)
13468 , NULL
13469 , NVL(tmp.EQUIPMENT_hours, 0)
13470 , NVL(tmp.ETC_EQUIP_HRS, 0)
13471 )
13472 , NVL(tmp.ETC_EQUIP_HRS, 0)
13473 ) ETC_EQUIP_HRS
13474 , DECODE ( ver3.wp_flag
13475 , 'Y'
13476 , DECODE(TO_CHAR(tmp.ETC_LABOR_BRDN_COST)
13477 , NULL
13478 , NVL(tmp.labor_BRDN_COST, 0)
13479 , NVL(tmp.ETC_LABOR_BRDN_COST, 0)
13480 )
13481 , NVL(tmp.ETC_LABOR_BRDN_COST, 0)
13482 ) ETC_LABOR_BRDN_COST
13483 , DECODE ( ver3.wp_flag
13484 , 'Y'
13485 , DECODE(TO_CHAR(tmp.ETC_EQUIP_BRDN_COST)
13486 , NULL
13487 , NVL(tmp.EQUIPment_BRDN_COST, 0)
13488 , NVL(tmp.ETC_equip_BRDN_COST, 0)
13489 )
13490 , NVL(tmp.ETC_EQUIP_BRDN_COST, 0)
13491 ) ETC_equip_BRDN_COST
13492 , DECODE ( ver3.wp_flag
13493 , 'Y'
13494 , DECODE(TO_CHAR(tmp.ETC_BRDN_COST)
13495 , NULL
13496 , NVL(tmp.BRDN_COST, 0)
13497 , NVL(tmp.ETC_BRDN_COST, 0)
13498 )
13499 , NVL(tmp.ETC_BRDN_COST, 0)
13500 ) ETC_BRDN_COST
13501 , DECODE ( ver3.wp_flag
13502 , 'Y'
13503 , DECODE(TO_CHAR(tmp.ETC_raw_COST)
13504 , NULL
13505 , NVL(tmp.raw_COST, 0)
13506 , NVL(tmp.ETC_raw_COST, 0)
13507 )
13508 , NVL(tmp.ETC_raw_COST, 0)
13509 ) ETC_raw_COST
13510 , DECODE ( ver3.wp_flag
13511 , 'Y'
13512 , DECODE(TO_CHAR(tmp.ETC_labor_raw_COST)
13513 , NULL
13514 , NVL(tmp.labor_raw_COST, 0)
13515 , NVL(tmp.ETC_labor_raw_COST, 0)
13516 )
13517 , NVL(tmp.ETC_labor_raw_COST, 0)
13518 ) ETC_labor_raw_COST
13519 , DECODE ( ver3.wp_flag
13520 , 'Y'
13521 , DECODE(TO_CHAR(tmp.ETC_equip_raw_COST)
13522 , NULL
13523 , NVL(tmp.equipment_raw_COST, 0)
13524 , NVL(tmp.ETC_equip_raw_COST, 0)
13525 )
13526 , NVL(tmp.ETC_equip_raw_COST, 0)
13527 ) ETC_equip_raw_COST
13528 , tmp.CUSTOM1
13529 , tmp.CUSTOM2
13530 , tmp.CUSTOM3
13531 , tmp.CUSTOM4
13532 , tmp.CUSTOM5
13533 , tmp.CUSTOM6
13534 , tmp.CUSTOM7
13535 , tmp.CUSTOM8
13536 , tmp.CUSTOM9
13537 , tmp.CUSTOM10
13538 , tmp.CUSTOM11
13539 , tmp.CUSTOM12
13540 , tmp.CUSTOM13
13541 , tmp.CUSTOM14
13542 , tmp.CUSTOM15
13543 , tmp.PLAN_TYPE_CODE
13544 FROM pji_fp_aggr_pjp1 tmp
13545 , pji_pjp_wbs_header ver3
13546 WHERE 1 = 1
13547 AND tmp.worker_id = g_worker_id
13548 AND tmp.project_id = ver3.project_id
13549 AND ver3.plan_version_id = tmp.plan_version_id
13550 AND NVL(tmp.plan_type_id,-1) = NVL(ver3.plan_type_id, -1) -- each plan type can have a different -3, -4 slice.
13551 AND ver3.plan_type_code = tmp.plan_type_code
13552 AND tmp.rowid = x_row_id(i)
13553 AND tmp.RATE_DANGLING_FLAG IS NULL
13554 AND tmp.TIME_DANGLING_FLAG IS NULL
13555 ) pjp1 ;
13556
13557 print_time ( 'SAM INSERT_INTO_FP_FACTS worker id..' || g_worker_id || 'row count ' || SQL%ROWCOUNT) ;
13558
13559 Forall j in x_row_id.first..x_row_id.last
13560 delete from pji_fp_aggr_pjp1
13561 where worker_id = g_worker_id
13562 and rowid = x_row_id(j);
13563
13564 commit;
13565
13566 x_row_id.delete;
13567 exit when c1%notfound;
13568 Else
13569 Exit;
13570 End if;
13571 end loop;
13572
13573 close c1;
13574
13575 /* Gather stats since we have inserted data into fact table */
13576 FND_STATS.GATHER_TABLE_STATS(ownname => PJI_UTILS.GET_PJI_SCHEMA_NAME,
13577 tabname => 'PJI_FP_XBS_ACCUM_F',
13578 percent => 5,
13579 degree => PJI_UTILS.GET_DEGREE_OF_PARALLELISM());
13580
13581 EXCEPTION
13582 WHEN OTHERS THEN
13583 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
13584 p_procedure_name => 'INSERT_INTO_FP_FACTS');
13585 RAISE;
13586 END INSERT_INTO_FP_FACTS;
13587 -- End for bug# 14636607
13588
13589
13590 /* Added for bug 13030627 */
13591 PROCEDURE MERGE_HELPER(errbuf OUT NOCOPY VARCHAR2,
13592 retcode OUT NOCOPY VARCHAR2,
13593 p_batch_id IN number)
13594 IS
13595 l_last_update_date date := SYSDATE;
13596 l_last_updated_by NUMBER := FND_GLOBAL.USER_ID;
13597 l_creation_date date := SYSDATE;
13598 l_created_by NUMBER := FND_GLOBAL.USER_ID;
13599 l_last_update_login NUMBER := FND_GLOBAL.LOGIN_ID;
13600 l_process varchar2(30);
13601 l_from_launch varchar2(5) := 'N'; /* Added for bug 8416116 */
13602
13603 TYPE row_id_tab_type IS TABLE OF rowid index by binary_integer;
13604 x_row_id row_id_tab_type;
13605 xf_row_id row_id_tab_type;
13606
13607 cursor c1(x_batch_id number) is
13608 select /*+ parallel(pji_merge_helper) */
13609 pjp_row_id,
13610 fact_row_id
13611 from pji_merge_helper
13612 where batch_id = x_batch_id;
13613
13614 BEGIN
13615
13616 l_process := PJI_PJP_SUM_MAIN.g_process || g_worker_id; /* Added for bug 8416116 */
13617
13618 MERGE INTO PJI_FP_XBS_ACCUM_F fact
13619 USING ( SELECT
13620 tmp.worker_id
13621 , tmp.PROJECT_ID
13622 , tmp.PROJECT_ORG_ID
13623 , tmp.PROJECT_ORGANIZATION_ID
13624 , tmp.PROJECT_ELEMENT_ID
13625 , tmp.TIME_ID
13626 , tmp.PERIOD_TYPE_ID
13627 , tmp.CALENDAR_TYPE
13628 , tmp.RBS_AGGR_LEVEL
13629 , tmp.WBS_ROLLUP_FLAG
13630 , tmp.PRG_ROLLUP_FLAG
13631 , tmp.CURR_RECORD_TYPE_ID
13632 , tmp.CURRENCY_CODE
13633 , tmp.RBS_ELEMENT_ID
13634 , tmp.RBS_VERSION_ID
13635 , ver3.PLAN_VERSION_ID
13636 , tmp.PLAN_TYPE_ID
13637 , tmp.RAW_COST
13638 , tmp.BRDN_COST
13639 , tmp.REVENUE
13640 , tmp.BILL_RAW_COST
13641 , tmp.BILL_BRDN_COST
13642 , tmp.BILL_LABOR_RAW_COST
13643 , tmp.BILL_LABOR_BRDN_COST
13644 , tmp.BILL_LABOR_HRS
13645 , tmp.EQUIPMENT_RAW_COST
13646 , tmp.EQUIPMENT_BRDN_COST
13647 , tmp.CAPITALIZABLE_RAW_COST
13648 , tmp.CAPITALIZABLE_BRDN_COST
13649 , tmp.LABOR_RAW_COST
13650 , tmp.LABOR_BRDN_COST
13651 , tmp.LABOR_HRS
13652 , tmp.LABOR_REVENUE
13653 , tmp.EQUIPMENT_HOURS
13654 , tmp.BILLABLE_EQUIPMENT_HOURS
13655 , tmp.SUP_INV_COMMITTED_COST
13656 , tmp.PO_COMMITTED_COST
13657 , tmp.PR_COMMITTED_COST
13658 , tmp.OTH_COMMITTED_COST
13659 , tmp.ACT_LABOR_HRS
13660 , tmp.ACT_EQUIP_HRS
13661 , tmp.ACT_LABOR_BRDN_COST
13662 , tmp.ACT_EQUIP_BRDN_COST
13663 , tmp.ACT_BRDN_COST
13664 , tmp.ACT_RAW_COST
13665 , tmp.ACT_REVENUE
13666 , tmp.ACT_LABOR_RAW_COST
13667 , tmp.ACT_EQUIP_RAW_COST
13668 , DECODE ( ver3.wp_flag
13669 , 'Y'
13670 , DECODE(TO_CHAR(tmp.ETC_LABOR_HRS)
13671 , NULL
13672 , NVL(tmp.labor_hrs, 0)
13673 , NVL(tmp.ETC_LABOR_HRS, 0)
13674 )
13675 , NVL(tmp.ETC_LABOR_HRS, 0)
13676 ) ETC_LABOR_HRS
13677 , DECODE ( ver3.wp_flag
13678 , 'Y'
13679 , DECODE(TO_CHAR(tmp.ETC_EQUIP_HRS)
13680 , NULL
13681 , NVL(tmp.EQUIPMENT_hours, 0)
13682 , NVL(tmp.ETC_EQUIP_HRS, 0)
13683 )
13684 , NVL(tmp.ETC_EQUIP_HRS, 0)
13685 ) ETC_EQUIP_HRS
13686 , DECODE ( ver3.wp_flag
13687 , 'Y'
13688 , DECODE(TO_CHAR(tmp.ETC_LABOR_BRDN_COST)
13689 , NULL
13690 , NVL(tmp.labor_BRDN_COST, 0)
13691 , NVL(tmp.ETC_LABOR_BRDN_COST, 0)
13692 )
13693 , NVL(tmp.ETC_LABOR_BRDN_COST, 0)
13694 ) ETC_LABOR_BRDN_COST
13695 , DECODE ( ver3.wp_flag
13696 , 'Y'
13697 , DECODE(TO_CHAR(tmp.ETC_EQUIP_BRDN_COST)
13698 , NULL
13699 , NVL(tmp.EQUIPment_BRDN_COST, 0)
13700 , NVL(tmp.ETC_equip_BRDN_COST, 0)
13701 )
13702 , NVL(tmp.ETC_EQUIP_BRDN_COST, 0)
13703 ) ETC_equip_BRDN_COST
13704 , DECODE ( ver3.wp_flag
13705 , 'Y'
13706 , DECODE(TO_CHAR(tmp.ETC_BRDN_COST)
13707 , NULL
13708 , NVL(tmp.BRDN_COST, 0)
13709 , NVL(tmp.ETC_BRDN_COST, 0)
13710 )
13711 , NVL(tmp.ETC_BRDN_COST, 0)
13712 ) ETC_BRDN_COST
13713 , DECODE ( ver3.wp_flag
13714 , 'Y'
13715 , DECODE(TO_CHAR(tmp.ETC_raw_COST)
13716 , NULL
13717 , NVL(tmp.raw_COST, 0)
13718 , NVL(tmp.ETC_raw_COST, 0)
13719 )
13720 , NVL(tmp.ETC_raw_COST, 0)
13721 ) ETC_raw_COST
13722 , DECODE ( ver3.wp_flag
13723 , 'Y'
13724 , DECODE(TO_CHAR(tmp.ETC_labor_raw_COST)
13725 , NULL
13726 , NVL(tmp.labor_raw_COST, 0)
13727 , NVL(tmp.ETC_labor_raw_COST, 0)
13728 )
13729 , NVL(tmp.ETC_labor_raw_COST, 0)
13730 ) ETC_labor_raw_COST
13731 , DECODE ( ver3.wp_flag
13732 , 'Y'
13733 , DECODE(TO_CHAR(tmp.ETC_equip_raw_COST)
13734 , NULL
13735 , NVL(tmp.equipment_raw_COST, 0)
13736 , NVL(tmp.ETC_equip_raw_COST, 0)
13737 )
13738 , NVL(tmp.ETC_equip_raw_COST, 0)
13739 ) ETC_equip_raw_COST
13740 , tmp.CUSTOM1
13741 , tmp.CUSTOM2
13742 , tmp.CUSTOM3
13743 , tmp.CUSTOM4
13744 , tmp.CUSTOM5
13745 , tmp.CUSTOM6
13746 , tmp.CUSTOM7
13747 , tmp.CUSTOM8
13748 , tmp.CUSTOM9
13749 , tmp.CUSTOM10
13750 , tmp.CUSTOM11
13751 , tmp.CUSTOM12
13752 , tmp.CUSTOM13
13753 , tmp.CUSTOM14
13754 , tmp.CUSTOM15
13755 , tmp.PLAN_TYPE_CODE
13756 , tmp.fact_row_id
13757 FROM pji_merge_helper tmp
13758 , pji_pjp_wbs_header ver3
13759 WHERE 1 = 1
13760 AND tmp.worker_id = g_worker_id
13761 AND tmp.project_id = ver3.project_id
13762 AND ver3.plan_version_id = tmp.plan_version_id
13763 AND NVL(tmp.plan_type_id,-1) = NVL(ver3.plan_type_id, -1)
13764 AND ver3.plan_type_code = tmp.plan_type_code
13765 AND tmp.batch_id = p_batch_id
13766 AND tmp.RATE_DANGLING_FLAG IS NULL
13767 AND tmp.TIME_DANGLING_FLAG IS NULL
13768 ) pjp1
13769 ON (pjp1.WORKER_ID = g_worker_id
13770 AND fact.rowid = pjp1.fact_row_id)
13771 WHEN MATCHED THEN
13772 UPDATE
13773 SET fact.RAW_COST = NVL(fact.RAW_COST, 0) + NVL(pjp1.RAW_COST, 0)
13774 , fact.BRDN_COST = NVL(fact.BRDN_COST, 0) + NVL(pjp1.BRDN_COST, 0)
13775 , fact.REVENUE = NVL(fact.REVENUE, 0) + NVL(pjp1.REVENUE, 0)
13776 , fact.BILL_RAW_COST = NVL(fact.BILL_RAW_COST, 0) + NVL(pjp1.BILL_RAW_COST, 0)
13777 , fact.BILL_BRDN_COST = NVL(fact.BILL_BRDN_COST, 0) + NVL(pjp1.BILL_BRDN_COST, 0)
13778 , fact.BILL_LABOR_RAW_COST = NVL(fact.BILL_LABOR_RAW_COST, 0) + NVL(pjp1.BILL_LABOR_RAW_COST, 0)
13779 , fact.BILL_LABOR_BRDN_COST = NVL(fact.BILL_LABOR_BRDN_COST, 0) + NVL(pjp1.BILL_LABOR_BRDN_COST, 0)
13780 , fact.BILL_LABOR_HRS = NVL(fact.BILL_LABOR_HRS, 0) + NVL(pjp1.BILL_LABOR_HRS, 0)
13781 , fact.EQUIPMENT_RAW_COST = NVL(fact.EQUIPMENT_RAW_COST, 0) + NVL(pjp1.EQUIPMENT_RAW_COST, 0)
13782 , fact.EQUIPMENT_BRDN_COST = NVL(fact.EQUIPMENT_BRDN_COST, 0) + NVL(pjp1.EQUIPMENT_BRDN_COST, 0)
13783 , fact.CAPITALIZABLE_RAW_COST = NVL(fact.CAPITALIZABLE_RAW_COST, 0) + NVL(pjp1.CAPITALIZABLE_RAW_COST, 0)
13784 , fact.CAPITALIZABLE_BRDN_COST = NVL(fact.CAPITALIZABLE_BRDN_COST, 0) + NVL(pjp1.CAPITALIZABLE_BRDN_COST, 0)
13785 , fact.LABOR_RAW_COST = NVL(fact.LABOR_RAW_COST, 0) + NVL(pjp1.LABOR_RAW_COST, 0)
13786 , fact.LABOR_BRDN_COST = NVL(fact.LABOR_BRDN_COST, 0) + NVL(pjp1.LABOR_BRDN_COST, 0)
13787 , fact.LABOR_HRS = NVL(fact.LABOR_HRS, 0) + NVL(pjp1.LABOR_HRS, 0)
13788 , fact.LABOR_REVENUE = NVL(fact.LABOR_REVENUE, 0) + NVL(pjp1.LABOR_REVENUE, 0)
13789 , fact.EQUIPMENT_HOURS = NVL(fact.EQUIPMENT_HOURS, 0) + NVL(pjp1.EQUIPMENT_HOURS, 0)
13790 , fact.BILLABLE_EQUIPMENT_HOURS = NVL(fact.BILLABLE_EQUIPMENT_HOURS, 0) + NVL(pjp1.BILLABLE_EQUIPMENT_HOURS, 0)
13791 , fact.SUP_INV_COMMITTED_COST = NVL(fact.SUP_INV_COMMITTED_COST, 0) + NVL(pjp1.SUP_INV_COMMITTED_COST, 0)
13792 , fact.PO_COMMITTED_COST = NVL(fact.PO_COMMITTED_COST, 0) + NVL(pjp1.PO_COMMITTED_COST, 0)
13793 , fact.PR_COMMITTED_COST = NVL(fact.PR_COMMITTED_COST, 0) + NVL(pjp1.PR_COMMITTED_COST, 0)
13794 , fact.OTH_COMMITTED_COST = NVL(fact.OTH_COMMITTED_COST, 0) + NVL(pjp1.OTH_COMMITTED_COST, 0)
13795 , fact.ACT_LABOR_HRS = NVL(fact.ACT_LABOR_HRS, 0) + NVL(pjp1.ACT_LABOR_HRS, 0)
13796 , fact.ACT_EQUIP_HRS = NVL(fact.ACT_EQUIP_HRS, 0) + NVL(pjp1.ACT_EQUIP_HRS, 0)
13797 , fact.ACT_LABOR_BRDN_COST = NVL(fact.ACT_LABOR_BRDN_COST, 0) + NVL(pjp1.ACT_LABOR_BRDN_COST, 0)
13798 , fact.ACT_EQUIP_BRDN_COST = NVL(fact.ACT_EQUIP_BRDN_COST, 0) + NVL(pjp1.ACT_EQUIP_BRDN_COST, 0)
13799 , fact.ACT_BRDN_COST = NVL(fact.ACT_BRDN_COST, 0) + NVL(pjp1.ACT_BRDN_COST, 0)
13800 , fact.ACT_RAW_COST = NVL(fact.ACT_RAW_COST, 0) + NVL(pjp1.ACT_RAW_COST, 0)
13801 , fact.ACT_REVENUE = NVL(fact.ACT_REVENUE, 0) + NVL(pjp1.ACT_REVENUE, 0)
13802 , fact.ACT_LABOR_RAW_COST = NVL(fact.ACT_LABOR_RAW_COST, 0) + NVL(pjp1.ACT_LABOR_RAW_COST, 0)
13803 , fact.ACT_EQUIP_RAW_COST = NVL(fact.ACT_EQUIP_RAW_COST, 0) + NVL(pjp1.ACT_EQUIP_RAW_COST, 0)
13804 , fact.ETC_LABOR_HRS = NVL(fact.ETC_LABOR_HRS, 0) + NVL(pjp1.ETC_LABOR_HRS, 0)
13805 , fact.ETC_EQUIP_HRS = NVL(fact.ETC_EQUIP_HRS, 0) + NVL(pjp1.ETC_EQUIP_HRS, 0)
13806 , fact.ETC_LABOR_BRDN_COST = NVL(fact.ETC_LABOR_BRDN_COST, 0) + NVL(pjp1.ETC_LABOR_BRDN_COST, 0)
13807 , fact.ETC_EQUIP_BRDN_COST = NVL(fact.ETC_EQUIP_BRDN_COST, 0) + NVL(pjp1.ETC_EQUIP_BRDN_COST, 0)
13808 , fact.ETC_BRDN_COST = NVL(fact.ETC_BRDN_COST, 0) + NVL(pjp1.ETC_BRDN_COST, 0)
13809 , fact.ETC_RAW_COST = NVL(fact.ETC_RAW_COST, 0) + NVL(pjp1.ETC_RAW_COST, 0)
13810 , fact.ETC_LABOR_RAW_COST = NVL(fact.ETC_LABOR_RAW_COST, 0) + NVL(pjp1.ETC_LABOR_RAW_COST, 0)
13811 , fact.ETC_EQUIP_RAW_COST = NVL(fact.ETC_EQUIP_RAW_COST, 0) + NVL(pjp1.ETC_EQUIP_RAW_COST, 0)
13812 , fact.CUSTOM1 = NVL(fact.CUSTOM1, 0) + NVL(pjp1.CUSTOM1, 0)
13813 , fact.CUSTOM2 = NVL(fact.CUSTOM2, 0) + NVL(pjp1.CUSTOM2, 0)
13814 , fact.CUSTOM3 = NVL(fact.CUSTOM3, 0) + NVL(pjp1.CUSTOM3, 0)
13815 , fact.CUSTOM4 = NVL(fact.CUSTOM4, 0) + NVL(pjp1.CUSTOM4, 0)
13816 , fact.CUSTOM5 = NVL(fact.CUSTOM5, 0) + NVL(pjp1.CUSTOM5, 0)
13817 , fact.CUSTOM6 = NVL(fact.CUSTOM6, 0) + NVL(pjp1.CUSTOM6, 0)
13818 , fact.CUSTOM7 = NVL(fact.CUSTOM7, 0) + NVL(pjp1.CUSTOM7, 0)
13819 , fact.CUSTOM8 = NVL(fact.CUSTOM8, 0) + NVL(pjp1.CUSTOM8, 0)
13820 , fact.CUSTOM9 = NVL(fact.CUSTOM9, 0) + NVL(pjp1.CUSTOM9, 0)
13821 , fact.CUSTOM10 = NVL(fact.CUSTOM10, 0) + NVL(pjp1.CUSTOM10, 0)
13822 , fact.CUSTOM11 = NVL(fact.CUSTOM11, 0) + NVL(pjp1.CUSTOM11, 0)
13823 , fact.CUSTOM12 = NVL(fact.CUSTOM12, 0) + NVL(pjp1.CUSTOM12, 0)
13824 , fact.CUSTOM13 = NVL(fact.CUSTOM13, 0) + NVL(pjp1.CUSTOM13, 0)
13825 , fact.CUSTOM14 = NVL(fact.CUSTOM14, 0) + NVL(pjp1.CUSTOM14, 0)
13826 , fact.CUSTOM15 = NVL(fact.CUSTOM15, 0) + NVL(pjp1.CUSTOM15, 0)
13827 , fact.last_update_date = SYSDATE
13828 , fact.last_updated_by = l_last_updated_by
13829 , fact.last_update_login = l_last_update_login
13830 WHEN NOT MATCHED THEN
13831 INSERT (
13832 fact.PROJECT_ID
13833 , fact.PROJECT_ORG_ID
13834 , fact.PROJECT_ORGANIZATION_ID
13835 , fact.PROJECT_ELEMENT_ID
13836 , fact.TIME_ID
13837 , fact.PERIOD_TYPE_ID
13838 , fact.CALENDAR_TYPE
13839 , fact.RBS_AGGR_LEVEL
13840 , fact.WBS_ROLLUP_FLAG
13841 , fact.PRG_ROLLUP_FLAG
13842 , fact.CURR_RECORD_TYPE_ID
13843 , fact.CURRENCY_CODE
13844 , fact.RBS_ELEMENT_ID
13845 , fact.RBS_VERSION_ID
13846 , fact.PLAN_VERSION_ID
13847 , fact.PLAN_TYPE_ID
13848 , fact.LAST_UPDATE_DATE
13849 , fact.LAST_UPDATED_BY
13850 , fact.CREATION_DATE
13851 , fact.CREATED_BY
13852 , fact.LAST_UPDATE_LOGIN
13853 , fact.RAW_COST
13854 , fact.BRDN_COST
13855 , fact.REVENUE
13856 , fact.BILL_RAW_COST
13857 , fact.BILL_BRDN_COST
13858 , fact.BILL_LABOR_RAW_COST
13859 , fact.BILL_LABOR_BRDN_COST
13860 , fact.BILL_LABOR_HRS
13861 , fact.EQUIPMENT_RAW_COST
13862 , fact.EQUIPMENT_BRDN_COST
13863 , fact.CAPITALIZABLE_RAW_COST
13864 , fact.CAPITALIZABLE_BRDN_COST
13865 , fact.LABOR_RAW_COST
13866 , fact.LABOR_BRDN_COST
13867 , fact.LABOR_HRS
13868 , fact.LABOR_REVENUE
13869 , fact.EQUIPMENT_HOURS
13870 , fact.BILLABLE_EQUIPMENT_HOURS
13871 , fact.SUP_INV_COMMITTED_COST
13872 , fact.PO_COMMITTED_COST
13873 , fact.PR_COMMITTED_COST
13874 , fact.OTH_COMMITTED_COST
13875 , fact.ACT_LABOR_HRS
13876 , fact.ACT_EQUIP_HRS
13877 , fact.ACT_LABOR_BRDN_COST
13878 , fact.ACT_EQUIP_BRDN_COST
13879 , fact.ACT_BRDN_COST
13880 , fact.ACT_RAW_COST
13881 , fact.ACT_REVENUE
13882 , fact.ACT_LABOR_RAW_COST
13883 , fact.ACT_EQUIP_RAW_COST
13884 , fact.ETC_LABOR_HRS
13885 , fact.ETC_EQUIP_HRS
13886 , fact.ETC_LABOR_BRDN_COST
13887 , fact.ETC_EQUIP_BRDN_COST
13888 , fact.ETC_BRDN_COST
13889 , fact.ETC_RAW_COST
13890 , fact.ETC_LABOR_RAW_COST
13891 , fact.ETC_EQUIP_RAW_COST
13892 , fact.CUSTOM1
13893 , fact.CUSTOM2
13894 , fact.CUSTOM3
13895 , fact.CUSTOM4
13896 , fact.CUSTOM5
13897 , fact.CUSTOM6
13898 , fact.CUSTOM7
13899 , fact.CUSTOM8
13900 , fact.CUSTOM9
13901 , fact.CUSTOM10
13902 , fact.CUSTOM11
13903 , fact.CUSTOM12
13904 , fact.CUSTOM13
13905 , fact.CUSTOM14
13906 , fact.CUSTOM15
13907 , fact.PLAN_TYPE_CODE
13908 )
13909 VALUES (
13910 pjp1.PROJECT_ID
13911 , pjp1.PROJECT_ORG_ID
13912 , pjp1.PROJECT_ORGANIZATION_ID
13913 , pjp1.PROJECT_ELEMENT_ID
13914 , pjp1.TIME_ID
13915 , pjp1.PERIOD_TYPE_ID
13916 , pjp1.CALENDAR_TYPE
13917 , pjp1.RBS_AGGR_LEVEL
13918 , pjp1.WBS_ROLLUP_FLAG
13919 , pjp1.PRG_ROLLUP_FLAG
13920 , pjp1.CURR_RECORD_TYPE_ID
13921 , pjp1.CURRENCY_CODE
13922 , pjp1.RBS_ELEMENT_ID
13923 , pjp1.RBS_VERSION_ID
13924 , pjp1.PLAN_VERSION_ID
13925 , pjp1.PLAN_TYPE_ID
13926 , sysdate
13927 , l_last_updated_by
13928 , sysdate
13929 , l_created_by
13930 , l_last_update_login
13931 , pjp1.RAW_COST
13932 , pjp1.BRDN_COST
13933 , pjp1.REVENUE
13934 , pjp1.BILL_RAW_COST
13935 , pjp1.BILL_BRDN_COST
13936 , pjp1.BILL_LABOR_RAW_COST
13937 , pjp1.BILL_LABOR_BRDN_COST
13938 , pjp1.BILL_LABOR_HRS
13939 , pjp1.EQUIPMENT_RAW_COST
13940 , pjp1.EQUIPMENT_BRDN_COST
13941 , pjp1.CAPITALIZABLE_RAW_COST
13942 , pjp1.CAPITALIZABLE_BRDN_COST
13943 , pjp1.LABOR_RAW_COST
13944 , pjp1.LABOR_BRDN_COST
13945 , pjp1.LABOR_HRS
13946 , pjp1.LABOR_REVENUE
13947 , pjp1.EQUIPMENT_HOURS
13948 , pjp1.BILLABLE_EQUIPMENT_HOURS
13949 , pjp1.SUP_INV_COMMITTED_COST
13950 , pjp1.PO_COMMITTED_COST
13951 , pjp1.PR_COMMITTED_COST
13952 , pjp1.OTH_COMMITTED_COST
13953 , pjp1.ACT_LABOR_HRS
13954 , pjp1.ACT_EQUIP_HRS
13955 , pjp1.ACT_LABOR_BRDN_COST
13956 , pjp1.ACT_EQUIP_BRDN_COST
13957 , pjp1.ACT_BRDN_COST
13958 , pjp1.ACT_RAW_COST
13959 , pjp1.ACT_REVENUE
13960 , pjp1.ACT_LABOR_RAW_COST
13961 , pjp1.ACT_EQUIP_RAW_COST
13962 , pjp1.ETC_LABOR_HRS
13963 , pjp1.ETC_EQUIP_HRS
13964 , pjp1.ETC_LABOR_BRDN_COST
13965 , pjp1.ETC_equip_BRDN_COST
13966 , pjp1.ETC_BRDN_COST
13967 , pjp1.ETC_RAW_COST
13968 , pjp1.ETC_LABOR_RAW_COST
13969 , pjp1.ETC_EQUIP_RAW_COST
13970 , pjp1.CUSTOM1
13971 , pjp1.CUSTOM2
13972 , pjp1.CUSTOM3
13973 , pjp1.CUSTOM4
13974 , pjp1.CUSTOM5
13975 , pjp1.CUSTOM6
13976 , pjp1.CUSTOM7
13977 , pjp1.CUSTOM8
13978 , pjp1.CUSTOM9
13979 , pjp1.CUSTOM10
13980 , pjp1.CUSTOM11
13981 , pjp1.CUSTOM12
13982 , pjp1.CUSTOM13
13983 , pjp1.CUSTOM14
13984 , pjp1.CUSTOM15
13985 , pjp1.PLAN_TYPE_CODE
13986 );
13987
13988 delete /*+ parallel(pjp1_d) */
13989 from pji_fp_aggr_pjp1 pjp1_d
13990 where EXISTS (SELECT /*+ parallel(pmh) */ NULL
13991 FROM pji_merge_helper pmh
13992 WHERE pmh.batch_id = p_batch_id
13993 AND pmh.worker_id = g_worker_id
13994 AND pmh.pjp_row_id = pjp1_d.rowid );
13995
13996 commit;
13997
13998 x_row_id.delete;
13999 xf_row_id.delete;
14000
14001 delete /*+ parallel(pji_merge_helper) */
14002 from pji_merge_helper
14003 where batch_id = p_batch_id;
14004
14005 update pji_merge_batch_status
14006 set request_status = 'COMPLETED'
14007 where batch_id = p_batch_id;
14008
14009 commit;
14010
14011 EXCEPTION
14012 WHEN OTHERS THEN
14013 FND_MSG_PUB.add_exc_msg( p_pkg_name => g_package_name ,
14014 p_procedure_name => 'MERGE_INTO_FP_FACTS');
14015 retcode := 2;
14016 errbuf := sqlerrm;
14017 RAISE;
14018 END MERGE_HELPER;
14019
14020 -- bug 6063826
14021
14022 BEGIN -- this portion is executed WHENever the package is initialized
14023
14024 g_worker_id := PJI_PJP_FP_CURR_WRAP.GET_WORKER_ID;
14025
14026 END PJI_FM_PLAN_MAINT_PVT;