DBA Data[Home] [Help]

PACKAGE BODY: APPS.PA_MAINT_PROJECT_ACCUMS

Source


1 PACKAGE body PA_MAINT_PROJECT_ACCUMS AS
2 /* $Header: PAACACTB.pls 120.3.12010000.2 2008/08/27 18:24:07 jngeorge ship $ */
3 
4 -- Change History :
5 --
6 -- APR-09-99	S Sanckar	Rollup logic changed
7 -- APR-12-99    Shanif          Rollup logic modified for Performance improvement
8 -- MAY-19-00    Mohnish     Included the changes sent by Shanif for fixing bug 1221390, going to GL_PERIOD_STATUSES instead of PA_PERIODS_V for GL impl_opt
9 -- MAY-19-00    Mohnish     Ported changes for 1265148 from R11.0
10 --                          Added wbs_level to the 2 cursors Res_accum_Cur and
11 --                          PA_Txn_Accum_Cur. Added wbs_level to the order by
12 --                          of both for fixing bug 1265148
13 --
14 ---
15 ---  15-OCT-2001     jwhite     Changed application_id = 101 to
16 ---                             =pa_period_process_pkg.application_id
17 ---
18 ---   19-Sep-2002    Rajnish    change is made in procedure Process_Txn_Accum.
19 ---                             BUg 2569461: In  all the cursors,in the statment
20 ----                            gps.application_id =decode(x_impl_opt,'PA',275,'GL',pa_period_process_pkg.application_id)
21 ---                             275 is replaced with
22 ---                              decode(x_impl_opt,'PA',decode(PA_Period_Process_PKG.Use_Same_PA_GL_Period,'Y',
23 ---                                 pa_period_process_pkg.application_id,'N',275),'GL',pa_period_process_pkg.application_id)
24 ---  29-nov-2002    sramesh    Added the profile option check pa:debug for the pa_debug calls
25 --
26 --   16-JAN-2003     jwhite    Bug#2753251
27 --                             Problem Description:
28 --                               1) The comparative period processing logic in this
29 --                                  package did not make a distinction as to  whether
30 --                                  summarization was processing for GL or PA periods.
31 --
32 --                                  The logic simply matched the GL and PA periods for the
33 --                                  pa_txn_accum record to the current reporting period. If EITHER
34 --                                  period equated to the current reportintg period, PTD
35 --                                  amounts were processed.
36 --
37 --                               2) Using transaction import for December 2001 data, the client accidently
38 --                                  created data with a PA period of 'DEC-2002'. The current reporting period
39 --                                  was also 'DEC-2002'. So, 2001-year amounts were being summarized
40 --                                  into the DEC-2002 PTD balance.
41 --
42 --                               3) Since loading legacy data may generate the situation created in
43 --                                  item #2 with regular frequency, the package code should handle this
44 --                                  corner case.
45 --
46 --                              Resolution Description:
47 --                                This bug fix uses the IN-parameter X_impl_opt to make
48 --                                a distinction between GL and PA period
49 --                                processing.
50 --
51 ---   06-May-2003   sacgupta    Bug 2834359. Change are done in procedure Process_Txn_Accum.
52 --                              TO_NUMBER(SUBSTR(USERENV('CLIENT_INFO'),1,10)) is passed as value in the
53 --                              call to the package function PA_Period_Process_PKG.Use_Same_PA_GL_Period
54 --                              in all the cursors.
55 --
56 --    08-Oct-2003   gjain       Bug 3147957: Replaced the usage of TO_NUMBER(SUBSTR(USERENV('CLIENT_INFO'),1,10))
57 --                              with cursor parameter p_org_id. This paramter is passed on the basis of valus returned
58 --                              by LTRIM(RTRIM(SUBSTR(USERENV('CLIENT_INFO'),1,10)))
59 --   03-may-2004    dkala       Added migration_code <> 'N'.
60 --   07-Mar-2004    sacupta     Bug 4195598. Cursors Res_accum_Cur and PA_Txn_Accum_Cur are modified
61 --                              in procedure PROCESS_TXN_ACCUM. The reference to GL_PERIOD_STATUSES
62 --                              table is replaced by GL_PERIODS. Accordingly the condition to join
63 --                              this table with PA_IMPLEMENTATIONS has changed. Now period_set_name
64 --                              and period_type is used to join GL_PERIODS and PA_IMPLIMENTATIONS
65 --                              table as against application_id and set_of_books_id that was used
66 --                              previously to join GL_PERIOD_STATUSES with PA_IMPLEMENTAIONS.
67 --                              Refer bug for further details.
68 --
69 --   05-Aug-2005   sacgupta	   Bug 4532088. Added trunc to the condition trunc(gps.END_DATE) <= x_current_end_date
70 --                             in procedure Process_Txn_Accum, cursors Res_accum_Cur and PA_Txn_Accum_Cur
71 --   30-Sep-2005   pkanupar     Bug4631058: In the procedure PROCESS_TXN_ACCUM, in the cursors Res_accum_Cur
72 --                              and PA_Txn_Accum_Cur, removed the check for 'PERIOD_TYPE' between GL_PERIODS
73 --                              and PA_IMPLIMENTATIONS.
74 --   16-Feb-2006   djoseph      Bug 5019025 : In the procedure PROCESS_TXN_ACCUM, in the cursors Res_accum_Cur
75 --                              and PA_Txn_Accum_Cur, removed the decode that was used to join the period_name
76 --                              based on the value of x_impl_opt.
77 --   20-feb-2006   degupta      To port the changes done in 11i file v115.23 to v115.25
78 --  27-AUG-2008 jngeorge  Bug 6511571: Removed the incorrect fix done for Bug# 5019025
79 --
80 TYPE resource_list_id_tabtype IS
81 TABLE OF PA_RESOURCE_LIST_ASSIGNMENTS.RESOURCE_LIST_ID%TYPE
82 INDEX BY BINARY_INTEGER;
83 
84 P_DEBUG_MODE varchar2(1) := NVL(FND_PROFILE.value('PA_DEBUG_MODE'), 'N'); /* Added Debug Profile Option  variable initialization for bug#2674619 */
85 
86 
87   Procedure Process_Txn_Accum  (X_project_id in Number,
88                                 X_impl_opt  In Varchar2,
89                                 x_Proj_accum_id   in Number,
90                                 x_current_period in Varchar2,
91                                 x_prev_period    in Varchar2,
92                                 x_current_year   in Number,
93                                 x_prev_accum_period in Varchar2,
94                                 x_current_start_date In Date,
95                                 x_current_end_date  In Date,
96 				x_actual_cost_flag  In Varchar2,
97 				x_revenue_flag  In Varchar2,
98 				x_commitments_flag  In Varchar2,
99                                 x_resource_list_id  In Number,
100                                 x_err_stack     In Out NOCOPY Varchar2,
101                                 x_err_stage     In Out NOCOPY Varchar2,
102                                 x_err_code      In Out NOCOPY Number ) Is
103 
104 -- This procedure reads the PA_TXN_ACCUM table and processes all transactions
105 
106   -- x_resource_list_id resource_list_id_tabtype;
107 
108   v_noof_tasks 		   Number := 0;
109   V_task_array 		   task_id_tabtype;
110 
111   Curr_task_id 			NUMBER := -99;
112   Curr_rlmid 			NUMBER := -99;
113   Curr_rlid                     NUMBER := 0;
114   Curr_rid                      NUMBER := 0;
115   Curr_rlaid                    NUMBER := 0;
116   Prev_parent_id                NUMBER := 0;
117   Curr_parent_id                NUMBER := 0;
118   curr_res_task                 NUMBER := 0;
119   create_actuals                VARCHAR2(1) := 'N';
120   create_commit                 VARCHAR2(1) := 'N';
121   create_wbs_actuals                VARCHAR2(1) := 'N';
122   create_wbs_commit                 VARCHAR2(1) := 'N';
123 
124   V_Old_Stack       		Varchar2(630);
125   x_quantity        		NUMBER :=0;
126   x_cmt_quantity        	NUMBER :=0;
127   x_billable_quantity 		NUMBER :=0;
128 
129   Fetch_task 			BOOLEAN := True;
130   Fetch_res  			BOOLEAN := True;
131 
132   x_dummy_var			VARCHAR2(1) := NULL;
133   V_accum_id			NUMBER	    := 0;
134   x_paa_flag			VARCHAR2(1) := 'Y';
135   x_pac_flag			VARCHAR2(1) := 'Y';
136   x_res_task                    Number := 0;
137 
138 -- This cursor fetches all resource lists which have already been accumulated
139 -- for the project.
140 
141   CURSOR Reslist_assgmt_Cur is
142   Select Distinct
143   Resource_list_id
144   FROM
145   PA_RESOURCE_LIST_ASSIGNMENTS
146   WHERE Project_id = X_project_id;
147 
148 /* Commented the cursor for bug 4195598
149 -- This cursor fetches the Resource Accum Details
150 
151  CURSOR Res_accum_Cur(p_org_id NUMBER) IS --Added p_org_id parameter to the cursor for bug 3147957
152  SELECT
153   PTA.TXN_ACCUM_ID,
154   nvl(PT.parent_task_id,PT.task_id) parent_task_id,
155   PTA.TASK_ID task_id,
156   PTA.PA_PERIOD,
157   PTA.GL_PERIOD,
158   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_REVENUE,0),NVL(PTA.I_TOT_REVENUE,0)) I_TOT_REVENUE,
159   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_RAW_COST,0),NVL(PTA.I_TOT_RAW_COST,0)) I_TOT_RAW_COST,
160   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BURDENED_COST,0),NVL(PTA.I_TOT_BURDENED_COST,0)) I_TOT_BURDENED_COST,
161   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_QUANTITY,0),NVL(PTA.I_TOT_QUANTITY,0)) I_TOT_QUANTITY,
162   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_LABOR_HOURS,0),NVL(PTA.I_TOT_LABOR_HOURS,0)) I_TOT_LABOR_HOURS,
163   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BILLABLE_RAW_COST,0),NVL(PTA.I_TOT_BILLABLE_RAW_COST,0)) I_TOT_BILLABLE_RAW_COST ,
164   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BILLABLE_BURDENED_COST,0),NVL(PTA.I_TOT_BILLABLE_BURDENED_COST,0)) I_TOT_BILLABLE_BURDENED_COST,
165   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BILLABLE_QUANTITY,0),NVL(PTA.I_TOT_BILLABLE_QUANTITY,0))I_TOT_BILLABLE_QUANTITY,
166   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BILLABLE_LABOR_HOURS,0),NVL(PTA.I_TOT_BILLABLE_LABOR_HOURS,0)) I_TOT_BILLABLE_LABOR_HOURS,
167   NVL(PTA.TOT_CMT_RAW_COST,0) TOT_CMT_RAW_COST,
168   NVL(PTA.TOT_CMT_BURDENED_COST,0) TOT_CMT_BURDENED_COST,
169   NVL(PTA.TOT_CMT_QUANTITY,0) TOT_CMT_QUANTITY,
170   PTA.actual_cost_rollup_flag,
171   PTA.revenue_rollup_flag,
172   PTA.cmt_rollup_flag,
173   GPS.PERIOD_YEAR,
174   Para.RESOURCE_LIST_ASSIGNMENT_ID,
175   Para.RESOURCE_LIST_ID,
176   Para.RESOURCE_LIST_MEMBER_ID,
177   Para.RESOURCE_ID ,
178   Parl.TRACK_AS_LABOR_FLAG,
179   Par.ROLLUP_QUANTITY_FLAG ,
180   Par.UNIT_OF_MEASURE,
181   PT.wbs_level
182  FROM
183   PA_TXN_ACCUM PTA,
184   PA_TASKS PT,
185   GL_PERIOD_STATUSES GPS,
186   PA_IMPLEMENTATIONS PI,
187   PA_RESOURCE_ACCUM_DETAILS Para,
188   PA_RESOURCES Par,
189   PA_RESOURCE_LIST_MEMBERS Parl
190  Where  Parl.resource_list_id = nvl(x_resource_list_id,Parl.resource_list_id) and
191         Para.Resource_list_id = Parl.Resource_list_id and
192         Para.Resource_list_member_id = Parl.Resource_list_member_id and
193         Para.Resource_id  = Par.Resource_Id and
194  	PTA.Project_Id = x_project_id and
195         nvl(parl.migration_code,'-99') <> 'N' and
196        (PTA.ACTUAL_COST_Rollup_flag = DECODE(x_Actual_Cost_Flag,'Y','Y','X')
197         OR PTA.REVENUE_Rollup_flag = DECODE(x_revenue_Flag,'Y','Y','X')
198 	OR PTA.CMT_Rollup_flag = DECODE(x_commitments_Flag,'Y','Y','X')
199         OR pa_proj_accum_main.x_summ_process = 'RL') and
200 --    gps.application_id = decode(x_impl_opt,'PA',275,'GL',pa_period_process_pkg.application_id) and
201 -----     commented and added for bug 2569461
202 -- Added TO_NUMBER(SUBSTR(USERENV('CLIENT_INFO'),1,10)) for bug 2834359
203 -- bug 3147957: Replaced TO_NUMBER(SUBSTR(USERENV('CLIENT_INFO'),1,10)) with p_org_id
204       gps.application_id = decode(x_impl_opt,'PA',decode(PA_Period_Process_PKG.Use_Same_PA_GL_Period(p_org_id),'Y',
205                                   pa_period_process_pkg.application_id,'N',275),'GL',pa_period_process_pkg.application_id) and
206     gps.set_of_books_id = pi.set_of_books_id and
207     gps.period_name = decode(x_impl_opt,'PA',PTA.pa_period,'GL',PTA.gl_period) and
208 	gps.END_DATE <= x_current_end_date and
209         PT.task_id = PTA.Task_id and
210   	Para.Txn_Accum_id = PTA.Txn_Accum_id
211 union
212  select
213   PTA.TXN_ACCUM_ID,
214   0 parent_task_id,
215   0 task_id,
216   PTA.PA_PERIOD,
217   PTA.GL_PERIOD,
218   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_REVENUE,0),NVL(PTA.I_TOT_REVENUE,0)) I_TOT_REVENUE,
219   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_RAW_COST,0),NVL(PTA.I_TOT_RAW_COST,0)) I_TOT_RAW_COST,
220   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BURDENED_COST,0),NVL(PTA.I_TOT_BURDENED_COST,0)) I_TOT_BURDENED_COST,
221   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_QUANTITY,0),NVL(PTA.I_TOT_QUANTITY,0)) I_TOT_QUANTITY,
222   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_LABOR_HOURS,0),NVL(PTA.I_TOT_LABOR_HOURS,0)) I_TOT_LABOR_HOURS,
223   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BILLABLE_RAW_COST,0),NVL(PTA.I_TOT_BILLABLE_RAW_COST,0)) I_TOT_BILLABLE_RAW_COST ,
224   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BILLABLE_BURDENED_COST,0),NVL(PTA.I_TOT_BILLABLE_BURDENED_COST,0)) I_TOT_BILLABLE_BURDENED_COST,
225   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BILLABLE_QUANTITY,0),NVL(PTA.I_TOT_BILLABLE_QUANTITY,0))I_TOT_BILLABLE_QUANTITY,
226   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BILLABLE_LABOR_HOURS,0),NVL(PTA.I_TOT_BILLABLE_LABOR_HOURS,0)) I_TOT_BILLABLE_LABOR_HOURS,
227   NVL(PTA.TOT_CMT_RAW_COST,0) TOT_CMT_RAW_COST,
228   NVL(PTA.TOT_CMT_BURDENED_COST,0) TOT_CMT_BURDENED_COST,
229   NVL(PTA.TOT_CMT_QUANTITY,0) TOT_CMT_QUANTITY,
230   PTA.actual_cost_rollup_flag,
231   PTA.revenue_rollup_flag,
232   PTA.cmt_rollup_flag,
233   GPS.PERIOD_YEAR,
234   Para.RESOURCE_LIST_ASSIGNMENT_ID,
235   Para.RESOURCE_LIST_ID,
236   Para.RESOURCE_LIST_MEMBER_ID,
237   Para.RESOURCE_ID ,
238   Parl.TRACK_AS_LABOR_FLAG,
239   Par.ROLLUP_QUANTITY_FLAG ,
240   Par.UNIT_OF_MEASURE,
241   0  wbs_level
242  FROM
243   PA_TXN_ACCUM PTA,
244   GL_PERIOD_STATUSES GPS,
245   PA_IMPLEMENTATIONS PI,
246   PA_RESOURCE_ACCUM_DETAILS Para,
247   PA_RESOURCES Par,
248   PA_RESOURCE_LIST_MEMBERS Parl
249  Where  Parl.resource_list_id = nvl(x_resource_list_id,Parl.resource_list_id) and
250         Para.Resource_list_id = Parl.Resource_list_id and
251         Para.Resource_list_member_id = Parl.Resource_list_member_id and
252         Para.Resource_id  = Par.Resource_Id and
253  	PTA.Project_Id = x_project_id and
254         nvl(parl.migration_code,'-99') <> 'N' and
255        (PTA.ACTUAL_COST_Rollup_flag = DECODE(x_Actual_Cost_Flag,'Y','Y','X')
256         OR PTA.REVENUE_Rollup_flag = DECODE(x_revenue_Flag,'Y','Y','X')
257 	OR PTA.CMT_Rollup_flag = DECODE(x_commitments_Flag,'Y','Y','X')
258         OR pa_proj_accum_main.x_summ_process = 'RL') and
259 --        gps.application_id = decode(x_impl_opt,'PA',275,'GL',pa_period_process_pkg.application_id) and
260 --     commented and added for bug 2569461
261 -- Added TO_NUMBER(SUBSTR(USERENV('CLIENT_INFO'),1,10)) for bug 2834359
262 -- bug 3147957: Replaced TO_NUMBER(SUBSTR(USERENV('CLIENT_INFO'),1,10)) with p_org_id
263         gps.application_id = decode(x_impl_opt,'PA',decode(PA_Period_Process_PKG.Use_Same_PA_GL_Period(p_org_id),'Y',
264                                   pa_period_process_pkg.application_id,'N',275),'GL',pa_period_process_pkg.application_id) and
265         gps.set_of_books_id = pi.set_of_books_id and
266         gps.period_name = decode(x_impl_opt,'PA',PTA.pa_period,'GL',PTA.gl_period) and
267 	gps.END_DATE <= x_current_end_date and
268   	Para.Txn_Accum_id = PTA.Txn_Accum_id
269   Order By 2,29,3,24; --Parent_Task_id,WBS_Level,Task_id,Para.Resource_List_Member_id;
270 
271 
272  CURSOR PA_Txn_Accum_Cur(p_org_id NUMBER) IS   --Added p_org_id parameter to the cursor for bug 3147957
273  SELECT DISTINCT
274   PTA.TXN_ACCUM_ID,
275   nvl(PT.parent_task_id,nvl(pt.task_id,0)) top_task_id,
276   PTA.TASK_ID,
277   PTA.PA_PERIOD,
278   PTA.GL_PERIOD,
279   NVL(PTA.I_TOT_REVENUE,0) I_TOT_REVENUE,
280   NVL(PTA.I_TOT_RAW_COST,0) I_TOT_RAW_COST,
281   NVL(PTA.I_TOT_BURDENED_COST,0) I_TOT_BURDENED_COST,
282   NVL(PTA.I_TOT_QUANTITY,0) I_TOT_QUANTITY,
283   NVL(PTA.I_TOT_LABOR_HOURS,0) I_TOT_LABOR_HOURS,
284   NVL(PTA.I_TOT_BILLABLE_RAW_COST,0) I_TOT_BILLABLE_RAW_COST ,
285   NVL(PTA.I_TOT_BILLABLE_BURDENED_COST,0) I_TOT_BILLABLE_BURDENED_COST,
286   NVL(PTA.I_TOT_BILLABLE_QUANTITY,0) I_TOT_BILLABLE_QUANTITY,
287   NVL(PTA.I_TOT_BILLABLE_LABOR_HOURS,0) I_TOT_BILLABLE_LABOR_HOURS,
288   NVL(PTA.TOT_CMT_RAW_COST,0) TOT_CMT_RAW_COST,
289   NVL(PTA.TOT_CMT_BURDENED_COST,0) TOT_CMT_BURDENED_COST,
290   NVL(PTA.TOT_CMT_QUANTITY,0) TOT_CMT_QUANTITY,
291   PTA.actual_cost_rollup_flag,
292   PTA.revenue_rollup_flag,
293   PTA.cmt_rollup_flag,
294   PTA.UNIT_OF_MEASURE,
295   GPS.PERIOD_YEAR,
296   nvl(PT.WBS_Level,0)
297  FROM
298  PA_TXN_ACCUM PTA,
299  PA_TASKS PT,
300  GL_PERIOD_STATUSES GPS,
301  PA_IMPLEMENTATIONS PI
302  Where	PTA.Project_Id = x_project_id
303  and   PTA.task_id = PT.task_id(+)
304  and   (PTA.ACTUAL_COST_Rollup_flag = DECODE(x_Actual_Cost_Flag,'Y','Y','X')
305         OR PTA.REVENUE_Rollup_flag = DECODE(x_revenue_Flag,'Y','Y','X')
306 	OR PTA.CMT_Rollup_flag = DECODE(x_commitments_Flag,'Y','Y','X')
307         OR pa_proj_accum_main.x_summ_process = 'RL')
308 --   and gps.application_id = decode(x_impl_opt,'PA',275,'GL',pa_period_process_pkg.application_id)
309 -----     commented and added for bug 2569461
310 -- Added TO_NUMBER(SUBSTR(USERENV('CLIENT_INFO'),1,10)) for bug 2834359
311 -- bug 3147957: Replaced TO_NUMBER(SUBSTR(USERENV('CLIENT_INFO'),1,10)) with p_org_id
312      and gps.application_id = decode(x_impl_opt,'PA',decode(PA_Period_Process_PKG.Use_Same_PA_GL_Period(p_org_id),'Y',
313                                   pa_period_process_pkg.application_id,'N',275),'GL',pa_period_process_pkg.application_id)
314    and gps.set_of_books_id = pi.set_of_books_id
315    and gps.period_name = decode(x_impl_opt,'PA',PTA.pa_period,'GL',PTA.gl_period)
316    and gps.END_DATE <= x_current_end_date
317  Order By 2,23,3; --Parent_Task_id,WBS_Level,Task_id
318 */
319 
320  CURSOR Res_accum_Cur IS
321  SELECT
322   PTA.TXN_ACCUM_ID,
323   nvl(PT.parent_task_id,PT.task_id) parent_task_id,
324   PTA.TASK_ID task_id,
325   PTA.PA_PERIOD,
326   PTA.GL_PERIOD,
327   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_REVENUE,0),NVL(PTA.I_TOT_REVENUE,0)) I_TOT_REVENUE,
328   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_RAW_COST,0),NVL(PTA.I_TOT_RAW_COST,0)) I_TOT_RAW_COST,
329   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BURDENED_COST,0),NVL(PTA.I_TOT_BURDENED_COST,0)) I_TOT_BURDENED_COST,
330   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_QUANTITY,0),NVL(PTA.I_TOT_QUANTITY,0)) I_TOT_QUANTITY,
331   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_LABOR_HOURS,0),NVL(PTA.I_TOT_LABOR_HOURS,0)) I_TOT_LABOR_HOURS,
332   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BILLABLE_RAW_COST,0),NVL(PTA.I_TOT_BILLABLE_RAW_COST,0)) I_TOT_BILLABLE_RAW_COST ,
333   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BILLABLE_BURDENED_COST,0),NVL(PTA.I_TOT_BILLABLE_BURDENED_COST,0)) I_TOT_BILLABLE_BURDENED_COST,
334   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BILLABLE_QUANTITY,0),NVL(PTA.I_TOT_BILLABLE_QUANTITY,0))I_TOT_BILLABLE_QUANTITY,
335   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BILLABLE_LABOR_HOURS,0),NVL(PTA.I_TOT_BILLABLE_LABOR_HOURS,0)) I_TOT_BILLABLE_LABOR_HOURS,
336   NVL(PTA.TOT_CMT_RAW_COST,0) TOT_CMT_RAW_COST,
337   NVL(PTA.TOT_CMT_BURDENED_COST,0) TOT_CMT_BURDENED_COST,
338   NVL(PTA.TOT_CMT_QUANTITY,0) TOT_CMT_QUANTITY,
339   PTA.actual_cost_rollup_flag,
340   PTA.revenue_rollup_flag,
341   PTA.cmt_rollup_flag,
342   GPS.PERIOD_YEAR,
343   Para.RESOURCE_LIST_ASSIGNMENT_ID,
344   Para.RESOURCE_LIST_ID,
345   Para.RESOURCE_LIST_MEMBER_ID,
346   Para.RESOURCE_ID ,
347   Parl.TRACK_AS_LABOR_FLAG,
348   Par.ROLLUP_QUANTITY_FLAG ,
349   Par.UNIT_OF_MEASURE,
350   PT.wbs_level
351  FROM
352   PA_TXN_ACCUM PTA,
353   PA_TASKS PT,
354   GL_PERIODS GPS,
355   PA_IMPLEMENTATIONS PI,
356   PA_RESOURCE_ACCUM_DETAILS Para,
357   PA_RESOURCES Par,
358   PA_RESOURCE_LIST_MEMBERS Parl
359  Where  Parl.resource_list_id = nvl(x_resource_list_id,Parl.resource_list_id) and
360         Para.Resource_list_id = Parl.Resource_list_id and
361         Para.Resource_list_member_id = Parl.Resource_list_member_id and
362         Para.Resource_id  = Par.Resource_Id and
363  	PTA.Project_Id = x_project_id and
364         nvl(parl.migration_code,'-99') <> 'N' and
365        (PTA.ACTUAL_COST_Rollup_flag = DECODE(x_Actual_Cost_Flag,'Y','Y','X')
366         OR PTA.REVENUE_Rollup_flag = DECODE(x_revenue_Flag,'Y','Y','X')
367 	OR PTA.CMT_Rollup_flag = DECODE(x_commitments_Flag,'Y','Y','X')
368         OR pa_proj_accum_main.x_summ_process = 'RL') and
369        gps.period_set_name = pi.period_set_name and
370        /* Commented for bug 4631058 gps.period_type = pi.pa_period_type and */
371        gps.adjustment_period_flag = 'N' and
372        -- Removed the fix done for Bug# 5019025
373        gps.period_name = decode(x_impl_opt,'PA',PTA.pa_period,'GL',PTA.gl_period) and
374 	trunc(gps.END_DATE) <= x_current_end_date and    -- added trunc for the bug 4532088
375         PT.task_id = PTA.Task_id and
376   	Para.Txn_Accum_id = PTA.Txn_Accum_id
377 union
378  select
379   PTA.TXN_ACCUM_ID,
380   0 parent_task_id,
381   0 task_id,
382   PTA.PA_PERIOD,
383   PTA.GL_PERIOD,
384   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_REVENUE,0),NVL(PTA.I_TOT_REVENUE,0)) I_TOT_REVENUE,
385   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_RAW_COST,0),NVL(PTA.I_TOT_RAW_COST,0)) I_TOT_RAW_COST,
386   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BURDENED_COST,0),NVL(PTA.I_TOT_BURDENED_COST,0)) I_TOT_BURDENED_COST,
387   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_QUANTITY,0),NVL(PTA.I_TOT_QUANTITY,0)) I_TOT_QUANTITY,
388   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_LABOR_HOURS,0),NVL(PTA.I_TOT_LABOR_HOURS,0)) I_TOT_LABOR_HOURS,
389   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BILLABLE_RAW_COST,0),NVL(PTA.I_TOT_BILLABLE_RAW_COST,0)) I_TOT_BILLABLE_RAW_COST ,
390   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BILLABLE_BURDENED_COST,0),NVL(PTA.I_TOT_BILLABLE_BURDENED_COST,0)) I_TOT_BILLABLE_BURDENED_COST,
391   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BILLABLE_QUANTITY,0),NVL(PTA.I_TOT_BILLABLE_QUANTITY,0))I_TOT_BILLABLE_QUANTITY,
392   decode(pa_proj_accum_main.x_summ_process,'RL',NVL(PTA.TOT_BILLABLE_LABOR_HOURS,0),NVL(PTA.I_TOT_BILLABLE_LABOR_HOURS,0)) I_TOT_BILLABLE_LABOR_HOURS,
393   NVL(PTA.TOT_CMT_RAW_COST,0) TOT_CMT_RAW_COST,
394   NVL(PTA.TOT_CMT_BURDENED_COST,0) TOT_CMT_BURDENED_COST,
395   NVL(PTA.TOT_CMT_QUANTITY,0) TOT_CMT_QUANTITY,
396   PTA.actual_cost_rollup_flag,
397   PTA.revenue_rollup_flag,
398   PTA.cmt_rollup_flag,
399   GPS.PERIOD_YEAR,
400   Para.RESOURCE_LIST_ASSIGNMENT_ID,
401   Para.RESOURCE_LIST_ID,
402   Para.RESOURCE_LIST_MEMBER_ID,
403   Para.RESOURCE_ID ,
404   Parl.TRACK_AS_LABOR_FLAG,
405   Par.ROLLUP_QUANTITY_FLAG ,
406   Par.UNIT_OF_MEASURE,
407   0  wbs_level
408  FROM
409   PA_TXN_ACCUM PTA,
410   GL_PERIODS GPS,
411   PA_IMPLEMENTATIONS PI,
412   PA_RESOURCE_ACCUM_DETAILS Para,
413   PA_RESOURCES Par,
414   PA_RESOURCE_LIST_MEMBERS Parl
415  Where  Parl.resource_list_id = nvl(x_resource_list_id,Parl.resource_list_id) and
416         Para.Resource_list_id = Parl.Resource_list_id and
417         Para.Resource_list_member_id = Parl.Resource_list_member_id and
418         Para.Resource_id  = Par.Resource_Id and
419  	PTA.Project_Id = x_project_id and
420         nvl(parl.migration_code,'-99') <> 'N' and
421        (PTA.ACTUAL_COST_Rollup_flag = DECODE(x_Actual_Cost_Flag,'Y','Y','X')
422         OR PTA.REVENUE_Rollup_flag = DECODE(x_revenue_Flag,'Y','Y','X')
423 	OR PTA.CMT_Rollup_flag = DECODE(x_commitments_Flag,'Y','Y','X')
424         OR pa_proj_accum_main.x_summ_process = 'RL') and
425        gps.period_set_name = pi.period_set_name and
426        /* Commented for bug 4631058 gps.period_type = pi.pa_period_type and */
427        gps.adjustment_period_flag = 'N' and
428        -- Removed the fix done for Bug# 5019025
429         gps.period_name = decode(x_impl_opt,'PA',PTA.pa_period,'GL',PTA.gl_period) and
430 	trunc(gps.END_DATE) <= x_current_end_date and -- added trunc for the bug 4532088
431   	Para.Txn_Accum_id = PTA.Txn_Accum_id
432   Order By 2,29,3,24; --Parent_Task_id,WBS_Level,Task_id,Para.Resource_List_Member_id;
433 
434 
435  CURSOR PA_Txn_Accum_Cur IS
436  SELECT DISTINCT
437   PTA.TXN_ACCUM_ID,
438   nvl(PT.parent_task_id,nvl(pt.task_id,0)) top_task_id,
439   PTA.TASK_ID,
440   PTA.PA_PERIOD,
441   PTA.GL_PERIOD,
442   NVL(PTA.I_TOT_REVENUE,0) I_TOT_REVENUE,
443   NVL(PTA.I_TOT_RAW_COST,0) I_TOT_RAW_COST,
444   NVL(PTA.I_TOT_BURDENED_COST,0) I_TOT_BURDENED_COST,
445   NVL(PTA.I_TOT_QUANTITY,0) I_TOT_QUANTITY,
446   NVL(PTA.I_TOT_LABOR_HOURS,0) I_TOT_LABOR_HOURS,
447   NVL(PTA.I_TOT_BILLABLE_RAW_COST,0) I_TOT_BILLABLE_RAW_COST ,
448   NVL(PTA.I_TOT_BILLABLE_BURDENED_COST,0) I_TOT_BILLABLE_BURDENED_COST,
449   NVL(PTA.I_TOT_BILLABLE_QUANTITY,0) I_TOT_BILLABLE_QUANTITY,
453   NVL(PTA.TOT_CMT_QUANTITY,0) TOT_CMT_QUANTITY,
450   NVL(PTA.I_TOT_BILLABLE_LABOR_HOURS,0) I_TOT_BILLABLE_LABOR_HOURS,
451   NVL(PTA.TOT_CMT_RAW_COST,0) TOT_CMT_RAW_COST,
452   NVL(PTA.TOT_CMT_BURDENED_COST,0) TOT_CMT_BURDENED_COST,
454   PTA.actual_cost_rollup_flag,
455   PTA.revenue_rollup_flag,
456   PTA.cmt_rollup_flag,
457   PTA.UNIT_OF_MEASURE,
458   GPS.PERIOD_YEAR,
459   nvl(PT.WBS_Level,0)
460  FROM
461  PA_TXN_ACCUM PTA,
462  PA_TASKS PT,
463  GL_PERIODS GPS,
464  PA_IMPLEMENTATIONS PI
465  Where	PTA.Project_Id = x_project_id
466  and   PTA.task_id = PT.task_id(+)
467  and   (PTA.ACTUAL_COST_Rollup_flag = DECODE(x_Actual_Cost_Flag,'Y','Y','X')
468         OR PTA.REVENUE_Rollup_flag = DECODE(x_revenue_Flag,'Y','Y','X')
469 	OR PTA.CMT_Rollup_flag = DECODE(x_commitments_Flag,'Y','Y','X')
470         OR pa_proj_accum_main.x_summ_process = 'RL')
471    and gps.period_set_name = pi.period_set_name
472    /* Commented for bug 4631058 and gps.period_type = pi.pa_period_type */
473    and gps.adjustment_period_flag = 'N'
474    -- Removed the fix done for Bug# 5019025
475    and gps.period_name = decode(x_impl_opt,'PA',PTA.pa_period,'GL',PTA.gl_period)
476    and trunc(gps.END_DATE) <= x_current_end_date    -- added trunc for the bug 4532088
477  Order By 2,23,3; --Parent_Task_id,WBS_Level,Task_id
478 
479   x_txn_accum_rec 		PA_Txn_Accum_Cur%ROWTYPE;
480   x_res_accum_rec 		Res_accum_Cur%ROWTYPE;
481   /* Code Addition for bug 3147957 begins */
482   l_client_info                 varchar2(20);
483   l_org_id                      NUMBER;
484   /* Code Addition for bug 3147957 ends */
485  Begin
486 
487     V_Old_Stack := x_err_stack;
488     x_err_stack :=
489     x_err_stack ||'->PA_MAINT_PROJECT_ACCUMS.Process_Txn_Accum';
490    IF P_DEBUG_MODE = 'Y' THEN /* Added Debug Profile Option Check for bug#2674619 */
491     pa_debug.debug(x_err_stack);
492     END IF;
493 
494     /* Commented for bug 4195598
495     -- Code addition for bug 3147957 begins
496     l_client_info := null;
497     l_client_info := LTRIM(RTRIM(SUBSTR(USERENV('CLIENT_INFO'),1,10)));
498 
499     if l_client_info is null then
500        l_org_id := null;
501     else
502        l_org_id := TO_NUMBER(l_client_info);
503     end if;
504     -- Code addition for bug 3147957 ends   */
505 
506     initialize_parent_level;
507     initialize_task_level;
508     initialize_project_level;
509 
510 /* Modified for bug 4195598
511     OPEN Res_Accum_Cur(l_org_id); -- Bug3147957: Added parameter l_org_id
512     OPEN PA_Txn_Accum_Cur(l_org_id); -- Bug3147957: Added parameter l_org_id
513 */
514     OPEN Res_Accum_Cur;
515     OPEN PA_Txn_Accum_Cur;
516     LOOP
517 
518  	IF Fetch_Task = True THEN
519 	   Fetch PA_Txn_Accum_Cur INTO x_txn_accum_rec;
520 	END IF;
521 
522 	Fetch_Task := True;
523 
524 	IF (x_txn_accum_rec.task_id = curr_task_id OR curr_task_id = -99)
525           AND (PA_Txn_Accum_Cur%FOUND) then
526 
527             If (x_txn_accum_rec.actual_cost_rollup_flag = 'Y' and
528                 x_actual_cost_flag = 'Y') or
529                (x_txn_accum_rec.revenue_rollup_flag = 'Y' and
530                 x_revenue_flag = 'Y') then
531                     create_actuals := 'Y';
532                     create_wbs_actuals := 'Y';
533             end if;
534             If x_txn_accum_rec.cmt_rollup_flag = 'Y' and
535                x_commitments_flag = 'Y' then
536                     create_commit := 'Y';
537                     create_wbs_commit := 'Y';
538             end if;
539            --   Fetched period = current period
540            --  (Update only ITD,YTD and PTD figures)-
541            --    Task level figures without resources
542 
543                    IF (x_commitments_flag = 'Y' and
544                        x_txn_accum_rec.cmt_rollup_flag = 'Y' and
545                        pa_proj_accum_main.x_summ_process <> 'RL') THEN
546 
547                         New_cmt_burd_cost_itd := New_cmt_burd_cost_itd +
548                                 NVL(x_txn_accum_rec.TOT_CMT_BURDENED_COST,0);
549                         New_cmt_burd_cost_ytd := New_cmt_burd_cost_ytd +
550                                 NVL(x_txn_accum_rec.TOT_CMT_BURDENED_COST,0);
551                         New_cmt_burd_cost_ptd := New_cmt_burd_cost_ptd +
552                                 NVL(x_txn_accum_rec.TOT_CMT_BURDENED_COST,0);
553 
554                         New_cmt_raw_cost_itd := New_cmt_raw_cost_itd +
555                                 NVL(x_txn_accum_rec.TOT_CMT_RAW_COST,0);
556                         New_cmt_raw_cost_ytd := New_cmt_raw_cost_ytd +
557                                 NVL(x_txn_accum_rec.TOT_CMT_RAW_COST,0);
558                         New_cmt_raw_cost_ptd := New_cmt_raw_cost_ptd +
559                                 NVL(x_txn_accum_rec.TOT_CMT_RAW_COST,0);
560 
561                    END IF;
562 
563  -- Bug 2753251, jwhite, 16-JAN-2003: Original Code -----------------------
564 
565 /*
566                 IF ((x_txn_accum_rec.PA_PERIOD =  x_current_period ) OR
567                    (x_txn_accum_rec.GL_PERIOD = x_current_period )) AND
568                     pa_proj_accum_main.x_summ_process <> 'RL' THEN
569 */
570       --New logic implemented for the bug 2753251
571              IF ((x_txn_accum_rec.PA_PERIOD =  x_current_period AND X_impl_opt = 'PA' ) OR
572                    (x_txn_accum_rec.GL_PERIOD = x_current_period AND X_impl_opt = 'GL')) AND
573                     pa_proj_accum_main.x_summ_process <> 'RL'
574                THEN
575 
576 
577   -- bug 2753251 ------------------------------------------------------------
578 
579 		    IF x_actual_cost_flag = 'Y' and
580                        x_txn_accum_rec.actual_cost_rollup_flag = 'Y' THEN
581 
582   			New_raw_cost_itd := New_raw_cost_itd +
583 				NVL(x_txn_accum_rec.I_TOT_RAW_COST,0);
584   			New_raw_cost_ytd := New_raw_cost_ytd +
585 				NVL(x_txn_accum_rec.I_TOT_RAW_COST,0);
586   			New_raw_cost_ptd := New_raw_cost_ptd +
587 				NVL(x_txn_accum_rec.I_TOT_RAW_COST,0);
588 
589   			New_burd_cost_itd := New_burd_cost_itd +
590 				NVL(x_txn_accum_rec.I_TOT_BURDENED_COST,0);
591   			New_burd_cost_ytd := New_burd_cost_ytd +
592 				NVL(x_txn_accum_rec.I_TOT_BURDENED_COST,0);
593   			New_burd_cost_ptd := New_burd_cost_ptd +
594 				NVL(x_txn_accum_rec.I_TOT_BURDENED_COST,0);
595 
596   			New_bill_raw_cost_itd := New_bill_raw_cost_itd +
597 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
598   			New_bill_raw_cost_ytd := New_bill_raw_cost_ytd +
599 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
600   			New_bill_raw_cost_ptd := New_bill_raw_cost_ptd +
601 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
602 
603   			New_bill_burd_cost_itd := New_bill_burd_cost_itd +
604 			   NVL(x_txn_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
605   			New_bill_burd_cost_ytd := New_bill_burd_cost_ytd +
606 			   NVL(x_txn_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
607   			New_bill_burd_cost_ptd := New_bill_burd_cost_ptd +
608 			   NVL(x_txn_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
609 
610   			New_labor_hours_itd := New_labor_hours_itd +
611 				NVL(x_txn_accum_rec.I_TOT_LABOR_HOURS,0);
612   			New_labor_hours_ytd := New_labor_hours_ytd +
613 				NVL(x_txn_accum_rec.I_TOT_LABOR_HOURS,0);
614   			New_labor_hours_ptd := New_labor_hours_ptd +
615 				NVL(x_txn_accum_rec.I_TOT_LABOR_HOURS,0);
616 
617   			New_bill_labor_hours_itd := New_bill_labor_hours_itd +
618 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
619   			New_bill_labor_hours_ytd := New_bill_labor_hours_ytd +
620 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
621   			New_bill_labor_hours_ptd := New_bill_labor_hours_ptd +
622 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
623 
624 		   END IF;
625 
626               /*   IF x_commitments_flag = 'Y' and
627                       x_txn_accum_rec.cmt_rollup_flag = 'Y' THEN
628 
629   			New_cmt_burd_cost_itd := New_cmt_burd_cost_itd +
630 				NVL(x_txn_accum_rec.TOT_CMT_BURDENED_COST,0);
631   			New_cmt_burd_cost_ytd := New_cmt_burd_cost_ytd +
632 				NVL(x_txn_accum_rec.TOT_CMT_BURDENED_COST,0);
633   			New_cmt_burd_cost_ptd := New_cmt_burd_cost_ptd +
634 				NVL(x_txn_accum_rec.TOT_CMT_BURDENED_COST,0);
635 
636   			New_cmt_raw_cost_itd := New_cmt_raw_cost_itd +
637 				NVL(x_txn_accum_rec.TOT_CMT_RAW_COST,0);
638   			New_cmt_raw_cost_ytd := New_cmt_raw_cost_ytd +
639 				NVL(x_txn_accum_rec.TOT_CMT_RAW_COST,0);
640   			New_cmt_raw_cost_ptd := New_cmt_raw_cost_ptd +
641 				NVL(x_txn_accum_rec.TOT_CMT_RAW_COST,0);
642 
643 		   END IF; */
644 
645 		   IF x_revenue_flag = 'Y' and
646                       x_txn_accum_rec.revenue_rollup_flag = 'Y' THEN
647 
648   			New_revenue_itd := New_revenue_itd +
649 				NVL(x_txn_accum_rec.I_TOT_REVENUE,0);
650   			New_revenue_ytd	:= New_revenue_ytd +
651 				NVL(x_txn_accum_rec.I_TOT_REVENUE,0);
652   			New_revenue_ptd	:= New_revenue_ptd +
653 				NVL(x_txn_accum_rec.I_TOT_REVENUE,0);
654 		  END IF;
655 
656   -- Bug 2753251, jwhite, 16-JAN-2003: Original Code -----------------------
657 
658 /*
659                 ELSIF  --    Fetched period = Previous period
660             	      ((x_txn_accum_rec.PA_PERIOD = x_prev_period )
661         	       OR (x_txn_accum_rec.GL_PERIOD = x_prev_period ))
662                         AND pa_proj_accum_main.x_summ_process <> 'RL' THEN
663 
664 */
665 
666                 ELSIF  --    Fetched period = Previous period
667             	      ((x_txn_accum_rec.PA_PERIOD = x_prev_period AND X_impl_opt = 'PA')
668         	       OR (x_txn_accum_rec.GL_PERIOD = x_prev_period AND X_impl_opt = 'GL'))
669                         AND pa_proj_accum_main.x_summ_process <> 'RL'
670                      THEN
671 
672 
673   -- bug 2753251 -----------------------------------------------------------
674 
675 		--   Fetched period=previous period and fetched year=currentyear
676 		--   (Update only ITD,YTD and PP figures )- Task level figures
677 		--    without resources
678 
679              	      IF x_txn_accum_rec.PERIOD_YEAR = x_current_year THEN
680 
681 			IF x_actual_cost_flag = 'Y' and
682                            x_txn_accum_rec.actual_cost_rollup_flag = 'Y' THEN
683 
684   			New_raw_cost_itd := New_raw_cost_itd +
685 				NVL(x_txn_accum_rec.I_TOT_RAW_COST,0);
686   			New_raw_cost_ytd := New_raw_cost_ytd +
687 				NVL(x_txn_accum_rec.I_TOT_RAW_COST,0);
688   			New_raw_cost_pp := New_raw_cost_pp +
689 				NVL(x_txn_accum_rec.I_TOT_RAW_COST,0);
690 
691   			New_burd_cost_itd := New_burd_cost_itd +
692 				NVL(x_txn_accum_rec.I_TOT_BURDENED_COST,0);
693   			New_burd_cost_ytd := New_burd_cost_ytd +
694 				NVL(x_txn_accum_rec.I_TOT_BURDENED_COST,0);
695   			New_burd_cost_pp := New_burd_cost_pp +
696 				NVL(x_txn_accum_rec.I_TOT_BURDENED_COST,0);
697 
698   			New_labor_hours_itd := New_labor_hours_itd +
699 				NVL(x_txn_accum_rec.I_TOT_LABOR_HOURS,0);
700   			New_labor_hours_ytd := New_labor_hours_ytd +
701 				NVL(x_txn_accum_rec.I_TOT_LABOR_HOURS,0);
702   			New_labor_hours_pp := New_labor_hours_pp +
703 				NVL(x_txn_accum_rec.I_TOT_LABOR_HOURS,0);
704 
705   			New_bill_raw_cost_itd := New_bill_raw_cost_itd +
706 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
707   			New_bill_raw_cost_ytd := New_bill_raw_cost_ytd +
708 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
709   			New_bill_raw_cost_pp := New_bill_raw_cost_pp +
710 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
711 
712   			New_bill_burd_cost_itd := New_bill_burd_cost_itd +
713 			   NVL(x_txn_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
714   			New_bill_burd_cost_ytd := New_bill_burd_cost_ytd +
715 			   NVL(x_txn_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
716   			New_bill_burd_cost_pp := New_bill_burd_cost_pp +
717 			   NVL(x_txn_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
718 
719   			New_bill_labor_hours_itd := New_bill_labor_hours_itd +
720 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
721   			New_bill_labor_hours_ytd := New_bill_labor_hours_ytd +
722 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
723   			New_bill_labor_hours_pp := New_bill_labor_hours_pp +
724 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
725 
726 			END IF;
727 
728 			IF x_revenue_flag = 'Y' and
729                            x_txn_accum_rec.revenue_rollup_flag = 'Y' THEN
730 
731   			New_revenue_itd := New_revenue_itd +
732 				NVL(x_txn_accum_rec.I_TOT_REVENUE,0);
733   			New_revenue_ytd	:= New_revenue_ytd +
734 				NVL(x_txn_accum_rec.I_TOT_REVENUE,0);
735   			New_revenue_pp	:= New_revenue_pp +
736 				NVL(x_txn_accum_rec.I_TOT_REVENUE,0);
737 			END IF;
738 
739 	/*		IF x_commitments_flag = 'Y' and
740                            x_txn_accum_rec.cmt_rollup_flag = 'Y' THEN
741 
742   			New_cmt_raw_cost_itd := New_cmt_raw_cost_itd +
743 				NVL(x_txn_accum_rec.TOT_CMT_RAW_COST,0);
744   			New_cmt_raw_cost_ytd := New_cmt_raw_cost_ytd +
745 				NVL(x_txn_accum_rec.TOT_CMT_RAW_COST,0);
746   			New_cmt_raw_cost_pp  := New_cmt_raw_cost_pp  +
747 				NVL(x_txn_accum_rec.TOT_CMT_RAW_COST,0);
748 
749   			New_cmt_burd_cost_itd := New_cmt_burd_cost_itd +
750 				NVL(x_txn_accum_rec.TOT_CMT_BURDENED_COST,0);
751   			New_cmt_burd_cost_ytd := New_cmt_burd_cost_ytd +
752 				NVL(x_txn_accum_rec.TOT_CMT_BURDENED_COST,0);
753   			New_cmt_burd_cost_pp  := New_cmt_burd_cost_pp  +
754 				NVL(x_txn_accum_rec.TOT_CMT_BURDENED_COST,0);
755 
756 		  	END IF; */
757 
758             	      ELSE
759 
760 			--   Fetched period = previous period but
761 			--   fetched year <> current year
762 			--  (Update only ITD and PP figures )-Task level
763 			--   figures without resources
764 
765 			IF x_actual_cost_flag = 'Y' and
766                            x_txn_accum_rec.actual_cost_rollup_flag = 'Y' THEN
767 
768   			New_raw_cost_itd := New_raw_cost_itd +
769 				NVL(x_txn_accum_rec.I_TOT_RAW_COST,0);
770   			New_raw_cost_pp  := New_raw_cost_pp  +
771 				NVL(x_txn_accum_rec.I_TOT_RAW_COST,0);
772 
773   			New_burd_cost_itd := New_burd_cost_itd +
774 				NVL(x_txn_accum_rec.I_TOT_BURDENED_COST,0);
775   			New_burd_cost_pp  := New_burd_cost_pp  +
776 				NVL(x_txn_accum_rec.I_TOT_BURDENED_COST,0);
777 
778   			New_labor_hours_itd := New_labor_hours_itd +
779 				NVL(x_txn_accum_rec.I_TOT_LABOR_HOURS,0);
780   			New_labor_hours_pp  := New_labor_hours_pp  +
781 				NVL(x_txn_accum_rec.I_TOT_LABOR_HOURS,0);
782 
783   			New_bill_raw_cost_itd := New_bill_raw_cost_itd +
784 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
785   			New_bill_raw_cost_pp  := New_bill_raw_cost_pp  +
786 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
787 
788   			New_bill_burd_cost_itd := New_bill_burd_cost_itd +
789 			   NVL(x_txn_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
790   			New_bill_burd_cost_pp  := New_bill_burd_cost_pp  +
791 			   NVL(x_txn_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
792 
793   			New_bill_labor_hours_itd := New_bill_labor_hours_itd +
794 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
795   			New_bill_labor_hours_pp  := New_bill_labor_hours_pp  +
796 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
797 
798 			END IF;
799 
800 	/*		IF x_commitments_flag = 'Y' and
801                            x_txn_accum_rec.cmt_rollup_flag = 'Y' THEN
802 
803   			New_cmt_raw_cost_itd := New_cmt_raw_cost_itd +
804 				NVL(x_txn_accum_rec.TOT_CMT_RAW_COST,0);
805   			New_cmt_raw_cost_pp  := New_cmt_raw_cost_pp  +
806 				NVL(x_txn_accum_rec.TOT_CMT_RAW_COST,0);
807 
808   			New_cmt_burd_cost_itd := New_cmt_burd_cost_itd +
809 				NVL(x_txn_accum_rec.TOT_CMT_BURDENED_COST,0);
810   			New_cmt_burd_cost_pp  := New_cmt_burd_cost_pp  +
811 				NVL(x_txn_accum_rec.TOT_CMT_BURDENED_COST,0);
812 
813 			END IF; */
814 
815 			IF x_revenue_flag = 'Y' and
816                            x_txn_accum_rec.revenue_rollup_flag = 'Y' THEN
817 
818   			New_revenue_itd := New_revenue_itd +
819 				NVL(x_txn_accum_rec.I_TOT_REVENUE,0);
820   			New_revenue_pp 	:= New_revenue_pp  +
821 				NVL(x_txn_accum_rec.I_TOT_REVENUE,0);
822 
823 			END IF;
824 
825            	      END IF; --If x_txn_accum_rec.PERIOD_YEAR = x_current_year
826           	ELSE
827 
828 		--   Fetched period <> current or previous period but fetched
829 		--   year = current year
830 		--   (Update only ITD and YTD figures)- Task level
831 		--   figures without resources
832 
833              	     IF x_txn_accum_rec.PERIOD_YEAR = x_current_year
834                         and pa_proj_accum_main.x_summ_process <> 'RL' Then
835 
836 			IF x_actual_cost_flag = 'Y' and
837                            x_txn_accum_rec.actual_cost_rollup_flag = 'Y' THEN
838 
839   			New_raw_cost_itd := New_raw_cost_itd +
840 				NVL(x_txn_accum_rec.I_TOT_RAW_COST,0);
841   			New_raw_cost_ytd := New_raw_cost_ytd +
842 				NVL(x_txn_accum_rec.I_TOT_RAW_COST,0);
843 
844   			New_burd_cost_itd := New_burd_cost_itd +
845 				NVL(x_txn_accum_rec.I_TOT_BURDENED_COST,0);
846   			New_burd_cost_ytd := New_burd_cost_ytd +
847 				NVL(x_txn_accum_rec.I_TOT_BURDENED_COST,0);
848 
849   			New_labor_hours_itd := New_labor_hours_itd +
850 				NVL(x_txn_accum_rec.I_TOT_LABOR_HOURS,0);
851   			New_labor_hours_ytd := New_labor_hours_ytd +
852 				NVL(x_txn_accum_rec.I_TOT_LABOR_HOURS,0);
853 
854   			New_bill_raw_cost_itd := New_bill_raw_cost_itd +
855 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
856   			New_bill_raw_cost_ytd := New_bill_raw_cost_ytd +
857 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
858 
859   			New_bill_burd_cost_itd := New_bill_burd_cost_itd +
860 			   NVL(x_txn_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
861   			New_bill_burd_cost_ytd := New_bill_burd_cost_ytd +
862 			   NVL(x_txn_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
863 
864   			New_bill_labor_hours_itd := New_bill_labor_hours_itd +
865 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
866   			New_bill_labor_hours_ytd := New_bill_labor_hours_ytd +
867 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
868 
869 			END IF;
870 
871 	/*		IF x_commitments_flag = 'Y' and
872                            x_txn_accum_rec.cmt_rollup_flag = 'Y' THEN
873 
874   			New_cmt_raw_cost_itd := New_cmt_raw_cost_itd +
875 				NVL(x_txn_accum_rec.TOT_CMT_RAW_COST,0);
876   			New_cmt_raw_cost_ytd := New_cmt_raw_cost_ytd +
877 				NVL(x_txn_accum_rec.TOT_CMT_RAW_COST,0);
878 
879   			New_cmt_burd_cost_itd := New_cmt_burd_cost_itd +
880 				NVL(x_txn_accum_rec.TOT_CMT_BURDENED_COST,0);
881   			New_cmt_burd_cost_ytd := New_cmt_burd_cost_ytd +
882 				NVL(x_txn_accum_rec.TOT_CMT_BURDENED_COST,0);
883 
884 			END IF; */
885 
886 			IF x_revenue_flag = 'Y' and
887                            x_txn_accum_rec.revenue_rollup_flag = 'Y' THEN
888 
889   			New_revenue_itd := New_revenue_itd +
890 				NVL(x_txn_accum_rec.I_TOT_REVENUE,0);
891   			New_revenue_ytd	:= New_revenue_ytd +
892 				NVL(x_txn_accum_rec.I_TOT_REVENUE,0);
893 
894 			END IF;
895 
896              	     ELSE
897 
898 		--   Fetched period <> current or previous period
899 		--   and fetched year <>
900 		--   current year (Update only ITD figures )-
901 		--   Task level figures without resources
902                        If pa_proj_accum_main.x_summ_process <> 'RL' then
903 			IF x_actual_cost_flag = 'Y' and
904                            x_txn_accum_rec.actual_cost_rollup_flag = 'Y' THEN
905 
906   			New_raw_cost_itd := New_raw_cost_itd +
907 				NVL(x_txn_accum_rec.I_TOT_RAW_COST,0);
908   			New_burd_cost_itd := New_burd_cost_itd +
909 				NVL(x_txn_accum_rec.I_TOT_BURDENED_COST,0);
910   			New_labor_hours_itd := New_labor_hours_itd +
911 				NVL(x_txn_accum_rec.I_TOT_LABOR_HOURS,0);
912   			New_bill_raw_cost_itd := New_bill_raw_cost_itd +
913 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
914   			New_bill_burd_cost_itd := New_bill_burd_cost_itd +
918 
915 			   NVL(x_txn_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
916   			New_bill_labor_hours_itd := New_bill_labor_hours_itd +
917 				NVL(x_txn_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
919 			END IF;
920 
921 			IF x_revenue_flag = 'Y' and
922                            x_txn_accum_rec.revenue_rollup_flag = 'Y' THEN
923 
924   			New_revenue_itd := New_revenue_itd +
925 				NVL(x_txn_accum_rec.I_TOT_REVENUE,0);
926 			END IF;
927 
928 	/*		IF x_commitments_flag = 'Y' and
929                            x_txn_accum_rec.cmt_rollup_flag = 'Y' THEN
930 
931   			New_cmt_raw_cost_itd := New_cmt_raw_cost_itd +
932 				NVL(x_txn_accum_rec.TOT_CMT_RAW_COST,0);
933   			New_cmt_burd_cost_itd := New_cmt_burd_cost_itd +
934 				NVL(x_txn_accum_rec.TOT_CMT_BURDENED_COST,0);
935 
936 			END IF; */
937                       end if;
938 
939             	     END IF;
940 
941          	END IF;
942 
943         ELSE     -- for task_id = curr_task_id or curr_task_id = -99 condition
944 
945 		-- Store the value onto variables to be later updated on Project
946 		-- Level (task = 0 and rlmid = 0) record.
947              if pa_proj_accum_main.x_summ_process <> 'RL' then
948 	        add_project_amounts;
949              end if;
950 
951              if (x_txn_accum_rec.top_task_id <> curr_parent_id and
952                 curr_parent_id > 0)or
953                 pa_txn_accum_cur%notfound then
954                 add_parent_amounts;
955    		Get_all_higher_tasks
956 			(x_project_id ,
957                          curr_task_id ,
958 			 0,             -- resource_list_member_id
959                          v_task_array,
960                          v_noof_tasks,
961                          x_err_stack,
962                          x_err_stage,
963                          x_err_code);
964               if (pa_proj_accum_main.x_summ_process <> 'RL' and curr_parent_id > 0) then
965  		Check_Accum_res_tasks
966 			( x_project_id ,
967                		  curr_task_id,
968 			  x_Proj_Accum_id,
969 			  x_current_period,
970                           0,
971                           0,
972                           0,
973                           0,
974                           create_actuals,
975                           create_commit,
976                	          x_err_stack ,
977                        	  x_err_stage ,
978                        	  x_err_code  );
979 
980    		If v_noof_tasks > 0 Then
981        		   For i in 2..v_noof_tasks LOOP
982  			Check_Accum_WBS
983 				( x_project_id ,
984                        		  v_task_array(i),
985 				  x_Proj_Accum_id,
986 				  x_current_period,
987                                   0,
988                                   0,
989                                   0,
990                                   0,
991                                   create_wbs_actuals,
992                                   create_wbs_commit,
993                        		  x_err_stack ,
994                        		  x_err_stage ,
995                        		  x_err_code  );
996 
997 		   End LOOP;
998 		End If;
999                end if;
1000 
1001                 initialize_task_level;
1002                 initialize_parent_level;
1003                 create_commit := 'N';
1004                 create_actuals := 'N';
1005                 create_wbs_actuals := 'N';
1006                 create_wbs_commit := 'N';
1007 
1008 		Fetch_Task := False;
1009                 prev_parent_id := curr_parent_id;
1010 
1011            	LOOP
1012                      if curr_rlmid = -99 then
1013                            curr_res_task := 0;
1014                      end if;
1015 		     IF Fetch_Res = True THEN
1016 			FETCH Res_Accum_Cur INTO x_Res_Accum_rec;
1017 			--EXIT WHEN Res_Accum_Cur%NOTFOUND;
1018 		     END IF;
1019 
1020 		     Fetch_Res := True;
1021 
1022 		     IF x_Res_Accum_rec.Task_id = curr_res_task AND Res_Accum_Cur%FOUND THEN
1023 
1024 			IF x_Res_Accum_rec.resource_list_member_id = curr_rlmid OR
1025 			   curr_rlmid = -99 THEN
1026 ----------------------------
1027             If (x_res_accum_rec.actual_cost_rollup_flag = 'Y' and
1028                 x_actual_cost_flag = 'Y') or
1029                (x_res_accum_rec.revenue_rollup_flag = 'Y' and
1030                 x_revenue_flag = 'Y') or
1031                (pa_proj_accum_main.x_summ_process = 'RL') then
1032                     create_actuals := 'Y';
1033             end if;
1034             If (x_res_accum_rec.cmt_rollup_flag = 'Y' and x_commitments_flag = 'Y')
1035                 or pa_proj_accum_main.x_summ_process = 'RL' then
1036                     create_commit := 'Y';
1037             end if;
1038                         curr_rlmid := x_res_accum_rec.resource_list_member_id;
1039                         curr_rid   := x_res_accum_rec.resource_id;
1040                         curr_rlid  := x_res_accum_rec.resource_list_id;
1041                         curr_rlaid := x_res_accum_rec.resource_list_assignment_id;
1042 ----------------------------
1043 
1044            	     	   IF ( x_Res_Accum_Rec.rollup_Quantity_flag = 'Y') THEN
1045               	                x_quantity := x_res_accum_rec.I_TOT_QUANTITY;
1046               	                x_cmt_quantity :=
1047 					x_res_accum_rec.TOT_CMT_QUANTITY;
1048                    	        x_billable_quantity :=
1049 					x_res_accum_rec.I_TOT_BILLABLE_QUANTITY;
1050            	     	   ELSE
1051               	                x_quantity := 0;
1052               	          	x_billable_quantity :=0;
1053            	    	  END IF;
1054 --------------------------------------------------------------------------
1058            	--  (Update only ITD,YTD and PTD figures)-
1055 --   Add amounts for a Project, Task and Resource combination
1056 --------------------------------------------------------------------------
1057            	--   Fetched period = current period
1059            	--    Task level figures without resources
1060                         IF (x_commitments_flag = 'Y' and
1061                            x_res_accum_rec.cmt_rollup_flag = 'Y') or
1062                            pa_proj_accum_main.x_summ_process = 'RL' THEN
1063 
1064                         New_cmt_quantity_itd := New_cmt_quantity_itd
1065                                                 + x_cmt_quantity;
1066                         New_cmt_quantity_ytd := New_cmt_quantity_ytd
1067                                                 + x_cmt_quantity;
1068                         New_cmt_quantity_ptd := New_cmt_quantity_ptd
1069                                                 + x_cmt_quantity;
1070 
1071                         New_cmt_raw_cost_itd := New_cmt_raw_cost_itd +
1072                                 NVL(x_res_accum_rec.TOT_CMT_RAW_COST,0);
1073                         New_cmt_raw_cost_ytd := New_cmt_raw_cost_ytd +
1074                                 NVL(x_res_accum_rec.TOT_CMT_RAW_COST,0);
1075                         New_cmt_raw_cost_ptd := New_cmt_raw_cost_ptd +
1076                                 NVL(x_res_accum_rec.TOT_CMT_RAW_COST,0);
1077 
1078                         New_cmt_burd_cost_itd := New_cmt_burd_cost_itd +
1079                                 NVL(x_res_accum_rec.TOT_CMT_BURDENED_COST,0);
1080                         New_cmt_burd_cost_ytd := New_cmt_burd_cost_ytd +
1081                                 NVL(x_res_accum_rec.TOT_CMT_BURDENED_COST,0);
1082                         New_cmt_burd_cost_ptd := New_cmt_burd_cost_ptd +
1083                                 NVL(x_res_accum_rec.TOT_CMT_BURDENED_COST,0);
1084 
1085                         END IF;
1086 
1087 -- Bug 2753251, jwhite, 16-JAN-2003: Original Code -----------------------
1088 
1089 /*
1090 
1091                 IF (x_res_accum_rec.PA_PERIOD =  x_current_period ) OR
1092                    (x_res_accum_rec.GL_PERIOD = x_current_period ) THEN
1093 
1094 */
1095 
1096 
1097                IF (x_res_accum_rec.PA_PERIOD =  x_current_period AND X_impl_opt = 'PA') OR
1098                    (x_res_accum_rec.GL_PERIOD = x_current_period AND X_impl_opt = 'GL' )
1099                  THEN
1100 
1101 
1102  -- bug 2753251 -----------------------------------------------------------
1103 
1104 
1105 			IF (x_actual_cost_flag = 'Y' and
1106                            x_res_accum_rec.actual_cost_rollup_flag = 'Y') or
1107                            pa_proj_accum_main.x_summ_process = 'RL' THEN
1108 
1109   			New_raw_cost_itd := New_raw_cost_itd +
1110 				NVL(x_res_accum_rec.I_TOT_RAW_COST,0);
1111   			New_raw_cost_ytd := New_raw_cost_ytd +
1112 				NVL(x_res_accum_rec.I_TOT_RAW_COST,0);
1113   			New_raw_cost_ptd := New_raw_cost_ptd +
1114 				NVL(x_res_accum_rec.I_TOT_RAW_COST,0);
1115 
1116   			New_quantity_itd := New_quantity_itd + x_quantity;
1117   			New_quantity_ytd := New_quantity_ytd + x_quantity;
1118   			New_quantity_ptd := New_quantity_ptd + x_quantity;
1119 
1120   			New_bill_quantity_itd := New_bill_quantity_itd +
1121 						 x_billable_quantity;
1122   			New_bill_quantity_ytd := New_bill_quantity_ytd +
1123 						 x_billable_quantity;
1124   			New_bill_quantity_ptd := New_bill_quantity_ptd +
1125 						 x_billable_quantity;
1126 
1127   			New_burd_cost_itd := New_burd_cost_itd +
1128 				NVL(x_res_accum_rec.I_TOT_BURDENED_COST,0);
1129   			New_burd_cost_ytd := New_burd_cost_ytd +
1130 				NVL(x_res_accum_rec.I_TOT_BURDENED_COST,0);
1131   			New_burd_cost_ptd := New_burd_cost_ptd +
1132 				NVL(x_res_accum_rec.I_TOT_BURDENED_COST,0);
1133 
1134   			New_labor_hours_itd := New_labor_hours_itd +
1135 				NVL(x_res_accum_rec.I_TOT_LABOR_HOURS,0);
1136   			New_labor_hours_ytd := New_labor_hours_ytd +
1137 				NVL(x_res_accum_rec.I_TOT_LABOR_HOURS,0);
1138   			New_labor_hours_ptd := New_labor_hours_ptd +
1139 				NVL(x_res_accum_rec.I_TOT_LABOR_HOURS,0);
1140 
1141   			New_bill_raw_cost_itd := New_bill_raw_cost_itd +
1142 				NVL(x_res_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
1143   			New_bill_raw_cost_ytd := New_bill_raw_cost_ytd +
1144 				NVL(x_res_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
1145   			New_bill_raw_cost_ptd := New_bill_raw_cost_ptd +
1146 				NVL(x_res_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
1147 
1148   			New_bill_burd_cost_itd := New_bill_burd_cost_itd +
1149 			   NVL(x_res_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
1150   			New_bill_burd_cost_ytd := New_bill_burd_cost_ytd +
1151 			   NVL(x_res_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
1152   			New_bill_burd_cost_ptd := New_bill_burd_cost_ptd +
1153 			   NVL(x_res_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
1154 
1155   			New_bill_labor_hours_itd := New_bill_labor_hours_itd +
1156 				NVL(x_res_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
1157   			New_bill_labor_hours_ytd := New_bill_labor_hours_ytd +
1158 				NVL(x_res_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
1159   			New_bill_labor_hours_ptd := New_bill_labor_hours_ptd +
1160 				NVL(x_res_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
1161 
1162 			END IF;
1163 
1164 			IF (x_revenue_flag = 'Y' and
1165                            x_res_accum_rec.revenue_rollup_flag = 'Y') or
1166                            pa_proj_accum_main.x_summ_process = 'RL' THEN
1167 
1168   			New_revenue_itd := New_revenue_itd +
1169 				NVL(x_res_accum_rec.I_TOT_REVENUE,0);
1170   			New_revenue_ytd	:= New_revenue_ytd +
1171 				NVL(x_res_accum_rec.I_TOT_REVENUE,0);
1172   			New_revenue_ptd	:= New_revenue_ptd +
1173 				NVL(x_res_accum_rec.I_TOT_REVENUE,0);
1174 
1175 			END IF;
1176 
1177 	/*		IF (x_commitments_flag = 'Y' and
1181   			New_cmt_quantity_itd := New_cmt_quantity_itd
1178                            x_res_accum_rec.cmt_rollup_flag = 'Y') or
1179                            pa_proj_accum_main.x_summ_process = 'RL' THEN
1180 
1182 						+ x_cmt_quantity;
1183   			New_cmt_quantity_ytd := New_cmt_quantity_ytd
1184 						+ x_cmt_quantity;
1185   			New_cmt_quantity_ptd := New_cmt_quantity_ptd
1186 						+ x_cmt_quantity;
1187 
1188   			New_cmt_raw_cost_itd := New_cmt_raw_cost_itd +
1189 				NVL(x_res_accum_rec.TOT_CMT_RAW_COST,0);
1190   			New_cmt_raw_cost_ytd := New_cmt_raw_cost_ytd +
1191 				NVL(x_res_accum_rec.TOT_CMT_RAW_COST,0);
1192   			New_cmt_raw_cost_ptd := New_cmt_raw_cost_ptd +
1193 				NVL(x_res_accum_rec.TOT_CMT_RAW_COST,0);
1194 
1195   			New_cmt_burd_cost_itd := New_cmt_burd_cost_itd +
1196 				NVL(x_res_accum_rec.TOT_CMT_BURDENED_COST,0);
1197   			New_cmt_burd_cost_ytd := New_cmt_burd_cost_ytd +
1198 				NVL(x_res_accum_rec.TOT_CMT_BURDENED_COST,0);
1199   			New_cmt_burd_cost_ptd := New_cmt_burd_cost_ptd +
1200 				NVL(x_res_accum_rec.TOT_CMT_BURDENED_COST,0);
1201 
1202               		END IF; */
1203 
1204                 ELSIF  --    Fetched period = Previous period
1205 
1206 -- Bug 2753251, jwhite, 16-JAN-2003: Original Code -----------------------
1207 
1208 /*
1209             	      (x_res_accum_rec.PA_PERIOD = x_prev_period )
1210         	       OR (x_res_accum_rec.GL_PERIOD = x_prev_period ) THEN
1211 */
1212 
1213           	      (x_res_accum_rec.PA_PERIOD = x_prev_period AND X_impl_opt = 'PA')
1214         	       OR (x_res_accum_rec.GL_PERIOD = x_prev_period AND X_impl_opt = 'GL' )
1215                         THEN
1216 
1217 
1218 -- bug 2753251 -----------------------------------------------------------
1219 
1220 		--    Fetched period = previous period and fetched
1221 		--    year = current year
1222 		--   (Update only ITD,YTD and PP figures )- Task level figures
1223 		--    without resources
1224 
1225              	      IF x_res_accum_rec.PERIOD_YEAR = x_current_year THEN
1226 
1227 			IF (x_actual_cost_flag = 'Y' and
1228                            x_res_accum_rec.actual_cost_rollup_flag = 'Y') or
1229                            pa_proj_accum_main.x_summ_process = 'RL' THEN
1230 
1231   			New_raw_cost_itd := New_raw_cost_itd +
1232 				NVL(x_res_accum_rec.I_TOT_RAW_COST,0);
1233   			New_raw_cost_ytd := New_raw_cost_ytd +
1234 				NVL(x_res_accum_rec.I_TOT_RAW_COST,0);
1235   			New_raw_cost_pp := New_raw_cost_pp +
1236 				NVL(x_res_accum_rec.I_TOT_RAW_COST,0);
1237 
1238   			New_quantity_itd := New_quantity_itd + x_quantity;
1239   			New_quantity_ytd := New_quantity_ytd + x_quantity;
1240   			New_quantity_pp  := New_quantity_pp  + x_quantity;
1241 
1242   			New_bill_quantity_itd := New_bill_quantity_itd +
1243 						 x_billable_quantity;
1244   			New_bill_quantity_ytd := New_bill_quantity_ytd +
1245 						 x_billable_quantity;
1246   			New_bill_quantity_pp  := New_bill_quantity_pp  +
1247 						 x_billable_quantity;
1248 
1249   			New_burd_cost_itd := New_burd_cost_itd +
1250 				NVL(x_res_accum_rec.I_TOT_BURDENED_COST,0);
1251   			New_burd_cost_ytd := New_burd_cost_ytd +
1252 				NVL(x_res_accum_rec.I_TOT_BURDENED_COST,0);
1253   			New_burd_cost_pp := New_burd_cost_pp +
1254 				NVL(x_res_accum_rec.I_TOT_BURDENED_COST,0);
1255 
1256   			New_labor_hours_itd := New_labor_hours_itd +
1257 				NVL(x_res_accum_rec.I_TOT_LABOR_HOURS,0);
1258   			New_labor_hours_ytd := New_labor_hours_ytd +
1259 				NVL(x_res_accum_rec.I_TOT_LABOR_HOURS,0);
1260   			New_labor_hours_pp := New_labor_hours_pp +
1261 				NVL(x_res_accum_rec.I_TOT_LABOR_HOURS,0);
1262 
1263   			New_bill_raw_cost_itd := New_bill_raw_cost_itd +
1264 				NVL(x_res_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
1265   			New_bill_raw_cost_ytd := New_bill_raw_cost_ytd +
1266 				NVL(x_res_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
1267   			New_bill_raw_cost_pp := New_bill_raw_cost_pp +
1268 				NVL(x_res_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
1269 
1270   			New_bill_burd_cost_itd := New_bill_burd_cost_itd +
1271 			   NVL(x_res_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
1272   			New_bill_burd_cost_ytd := New_bill_burd_cost_ytd +
1273 			   NVL(x_res_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
1274   			New_bill_burd_cost_pp := New_bill_burd_cost_pp +
1275 			   NVL(x_res_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
1276 
1277   			New_bill_labor_hours_itd := New_bill_labor_hours_itd +
1278 				NVL(x_res_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
1279   			New_bill_labor_hours_ytd := New_bill_labor_hours_ytd +
1280 				NVL(x_res_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
1281   			New_bill_labor_hours_pp := New_bill_labor_hours_pp +
1282 				NVL(x_res_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
1283 
1284 			END IF;
1285 
1286 			IF (x_revenue_flag = 'Y' and
1287                            x_res_accum_rec.revenue_rollup_flag = 'Y') or
1288                            pa_proj_accum_main.x_summ_process = 'RL' THEN
1289 
1290   			New_revenue_itd := New_revenue_itd +
1291 				NVL(x_res_accum_rec.I_TOT_REVENUE,0);
1292   			New_revenue_ytd	:= New_revenue_ytd +
1293 				NVL(x_res_accum_rec.I_TOT_REVENUE,0);
1294   			New_revenue_pp	:= New_revenue_pp +
1295 				NVL(x_res_accum_rec.I_TOT_REVENUE,0);
1296 
1297 			END IF;
1298 
1299 	/*		IF (x_commitments_flag = 'Y' and
1300                            x_res_accum_rec.cmt_rollup_flag = 'Y') or
1301                            pa_proj_accum_main.x_summ_process = 'RL' THEN
1302 
1303   			New_cmt_quantity_itd := New_cmt_quantity_itd +
1304 						 x_cmt_quantity;
1305   			New_cmt_quantity_ytd := New_cmt_quantity_ytd +
1306 						 x_cmt_quantity;
1307   			New_cmt_quantity_pp  := New_cmt_quantity_pp  +
1308 						 x_cmt_quantity;
1309 
1310   			New_cmt_raw_cost_itd := New_cmt_raw_cost_itd +
1314   			New_cmt_raw_cost_pp  := New_cmt_raw_cost_pp  +
1311 				NVL(x_res_accum_rec.TOT_CMT_RAW_COST,0);
1312   			New_cmt_raw_cost_ytd := New_cmt_raw_cost_ytd +
1313 				NVL(x_res_accum_rec.TOT_CMT_RAW_COST,0);
1315 				NVL(x_res_accum_rec.TOT_CMT_RAW_COST,0);
1316 
1317   			New_cmt_burd_cost_itd := New_cmt_burd_cost_itd +
1318 				NVL(x_res_accum_rec.TOT_CMT_BURDENED_COST,0);
1319   			New_cmt_burd_cost_ytd := New_cmt_burd_cost_ytd +
1320 				NVL(x_res_accum_rec.TOT_CMT_BURDENED_COST,0);
1321   			New_cmt_burd_cost_pp  := New_cmt_burd_cost_pp  +
1322 				NVL(x_res_accum_rec.TOT_CMT_BURDENED_COST,0);
1323 
1324 			END IF; */
1325 
1326      	      ELSE
1327 
1328 			--   Fetched period = previous period but
1329 			--   fetched year <> current year
1330 			--  (Update only ITD and PP figures )-Task level
1331 			--   figures without resources
1332 
1333 			IF (x_actual_cost_flag = 'Y' and
1334                            x_res_accum_rec.actual_cost_rollup_flag = 'Y') or
1335                            pa_proj_accum_main.x_summ_process = 'RL' THEN
1336 
1337   			New_raw_cost_itd := New_raw_cost_itd +
1338 				NVL(x_res_accum_rec.I_TOT_RAW_COST,0);
1339   			New_raw_cost_pp  := New_raw_cost_pp  +
1340 				NVL(x_res_accum_rec.I_TOT_RAW_COST,0);
1341 
1342   			New_quantity_itd := New_quantity_itd + x_quantity;
1343   			New_quantity_pp  := New_quantity_pp  + x_quantity;
1344 
1345   			New_bill_quantity_itd := New_bill_quantity_itd +
1346 						 x_billable_quantity;
1347   			New_bill_quantity_pp  := New_bill_quantity_pp  +
1348 						 x_billable_quantity;
1349 
1350   			New_burd_cost_itd := New_burd_cost_itd +
1351 				NVL(x_res_accum_rec.I_TOT_BURDENED_COST,0);
1352   			New_burd_cost_pp  := New_burd_cost_pp  +
1353 				NVL(x_res_accum_rec.I_TOT_BURDENED_COST,0);
1354 
1355   			New_labor_hours_itd := New_labor_hours_itd +
1356 				NVL(x_res_accum_rec.I_TOT_LABOR_HOURS,0);
1357   			New_labor_hours_pp  := New_labor_hours_pp  +
1358 				NVL(x_res_accum_rec.I_TOT_LABOR_HOURS,0);
1359 
1360   			New_bill_raw_cost_itd := New_bill_raw_cost_itd +
1361 				NVL(x_res_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
1362   			New_bill_raw_cost_pp  := New_bill_raw_cost_pp  +
1363 				NVL(x_res_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
1364 
1365   			New_bill_burd_cost_itd := New_bill_burd_cost_itd +
1366 			   NVL(x_res_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
1367   			New_bill_burd_cost_pp  := New_bill_burd_cost_pp  +
1368 			   NVL(x_res_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
1369 
1370   			New_bill_labor_hours_itd := New_bill_labor_hours_itd +
1371 				NVL(x_res_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
1372   			New_bill_labor_hours_pp  := New_bill_labor_hours_pp  +
1373 				NVL(x_res_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
1374 
1375 			END IF;
1376 
1377 			IF (x_revenue_flag = 'Y' and
1378                            x_res_accum_rec.revenue_rollup_flag = 'Y') or
1379                            pa_proj_accum_main.x_summ_process = 'RL' THEN
1380 
1381   			New_revenue_itd := New_revenue_itd +
1382 				NVL(x_res_accum_rec.I_TOT_REVENUE,0);
1383   			New_revenue_pp 	:= New_revenue_pp  +
1384 				NVL(x_res_accum_rec.I_TOT_REVENUE,0);
1385 
1386 			END IF;
1387 
1388 	/*		IF (x_commitments_flag = 'Y' and
1389                            x_res_accum_rec.cmt_rollup_flag = 'Y') or
1390                            pa_proj_accum_main.x_summ_process = 'RL' THEN
1391 
1392   			New_cmt_quantity_itd := New_cmt_quantity_itd +
1393 						 x_cmt_quantity;
1394   			New_cmt_quantity_pp  := New_cmt_quantity_pp  +
1395 						 x_cmt_quantity;
1396 
1397   			New_cmt_raw_cost_itd := New_cmt_raw_cost_itd +
1398 				NVL(x_res_accum_rec.TOT_CMT_RAW_COST,0);
1399   			New_cmt_raw_cost_pp  := New_cmt_raw_cost_pp  +
1400 				NVL(x_res_accum_rec.TOT_CMT_RAW_COST,0);
1401 
1402   			New_cmt_burd_cost_itd := New_cmt_burd_cost_itd +
1403 				NVL(x_res_accum_rec.TOT_CMT_BURDENED_COST,0);
1404   			New_cmt_burd_cost_pp  := New_cmt_burd_cost_pp  +
1405 				NVL(x_res_accum_rec.TOT_CMT_BURDENED_COST,0);
1406 
1407 			END IF; */
1408 
1409            	      END IF; -- If x_txn_accum_rec.PERIOD_YEAR = x_current_year
1410           	ELSE
1411 
1412 		--   Fetched period <> current or previous period but fetched
1413 		--   year = current year
1414 		--   (Update only ITD and YTD figures)- Task level
1415 		--   figures without resources
1416 
1417              	     IF x_res_accum_rec.PERIOD_YEAR = x_current_year Then
1418 
1419 			IF (x_actual_cost_flag = 'Y' and
1420                            x_res_accum_rec.actual_cost_rollup_flag = 'Y') or
1421                            pa_proj_accum_main.x_summ_process = 'RL' THEN
1422 
1423   			New_raw_cost_itd := New_raw_cost_itd +
1424 				NVL(x_res_accum_rec.I_TOT_RAW_COST,0);
1425   			New_raw_cost_ytd := New_raw_cost_ytd +
1426 				NVL(x_res_accum_rec.I_TOT_RAW_COST,0);
1427 
1428   			New_quantity_itd := New_quantity_itd + x_quantity;
1429   			New_quantity_ytd := New_quantity_ytd + x_quantity;
1430 
1431   			New_bill_quantity_itd := New_bill_quantity_itd +
1432 						 x_billable_quantity;
1433   			New_bill_quantity_ytd := New_bill_quantity_ytd +
1434 						 x_billable_quantity;
1435 
1436   			New_burd_cost_itd := New_burd_cost_itd +
1437 				NVL(x_res_accum_rec.I_TOT_BURDENED_COST,0);
1438   			New_burd_cost_ytd := New_burd_cost_ytd +
1439 				NVL(x_res_accum_rec.I_TOT_BURDENED_COST,0);
1440 
1441   			New_labor_hours_itd := New_labor_hours_itd +
1442 				NVL(x_res_accum_rec.I_TOT_LABOR_HOURS,0);
1443   			New_labor_hours_ytd := New_labor_hours_ytd +
1444 				NVL(x_res_accum_rec.I_TOT_LABOR_HOURS,0);
1445 
1446   			New_bill_raw_cost_itd := New_bill_raw_cost_itd +
1447 				NVL(x_res_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
1451   			New_bill_burd_cost_itd := New_bill_burd_cost_itd +
1448   			New_bill_raw_cost_ytd := New_bill_raw_cost_ytd +
1449 				NVL(x_res_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
1450 
1452 			   NVL(x_res_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
1453   			New_bill_burd_cost_ytd := New_bill_burd_cost_ytd +
1454 			   NVL(x_res_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
1455 
1456   			New_bill_labor_hours_itd := New_bill_labor_hours_itd +
1457 				NVL(x_res_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
1458   			New_bill_labor_hours_ytd := New_bill_labor_hours_ytd +
1459 				NVL(x_res_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
1460 			END IF;
1461 
1462 			IF (x_revenue_flag = 'Y' and
1463                            x_res_accum_rec.revenue_rollup_flag = 'Y') or
1464                            pa_proj_accum_main.x_summ_process = 'RL' THEN
1465 
1466   			New_revenue_itd := New_revenue_itd +
1467 				NVL(x_res_accum_rec.I_TOT_REVENUE,0);
1468   			New_revenue_ytd	:= New_revenue_ytd +
1469 				NVL(x_res_accum_rec.I_TOT_REVENUE,0);
1470 
1471 			END IF;
1472 
1473 	/*		IF (x_commitments_flag = 'Y' and
1474                            x_res_accum_rec.cmt_rollup_flag = 'Y') or
1475                            pa_proj_accum_main.x_summ_process = 'RL' THEN
1476 
1477   			New_cmt_quantity_itd := New_cmt_quantity_itd +
1478 						x_cmt_quantity;
1479   			New_cmt_quantity_ytd := New_cmt_quantity_ytd +
1480 						x_cmt_quantity;
1481 
1482   			New_cmt_raw_cost_itd := New_cmt_raw_cost_itd +
1483 				NVL(x_res_accum_rec.TOT_CMT_RAW_COST,0);
1484   			New_cmt_raw_cost_ytd := New_cmt_raw_cost_ytd +
1485 				NVL(x_res_accum_rec.TOT_CMT_RAW_COST,0);
1486 
1487   			New_cmt_burd_cost_itd := New_cmt_burd_cost_itd +
1488 				NVL(x_res_accum_rec.TOT_CMT_BURDENED_COST,0);
1489   			New_cmt_burd_cost_ytd := New_cmt_burd_cost_ytd +
1490 				NVL(x_res_accum_rec.TOT_CMT_BURDENED_COST,0);
1491 			END IF; */
1492 
1493              	     ELSE
1494 
1495 		--   Fetched period <> current or previous period
1496 		--   and fetched year <>
1497 		--   current year (Update only ITD figures )-
1498 		--   Task level figures without resources
1499 
1500 			IF (x_actual_cost_flag = 'Y' and
1501                            x_res_accum_rec.actual_cost_rollup_flag = 'Y') or
1502                            pa_proj_accum_main.x_summ_process = 'RL' THEN
1503 
1504   			New_raw_cost_itd := New_raw_cost_itd +
1505 				NVL(x_res_accum_rec.I_TOT_RAW_COST,0);
1506   			New_quantity_itd := New_quantity_itd + x_quantity;
1507   			New_bill_quantity_itd := New_bill_quantity_itd +
1508 						 x_billable_quantity;
1509   			New_burd_cost_itd := New_burd_cost_itd +
1510 				NVL(x_res_accum_rec.I_TOT_BURDENED_COST,0);
1511   			New_labor_hours_itd := New_labor_hours_itd +
1512 				NVL(x_res_accum_rec.I_TOT_LABOR_HOURS,0);
1513   			New_bill_raw_cost_itd := New_bill_raw_cost_itd +
1514 				NVL(x_res_accum_rec.I_TOT_BILLABLE_RAW_COST,0);
1515   			New_bill_burd_cost_itd := New_bill_burd_cost_itd +
1516 			   NVL(x_res_accum_rec.I_TOT_BILLABLE_BURDENED_COST,0);
1517   			New_bill_labor_hours_itd := New_bill_labor_hours_itd +
1518 			NVL(x_res_accum_rec.I_TOT_BILLABLE_LABOR_HOURS,0);
1519 
1520 			END IF;
1521 
1522 			IF (x_revenue_flag = 'Y' and
1523                            x_res_accum_rec.revenue_rollup_flag = 'Y') or
1524                            pa_proj_accum_main.x_summ_process = 'RL' THEN
1525 
1526   			New_revenue_itd := New_revenue_itd +
1527 				NVL(x_res_accum_rec.I_TOT_REVENUE,0);
1528 
1529 			END IF;
1530 
1531 	/*		IF (x_commitments_flag = 'Y' and
1532                            x_res_accum_rec.cmt_rollup_flag = 'Y') or
1533                            pa_proj_accum_main.x_summ_process = 'RL' THEN
1534 
1535   			New_cmt_quantity_itd := New_cmt_quantity_itd +
1536 						 x_cmt_quantity;
1537   			New_cmt_raw_cost_itd := New_cmt_raw_cost_itd +
1538 				NVL(x_res_accum_rec.TOT_CMT_RAW_COST,0);
1539   			New_cmt_burd_cost_itd := New_cmt_burd_cost_itd +
1540 				NVL(x_res_accum_rec.TOT_CMT_BURDENED_COST,0);
1541 
1542 			END IF; */
1543 
1544             	     END IF;
1545 
1546          	END IF;
1547 
1548 --------------------------------------------------------------------------
1549 --   End of Add amounts for a Project, Task and Resource combination
1550 --------------------------------------------------------------------------
1551 
1552 			ELSE
1553                            If x_res_accum_rec.task_id = 0 then
1554                              Check_Accum_Res_Tasks
1555                                  ( x_project_id,
1556                                    0,
1557                                    x_Proj_Accum_id,
1558                                    x_current_period,
1559                                    curr_rlid,
1560                                    curr_rlmid,
1561                                    curr_rid,
1562                                    curr_rlaid,
1563                                    create_actuals,
1564                                    create_commit,
1565                                    x_err_stack,
1566                                    x_err_stage,
1567                                    x_err_code );
1568                           else
1569                            if curr_parent_id = x_res_accum_rec.task_id then
1570                                Check_accum_res_tasks
1571                                 ( x_project_id,
1572                                   x_res_accum_rec.task_id,
1573                                   x_Proj_Accum_id,
1574                                   x_current_period,
1575                                    curr_rlid,
1579                                    create_actuals,
1576                                    curr_rlmid,
1577                                    curr_rid,
1578                                    curr_rlaid,
1580                                    create_commit,
1581                                   x_err_stack,
1582                                   x_err_stage,
1583                                   x_err_code );
1584                            else
1585    			   If v_noof_tasks > 0 Then
1586                              v_task_array(1) := x_res_accum_rec.task_id;
1587        		   	     For i in 1..v_noof_tasks LOOP
1588 
1589  				Check_Accum_Res_Tasks
1590 			         ( x_project_id,
1591                                	   v_task_array(i),
1592 				   x_Proj_Accum_id,
1593 				   x_current_period,
1594                                    curr_rlid,
1595                                    curr_rlmid,
1596                                    curr_rid,
1597                                    curr_rlaid,
1598                                    create_actuals,
1599                                    create_commit,
1600                                	   x_err_stack,
1601                                	   x_err_stage,
1602                                	   x_err_code );
1603 
1604 			     END LOOP;
1605 			   END IF;
1606                           end if;
1607                          end if;
1608 
1609                         initialize_task_level;
1610                         create_actuals := 'N';
1611                         create_commit := 'N';
1612                         Fetch_res := FALSE;
1613 
1614 			END IF;
1615 
1616 		     ELSE
1617                         if curr_res_task = 0 then
1618                               Check_Accum_Res_Tasks
1619                                  ( x_project_id,
1620                                    0,
1621                                    x_Proj_Accum_id,
1622                                    x_current_period,
1623                                    curr_rlid,
1624                                    curr_rlmid,
1625                                    curr_rid,
1626                                    curr_rlaid,
1627                                    create_actuals,
1628                                    create_commit,
1629                                    x_err_stack,
1630                                    x_err_stage,
1631                                    x_err_code );
1632                        else
1633                        If curr_parent_id = curr_res_task then
1634                              Check_Accum_Res_Tasks
1635                               ( x_project_id,
1636                                   curr_res_task,
1637                                   x_Proj_Accum_id,
1638                                   x_current_period,
1639                                    curr_rlid,
1640                                    curr_rlmid,
1641                                    curr_rid,
1642                                    curr_rlaid,
1643                                    create_actuals,
1644                                    create_commit,
1645                                   x_err_stack,
1646                                   x_err_stage,
1647                                   x_err_code );
1648                         else
1649                            if v_noof_tasks > 0 then
1650                            v_task_array(1) := curr_res_task;
1651        		   	   For i in 1..v_noof_tasks LOOP
1652  			     Check_Accum_Res_Tasks
1653 				( x_project_id,
1654                                   v_task_array(i),
1655 				  x_Proj_Accum_id,
1656 				  x_current_period,
1657                                    curr_rlid,
1658                                    curr_rlmid,
1659                                    curr_rid,
1660                                    curr_rlaid,
1661                                    create_actuals,
1662                                    create_commit,
1663                                   x_err_stack,
1664                                   x_err_stage,
1665                                   x_err_code );
1666 			   END LOOP;
1667                           end if;
1668 			END IF;
1669                        end if;
1670 			-- Initialize amount variables
1671                         initialize_task_level;
1672 
1673                         create_actuals := 'N';
1674                         create_commit := 'N';
1675 		 	Fetch_res := False;
1676 		 	curr_rlmid := x_Res_Accum_rec.resource_list_member_id;
1677 
1678                        if curr_res_task = 0 and
1679                           x_res_accum_rec.parent_task_id <> 0 then
1680                           curr_parent_id := prev_parent_id;
1681                        end if;
1682 
1683 	                curr_res_task := x_res_accum_rec.task_id;
1684 		    if x_res_accum_rec.parent_task_id <> curr_parent_id then
1685 			  exit;
1686 		    end if;
1687                     exit when res_accum_cur%notfound;
1688 	    END IF;
1689 	    Curr_rlmid := x_Res_Accum_rec.resource_list_member_id;
1690 	    curr_res_task := x_res_accum_rec.task_id;
1691            END LOOP; -- End of x_Res_Accum_rec in Res_accum_Cur LOOP
1692           else
1693              --- create task level record
1694                       if pa_proj_accum_main.x_summ_process <> 'RL' and
1695                          curr_parent_id <> 0 then
1696  			     Check_Accum_Res_Tasks
1697 				( x_project_id,
1698                                   curr_task_id,
1699 				  x_Proj_Accum_id,
1700 				  x_current_period,
1701                                   0,
1702                                   0,
1703                                   0,
1704                                   0,
1705                                   create_actuals,
1709                                   x_err_code );
1706                                   create_commit,
1707                                   x_err_stack,
1708                                   x_err_stage,
1710                       end if;
1711              --- add amounts in parent_level
1712              if curr_parent_id > 0 and curr_parent_id <> curr_task_id then
1713                             add_parent_amounts;
1714              end if;
1715              initialize_task_level;
1716              create_actuals := 'N';
1717              create_commit :=  'N';
1718              fetch_task := False;
1719          end if;
1720 
1721 	END IF;
1722       Exit when PA_TXN_ACCUM_CUR%NOTFOUND;
1723 	Curr_task_id := x_Txn_Accum_rec.Task_id;
1724         Curr_parent_id := x_txn_accum_rec.top_task_id;
1725 
1726 -- After processing the records, Update the PA_TXN_ACCUM , modifying  the
1727       if pa_proj_accum_main.x_summ_process <> 'RL' then
1728     	Update PA_TXN_ACCUM Set
1729         	TOT_REVENUE   	  = NVL(TOT_REVENUE,0) + NVL(I_TOT_REVENUE,0),
1730         	TOT_RAW_COST  	  = NVL(TOT_RAW_COST,0) + NVL(I_TOT_RAW_COST,0),
1731         	TOT_BURDENED_COST = NVL(TOT_BURDENED_COST,0) +
1732               		            NVL(I_TOT_BURDENED_COST,0),
1733         	TOT_LABOR_HOURS   = NVL(TOT_LABOR_HOURS,0) +
1734                		            NVL(I_TOT_LABOR_HOURS,0),
1735         	TOT_QUANTITY      = NVL(TOT_QUANTITY,0) + NVL(I_TOT_QUANTITY,0),
1736         	TOT_BILLABLE_QUANTITY = NVL(TOT_BILLABLE_QUANTITY,0) +
1737                		            NVL(I_TOT_BILLABLE_QUANTITY,0),
1738         	TOT_BILLABLE_RAW_COST = NVL(TOT_BILLABLE_RAW_COST,0) +
1739                		            NVL(I_TOT_BILLABLE_RAW_COST,0),
1740         	TOT_BILLABLE_BURDENED_COST = NVL(TOT_BILLABLE_BURDENED_COST,0) +
1741                	                    NVL(I_TOT_BILLABLE_BURDENED_COST,0),
1742         	TOT_BILLABLE_LABOR_HOURS = NVL(TOT_BILLABLE_LABOR_HOURS,0) +
1743                                     NVL(I_TOT_BILLABLE_LABOR_HOURS,0),
1744         	I_TOT_REVENUE         		= 0,
1745         	I_TOT_RAW_COST        		= 0,
1746         	I_TOT_BURDENED_COST   		= 0,
1747         	I_TOT_LABOR_HOURS     		= 0,
1748         	I_TOT_QUANTITY        		= 0,
1749         	I_TOT_BILLABLE_QUANTITY		= 0,
1750         	I_TOT_BILLABLE_RAW_COST		= 0,
1751         	I_TOT_BILLABLE_BURDENED_COST	= 0,
1752         	I_TOT_BILLABLE_LABOR_HOURS	= 0,
1753         	ACTUAL_COST_ROLLUP_FLAG   	= decode(x_actual_cost_flag,'Y','N',actual_cost_rollup_flag),
1754         	REVENUE_ROLLUP_FLAG             = decode(x_revenue_flag,'Y','N',revenue_rollup_flag),
1755 		CMT_ROLLUP_FLAG 		= decode(x_commitments_flag,'Y','N',cmt_rollup_flag),
1756        		last_updated_by        = pa_proj_accum_main.x_last_updated_by,
1757        		last_update_date       = SYSDATE,
1758        		request_id             = pa_proj_accum_main.x_request_id,
1759        		program_application_id =
1760 				pa_proj_accum_main.x_program_application_id,
1761        		program_id             = pa_proj_accum_main.x_program_id,
1762        		program_update_date    = SYSDATE
1763                 Where  TXN_ACCUM_ID = x_txn_accum_rec.txn_accum_id;
1764        end if;
1765     END LOOP; -- End of x_Txn_Accum_rec in PA_Txn_Accum_cur LOOP
1766 
1767     CLOSE PA_Txn_Accum_Cur;
1768     CLOSE res_accum_cur;
1769     -- Update pa_project_accum_actuals project level records
1770      if (x_actual_cost_flag = 'Y' or x_revenue_flag = 'Y')
1771                    and pa_proj_accum_main.x_summ_process <> 'RL' then
1772 	      UPDATE Pa_Project_Accum_actuals PAA SET
1773 		    Raw_cost_itd = nvl(raw_cost_itd,0) + Tsk_raw_cost_itd,
1774 		    Raw_cost_ytd = nvl(raw_cost_ytd,0) + Tsk_raw_cost_ytd,
1775 		    Raw_cost_pp  = nvl(raw_cost_pp,0) + Tsk_raw_cost_pp,
1776 		    Raw_cost_ptd = nvl(raw_cost_ptd,0) + Tsk_raw_cost_ptd,
1777 		    billable_raw_cost_itd = nvl(billable_raw_cost_itd,0) +
1778                                         Tsk_bill_raw_cost_itd,
1779 		    billable_raw_cost_ytd = nvl(billable_raw_cost_ytd,0) +
1780                                         Tsk_bill_raw_cost_ytd,
1781 		    billable_raw_cost_pp  = nvl(billable_raw_cost_pp,0) +
1782                                         Tsk_bill_raw_cost_pp,
1783 		    billable_raw_cost_ptd = nvl(billable_raw_cost_ptd,0) +
1784                                         Tsk_bill_raw_cost_ptd,
1785 		    burdened_cost_itd = nvl(burdened_cost_itd,0) +
1786                                     Tsk_burd_cost_itd,
1787 		    burdened_cost_ytd = nvl(burdened_cost_ytd,0) + Tsk_burd_cost_ytd,
1788 		    burdened_cost_pp  = nvl(burdened_cost_pp,0) + Tsk_burd_cost_pp,
1789 		    burdened_cost_ptd = nvl(burdened_cost_ptd,0) + Tsk_burd_cost_ptd,
1790 		    billable_burdened_cost_itd = nvl(billable_burdened_cost_itd,0) + Tsk_bill_burd_cost_itd,
1791 		    billable_burdened_cost_ytd = nvl(billable_burdened_cost_ytd,0) + Tsk_bill_burd_cost_ytd,
1792 		    billable_burdened_cost_pp  = nvl(billable_burdened_cost_pp,0) + Tsk_bill_burd_cost_pp,
1793 		    billable_burdened_cost_ptd = nvl(billable_burdened_cost_ptd,0) + Tsk_bill_burd_cost_ptd,
1794 		    quantity_itd = nvl(quantity_itd,0) + Tsk_quantity_itd,
1795 		    quantity_ytd = nvl(quantity_ytd,0) + Tsk_quantity_ytd,
1796 		    quantity_pp  = nvl(quantity_pp,0) + Tsk_quantity_pp,
1797 		    quantity_ptd = nvl(quantity_ptd,0) + Tsk_quantity_ptd,
1798 		    labor_hours_itd = nvl(labor_hours_itd,0) + Tsk_labor_hours_itd,
1799 		    labor_hours_ytd = nvl(labor_hours_ytd,0) + Tsk_labor_hours_ytd,
1800 		    labor_hours_pp  = nvl(labor_hours_pp,0) + Tsk_labor_hours_pp,
1801 		    labor_hours_ptd = nvl(labor_hours_ptd,0) + Tsk_labor_hours_ptd,
1802 		    billable_quantity_itd = nvl(billable_quantity_itd,0) + Tsk_bill_quantity_itd,
1803 		    billable_quantity_ytd = nvl(billable_quantity_ytd,0) + Tsk_bill_quantity_ytd,
1804 		    billable_quantity_pp  = nvl(billable_quantity_pp,0) + Tsk_bill_quantity_pp,
1805 		    billable_quantity_ptd = nvl(billable_quantity_ptd,0) + Tsk_bill_quantity_ptd,
1809 		    billable_labor_hours_ptd = nvl(billable_labor_hours_ptd,0) + Tsk_bill_labor_hours_ptd,
1806 		    billable_labor_hours_itd = nvl(billable_labor_hours_itd,0) + Tsk_bill_labor_hours_itd,
1807 		    billable_labor_hours_ytd = nvl(billable_labor_hours_ytd,0) + Tsk_bill_labor_hours_ytd,
1808 		    billable_labor_hours_pp  = nvl(billable_labor_hours_pp,0) + Tsk_bill_labor_hours_pp,
1810 		    revenue_itd = nvl(revenue_itd,0) + Tsk_revenue_itd,
1811 		    revenue_ytd = nvl(revenue_ytd,0) + Tsk_revenue_ytd,
1812 		    revenue_pp  = nvl(revenue_pp,0) + Tsk_revenue_pp,
1813 		    revenue_ptd = nvl(revenue_ptd,0) + Tsk_revenue_ptd,
1814         	    txn_unit_of_measure = NULL,
1815 		    request_id = pa_proj_accum_main.x_request_id,
1816 		    last_updated_by = pa_proj_accum_main.x_last_updated_by,
1817 		    last_update_date = Trunc(sysdate),
1818         	    creation_date = Trunc(Sysdate),
1819 		    created_by = pa_proj_accum_main.x_created_by,
1820 		    last_update_login = pa_proj_accum_main.x_last_update_login
1821               Where PAA.Project_Accum_id     In
1822              (Select Pah.Project_Accum_id from PA_PROJECT_ACCUM_HEADERS PAH
1823               Where Pah.Project_id = x_project_id and
1824               pah.Resource_list_member_id = 0 and
1825               Pah.Task_id = 0);
1826       if sql%notfound then
1827 
1828             Select project_accum_id into v_accum_id
1829               from pa_project_accum_headers
1830              where project_id = x_project_id
1831                and task_id = 0
1832                and resource_list_member_id = 0;
1833 
1834        	   Insert into PA_PROJECT_ACCUM_ACTUALS (
1835        	    PROJECT_ACCUM_ID,RAW_COST_ITD,RAW_COST_YTD,RAW_COST_PP,RAW_COST_PTD,
1836        	    BILLABLE_RAW_COST_ITD,BILLABLE_RAW_COST_YTD,BILLABLE_RAW_COST_PP,
1837        	    BILLABLE_RAW_COST_PTD,BURDENED_COST_ITD,BURDENED_COST_YTD,
1838        	    BURDENED_COST_PP,BURDENED_COST_PTD,BILLABLE_BURDENED_COST_ITD,
1839        	    BILLABLE_BURDENED_COST_YTD,BILLABLE_BURDENED_COST_PP,
1840        	    BILLABLE_BURDENED_COST_PTD,QUANTITY_ITD,QUANTITY_YTD,QUANTITY_PP,
1841        	    QUANTITY_PTD,LABOR_HOURS_ITD,LABOR_HOURS_YTD,LABOR_HOURS_PP,
1842        	    LABOR_HOURS_PTD,BILLABLE_QUANTITY_ITD,BILLABLE_QUANTITY_YTD,
1843        	    BILLABLE_QUANTITY_PP,BILLABLE_QUANTITY_PTD,
1844        	    BILLABLE_LABOR_HOURS_ITD,BILLABLE_LABOR_HOURS_YTD,
1845        	    BILLABLE_LABOR_HOURS_PP,BILLABLE_LABOR_HOURS_PTD,REVENUE_ITD,
1846        	    REVENUE_YTD,REVENUE_PP,REVENUE_PTD,TXN_UNIT_OF_MEASURE,
1847        	    REQUEST_ID,LAST_UPDATED_BY,LAST_UPDATE_DATE,CREATION_DATE,
1848 	    CREATED_BY,LAST_UPDATE_LOGIN)
1849 	    Values (V_Accum_id,
1850 		    Tsk_raw_cost_itd,
1851 		    Tsk_raw_cost_ytd,
1852 		    Tsk_raw_cost_pp,
1853 		    Tsk_raw_cost_ptd,
1854 		    Tsk_bill_raw_cost_itd,
1855 		    Tsk_bill_raw_cost_ytd,
1856 		    Tsk_bill_raw_cost_pp,
1857 		    Tsk_bill_raw_cost_ptd,
1858 		    Tsk_burd_cost_itd,
1859 		    Tsk_burd_cost_ytd,
1860 		    Tsk_burd_cost_pp,
1861 		    Tsk_burd_cost_ptd,
1862 		    Tsk_bill_burd_cost_itd,
1863 		    Tsk_bill_burd_cost_ytd,
1864 		    Tsk_bill_burd_cost_pp,
1865 		    Tsk_bill_burd_cost_ptd,
1866 		    Tsk_quantity_itd,
1867 		    Tsk_quantity_ytd,
1868 		    Tsk_quantity_pp,
1869 		    Tsk_quantity_ptd,
1870 		    Tsk_labor_hours_itd,
1871 		    Tsk_labor_hours_ytd,
1872 		    Tsk_labor_hours_pp,
1873 		    Tsk_labor_hours_ptd,
1874 		    Tsk_bill_quantity_itd,
1875 		    Tsk_bill_quantity_ytd,
1876 		    Tsk_bill_quantity_pp,
1877 		    Tsk_bill_quantity_ptd,
1878 		    Tsk_bill_labor_hours_itd,
1879 		    Tsk_bill_labor_hours_ytd,
1880 		    Tsk_bill_labor_hours_pp,
1881 		    Tsk_bill_labor_hours_ptd,
1882 		    Tsk_revenue_itd,
1883 		    Tsk_revenue_ytd,
1884 		    Tsk_revenue_pp,
1885 		    Tsk_revenue_ptd,
1886         	    NULL,
1887 		    pa_proj_accum_main.x_request_id,
1888 		    pa_proj_accum_main.x_last_updated_by,
1889 		    Trunc(sysdate),
1890         	    Trunc(Sysdate),
1891 		    pa_proj_accum_main.x_created_by,
1892 		    pa_proj_accum_main.x_last_update_login);
1893       end if;
1894      end if;
1895      if x_commitments_flag = 'Y' and pa_proj_accum_main.x_summ_process <> 'RL' then
1896 	      UPDATE Pa_Project_Accum_Commitments PAA SET
1897 		    Cmt_Raw_cost_itd = nvl(Cmt_Raw_cost_itd,0) + Tsk_cmt_raw_cost_itd,
1898 		    Cmt_Raw_cost_ytd = nvl(Cmt_Raw_cost_ytd,0) + Tsk_cmt_raw_cost_ytd,
1899 		    Cmt_Raw_cost_pp  = nvl(Cmt_Raw_cost_pp,0) + Tsk_cmt_raw_cost_pp,
1900 		    Cmt_Raw_cost_ptd = nvl(Cmt_Raw_cost_ptd,0) + Tsk_cmt_raw_cost_ptd,
1901 		    Cmt_burdened_cost_itd = nvl(Cmt_burdened_cost_itd,0) + Tsk_cmt_burd_cost_itd,
1902 		    Cmt_burdened_cost_ytd = nvl(Cmt_burdened_cost_ytd,0) + Tsk_cmt_burd_cost_ytd,
1903 		    Cmt_burdened_cost_pp  = nvl(Cmt_burdened_cost_pp,0) + Tsk_cmt_burd_cost_pp,
1904 		    Cmt_burdened_cost_ptd = nvl(Cmt_burdened_cost_ptd,0) + Tsk_cmt_burd_cost_ptd,
1905 		    Cmt_quantity_itd = nvl(Cmt_quantity_itd,0) + Tsk_cmt_quantity_itd,
1906 		    Cmt_quantity_ytd = nvl(Cmt_quantity_ytd,0) + Tsk_cmt_quantity_ytd,
1907 		    Cmt_quantity_pp  = nvl(Cmt_quantity_pp,0) + Tsk_cmt_quantity_pp,
1908 		    Cmt_quantity_ptd = nvl(Cmt_quantity_ptd,0) + Tsk_cmt_quantity_ptd,
1909         	    cmt_unit_of_measure = NULL,
1910 		    request_id = pa_proj_accum_main.x_request_id,
1911 		    last_updated_by = pa_proj_accum_main.x_last_updated_by,
1912 		    last_update_date = Trunc(sysdate),
1913         	    creation_date = Trunc(Sysdate),
1914 		    created_by = pa_proj_accum_main.x_created_by,
1915 		    last_update_login = pa_proj_accum_main.x_last_update_login
1916               Where PAA.Project_Accum_id     In
1917              (Select Pah.Project_Accum_id from PA_PROJECT_ACCUM_HEADERS PAH
1918               Where Pah.Project_id = x_project_id and
1919               pah.Resource_list_member_id = 0 and
1920               Pah.Task_id = 0);
1921 
1925               from pa_project_accum_headers
1922             If sql%notfound then
1923 
1924             Select project_accum_id into v_accum_id
1926              where project_id = x_project_id
1927                and task_id = 0
1928                and resource_list_member_id = 0;
1929 
1930        	    Insert into PA_PROJECT_ACCUM_COMMITMENTS (
1931        	    PROJECT_ACCUM_ID,CMT_RAW_COST_ITD,CMT_RAW_COST_YTD,CMT_RAW_COST_PP,
1932             CMT_RAW_COST_PTD,
1933             CMT_BURDENED_COST_ITD,CMT_BURDENED_COST_YTD,
1934             CMT_BURDENED_COST_PP,CMT_BURDENED_COST_PTD,
1935        	    CMT_QUANTITY_ITD,CMT_QUANTITY_YTD,
1936        	    CMT_QUANTITY_PP,CMT_QUANTITY_PTD,
1937        	    CMT_UNIT_OF_MEASURE,
1938        	    LAST_UPDATED_BY,LAST_UPDATE_DATE,CREATION_DATE,CREATED_BY,
1939        	    LAST_UPDATE_LOGIN)
1940 	    Values (V_Accum_id,
1941        		    Tsk_cmt_raw_cost_itd,
1942        		    Tsk_cmt_raw_cost_ytd,
1943        		    Tsk_cmt_raw_cost_pp,
1944        		    Tsk_cmt_raw_cost_ptd,
1945        		    Tsk_cmt_burd_cost_itd,
1946        		    Tsk_cmt_burd_cost_ytd,
1947        		    Tsk_cmt_burd_cost_pp,
1948        		    Tsk_cmt_burd_cost_ptd,
1949        		    Tsk_cmt_quantity_itd,
1950        		    Tsk_cmt_quantity_ytd,
1951        		    Tsk_cmt_quantity_pp,
1952        		    Tsk_cmt_quantity_ptd,
1953 		    NULL,pa_proj_accum_main.x_last_updated_by,Trunc(sysdate),
1954         	    Trunc(Sysdate),pa_proj_accum_main.x_created_by,
1955 		    pa_proj_accum_main.x_last_update_login);
1956             end if;
1957         end if;
1958          update pa_resource_list_assignments
1959             set resource_list_accumulated_flag = 'Y'
1960           where project_id = x_project_id
1961                 and resource_list_id = nvl(x_resource_list_id,resource_list_id);
1962     -- Restore the old x_err_stack;
1963 
1964     x_err_stack := V_Old_Stack;
1965 
1966   Exception
1967    When Others Then
1968      x_err_code := SQLCODE;
1969      RAISE;
1970  End Process_Txn_Accum ;
1971 
1972 
1973  Procedure Check_Accum_Res_Tasks ( x_project_id In Number,
1974                                   x_task_id    In Number,
1975 				  x_Proj_Accum_id In Number,
1976 				  x_current_period In VARCHAR2,
1977                                   x_resource_list_id in Number,
1978                                   x_resource_list_Member_id in Number,
1979                                   x_resource_id in Number,
1980                                   x_resource_list_assignment_id in Number,
1981                                   x_create_actuals in varchar2,
1982                                   x_create_commit  in varchar2,
1983                                   x_err_stack     In Out NOCOPY Varchar2,
1984                                   x_err_stage     In Out NOCOPY Varchar2,
1985                                   x_err_code      In Out NOCOPY Number ) IS
1986 
1987  x_dummy_var	VARCHAR2(1) := NULL;
1988  V_accum_id	NUMBER	    := 0;
1989  V_old_stack    VARCHAR2(630);
1990  x_paa_flag	VARCHAR2(1) := 'Y';
1991  x_pac_flag	VARCHAR2(1) := 'Y';
1992 
1993  BEGIN
1994 
1995     V_Old_Stack := x_err_stack;
1996     x_err_stack :=
1997     x_err_stack ||'->PA_MAINT_PROJECT_ACCUMS.Check_Accum_Res_Tasks';
1998 IF P_DEBUG_MODE = 'Y' THEN /* Added Debug Profile Option Check for bug#2674619 */
1999     pa_debug.debug(x_err_stack);
2000     END IF;
2001    If x_create_actuals = 'Y' or x_create_commit = 'Y' then
2002     BEGIN
2003 	SELECT	project_accum_id INTO V_accum_id
2004 	FROM	Pa_Project_Accum_Headers PAH
2005 	WHERE	PAH.Project_id = x_project_id
2006 	AND	PAH.Task_id    = x_task_id
2007 	AND     PAH.Resource_List_Member_id = x_resource_list_member_id;
2008 
2009     EXCEPTION
2010 	WHEN NO_DATA_FOUND THEN
2011 	   Select PA_PROJECT_ACCUM_HEADERS_S.Nextval into V_Accum_id
2012 	   From Dual;
2013 
2014            Insert into PA_PROJECT_ACCUM_HEADERS
2015            (PROJECT_ACCUM_ID,PROJECT_ID,TASK_ID,ACCUM_PERIOD,RESOURCE_ID,
2016             RESOURCE_LIST_ID,RESOURCE_LIST_ASSIGNMENT_ID,
2017             RESOURCE_LIST_MEMBER_ID,LAST_UPDATED_BY,LAST_UPDATE_DATE,
2018             REQUEST_ID,CREATION_DATE,CREATED_BY,LAST_UPDATE_LOGIN )
2019             Values (v_accum_id,X_project_id,x_task_id,
2020                     x_current_period,
2021                     x_resource_id,x_resource_list_id,
2022                     x_resource_list_assignment_id,x_resource_list_Member_id,
2023                     pa_proj_accum_main.x_last_updated_by,
2024 		    Trunc(sysdate),pa_proj_accum_main.x_request_id,
2025 		    trunc(sysdate),
2026                     pa_proj_accum_main.x_created_by,
2027 		    pa_proj_accum_main.x_last_update_login );
2028 
2029           If x_create_actuals = 'Y' then
2030        	   Insert into PA_PROJECT_ACCUM_ACTUALS (
2031        	    PROJECT_ACCUM_ID,RAW_COST_ITD,RAW_COST_YTD,RAW_COST_PP,RAW_COST_PTD,
2032        	    BILLABLE_RAW_COST_ITD,BILLABLE_RAW_COST_YTD,BILLABLE_RAW_COST_PP,
2033        	    BILLABLE_RAW_COST_PTD,BURDENED_COST_ITD,BURDENED_COST_YTD,
2034        	    BURDENED_COST_PP,BURDENED_COST_PTD,BILLABLE_BURDENED_COST_ITD,
2035        	    BILLABLE_BURDENED_COST_YTD,BILLABLE_BURDENED_COST_PP,
2036        	    BILLABLE_BURDENED_COST_PTD,QUANTITY_ITD,QUANTITY_YTD,QUANTITY_PP,
2037        	    QUANTITY_PTD,LABOR_HOURS_ITD,LABOR_HOURS_YTD,LABOR_HOURS_PP,
2038        	    LABOR_HOURS_PTD,BILLABLE_QUANTITY_ITD,BILLABLE_QUANTITY_YTD,
2039        	    BILLABLE_QUANTITY_PP,BILLABLE_QUANTITY_PTD,
2040        	    BILLABLE_LABOR_HOURS_ITD,BILLABLE_LABOR_HOURS_YTD,
2041        	    BILLABLE_LABOR_HOURS_PP,BILLABLE_LABOR_HOURS_PTD,REVENUE_ITD,
2042        	    REVENUE_YTD,REVENUE_PP,REVENUE_PTD,TXN_UNIT_OF_MEASURE,
2043        	    REQUEST_ID,LAST_UPDATED_BY,LAST_UPDATE_DATE,CREATION_DATE,
2044 	    CREATED_BY,LAST_UPDATE_LOGIN)
2045 	    Values (V_Accum_id,
2046 		    New_raw_cost_itd,
2047 		    New_raw_cost_ytd,
2048 		    New_raw_cost_pp,
2049 		    New_raw_cost_ptd,
2050 		    New_bill_raw_cost_itd,
2051 		    New_bill_raw_cost_ytd,
2052 		    New_bill_raw_cost_pp,
2053 		    New_bill_raw_cost_ptd,
2054 		    New_burd_cost_itd,
2055 		    New_burd_cost_ytd,
2056 		    New_burd_cost_pp,
2057 		    New_burd_cost_ptd,
2058 		    New_bill_burd_cost_itd,
2059 		    New_bill_burd_cost_ytd,
2060 		    New_bill_burd_cost_pp,
2061 		    New_bill_burd_cost_ptd,
2062 		    New_quantity_itd,
2063 		    New_quantity_ytd,
2064 		    New_quantity_pp,
2065 		    New_quantity_ptd,
2066 		    New_labor_hours_itd,
2067 		    New_labor_hours_ytd,
2068 		    New_labor_hours_pp,
2069 		    New_labor_hours_ptd,
2070 		    New_bill_quantity_itd,
2071 		    New_bill_quantity_ytd,
2072 		    New_bill_quantity_pp,
2073 		    New_bill_quantity_ptd,
2074 		    New_bill_labor_hours_itd,
2075 		    New_bill_labor_hours_ytd,
2076 		    New_bill_labor_hours_pp,
2077 		    New_bill_labor_hours_ptd,
2078 		    New_revenue_itd,
2079 		    New_revenue_ytd,
2080 		    New_revenue_pp,
2081 		    New_revenue_ptd,
2082         	    NULL,
2083 		    pa_proj_accum_main.x_request_id,
2084 		    pa_proj_accum_main.x_last_updated_by,
2085 		    Trunc(sysdate),
2086         	    Trunc(Sysdate),
2087 		    pa_proj_accum_main.x_created_by,
2088 		    pa_proj_accum_main.x_last_update_login);
2089             end if;
2090             If x_create_commit = 'Y' then
2091        	    Insert into PA_PROJECT_ACCUM_COMMITMENTS (
2092        	    PROJECT_ACCUM_ID,CMT_RAW_COST_ITD,CMT_RAW_COST_YTD,CMT_RAW_COST_PP,
2093             CMT_RAW_COST_PTD,
2094             CMT_BURDENED_COST_ITD,CMT_BURDENED_COST_YTD,
2095             CMT_BURDENED_COST_PP,CMT_BURDENED_COST_PTD,
2096        	    CMT_QUANTITY_ITD,CMT_QUANTITY_YTD,
2097        	    CMT_QUANTITY_PP,CMT_QUANTITY_PTD,
2098        	    CMT_UNIT_OF_MEASURE,
2099        	    LAST_UPDATED_BY,LAST_UPDATE_DATE,CREATION_DATE,CREATED_BY,
2100        	    LAST_UPDATE_LOGIN)
2101 	    Values (V_Accum_id,
2102        		    New_cmt_raw_cost_itd,
2103        		    New_cmt_raw_cost_ytd,
2104        		    New_cmt_raw_cost_pp,
2105        		    New_cmt_raw_cost_ptd,
2106        		    New_cmt_burd_cost_itd,
2107        		    New_cmt_burd_cost_ytd,
2108        		    New_cmt_burd_cost_pp,
2109        		    New_cmt_burd_cost_ptd,
2110        		    New_cmt_quantity_itd,
2111        		    New_cmt_quantity_ytd,
2112        		    New_cmt_quantity_pp,
2113        		    New_cmt_quantity_ptd,
2114 		    NULL,pa_proj_accum_main.x_last_updated_by,Trunc(sysdate),
2115         	    Trunc(Sysdate),pa_proj_accum_main.x_created_by,
2116 		    pa_proj_accum_main.x_last_update_login);
2117             end if;
2118 	    x_paa_flag := 'N';
2119 	    x_pac_flag := 'N';
2120 
2121     END;
2122 
2123     IF x_paa_flag = 'Y' and x_create_actuals = 'Y' THEN
2124 
2125     BEGIN
2126 
2127 	      UPDATE Pa_Project_Accum_actuals PAA SET
2128 		    Raw_cost_itd = nvl(Raw_cost_itd,0) + New_raw_cost_itd,
2132 		    billable_raw_cost_itd = nvl(billable_raw_cost_itd,0) + New_bill_raw_cost_itd,
2129 		    Raw_cost_ytd = nvl(Raw_cost_ytd,0) + New_raw_cost_ytd,
2130 		    Raw_cost_pp  = nvl(Raw_cost_pp,0) + New_raw_cost_pp,
2131 		    Raw_cost_ptd = nvl(Raw_cost_ptd,0) + New_raw_cost_ptd,
2133 		    billable_raw_cost_ytd = nvl(billable_raw_cost_ytd,0) + New_bill_raw_cost_ytd,
2134 		    billable_raw_cost_pp  = nvl(billable_raw_cost_pp,0) + New_bill_raw_cost_pp,
2135 		    billable_raw_cost_ptd = nvl(billable_raw_cost_ptd,0) + New_bill_raw_cost_ptd,
2136 		    burdened_cost_itd = nvl(burdened_cost_itd,0) + New_burd_cost_itd,
2137 		    burdened_cost_ytd = nvl(burdened_cost_ytd,0) + New_burd_cost_ytd,
2138 		    burdened_cost_pp  = nvl(burdened_cost_pp,0) + New_burd_cost_pp,
2139 		    burdened_cost_ptd = nvl(burdened_cost_ptd,0) + New_burd_cost_ptd,
2140 		    billable_burdened_cost_itd = nvl(billable_burdened_cost_itd,0) + New_bill_burd_cost_itd,
2141 		    billable_burdened_cost_ytd = nvl(billable_burdened_cost_ytd,0) + New_bill_burd_cost_ytd,
2142 		    billable_burdened_cost_pp  = nvl(billable_burdened_cost_pp,0) + New_bill_burd_cost_pp,
2143 		    billable_burdened_cost_ptd = nvl(billable_burdened_cost_ptd,0) + New_bill_burd_cost_ptd,
2144 		    quantity_itd = nvl(quantity_itd,0) + New_quantity_itd,
2145 		    quantity_ytd = nvl(quantity_ytd,0) + New_quantity_ytd,
2146 		    quantity_pp  = nvl(quantity_pp,0) + New_quantity_pp,
2147 		    quantity_ptd = nvl(quantity_ptd,0) + New_quantity_ptd,
2148 		    labor_hours_itd = nvl(labor_hours_itd,0) + New_labor_hours_itd,
2149 		    labor_hours_ytd = nvl(labor_hours_ytd,0) + New_labor_hours_ytd,
2150 		    labor_hours_pp  = nvl(labor_hours_pp,0) + New_labor_hours_pp,
2151 		    labor_hours_ptd = nvl(labor_hours_ptd,0) + New_labor_hours_ptd,
2152 		    billable_quantity_itd = nvl(billable_quantity_itd,0) + New_bill_quantity_itd,
2153 		    billable_quantity_ytd = nvl(billable_quantity_ytd,0) + New_bill_quantity_ytd,
2154 		    billable_quantity_pp  = nvl(billable_quantity_pp,0) + New_bill_quantity_pp,
2155 		    billable_quantity_ptd = nvl(billable_quantity_ptd,0) + New_bill_quantity_ptd,
2156 		    billable_labor_hours_itd = nvl(billable_labor_hours_itd,0) + New_bill_labor_hours_itd,
2157 		    billable_labor_hours_ytd = nvl(billable_labor_hours_ytd,0) + New_bill_labor_hours_ytd,
2158 		    billable_labor_hours_pp  = nvl(billable_labor_hours_pp,0) + New_bill_labor_hours_pp,
2159 		    billable_labor_hours_ptd = nvl(billable_labor_hours_ptd,0) + New_bill_labor_hours_ptd,
2160 		    revenue_itd = nvl(revenue_itd,0) + New_revenue_itd,
2161 		    revenue_ytd = nvl(revenue_ytd,0) + New_revenue_ytd,
2162 		    revenue_pp  = nvl(revenue_pp,0) + New_revenue_pp,
2163 		    revenue_ptd = nvl(revenue_ptd,0) + New_revenue_ptd,
2164         	    txn_unit_of_measure = NULL,
2165 		    request_id = pa_proj_accum_main.x_request_id,
2166 		    last_updated_by = pa_proj_accum_main.x_last_updated_by,
2167 		    last_update_date = Trunc(sysdate),
2168         	    creation_date = Trunc(Sysdate),
2169 		    created_by = pa_proj_accum_main.x_created_by,
2170 		    last_update_login = pa_proj_accum_main.x_last_update_login
2171                Where PAA.Project_Accum_id = v_accum_id;
2172 
2173    if sql%notfound then
2174        	   Insert into PA_PROJECT_ACCUM_ACTUALS (
2175        	    PROJECT_ACCUM_ID,RAW_COST_ITD,RAW_COST_YTD,RAW_COST_PP,RAW_COST_PTD,
2176        	    BILLABLE_RAW_COST_ITD,BILLABLE_RAW_COST_YTD,BILLABLE_RAW_COST_PP,
2177        	    BILLABLE_RAW_COST_PTD,BURDENED_COST_ITD,BURDENED_COST_YTD,
2178        	    BURDENED_COST_PP,BURDENED_COST_PTD,BILLABLE_BURDENED_COST_ITD,
2179        	    BILLABLE_BURDENED_COST_YTD,BILLABLE_BURDENED_COST_PP,
2180        	    BILLABLE_BURDENED_COST_PTD,QUANTITY_ITD,QUANTITY_YTD,QUANTITY_PP,
2181        	    QUANTITY_PTD,LABOR_HOURS_ITD,LABOR_HOURS_YTD,LABOR_HOURS_PP,
2182        	    LABOR_HOURS_PTD,BILLABLE_QUANTITY_ITD,BILLABLE_QUANTITY_YTD,
2183        	    BILLABLE_QUANTITY_PP,BILLABLE_QUANTITY_PTD,
2184        	    BILLABLE_LABOR_HOURS_ITD,BILLABLE_LABOR_HOURS_YTD,
2185        	    BILLABLE_LABOR_HOURS_PP,BILLABLE_LABOR_HOURS_PTD,REVENUE_ITD,
2186        	    REVENUE_YTD,REVENUE_PP,REVENUE_PTD,TXN_UNIT_OF_MEASURE,
2187        	    REQUEST_ID,LAST_UPDATED_BY,LAST_UPDATE_DATE,CREATION_DATE,
2188 	    CREATED_BY,LAST_UPDATE_LOGIN)
2189 	    Values (V_Accum_id,
2190 		    New_raw_cost_itd,
2191 		    New_raw_cost_ytd,
2192 		    New_raw_cost_pp,
2193 		    New_raw_cost_ptd,
2194 		    New_bill_raw_cost_itd,
2195 		    New_bill_raw_cost_ytd,
2196 		    New_bill_raw_cost_pp,
2197 		    New_bill_raw_cost_ptd,
2198 		    New_burd_cost_itd,
2199 		    New_burd_cost_ytd,
2200 		    New_burd_cost_pp,
2201 		    New_burd_cost_ptd,
2202 		    New_bill_burd_cost_itd,
2203 		    New_bill_burd_cost_ytd,
2204 		    New_bill_burd_cost_pp,
2205 		    New_bill_burd_cost_ptd,
2206 		    New_quantity_itd,
2207 		    New_quantity_ytd,
2208 		    New_quantity_pp,
2209 		    New_quantity_ptd,
2210 		    New_labor_hours_itd,
2211 		    New_labor_hours_ytd,
2212 		    New_labor_hours_pp,
2213 		    New_labor_hours_ptd,
2214 		    New_bill_quantity_itd,
2215 		    New_bill_quantity_ytd,
2216 		    New_bill_quantity_pp,
2217 		    New_bill_quantity_ptd,
2218 		    New_bill_labor_hours_itd,
2219 		    New_bill_labor_hours_ytd,
2220 		    New_bill_labor_hours_pp,
2221 		    New_bill_labor_hours_ptd,
2222 		    New_revenue_itd,
2223 		    New_revenue_ytd,
2224 		    New_revenue_pp,
2225 		    New_revenue_ptd,
2226         	    NULL,
2227 		    pa_proj_accum_main.x_request_id,
2228 		    pa_proj_accum_main.x_last_updated_by,
2229 		    Trunc(sysdate),
2230         	    Trunc(Sysdate),
2231 		    pa_proj_accum_main.x_created_by,
2232 		    pa_proj_accum_main.x_last_update_login);
2233    end if;
2234 
2235     END;
2236 
2237     END IF;
2238 
2239     IF x_pac_flag = 'Y' and x_create_commit = 'Y' THEN
2240 
2241     BEGIN
2242 
2246 		    Cmt_Raw_cost_pp  = nvl(Cmt_Raw_cost_pp,0) + New_cmt_raw_cost_pp,
2243 	      UPDATE Pa_Project_Accum_Commitments PAA SET
2244 		    Cmt_Raw_cost_itd = nvl(Cmt_Raw_cost_itd,0) + New_cmt_raw_cost_itd,
2245 		    Cmt_Raw_cost_ytd = nvl(Cmt_Raw_cost_ytd,0) + New_cmt_raw_cost_ytd,
2247 		    Cmt_Raw_cost_ptd = nvl(Cmt_Raw_cost_ptd,0) + New_cmt_raw_cost_ptd,
2248 		    Cmt_burdened_cost_itd = nvl(Cmt_burdened_cost_itd,0) + New_cmt_burd_cost_itd,
2249 		    Cmt_burdened_cost_ytd = nvl(Cmt_burdened_cost_ytd,0) + New_cmt_burd_cost_ytd,
2250 		    Cmt_burdened_cost_pp  = nvl(Cmt_burdened_cost_pp,0) + New_cmt_burd_cost_pp,
2251 		    Cmt_burdened_cost_ptd = nvl(Cmt_burdened_cost_ptd,0) + New_cmt_burd_cost_ptd,
2252 		    Cmt_quantity_itd = nvl(Cmt_quantity_itd,0) + New_cmt_quantity_itd,
2253 		    Cmt_quantity_ytd = nvl(Cmt_quantity_ytd,0) + New_cmt_quantity_ytd,
2254 		    Cmt_quantity_pp  = nvl(Cmt_quantity_pp,0) + New_cmt_quantity_pp,
2255 		    Cmt_quantity_ptd = nvl(Cmt_quantity_ptd,0) + New_cmt_quantity_ptd,
2256         	    cmt_unit_of_measure = NULL,
2257 		    request_id = pa_proj_accum_main.x_request_id,
2258 		    last_updated_by = pa_proj_accum_main.x_last_updated_by,
2259 		    last_update_date = Trunc(sysdate),
2260         	    creation_date = Trunc(Sysdate),
2261 		    created_by = pa_proj_accum_main.x_created_by,
2262 		    last_update_login = pa_proj_accum_main.x_last_update_login
2263               Where PAA.Project_Accum_id = v_accum_id;
2264 
2265        if sql%notfound then
2266        	    Insert into PA_PROJECT_ACCUM_COMMITMENTS (
2267        	    PROJECT_ACCUM_ID,CMT_RAW_COST_ITD,CMT_RAW_COST_YTD,CMT_RAW_COST_PP,
2268             CMT_RAW_COST_PTD,
2269             CMT_BURDENED_COST_ITD,CMT_BURDENED_COST_YTD,
2270             CMT_BURDENED_COST_PP,CMT_BURDENED_COST_PTD,
2271        	    CMT_QUANTITY_ITD,CMT_QUANTITY_YTD,
2272        	    CMT_QUANTITY_PP,CMT_QUANTITY_PTD,
2273        	    CMT_UNIT_OF_MEASURE,
2274        	    LAST_UPDATED_BY,LAST_UPDATE_DATE,CREATION_DATE,CREATED_BY,
2275        	    LAST_UPDATE_LOGIN)
2276 	    Values (V_Accum_id,
2277        		    New_cmt_raw_cost_itd,
2278        		    New_cmt_raw_cost_ytd,
2279        		    New_cmt_raw_cost_pp,
2280        		    New_cmt_raw_cost_ptd,
2281        		    New_cmt_burd_cost_itd,
2282        		    New_cmt_burd_cost_ytd,
2283        		    New_cmt_burd_cost_pp,
2284        		    New_cmt_burd_cost_ptd,
2285        		    New_cmt_quantity_itd,
2286        		    New_cmt_quantity_ytd,
2287        		    New_cmt_quantity_pp,
2288        		    New_cmt_quantity_ptd,
2289 		    NULL,pa_proj_accum_main.x_last_updated_by,Trunc(sysdate),
2290         	    Trunc(Sysdate),pa_proj_accum_main.x_created_by,
2291 		    pa_proj_accum_main.x_last_update_login);
2292      end if;
2293     END ;
2294 
2295     END IF;
2296  End if;
2297     x_err_stack := V_Old_Stack;
2298 
2299 EXCEPTION
2300    When Others Then
2301      x_err_code := SQLCODE;
2302      RAISE;
2303 
2304  END Check_Accum_res_tasks;
2305 
2306 
2307  Procedure Check_Accum_wbs ( x_project_id In Number,
2308                                   x_task_id    In Number,
2309 				  x_Proj_Accum_id In Number,
2310 				  x_current_period In VARCHAR2,
2311                                   x_resource_list_id in Number,
2312                                   x_resource_list_Member_id in Number,
2313                                   x_resource_id in Number,
2314                                   x_resource_list_assignment_id in Number,
2315                                   x_create_wbs_actuals in varchar2,
2316                                   x_create_wbs_commit  in varchar2,
2317                                   x_err_stack     In Out NOCOPY Varchar2,
2318                                   x_err_stage     In Out NOCOPY Varchar2,
2319                                   x_err_code      In Out NOCOPY Number ) IS
2320 
2321  x_dummy_var	VARCHAR2(1) := NULL;
2322  V_accum_id	NUMBER	    := 0;
2323  V_old_stack    VARCHAR2(630);
2324  x_paa_flag	VARCHAR2(1) := 'Y';
2325  x_pac_flag	VARCHAR2(1) := 'Y';
2326 
2327  BEGIN
2328 
2329     V_Old_Stack := x_err_stack;
2330     x_err_stack :=
2331     x_err_stack ||'->PA_MAINT_PROJECT_ACCUMS.Check_Accum_WBS';
2332 IF P_DEBUG_MODE = 'Y' THEN /* Added Debug Profile Option Check for bug#2674619 */
2333     pa_debug.debug(x_err_stack);
2334     END IF;
2335    If x_create_wbs_actuals = 'Y' or x_create_wbs_commit = 'Y' then
2336     BEGIN
2337 	SELECT	project_accum_id INTO V_accum_id
2338 	FROM	Pa_Project_Accum_Headers PAH
2339 	WHERE	PAH.Project_id = x_project_id
2340 	AND	PAH.Task_id    = x_task_id
2341 	AND     PAH.Resource_List_Member_id = x_resource_list_member_id;
2342 
2343     EXCEPTION
2344 	WHEN NO_DATA_FOUND THEN
2345 	   Select PA_PROJECT_ACCUM_HEADERS_S.Nextval into V_Accum_id
2346 	   From Dual;
2347 
2348            Insert into PA_PROJECT_ACCUM_HEADERS
2349            (PROJECT_ACCUM_ID,PROJECT_ID,TASK_ID,ACCUM_PERIOD,RESOURCE_ID,
2350             RESOURCE_LIST_ID,RESOURCE_LIST_ASSIGNMENT_ID,
2351             RESOURCE_LIST_MEMBER_ID,LAST_UPDATED_BY,LAST_UPDATE_DATE,
2352             REQUEST_ID,CREATION_DATE,CREATED_BY,LAST_UPDATE_LOGIN )
2353             Values (v_accum_id,X_project_id,x_task_id,
2354                     x_current_period,
2355                     x_resource_id,x_resource_list_id,
2356                     x_resource_list_assignment_id,x_resource_list_Member_id,
2357                     pa_proj_accum_main.x_last_updated_by,
2358 		    Trunc(sysdate),pa_proj_accum_main.x_request_id,
2359 		    trunc(sysdate),
2360                     pa_proj_accum_main.x_created_by,
2361 		    pa_proj_accum_main.x_last_update_login );
2362 
2363           If x_create_wbs_actuals = 'Y' then
2364        	   Insert into PA_PROJECT_ACCUM_ACTUALS (
2365        	    PROJECT_ACCUM_ID,RAW_COST_ITD,RAW_COST_YTD,RAW_COST_PP,RAW_COST_PTD,
2369        	    BILLABLE_BURDENED_COST_YTD,BILLABLE_BURDENED_COST_PP,
2366        	    BILLABLE_RAW_COST_ITD,BILLABLE_RAW_COST_YTD,BILLABLE_RAW_COST_PP,
2367        	    BILLABLE_RAW_COST_PTD,BURDENED_COST_ITD,BURDENED_COST_YTD,
2368        	    BURDENED_COST_PP,BURDENED_COST_PTD,BILLABLE_BURDENED_COST_ITD,
2370        	    BILLABLE_BURDENED_COST_PTD,QUANTITY_ITD,QUANTITY_YTD,QUANTITY_PP,
2371        	    QUANTITY_PTD,LABOR_HOURS_ITD,LABOR_HOURS_YTD,LABOR_HOURS_PP,
2372        	    LABOR_HOURS_PTD,BILLABLE_QUANTITY_ITD,BILLABLE_QUANTITY_YTD,
2373        	    BILLABLE_QUANTITY_PP,BILLABLE_QUANTITY_PTD,
2374        	    BILLABLE_LABOR_HOURS_ITD,BILLABLE_LABOR_HOURS_YTD,
2375        	    BILLABLE_LABOR_HOURS_PP,BILLABLE_LABOR_HOURS_PTD,REVENUE_ITD,
2376        	    REVENUE_YTD,REVENUE_PP,REVENUE_PTD,TXN_UNIT_OF_MEASURE,
2377        	    REQUEST_ID,LAST_UPDATED_BY,LAST_UPDATE_DATE,CREATION_DATE,
2378 	    CREATED_BY,LAST_UPDATE_LOGIN)
2379 	    Values (V_Accum_id,
2380 		    Prt_raw_cost_itd,
2381 		    Prt_raw_cost_ytd,
2382 		    Prt_raw_cost_pp,
2383 		    Prt_raw_cost_ptd,
2384 		    Prt_bill_raw_cost_itd,
2385 		    Prt_bill_raw_cost_ytd,
2386 		    Prt_bill_raw_cost_pp,
2387 		    Prt_bill_raw_cost_ptd,
2388 		    Prt_burd_cost_itd,
2389 		    Prt_burd_cost_ytd,
2390 		    Prt_burd_cost_pp,
2391 		    Prt_burd_cost_ptd,
2392 		    Prt_bill_burd_cost_itd,
2393 		    Prt_bill_burd_cost_ytd,
2394 		    Prt_bill_burd_cost_pp,
2395 		    Prt_bill_burd_cost_ptd,
2396 		    Prt_quantity_itd,
2397 		    Prt_quantity_ytd,
2398 		    Prt_quantity_pp,
2399 		    Prt_quantity_ptd,
2400 		    Prt_labor_hours_itd,
2401 		    Prt_labor_hours_ytd,
2402 		    Prt_labor_hours_pp,
2403 		    Prt_labor_hours_ptd,
2404 		    Prt_bill_quantity_itd,
2405 		    Prt_bill_quantity_ytd,
2406 		    Prt_bill_quantity_pp,
2407 		    Prt_bill_quantity_ptd,
2408 		    Prt_bill_labor_hours_itd,
2409 		    Prt_bill_labor_hours_ytd,
2410 		    Prt_bill_labor_hours_pp,
2411 		    Prt_bill_labor_hours_ptd,
2412 		    Prt_revenue_itd,
2413 		    Prt_revenue_ytd,
2414 		    Prt_revenue_pp,
2415 		    Prt_revenue_ptd,
2416         	    NULL,
2417 		    pa_proj_accum_main.x_request_id,
2418 		    pa_proj_accum_main.x_last_updated_by,
2419 		    Trunc(sysdate),
2420         	    Trunc(Sysdate),
2421 		    pa_proj_accum_main.x_created_by,
2422 		    pa_proj_accum_main.x_last_update_login);
2423             end if;
2424             If x_create_wbs_commit = 'Y' then
2425        	    Insert into PA_PROJECT_ACCUM_COMMITMENTS (
2426        	    PROJECT_ACCUM_ID,CMT_RAW_COST_ITD,CMT_RAW_COST_YTD,CMT_RAW_COST_PP,
2427             CMT_RAW_COST_PTD,
2428             CMT_BURDENED_COST_ITD,CMT_BURDENED_COST_YTD,
2429             CMT_BURDENED_COST_PP,CMT_BURDENED_COST_PTD,
2430        	    CMT_QUANTITY_ITD,CMT_QUANTITY_YTD,
2431        	    CMT_QUANTITY_PP,CMT_QUANTITY_PTD,
2432        	    CMT_UNIT_OF_MEASURE,
2433        	    LAST_UPDATED_BY,LAST_UPDATE_DATE,CREATION_DATE,CREATED_BY,
2434        	    LAST_UPDATE_LOGIN)
2435 	    Values (V_Accum_id,
2436        		    Prt_cmt_raw_cost_itd,
2437        		    Prt_cmt_raw_cost_ytd,
2438        		    Prt_cmt_raw_cost_pp,
2439        		    Prt_cmt_raw_cost_ptd,
2440        		    Prt_cmt_burd_cost_itd,
2441        		    Prt_cmt_burd_cost_ytd,
2442        		    Prt_cmt_burd_cost_pp,
2443        		    Prt_cmt_burd_cost_ptd,
2444        		    Prt_cmt_quantity_itd,
2445        		    Prt_cmt_quantity_ytd,
2446        		    Prt_cmt_quantity_pp,
2447        		    Prt_cmt_quantity_ptd,
2448 		    NULL,pa_proj_accum_main.x_last_updated_by,Trunc(sysdate),
2449         	    Trunc(Sysdate),pa_proj_accum_main.x_created_by,
2450 		    pa_proj_accum_main.x_last_update_login);
2451             end if;
2452 	    x_paa_flag := 'N';
2453 	    x_pac_flag := 'N';
2454 
2455     END;
2456 
2457     IF x_paa_flag = 'Y' and x_create_wbs_actuals = 'Y' THEN
2458 
2459     BEGIN
2460 
2461 	      UPDATE Pa_Project_Accum_actuals PAA SET
2462 		    Raw_cost_itd = nvl(Raw_cost_itd,0) + Prt_raw_cost_itd,
2463 		    Raw_cost_ytd = nvl(Raw_cost_ytd,0) + Prt_raw_cost_ytd,
2464 		    Raw_cost_pp  = nvl(Raw_cost_pp,0) + Prt_raw_cost_pp,
2465 		    Raw_cost_ptd = nvl(Raw_cost_ptd,0) + Prt_raw_cost_ptd,
2466 		    billable_raw_cost_itd = nvl(billable_raw_cost_itd,0) + Prt_bill_raw_cost_itd,
2467 		    billable_raw_cost_ytd = nvl(billable_raw_cost_ytd,0) + Prt_bill_raw_cost_ytd,
2468 		    billable_raw_cost_pp  = nvl(billable_raw_cost_pp,0) + Prt_bill_raw_cost_pp,
2469 		    billable_raw_cost_ptd = nvl(billable_raw_cost_ptd,0) + Prt_bill_raw_cost_ptd,
2470 		    burdened_cost_itd = nvl(burdened_cost_itd,0) + Prt_burd_cost_itd,
2471 		    burdened_cost_ytd = nvl(burdened_cost_ytd,0) + Prt_burd_cost_ytd,
2472 		    burdened_cost_pp  = nvl(burdened_cost_pp,0) + Prt_burd_cost_pp,
2473 		    burdened_cost_ptd = nvl(burdened_cost_ptd,0) + Prt_burd_cost_ptd,
2474 		    billable_burdened_cost_itd = nvl(billable_burdened_cost_itd,0) + Prt_bill_burd_cost_itd,
2475 		    billable_burdened_cost_ytd = nvl(billable_burdened_cost_ytd,0) + Prt_bill_burd_cost_ytd,
2476 		    billable_burdened_cost_pp  = nvl(billable_burdened_cost_pp,0) + Prt_bill_burd_cost_pp,
2477 		    billable_burdened_cost_ptd = nvl(billable_burdened_cost_ptd,0) + Prt_bill_burd_cost_ptd,
2478 		    quantity_itd = nvl(quantity_itd,0) + Prt_quantity_itd,
2479 		    quantity_ytd = nvl(quantity_ytd,0) + Prt_quantity_ytd,
2480 		    quantity_pp  = nvl(quantity_pp,0) + Prt_quantity_pp,
2481 		    quantity_ptd = nvl(quantity_ptd,0) + Prt_quantity_ptd,
2482 		    labor_hours_itd = nvl(labor_hours_itd,0) + Prt_labor_hours_itd,
2483 		    labor_hours_ytd = nvl(labor_hours_ytd,0) + Prt_labor_hours_ytd,
2484 		    labor_hours_pp  = nvl(labor_hours_pp,0) + Prt_labor_hours_pp,
2485 		    labor_hours_ptd = nvl(labor_hours_ptd,0) + Prt_labor_hours_ptd,
2486 		    billable_quantity_itd = nvl(billable_quantity_itd,0) + Prt_bill_quantity_itd,
2490 		    billable_labor_hours_itd = nvl(billable_labor_hours_itd,0) + Prt_bill_labor_hours_itd,
2487 		    billable_quantity_ytd = nvl(billable_quantity_ytd,0) + Prt_bill_quantity_ytd,
2488 		    billable_quantity_pp  = nvl(billable_quantity_pp,0) + Prt_bill_quantity_pp,
2489 		    billable_quantity_ptd = nvl(billable_quantity_ptd,0) + Prt_bill_quantity_ptd,
2491 		    billable_labor_hours_ytd = nvl(billable_labor_hours_ytd,0) + Prt_bill_labor_hours_ytd,
2492 		    billable_labor_hours_pp  = nvl(billable_labor_hours_pp,0) + Prt_bill_labor_hours_pp,
2493 		    billable_labor_hours_ptd = nvl(billable_labor_hours_ptd,0) + Prt_bill_labor_hours_ptd,
2494 		    revenue_itd = nvl(revenue_itd,0) + Prt_revenue_itd,
2495 		    revenue_ytd = nvl(revenue_ytd,0) + Prt_revenue_ytd,
2496 		    revenue_pp  = nvl(revenue_pp,0) + Prt_revenue_pp,
2497 		    revenue_ptd = nvl(revenue_ptd,0) + Prt_revenue_ptd,
2498         	    txn_unit_of_measure = NULL,
2499 		    request_id = pa_proj_accum_main.x_request_id,
2500 		    last_updated_by = pa_proj_accum_main.x_last_updated_by,
2501 		    last_update_date = Trunc(sysdate),
2502         	    creation_date = Trunc(Sysdate),
2503 		    created_by = pa_proj_accum_main.x_created_by,
2504 		    last_update_login = pa_proj_accum_main.x_last_update_login
2505                Where PAA.Project_Accum_id = v_accum_id;
2506 
2507    if sql%notfound then
2508        	   Insert into PA_PROJECT_ACCUM_ACTUALS (
2509        	    PROJECT_ACCUM_ID,RAW_COST_ITD,RAW_COST_YTD,RAW_COST_PP,RAW_COST_PTD,
2510        	    BILLABLE_RAW_COST_ITD,BILLABLE_RAW_COST_YTD,BILLABLE_RAW_COST_PP,
2511        	    BILLABLE_RAW_COST_PTD,BURDENED_COST_ITD,BURDENED_COST_YTD,
2512        	    BURDENED_COST_PP,BURDENED_COST_PTD,BILLABLE_BURDENED_COST_ITD,
2513        	    BILLABLE_BURDENED_COST_YTD,BILLABLE_BURDENED_COST_PP,
2514        	    BILLABLE_BURDENED_COST_PTD,QUANTITY_ITD,QUANTITY_YTD,QUANTITY_PP,
2515        	    QUANTITY_PTD,LABOR_HOURS_ITD,LABOR_HOURS_YTD,LABOR_HOURS_PP,
2516        	    LABOR_HOURS_PTD,BILLABLE_QUANTITY_ITD,BILLABLE_QUANTITY_YTD,
2517        	    BILLABLE_QUANTITY_PP,BILLABLE_QUANTITY_PTD,
2518        	    BILLABLE_LABOR_HOURS_ITD,BILLABLE_LABOR_HOURS_YTD,
2519        	    BILLABLE_LABOR_HOURS_PP,BILLABLE_LABOR_HOURS_PTD,REVENUE_ITD,
2520        	    REVENUE_YTD,REVENUE_PP,REVENUE_PTD,TXN_UNIT_OF_MEASURE,
2521        	    REQUEST_ID,LAST_UPDATED_BY,LAST_UPDATE_DATE,CREATION_DATE,
2522 	    CREATED_BY,LAST_UPDATE_LOGIN)
2523 	    Values (V_Accum_id,
2524 		    Prt_raw_cost_itd,
2525 		    Prt_raw_cost_ytd,
2526 		    Prt_raw_cost_pp,
2527 		    Prt_raw_cost_ptd,
2528 		    Prt_bill_raw_cost_itd,
2529 		    Prt_bill_raw_cost_ytd,
2530 		    Prt_bill_raw_cost_pp,
2531 		    Prt_bill_raw_cost_ptd,
2532 		    Prt_burd_cost_itd,
2533 		    Prt_burd_cost_ytd,
2534 		    Prt_burd_cost_pp,
2535 		    Prt_burd_cost_ptd,
2536 		    Prt_bill_burd_cost_itd,
2537 		    Prt_bill_burd_cost_ytd,
2538 		    Prt_bill_burd_cost_pp,
2539 		    Prt_bill_burd_cost_ptd,
2540 		    Prt_quantity_itd,
2541 		    Prt_quantity_ytd,
2542 		    Prt_quantity_pp,
2543 		    Prt_quantity_ptd,
2544 		    Prt_labor_hours_itd,
2545 		    Prt_labor_hours_ytd,
2546 		    Prt_labor_hours_pp,
2547 		    Prt_labor_hours_ptd,
2548 		    Prt_bill_quantity_itd,
2549 		    Prt_bill_quantity_ytd,
2550 		    Prt_bill_quantity_pp,
2551 		    Prt_bill_quantity_ptd,
2552 		    Prt_bill_labor_hours_itd,
2553 		    Prt_bill_labor_hours_ytd,
2554 		    Prt_bill_labor_hours_pp,
2555 		    Prt_bill_labor_hours_ptd,
2556 		    Prt_revenue_itd,
2557 		    Prt_revenue_ytd,
2558 		    Prt_revenue_pp,
2559 		    Prt_revenue_ptd,
2560         	    NULL,
2561 		    pa_proj_accum_main.x_request_id,
2562 		    pa_proj_accum_main.x_last_updated_by,
2563 		    Trunc(sysdate),
2564         	    Trunc(Sysdate),
2565 		    pa_proj_accum_main.x_created_by,
2566 		    pa_proj_accum_main.x_last_update_login);
2567    end if;
2568 
2569     END;
2570 
2571     END IF;
2572 
2573     IF x_pac_flag = 'Y' and x_create_wbs_commit = 'Y' THEN
2574 
2575     BEGIN
2576 
2577 	      UPDATE Pa_Project_Accum_Commitments PAA SET
2578 		    Cmt_Raw_cost_itd = nvl(Cmt_Raw_cost_itd,0) + Prt_cmt_raw_cost_itd,
2579 		    Cmt_Raw_cost_ytd = nvl(Cmt_Raw_cost_ytd,0) + Prt_cmt_raw_cost_ytd,
2580 		    Cmt_Raw_cost_pp  = nvl(Cmt_Raw_cost_pp,0) + Prt_cmt_raw_cost_pp,
2581 		    Cmt_Raw_cost_ptd = nvl(Cmt_Raw_cost_ptd,0) + Prt_cmt_raw_cost_ptd,
2582 		    Cmt_burdened_cost_itd = nvl(Cmt_burdened_cost_itd,0) + Prt_cmt_burd_cost_itd,
2583 		    Cmt_burdened_cost_ytd = nvl(Cmt_burdened_cost_ytd,0) + Prt_cmt_burd_cost_ytd,
2584 		    Cmt_burdened_cost_pp  = nvl(Cmt_burdened_cost_pp,0) + Prt_cmt_burd_cost_pp,
2585 		    Cmt_burdened_cost_ptd = nvl(Cmt_burdened_cost_ptd,0) + Prt_cmt_burd_cost_ptd,
2586 		    Cmt_quantity_itd = nvl(Cmt_quantity_itd,0) + Prt_cmt_quantity_itd,
2587 		    Cmt_quantity_ytd = nvl(Cmt_quantity_ytd,0) + Prt_cmt_quantity_ytd,
2588 		    Cmt_quantity_pp  = nvl(Cmt_quantity_pp,0) + Prt_cmt_quantity_pp,
2589 		    Cmt_quantity_ptd = nvl(Cmt_quantity_ptd,0) + Prt_cmt_quantity_ptd,
2590         	    cmt_unit_of_measure = NULL,
2591 		    request_id = pa_proj_accum_main.x_request_id,
2592 		    last_updated_by = pa_proj_accum_main.x_last_updated_by,
2593 		    last_update_date = Trunc(sysdate),
2594         	    creation_date = Trunc(Sysdate),
2595 		    created_by = pa_proj_accum_main.x_created_by,
2596 		    last_update_login = pa_proj_accum_main.x_last_update_login
2597               Where PAA.Project_Accum_id = v_accum_id;
2598 
2599        if sql%notfound then
2600        	    Insert into PA_PROJECT_ACCUM_COMMITMENTS (
2601        	    PROJECT_ACCUM_ID,CMT_RAW_COST_ITD,CMT_RAW_COST_YTD,CMT_RAW_COST_PP,
2602             CMT_RAW_COST_PTD,
2603             CMT_BURDENED_COST_ITD,CMT_BURDENED_COST_YTD,
2604             CMT_BURDENED_COST_PP,CMT_BURDENED_COST_PTD,
2605        	    CMT_QUANTITY_ITD,CMT_QUANTITY_YTD,
2609        	    LAST_UPDATE_LOGIN)
2606        	    CMT_QUANTITY_PP,CMT_QUANTITY_PTD,
2607        	    CMT_UNIT_OF_MEASURE,
2608        	    LAST_UPDATED_BY,LAST_UPDATE_DATE,CREATION_DATE,CREATED_BY,
2610 	    Values (V_Accum_id,
2611        		    Prt_cmt_raw_cost_itd,
2612        		    Prt_cmt_raw_cost_ytd,
2613        		    Prt_cmt_raw_cost_pp,
2614        		    Prt_cmt_raw_cost_ptd,
2615        		    Prt_cmt_burd_cost_itd,
2616        		    Prt_cmt_burd_cost_ytd,
2617        		    Prt_cmt_burd_cost_pp,
2618        		    Prt_cmt_burd_cost_ptd,
2619        		    Prt_cmt_quantity_itd,
2620        		    Prt_cmt_quantity_ytd,
2621        		    Prt_cmt_quantity_pp,
2622        		    Prt_cmt_quantity_ptd,
2623 		    NULL,pa_proj_accum_main.x_last_updated_by,Trunc(sysdate),
2624         	    Trunc(Sysdate),pa_proj_accum_main.x_created_by,
2625 		    pa_proj_accum_main.x_last_update_login);
2626      end if;
2627     END ;
2628 
2629     END IF;
2630  End if;
2631     x_err_stack := V_Old_Stack;
2632 
2633 EXCEPTION
2634    When Others Then
2635      x_err_code := SQLCODE;
2636      RAISE;
2637 
2638  END Check_Accum_wbs;
2639 
2640 -- This procedure           - For the given Task Id returns all the
2641 --                          higher level tasks in the WBS (including the given
2642 --                          task) which are not in PA_PROJECT_ACCUM_HEADERS
2643 --                          (Tasks with the given Resource )
2644 
2645 Procedure   Get_all_higher_tasks     (x_project_id in Number,
2646                                       x_task_id in Number,
2647                                       x_resource_list_member_id In Number,
2648                                       x_task_array  Out NOCOPY task_id_tabtype,
2649                                       x_noof_tasks Out NOCOPY number,
2650                                       x_err_stack     In Out NOCOPY Varchar2,
2651                                       x_err_stage     In Out NOCOPY Varchar2,
2652                                       x_err_code      In Out NOCOPY Number ) IS
2653 
2654 CURSOR  Tasks_Cur IS
2655 SELECT  task_id
2656 FROM
2657 pa_tasks pt
2658 WHERE project_id = x_project_id
2659  start with task_id = x_task_id
2660  connect by prior parent_task_id = task_id;
2661 
2662 v_noof_tasks         Number := 0;
2663 V_Old_Stack       Varchar2(630);
2664 Task_Rec Tasks_Cur%ROWTYPE;
2665 Begin
2666       V_Old_Stack := x_err_stack;
2667       x_err_stack :=
2668       x_err_stack||'->PA_PROCESS_ACCUM_ACTUALS_RES.Get_all_higher_tasks';
2669 IF P_DEBUG_MODE = 'Y' THEN /* Added Debug Profile Option Check for bug#2674619 */
2670       pa_debug.debug(x_err_stack);
2671 END IF;
2672       For Task_Rec IN Tasks_Cur LOOP
2673           V_noof_tasks := v_noof_tasks + 1;
2674           x_task_array(v_noof_tasks) := Task_Rec.Task_id;
2675 
2676       END LOOP;
2677 
2678       x_noof_tasks := v_noof_tasks;
2679 
2680       -- Restore the old x_err_stack;
2681 
2682       x_err_stack := V_Old_Stack;
2683 
2684 Exception
2685    When Others Then
2686      x_err_code := SQLCODE;
2687 
2688 end Get_all_higher_tasks;
2689 
2690 Procedure Insert_Headers_tasks (X_project_id In Number,
2691                                 x_task_id In Number,
2692                                 x_current_period In Varchar2,
2693                                 x_accum_id In Number,
2694                                 x_err_stack     In Out NOCOPY Varchar2,
2695                                 x_err_stage     In Out NOCOPY Varchar2,
2696                                 x_err_code      In Out NOCOPY Number ) IS
2697 -- Insert_Headers_tasks  - Inserts Header records in the
2698 --                         PA_PROJECT_ACCUM_HEADERS table
2699 V_Old_Stack       Varchar2(630);
2700 
2701 Begin
2702 
2703       V_Old_Stack := x_err_stack;
2704       x_err_stack :=
2705 
2706       x_err_stack||'->PA_PROCESS_ACCUM_ACTUALS.Insert_Headers_tasks';
2707 IF P_DEBUG_MODE = 'Y' THEN /* Added Debug Profile Option Check for bug#2674619 */
2708       pa_debug.debug(x_err_stack);
2709       END IF;
2710 
2711         Insert into PA_PROJECT_ACCUM_HEADERS
2712         (PROJECT_ACCUM_ID,PROJECT_ID,TASK_ID,ACCUM_PERIOD,RESOURCE_ID,
2713          RESOURCE_LIST_ID,RESOURCE_LIST_ASSIGNMENT_ID,
2714          RESOURCE_LIST_MEMBER_ID,LAST_UPDATED_BY,LAST_UPDATE_DATE,
2715          CREATION_DATE,REQUEST_ID,CREATED_BY,LAST_UPDATE_LOGIN )
2716          Values (x_Accum_id,X_project_id,x_task_id,
2717                  x_current_period,
2718                  0,0,0,0,pa_proj_accum_main.x_last_updated_by,Trunc(sysdate),trunc(sysdate),
2719                  pa_proj_accum_main.x_request_id,pa_proj_accum_main.x_created_by,pa_proj_accum_main.x_last_update_login);
2720 
2721 --      Restore the old x_err_stack;
2722 
2723               x_err_stack := V_Old_Stack;
2724 Exception
2725      when dup_val_on_index then
2726         null;
2727      When Others Then
2728      x_err_code := SQLCODE;
2729      RAISE;
2730 
2731 End Insert_Headers_tasks;
2732 
2733 -- This procedure creates the records in pa_project_accum_actuals
2734 -- for all the task break down hierarachy
2735 
2736 Procedure   create_accum_actuals
2737                                 (x_project_id In Number,
2738                                  x_task_id In Number,
2739                                  x_current_period In Varchar2,
2740                                  x_Recs_processed Out NOCOPY Number,
2741                                  x_err_stack     In Out NOCOPY Varchar2,
2742                                  x_err_stage     In Out NOCOPY Varchar2,
2743                                  x_err_code      In Out NOCOPY Number )
2744 IS
2745 
2746 Recs_processed Number := 0;
2750 v_err_code Number := 0;
2747 V_Accum_id     Number := 0;
2748 V_task_array task_id_tabtype;
2749 v_noof_tasks Number := 0;
2751 other_recs_processed Number := 0;
2752 V_Old_Stack       Varchar2(630);
2753 Begin
2754    V_Old_Stack := x_err_stack;
2755    x_err_stack :=
2756    x_err_stack||'->PA_PROCESS_ACCUM_ACTUALS.create_accum_actuals';
2757    -- This checks for Actuals record in PA_PROJECT_ACCUM_ACTUALS for this
2758    -- project and task combination. It is possible that there might be a
2759    -- header record for this combination in PA_PROJECT_ACCUM_HEADERS, but
2760    -- no corresponding detail record. The procedure called below,will
2761    -- check for the existence of the detail records and if not available
2762    -- would create it.
2763 
2764    pa_accum_utils.Check_Actuals_Details
2765                              (x_project_id,
2766                               x_task_id,
2767                               0,
2768                               other_recs_processed,
2769                               x_err_stack,
2770                               x_err_stage,
2771                               x_err_code);
2772 
2773    Recs_processed := Recs_processed + other_recs_processed;
2774 
2775    -- The following procedure would return all the tasks in the given task
2776    -- WBS hierarchy, including the given task, which do not have a header
2777    -- record . The return parameter is an array of records.
2778 
2779    Get_all_higher_tasks
2780 			(x_project_id ,
2781                          x_task_id ,
2782 			 0,             -- resource_list_member_id
2783                          v_task_array,
2784                          v_noof_tasks,
2785                          x_err_stack,
2786                          x_err_stage,
2787                          x_err_code);
2788 
2789    -- If the above procedure had returned any tasks , then we need to insert
2790    -- header record and actuals record. We need to process the tasks one by one
2791    -- since we require the Accum_id for each detail record.
2792    -- Eg: If the given task (the one fetched from PA_TXN_ACCUM) was say
2793    -- 1.1.1, then the first time,    Get_all_higher_tasks would return,
2794    -- 1.1.1, 1.1,  and 1. We create three header records and three detail records
2795    -- in the Project_accum_actuals table. The next time , if the given task
2796    -- is 1.1.2, the Get_all_higher_tasks would return only 1.1.2, since
2797    -- 1.1 and 1 are already available in the Pa_project_accum_headers. Those
2798    -- two records would have been processed by the Update statements.
2799 
2800    If v_noof_tasks > 0 Then
2801        For i in 1..v_noof_tasks LOOP
2802         Select PA_PROJECT_ACCUM_HEADERS_S.Nextval into V_Accum_id
2803         From Dual;
2804         Insert_Headers_tasks
2805 			     (X_project_id,
2806                               v_task_array(i),
2807                               x_current_period,
2808                               v_accum_id,
2809                               x_err_stack,
2810                               x_err_stage,
2811                               x_err_code);
2812 
2813        Recs_processed := Recs_processed + 1;
2814        Insert into PA_PROJECT_ACCUM_ACTUALS (
2815        PROJECT_ACCUM_ID,RAW_COST_ITD,RAW_COST_YTD,RAW_COST_PP,RAW_COST_PTD,
2816        BILLABLE_RAW_COST_ITD,BILLABLE_RAW_COST_YTD,BILLABLE_RAW_COST_PP,
2817        BILLABLE_RAW_COST_PTD,BURDENED_COST_ITD,BURDENED_COST_YTD,
2818        BURDENED_COST_PP,BURDENED_COST_PTD,BILLABLE_BURDENED_COST_ITD,
2819        BILLABLE_BURDENED_COST_YTD,BILLABLE_BURDENED_COST_PP,
2820        BILLABLE_BURDENED_COST_PTD,QUANTITY_ITD,QUANTITY_YTD,QUANTITY_PP,
2821        QUANTITY_PTD,LABOR_HOURS_ITD,LABOR_HOURS_YTD,LABOR_HOURS_PP,
2822        LABOR_HOURS_PTD,BILLABLE_QUANTITY_ITD,BILLABLE_QUANTITY_YTD,
2823        BILLABLE_QUANTITY_PP,BILLABLE_QUANTITY_PTD,
2824        BILLABLE_LABOR_HOURS_ITD,BILLABLE_LABOR_HOURS_YTD,
2825        BILLABLE_LABOR_HOURS_PP,BILLABLE_LABOR_HOURS_PTD,REVENUE_ITD,
2826        REVENUE_YTD,REVENUE_PP,REVENUE_PTD,TXN_UNIT_OF_MEASURE,
2827        REQUEST_ID,LAST_UPDATED_BY,LAST_UPDATE_DATE,CREATION_DATE,CREATED_BY,
2828        LAST_UPDATE_LOGIN) Values
2829        (V_Accum_id,0,0,0,0,
2830         0,0,0,0,
2831         0,0,
2832         0,0,0,
2833         0,0,0,
2834         0,0,0,0,0,0,0,0,
2835         0,0,0,0,0,0,
2836         0,0,0,0,
2837         0,0,NULL,pa_proj_accum_main.x_request_id,pa_proj_accum_main.x_last_updated_by,Trunc(sysdate),
2838         Trunc(Sysdate),pa_proj_accum_main.x_created_by,pa_proj_accum_main.x_last_update_login);
2839         Recs_processed := Recs_processed + 1;
2840       END LOOP;
2841 
2842     End If;
2843     x_recs_processed := Recs_processed;
2844     x_err_stack := V_Old_Stack;
2845 
2846 EXCEPTION
2847     When Others then
2848     x_err_code := SQLCODE;
2849     RAISE;
2850 END create_accum_actuals;
2851 
2852 -- This procedure creates records in HEADERS/ACTUALS table for
2853 -- task/resource_list_member_id combination
2854 
2855 Procedure   create_accum_actuals_res
2856                                 (x_project_id In Number,
2857                                  x_task_id In Number,
2858                                  x_resource_list_id in Number,
2859                                  x_resource_list_Member_id in Number,
2860                                  x_resource_id in Number,
2861                                  x_resource_list_assignment_id in Number,
2862                                  x_current_period In Varchar2,
2863                                  X_Recs_processed Out NOCOPY Number,
2864                                  x_err_stack     In Out NOCOPY Varchar2,
2865                                  x_err_stage     In Out NOCOPY Varchar2,
2866                                  x_err_code      In Out NOCOPY Number ) IS
2867 
2868 CURSOR Proj_Res_level_Cur IS
2872 WHERE Project_id = X_project_id
2869 SELECT Project_Accum_Id
2870 FROM
2871 PA_PROJECT_ACCUM_HEADERS
2873 AND Task_Id = 0
2874 AND Resource_list_Member_id = X_resource_list_member_id;
2875 
2876 Recs_processed Number := 0;
2877 V_Accum_id     Number := 0;
2878 V_task_array task_id_tabtype;
2879 v_noof_tasks Number := 0;
2880 Res_Recs_processed Number := 0;
2881 V_Old_Stack       Varchar2(630);
2882 
2883 Begin
2884       V_Old_Stack := x_err_stack;
2885       x_err_stack :=
2886       X_err_stack ||'-PA_MAINT_PROJECT_ACCUM.create_accum_actual_res';
2887       -- This checks for Actuals record in PA_PROJECT_ACCUM_ACTUALS for this
2888       -- project,task and resource combination.It is possible that there might be a
2889       -- header record for this combination in PA_PROJECT_ACCUM_HEADERS, but
2890       -- no corresponding detail record. The procedure called below,will
2891       -- check for the existence of the detail records and if not available
2892       -- would create it.
2893 
2894         PA_ACCUM_UTILS.Check_Actuals_Details
2895                              (x_project_id,
2896                               x_task_id,
2897                               x_resource_list_Member_id,
2898                               Res_recs_processed,
2899                               x_err_stack,
2900                               x_err_stage,
2901                               x_err_code);
2902         Recs_processed := Recs_processed + Res_recs_processed;
2903 
2904         -- This checks for Actuals record in PA_PROJECT_ACCUM_ACTUALS for this
2905         -- project and Resource combination. It is possible that there might be a
2906         -- header record for this combination in PA_PROJECT_ACCUM_HEADERS, but
2907         -- no corresponding detail record. The procedure called below,will
2908         -- check for the existence of the detail records and if not available
2909         -- would create it.
2910 
2911         PA_ACCUM_UTILS.Check_Actuals_Details
2912                              (x_project_id,
2913                               0,
2914                               x_resource_list_Member_id,
2915                               Res_recs_processed,
2916                               x_err_stack,
2917                               x_err_stage,
2918                               x_err_code);
2919         Recs_processed := Recs_processed + Res_recs_processed;
2920 
2921         -- The following procedure would return all the tasks in the given task
2922         -- WBS hierarchy, including the given task, which do not have a header
2923         -- record . The return parameter is an array of records.
2924 
2925         v_noof_tasks := 0;
2926 
2927         Get_all_higher_tasks  (x_project_id ,
2928                                x_task_id ,
2929                                x_resource_list_member_id,
2930                                v_task_array,
2931                                v_noof_tasks,
2932                                x_err_stack,
2933                                x_err_stage,
2934                                x_err_code);
2935 
2936 -- If the above procedure had returned any tasks , then we need to insert
2937 -- header record and actuals record. We need to process the tasks one by one
2938 -- since we require the Accum_id for each detail record.
2939 -- Eg: If the given task (the one fetched from PA_TXN_ACCUM) was say
2940 -- 1.1.1, then the first time,    Get_all_higher_tasks would return,
2941 -- 1.1.1, 1.1,  and 1. We create three header records and three detail records
2942 -- in the Project_accum_actuals table. The next time , if the given task
2943 -- is 1.1.2, the Get_all_higher_tasks would return only 1.1.2, since
2944 -- 1.1 and 1 are already available in the Pa_project_accum_headers. Those
2945 -- two records would have been processed by the Update statements.
2946 
2947     If v_noof_tasks > 0 Then
2948        For i in 1..v_noof_tasks LOOP
2949         Select PA_PROJECT_ACCUM_HEADERS_S.Nextval into V_Accum_id
2950         From Dual;
2951         PA_process_accum_actuals_res.insert_headers_res
2952 			     (x_project_id,
2953                               v_task_array(i),
2954                               x_resource_list_id ,
2955                               x_resource_list_Member_id ,
2956                               x_resource_id ,
2957                               x_resource_list_assignment_id ,
2958                               x_current_period,
2959                               v_accum_id,
2960                               x_err_stack,
2961                               x_err_stage,
2962                               x_err_code);
2963        Recs_processed := Recs_processed + 1;
2964 
2965        Insert into PA_PROJECT_ACCUM_ACTUALS (
2966        PROJECT_ACCUM_ID,RAW_COST_ITD,RAW_COST_YTD,RAW_COST_PP,RAW_COST_PTD,
2967        BILLABLE_RAW_COST_ITD,BILLABLE_RAW_COST_YTD,BILLABLE_RAW_COST_PP,
2968        BILLABLE_RAW_COST_PTD,BURDENED_COST_ITD,BURDENED_COST_YTD,
2969        BURDENED_COST_PP,BURDENED_COST_PTD,BILLABLE_BURDENED_COST_ITD,
2970        BILLABLE_BURDENED_COST_YTD,BILLABLE_BURDENED_COST_PP,
2971        BILLABLE_BURDENED_COST_PTD,QUANTITY_ITD,QUANTITY_YTD,QUANTITY_PP,
2972        QUANTITY_PTD,LABOR_HOURS_ITD,LABOR_HOURS_YTD,LABOR_HOURS_PP,
2973        LABOR_HOURS_PTD,BILLABLE_QUANTITY_ITD,BILLABLE_QUANTITY_YTD,
2974        BILLABLE_QUANTITY_PP,BILLABLE_QUANTITY_PTD,
2975        BILLABLE_LABOR_HOURS_ITD,BILLABLE_LABOR_HOURS_YTD,
2976        BILLABLE_LABOR_HOURS_PP,BILLABLE_LABOR_HOURS_PTD,REVENUE_ITD,
2977        REVENUE_YTD,REVENUE_PP,REVENUE_PTD,TXN_UNIT_OF_MEASURE,
2978        REQUEST_ID,LAST_UPDATED_BY,LAST_UPDATE_DATE,CREATION_DATE,CREATED_BY,
2979        LAST_UPDATE_LOGIN) Values
2980        (V_Accum_id,0,0,0,0,
2981         0,0,0,
2982         0,0,0,
2983         0,0,0,
2984         0,0,0,
2985         0,0,0,0,0,0,0,0,
2986         0,0,0,0,
2987         0,0,0,
2988         0,0,0,0,
2992       END LOOP;
2989         0,NULL,pa_proj_accum_main.x_request_id,pa_proj_accum_main.x_last_updated_by,Trunc(sysdate),
2990         Trunc(Sysdate),pa_proj_accum_main.x_created_by,pa_proj_accum_main.x_last_update_login);
2991         Recs_processed := Recs_processed + 1;
2993     End If;
2994 -- This will check for the Project-Resource combination in the Header records
2995 -- and if not present create the Header and Detail records for Actuals
2996     Open Proj_Res_level_Cur;
2997     Fetch Proj_Res_level_Cur Into V_Accum_Id;
2998     IF Proj_Res_level_Cur%NOTFOUND Then
2999        Select PA_PROJECT_ACCUM_HEADERS_S.Nextval into V_Accum_id
3000        From Dual;
3001        PA_process_accum_actuals_res.insert_headers_res
3002                           (x_project_id,
3003                            0,
3004                            x_resource_list_id ,
3005                            x_resource_list_Member_id ,
3006                            x_resource_id ,
3007                            x_resource_list_assignment_id ,
3008                            x_current_period,
3009                            v_accum_id,
3010                            x_err_stack,
3011                            x_err_stage,
3012                            x_err_code);
3013 
3014        Recs_processed := Recs_processed + 1;
3015        Insert into PA_PROJECT_ACCUM_ACTUALS (
3016        PROJECT_ACCUM_ID,RAW_COST_ITD,RAW_COST_YTD,RAW_COST_PP,RAW_COST_PTD,
3017        BILLABLE_RAW_COST_ITD,BILLABLE_RAW_COST_YTD,BILLABLE_RAW_COST_PP,
3018        BILLABLE_RAW_COST_PTD,BURDENED_COST_ITD,BURDENED_COST_YTD,
3019        BURDENED_COST_PP,BURDENED_COST_PTD,BILLABLE_BURDENED_COST_ITD,
3020        BILLABLE_BURDENED_COST_YTD,BILLABLE_BURDENED_COST_PP,
3021        BILLABLE_BURDENED_COST_PTD,QUANTITY_ITD,QUANTITY_YTD,QUANTITY_PP,
3022        QUANTITY_PTD,LABOR_HOURS_ITD,LABOR_HOURS_YTD,LABOR_HOURS_PP,
3023        LABOR_HOURS_PTD,BILLABLE_QUANTITY_ITD,BILLABLE_QUANTITY_YTD,
3024        BILLABLE_QUANTITY_PP,BILLABLE_QUANTITY_PTD,
3025        BILLABLE_LABOR_HOURS_ITD,BILLABLE_LABOR_HOURS_YTD,
3026        BILLABLE_LABOR_HOURS_PP,BILLABLE_LABOR_HOURS_PTD,REVENUE_ITD,
3027        REVENUE_YTD,REVENUE_PP,REVENUE_PTD,TXN_UNIT_OF_MEASURE,
3028        REQUEST_ID,LAST_UPDATED_BY,LAST_UPDATE_DATE,CREATION_DATE,CREATED_BY,
3029        LAST_UPDATE_LOGIN) Values
3030        (V_Accum_id,0,0,0,0,
3031         0,0,0,
3032         0,0,0,
3033         0,0,0,
3034         0,0,0,
3035         0,0,0,0,0,0,0,0,
3036         0,0,0,0,
3037         0,0,0,
3038         0,0,0,0,
3039         0,NULL,pa_proj_accum_main.x_request_id,pa_proj_accum_main.x_last_updated_by,Trunc(sysdate),
3040         Trunc(Sysdate),pa_proj_accum_main.x_created_by,pa_proj_accum_main.x_last_update_login);
3041         Recs_processed := Recs_processed + 1;
3042     END IF;
3043     Close Proj_Res_level_Cur;
3044     x_recs_processed := Recs_processed;
3045 
3046     --  Restore the old x_err_stack;
3047 
3048     x_err_stack := V_Old_Stack;
3049 Exception
3050   When Others Then
3051        x_err_code := SQLCODE;
3052        RAISE;
3053 End create_accum_actuals_res;
3054 
3055 
3056 -- This Procedure Initializes the figures in the PA_PROJECT_ACCUM_ACTUALS
3057 -- Table. The Initialization will happen in case the current period is
3058 -- greater than the previously accumulated period. The procedure would
3059 -- be called only if the run-mod is 'I' (Incremental) .
3060 
3061   Procedure Initialize_actuals (x_project_id  In Number,
3062                                 x_accum_id    In Number,
3063                                 x_impl_opt    In Varchar2,
3064                                 x_Current_period In Varchar2,
3065                                 x_Prev_period    In Varchar2,
3066                                 x_Prev_Accum_period In Varchar2,
3067                                 x_Current_year  In Number,
3068                                 x_Prev_year     In Number,
3069                                 x_prev_accum_year In Number,
3070                                 x_current_start_date In Date,
3071                                 x_current_end_date In Date,
3072                                 x_prev_start_date In Date,
3073                                 x_prev_end_date In Date,
3074                                 x_prev_accum_start_date In Date,
3075                                 x_prev_accum_end_date In Date,
3076                                 x_err_stack     In Out NOCOPY Varchar2,
3077                                 x_err_stage     In Out NOCOPY Varchar2,
3078                                 x_err_code      In Out NOCOPY Number ) Is
3079 
3080 V_Accum_period    Varchar2(20);
3081 V_Accum_id  Number := 0;
3082 V_Old_Stack       Varchar2(630);
3083 
3084  Begin
3085 -- If previously accumulated period and current period are the same or
3086 -- there has been no accumulations so far , then do nothing.
3087       V_Old_Stack := x_err_stack;
3088       x_err_stack :=
3089       x_err_stack ||'->PA_MAINT_PROJECT_ACCUMS.Initialize_actuals';
3090 IF P_DEBUG_MODE = 'Y' THEN /* Added Debug Profile Option Check for bug#2674619 */
3091       pa_debug.debug(x_err_stack);
3092       END IF;
3093 
3094 -- If current period > previously accumulated period
3095 --   If previously accumuated period = previous period (the one previous
3096 --   to the current period ),
3097 --       If current year > year pertaining to the previously accumulated year
3098 --         Then Initialize as follows
3099 --         YTD = 0,PP = PTD, PTD = 0
3100 --       Elsif current year = previously accumulated year,
3101 --         Then Initialize as follows
3102 --         PP = PTD, PTD = 0
3103 --      End If
3104 --   Elsif previously accumulated period <> previous period
3105 --    Then
3106 --       If current year > year pertaining to the previously accumulated year
3107 --         Then Initialize as follows
3108 --         YTD = 0,PP = 0, PTD = 0
3112 --      End If
3109 --       Elsif current year = previously accumulated year,
3110 --         Then Initialize as follows
3111 --         PP = 0, PTD = 0
3113 --  End If
3114 
3115 
3116       If x_current_start_date > x_prev_accum_start_date then
3117         If X_prev_period = x_prev_accum_period then
3118             If x_current_year >  x_prev_accum_year then
3119                Update PA_PROJECT_ACCUM_ACTUALS SET
3120                RAW_COST_YTD          = 0,
3121                RAW_COST_PP = RAW_COST_PTD,
3122                RAW_COST_PTD = 0,
3123                BILLABLE_RAW_COST_YTD = 0,
3124                BILLABLE_RAW_COST_PP =BILLABLE_RAW_COST_PTD,
3125                BILLABLE_RAW_COST_PTD = 0,BURDENED_COST_YTD = 0,
3126                BURDENED_COST_PP      = BURDENED_COST_PTD,
3127                BURDENED_COST_PTD = 0,
3128                BILLABLE_BURDENED_COST_YTD = 0,
3129                BILLABLE_BURDENED_COST_PP = BILLABLE_BURDENED_COST_PTD,
3130                BILLABLE_BURDENED_COST_PTD = 0,QUANTITY_YTD = 0,
3131                QUANTITY_PP = QUANTITY_PTD,
3132                QUANTITY_PTD  = 0,LABOR_HOURS_YTD = 0,
3133                LABOR_HOURS_PP = LABOR_HOURS_PTD,
3134                LABOR_HOURS_PTD = 0,BILLABLE_QUANTITY_YTD = 0,
3135                BILLABLE_QUANTITY_PP = BILLABLE_QUANTITY_PTD,
3136                BILLABLE_QUANTITY_PTD = 0,
3137                BILLABLE_LABOR_HOURS_YTD = 0,
3138                BILLABLE_LABOR_HOURS_PP = BILLABLE_LABOR_HOURS_PTD,
3139                BILLABLE_LABOR_HOURS_PTD = 0,REVENUE_YTD = 0,
3140                REVENUE_PP = REVENUE_PTD,REVENUE_PTD = 0,
3141                LAST_UPDATED_BY = pa_proj_accum_main.x_last_updated_by,
3142                LAST_UPDATE_DATE = trunc(sysdate),
3143                LAST_UPDATE_LOGIN = pa_proj_accum_main.x_last_update_login
3144                Where Project_Accum_id IN
3145                (Select Project_Accum_id from PA_PROJECT_ACCUM_HEADERS PAH Where
3146                 PAH.Project_Id = x_project_id);
3147             Else
3148                Update PA_PROJECT_ACCUM_ACTUALS SET
3149                RAW_COST_PP   = RAW_COST_PTD,
3150                RAW_COST_PTD   = 0,
3151                BILLABLE_RAW_COST_PP  = BILLABLE_RAW_COST_PTD,
3152                BILLABLE_RAW_COST_PTD = 0,
3153                BURDENED_COST_PP      = BURDENED_COST_PTD,
3154                BURDENED_COST_PTD   = 0,
3155                BILLABLE_BURDENED_COST_PP  = BILLABLE_BURDENED_COST_PTD,
3156                BILLABLE_BURDENED_COST_PTD = 0,
3157                QUANTITY_PP           = QUANTITY_PTD,
3158                QUANTITY_PTD          = 0,
3159                LABOR_HOURS_PP        = LABOR_HOURS_PTD,
3160                LABOR_HOURS_PTD       = 0,
3161                BILLABLE_QUANTITY_PP  = BILLABLE_QUANTITY_PTD,
3162                BILLABLE_QUANTITY_PTD = 0,
3163                BILLABLE_LABOR_HOURS_PP = BILLABLE_LABOR_HOURS_PTD,
3164                BILLABLE_LABOR_HOURS_PTD  = 0,
3165                REVENUE_PP            = REVENUE_PTD,
3166                REVENUE_PTD           = 0,
3167                LAST_UPDATED_BY       = pa_proj_accum_main.x_last_updated_by,
3168                LAST_UPDATE_DATE      = trunc(sysdate),
3169                LAST_UPDATE_LOGIN     = pa_proj_accum_main.x_last_update_login
3170                Where Project_Accum_id IN
3171                (Select Project_Accum_id from PA_PROJECT_ACCUM_HEADERS PAH Where
3172                 PAH.Project_Id = x_project_id);
3173             End If;
3174         ElsIf X_prev_start_date > x_prev_accum_start_date then
3175             If x_current_year >  x_prev_accum_year then
3176                Update PA_PROJECT_ACCUM_ACTUALS SET
3177                RAW_COST_YTD = 0,RAW_COST_PP = 0,
3178                RAW_COST_PTD = 0,
3179                BILLABLE_RAW_COST_YTD = 0,
3180                BILLABLE_RAW_COST_PP =0,
3181                BILLABLE_RAW_COST_PTD = 0,BURDENED_COST_YTD = 0,
3182                BURDENED_COST_PP      = 0,
3183                BURDENED_COST_PTD = 0,
3184                BILLABLE_BURDENED_COST_YTD = 0,
3185                BILLABLE_BURDENED_COST_PP = 0,
3186                BILLABLE_BURDENED_COST_PTD = 0,QUANTITY_YTD = 0,
3187                QUANTITY_PP = 0,
3188                QUANTITY_PTD  = 0,LABOR_HOURS_YTD = 0,
3189                LABOR_HOURS_PP = 0,
3190                LABOR_HOURS_PTD = 0,BILLABLE_QUANTITY_YTD = 0,
3191                BILLABLE_QUANTITY_PP = 0,
3192                BILLABLE_QUANTITY_PTD = 0,
3193                BILLABLE_LABOR_HOURS_YTD = 0,
3194                BILLABLE_LABOR_HOURS_PP = 0,
3195                BILLABLE_LABOR_HOURS_PTD = 0,REVENUE_YTD = 0,
3196                REVENUE_PP = 0,REVENUE_PTD = 0,
3197                LAST_UPDATED_BY = pa_proj_accum_main.x_last_updated_by,
3198                LAST_UPDATE_DATE = trunc(sysdate),
3199                LAST_UPDATE_LOGIN = pa_proj_accum_main.x_last_update_login
3200                Where Project_Accum_id IN
3201                (Select Project_Accum_id from PA_PROJECT_ACCUM_HEADERS PAH Where
3202                 PAH.Project_Id = x_project_id);
3203             Else
3204                Update PA_PROJECT_ACCUM_ACTUALS SET
3205                RAW_COST_PP   = 0,
3206                RAW_COST_PTD   = 0,
3207                BILLABLE_RAW_COST_PP  = 0,
3208                BILLABLE_RAW_COST_PTD = 0,
3209                BURDENED_COST_PP      = 0,
3210                BURDENED_COST_PTD   = 0,
3211                BILLABLE_BURDENED_COST_PP  = 0,
3212                BILLABLE_BURDENED_COST_PTD = 0,
3213                QUANTITY_PP           = 0,
3214                QUANTITY_PTD          = 0,
3215                LABOR_HOURS_PP        = 0,
3216                LABOR_HOURS_PTD       = 0,
3217                BILLABLE_QUANTITY_PP  = 0,
3218                BILLABLE_QUANTITY_PTD = 0,
3219                BILLABLE_LABOR_HOURS_PP = 0,
3220                BILLABLE_LABOR_HOURS_PTD  = 0,
3221                REVENUE_PP            = 0,
3225                LAST_UPDATE_LOGIN     = pa_proj_accum_main.x_last_update_login
3222                REVENUE_PTD           = 0,
3223                LAST_UPDATED_BY       = pa_proj_accum_main.x_last_updated_by,
3224                LAST_UPDATE_DATE      = trunc(sysdate),
3226                Where Project_Accum_id IN
3227                (Select Project_Accum_id from PA_PROJECT_ACCUM_HEADERS PAH Where
3228                 PAH.Project_Id = x_project_id);
3229             End If;
3230           End If;
3231         End If;
3232 --           Update Pa_project_accum_Headers Set
3233 --             Accum_Period = x_current_period
3234 --             where Project_Id = X_Project_id;
3235 --      Restore the old x_err_stack;
3236 
3237               x_err_stack := V_Old_Stack;
3238 Exception
3239   When Others then
3240        x_err_code := SQLCODE;
3241        RAISE;
3242 End Initialize_actuals;
3243 
3244 -- This Procedure Initializes the figures in the PA_PROJECT_ACCUM_BUDGETS
3245 -- Table. The Initialization will happen in case the current period is
3246 -- greater than the previously accumulated period. The procedure would
3247 -- be called only if the run-mod is 'I' (Incremental) .Also,the initialization
3248 -- would be done only for those budget-types which are not being
3249 -- run now.
3250 
3251   Procedure Initialize_budgets (X_project_id  In Number,
3252                                 x_accum_id    In Number,
3253                                 x_impl_opt    In Varchar2,
3254                                 x_budget_type In Varchar2,
3255                                 x_Current_period In Varchar2,
3256                                 x_Prev_period    In Varchar2,
3257                                 x_Prev_Accum_period In Varchar2,
3258                                 x_Current_year  In Number,
3259                                 x_Prev_year     In Number,
3260                                 x_prev_accum_year In Number,
3261                                 x_current_start_date In Date,
3262                                 x_current_end_date In Date,
3263                                 x_prev_start_date In Date,
3264                                 x_prev_end_date In Date,
3265                                 x_prev_accum_start_date In Date,
3266                                 x_prev_accum_end_date In Date,
3267                                 x_err_stack     In Out NOCOPY Varchar2,
3268                                 x_err_stage     In Out NOCOPY Varchar2,
3269                                 x_err_code      In Out NOCOPY Number ) Is
3270 
3271 V_Old_Stack       Varchar2(630);
3272 
3273  Begin
3274       V_Old_Stack := x_err_stack;
3275       x_err_stack :=
3276       x_err_stack ||'->PA_MAINT_PROJECT_ACCUMS.Initialize_budgets';
3277 IF P_DEBUG_MODE = 'Y' THEN /* Added Debug Profile Option Check for bug#2674619 */
3278       pa_debug.debug(x_err_stack);
3279       END IF;
3280 
3281 -- If current period > previously accumulated period
3282 --   If previously accumuated period = previous period (the one previous
3283 --   to the current period ),
3284 --       If current year > year pertaining to the previously accumulated year
3285 --         Then Initialize as follows
3286 --         YTD = 0,PP = PTD, PTD = 0
3287 --       Elsif current year = previously accumulated year,
3288 --         Then Initialize as follows
3289 --         PP = PTD, PTD = 0
3290 --      End If
3291 --   Elsif previously accumulated period <> previous period
3292 --    Then
3293 --       If current year > year pertaining to the previously accumulated year
3294 --         Then Initialize as follows
3295 --         YTD = 0,PP = 0, PTD = 0
3296 --       Elsif current year = previously accumulated year,
3297 --         Then Initialize as follows
3298 --         PP = 0, PTD = 0
3299 --      End If
3300 --  End If
3301 
3302 
3303       If x_current_start_date > x_prev_accum_start_date then
3304         If X_prev_period = x_prev_accum_period then
3305             If x_current_year >  x_prev_accum_year then
3306                Update PA_PROJECT_ACCUM_BUDGETS SET
3307                BASE_RAW_COST_YTD          = 0,
3308                BASE_RAW_COST_PP           = BASE_RAW_COST_PTD,
3309                BASE_RAW_COST_PTD          = 0,
3310                ORIG_RAW_COST_YTD          = 0,
3311                ORIG_RAW_COST_PP           = ORIG_RAW_COST_PTD,
3312                ORIG_RAW_COST_PTD          = 0,
3313                BASE_BURDENED_COST_YTD     = 0,
3314                BASE_BURDENED_COST_PP      = BASE_BURDENED_COST_PTD,
3315                BASE_BURDENED_COST_PTD     = 0,
3316                ORIG_BURDENED_COST_YTD     = 0,
3317                ORIG_BURDENED_COST_PP      = ORIG_BURDENED_COST_PTD,
3318                ORIG_BURDENED_COST_PTD     = 0,
3319                BASE_QUANTITY_YTD          = 0,
3320                BASE_QUANTITY_PP           = BASE_QUANTITY_PTD,
3321                BASE_QUANTITY_PTD          = 0,
3322                ORIG_QUANTITY_YTD          = 0,
3323                ORIG_QUANTITY_PP           = ORIG_QUANTITY_PTD,
3324                ORIG_QUANTITY_PTD          = 0,
3325                BASE_LABOR_HOURS_YTD       = 0,
3326                BASE_LABOR_HOURS_PP        = BASE_LABOR_HOURS_PTD,
3327                BASE_LABOR_HOURS_PTD       = 0,
3328                ORIG_LABOR_HOURS_YTD       = 0,
3329                ORIG_LABOR_HOURS_PP        = ORIG_LABOR_HOURS_PTD,
3330                ORIG_LABOR_HOURS_PTD       = 0,
3331                BASE_REVENUE_YTD           = 0,
3332                BASE_REVENUE_PP            = BASE_REVENUE_PTD,
3333                BASE_REVENUE_PTD           = 0,
3334                LAST_UPDATED_BY            = pa_proj_accum_main.x_last_updated_by,
3335                LAST_UPDATE_DATE           = trunc(sysdate),
3336                LAST_UPDATE_LOGIN          = pa_proj_accum_main.x_last_update_login
3337                Where Project_Accum_id IN
3341             Else
3338                (Select Project_Accum_id from PA_PROJECT_ACCUM_HEADERS PAH Where
3339                 PAH.Project_Id = x_project_id) And
3340                 Budget_Type_Code <> Nvl(x_budget_type,'00');
3342                Update PA_PROJECT_ACCUM_BUDGETS SET
3343                BASE_RAW_COST_PP           = BASE_RAW_COST_PTD,
3344                BASE_RAW_COST_PTD          = 0,
3345                ORIG_RAW_COST_PP           = ORIG_RAW_COST_PTD,
3346                ORIG_RAW_COST_PTD          = 0,
3347                BASE_BURDENED_COST_PP      = BASE_BURDENED_COST_PTD,
3348                BASE_BURDENED_COST_PTD     = 0,
3349                ORIG_BURDENED_COST_PP      = ORIG_BURDENED_COST_PTD,
3350                ORIG_BURDENED_COST_PTD     = 0,
3351                BASE_QUANTITY_PP           = BASE_QUANTITY_PTD,
3352                BASE_QUANTITY_PTD          = 0,
3353                ORIG_QUANTITY_PP           = ORIG_QUANTITY_PTD,
3354                ORIG_QUANTITY_PTD          = 0,
3355                BASE_LABOR_HOURS_PP        = BASE_LABOR_HOURS_PTD,
3356                BASE_LABOR_HOURS_PTD       = 0,
3357                ORIG_LABOR_HOURS_PP        = ORIG_LABOR_HOURS_PTD,
3358                ORIG_LABOR_HOURS_PTD       = 0,
3359                BASE_REVENUE_PP            = BASE_REVENUE_PTD,
3360                BASE_REVENUE_PTD           = 0,
3361                LAST_UPDATED_BY            = pa_proj_accum_main.x_last_updated_by,
3362                LAST_UPDATE_DATE           = trunc(sysdate),
3363                LAST_UPDATE_LOGIN          = pa_proj_accum_main.x_last_update_login
3364               Where Project_Accum_id IN
3365                (Select Project_Accum_id from PA_PROJECT_ACCUM_HEADERS PAH Where
3366                 PAH.Project_Id = x_project_id) And
3367                 Budget_Type_Code <> Nvl(x_budget_type,'00');
3368             End If;
3369         ElsIf X_prev_start_date > x_prev_accum_start_date then
3370             If x_current_year >  x_prev_accum_year then
3371               Update PA_PROJECT_ACCUM_BUDGETS SET
3372                BASE_RAW_COST_YTD          = 0,
3373                BASE_RAW_COST_PP           = 0,
3374                BASE_RAW_COST_PTD          = 0,
3375                ORIG_RAW_COST_YTD          = 0,
3376                ORIG_RAW_COST_PP           = 0,
3377                ORIG_RAW_COST_PTD          = 0,
3378                BASE_BURDENED_COST_YTD     = 0,
3379                BASE_BURDENED_COST_PP      = 0,
3380                BASE_BURDENED_COST_PTD     = 0,
3381                ORIG_BURDENED_COST_YTD     = 0,
3382                ORIG_BURDENED_COST_PP      = 0,
3383                ORIG_BURDENED_COST_PTD     = 0,
3384                BASE_QUANTITY_YTD          = 0,
3385                BASE_QUANTITY_PP           = 0,
3386                BASE_QUANTITY_PTD          = 0,
3387                ORIG_QUANTITY_YTD          = 0,
3388                ORIG_QUANTITY_PP           = 0,
3389                ORIG_QUANTITY_PTD          = 0,
3390                BASE_LABOR_HOURS_YTD       = 0,
3391                BASE_LABOR_HOURS_PP        = 0,
3392                BASE_LABOR_HOURS_PTD       = 0,
3393                ORIG_LABOR_HOURS_YTD       = 0,
3394                ORIG_LABOR_HOURS_PP        = 0,
3395                ORIG_LABOR_HOURS_PTD       = 0,
3396                BASE_REVENUE_YTD           = 0,
3397                BASE_REVENUE_PP            = 0,
3398                BASE_REVENUE_PTD           = 0,
3399                LAST_UPDATED_BY = pa_proj_accum_main.x_last_updated_by,
3400                LAST_UPDATE_DATE = trunc(sysdate),
3401                LAST_UPDATE_LOGIN = pa_proj_accum_main.x_last_update_login
3402               Where Project_Accum_id IN
3403               (Select Project_Accum_id from PA_PROJECT_ACCUM_HEADERS PAH Where
3404               PAH.Project_Id = x_project_id) And
3405               Budget_Type_Code <> Nvl(x_budget_type,'00');
3406             Else
3407               Update PA_PROJECT_ACCUM_BUDGETS SET
3408                BASE_RAW_COST_PP          = 0,
3409                BASE_RAW_COST_PTD         = 0,
3410                ORIG_RAW_COST_PP          = 0,
3411                ORIG_RAW_COST_PTD         = 0,
3412                BASE_BURDENED_COST_PP     = 0,
3413                BASE_BURDENED_COST_PTD    = 0,
3414                ORIG_BURDENED_COST_PP     = 0,
3415                ORIG_BURDENED_COST_PTD    = 0,
3416                BASE_QUANTITY_PP          = 0,
3417                BASE_QUANTITY_PTD         = 0,
3418                ORIG_QUANTITY_PP          = 0,
3419                ORIG_QUANTITY_PTD         = 0,
3420                BASE_LABOR_HOURS_PP       = 0,
3421                BASE_LABOR_HOURS_PTD      = 0,
3422                ORIG_LABOR_HOURS_PP       = 0,
3423                ORIG_LABOR_HOURS_PTD      = 0,
3424                BASE_REVENUE_PP           = 0,
3425                BASE_REVENUE_PTD          = 0,
3426                LAST_UPDATED_BY           = pa_proj_accum_main.x_last_updated_by,
3427                LAST_UPDATE_DATE          = trunc(sysdate),
3428                LAST_UPDATE_LOGIN         = pa_proj_accum_main.x_last_update_login
3429               Where Project_Accum_id IN
3430                (Select Project_Accum_id from PA_PROJECT_ACCUM_HEADERS PAH Where
3431                PAH.Project_Id = x_project_id) And
3432                Budget_Type_Code <> Nvl(x_budget_type,'00');
3433             End If;
3434           End If;
3435         End If;
3436         --- Since Period has changed,and budget figures have been initialized
3437         --- we have to make the current budget version as not accumulated
3438         --- so that they get picked up , when next time budget is run
3439 
3440            Update Pa_Budget_Versions
3441            Set Resource_Accumulated_Flag ='N'
3442            Where Current_Flag = 'Y'
3443            And Project_id = x_project_id
3444            AND Budget_type_code <> nvl(x_budget_type,'00');
3445 
3446 --      Restore the old x_err_stack;
3447         x_err_stack := V_Old_Stack;
3451        RAISE;
3448 Exception
3449   When Others then
3450        x_err_code := SQLCODE;
3452 End Initialize_budgets;
3453 
3454 -- This Procedure Initializes the figures in the PA_PROJECT_ACCUM_COMMITMENTS
3455 -- Table. The Initialization will happen in case the current period is
3456 -- greater than the previously accumulated period. The procedure would
3457 -- be called only if the run-mode is 'I' (Incremental) .
3458 
3459   Procedure Initialize_commitments
3460                                (x_project_id  In Number,
3461                                 x_accum_id    In Number,
3462                                 x_impl_opt    In Varchar2,
3463                                 x_Current_period In Varchar2,
3464                                 x_Prev_period    In Varchar2,
3465                                 x_Prev_Accum_period In Varchar2,
3466                                 x_Current_year  In Number,
3467                                 x_Prev_year     In Number,
3468                                 x_prev_accum_year In Number,
3469                                 x_current_start_date In Date,
3470                                 x_current_end_date In Date,
3471                                 x_prev_start_date In Date,
3472                                 x_prev_end_date In Date,
3473                                 x_prev_accum_start_date In Date,
3474                                 x_prev_accum_end_date In Date,
3475                                 x_err_stack     In Out NOCOPY Varchar2,
3476                                 x_err_stage     In Out NOCOPY Varchar2,
3477                                 x_err_code      In Out NOCOPY Number ) Is
3478 
3479 V_Old_Stack       Varchar2(630);
3480 
3481  Begin
3482 -- If previously accumulated period and current period are the same or
3483 -- there has been no accumulations so far , then do nothing.
3484       V_Old_Stack := x_err_stack;
3485       x_err_stack :=
3486       x_err_stack ||'->PA_MAINT_PROJECT_ACCUMS.Initialize_commitments';
3487 IF P_DEBUG_MODE = 'Y' THEN /* Added Debug Profile Option Check for bug#2674619 */
3488       pa_debug.debug(x_err_stack);
3489       END IF;
3490 
3491 -- If current period > previously accumulated period
3492 --   If previously accumuated period = previous period (the one previous
3493 --   to the current period ),
3494 --       If current year > year pertaining to the previously accumulated year
3495 --         Then Initialize as follows
3496 --         YTD = 0,PP = PTD, PTD = 0
3497 --       Elsif current year = previously accumulated year,
3498 --         Then Initialize as follows
3499 --         PP = PTD, PTD = 0
3500 --      End If
3501 --   Elsif previously accumulated period <> previous period
3502 --    Then
3503 --       If current year > year pertaining to the previously accumulated year
3504 --         Then Initialize as follows
3505 --         YTD = 0,PP = 0, PTD = 0
3506 --       Elsif current year = previously accumulated year,
3507 --         Then Initialize as follows
3508 --         PP = 0, PTD = 0
3509 --      End If
3510 --  End If
3511 
3512 
3513       If x_current_start_date > x_prev_accum_start_date then
3514         If X_prev_period = x_prev_accum_period then
3515             If x_current_year >  x_prev_accum_year then
3516               Update PA_PROJECT_ACCUM_COMMITMENTS SET
3517                CMT_RAW_COST_YTD          = 0,
3518                CMT_RAW_COST_PP           = CMT_RAW_COST_PTD,
3519                CMT_RAW_COST_PTD          = 0,
3520                CMT_BURDENED_COST_YTD     = 0,
3521                CMT_BURDENED_COST_PP      = CMT_BURDENED_COST_PTD,
3522                CMT_BURDENED_COST_PTD     = 0,
3523                CMT_QUANTITY_YTD          = 0,
3524                CMT_QUANTITY_PP           = CMT_QUANTITY_PTD,
3525                CMT_QUANTITY_PTD          = 0,
3526                LAST_UPDATED_BY           = pa_proj_accum_main.x_last_updated_by,
3527                LAST_UPDATE_DATE          = trunc(sysdate),
3528                LAST_UPDATE_LOGIN         = pa_proj_accum_main.x_last_update_login
3529               Where Project_Accum_id IN
3530                (Select Project_Accum_id from PA_PROJECT_ACCUM_HEADERS PAH Where
3531                PAH.Project_Id = x_project_id);
3532             Else
3533               Update PA_PROJECT_ACCUM_COMMITMENTS SET
3534                CMT_RAW_COST_PP           = CMT_RAW_COST_PTD,
3535                CMT_RAW_COST_PTD          = 0,
3536                CMT_BURDENED_COST_PP      = CMT_BURDENED_COST_PTD,
3537                CMT_BURDENED_COST_PTD     = 0,
3538                CMT_QUANTITY_PP           = CMT_QUANTITY_PTD,
3539                CMT_QUANTITY_PTD          = 0,
3540                LAST_UPDATED_BY           = pa_proj_accum_main.x_last_updated_by,
3541                LAST_UPDATE_DATE          = trunc(sysdate),
3542                LAST_UPDATE_LOGIN         = pa_proj_accum_main.x_last_update_login
3543               Where Project_Accum_id IN
3544                (Select Project_Accum_id from PA_PROJECT_ACCUM_HEADERS PAH Where
3545                PAH.Project_Id = x_project_id);
3546             End If;
3547         ElsIf X_prev_start_date > x_prev_accum_start_date then
3548             If x_current_year >  x_prev_accum_year then
3549               Update PA_PROJECT_ACCUM_COMMITMENTS SET
3550                CMT_RAW_COST_YTD          = 0,
3551                CMT_RAW_COST_PP           = 0,
3552                CMT_RAW_COST_PTD          = 0,
3553                CMT_BURDENED_COST_YTD     = 0,
3554                CMT_BURDENED_COST_PP      = 0,
3555                CMT_BURDENED_COST_PTD     = 0,
3556                CMT_QUANTITY_YTD          = 0,
3557                CMT_QUANTITY_PP           = 0,
3558                CMT_QUANTITY_PTD          = 0,
3559                LAST_UPDATED_BY           = pa_proj_accum_main.x_last_updated_by,
3560                LAST_UPDATE_DATE          = trunc(sysdate),
3564                PAH.Project_Id = x_project_id);
3561                LAST_UPDATE_LOGIN         = pa_proj_accum_main.x_last_update_login
3562               Where Project_Accum_id IN
3563                (Select Project_Accum_id from PA_PROJECT_ACCUM_HEADERS PAH Where
3565             Else
3566               Update PA_PROJECT_ACCUM_COMMITMENTS SET
3567                CMT_RAW_COST_PP           = 0,
3568                CMT_RAW_COST_PTD          = 0,
3569                CMT_BURDENED_COST_PP      = 0,
3570                CMT_BURDENED_COST_PTD     = 0,
3571                CMT_QUANTITY_PP           = 0,
3572                CMT_QUANTITY_PTD          = 0,
3573                LAST_UPDATED_BY           = pa_proj_accum_main.x_last_updated_by,
3574                LAST_UPDATE_DATE          = trunc(sysdate),
3575                LAST_UPDATE_LOGIN         = pa_proj_accum_main.x_last_update_login
3576               Where Project_Accum_id IN
3577                (Select Project_Accum_id from PA_PROJECT_ACCUM_HEADERS PAH Where
3578                PAH.Project_Id = x_project_id);
3579             End If;
3580           End If;
3581         End If;
3582 --      Restore the old x_err_stack;
3583 
3584               x_err_stack := V_Old_Stack;
3585 Exception
3586 When Others then
3587      x_err_code := SQLCODE;
3588      RAISE;
3589 End Initialize_commitments;
3590 
3591 Procedure Initialize_task_level is
3592 begin
3593 IF P_DEBUG_MODE = 'Y' THEN /* Added Debug Profile Option Check for bug#2674619 */
3594     pa_debug.debug('Initialize_task_level');
3595     END IF;
3596 		-- Initialize amount variables
3597   			New_raw_cost_itd	:= 0;
3598   			New_raw_cost_ytd	:= 0;
3599   			New_raw_cost_ptd	:= 0;
3600   			New_raw_cost_pp 	:= 0;
3601 
3602   			New_quantity_itd	:= 0;
3603   			New_quantity_ytd	:= 0;
3604   			New_quantity_ptd	:= 0;
3605   			New_quantity_pp 	:= 0;
3606 
3607   			New_cmt_quantity_itd	:= 0;
3608   			New_cmt_quantity_ytd	:= 0;
3609   			New_cmt_quantity_ptd	:= 0;
3610   			New_cmt_quantity_pp 	:= 0;
3611 
3612   			New_bill_quantity_itd	:= 0;
3613   			New_bill_quantity_ytd	:= 0;
3614   			New_bill_quantity_ptd	:= 0;
3615   			New_bill_quantity_pp 	:= 0;
3616 
3617 	  		New_cmt_raw_cost_itd	:= 0;
3618   			New_cmt_raw_cost_ytd	:= 0;
3619   			New_cmt_raw_cost_ptd	:= 0;
3620   			New_cmt_raw_cost_pp 	:= 0;
3621 
3622   			New_burd_cost_itd	:= 0;
3623   			New_burd_cost_ytd	:= 0;
3624   			New_burd_cost_ptd	:= 0;
3625   			New_burd_cost_pp 	:= 0;
3626 
3627   			New_cmt_burd_cost_itd	:= 0;
3628   			New_cmt_burd_cost_ytd	:= 0;
3629   			New_cmt_burd_cost_ptd	:= 0;
3630   			New_cmt_burd_cost_pp    := 0;
3631 
3632   			New_labor_hours_itd	:= 0;
3633   			New_labor_hours_ytd	:= 0;
3634   			New_labor_hours_ptd	:= 0;
3635   			New_labor_hours_pp 	:= 0;
3636 
3637   			New_revenue_itd		:= 0;
3638   			New_revenue_ytd		:= 0;
3639   			New_revenue_ptd		:= 0;
3640   			New_revenue_pp 		:= 0;
3641 
3642   			New_bill_raw_cost_itd	:= 0;
3643   			New_bill_raw_cost_ytd	:= 0;
3644   			New_bill_raw_cost_ptd	:= 0;
3645   			New_bill_raw_cost_pp 	:= 0;
3646 
3647   			New_bill_burd_cost_itd	:= 0;
3648   			New_bill_burd_cost_ytd	:= 0;
3649   			New_bill_burd_cost_ptd	:= 0;
3650   			New_bill_burd_cost_pp 	:= 0;
3651 
3652   			New_bill_labor_hours_itd:= 0;
3653   			New_bill_labor_hours_ytd:= 0;
3654   			New_bill_labor_hours_ptd:= 0;
3655   			New_bill_labor_hours_pp	:= 0;
3656 
3657 end initialize_task_level;
3658 
3659 Procedure Initialize_parent_level is
3660 begin
3661     IF P_DEBUG_MODE = 'Y' THEN /* Added Debug Profile Option Check for bug#2674619 */
3662     pa_debug.debug('Initialize_parent_level');
3663     END IF;
3664 		-- Initialize amount variables
3665   			Prt_raw_cost_itd	:= 0;
3666   			Prt_raw_cost_ytd	:= 0;
3667   			Prt_raw_cost_ptd	:= 0;
3668   			Prt_raw_cost_pp 	:= 0;
3669 
3670   			Prt_quantity_itd	:= 0;
3671   			Prt_quantity_ytd	:= 0;
3672   			Prt_quantity_ptd	:= 0;
3673   			Prt_quantity_pp 	:= 0;
3674 
3675   			Prt_cmt_quantity_itd	:= 0;
3676   			Prt_cmt_quantity_ytd	:= 0;
3677   			Prt_cmt_quantity_ptd	:= 0;
3678   			Prt_cmt_quantity_pp 	:= 0;
3679 
3680   			Prt_bill_quantity_itd	:= 0;
3681   			Prt_bill_quantity_ytd	:= 0;
3682   			Prt_bill_quantity_ptd	:= 0;
3683   			Prt_bill_quantity_pp 	:= 0;
3684 
3685 	  		Prt_cmt_raw_cost_itd	:= 0;
3686   			Prt_cmt_raw_cost_ytd	:= 0;
3687   			Prt_cmt_raw_cost_ptd	:= 0;
3688   			Prt_cmt_raw_cost_pp 	:= 0;
3689 
3690   			Prt_burd_cost_itd	:= 0;
3691   			Prt_burd_cost_ytd	:= 0;
3692   			Prt_burd_cost_ptd	:= 0;
3693   			Prt_burd_cost_pp 	:= 0;
3694 
3695   			Prt_cmt_burd_cost_itd	:= 0;
3696   			Prt_cmt_burd_cost_ytd	:= 0;
3697   			Prt_cmt_burd_cost_ptd	:= 0;
3698   			Prt_cmt_burd_cost_pp    := 0;
3699 
3700   			Prt_labor_hours_itd	:= 0;
3701   			Prt_labor_hours_ytd	:= 0;
3702   			Prt_labor_hours_ptd	:= 0;
3703   			Prt_labor_hours_pp 	:= 0;
3704 
3705   			Prt_revenue_itd		:= 0;
3706   			Prt_revenue_ytd		:= 0;
3707   			Prt_revenue_ptd		:= 0;
3708   			Prt_revenue_pp 		:= 0;
3709 
3710   			Prt_bill_raw_cost_itd	:= 0;
3711   			Prt_bill_raw_cost_ytd	:= 0;
3712   			Prt_bill_raw_cost_ptd	:= 0;
3713   			Prt_bill_raw_cost_pp 	:= 0;
3714 
3715   			Prt_bill_burd_cost_itd	:= 0;
3716   			Prt_bill_burd_cost_ytd	:= 0;
3717   			Prt_bill_burd_cost_ptd	:= 0;
3718   			Prt_bill_burd_cost_pp 	:= 0;
3719 
3720   			Prt_bill_labor_hours_itd:= 0;
3721   			Prt_bill_labor_hours_ytd:= 0;
3722   			Prt_bill_labor_hours_ptd:= 0;
3726 Procedure Initialize_project_level is
3723   			Prt_bill_labor_hours_pp	:= 0;
3724 end initialize_parent_level;
3725 
3727 begin
3728     IF P_DEBUG_MODE = 'Y' THEN /* Added Debug Profile Option Check for bug#2674619 */
3729     pa_debug.debug('Initialize_project_level');
3730     END IF;
3731 		-- Initialize amount variables
3732   			Tsk_raw_cost_itd	:= 0;
3733   			Tsk_raw_cost_ytd	:= 0;
3734   			Tsk_raw_cost_ptd	:= 0;
3735   			Tsk_raw_cost_pp 	:= 0;
3736 
3737   			Tsk_quantity_itd	:= 0;
3738   			Tsk_quantity_ytd	:= 0;
3739   			Tsk_quantity_ptd	:= 0;
3740   			Tsk_quantity_pp 	:= 0;
3741 
3742   			Tsk_cmt_quantity_itd	:= 0;
3743   			Tsk_cmt_quantity_ytd	:= 0;
3744   			Tsk_cmt_quantity_ptd	:= 0;
3745   			Tsk_cmt_quantity_pp 	:= 0;
3746 
3747   			Tsk_bill_quantity_itd	:= 0;
3748   			Tsk_bill_quantity_ytd	:= 0;
3749   			Tsk_bill_quantity_ptd	:= 0;
3750   			Tsk_bill_quantity_pp 	:= 0;
3751 
3752 	  		Tsk_cmt_raw_cost_itd	:= 0;
3753   			Tsk_cmt_raw_cost_ytd	:= 0;
3754   			Tsk_cmt_raw_cost_ptd	:= 0;
3755   			Tsk_cmt_raw_cost_pp 	:= 0;
3756 
3757   			Tsk_burd_cost_itd	:= 0;
3758   			Tsk_burd_cost_ytd	:= 0;
3759   			Tsk_burd_cost_ptd	:= 0;
3760   			Tsk_burd_cost_pp 	:= 0;
3761 
3762   			Tsk_cmt_burd_cost_itd	:= 0;
3763   			Tsk_cmt_burd_cost_ytd	:= 0;
3764   			Tsk_cmt_burd_cost_ptd	:= 0;
3765   			Tsk_cmt_burd_cost_pp    := 0;
3766 
3767   			Tsk_labor_hours_itd	:= 0;
3768   			Tsk_labor_hours_ytd	:= 0;
3769   			Tsk_labor_hours_ptd	:= 0;
3770   			Tsk_labor_hours_pp 	:= 0;
3771 
3772   			Tsk_revenue_itd		:= 0;
3773   			Tsk_revenue_ytd		:= 0;
3774   			Tsk_revenue_ptd		:= 0;
3775   			Tsk_revenue_pp 		:= 0;
3776 
3777   			Tsk_bill_raw_cost_itd	:= 0;
3778   			Tsk_bill_raw_cost_ytd	:= 0;
3779   			Tsk_bill_raw_cost_ptd	:= 0;
3780   			Tsk_bill_raw_cost_pp 	:= 0;
3781 
3782   			Tsk_bill_burd_cost_itd	:= 0;
3783   			Tsk_bill_burd_cost_ytd	:= 0;
3784   			Tsk_bill_burd_cost_ptd	:= 0;
3785   			Tsk_bill_burd_cost_pp 	:= 0;
3786 
3787   			Tsk_bill_labor_hours_itd:= 0;
3788   			Tsk_bill_labor_hours_ytd:= 0;
3789   			Tsk_bill_labor_hours_ptd:= 0;
3790   			Tsk_bill_labor_hours_pp	:= 0;
3791 end initialize_project_level;
3792 
3793 Procedure Add_Project_Amounts is
3794 begin
3795     IF P_DEBUG_MODE = 'Y' THEN /* Added Debug Profile Option Check for bug#2674619 */
3796     pa_debug.debug('Add_Project_Amount');
3797     END IF;
3798   		Tsk_raw_cost_itd	:= Tsk_raw_cost_itd +
3799 					   New_raw_cost_itd;
3800   		Tsk_raw_cost_ytd	:= Tsk_raw_cost_ytd +
3801 					   New_raw_cost_ytd;
3802   		Tsk_raw_cost_ptd	:= Tsk_raw_cost_ptd +
3803 					   New_raw_cost_ptd;
3804   		Tsk_raw_cost_pp 	:= Tsk_raw_cost_pp +
3805 					   New_raw_cost_pp;
3806 
3807   		Tsk_quantity_itd	:= Tsk_quantity_itd +
3808 					   New_quantity_itd;
3809   		Tsk_quantity_ytd	:= Tsk_quantity_ytd +
3810 					   New_quantity_ytd;
3811   		Tsk_quantity_ptd	:= Tsk_quantity_ptd +
3812 					   New_quantity_ptd;
3813   		Tsk_quantity_pp 	:= Tsk_quantity_pp +
3814 					   New_quantity_pp;
3815 
3816   		Tsk_bill_quantity_itd	:= Tsk_bill_quantity_itd +
3817 					   New_bill_quantity_itd;
3818  	 	Tsk_bill_quantity_ytd	:= Tsk_bill_quantity_ytd +
3819 					   New_bill_quantity_ytd;
3820  	 	Tsk_bill_quantity_ptd	:= Tsk_bill_quantity_ptd +
3821 					   New_bill_quantity_ptd;
3822  	 	Tsk_bill_quantity_pp 	:= Tsk_bill_quantity_pp +
3823 					   New_bill_quantity_pp;
3824 
3825   		Tsk_cmt_raw_cost_itd	:= Tsk_cmt_raw_cost_itd +
3826 					   New_cmt_raw_cost_itd;
3827  	 	Tsk_cmt_raw_cost_ytd	:= Tsk_cmt_raw_cost_ytd +
3828 					   New_cmt_raw_cost_ytd;
3829  	 	Tsk_cmt_raw_cost_ptd	:= Tsk_cmt_raw_cost_ptd +
3830 					   New_cmt_raw_cost_ptd;
3831   		Tsk_cmt_raw_cost_pp 	:= Tsk_cmt_raw_cost_pp +
3832 					   New_cmt_raw_cost_pp;
3833 
3834   		Tsk_burd_cost_itd	:= Tsk_burd_cost_itd +
3835 					   New_burd_cost_itd;
3836  	 	Tsk_burd_cost_ytd	:= Tsk_burd_cost_ytd +
3837 					   New_burd_cost_ytd;
3838  	 	Tsk_burd_cost_ptd	:= Tsk_burd_cost_ptd +
3839 					   New_burd_cost_ptd;
3840  	 	Tsk_burd_cost_pp 	:= Tsk_burd_cost_pp +
3841 					   New_burd_cost_pp;
3842 
3843   		Tsk_cmt_burd_cost_itd	:= Tsk_cmt_burd_cost_itd +
3844 					   New_cmt_burd_cost_itd;
3845  	 	Tsk_cmt_burd_cost_ytd	:= Tsk_cmt_burd_cost_ytd +
3846 					   New_cmt_burd_cost_ytd;
3847  	 	Tsk_cmt_burd_cost_ptd	:= Tsk_cmt_burd_cost_ptd +
3848 					   New_cmt_burd_cost_ptd;
3849  	 	Tsk_cmt_burd_cost_pp 	:= Tsk_cmt_burd_cost_pp +
3850 					   New_cmt_burd_cost_pp;
3851 
3852   		Tsk_labor_hours_itd	:= Tsk_labor_hours_itd +
3853 					   New_labor_hours_itd;
3854  	 	Tsk_labor_hours_ytd	:= Tsk_labor_hours_ytd +
3855 					   New_labor_hours_ytd;
3856  	 	Tsk_labor_hours_ptd	:= Tsk_labor_hours_ptd +
3857 					   New_labor_hours_ptd;
3858  	 	Tsk_labor_hours_pp 	:= Tsk_labor_hours_pp+
3859 					   New_labor_hours_pp;
3860 
3861   		Tsk_revenue_itd		:= Tsk_revenue_itd +
3862 					   New_revenue_itd;
3863  	 	Tsk_revenue_ytd		:= Tsk_revenue_ytd +
3864 					   New_revenue_ytd;
3865 	  	Tsk_revenue_ptd		:= Tsk_revenue_ptd +
3866 					   New_revenue_ptd;
3867  	 	Tsk_revenue_pp 		:= Tsk_revenue_pp +
3868 					   New_revenue_pp;
3869 
3870   		Tsk_bill_raw_cost_itd	:= Tsk_bill_raw_cost_itd +
3871 					   New_bill_raw_cost_itd;
3872  	 	Tsk_bill_raw_cost_ytd	:= Tsk_bill_raw_cost_ytd +
3873 					   New_bill_raw_cost_ytd;
3874  	 	Tsk_bill_raw_cost_ptd	:= Tsk_bill_raw_cost_ptd +
3875 					   New_bill_raw_cost_ptd;
3876   		Tsk_bill_raw_cost_pp 	:= Tsk_bill_raw_cost_pp +
3877 					   New_bill_raw_cost_pp;
3878 
3882 					   New_bill_burd_cost_ytd;
3879   		Tsk_bill_burd_cost_itd	:= Tsk_bill_burd_cost_itd +
3880 					   New_bill_burd_cost_itd;
3881  	 	Tsk_bill_burd_cost_ytd	:= Tsk_bill_burd_cost_ytd +
3883   		Tsk_bill_burd_cost_ptd	:= Tsk_bill_burd_cost_ptd +
3884 					   New_bill_burd_cost_ptd;
3885   		Tsk_bill_burd_cost_pp 	:= Tsk_bill_burd_cost_pp +
3886 					   New_bill_burd_cost_pp;
3887 
3888   		Tsk_bill_labor_hours_itd :=Tsk_bill_labor_hours_itd +
3889 					   New_bill_labor_hours_itd;
3890   		Tsk_bill_labor_hours_ytd :=Tsk_bill_labor_hours_ytd +
3891 					   New_bill_labor_hours_ytd;
3892   		Tsk_bill_labor_hours_ptd :=Tsk_bill_labor_hours_ptd +
3893 					   New_bill_labor_hours_ptd;
3894   		Tsk_bill_labor_hours_pp	 :=Tsk_bill_labor_hours_pp +
3895 					   New_bill_labor_hours_pp;
3896 
3897   		Tsk_cmt_quantity_itd	:= Tsk_cmt_quantity_itd +
3898 					   New_cmt_quantity_itd;
3899   		Tsk_cmt_quantity_ytd	:= Tsk_cmt_quantity_ytd +
3900 					   New_cmt_quantity_ytd;
3901   		Tsk_cmt_quantity_ptd	:= Tsk_cmt_quantity_ptd +
3902 					   New_cmt_quantity_ptd;
3903   		Tsk_cmt_quantity_pp 	:= Tsk_cmt_quantity_pp +
3904 					   New_cmt_quantity_pp;
3905 end add_project_amounts;
3906 
3907 Procedure add_parent_amounts is
3908 begin
3909     IF P_DEBUG_MODE = 'Y' THEN /* Added Debug Profile Option Check for bug#2674619 */
3910     pa_debug.debug('Add_parent_amounts');
3911     END IF;
3912   		Prt_raw_cost_itd	:= Prt_raw_cost_itd +
3913 					   New_raw_cost_itd;
3914   		Prt_raw_cost_ytd	:= Prt_raw_cost_ytd +
3915 					   New_raw_cost_ytd;
3916   		Prt_raw_cost_ptd	:= Prt_raw_cost_ptd +
3917 					   New_raw_cost_ptd;
3918   		Prt_raw_cost_pp 	:= Prt_raw_cost_pp +
3919 					   New_raw_cost_pp;
3920 
3921   		Prt_quantity_itd	:= Prt_quantity_itd +
3922 					   New_quantity_itd;
3923   		Prt_quantity_ytd	:= Prt_quantity_ytd +
3924 					   New_quantity_ytd;
3925   		Prt_quantity_ptd	:= Prt_quantity_ptd +
3926 					   New_quantity_ptd;
3927   		Prt_quantity_pp 	:= Prt_quantity_pp +
3928 					   New_quantity_pp;
3929 
3930   		Prt_bill_quantity_itd	:= Prt_bill_quantity_itd +
3931 					   New_bill_quantity_itd;
3932  	 	Prt_bill_quantity_ytd	:= Prt_bill_quantity_ytd +
3933 					   New_bill_quantity_ytd;
3934  	 	Prt_bill_quantity_ptd	:= Prt_bill_quantity_ptd +
3935 					   New_bill_quantity_ptd;
3936  	 	Prt_bill_quantity_pp 	:= Prt_bill_quantity_pp +
3937 					   New_bill_quantity_pp;
3938 
3939   		Prt_cmt_raw_cost_itd	:= Prt_cmt_raw_cost_itd +
3940 					   New_cmt_raw_cost_itd;
3941  	 	Prt_cmt_raw_cost_ytd	:= Prt_cmt_raw_cost_ytd +
3942 					   New_cmt_raw_cost_ytd;
3943  	 	Prt_cmt_raw_cost_ptd	:= Prt_cmt_raw_cost_ptd +
3944 					   New_cmt_raw_cost_ptd;
3945   		Prt_cmt_raw_cost_pp 	:= Prt_cmt_raw_cost_pp +
3946 					   New_cmt_raw_cost_pp;
3947 
3948   		Prt_burd_cost_itd	:= Prt_burd_cost_itd +
3949 					   New_burd_cost_itd;
3950  	 	Prt_burd_cost_ytd	:= Prt_burd_cost_ytd +
3951 					   New_burd_cost_ytd;
3952  	 	Prt_burd_cost_ptd	:= Prt_burd_cost_ptd +
3953 					   New_burd_cost_ptd;
3954  	 	Prt_burd_cost_pp 	:= Prt_burd_cost_pp +
3955 					   New_burd_cost_pp;
3956 
3957   		Prt_cmt_burd_cost_itd	:= Prt_cmt_burd_cost_itd +
3958 					   New_cmt_burd_cost_itd;
3959  	 	Prt_cmt_burd_cost_ytd	:= Prt_cmt_burd_cost_ytd +
3960 					   New_cmt_burd_cost_ytd;
3961  	 	Prt_cmt_burd_cost_ptd	:= Prt_cmt_burd_cost_ptd +
3962 					   New_cmt_burd_cost_ptd;
3963  	 	Prt_cmt_burd_cost_pp 	:= Prt_cmt_burd_cost_pp +
3964 					   New_cmt_burd_cost_pp;
3965 
3966   		Prt_labor_hours_itd	:= Prt_labor_hours_itd +
3967 					   New_labor_hours_itd;
3968  	 	Prt_labor_hours_ytd	:= Prt_labor_hours_ytd +
3969 					   New_labor_hours_ytd;
3970  	 	Prt_labor_hours_ptd	:= Prt_labor_hours_ptd +
3971 					   New_labor_hours_ptd;
3972  	 	Prt_labor_hours_pp 	:= Prt_labor_hours_pp+
3973 					   New_labor_hours_pp;
3974 
3975   		Prt_revenue_itd		:= Prt_revenue_itd +
3976 					   New_revenue_itd;
3977  	 	Prt_revenue_ytd		:= Prt_revenue_ytd +
3978 					   New_revenue_ytd;
3979 	  	Prt_revenue_ptd		:= Prt_revenue_ptd +
3980 					   New_revenue_ptd;
3981  	 	Prt_revenue_pp 		:= Prt_revenue_pp +
3982 					   New_revenue_pp;
3983 
3984   		Prt_bill_raw_cost_itd	:= Prt_bill_raw_cost_itd +
3985 					   New_bill_raw_cost_itd;
3986  	 	Prt_bill_raw_cost_ytd	:= Prt_bill_raw_cost_ytd +
3987 					   New_bill_raw_cost_ytd;
3988  	 	Prt_bill_raw_cost_ptd	:= Prt_bill_raw_cost_ptd +
3989 					   New_bill_raw_cost_ptd;
3990   		Prt_bill_raw_cost_pp 	:= Prt_bill_raw_cost_pp +
3991 					   New_bill_raw_cost_pp;
3992 
3993   		Prt_bill_burd_cost_itd	:= Prt_bill_burd_cost_itd +
3994 					   New_bill_burd_cost_itd;
3995  	 	Prt_bill_burd_cost_ytd	:= Prt_bill_burd_cost_ytd +
3996 					   New_bill_burd_cost_ytd;
3997   		Prt_bill_burd_cost_ptd	:= Prt_bill_burd_cost_ptd +
3998 					   New_bill_burd_cost_ptd;
3999   		Prt_bill_burd_cost_pp 	:= Prt_bill_burd_cost_pp +
4000 					   New_bill_burd_cost_pp;
4001 
4002   		Prt_bill_labor_hours_itd :=Prt_bill_labor_hours_itd +
4003 					   New_bill_labor_hours_itd;
4004   		Prt_bill_labor_hours_ytd :=Prt_bill_labor_hours_ytd +
4005 					   New_bill_labor_hours_ytd;
4006   		Prt_bill_labor_hours_ptd :=Prt_bill_labor_hours_ptd +
4007 					   New_bill_labor_hours_ptd;
4008   		Prt_bill_labor_hours_pp	 :=Prt_bill_labor_hours_pp +
4009 					   New_bill_labor_hours_pp;
4010 
4011   		Prt_cmt_quantity_itd	:= Prt_cmt_quantity_itd +
4012 					   New_cmt_quantity_itd;
4013   		Prt_cmt_quantity_ytd	:= Prt_cmt_quantity_ytd +
4014 					   New_cmt_quantity_ytd;
4015   		Prt_cmt_quantity_ptd	:= Prt_cmt_quantity_ptd +
4016 					   New_cmt_quantity_ptd;
4017   		Prt_cmt_quantity_pp 	:= Prt_cmt_quantity_pp +
4018 					   New_cmt_quantity_pp;
4019 end add_parent_amounts;
4020 End PA_MAINT_PROJECT_ACCUMS;